Annotation of hatari/src/statusBar.c, revision 1.1

1.1     ! root        1: /*
        !             2:   Hatari
        !             3: 
        !             4:   Status Bar icons and text
        !             5: */
        !             6: 
        !             7: #include "main.h"
        !             8: #include "screen.h"
        !             9: #include "statusBar.h"
        !            10: #include "view.h"
        !            11: 
        !            12: #define  DEFAULT_STATUS_ICON_TIME  15    // Time to show status bar icon in frames
        !            13: #define  ON_STATUS_ICON_TIME      -1     // Force icon to show all the time
        !            14: 
        !            15: STATUSICON StatusIcons[STATUS_ICON_COUNT] = {
        !            16:   { STATUS_ICONS_X_OFFSET,112,0,16,13, 0 },    // STATUS_ICON_FRAMERATE
        !            17:   { STATUS_ICONS_X_OFFSET-16,16,0,12,13, 0 },  // STATUS_ICON_FLOPPY
        !            18:   { STATUS_ICONS_X_OFFSET-28,32,0,13,13, 0 },  // STATUS_ICON_HARDDRIVE
        !            19:   { STATUS_ICONS_X_OFFSET-41,48,0,16,13, 0 },  // STATUS_ICON_PRINTER
        !            20:   { STATUS_ICONS_X_OFFSET-41,64,0,16,13, 0 },  // STATUS_ICON_RS232
        !            21:   { STATUS_ICONS_X_OFFSET-57,80,0,14,13, 0 },  // STATUS_ICON_SOUND
        !            22:   { STATUS_ICONS_X_OFFSET-71,96,0,16,13, 0 },  // STATUS_ICON_SCREEN
        !            23: };
        !            24: char *pszStatusBarHelpText = { "Press F1 for Help." };
        !            25: static char szStatusBarText[256];        // Text in status bar
        !            26: 
        !            27: //-----------------------------------------------------------------------
        !            28: /*
        !            29:   Set to display icon on status bar for at least 'x' frames
        !            30: */
        !            31: void StatusBar_SetIcon(int StatusIcon, int IconState)
        !            32: {
        !            33:   // Check state as ON, OFF or UPDATE
        !            34:   switch (IconState) {
        !            35:     case ICONSTATE_ON:
        !            36:       // Set icon to display
        !            37:       StatusIcons[StatusIcon].DisplayCount = ON_STATUS_ICON_TIME;
        !            38:       // Draw icon
        !            39:       StatusBar_DrawIcon(/*NULL,NULL,*/StatusIcon);
        !            40:       break;
        !            41:     case ICONSTATE_OFF:
        !            42:       // Set icon to off
        !            43:       StatusIcons[StatusIcon].DisplayCount = 0;
        !            44:       // Draw icon
        !            45:       StatusBar_DrawIcon(/*NULL,NULL,*/StatusIcon);
        !            46:       break;
        !            47:     case ICONSTATE_UPDATE:
        !            48:       // Is icon already on? No
        !            49:       if (StatusIcons[StatusIcon].DisplayCount==0) {
        !            50:         // Set icon to display for 'x' frames
        !            51:         StatusIcons[StatusIcon].DisplayCount = DEFAULT_STATUS_ICON_TIME;
        !            52:         // Draw icon
        !            53:         StatusBar_DrawIcon(/*NULL,NULL,*/StatusIcon);
        !            54:       }
        !            55:       else  // Keep count high
        !            56:         StatusIcons[StatusIcon].DisplayCount = DEFAULT_STATUS_ICON_TIME;
        !            57:       break;
        !            58:   }
        !            59: }
        !            60: 
        !            61: //-----------------------------------------------------------------------
        !            62: /*
        !            63:   Update icon on status bar, call once per display frame
        !            64: */
        !            65: void StatusBar_UpdateIcons(void)
        !            66: {
        !            67:   int i;
        !            68: 
        !            69:   // Adjust timers on icons and update if needed
        !            70:   for(i=0; i<STATUS_ICON_COUNT; i++) {
        !            71:     // Is on? Decrement count to zero(off)
        !            72:     if (StatusIcons[i].DisplayCount>0) {
        !            73:       StatusIcons[i].DisplayCount--;
        !            74: 
        !            75:       // Is now off? Update status bar
        !            76:       if (StatusIcons[i].DisplayCount==0)
        !            77:         StatusBar_DrawIcon(/*NULL,NULL,*/i);
        !            78:     }
        !            79:   }
        !            80: }
        !            81: 
        !            82: //-----------------------------------------------------------------------
        !            83: /*
        !            84:   Draw all icons on status bar
        !            85: */
        !            86: void StatusBar_DrawAllIcons(void)
        !            87: {
        !            88:   int i;
        !            89: /* FIXME */
        !            90: /*
        !            91:   HDC hDC,MemDC;
        !            92: 
        !            93:   // Select bitmap for icons
        !            94:   hDC = GetDC(hWnd);
        !            95:   MemDC = CreateCompatibleDC(hDC);
        !            96:   SelectObject(MemDC,Bitmaps[BITMAP_STATUSBAR_ICONS]);
        !            97: */
        !            98:   // Draw all icons with current state
        !            99:   for(i=0; i<STATUS_ICON_COUNT; i++)
        !           100:     StatusBar_DrawIcon(/*hDC,MemDC,*/i);
        !           101: /*
        !           102:   // Release icon bitmap
        !           103:   ReleaseDC(hWnd,hDC);
        !           104:   DeleteDC(MemDC);
        !           105: */
        !           106: }
        !           107: 
        !           108: //-----------------------------------------------------------------------
        !           109: /*
        !           110:   Draw a single icon on status bar
        !           111: */
        !           112: void StatusBar_DrawIcon(/*HDC hDC, HDC MemDC,*/int StatusIcon)
        !           113: {
        !           114: /* FIXME */
        !           115: /*
        !           116:   HDC DrawDC,DrawMemDC;
        !           117:   XYWH SrcBitmapPos;
        !           118:   RECT Rect;
        !           119: 
        !           120:   if (!bInFullScreen) {  // Only draw when in Window, else DirectX may draw! Doh!
        !           121:     DrawDC = hDC;
        !           122:     if (hDC==NULL)
        !           123:       DrawDC = GetDC(hWnd);
        !           124:     DrawMemDC = MemDC;
        !           125:     if (MemDC==NULL) {
        !           126:       DrawMemDC = CreateCompatibleDC(DrawDC);
        !           127:       SelectObject(DrawMemDC,Bitmaps[BITMAP_STATUSBAR_ICONS]);
        !           128:     }
        !           129: 
        !           130:     // So, are we on or off?
        !           131:     if (StatusIcons[StatusIcon].DisplayCount) {  // On
        !           132:       SrcBitmapPos.x = StatusIcons[StatusIcon].SrcBitmapPos.x;
        !           133:       SrcBitmapPos.y = StatusIcons[StatusIcon].SrcBitmapPos.y;
        !           134:     }
        !           135:     else                    // Off(grey out)
        !           136:       SrcBitmapPos.x = SrcBitmapPos.y = 0;
        !           137:     // And draw icon from bottom-right corner
        !           138:     GetClientRect(hWnd,&Rect);
        !           139:     BitBlt(DrawDC,Rect.right-StatusIcons[StatusIcon].x,Rect.bottom-STATUS_ICONS_Y_OFFSET,StatusIcons[StatusIcon].SrcBitmapPos.w,StatusIcons[StatusIcon].SrcBitmapPos.h,DrawMemDC,SrcBitmapPos.x,SrcBitmapPos.y,SRCCOPY);
        !           140: 
        !           141:     // Delete bitmap object
        !           142:     if (hDC==NULL)
        !           143:       ReleaseDC(hWnd,DrawDC);
        !           144:     if (MemDC==NULL)
        !           145:       DeleteDC(DrawMemDC);
        !           146:   }
        !           147: */
        !           148: }
        !           149: 
        !           150: //-----------------------------------------------------------------------
        !           151: /*
        !           152:   Set status bar text and update window
        !           153: */
        !           154: void StatusBar_SetText(char *pString)
        !           155: {
        !           156:   // Set text
        !           157:   strcpy(szStatusBarText,pString);
        !           158:   // And redraw, clear background
        !           159:   StatusBar_DrawText(TRUE);
        !           160: }
        !           161: 
        !           162: //-----------------------------------------------------------------------
        !           163: /*
        !           164:   Draw status bar
        !           165: */
        !           166: void StatusBar_Draw(void)
        !           167: {
        !           168: /* FIXME */
        !           169: /*
        !           170:   RECT Rect;
        !           171:   HDC hDC,MemDC;
        !           172: 
        !           173:   // Setup
        !           174:   hDC = GetDC(hWnd);
        !           175:   MemDC = CreateCompatibleDC(hDC);
        !           176: 
        !           177:   // Draw status bar, with resize icon
        !           178:   GetClientRect(hWnd,&Rect);
        !           179:   Rect.top = Rect.bottom-17;
        !           180:   View_DrawBackgroundRect(hDC,&Rect);
        !           181:   SelectObject(MemDC,Bitmaps[BITMAP_RESIZE]);
        !           182:   BitBlt(hDC,Rect.right-16,Rect.bottom-14,14,14,MemDC,0,0,SRCCOPY);
        !           183:   
        !           184:   // Complete
        !           185:   ReleaseDC(hWnd,hDC);
        !           186:   DeleteDC(MemDC);
        !           187: 
        !           188:   // And draw text, don't clear background as already done
        !           189:   StatusBar_DrawText(FALSE);
        !           190:   // And icons
        !           191:   StatusBar_DrawAllIcons();
        !           192: */
        !           193: }
        !           194: 
        !           195: //-----------------------------------------------------------------------
        !           196: /*
        !           197:   Draw text into status bar
        !           198: */
        !           199: void StatusBar_DrawText(BOOL bClearBackground)
        !           200: {
        !           201: /* FIXME */
        !           202: /*
        !           203:   HFONT OldFont;
        !           204:   RECT Rect,ClearRect;
        !           205:   HDC hDC;
        !           206:   int x,y;
        !           207: 
        !           208:   if (!bInFullScreen) {  // Only draw when in Window, else DirectX may draw! Doh!
        !           209:     hDC = GetDC(hWnd);
        !           210: 
        !           211:     // Find where status bar is!
        !           212:     GetClientRect(hWnd,&Rect);
        !           213: 
        !           214:     // Clear status bar - just text area
        !           215:     ClearRect = Rect;
        !           216:     ClearRect.left = STATUS_TEXT_X_OFFSET;
        !           217:     ClearRect.right -= STATUS_ICONS_X_OFFSET;
        !           218:     ClearRect.top = ClearRect.bottom - STATUS_ICONS_Y_OFFSET;
        !           219:     ClearRect.bottom -= 1;
        !           220:     View_DrawBackgroundRect(hDC,&ClearRect);
        !           221: 
        !           222:     // Find coords to place text
        !           223:     x = Rect.left + STATUS_TEXT_X_OFFSET;
        !           224:     y = Rect.bottom - STATUS_ICONS_Y_OFFSET;
        !           225: 
        !           226:     // Draw new text string
        !           227:     SetBkMode(hDC,TRANSPARENT);          // Font
        !           228:     OldFont = (HFONT)SelectObject(hDC,(HFONT)GetStockObject(ANSI_VAR_FONT));
        !           229:     TextOut(hDC,x,y,szStatusBarText,strlen(szStatusBarText));
        !           230:     SelectObject(hDC,OldFont);
        !           231: 
        !           232:     ReleaseDC(hWnd,hDC);
        !           233:   }
        !           234: */
        !           235: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.