/* * StatusWndDraw3DBox - called by StatusWndDrawLine or externally * if StatusWndDrawLine is not used. */ void StatusWndDraw3DBox( statwnd *sw, WPI_PRES pres ) { HPEN old_pen; int i; WPI_RECT r; old_pen = _wpi_selectobject( pres, penLight ); for( i = 0; i <= sw->numSections; i++ ) { getRect( sw, &r, i ); outlineRect( sw, pres, &r ); makeInsideRect( &r ); _wpi_fillrect( pres, &r, colorButtonFace, brushButtonFace ); } _wpi_selectobject( pres, old_pen ); } /* StatusWndDraw3DBox */
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg ) { HDC prev_hdc; PAINTSTRUCT *prev_ps; gui_row_num row_num; PAINTSTRUCT ps; WPI_RECT fill_area; #ifdef __OS2_PM__ ULONG flags; RECTL client; #endif isdlg=isdlg; /* save old state */ prev_hdc = wnd->hdc; prev_ps = wnd->ps; /* Setup Paint */ wnd->ps = &ps; wnd->hdc = _wpi_beginpaint( hwnd, NULLHANDLE, wnd->ps ); _wpi_torgbmode( wnd->hdc ); _wpi_getpaintrect( wnd->ps, &fill_area ); #ifdef __OS2_PM__ fill_area = *(wnd->ps); if( isdlg ) { _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10); } WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) ); #endif #if defined( __NT__ ) if( isdlg ) { _wpi_fillrect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ), wnd->bk_brush ); } #endif if( wnd->font != NULL ) { wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font ); } else { wnd->prev_font = NULL; } /* send paint to app */ GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num ); if( row_num.num > 0 ) { GUIEVENTWND( wnd, GUI_PAINT, &row_num ); } /* finish painting */ if( wnd->prev_font != NULL ) { _wpi_getoldfont( wnd->hdc, wnd->prev_font ); wnd->prev_font = NULL; } #ifdef __OS2_PM__ if( isdlg ) { flags = DB_AREAATTRS | DB_DLGBORDER; #ifdef _M_I86 if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) { #else if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) { #endif //if( _wpi_getfocus() != hwnd ) { flags |= DB_PATINVERT; } WinQueryWindowRect( hwnd, &client ); WinDrawBorder( wnd->hdc, &client, 1, 1, 0, 0, flags ); } #endif _wpi_endpaint( hwnd, wnd->hdc, wnd->ps ); /* restore old state */ wnd->hdc = prev_hdc; wnd->ps = prev_ps; } #else // this is some experimental PM stuff void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg ) { HDC prev_hdc; PAINTSTRUCT *prev_ps; gui_row_num row_num; PAINTSTRUCT ps; PAINTSTRUCT fill_area; // experimenal stuff HPS hps; RECTL client; LONG width, height; ULONG flags; int compat_created; gui_paint_info *pinfo; // figure out which paint info to use if( !isdlg && wnd->root == hwnd ) { pinfo = &wnd->root_pinfo; } else { pinfo = &wnd->hwnd_pinfo; } pinfo->in_use++; compat_created = FALSE; /* save old state */ prev_hdc = wnd->hdc; prev_ps = wnd->ps; if( isdlg ) { _wpi_getclientrect( hwnd, &client ); } else { WinQueryWindowRect( hwnd, &client ); } width = client.xRight - client.xLeft; height = client.yTop - client.yBottom; wnd->ps = &ps; //hps = _wpi_beginpaint( hwnd, pinfo->normal_pres, wnd->ps ); hps = _wpi_beginpaint( hwnd, NULL, wnd->ps ); if( pinfo->compatible_pres == (WPI_PRES)NULL ) { compat_created = TRUE; pinfo->compatible_pres = _wpi_createcompatiblepres( hps, GUIMainHInst, &pinfo->compatible_hdc ); pinfo->draw_bmp = _wpi_createcompatiblebitmap( hps, width, height ); pinfo->old_bmp = _wpi_selectbitmap( pinfo->compatible_pres, pinfo->draw_bmp ); } // the condition is here VERY conservative!! // its gains have to analyzed if( compat_created || pinfo->force_count ) { wnd->hdc = pinfo->compatible_pres; //wnd->hdc = hps; _wpi_torgbmode( wnd->hdc ); fill_area = *(wnd->ps); if( isdlg ) { _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10); } WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) ); wnd->prev_font = NULL; if( wnd->font != NULL ) { wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font ); } /* send paint to app */ GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num ); if( row_num.num > 0 ) { GUIEVENTWND( wnd, GUI_PAINT, &row_num ); } /* finish painting */ if( wnd->prev_font != NULL ) { _wpi_getoldfont( wnd->hdc, wnd->prev_font ); wnd->prev_font = NULL; } if( pinfo->force_count ) { //pinfo->force_count--; } } //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height, // wnd->hdc, 0, 0, SRCCOPY ); if( pinfo->in_use == 1 ) { //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height, // wnd->hdc, 0, 0, SRCCOPY ); _wpi_bitblt( hps, ps.xLeft, ps.yBottom, ps.xRight - ps.xLeft, ps.yTop - ps.yBottom, wnd->hdc, ps.xLeft, ps.yBottom, SRCCOPY ); if( pinfo->delete_when_done ) { GUIFreePaintHandles( pinfo, TRUE ); } } if( isdlg ) { flags = DB_AREAATTRS | DB_DLGBORDER; #ifdef _M_I86 if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) { #else if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) { #endif //if( _wpi_getfocus() != hwnd ) { flags |= DB_PATINVERT; } WinQueryWindowRect( hwnd, &client ); WinDrawBorder( hps, &client, 1, 1, 0, 0, flags ); } _wpi_endpaint( hwnd, hps, wnd->ps ); /* restore old state */ wnd->hdc = prev_hdc; wnd->ps = prev_ps; if( pinfo->in_use ) { pinfo->in_use--; } } #endif void GUIInvalidatePaintHandles( gui_window *wnd ) { GUIFreeWndPaintHandles( wnd, FALSE ); }
static bool DrawRect( gui_window *wnd, gui_rect *rect, WPI_COLOUR colour, bool fill, bool outline ) { WPI_RECT wnd_rect; gui_coord pos; gui_coord size; HBRUSH brush; int hscroll; int vscroll; int win_height; if( ( rect->width == 0 ) || ( rect->height == 0 ) ) { return( false ); } if( GUI_DO_VSCROLL( wnd ) ) { vscroll = GUIGetScrollPos( wnd, SB_VERT ); } else { vscroll = 0; } if( GUI_DO_HSCROLL( wnd ) ) { hscroll = GUIGetScrollPos( wnd, SB_HORZ ); } else { hscroll = 0; } win_height = _wpi_getheightrect( wnd->hwnd_client_rect ); pos.x = rect->x; pos.y = rect->y; size.x = rect->width; if( rect->width < 0 ) { pos.x += rect->width; size.x *= -1; } size.y = rect->height; if( rect->height < 0 ) { pos.y += rect->height; size.y *= -1; } GUIScaleToScreenR( &pos ); GUIScaleToScreenR( &size ); pos.x -= hscroll; pos.y -= vscroll; pos.y = _wpi_cvth_y_size_plus1( pos.y, win_height, size.y ); _wpi_setrectvalues( &wnd_rect, pos.x, pos.y, pos.x + size.x, pos.y + size.y ); if( GUIIsRectInUpdateRect( wnd, &wnd_rect ) ) { brush = _wpi_createsolidbrush( colour ); if( fill ) { _wpi_fillrect( wnd->hdc, &wnd_rect, colour, brush ); } if( outline ) { _wpi_borderrect( wnd->hdc, &wnd_rect, brush, colour, colour ); } _wpi_deletebrush( brush ); } return( true ); }
/* * outputText - output a text string */ static void outputText( statwnd *sw, WPI_PRES pres, char *buff, WPI_RECT *r, UINT flags, int curr_block ) { WPI_RECT ir; WPI_RECT draw_rect; size_t len; int ext; int width; WPI_RECTDIM ir_left; WPI_RECTDIM ir_right; WPI_RECTDIM ir_top; WPI_RECTDIM ir_bottom; WPI_RECTDIM r_left; WPI_RECTDIM r_right; WPI_RECTDIM r_top; WPI_RECTDIM r_bottom; UINT pmflags; #ifndef __NT__ int height; #else SIZE sz; #endif if( sw->sectionData[curr_block] != NULL ) { if( !strcmp( buff, sw->sectionData[curr_block] ) && flags == sw->sectionDataFlags[curr_block] ) { return; } } len = strlen( buff ); if( len == 0 ) { return; } MemFree( sw->sectionData[curr_block] ); sw->sectionData[curr_block] = MemAlloc( len + 1 ); memcpy( sw->sectionData[curr_block], buff, len + 1 ); sw->sectionDataFlags[curr_block] = flags | DT_TEXTATTRS; #ifndef __NT__ _wpi_gettextextent( pres, buff, (int)len, &ext, &height ); #else GetTextExtentPoint( pres, buff, (int)len, &sz ); ext = sz.cx; #endif ir = *r; _wpi_getrectvalues( ir, &ir_left, &ir_top, &ir_right, &ir_bottom ); #ifdef __OS2_PM__ ir_left++; ir_top++; ir_bottom++; _wpi_setrectvalues( &draw_rect, ir_left, ir_top, ir_right, ir_bottom ); #else draw_rect = *r; #endif if( flags & DT_CENTER ) { width = ( ir_right - ir_left - ext ) / 2; if( width > 0 ) { ir_right = ir_left + width; _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom ); _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace ); _wpi_getrectvalues( *r, &r_left, &r_top, &r_right, &r_bottom ); ir_right = r_right; ir_left = r_right - width; _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom ); _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace ); } } else if( flags & DT_RIGHT ) { ir_right -= ext; if( ir_right >= ir_left ) { _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom ); _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace ); } } else { ir_left += ext; if( ir_left < ir_right ) { _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom ); _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace ); } } pmflags = flags | DT_TEXTATTRS; _wpi_drawtext( pres, buff, -1, &draw_rect, pmflags ); } /* outputText */
/* * StatusWndCallback - handle messages for the status window */ WPI_MRESULT CALLBACK StatusWndCallback( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { PAINTSTRUCT ps; WPI_RECT r; int i; WPI_PRES pres; statwnd *sw; sw = (statwnd *)_wpi_getwindowlongptr( hwnd, classWinExtra ); if( statusWndHookFunc != NULL ) { if( statusWndHookFunc( hwnd, msg, wparam, lparam ) ) { return( 0 ); } } if( (msg == WM_SIZE || msg == WM_PAINT) && sw == NULL ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } switch( msg ) { case WM_CREATE: _wpi_setwindowlongptr( hwnd, classWinExtra, (LONG_PTR)currentStatWnd ); return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); case WM_SIZE: GetClientRect( hwnd, &sw->statusRect ); sw->wndHeight = _wpi_getheightrect( sw->statusRect ); _wpi_inflaterect( classHandle, &sw->statusRect, -HORZ_BORDER, -VERT_BORDER ); return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); case WM_PAINT: pres = _wpi_beginpaint( hwnd, NULLHANDLE, &ps ); #ifdef __OS2_PM__ WinFillRect( pres, &ps, CLR_PALEGRAY ); #endif #ifdef __NT__ /* * We have to do this little trick because currently this window does not receive * the WM_SYSCOLORCHANGE message when it should. */ if( colorButtonFace != GetSysColor( COLOR_BTNFACE ) ) { RECT rs; if( hasGDIObjects ) { _wpi_deleteobject( penLight ); _wpi_deleteobject( penShade ); _wpi_deleteobject( brushButtonFace ); } colorButtonFace = GetSysColor( COLOR_BTNFACE ); _wpi_setbackcolour( pres, colorButtonFace ); brushButtonFace = CreateSolidBrush( colorButtonFace ); penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ); hasGDIObjects = true; GetClientRect( hwnd, &rs ); FillRect( pres, &rs, brushButtonFace ); } #endif StatusWndDraw3DBox( sw, pres ); if( initPRES( sw, pres ) ) { for( i = 0; i <= sw->numSections; i++ ) { if( sw->sectionData[i] != NULL ) { getRect( sw, &r, i ); makeInsideRect( &r ); _wpi_drawtext( pres, sw->sectionData[i], -1, &r, sw->sectionDataFlags[i] ); } } finiPRES( pres ); } _wpi_endpaint( hwnd, pres, &ps ); break; #ifdef __NT__ case WM_SYSCOLORCHANGE: if( hasGDIObjects ) { DeleteObject( penLight ); DeleteObject( penShade ); DeleteObject( brushButtonFace ); hasGDIObjects = false; } colorButtonFace = GetSysColor( COLOR_BTNFACE ); colorTextFace = GetSysColor( COLOR_BTNTEXT ); brushButtonFace = CreateSolidBrush( colorButtonFace ); penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ); hasGDIObjects = true; break; #endif case WM_ERASEBKGND: #ifdef __NT__ if( colorButtonFace != GetSysColor( COLOR_BTNFACE ) ) { /* * If WM_SYSCOLORCHANGE message is not received by this window, we * have to fake it. */ SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0L ); } #endif GetClientRect( hwnd, &r ); _wpi_unrealizeobject( brushButtonFace ); _wpi_fillrect( (WPI_PRES)wparam, &r, colorButtonFace, brushButtonFace ); break; default: return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } return( 0 ); } /* StatusWndCallback */