static void ShowWnd( HWND hwnd ) { if( hwnd == NULLHANDLE ) { GUIError( LIT( Open_Failed ) ); } else { _wpi_showwindow( hwnd, SW_SHOWNORMAL ); _wpi_updatewindow( hwnd ); } }
void GUIControlDirty( gui_window *wnd, gui_ctl_id id ) { HWND control; control = _wpi_getdlgitem( wnd->hwnd, id ); if( control != NULLHANDLE ) { //GUIInvalidatePaintHandles( wnd ); // not 100% sure this is required _wpi_invalidaterect( control, NULL, TRUE ); _wpi_updatewindow( control ); } }
void GUIWndDirty( gui_window *wnd ) { gui_window *curr; if( wnd == NULL ) { for( curr = GUIGetFront(); curr != NULL; curr = GUIGetNextWindow( curr ) ) { if( GUIGetParentFrameHWND( curr ) != NULLHANDLE ) { GUIWndDirty( curr ); } } } else { //GUIInvalidatePaintHandles( wnd ); _wpi_invalidaterect( wnd->hwnd, NULL, TRUE ); wnd->flags &= ~NEEDS_RESIZE_REDRAW; _wpi_updatewindow( wnd->hwnd ); } }
/* * doRestore - handle restoring an edit window */ static void doRestore( HWND hwnd ) { DWORD style; mdi_data *md; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; md = MDI_DATA_FROM_HWND( hwnd ); if( md->curr_state == STATE_NORMAL ) { return; } if( mdiInfo.start_max_restore != NULL ) { mdiInfo.start_max_restore( hwnd ); } md->curr_state = md->orig_state = STATE_NORMAL; if( mdiInfo.set_style != NULL ) { (mdiInfo.set_style)( hwnd, FALSE ); } else { style = _wpi_getwindowlong( hwnd, GWL_STYLE ); style &= ~mdiInfo.max_style; style |= mdiInfo.reg_style; _wpi_setwindowlong( hwnd, GWL_STYLE, style ); } _wpi_setscrollrange( hwnd, SB_VERT, 1, 1, TRUE ); _wpi_setscrollrange( hwnd, SB_HORZ, 1, 1, TRUE ); _wpi_updatewindow( hwnd ); _wpi_getrectvalues( md->orig_size, &left, &top, &right, &bottom ); _wpi_movewindow( hwnd, left, top, right - left, bottom - top, TRUE ); if( mdiInfo.end_max_restore != NULL ) { mdiInfo.end_max_restore( hwnd ); } } /* doRestore */
bool GUIChangeToolBar( gui_window *wnd ) { gui_event gui_ev; toolbarinfo *tbar; HWND toolhwnd; int t; GUI_RECTDIM left, top, right, bottom; tbar = wnd->tbinfo; if( !tbar->info.is_fixed ) { tbar->info.is_fixed = true; tbar->info.style = TOOLBAR_FIXED_STYLE; tbar->info.area = tbar->fixedrect; gui_ev = GUI_TOOLBAR_FIXED; } else { tbar->info.is_fixed = false; tbar->info.style = TOOLBAR_FLOAT_STYLE; tbar->info.area = tbar->floatrect; _wpi_cvtc_rect_plus1( wnd->root, &tbar->info.area ); gui_ev = GUI_TOOLBAR_FLOATING; } ToolBarDisplay( tbar->hdl, &tbar->info ); if( tbar->info.style != TOOLBAR_FLOAT_STYLE ) { ToolBarRedrawButtons( tbar->hdl ); } toolhwnd = ToolBarWindow( tbar->hdl ); if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) { _wpi_getrectvalues( tbar->floatrect, &left, &top, &right, &bottom ); t = top; //t = _wpi_cvtc_y_size( wnd->hwnd, t, bottom - top ); t = _wpi_cvtc_y_plus1( wnd->root, t ); _wpi_movewindow( toolhwnd, left, t, right-left, bottom-top, TRUE ); } GUIResizeBackground( wnd, true ); _wpi_showwindow( toolhwnd, SW_SHOWNORMAL ); _wpi_updatewindow( toolhwnd ); GUIEVENTWND( wnd, gui_ev, NULL ); return( true ); }
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height, int num_toolbar_items, gui_toolbar_struct *toolinfo, bool excl, gui_colour_set *plain, gui_colour_set *standout, gui_rect *float_pos, bool use_tips ) { gui_coord size; gui_coord pos; HWND parent; HWND toolhwnd; toolbarinfo *tbar; int i; TOOLITEMINFO info; int fixed_height; int fixed_width; int adjust_amount; int width; int new_right; int bm_h; int bm_w; GUI_RECTDIM left, top, right, bottom; int h; excl = excl; plain = plain; standout = standout; fixed_height = 0; fixed_width = 0; if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) || ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) { return( false ); } if( wnd->tbinfo != NULL ) { GUICloseToolBar( wnd ); } tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) ); if( tbar == NULL ) { return( false ); } memset( tbar, 0, sizeof( toolbarinfo ) ); parent = wnd->root; tbar->fixedrect = wnd->hwnd_client_rect; tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) ); if( tbar->bitmaps == NULL ) { GUIMemFree( tbar ); wnd->tbinfo = NULL; return( false ); } for( i = 0; i < num_toolbar_items; i++ ) { tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst, _wpi_makeintresource( toolinfo[i].bitmap ) ); if( height == 0 ) { _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h ); if( bm_h > fixed_height ) { fixed_height = bm_h; } if( bm_w > fixed_width ) { fixed_width = bm_w; } } } tbar->info.border_size.x = BORDER_AMOUNT; tbar->info.border_size.y = BORDER_AMOUNT; /* space for border and space before border */ adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT); if( height == 0 ) { /* maintian # of pixels in bitmap */ height = fixed_height + adjust_amount + OUTLINE_AMOUNT; width = fixed_width + OUTLINE_AMOUNT; } else { /* only height of windows given, make bitmaps square */ size.x = 0; size.y = height - 2; GUIScaleToScreenR( &size ); height = size.y; width = size.y; } _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom ); h = _wpi_getheightrect( tbar->fixedrect ); bottom = _wpi_cvth_y_plus1( height, h ); top = _wpi_cvth_y_plus1( top, h ); _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom ); height -= adjust_amount; /* leaving just button size */ tbar->info.button_size.x = width; tbar->info.button_size.y = height; bottom = height + BORDER_AMOUNT * 2 + _wpi_getsystemmetrics( SM_CYCAPTION ) + 2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) - _wpi_getsystemmetrics( SM_CYBORDER ) ); bottom = _wpi_cvth_y_plus1( bottom, h ); #ifdef __OS2_PM__ bottom -= 2; #endif new_right = width * num_toolbar_items - (num_toolbar_items - 1) * tbar->info.border_size.x + left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) + BORDER_AMOUNT * 2; if( new_right < right ) { right = new_right; } _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); if( fixed ) { tbar->info.area = tbar->fixedrect; tbar->info.style = TOOLBAR_FIXED_STYLE; } else { if( float_pos != NULL ) { GUICalcLocation( float_pos, &pos, &size, parent ); _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y, pos.x + size.x, pos.y + size.y ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); } tbar->info.area = tbar->floatrect; tbar->info.style = TOOLBAR_FLOAT_STYLE; } tbar->info.hook = guiToolBarProc; tbar->info.helphook = guiToolBarHelp; tbar->info.background = 0; tbar->info.foreground = 0; tbar->num = num_toolbar_items; tbar->info.is_fixed = fixed; tbar->info.use_tips = use_tips; tbar->hdl = ToolBarInit( parent ); ToolBarDisplay( tbar->hdl, &tbar->info ); GUIResizeBackground( wnd, true ); for( i = 0; i < num_toolbar_items; i++ ) { info.u.bmp = tbar->bitmaps[i]; info.id = toolinfo[i].id; info.flags = 0; if( use_tips && toolinfo[i].tip != NULL ) { strncpy( info.tip, toolinfo[i].tip, MAX_TIP ); } else { info.tip[0] = '\0'; } ToolBarAddItem( tbar->hdl, &info ); } toolhwnd = ToolBarWindow( tbar->hdl ); _wpi_showwindow( toolhwnd, SW_SHOWNORMAL ); _wpi_updatewindow( toolhwnd ); return( true ); }
static void DoScroll( gui_window *wnd, int rows, int cols, int start, int end, bool chars ) { int dx, dy; WPI_RECT client; HWND hwnd; int multx, multy; GUI_RECTDIM left, top, right, bottom; #ifdef __OS2_PM__ int bottom_adjust; #endif hwnd = GUIGetScrollHWND( wnd ); _wpi_getclientrect( wnd->hwnd, &client ); _wpi_getrectvalues( client, &left, &top, &right, &bottom ); #ifdef __OS2_PM__ bottom_adjust = bottom - GUIGetScrollScreenSize( wnd, SB_VERT ); top += bottom_adjust; #else bottom = GUIGetScrollScreenSize( wnd, SB_VERT ); #endif multx = 1; multy = 1; if( chars ) { multx = GUIFromTextX( multx, wnd ); multy = GUIFromTextY( multy, wnd ); } dx = -cols * multx; dy = -rows * multy; if( dy != 0 ) { #ifdef __OS2_PM__ start *= multy; end *= multy; if( end > -multy ) { end += multy; if( end > bottom ) { end = bottom; } top = _wpi_getheightrect( client ) - end; //bottom = end + bottom_adjust; } if( start > -multy ) { //start += multy; if( start > bottom ) { start = bottom; } bottom = _wpi_getheightrect( client ) - start; //top = start + bottom_adjust; } #else start *= multy; end *= multy; if( start > -multy ) { if( start > bottom ) { start = bottom; } top = start; } if( end > -multy ) { end += multy; if( end > bottom ) { end = bottom; } bottom = end; } #endif } if( dx != 0 ) { start *= multx; end *= multx; if( start > -multx ) { if( start > right ) { start = right; } left = start; } if( end > -multx ) { end += multx; if( end > right ) { end = right; } right = end; } } _wpi_setrectvalues( &client, left, top, right, bottom ); GUIInvalidatePaintHandles( wnd ); _wpi_scrollwindow( hwnd, dx, dy, &client, &client ); _wpi_updatewindow( hwnd ); }
WPI_MRESULT CALLBACK GraphWndProc( HWND Wnd, WPI_MSG message, WPI_PARAM1 wParam, WPI_PARAM2 lParam ) //============================================================= { WPI_PRES Win_dc; PAINTSTRUCT ps; int width, height; int x, y, t; int h_minpos, h_maxpos, h_currpos; int v_minpos, v_maxpos, v_currpos; WPI_RECTDIM left, top, right, bottom; WPI_RECT rect; struct ScrollStruct scroll_info; LPWDATA w; HWND frame; #if defined( __OS2__ ) int wheight; WPI_RECT wrect; #endif w = _GetWindowData( Wnd ); if( w == NULL ) { return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); } #if defined( __OS2__ ) frame = w->frame; #else frame = Wnd; #endif switch( message ) { #if defined( __WINDOWS__ ) case WM_SETFOCUS: SetFocus( _MainWindow ); case WM_SYSCOMMAND: case WM_MOUSEACTIVATE: _MakeWindowActive( w ); return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); case WM_KILLFOCUS: if( ( wParam != NULL) && ( wParam != _MainWindow ) ) { _ShowWindowActive( NULL, w ); } return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); #else case WM_FOCUSCHANGE: case WM_SYSCOMMAND: _MakeWindowActive( w ); return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); #endif case WM_PAINT: // Setup Win_dc = _wpi_beginpaint( Wnd, NULLHANDLE, &ps ); _wpi_torgbmode( Win_dc ); _wpi_getpaintrect( &ps, &rect ); _wpi_getwrectvalues( rect, &left, &top, &right, &bottom ); width = _wpi_getwidthrect( rect ); height = _wpi_getheightrect( rect ); // Copy from the memory dc to the screen #if defined( __OS2__ ) GetClientRect( Wnd, &wrect ); wheight = _wpi_getheightrect( wrect ); y = _GetPresHeight() - wheight - _BitBlt_Coord.ycoord + top; #else y = _BitBlt_Coord.ycoord + top; #endif _wpi_bitblt( Win_dc, left, top, width, height, _Mem_dc, _BitBlt_Coord.xcoord + left, y, SRCCOPY ); //Cleanup _wpi_endpaint( Wnd, Win_dc, &ps ); break; #if defined( __OS2__ ) case WM_CLOSE: WinDestroyWindow( w->frame ); return( 0 ); #endif case WM_DESTROY: // free the system resources allocated if( _Mem_dc ){ _wpi_deletecliprgn( _Mem_dc, _ClipRgn ); _wpi_deletecompatiblepres( _Mem_dc, _Hdc ); if( _Mem_bmp ){ _wpi_deletebitmap( _Mem_bmp ); if( !_IsStockFont() ){ _wpi_f_deletefont( _CurFnt ); } } #if defined( __OS2__ ) WinSendMsg( _GetWinMenuHandle(), ( ULONG )MM_DELETEITEM, MPFROM2SHORT( ( w->handles[0] + DID_WIND_STDIO ), FALSE ), 0 ); #endif _DestroyAWindow( w ); } break; case WM_VSCROLL: scroll_info = getscrolldata( frame, SB_VERT ); CalPos( &scroll_info, wParam, lParam, &v_currpos, &y ); // Make sure we have to refresh first if( _BitBlt_Coord.ycoord != y ) { _BitBlt_Coord.ycoord = y; _wpi_setscrollpos( frame, SB_VERT, v_currpos, TRUE ); _wpi_invalidaterect( Wnd, NULL, 0 ); _wpi_updatewindow( Wnd ); } return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); case WM_HSCROLL: scroll_info = getscrolldata( frame, SB_HORZ ); CalPos( &scroll_info, wParam, lParam, &h_currpos, &x ); // make sure we need to refresh first if( _BitBlt_Coord.xcoord != x ) { _BitBlt_Coord.xcoord = x; _wpi_setscrollpos( frame, SB_HORZ, h_currpos, TRUE ); _wpi_invalidaterect( Wnd, NULL, 0 ); _wpi_updatewindow( Wnd ); } return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); case WM_SIZE: x = _wpi_getsystemmetrics( SM_CXSCREEN ); y = _wpi_getsystemmetrics( SM_CYSCREEN ); _wpi_getscrollrange( frame, SB_VERT, &v_minpos, &v_maxpos ); _wpi_getscrollrange( frame, SB_HORZ, &h_minpos, &h_maxpos ); _wpi_getclientrect( Wnd, &rect ); _wpi_getrectvalues( rect, &left, &top, &right, &bottom ); height = bottom - top + 1; width = right - left + 1; if( width >= x ) { // hide the scroll bar #if defined( __OS2__ ) WinShowWindow( WinWindowFromID( frame, FID_HORZSCROLL ), FALSE ); #else ShowScrollBar( Wnd, SB_HORZ, FALSE ); #endif _BitBlt_Coord.xcoord = 0; h_currpos = 0; } else { // if the window isn't as big as the device context // show the scroll bar t = x - width + 1; if( x - _BitBlt_Coord.xcoord + 1 < width ) { _BitBlt_Coord.xcoord = x - width + 1; } if( _BitBlt_Coord.xcoord == t ) { h_currpos = h_maxpos; } else { h_currpos = CalScrollAmt( h_maxpos, h_minpos, _BitBlt_Coord.xcoord, x, width ); } #if defined( __OS2__ ) WinShowWindow( WinWindowFromID( frame, FID_HORZSCROLL ), TRUE ); #else ShowScrollBar( Wnd, SB_HORZ, 1 ); #endif } if( height >= y ) { // hide the scroll bar #if defined( __OS2__ ) WinShowWindow( WinWindowFromID( frame, FID_VERTSCROLL ), FALSE ); #else ShowScrollBar( Wnd, SB_VERT, 0 ); #endif _BitBlt_Coord.ycoord = 0; v_currpos = 0; } else { // if the the window isn't as big as the device context // then show the scroll bar t = y - height + 1; if( y - _BitBlt_Coord.ycoord + 1 < height ) { _BitBlt_Coord.ycoord = t; } if( _BitBlt_Coord.ycoord == t ) { v_currpos = v_maxpos; } else { v_currpos = CalScrollAmt( v_maxpos, v_minpos, _BitBlt_Coord.ycoord, y, height ); } #if defined( __OS2__ ) WinShowWindow( WinWindowFromID( frame, FID_VERTSCROLL ), TRUE ); #else ShowScrollBar( Wnd, SB_VERT, 1 ); #endif } // Adjust the scroll bar thumbs' positions _wpi_setscrollpos( frame, SB_HORZ, h_currpos, TRUE ); _wpi_setscrollpos( frame, SB_VERT, v_currpos, TRUE ); #if defined( __OS2__ ) Win_dc = WinBeginPaint( Wnd, NULL, &rect ); WinFillRect( Win_dc, &rect, CLR_BLACK ); WinEndPaint( Win_dc ); #endif _wpi_invalidaterect( Wnd, NULL, 0 ); break; default: return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) ); } return( NULL ); }