bool GUIDrawLine( gui_window *wnd, gui_point *start, gui_point *end, gui_line_styles style, gui_ord thickness, gui_attr attr ) { gui_point my_start; gui_point my_end; SAREA area; char to_use; /* unused parameters */ (void)style; (void)thickness; my_start = *start; my_end = *end; GUIScaleToScreenRPt( &my_start ); GUIScaleToScreenRPt( &my_end ); area.row = my_start.y; area.height = my_end.y - my_start.y + 1; area.col = my_start.x; area.width = my_end.x - my_start.x + 1; if( my_start.x == my_end.x ) { to_use = DRAW( VERT_FRAME ); } else { if( my_start.y == my_end.y ) { to_use = DRAW( HOR_FRAME ); } else { return( false ); } } if( AdjustRect( wnd, &area ) ) { uivfill( &wnd->screen, area, wnd->colours[attr], to_use ); } return( true ); }
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 MapLocation( gui_window *wnd, gui_point *point ) { GUIScaleToScreenRPt( point ); if( ( wnd->hgadget != NULL ) && !GUI_HSCROLL_EVENTS_SET( wnd ) ) { point->x -= wnd->hgadget->pos; } if( ( wnd->vgadget != NULL ) && !GUI_VSCROLL_EVENTS_SET( wnd ) ) { point->y -= wnd->vgadget->pos; } point->x += wnd->use.col + 1; point->y += wnd->use.row + 1; }
gui_ord GUIGetRow( gui_window * wnd, gui_point * in_pos ) { int height; gui_ord row; gui_point pos; pos = *in_pos; GUIGetMetrics( wnd ); height = AVGYCHAR(GUItm); GUIScaleToScreenRPt( &pos ); row = pos.y / height; return( row ); }
gui_ord GUIGetCol( gui_window * wnd, char * text, gui_point * in_pos ) { int width; bool got_new; gui_point pos; got_new = GUIGetTheDC( wnd ); GUIGetMetrics( wnd ); pos = *in_pos; GUIScaleToScreenRPt( &pos ); width = pos.x / MAXXCHAR( GUItm ); while( ( width < strlen( text ) ) && ( GUIGetTextExtentX( wnd, text, width ) <= pos.x ) ) { width++ ; } if( got_new ) { GUIReleaseTheDC( wnd ); } return( (gui_ord) ( width - 1 ) ); }
static bool DrawLine( gui_window *wnd, gui_point *start, gui_point *end, gui_line_styles style, gui_ord thickness, WPI_COLOUR colour ) { gui_point my_start; gui_point my_end; HPEN pen; int win_style; gui_coord coord; HPEN old_pen; int hscroll; int vscroll; WPI_POINT pt; int win_height; my_start = *start; my_end = *end; GUIScaleToScreenRPt( &my_start ); GUIScaleToScreenRPt( &my_end ); 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; } switch( style ) { case GUI_PEN_SOLID : win_style = PS_SOLID; coord.x = thickness; GUIScaleToScreenR( &coord ); break; case GUI_PEN_DASH : coord.x = 1; win_style = PS_DASH; break; case GUI_PEN_DOT : coord.x = 1; win_style = PS_DOT; break; case GUI_PEN_DASHDOT : coord.x = 1; win_style = PS_DASHDOT; break; case GUI_PEN_DASHDOTDOT : coord.x = 1; win_style = PS_DASHDOTDOT; break; default: coord.x = 0; win_style = 0; break; } pen = _wpi_createpen( win_style, coord.x, colour ); old_pen = _wpi_selectpen( wnd->hdc, pen ); win_height = _wpi_getheightrect( wnd->hwnd_client_rect ); pt.x = my_start.x - hscroll; pt.y = my_start.y - vscroll; pt.y = _wpi_cvth_y_plus1( pt.y, win_height ); _wpi_movetoex( wnd->hdc, &pt, &pt ); pt.x = my_end.x - hscroll; pt.y = my_end.y - vscroll; pt.y = _wpi_cvth_y_plus1( pt.y, win_height ); _wpi_lineto( wnd->hdc, &pt ); if( old_pen != NULLHANDLE ) { _wpi_getoldpen( wnd->hdc, old_pen ); } _wpi_deletepen( pen ); return( true ); }