コード例 #1
0
ファイル: guitool.c プロジェクト: lycaner/open-watcom-v2
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 );
}
コード例 #2
0
ファイル: guixhot.c プロジェクト: Ukusbobra/open-watcom-v2
void GUIDrawHotSpot( gui_window *wnd, int hot_spot, gui_ord row,
                     gui_ord indent, gui_attr attr )
{
    gui_text_metrics    metrics;
    gui_coord           pos;

    if( ( hot_spot > 0 ) && ( hot_spot <= GUINumHotSpots ) ) {
        GUIGetTextMetrics( wnd, &metrics );
        pos.x = indent;
        pos.y = row * metrics.avg.y;
        GUIDrawTextBitmapAttr( wnd, NULL, GUIHotSpots[hot_spot - 1].size.x,
                               GUIHotSpots[hot_spot - 1].size.y,
                               &pos, attr, GUI_NO_COLUMN, FALSE,
                               hot_spot );
    }
}
コード例 #3
0
ファイル: guistat.c プロジェクト: Azarien/open-watcom-v2
static void CalcStatusRect( gui_window *wnd, gui_ord x, gui_ord height,
                            WPI_RECT *rect )
{
    gui_text_metrics    metrics;
    gui_coord           size;
    gui_coord           pos;

    pos.x = x;
    GUIScaleToScreenR( &pos );
    if( height == 0 ) {
        GUIGetTextMetrics( wnd, &metrics );
        size.y = metrics.max.y;
    } else {
        size.y = height;
    }
    GUIScaleToScreenR( &size );
    if( height == 0 ) {
        size.y += TOTAL_VERT + 2; /* windows is 2 pixels higher than client */
    }
    SetStatusRect( wnd->root, rect, pos.x, size.y );
}
コード例 #4
0
ファイル: menus.c プロジェクト: ArmstrongJ/open-watcom-v2
static void TimeIt( void )
{
    char                buff[80];
    size_t              len;
    long                iters;
    a_window            wnd;
    gui_text_metrics    dummy;

    wnd = WndFindActive();
    if( wnd == NULL )
        return;
    buff[0]='\0';
    DlgNew( "Enter Iterations", buff, 80 );
    if( buff[0] == '\0' )
        return;
    iters = strtol( buff, NULL, 10 );
    strcpy( buff, "This is just some text" );
    len = strlen( buff );
    while( --iters >= 0 ) {
//      GUIDrawText( WndGui( wnd ), buff, len, 0, 0, WndPlainAttr );
        GUIGetTextMetrics( WndGui( wnd ), &dummy );
//      WndExtentX( wnd, "This is just some text" );
    }
}
コード例 #5
0
ファイル: guitextm.c プロジェクト: ABratovic/open-watcom-v2
void GUIGetDlgTextMetrics( gui_text_metrics * metrics )
{
    GUIGetTextMetrics( NULL, metrics );
}
コード例 #6
0
ファイル: dlggen.c プロジェクト: Ukusbobra/open-watcom-v2
static bool GenericEventProc( gui_window *gui, gui_event gui_ev, void *param )
/****************************************************************************/
{
#if !defined( _UI )
    static bool         first_time = TRUE;
#endif
    unsigned            id;
    DLG_WINDOW_SET      *result;
    a_dialog_header     *curr_dialog;
    static int          initializing = FALSE;
    char                buff[MAXBUF];
    gui_text_metrics    metrics;

    if( gui == NULL ) return( FALSE );
    result = GUIGetExtra( gui );
    curr_dialog = result->current_dialog;

    switch( gui_ev ) {
    case GUI_INIT_DIALOG:
        initializing = TRUE;
        UpdateControlVisibility( gui, curr_dialog, TRUE );
        SetDefaultVals( gui, curr_dialog );
        SetFocusCtrl( gui, curr_dialog );
        GUIGetTextMetrics( gui, &metrics );
        if( stricmp( curr_dialog->name, "InsertDisk" ) == 0 ) {
            DoBeep();
        }
#if defined( __OS2__ )
        {
            int         i;
            for( i = 0; i < curr_dialog->num_controls; i++ ) {
                if( curr_dialog->controls[i].control_class == GUI_EDIT_MLE ) {
                    GUILimitEditText( gui, curr_dialog->controls[i].id, -1 );
                    GUISetText( gui, curr_dialog->controls[i].id,
                                curr_dialog->controls[i].text );
                }
            }
        }
#endif
#if defined( _UI )
        if( stricmp( curr_dialog->name, "Welcome" ) == 0 ) {
            if( GetVariableIntVal( "AutoOptionsDialog" ) == 1 ) {
                // call Options dialog
                DoDialogWithParent( gui, "Options" );
            }
        }
#endif
#if !defined( _UI )
        first_time = TRUE;
#endif
        initializing = FALSE;
        return( TRUE );
#if !defined( _UI )
    case GUI_PAINT:
        if( first_time ) {
            first_time = FALSE;
            if( stricmp( curr_dialog->name, "Welcome" ) == 0 ) {
                if( GetVariableIntVal( "AutoOptionsDialog" ) == 1 ) {
                    // call Options dialog
                    DoDialogWithParent( gui, "Options" );
                }
            }
        }
        break;
#endif
    case GUI_DESTROY:
        break;
    case GUI_CONTROL_CLICKED :
        GUI_GETID( param, id );
        switch( id ) {
        case CTL_OK:
        case CTL_PREVIOUS:
        case CTL_FIRST:
        case CTL_SKIP:
            GetVariableVals( gui, curr_dialog, TRUE );
            GUICloseDialog( gui );
            result->state = IdToDlgState( id );
            break;
        case CTL_CANCEL:
            GUICloseDialog( gui );
            result->state = DLG_CAN;
            break;
        case CTL_DONE:
            GUICloseDialog( gui );
            result->state = DLG_DONE;
            break;
        case CTL_OPTIONS:  // Options button on Welcome dialog
            // call Options dialog
            DoDialogWithParent( gui, "Options" );
            GetVariableVals( gui, curr_dialog, FALSE );
            break;
        default:
            {
                const char      *dlg_name;
                a_dialog_header *child;
                int             old_val;
                dlg_state       return_state;

                dlg_name = VarGetStrVal( GetVariableById( id ) );
                if( dlg_name != NULL ) {
                    child = FindDialogByName( dlg_name );
                    if( child != NULL ) {
                        GetVariableVals( gui, curr_dialog, FALSE );
                        if( child->any_check != NO_VAR ) {
                            old_val = VarGetIntVal( child->any_check );
                            SetVariableByHandle( child->any_check, "1" );
                            GUISetChecked( gui, VarGetId( child->any_check ), 1 );
                            CheckChildChecks( child );
                            return_state = DoDialogByPointer( gui, child );
                            if( return_state != DLG_CAN &&
                                return_state != DLG_DONE ) {
                                CheckAnyCheck( gui, child );
                            } else {
                                SetVariableByHandle( child->any_check, old_val ? "1" : "0" );
                                GUISetChecked( gui, VarGetId( child->any_check ), old_val );
                            }
                        } else {
                            DoDialogByPointer( gui, child );
                        }
                    }
                }
            }
            if( !initializing ) GetVariableVals( gui, curr_dialog, FALSE );

            UpdateControlVisibility( gui, curr_dialog, FALSE );

            break;
        case CTL_HELP:
            strcpy( buff, "Help_" );
            strcat( buff, curr_dialog->name );
            DoDialogWithParent( gui, buff );
            break;
        }
        return( TRUE );
    default:
        break;
    }
    return( FALSE );
}