Beispiel #1
0
void GUImain( void )
{
    char        buff[256];
    char        *p;

    WndMaxDirtyRects = 20;
    getcmd( buff );
    p = buff;
    while( *p == ' ' ) ++p;
    if( p[0] == '-' && p[1] == 'n' ) {
        WndStyle &= ~GUI_GMOUSE;
        p += 2;
    }
    while( *p == ' ' ) ++p;
    if( p[0] == '-' && p[1] == '1' ) {
        #ifdef __DOS__
            BIOSSetPage( 1 ); // just make sure it works for the debugger
        #endif
        p += 2;
    }
    WndGadgetInit();
    WndInit( "Sample Application" );
    WndCreateStatusWindow( &WndColours[GUI_MENU_STANDOUT] );
    GUIGetDialogColours( WndDlgColours );
    WndStatusText( "Hello World!" );
    WndSetIcon( WndMain, &MainIcon );
    WndMainMenuProc( WndMain, MENU_OPEN1 );
} // returning starts the events rolling
void ProcPaint( void )
{
    wnd_class           wndcls;
    gui_colour          fore;
    gui_colour          back;
    gui_colour_set      *set;
    bool                dialog;
    int                 attr;

    dialog = FALSE;
    wndcls = WND_NO_CLASS;
    if( ScanStatus() ) {
        attr = 0;
    } else if( ScanCmd( "DIalog\0" ) == 0 ) {
        dialog = TRUE;
        attr = ScanAttr( DlgAttrMap, ArraySize( DlgAttrMap ) );
    } else {
        wndcls = ReqWndName();
        attr = ScanAttr( AttrMap, ArraySize( AttrMap ) );
    }
    fore = ScanColour();
    ScanCmd( "On\0" );
    back = ScanColour();
    ReqEOC();
    if( attr < 0 )
        return;
    if( wndcls == WND_NO_CLASS ) {
        if( dialog ) {
            GUIGetDialogColours( WndDlgColours );
            set_dlg_attr( (gui_dlg_attr)attr, fore, back );
            GUISetDialogColours( WndDlgColours );
        } else {
            WndStatusColour.fore = fore;
            WndStatusColour.back = back;
            if( WndHaveStatusWindow() ) {
                WndCloseStatusWindow();
                WndCreateStatusWindow( &WndStatusColour );
            }
        }
    } else {
        set = WndClassColour[wndcls];
        if( set == NULL ) {
            set = WndAlloc( sizeof( WndColours ) );
            memcpy( set, WndColours, sizeof( WndColours ) );
            WndClassColour[wndcls] = set;
        }
        set_wndcls_attr( (wnd_attr)attr, set, fore, back, ( wndcls == WND_ALL ) );
        _SwitchOn( SW_PENDING_REPAINT );
    }
}
static void PrintDialogColours( void )
{
    int             i;
    gui_dlg_attr    dlgattr;
    char            fore[20];
    char            back[20];
    char            attr[30];

    GUIGetDialogColours( WndDlgColours );
    for( i = 0; i < ArraySize( DlgAttrMap ); ++i ) {
        dlgattr = DlgAttrMap[i].attr;
        GetAttrName( DlgAttrMap, i, attr );
        GetColourName( WndDlgColours[dlgattr].fore, fore );
        GetColourName( WndDlgColours[dlgattr].back, back );
        Format( TxtBuff, "%s dialog %s %s on %s", GetCmdName( CMD_PAINT ), attr, fore, back );
        WndDlgTxt( TxtBuff );
    }
}