Esempio n. 1
0
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 );
}
Esempio n. 2
0
static bool CreateFloatingToolbar( gui_window *wnd, gui_ord height )
{
    gui_text_metrics    metrics;
    int                 i;
    int                 loc;
    gui_rect            client;
    gui_rect            size;
    toolbarinfo         *tbar;
    gui_colour_set      *plain;
    gui_colour_set      *standout;

    tbar = wnd->tbinfo;
    tbar->fixed = false;
    GUIGetTextMetrics( wnd, &metrics );
    if( height == 0 ) {
        height = 2 * metrics.avg.y;
    }
    height += 2 * metrics.avg.y;
    GUIGetClientRect( wnd, &size );
    FloatingToolbar.parent = wnd;
    FloatingToolbar.title = LIT( Floating_Toolbar );
    FloatingToolbar.menu->label = LIT( XFix_Toolbar );
    FloatingToolbar.menu->hinttext = LIT( Fix_Toolbar_Hint );
    FloatingToolbar.rect.height = height;
    FloatingToolbar.rect.width = size.width;
    FloatingToolbar.num_attrs = GUIGetNumWindowColours( wnd );
    FloatingToolbar.colours = GUIGetWindowColours( wnd );
    FloatingToolbar.colours[GUI_FRAME_INACTIVE] = FloatingToolbar.colours[GUI_FRAME_ACTIVE];
    tbar->floattoolbar = GUICreateWindow( &FloatingToolbar );
    GUIMemFree( FloatingToolbar.colours );
    FloatingToolbar.colours = NULL;
    Button.parent = tbar->floattoolbar;
    loc = 0;
    if( tbar->has_colours ) {
        plain = &tbar->plain;
        standout = &tbar->standout;
    } else {
        plain = NULL;
        standout = NULL;
    }
    for( i = 0; i < tbar->num_items; i++ ) {
        Button.text = tbar->info[i].label;
        Button.id = tbar->info[i].id;
        Button.rect.x = loc;
        Button.rect.width = ( strlen( Button.text ) + 4 ) * metrics.avg.x;
        Button.rect.height = metrics.avg.y * 2;
        loc += Button.rect.width;
        if( !GUIAddControl( &Button, plain, standout ) ) {
            GUIDestroyWnd( tbar->floattoolbar );
            return( false );
        }
    }
    GUIGetClientRect( tbar->floattoolbar, &client );
    GUIGetRect( tbar->floattoolbar, &size );
    size.width += loc - client.width;
    GUIResizeWindow( tbar->floattoolbar, &size );
    GUIShowWindow( tbar->floattoolbar );
    return( true );
}
Esempio n. 3
0
static void DlgSetSize( gui_window *parent, gui_create_info *dlg_info, int rows,
                        int cols, gui_coord *charuse )
{
    gui_rect            max_size;
    gui_rect            rect;
    gui_system_metrics  metrics;
    gui_coord           half;
    gui_ord             char_ui_adjust;

    GetHalfAndAdjust( charuse, &half, &char_ui_adjust );
    GUIGetSystemMetrics( &metrics );
    GUIGetScale( &max_size );
    dlg_info->rect.width = (cols+3) * charuse->x + metrics.dialog_top_left_size.x +
                      metrics.dialog_bottom_right_size.x;
    dlg_info->rect.height= rows * charuse->y + metrics.dialog_top_left_size.y +
                      metrics.dialog_bottom_right_size.y + char_ui_adjust;
    if( dlg_info->rect.width  > max_size.width ) {
        dlg_info->rect.width  = max_size.width;
    }
    if( dlg_info->rect.height > max_size.height ) {
        dlg_info->rect.height = max_size.height;
    }
    dlg_info->rect.x = max_size.x + ( max_size.width - dlg_info->rect.width ) / 2;
    dlg_info->rect.y = max_size.y + ( max_size.height - dlg_info->rect.height ) / 2;
    if( parent != NULL ) {
        GUIGetClientRect( parent, &rect );
        dlg_info->rect.x -= rect.x;
        dlg_info->rect.y -= rect.y;
    }
}
Esempio n. 4
0
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 );
}
Esempio n. 5
0
bool WndIsMinimized( a_window wnd )
{
    gui_rect    rect;

    if( GUIIsMinimized( wnd->gui ) )
        return( true );
    GUIGetClientRect( wnd->gui, &rect );
    if( rect.width == 0 && rect.height == 0 )
        return( true ); // work around GUI bug
    return( false );
}