示例#1
0
EVENT GUICreateMenuPopup( gui_window *wnd, gui_point *location,
                          MENUITEM *menu, gui_mouse_track track,
                          gui_ctl_id *curr_id )
{
    EVENT       ev;
    gui_ctl_id  id;
    ATTR        attr_active;
    ATTR        attr_hot;
    ATTR        attr_curr_active;
    ATTR        attr_hot_curr;
    ATTR        attr_inactive;
    ATTR        attr_curr_inactive;
    ATTR        attr_menu;
    gui_window  *top;
    SAREA       area;
    DESCMENU    desc;

    MenuWnd = wnd;
    if( MenuState == MENU_NONE ) {
        MenuState = MENU_SYS;
    }
    if( menu == NULL ) {
        return( EV_NO_EVENT );
    }
    attr_active         = UIData->attrs[ATTR_ACTIVE];
    attr_hot            = UIData->attrs[ATTR_HOT];
    attr_curr_active    = UIData->attrs[ATTR_CURR_ACTIVE];
    attr_hot_curr       = UIData->attrs[ATTR_HOT_CURR];
    attr_inactive       = UIData->attrs[ATTR_INACTIVE];
    attr_curr_inactive  = UIData->attrs[ATTR_CURR_INACTIVE];
    attr_menu           = UIData->attrs[ATTR_MENU];

    UIData->attrs[ATTR_ACTIVE]          = wnd->colours[GUI_MENU_PLAIN];
    UIData->attrs[ATTR_HOT]             = 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];
    UIData->attrs[ATTR_INACTIVE]        = wnd->colours[GUI_MENU_GRAYED];
    UIData->attrs[ATTR_CURR_INACTIVE]   = wnd->colours[GUI_MENU_GRAYED_ACTIVE];
    UIData->attrs[ATTR_MENU]            = wnd->colours[GUI_MENU_FRAME];

    ev = 0;
    if( ( curr_id != NULL ) && ( *curr_id != 0 ) ) {
        ev = ID2EV( *curr_id );
    }
    top = GUIGetTopWnd( wnd );
    COPYAREA( top->use, area );
    area.row += top->screen.area.row;
    area.col += top->screen.area.col;

    if( !uiposfloatingpopup( menu, &desc, wnd->screen.area.row + location->y,
                            wnd->screen.area.col + location->x, &area, NULL ) ) {
        return( EV_NO_EVENT );
    }
    ev = uicreatepopupinarea( menu, &desc, track & GUI_TRACK_LEFT,
                              track & GUI_TRACK_RIGHT, ev, &area, false );

    if( ev == EV_KILL_UI ) {
        uiforceevadd( EV_KILL_UI );
        ev = EV_NO_EVENT;
    }

    GUIProcessMenuCurr( NULL );

    UIData->attrs[ATTR_ACTIVE]          = attr_active;
    UIData->attrs[ATTR_HOT]             = attr_hot;
    UIData->attrs[ATTR_CURR_ACTIVE]     = attr_curr_active;
    UIData->attrs[ATTR_HOT_CURR]        = attr_hot_curr;
    UIData->attrs[ATTR_INACTIVE]        = attr_inactive;
    UIData->attrs[ATTR_CURR_INACTIVE]   = attr_curr_inactive;
    UIData->attrs[ATTR_MENU]            = attr_menu;

    if( ( ev != EV_MOUSE_DCLICK ) && ( ev != EV_NO_EVENT ) ) {
        if( IS_CTLEVENT( ev ) ) {
            id = EV2ID( ev );
            GUIEVENTWND( wnd, GUI_CLICKED, &id );
            if( curr_id != NULL ) {
                *curr_id = id;
            }
        } else {
            GUIProcessSysMenuEvent( ev, wnd );
        }
    }
    if( MenuState == MENU_SYS ) {
        MenuState = MENU_NONE;
    }
    MenuWnd = NULL;

    return( ev );
}
示例#2
0
char *HelpSearch( HelpHdl hdl )
{
    EVENT               event;
    char                done;
    char                *ret;

    static EVENT        events[] = {
        EV_NO_EVENT,
        EV_ENTER,
        EV_ESCAPE,
        EV_MOUSE_PRESS,
        EV_LIST_BOX_DCLICK,
        EV_NO_EVENT
    };

    searchHdl = hdl;
    listData = hdl->header.topiccnt;
    curHelpDialog = uibegdialog( "Search", helpSearchDialog, 12, 60, 0, 0 );
    if( editCtl.buffer == NULL ) {
        fillListBox( "" );
    } else {
        fillListBox( editCtl.buffer );
    }
    uipushlist( NULL );     /* modal barrier */
    uipushlist( events );
    done = 0;
    while( !done ) {
        event = uidialog( curHelpDialog );
        switch( event ) {
        case EV_MOUSE_PRESS:
            if( curHelpDialog->curr != NULL ) {
                if( curHelpDialog->curr->ptr == &listBox ) {
                    copyLBLinetoEditCtl( listBox.box->row );
                }
            }
            break;
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
        /* fall through */
        case EV_ESCAPE:
            ret = NULL;
            done = 1;
            break;
        case EV_ENTER:
        case EV_LIST_BOX_DCLICK:
            ret = HelpMemAlloc( MAX_EDIT_LINE_LEN );
            GetLBItemLiteral( &listData, listBox.box->row, ret,
                              MAX_EDIT_LINE_LEN );
            if( ret[0] == '\0' ) {
                HelpMemFree( ret );
                ret = NULL;
            }
            done = 1;
            break;
        }
    }
    uipoplist();
    uipoplist();
    uienddialog( curHelpDialog );
    return( ret );
}
示例#3
0
bool GUIXCreateDialog( gui_create_info *dlg_info, gui_window *wnd,
                       int num_controls, gui_control_info *controls_info,
                       bool sys, long dlg_id )
{
    EVENT       ev;
    int         i;
    a_dialog    *ui_dlg_info;
    VFIELD      *fields;
    char        *title;
    VFIELD      *focus;
    int         size;
    bool        colours_set;
    bool        ok;

    if( dlg_id != -1 ) {
        if( !GUICreateDialogFromRes( dlg_id, dlg_info->parent,
                                     dlg_info->call_back, dlg_info->extra ) ) {
            return( false );
        }
        GUIMemFree( wnd );
        return( true );
    }

    sys = sys;
    RadioGroup = NULL;
    Group = false;
    fields = NULL;
    title = NULL;
    ui_dlg_info = NULL;
    colours_set = false;

    wnd->flags |= DIALOG;
    if( !GUISetupStruct( wnd, dlg_info, true ) ) {
        return( false );
    }

    size = ( num_controls + 1 ) * sizeof( VFIELD );
    fields = (VFIELD *)GUIMemAlloc( size );
    if( fields == NULL ) {
       return( false );
    }
    memset( fields, 0, size );
    focus = NULL;
    for( i = 0; i < num_controls; i++ ) {
        uiyield();
        if( !GUIDoAddControl( &controls_info[i], wnd, &fields[i] ) ) {
            GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
            return( false );
        } else {
            if( ( focus == NULL ) && ( controls_info[i].style & GUI_FOCUS ) ) {
                focus = &fields[i];
            }
        }
    }
    CleanUpRadioGroups();
    fields[num_controls].typ = FLD_VOID; /* mark end of list */
    title = GUIStrDup( dlg_info->title, &ok );
    if( !ok ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    colours_set = GUISetDialColours();
    ui_dlg_info = uibegdialog( title, fields, wnd->screen.area.height,
                             wnd->screen.area.width, wnd->screen.area.row,
                             wnd->screen.area.col );
    if( ui_dlg_info == NULL ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    if( focus != NULL ) {
        uidialogsetcurr( ui_dlg_info, focus );
    }
    if( !InsertDialog( wnd, ui_dlg_info, num_controls, title, colours_set ) ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    for( i = 0; i < num_controls; i++ ) {
        uiyield();
        GUIInsertControl( wnd, &controls_info[i], i );
    }
    GUIEVENTWND( wnd, GUI_INIT_DIALOG, NULL );
    uipushlist( NULL );
    uipushlist( GUIUserEvents );
    GUIPushControlEvents();
    uipushlist( DlgEvents );
    while( ( GetDialog( ui_dlg_info ) != NULL ) ) {
        ev = uidialog( ui_dlg_info );
        switch( ev ) {
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
        case EV_ESCAPE:
            GUIEVENTWND( wnd, GUI_DIALOG_ESCAPE, NULL );
            GUICloseDialog( wnd );
            break;
        default :
            GUIProcessControlNotify( ev, ui_dlg_info, wnd );
        }
    }
    return( true );
}
示例#4
0
static EVENT hlpwait( VTAB *tab )
{
    bool                done;
    static EVENT        bumpev = EV_NO_EVENT;
    char                *next_name;
    unsigned            len1;
    unsigned            len2;

    helpCur = field_find( helpTab, helpStack->cur );
    if( helpTab != NULL && helpCur == NULL ) {
        helpCur = helpTab;
    }
    tab->other = helpCur;
    tab->curr = helpCur;
    if( helpCur != NULL ) {
        tab->home = helpCur->area.col;
    }
    uipushlist( helpEventList );
    if( bumpev != EV_NO_EVENT ) {
        uitabfilter( bumpev, tab );
        helpCur = tab->curr;
        bumpev = EV_NO_EVENT;
    }
    done = false;
    while( !done ) {
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_CURR_EDIT ) );
        }
        do {
            uipushlist( keyShift );
            curEvent = uivget( &helpScreen );
            if( curEvent == EV_MOUSE_PRESS ) {
                ignoreMouseRelease = false;
            }
            uipoplist();
            curEvent = uigadgetfilter( curEvent, &vGadget );
            curEvent = uitabfilter( curEvent, tab );
        } while( curEvent == EV_NO_EVENT );
        if( eventMapFn != NULL ) {
            curEvent = (*eventMapFn)( curEvent );
        }
        curEvent = uihotspotfilter( &helpScreen, hotSpotFields, curEvent );
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_EDIT ) );
        }
        switch( curEvent ) {
        case EV_HELP:
            nexttopic( helpWord );
            done = true;
            break;
        case EV_BOTTOM:
        case E_UP:
        case EV_PAGE_UP:
        case EV_PAGE_DOWN:
        case EV_CURSOR_UP:
        case EV_CURSOR_DOWN:
        case EV_TOP:
        case E_DOWN:
        case EV_SCROLL_VERTICAL:
            if( curEvent == EV_BOTTOM ) {
                bumpev = EV_CURSOR_DOWN;
            } else if( curEvent == EV_TOP ) {
                bumpev = EV_CURSOR_UP;
            }
            helpStack->cur = field_count( helpTab, helpCur );
            done = true;
            break;
        case '-':
        case EV_MOUSE_RELEASE_R:
        case EV_ALT_B:
        case 'b':
        case 'B':
        case EV_F8:
        case EV_F4:
            prevtopic();
            if( strcmp( helpStack->helpfname, curFile ) ) {
                len1 = strlen( helpStack->word );
                len2 = strlen( helpStack->helpfname );
                helpCur = HelpMemAlloc( sizeof( a_field ) + len1 + len2 );
                memcpy( helpCur->keyword, helpStack->word, len1 );
                memcpy( helpCur->keyword + len1, helpStack->helpfname, len2 );
                helpCur->keyword[len1 + len2] = '\0';
                helpCur->key1_len = len1;
                helpCur->key2_len = len2;
                helpCur->next = NULL;
//              prevtopic();
                helpTab = helpCur;
            }
            done = true;
            break;
        case EV_ALT_S:
        case 'S':
        case 's':
            if( helpSearchHdl != NULL ) {
                uipoplist();
                next_name = HelpSearch( helpSearchHdl );
                if( next_name != NULL ) {
                    nexttopic( next_name );
                    HelpMemFree( next_name );
                    done = true;
                }
                uipushlist( helpEventList );
            }
            break;
        case EV_FIELD_CHANGE:
            helpCur = tab->curr;
            break;
        case EV_MOUSE_RELEASE:
            if( tab->other == NULL )
                break;
            if( ignoreMouseRelease ) {
                /* this mouse release is for a mouse press that occured
                 * before this help topic was opened */
                 ignoreMouseRelease = false;
                 break;
            }
            tab->other = tab->curr;
            /* fall through */
        case EV_ENTER:  /*same as page-down if there are other topics*/
        case EV_F7:
        case '+':
            // DEN 90/04/12 - next line necessary for mouse release kludge
            helpCur = tab->curr;
            if( helpTab != NULL ) {
                if( helpCur->key2_len == 0 ) {
                    nexttopic( helpCur->keyword );
                }
                done = true;
            }
            break;
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
            /* fall through */
        case EV_ESCAPE:
            done = true;
            break;
        }
    }
    uipoplist();
    return( curEvent );
}