Esempio n. 1
0
void GUImain( void )
{
    GUIMemOpen();
    GUIWndInit( 300, GUI_GMOUSE );
    GUISetScale( &Scale );
    Child.parent = GUICreateWindow( &Parent );
    GUICreateWindow( &Child );
}
Esempio n. 2
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. 3
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. 4
0
static a_window *WndCreateWithStructBody( wnd_create_struct *info,
                                          gui_create_info *init )
{
    a_window    *wnd;
    gui_window  *gui;
    char        buff[256];
    int         size;

    if( info->title == NULL ) {
        buff[0] = '\0';
    } else {        // might be clobbered by create
        strcpy( buff, info->title );
    }
    if( info->title != NULL )
        strcpy( buff, info->title ); // might be clobbered by create
    size = sizeof( *wnd ) + ( WndMaxDirtyRects - 1 ) * sizeof( wnd->dirty ); //
    wnd = WndAlloc( size );
    if( wnd == NULL ) {
        WndFree( info->extra );
        WndNoMemory();
    }
    memset( wnd, 0, size );
    wnd->u.button_down.row = (char)-1;
    wnd->gui = NULL;
    wnd->info = info->info;
    wnd->wndclass = info->wndclass;
    wnd->extra = info->extra;
    wnd->title_size = info->title_size;
    wnd->rows = 1;      // just so it's not zero in init code
    WndNoSelect( wnd );
    WndNoCurrent( wnd );
    WndSetCurrCol( wnd );
    WndNullPopItem( wnd );
    wnd->dirtyrects= 0; // wndnoselect changes this!
    wnd->vscroll_pending = 0;
    wnd->hscroll_pending = -1;
    wnd->keypiece = WND_NO_PIECE;

    wnd->switches = WSW_SELECT_IN_TABSTOP | WSW_MUST_CLICK_ON_PIECE |
                    WSW_ALLOW_POPUP | WSW_SEARCH_WRAP | WSW_HIGHLIGHT_CURRENT |
                    WSW_ONLY_MODIFY_TABSTOP | WSW_MENU_ACCURATE_ROW;

    if( info->rect.width == 0 || info->rect.height == 0 ) {
        init->rect.x = 0;
        init->rect.y = 0;
        init->rect.width = WndMax.x;
        init->rect.height = WndMax.y;
    } else {
        init->rect.x = info->rect.x;
        init->rect.y = info->rect.y;
        init->rect.width = info->rect.width;
        init->rect.height = info->rect.height;
    }
    init->scroll = info->scroll;
    init->style = info->style;
    init->style |= GUI_VSCROLL_EVENTS;
    init->style &= ~GUI_HSCROLL_EVENTS;
    init->title = ( info->title == NULL ) ? NULL : "";
    if( WndMain != NULL ) {
        init->style |= GUI_VISIBLE;
        init->parent = WndMain->gui;
        init->num_menus = 0;
        init->menu = NULL;
    } else {
        init->style &= ~GUI_VISIBLE;
        init->scroll = GUI_NOSCROLL;
        init->num_menus = WndNumMenus;
        init->menu = WndMainMenu;
        init->parent = NULL;
    }
    if( init->style & GUI_POPUP ) {
        init->parent = NULL;
    }
    init->num_attrs = WndNumColours;
    init->colours = info->colour;
    init->call_back = WndMainEventProc;
    init->extra = wnd;

    _Set( wnd, WSW_ACTIVE );

    gui = GUICreateWindow( init );
    if( gui == NULL ) {
        WndFree( info->extra );
        WndFree( wnd );
        WndNoMemory();
        return( NULL );
    } else {
        if( buff[0] != '\0' ) {
            WndSetTitle( wnd, buff );
        }
    }
    ++NumWindows;
    return( wnd );
}