/* * selectColor - select the color */ static void selectColor( WPI_POINT *pt, HWND hwnd ) { int i; WPI_PRES pres; HWND currentwnd; int top; int bottom; WPI_RECT wrect; currentwnd = _wpi_getdlgitem( hwnd, BK_CURRENT ); pres = _wpi_getpres( currentwnd ); _wpi_mapwindowpoints( hwnd, currentwnd, pt, 1 ); _wpi_torgbmode( pres ); for( i = 0; i < 16; i++ ) { top = availColor[i].box.top; bottom = availColor[i].box.bottom; top = _wpi_cvth_y( top, 2 * SQR_SIZE ); bottom = _wpi_cvth_y( bottom, 2 * SQR_SIZE ); _wpi_setintwrectvalues( &wrect, availColor[i].box.left, top, availColor[i].box.right, bottom ); if( _wpi_ptinrect( &wrect, *pt ) ) { screenColor.color = availColor[i].color; DisplayColorBox( pres, &screenColor ); inverseColor.color = GetInverseColor( screenColor.color ); DisplayColorBox( pres, &inverseColor ); break; } } _wpi_releasepres( currentwnd, pres ); } /* selectColor */
bool GUITrackFloatingPopup( gui_window *wnd, gui_point *location, gui_mouse_track track, gui_ctl_id *curr_id ) { WPI_POINT pt; ULONG flags; GUI_RECTDIM left, top, right, bottom; HMENU popup; if( ( popup = GUIHFloatingPopup ) == (HMENU)NULL ) { return( false ); } GUIScaleToScreenRPt( location ); _wpi_getrectvalues( wnd->hwnd_client_rect, &left, &top, &right, &bottom ); location->x += left; location->y += top; if( GUI_DO_HSCROLL( wnd ) ) { location->x -= GUIGetScrollPos( wnd, SB_HORZ ); } if( GUI_DO_VSCROLL( wnd ) ) { location->y -= GUIGetScrollPos( wnd, SB_VERT ); } CurrId = NO_SELECT; if( ( curr_id != NULL ) && ( *curr_id != 0 ) ) { CurrId = *curr_id; } location->y = _wpi_cvth_y( location->y, (bottom - top) ); pt.x = location->x; pt.y = location->y; _wpi_mapwindowpoints( wnd->hwnd, HWND_DESKTOP, &pt, 1 ); flags = TPM_LEFTALIGN; if( track & GUI_TRACK_LEFT ) { flags |= TPM_LEFTBUTTON; } if( track & GUI_TRACK_RIGHT ) { flags |= TPM_RIGHTBUTTON; } InitComplete = false; GUIFlushKeys(); _wpi_trackpopupmenu( popup, flags, pt.x, pt.y, wnd->hwnd_frame ); _wpi_destroymenu( popup ); GUIHFloatingPopup = NULLHANDLE; if( ( CurrId != NO_SELECT ) && ( curr_id != NULL ) ) { *curr_id = CurrId; } CurrId = NO_SELECT; GUIDeleteFloatingPopups( wnd ); return( true ); }
static void ResizeStatus( gui_window *wnd ) { WPI_RECT status; GUI_RECTDIM left, top, right, bottom; if( GUIHasStatus( wnd ) ) { _wpi_getwindowrect( wnd->status, &status ); _wpi_mapwindowpoints( HWND_DESKTOP, wnd->root, (WPI_LPPOINT)&status, 2 ); _wpi_getrectvalues( status, &left, &top, &right, &bottom ); /* maintain height and left position of status window -- tie the rest to the client are of the parent */ SetStatusRect( wnd->root, &status, left, bottom - top ); _wpi_getrectvalues( status, &left, &top, &right, &bottom ); _wpi_movewindow( wnd->status, left, top, right - left, bottom - top, TRUE ); } }
bool GUIGetRestoredSize( gui_window *wnd, gui_rect *rect ) { HWND top_hwnd; HWND parent; WPI_RECT new_rect; if( wnd->hwnd != NULLHANDLE ) { top_hwnd = GUIGetParentFrameHWND( wnd ); parent = _wpi_getparent( top_hwnd ); _wpi_getrestoredrect( top_hwnd, &new_rect ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_LPPOINT)&new_rect, 2 ); DoGetRelRect( top_hwnd, &new_rect, rect, ( wnd->style & GUI_POPUP ) ); return( true ); } return( false ); }
bool GUIResizeWindow( gui_window *wnd, gui_rect *rect ) { gui_coord pos; gui_coord size; gui_window *parent; HWND frame; HWND phwnd; HWND rphwnd; WPI_POINT pt; GUIInvalidatePaintHandles( wnd ); if( wnd->hwnd != NULLHANDLE ) { frame = GUIGetParentFrameHWND( wnd ); parent = wnd->parent; phwnd = HWND_DESKTOP; if( parent ) { phwnd = parent->hwnd; } GUICalcLocation( rect, &pos, &size, phwnd ); if( wnd->flags & IS_DIALOG ) { // dialogs are owned by, but not children of, phwnd // so lets map pos to its real parent pt.x = pos.x; pt.y = pos.y; rphwnd = _wpi_getparent( frame ); _wpi_mapwindowpoints( phwnd, rphwnd, &pt, 1 ); _wpi_movewindow( frame, pt.x, pt.y, size.x, size.y, TRUE ); // The following is a bandaid 'till I find out why WM_SIZE's aren't // generated for PM GUI dialogs by this fuction #ifdef __OS2_PM__ _wpi_getclientrect( frame, &wnd->hwnd_client ); wnd->root_client = wnd->hwnd_client; GUISetRowCol( wnd, NULL ); GUIScreenToScaleR( &size ); GUIEVENTWND( wnd, GUI_RESIZE, &size ); #endif } else { _wpi_setwindowpos( frame, NULLHANDLE, pos.x, pos.y, size.x, size.y, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE ); //SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE ); } } return( true ); }
void GUIMakeRelative( gui_window *wnd, WPI_POINT *pt, gui_point *point ) { WPI_RECT rect; GUI_RECTDIM left, top, right, bottom; rect = wnd->hwnd_client_rect; _wpi_mapwindowpoints( wnd->hwnd, HWND_DESKTOP, (WPI_LPPOINT)&rect, 2 ); _wpi_getrectvalues( rect, &left, &top, &right, &bottom ); point->x = pt->x - left; point->y = pt->y - top; if( GUI_DO_HSCROLL( wnd ) || GUI_DO_VSCROLL( wnd ) ) { if( GUI_DO_HSCROLL( wnd ) ) { point->x += GUIGetScrollPos( wnd, SB_HORZ ); } if( GUI_DO_VSCROLL( wnd ) ) { point->y += GUIGetScrollPos( wnd, SB_VERT ); } } GUIScreenToScaleRPt( point ); }
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 ); }