/* * ShowNewColor - replace the color of the color box and redisplay the boxes */ void ShowNewColor( int index, COLORREF newcolor, BOOL repaint ) { WPI_POINT topleft; WPI_POINT bottomright; WPI_PRES pres; WPI_PRES mempres; HDC hdc; HBITMAP oldbitmap; HBRUSH brush; HBRUSH oldbrush; HPEN blackpen; HPEN oldpen; pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); paletteBox[index].color = newcolor; paletteBox[index].solid_color = _wpi_getnearestcolor( pres, newcolor ); _wpi_releasepres( HWND_DESKTOP, pres ); if( numberOfColors != 2 ) { topleft.x = (index / 2) * SQR_SIZE; bottomright.x = topleft.x + SQR_SIZE + 1; if( index / 2 == (index + 1) / 2 ) { topleft.y = 0; bottomright.y = SQR_SIZE + 1; } else { topleft.y = SQR_SIZE; bottomright.y = 2 * SQR_SIZE + 1; } pres = _wpi_getpres( HWND_DESKTOP ); mempres = _wpi_createcompatiblepres( pres, Instance, &hdc ); _wpi_releasepres( HWND_DESKTOP, pres ); _wpi_torgbmode( mempres ); brush = _wpi_createsolidbrush( newcolor ); oldbrush = _wpi_selectobject( mempres, brush ); blackpen = _wpi_createpen( PS_SOLID, 0, BLACK ); oldpen = _wpi_selectobject( mempres, blackpen ); oldbitmap = _wpi_selectbitmap( mempres, hColorBitmap ); _wpi_cvth_pt( &topleft, colorsHeight ); _wpi_cvth_pt( &bottomright, colorsHeight ); _wpi_rectangle( mempres, topleft.x, topleft.y, bottomright.x, bottomright.y ); _wpi_selectobject( mempres, oldpen ); _wpi_selectobject( mempres, oldbrush ); _wpi_deleteobject( blackpen ); _wpi_deleteobject( brush ); _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_deletecompatiblepres( mempres, hdc ); } if( repaint ) { _wpi_invalidaterect( hColorsWnd, NULL, FALSE ); } } /* ShowNewColor */
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 ); } }
/* * SetScreenClr - set the color to represent the screen */ void SetScreenClr( COLORREF screen_color ) { WPI_PRES pres; pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); screenColor.color = _wpi_getnearestcolor( pres, screen_color ); screenColor.solid_color = screenColor.color; _wpi_releasepres( HWND_DESKTOP, pres ); inverseColor.color = GetInverseColor( screenColor.color ); inverseColor.solid_color = inverseColor.color; VerifyCurrentClr( screenColor.color, inverseColor.color ); _wpi_invalidaterect( hScreenWnd, NULL, FALSE ); } /* SetScreenClr */
void GUIInvalidateResize( gui_window *wnd ) { WPI_RECT rect; GUI_RECTDIM left, top, right, bottom; if( ( wnd->flags & NEEDS_RESIZE_REDRAW ) && ( wnd->old_rows != wnd->num_rows ) ) { _wpi_getrectvalues( wnd->hwnd_client_rect, &left, &top, &right, &bottom ); GUIGetMetrics( wnd ); if( wnd->old_rows < wnd->num_rows ) { /* window grew */ top = wnd->old_rows * AVGYCHAR( GUItm ); } else { /* window shrunk */ top = wnd->num_rows * AVGYCHAR( GUItm ); } _wpi_setrectvalues( &rect, left, top, right, bottom ); _wpi_invalidaterect( wnd->hwnd, &rect, TRUE ); wnd->flags &= ~NEEDS_RESIZE_REDRAW; } wnd->old_rows = wnd->num_rows; }
/* * SetNumColors - set the number of colors in the image and repaint the window */ void SetNumColors( int number_of_colors ) { HMENU hmenu; HWND frame; if( numberOfColors == number_of_colors ) { return; } SetCurrentNumColors( number_of_colors ); numberOfColors = number_of_colors; initPaletteBoxes( FALSE ); _wpi_invalidaterect( hColorsWnd, NULL, FALSE ); if( numberOfColors == 2 ) { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); if( _wpi_isitemenabled( hmenu, IMGED_RCOLOR ) ) { prevRestoreState = TRUE; } else { prevRestoreState = FALSE; } _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, FALSE, FALSE ); } } else { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, prevRestoreState, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, TRUE, FALSE ); } } } /* SetNumColors */
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 ); }
/* * doMaximize - handle maximizing an edit window */ static void doMaximize( HWND hwnd ) { DWORD style; mdi_data *md; WPI_RECT r; bool iconic; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; setMaximizedMenuConfig( hwnd ); md = MDI_DATA_FROM_HWND( hwnd ); if( mdiInfo.start_max_restore != NULL ) { mdiInfo.start_max_restore( hwnd ); } iconic = _wpi_isiconic( hwnd ); if( iconic ) { _wpi_getrestoredrect( hwnd, &md->orig_size ); } else { _wpi_getwindowrect( hwnd, &md->orig_size ); } md->orig_state = md->curr_state; md->curr_state = STATE_MAX; if( mdiInfo.set_style != NULL ) { (mdiInfo.set_style)( hwnd, TRUE ); } else { style = _wpi_getwindowlong( hwnd, GWL_STYLE ); style &= ~mdiInfo.reg_style; style |= mdiInfo.max_style; _wpi_setwindowlong( hwnd, GWL_STYLE, style ); } _wpi_setscrollrange( hwnd, SB_VERT, 1, 1, TRUE ); _wpi_setscrollrange( hwnd, SB_HORZ, 1, 1, TRUE ); _wpi_getwindowrect( mdiInfo.container, &r ); _wpi_getrectvalues( r, &left, &top, &right, &bottom ); if( !iconic ) { _wpi_offsetrect( mdiInfo.hinstance, &md->orig_size, -left, -top ); } _wpi_setrectvalues( &r, 0, 0, right-left+1, bottom-top+1 ); if( iconic ) { _wpi_setrestoredrect( hwnd, &r ); } else { _wpi_getrectvalues( r, &left, &top, &right, &bottom ); _wpi_movewindow( hwnd, left, top, right, bottom, TRUE ); } if( mdiInfo.end_max_restore != NULL ) { mdiInfo.end_max_restore( hwnd ); } _wpi_invalidaterect( hwnd, NULL, FALSE ); } /* doMaximize */