static void DlgOpen( gui_window *parent, const char *title, int rows, int cols, gui_control_info *controls_info, int num_controls, GUICALLBACK *rtn, void *extra, bool sys ) { gui_coord charuse; gui_coord charspace; gui_text_metrics metrics; DlgControl.title = title; DlgControl.call_back = rtn; DlgControl.extra = extra; DlgControl.parent = parent; GUIGetDlgTextMetrics( &metrics ); charspace.x = metrics.max.x; charspace.y = metrics.max.y; #ifdef __OS2_PM__ // brutal hack to get OS/2 and Windows dialogs to look the same. charuse.x = ( 5 * metrics.avg.x ) / 4; charuse.y = ( 3 * metrics.avg.y ) / 2; #else charuse.x = metrics.avg.x; charuse.y = ( 7 * metrics.avg.y ) / 4; #endif GUITruncToPixel( &charuse ); DlgSetSize( parent, &DlgControl, rows, cols, &charuse ); DlgSetCtlSizes( controls_info, num_controls, &charuse, &charspace ); if( sys || DlgModal ) { GUICreateSysModalDialog( &DlgControl, num_controls, controls_info ); } else { GUICreateDialog( &DlgControl, num_controls, controls_info ); } }
static bool OpenStatusWindow( const char *title ) /***********************************************/ { gui_text_metrics metrics; // int i; gui_rect rect; // for( i = STAT_BLANK; i < sizeof( Messages ) / sizeof( Messages[0] ); ++i ) { // Messages[i] = GetVariableStrVal( Messages[i] ); // } GUIGetDlgTextMetrics( &metrics ); CharSize.x = metrics.avg.x; CharSize.y = 5 * metrics.avg.y / 4; GUITruncToPixel( &CharSize ); StatusInfo.parent = MainWnd; StatusInfo.title = GUIStrDup( title, NULL ); StatusInfo.rect.width = STATUS_WIDTH * CharSize.x; StatusInfo.rect.height = STATUS_HEIGHT * CharSize.y; GUIGetClientRect( MainWnd, &rect ); if( GUIIsGUI() ) { StatusInfo.rect.y = BitMapBottom; } else { StatusInfo.rect.y = (GUIScale.y - StatusInfo.rect.height) / 2; } if( StatusInfo.rect.y > rect.height - StatusInfo.rect.height ) { StatusInfo.rect.y = rect.height - StatusInfo.rect.height; } StatusInfo.rect.x = (GUIScale.x - StatusInfo.rect.width) / 2; StatusBarLen = 0; StatusWnd = GUICreateWindow( &StatusInfo ); GUIGetClientRect( StatusWnd, &StatusRect ); Cancel.parent = StatusWnd; Cancel.text = LIT( Cancel ); Cancel.rect.height = 7 * CharSize.y / 4; Cancel.rect.width = (strlen( Cancel.text ) + 4) * CharSize.x; Cancel.rect.x = (StatusRect.width - Cancel.rect.width) / 2; Cancel.rect.y = CANNERY_ROW * CharSize.y; StatusBarRect.x = BAR_INDENT * CharSize.x; StatusBarRect.width = StatusRect.width - 2 * BAR_INDENT * CharSize.x; StatusBarRect.y = STATUS_ROW * CharSize.y; StatusBarRect.height = CharSize.y; #ifndef _UI StatusBarRect.y -= CharSize.y / 2; StatusBarRect.height += CharSize.y; #endif StatusBarLen = StatusBarRect.width / CharSize.x; if( !GUIAddControl( &Cancel, &ToolPlain, &ToolStandout ) ) { SetupError( "IDS_CONTROLERROR" ); return( false ); } return( true ); }
void WndShrinkToMouse( a_window wnd, wnd_metrics *metrics ) { gui_rect rect,client; gui_point mouse; gui_coord round; gui_ord max_width; gui_ord min_width; int rows; GUIGetRect( wnd->gui, &rect ); GUIGetClientRect( wnd->gui, &client ); max_width = metrics->max_cols * WndAvgCharX( wnd ); min_width = metrics->min_cols * WndAvgCharX( wnd ); rect.width = wnd->max_indent + rect.width - client.width; if( max_width != 0 && rect.width > max_width ) { rect.width = max_width; } if( min_width != 0 && rect.width < min_width ) { rect.width = min_width; } if( rect.width > WndMax.x ) rect.width = WndMax.x; rows = wnd->max_row + 1; if( metrics->max_rows != 0 && rows > metrics->max_rows ) { rows = metrics->max_rows; } if( metrics->min_rows != 0 && rows < metrics->min_rows ) { rows = metrics->min_rows; } if( rows > rect.height / WndMaxCharY( wnd ) ) { rows = rect.height / WndMaxCharY( wnd ); } rect.height = rows * WndMaxCharY( wnd ) + rect.height - client.height; if( rect.height > WndMax.y ) rect.height = WndMax.y; GUIGetMousePosn( WndMain->gui, &mouse ); if( mouse.x < 0 ) mouse.x = 0; if( mouse.y < 0 ) mouse.y = 0; if( rect.width / 2 > mouse.x ) { rect.x = 0; } else if( ( rect.width / 2 ) + mouse.x > WndMax.x ) { rect.x = WndMax.x - rect.width; } else { rect.x = mouse.x - rect.width / 2; } if( mouse.y + rect.height > WndMax.y ) { rect.y = WndMax.y - rect.height; } else { rect.y = mouse.y; round.y = WndMaxCharY( wnd ) / 2; round.x = 0; GUITruncToPixel( &round ); rect.y -= round.y; } GUISetRestoredSize( wnd->gui, &rect ); }
static void GetHalfAndAdjust( gui_coord *charuse, gui_coord *half, gui_ord *char_ui_adjust ) { half->x = charuse->x / 2; half->y = charuse->y / 2; GUITruncToPixel( half ); if( half->y == 0 ) { *char_ui_adjust = charuse->y; } else { *char_ui_adjust = 0; } }
void WndPaintDirt( a_window *wnd ) { int i; wnd_line_piece line; wnd_line_piece next_piece_line; gui_rect rect; wnd_dirt *dirt; gui_coord size; gui_coord half_char; a_window *next; // a_window *last; // last = NULL; for( wnd = WndNext( NULL ); wnd != NULL; wnd = next ) { next = WndNext( wnd ); if( wnd->vscroll_pending != 0 ) { if( wnd->hscroll_pending != -1 ) { _Set( wnd, WSW_REPAINT ); } if( _Is( wnd, WSW_REPAINT ) ) { if( wnd->hscroll_pending != -1 ) { GUIInitHScroll( wnd->gui, wnd->hscroll_pending ); } WndRepaint( wnd ); wnd->hscroll_pending = -1; wnd->vscroll_pending = 0; } else { for( i = 0; i < wnd->title_size; ++i ) { GUIDrawTextExtent( wnd->gui, " ", 1, i, 0, GUI_BACKGROUND, GUI_NO_COLUMN ); } GUIDoVScrollClip( wnd->gui, wnd->vscroll_pending, wnd->title_size, wnd->rows - 1 ); wnd->vscroll_pending = 0; } } if( _Is( wnd, WSW_REPAINT ) ) { _Clr( wnd, WSW_REPAINT ); WndKillCacheLines( wnd ); WndCheckCurrentValid( wnd ); GUIWndDirty( wnd->gui ); if( wnd->max_indent != 0 && wnd->width >= wnd->max_indent ) { GUISetHScroll( wnd->gui, 0 ); wnd->hscroll_pending = -1; GUISetHScrollRange( wnd->gui, wnd->max_indent ); } next = wnd; } else { for( i = 0; i < wnd->dirtyrects; ++i ) { dirt = &wnd->dirty[i]; if( dirt->row < 0 ) continue; if( dirt->row >= wnd->rows ) continue; if( dirt->piece == WND_NO_PIECE ) { if( !WndGetLine( wnd, dirt->row, 0, &line ) ) continue; GUIWndDirtyRow( wnd->gui, dirt->row ); } else { if( !WndGetLine( wnd, dirt->row, dirt->piece, &line ) ) continue; if( line.bitmap ) { GUIGetHotSpotSize( line.text[0], &size ); rect.x = line.indent; rect.y = dirt->row * wnd->max_char.y; rect.width = line.length; rect.height = size.y; } else if( dirt->col != WND_NO_COL ) { if( line.length == 0 ) line.text = " "; rect.x = line.indent; rect.x += GUIGetExtentX(wnd->gui, line.text, dirt->col); rect.y = dirt->row * wnd->max_char.y; rect.width = GUIGetExtentX( wnd->gui, line.text+dirt->col, dirt->end_col-dirt->col+GUICharLen( line.text[dirt->col] ) ); rect.height = wnd->max_char.y; } else if( line.extent == WND_MAX_EXTEND || line.master_tabstop ) { rect.width = 0; rect.height = 0; GUIWndDirtyRow( wnd->gui, dirt->row ); } else { rect.x = line.indent; if( WndGetLine( wnd, dirt->row, dirt->piece+1, &next_piece_line ) ) { if( next_piece_line.indent < line.indent ) { rect.width = WND_APPROX_SIZE; } else { rect.width = next_piece_line.indent - line.indent; } } else { rect.width = WND_APPROX_SIZE; } rect.y = dirt->row * wnd->max_char.y; rect.height = wnd->max_char.y; } /* begin kludge for Kerning problem */ if( rect.width != 0 || rect.height != 0 ) { half_char.x = WndAvgCharX( wnd ) / 2; half_char.y = 0; GUITruncToPixel( &half_char ); if( rect.x < half_char.x ) { rect.width += half_char.x + rect.x; rect.x = 0; } else { rect.x -= half_char.x; rect.width += half_char.x + half_char.x; } GUIWndDirtyRect( wnd->gui, &rect ); } } } } if( wnd->hscroll_pending != -1 ) { GUISetHScroll( wnd->gui, wnd->hscroll_pending ); wnd->hscroll_pending = -1; } wnd->dirtyrects = 0; WndSetThumb( wnd ); } }