/* Handler for the main window's WM_SIZE notification */ static int win32ui_window_resize( HWND hWnd, WPARAM wParam, LPARAM lParam ) { if( wParam == SIZE_MINIMIZED ) { if( !size_paused ) { size_paused = 1; fuse_emulation_pause(); /* Process UI events until the window is restored */ win32ui_process_messages( 0 ); } } else { win32display_drawing_area_resize( LOWORD( lParam ), HIWORD( lParam ), 1 ); /* Resize statusbar and inner parts */ SendMessage( fuse_hStatusWindow, WM_SIZE, wParam, lParam ); win32statusbar_resize( hWnd, wParam, lParam ); if( size_paused ) { timer_estimate_reset(); PostMessage( fuse_hWnd, WM_USER_EXIT_PROCESS_MESSAGES, 0, 0 ); size_paused = 0; fuse_emulation_unpause(); } } return 0; }
void win32statusbar_redraw( HWND hWnd, LPARAM lParam ) { DRAWITEMSTRUCT* di; HDC src_dc, dest_dc, mask_dc; RECT rc_item; HBITMAP src_bmp, src_bmp_mask; HBITMAP old_bmp, old_bmp_mask; BITMAP bmp; size_t i; int new_icons_part_width; src_bmp = 0; di = ( DRAWITEMSTRUCT* ) lParam; dest_dc = di->hDC; rc_item = di->rcItem; new_icons_part_width = 0; for( i=0; i<5; i++ ) { switch( icons_order[ i ] ) { case UI_STATUSBAR_ITEM_DISK: switch( icons_status[ UI_STATUSBAR_ITEM_DISK ] ) { case UI_STATUSBAR_STATE_NOT_AVAILABLE: src_bmp = NULL; break; case UI_STATUSBAR_STATE_ACTIVE: src_bmp = icon_disk_active; break; default: src_bmp = icon_disk_inactive; break; } break; case UI_STATUSBAR_ITEM_MOUSE: src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_MOUSE ] == UI_STATUSBAR_STATE_ACTIVE ? icon_mouse_active : icon_mouse_inactive ); break; case UI_STATUSBAR_ITEM_PAUSED: src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_PAUSED ] == UI_STATUSBAR_STATE_ACTIVE ? icon_pause_active : icon_pause_inactive ); break; case UI_STATUSBAR_ITEM_MICRODRIVE: switch( icons_status[ UI_STATUSBAR_ITEM_MICRODRIVE ] ) { case UI_STATUSBAR_STATE_NOT_AVAILABLE: src_bmp = NULL; break; case UI_STATUSBAR_STATE_ACTIVE: src_bmp = icon_mdr_active; break; default: src_bmp = icon_mdr_inactive; break; } break; case UI_STATUSBAR_ITEM_TAPE: src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_TAPE ] == UI_STATUSBAR_STATE_ACTIVE ? icon_tape_active : icon_tape_inactive ); break; } if( src_bmp != NULL ) { new_icons_part_width += icons_part_margin; /* create a bitmap mask on the fly */ GetObject( src_bmp, sizeof( bmp ), &bmp ); src_bmp_mask = CreateBitmap( bmp.bmWidth, bmp.bmHeight, 1, 1, NULL ); src_dc = CreateCompatibleDC( NULL ); mask_dc = CreateCompatibleDC( NULL ); old_bmp = SelectObject( src_dc, src_bmp ); old_bmp_mask = SelectObject( mask_dc, src_bmp_mask ); SetBkColor( src_dc, RGB( 0, 0, 0 ) ); BitBlt( mask_dc, 0, 0, bmp.bmWidth, bmp.bmHeight, src_dc, 0, 0, SRCCOPY ); BitBlt( src_dc, 0, 0, bmp.bmWidth, bmp.bmHeight, mask_dc, 0, 0, SRCINVERT ); /* blit the transparent icon onto the status bar */ SelectObject( mask_dc, src_bmp_mask ); BitBlt( dest_dc, rc_item.left + new_icons_part_width, rc_item.top + ( icons_part_height - bmp.bmHeight ) - ( 2 * icons_part_margin ), bmp.bmWidth, bmp.bmHeight, mask_dc, 0, 0, SRCAND ); SelectObject( src_dc, src_bmp ); BitBlt( dest_dc, rc_item.left + new_icons_part_width, rc_item.top + ( icons_part_height - bmp.bmHeight ) - ( 2 * icons_part_margin ), bmp.bmWidth, bmp.bmHeight, src_dc, 0, 0, SRCPAINT ); SelectObject( src_dc, old_bmp ); SelectObject( mask_dc, old_bmp_mask ); DeleteDC( src_dc ); DeleteDC( mask_dc ); DeleteObject( src_bmp_mask ); new_icons_part_width += bmp.bmWidth; } } if( new_icons_part_width > 0 ) new_icons_part_width += icons_part_margin; /* FIXME: if the calculations are correction I shouldn't be adding this */ new_icons_part_width += ( 2 * icons_part_margin ); /* Resize icons part if needed */ if( new_icons_part_width != icons_part_width ) { icons_part_width = new_icons_part_width; win32statusbar_resize( fuse_hWnd, 0, 0 ); } }