Ejemplo n.º 1
0
EVENT uihotkeyfilter( a_dialog *ui_dlg_info, EVENT ev )
{
    char        ch, hotkey;
    VFIELD      *vf;

    /* is the event a key press or alt-key press */
    if( ev < 0x100 && isalpha( ev ) ) {
        ch = tolower( ev );
    } else {
        ch = uialtchar( ev );
    }

    if( ch ) {
        hotkey = '\0';
        for( vf = ui_dlg_info->fields ; vf->typ != FLD_VOID; ++vf ){
            switch( vf->typ ) {
            case FLD_HOT:
                hotkey = vf->u.hs->flags;
                break;
            case FLD_CHECK:
                hotkey = vf->u.check->hotkey;
                break;
            case FLD_RADIO:
                hotkey = vf->u.radio->hotkey;
                break;
            default:
                hotkey = '\0';
                break;
            }
            if( hotkey == ch ) {
                break;
            }
        }

        /* make sure the new field is hilighted */
        if( ui_dlg_info->curr != vf && vf->typ != FLD_VOID ) {
            uidialogsetcurr( ui_dlg_info, vf );
        }

        if( hotkey == ch ) {
            switch( vf->typ ) {
                case FLD_HOT:
                    ev = vf->u.hs->event;
                    break;
                case FLD_CHECK:
                    ui_dlg_info->dirty = TRUE;
                    vf->u.check->val = !vf->u.check->val;
                    print_field( ui_dlg_info->vs, vf, TRUE );
                    ev = EV_CHECK_BOX_CLICK;
                    break;
                case FLD_RADIO:
                    do_radio( ui_dlg_info, vf );
                    ev = EV_CHECK_BOX_CLICK;
                    break;
            }
        }
    }

    return( ev );
}
Ejemplo n.º 2
0
ui_event uihotkeyfilter( a_dialog *ui_dlg_info, ui_event ui_ev )
{
    char        ch, hotkey;
    VFIELD      *fields;

    /* is the event a key press or alt-key press */
    if( iseditchar( ui_ev ) && isalpha( (unsigned char)ui_ev ) ) {
        ch = tolower( (unsigned char)ui_ev );
    } else {
        ch = uialtchar( ui_ev );
    }

    if( ch ) {
        hotkey = '\0';
        for( fields = ui_dlg_info->fields; fields->typ != FLD_NONE; fields++ ) {
            switch( fields->typ ) {
            case FLD_HOT:
                hotkey = fields->u.hs->flags;
                break;
            case FLD_CHECK:
                hotkey = fields->u.check->hotkey;
                break;
            case FLD_RADIO:
                hotkey = fields->u.radio->hotkey;
                break;
            default:
                hotkey = '\0';
                break;
            }
            if( hotkey == ch ) {
                break;
            }
        }

        /* make sure the new field is hilighted */
        if( ui_dlg_info->curr != fields && fields->typ != FLD_NONE ) {
            uidialogsetcurr( ui_dlg_info, fields );
        }

        if( hotkey == ch ) {
            switch( fields->typ ) {
            case FLD_HOT:
                ui_ev = fields->u.hs->event;
                break;
            case FLD_CHECK:
                ui_dlg_info->dirty = true;
                fields->u.check->val = !fields->u.check->val;
                print_field( ui_dlg_info->vs, fields, true );
                ui_ev = EV_CHECK_BOX_CLICK;
                break;
            case FLD_RADIO:
                do_radio( ui_dlg_info, fields );
                ui_ev = EV_CHECK_BOX_CLICK;
                break;
            }
        }
    }

    return( ui_ev );
}
Ejemplo n.º 3
0
static EVENT uitabkey( EVENT ev, a_dialog *info )
{
    VFIELD          *curr, *fld;
    ORD             row, col;
    SAREA           area;
    EVENT           newev;

    if( info->first == NULL ) return( FALSE );
    curr = info->curr;
    newev = ev;
    switch( ev ){
    case EV_MOUSE_DCLICK:
    case EV_MOUSE_PRESS:
    {
        a_combo_box         *combo;
        a_list              *list;
        VSCREEN             *mousevs;

        mousevs = uivmousepos( info->vs, &row, &col );
        fld = info->first;
        while( fld != NULL ) {
            list = NULL;
            area = fld->area;
            if( fld->typ == FLD_PULLDOWN ) {
                list = fld->ptr;
                area.height = 1;
                area.width += 1;    /* pulldown button */
            } else if( fld->typ == FLD_LISTBOX ) {
                list = fld->ptr;
            } else if( fld->typ == FLD_EDIT_MLE ) {
                list = fld->ptr;
            } else if( fld->typ == FLD_COMBOBOX ) {
                area.height = 1;
                area.width += 2;    /* pulldown button */
                combo = fld->ptr;
                list = &combo->list;
            }
            if( mousevs != info->vs ) {
                if( list != NULL && list->box != NULL ) {
                    if( list->box->vs == mousevs ) {
                        break;
                    }
                }
            } else if( row >= area.row  && row < area.row + area.height &&
                        col >= area.col  && col < area.col + area.width ) {
                break;
            }
            fld = nextfield( fld );
        }
        /* check boxes don't get mouse events unless mouse over them */
        if( fld == NULL && curr != NULL && curr->typ == FLD_CHECK ) {
            newev = EV_NO_EVENT;
        } else {
            curr = fld;
        }
        break;
    }
    case EV_TAB_FORWARD :
        curr = forwardtab( info );
        break;
    case EV_TAB_BACKWARD :
        curr = backwardtab( info );
        break;
    case EV_CURSOR_RIGHT :
    case EV_CURSOR_DOWN :
    {
        a_radio             *r1, *r2;

        if( curr!= NULL && curr->typ == FLD_RADIO ) {
            fld = nextfield( curr );
            if( fld != NULL ) {
                r1 = curr->ptr;
                r2 = fld->ptr;
                if( r1->group == r2->group ) {
                    curr = fld;
                    do_radio( info, fld );
                    newev = EV_CHECK_BOX_CLICK;
                }
            }
        }
        break;
    }
    case EV_CURSOR_LEFT :
    case EV_CURSOR_UP :
    {
        a_radio             *r1, *r2;

        if( curr!= NULL && curr->typ == FLD_RADIO ) {
            if( curr != info->first ) {
                fld = curr - 1;
                r1 = curr->ptr;
                r2 = fld->ptr;
                if( r1->group == r2->group ) {
                    curr = fld;
                    do_radio( info, fld );
                    newev = EV_CHECK_BOX_CLICK;
                }
            }
        }
        break;
    }
    }
    if( info->curr != curr ) {
        uidialogsetcurr( info, curr );
    }
    return( newev );
}
Ejemplo n.º 4
0
EVENT uiprocessdialogevent( EVENT ev, a_dialog *info )
{
    VFIELD              *field;
    a_check             *check;
    an_edit_control     *edit;
    unsigned            choice;
    a_combo_box         *combo;
    a_list              *list;

    ev = uicheckmove( ev, info );
    ev = uitabkey( ev, info );
    field = info->curr;
    if( field != NULL ) {
        switch( field->typ ) {
        case FLD_CHECK:
        case FLD_RADIO:
            switch( ev ) {
            case EV_MOUSE_DCLICK:
            case EV_MOUSE_PRESS:
            case ' ' :
                ev = EV_CHECK_BOX_CLICK;
                if( field->typ == FLD_RADIO ) {
                    do_radio( info, field );
                    break;
                }
                if( field->typ == FLD_CHECK ) {
                    info->dirty = TRUE;
                    check = field->ptr;
                    check->val = !check->val;
                    print_field( info->vs, field, TRUE );
                    break;
                }
            }
            break;
        case FLD_EDIT:
        case FLD_INVISIBLE_EDIT:
            ev = uiledit( ev );
            edit = field->ptr;
            if( info->edit_data != NULL ) {
                edit->buffer = info->edit_data->edit_buffer;
                edit->length = info->edit_data->edit_eline.length;
            }
            break;
        case FLD_LISTBOX:
        case FLD_EDIT_MLE:
            list = field->ptr;
            ev = uilistbox( ev, list, TRUE );
            break;
        case FLD_PULLDOWN:
            list = field->ptr;
            if( list->box == NULL ) {
                ev = pulldownfilter( ev, info );
            } else {
                choice = list->choice;
                ev = uilistbox( ev, list, FALSE );
                if( choice != list->choice ) {
                    info->dirty = TRUE;
                    print_field( info->vs, field, TRUE );
                }
            }
            break;
        case FLD_COMBOBOX:
            combo = field->ptr;
            list  = &combo->list;
            edit  = &combo->edit;
            if( list->box == NULL ) {
                ev = pulldownfilter( ev, info );
            } else {
                choice = list->choice;
                ev = uilistbox( ev, list, combo->perm );
                if( choice != list->choice ) {
                    info->dirty = TRUE;
                    setcombobuffer( info, field );
                    print_field( info->vs, field, TRUE );
                }
            }
            ev = uiledit( ev );
            if( info->edit_data != NULL ) {
                edit->buffer = info->edit_data->edit_buffer;
                edit->length = info->edit_data->edit_eline.length;
            }
            break;
        }
    }
    ev = uihotkeyfilter( info, ev );
    ev = uihotspotfilter( info->vs, info->fields, ev );
    return( ev );
}
Ejemplo n.º 5
0
ui_event uiprocessdialogevent( ui_event ui_ev, a_dialog *ui_dlg_info )
{
    VFIELD              *field;
    a_check             *check;
    an_edit_control     *edit;
    unsigned            choice;
    a_combo_box         *combo;
    a_list              *list;

    ui_ev = uicheckmove( ui_ev, ui_dlg_info );
    ui_ev = uitabkey( ui_ev, ui_dlg_info );
    field = ui_dlg_info->curr;
    if( field != NULL ) {
        switch( field->typ ) {
        case FLD_CHECK:
        case FLD_RADIO:
            switch( ui_ev ) {
            case EV_MOUSE_DCLICK:
            case EV_MOUSE_PRESS:
            case ' ' :
                ui_ev = EV_CHECK_BOX_CLICK;
                if( field->typ == FLD_RADIO ) {
                    do_radio( ui_dlg_info, field );
                    break;
                }
                if( field->typ == FLD_CHECK ) {
                    ui_dlg_info->dirty = true;
                    check = field->u.check;
                    check->val = !check->val;
                    print_field( ui_dlg_info->vs, field, true );
                    break;
                }
            }
            break;
        case FLD_EDIT:
        case FLD_INVISIBLE_EDIT:
            ui_ev = uiledit( ui_ev );
            edit = field->u.edit;
            if( ui_dlg_info->edit_data != NULL ) {
                edit->buffer = ui_dlg_info->edit_data->edit_buffer;
                edit->length = ui_dlg_info->edit_data->edit_eline.length;
            }
            break;
        case FLD_LISTBOX:
        case FLD_EDIT_MLE:
            list = field->u.list;
            ui_ev = uilistbox( ui_ev, list, true );
            break;
        case FLD_PULLDOWN:
            list = field->u.list;
            if( list->box == NULL ) {
                ui_ev = pulldownfilter( ui_ev, ui_dlg_info );
            } else {
                choice = list->choice;
                ui_ev = uilistbox( ui_ev, list, false );
                if( choice != list->choice ) {
                    ui_dlg_info->dirty = true;
                    print_field( ui_dlg_info->vs, field, true );
                }
            }
            break;
        case FLD_COMBOBOX:
            combo = field->u.combo;
            list  = &combo->list;
            edit  = &combo->edit;
            if( list->box == NULL ) {
                ui_ev = pulldownfilter( ui_ev, ui_dlg_info );
            } else {
                choice = list->choice;
                ui_ev = uilistbox( ui_ev, list, combo->perm );
                if( choice != list->choice ) {
                    ui_dlg_info->dirty = true;
                    setcombobuffer( ui_dlg_info, field );
                    print_field( ui_dlg_info->vs, field, true );
                }
            }
            ui_ev = uiledit( ui_ev );
            if( ui_dlg_info->edit_data != NULL ) {
                edit->buffer = ui_dlg_info->edit_data->edit_buffer;
                edit->length = ui_dlg_info->edit_data->edit_eline.length;
            }
            break;
        }
    }
    ui_ev = uihotkeyfilter( ui_dlg_info, ui_ev );
    ui_ev = uihotspotfilter( ui_dlg_info->vs, ui_dlg_info->fields, ui_ev );
    return( ui_ev );
}