示例#1
0
bool GUIXSetColours( gui_window *wnd, gui_colour_set *colours )
{
    int size;
    int i;

    size = sizeof( ATTR ) * wnd->num_attrs;
    wnd->colours = (ATTR *)GUIMemAlloc( size );
    if( wnd->colours == NULL ) {
        wnd->num_attrs = 0;
        return( false );
    }
    for( i = 0; i < wnd->num_attrs; i++ ) {
        wnd->colours[i] = MakeAttr( colours[i].fore, colours[i].back );
    }
    if( wnd->vbarmenu != NULL ) {
#if !defined( ISQL_COLOURS )
        UIData->attrs[ATTR_MENU]            = wnd->colours[GUI_MENU_FRAME];
        UIData->attrs[ATTR_ACTIVE]          = wnd->colours[GUI_MENU_PLAIN];
        UIData->attrs[ATTR_INACTIVE]        = wnd->colours[GUI_MENU_GRAYED];
        UIData->attrs[ATTR_CURR_INACTIVE]   = wnd->colours[GUI_MENU_GRAYED_ACTIVE];
        UIData->attrs[ATTR_HOT]             = wnd->colours[GUI_MENU_STANDOUT];
        UIData->attrs[ATTR_HOT_QUIET]       = wnd->colours[GUI_MENU_STANDOUT];
        UIData->attrs[ATTR_CURR_ACTIVE]     = wnd->colours[GUI_MENU_ACTIVE];
        UIData->attrs[ATTR_HOT_CURR]        = wnd->colours[GUI_MENU_ACTIVE_STANDOUT];
#endif
        uimenutitlebar();
    }
    return( true );
}
示例#2
0
static void drawbar( SAREA area, void *dummy )
/********************************************/
{
    forbid_refresh();
    dummy = dummy;
    if( area.row < uimenuheight() ) {
        mfill( &UIData->screen, area.row, 0,
               UIData->attrs[ ATTR_ACTIVE ], ' ', UIData->width, area.height );
        uimenutitlebar();
    }
    permit_refresh();
}
示例#3
0
EVENT intern process_menuevent( VSCREEN *vptr, EVENT ev )
/*******************************************************/
{
    register    int                     index;
    register    int                     oldmenu = 0;
    register    EVENT                   itemevent;
    auto        EVENT                   newevent;
    auto        DESCMENU*               desc;
    auto        int                     menu;
    auto        bool                    select;
    auto        ORD                     mouserow;
    auto        ORD                     mousecol;
    auto        int                     mouseon;

    newevent = ev;
    if( ev > EV_NO_EVENT && ev <= EV_LAST_KEYBOARD ) {
        /* this allows alt numeric keypad stuff to not activate the menus */
        Menu->altpressed = FALSE;
    }
    if( isdialogue( vptr ) == FALSE ) {
        if( NumMenus > 0 ) {
            desc = &Describe[ Menu->menu - 1 ];
            newevent = EV_NO_EVENT; /* Moved here from "else" case below */
            if( Menu->popuppending ) {
                Menu->popuppending = FALSE;
                itemevent = createpopup( desc, &ev );
            } else {
                itemevent = EV_NO_EVENT;
            }
            if( Menu->active ) {
                oldmenu = menu = Menu->menu;
            } else {
                oldmenu = menu = 0;
            }
            select = FALSE;
            if( ev == EV_ALT_PRESS && !Menu->ignorealt ) {
                Menu->altpressed = TRUE;
            } else if( ev == EV_ALT_RELEASE && Menu->altpressed ) {
                if( Menu->active ) {
                    menu = 0;
                } else {
                    desc = &Describe[ 0 ];
                    menu = 1;
                }
                Menu->altpressed = FALSE;
            } else if( ev == EV_FUNC( 10 ) && UIData->f10menus ) {
                desc = &Describe[ 0 ];
                menu = 1;
            } else if( ev == EV_MOUSE_PRESS_R  ||
                       ev == EV_MOUSE_PRESS_M  ) {
                newevent = ev;
                menu = 0;
                Menu->draginmenu = FALSE;
            } else if( ( ev == EV_MOUSE_PRESS ) ||
                       ( ev == EV_MOUSE_DRAG ) ||
                       ( ev == EV_MOUSE_REPEAT ) ||
                       ( ev == EV_MOUSE_RELEASE ) ||
                       ( ev == EV_MOUSE_DCLICK ) ) {
                uigetmouse( &mouserow, &mousecol, &mouseon );
                if( ( mouserow < uimenuheight() ) &&
                        ( Menu->active  ||
                          ev == EV_MOUSE_PRESS  || ev == EV_MOUSE_DCLICK  ||
                          ev == EV_MOUSE_DRAG || ev == EV_MOUSE_REPEAT ) ) {
                    if( ev == EV_MOUSE_DCLICK ) {
                        ev = EV_MOUSE_PRESS;
                    }
                    menu = 0;
                    for( index = 0 ; !MENUENDMARKER( Menu->titles[ index ] ); ++index ) {
                        desc = &Describe[ index ];
                        if( ( MENU_GET_ROW( desc ) == mouserow ) &&
                                ( desc->titlecol <= mousecol ) &&
                                ( mousecol < desc->titlecol + desc->titlewidth + 2 ) ) {
                            Menu->draginmenu = TRUE;
                            Menu->popuppending = TRUE;
                            menu = index + 1;
                            break;
                        }
                    }
                } else if( Menu->active || Menu->draginmenu ) {
                    if( ( desc->area.col < mousecol )
                            && ( mousecol < desc->area.col + desc->area.width - 1 )
                            && ( mouserow < desc->area.row + desc->area.height - 1 )
                            && ( desc->area.row <= mouserow ) ) {
                        Menu->movedmenu = TRUE;
                    } else if( ev == EV_MOUSE_PRESS  ) {
                        newevent = ev;
                        menu = 0;
                        Menu->draginmenu = FALSE;
                    } else if( ev == EV_MOUSE_RELEASE ) {
                        menu = 0;
                        Menu->draginmenu = FALSE;
                    }
                } else {
                    newevent = ev;
                }
                if( ev != EV_MOUSE_RELEASE && menu != oldmenu ) {
                    Menu->movedmenu = TRUE;
                }
                if( ev == EV_MOUSE_RELEASE ) {
                    if( !Menu->movedmenu ) {
                        menu = 0;
                    } else {
                        select = TRUE;
                    }
                    Menu->movedmenu = FALSE;
                }
            } else if( uialtchar( ev ) != '\0'  ) {
                process_char( uialtchar( ev ), &desc, &menu, &select );
                newevent = EV_NO_EVENT;
            } else if( Menu->active ) {
                switch( ev ) {
                case EV_ESCAPE :
                    menu = 0;
                    break;
                case EV_RETURN :
                    if( menu > 0 ) {
                        Menu->popuppending = TRUE;
                    }
                    break;
                case EV_CURSOR_LEFT :
                    menu -= 1;
                    if( menu == 0 ) {
                        menu = NumMenus;
                    }
                    Menu->popuppending = TRUE;
                    desc = &Describe[ menu - 1 ];
                    break;
                case EV_CURSOR_RIGHT :
                    menu += 1;
                    if( menu > NumMenus ) {
                        menu = 1;
                    }
                    Menu->popuppending = TRUE;
                    desc = &Describe[ menu - 1 ];
                    break;
                case EV_CURSOR_DOWN :
                    Menu->popuppending = TRUE;
                    break;
                case EV_NO_EVENT :
                    break;
                default :
                    if( ev <= EV_LAST_KEYBOARD ) {
                        if( process_char( ev, &desc, &menu, &select ) ) {
                            break;
                        }
                    }
                    if( itemevent != EV_NO_EVENT ) {
                        newevent = itemevent;
                        select = TRUE;
                    } else {
                        newevent = ev;
                    }
                }
            } else {
                newevent = ev;
            }
            if( menu != oldmenu ) {
                if( menu > 0 && !Menu->active ) {
                    newevent = EV_MENU_ACTIVE;
                }
                Menu->active = ( menu > 0 );
                if( oldmenu > 0 ) {
                    menutitle( oldmenu, FALSE );
                }
                if( menu > 0 ) {
                    Menu->menu = menu;
                    menutitle( menu, TRUE );
                }
                if( menu == 0 || oldmenu == 0 ) {
                    uimenutitlebar();
                }
            }
            if( Menu->active ) {
                if( itemevent == EV_NO_EVENT ) {
                    if( MENUGRAYED(Menu->titles[ menu-1]) )  {
                        Menu->popuppending = FALSE;
                    } else {
                        itemevent = Menu->titles[ menu-1 ].event;
                    }
                }
                Menu->event = itemevent;
                if( select ) {
                    newevent = Menu->event;
                    Menu->active = FALSE;
                    uimenutitlebar();
                }
            }
        }
    }
    if( ev == EV_MOUSE_RELEASE ) {
        Menu->draginmenu = FALSE;
    }
    if( Menu->ignorealt ) {
        Menu->ignorealt = FALSE;
    }
    if( ( !Menu->active && ( oldmenu != 0 ) ) ||
            ( Menu->active && ( oldmenu != Menu->menu ) ) ) {
        if( ( Menu->menu > 0 ) && Menu->active ) {
            uimenucurr( &Menu->titles[Menu->menu - 1 ] );
        } else {
            /* no current menu */
            uimenucurr( NULL );
        }
    }

    if ( Menu->popuppending ) {
        InitMenuPopupPending = TRUE;
    }

    return( newevent );
}