예제 #1
0
void uimovefield( a_dialog *info, VFIELD *curr, int row_diff, int col_diff )
{
    a_combo_box *combo;
    a_list      *list;

    info = info;

    switch( curr->typ ) {
    case FLD_COMBOBOX :
        combo = curr->ptr;
        if( combo->perm ) {
            uimovelistbox( &combo->list, row_diff, col_diff );
        } else {
            uiendlistbox( &combo->list );
        }
        break;
    case FLD_LISTBOX :
    case FLD_EDIT_MLE :
        list = (a_list *)curr->ptr;
        uimovelistbox( list, row_diff, col_diff );
        if( list->box != NULL ) {
            uivsetactive( list->box->vs );
        }
        break;
    case FLD_PULLDOWN :
        uiendlistbox( (a_list *)curr->ptr );
        break;
    }
}
예제 #2
0
void uimovefield( a_dialog *ui_dlg_info, VFIELD *curr, int row_diff, int col_diff )
{
    a_combo_box *combo;
    a_list      *list;

    /* unused parameters */ (void)ui_dlg_info;

    switch( curr->typ ) {
    case FLD_COMBOBOX :
        combo = curr->u.combo;
        if( combo->perm ) {
            uimovelistbox( &combo->list, row_diff, col_diff );
        } else {
            uiendlistbox( &combo->list );
        }
        break;
    case FLD_LISTBOX :
    case FLD_EDIT_MLE :
        list = curr->u.list;
        uimovelistbox( list, row_diff, col_diff );
        if( list->box != NULL ) {
            uivsetactive( list->box->vs );
        }
        break;
    case FLD_PULLDOWN :
        uiendlistbox( curr->u.list );
        break;
    }
}
예제 #3
0
void uifreedialog( a_dialog *ui_dlg_info )
{
    VFIELD              *fields;  // pointer to array of fields in dialog box
    a_list              *list;
    a_combo_box         *combo;
//  an_edit_control     *edit;

    exit_field( ui_dlg_info, ui_dlg_info->curr );

    for( fields = ui_dlg_info->fields; fields->typ != FLD_NONE; fields++ ) {
        switch( fields->typ ) {
        case FLD_LISTBOX:
        case FLD_PULLDOWN:
        case FLD_EDIT_MLE:
            list = fields->u.list;
            uiendlistbox( list );
            break;
//        case FLD_INVISIBLE_EDIT:
//        case FLD_EDIT:
//            edit = fields->u.edit;
//            uifree( edit->buffer );
//            edit->buffer = NULL;        //  Need this null for next
//            break;                      //  time around
        case FLD_COMBOBOX:
            combo = fields->u.combo;
            list = &combo->list;
//            edit = &combo->edit;
//            uifree( edit->buffer );
//            edit->buffer = NULL;
            uiendlistbox( list );       // Shut down listbox
            break;
        }
    }
}
예제 #4
0
void uifreedialog( a_dialog  *info )
{
    VFIELD              *fields;  // pointer to array of fields in dialog box
    a_list              *list;
    short unsigned      i;
    a_combo_box         *combo;
//  an_edit_control     *edit;

    fields = info->fields;

    exit_field( info, info->curr );
    for( i = 0 ; fields[i].typ != FLD_VOID ; ++i ) {
        switch( fields[i].typ ) {
            case FLD_LISTBOX:
            case FLD_PULLDOWN:
            case FLD_EDIT_MLE:
                list = fields[i].ptr;
                uiendlistbox( list );
                break;
//          case FLD_INVISIBLE_EDIT:
//          case FLD_EDIT:
//              edit = fields[i].ptr;
//              uifree( edit->buffer );
//              edit->buffer = NULL;            //  Need this null for next
//              break;                          //  time around
            case FLD_COMBOBOX:
                combo = fields[i].ptr;
                list = &combo->list;
//              edit = &combo->edit;
//              uifree( edit->buffer );
//              edit->buffer = NULL;
                uiendlistbox( list );       // Shut down listbox
                break;
        }
    }
}
예제 #5
0
static bool exit_field( a_dialog *info, VFIELD *field )
{
    bool                flag;
    an_edit_control     *edit;
    a_list              *list;
    a_combo_box         *combo;

    flag = FALSE;
    if( field != NULL ) {
        switch( field->typ ) {
        case FLD_EDIT :
        case FLD_INVISIBLE_EDIT:
            if( info->edit_data != NULL ) {
                edit = field->ptr;
                if( uieditisdirty() ) {
                    flag = TRUE;
                }
                uiedittrim( info->edit_data->edit_buffer );
                edit->buffer = info->edit_data->edit_buffer;
                edit->length = info->edit_data->edit_eline.length;
                uiendedit();
                info->edit_data = NULL;
            }
            uinocursor( info->vs );
            break;
        case FLD_COMBOBOX :
            combo = field->ptr;
            list = &combo->list;
            edit = &combo->edit;

            if( !combo->perm ) {
                uiendlistbox( list );           // Shut down listbox
            }
            if( info->edit_data != NULL ) {
                if( uieditisdirty() ) {
                    flag = TRUE;
                }
                uiedittrim( info->edit_data->edit_buffer );
                edit->buffer = info->edit_data->edit_buffer;
                edit->length = info->edit_data->edit_eline.length;
                uiendedit();
                info->edit_data = NULL;
            }
            uinocursor( info->vs );
            break;
        case FLD_PULLDOWN :
            list = field->ptr;
            uiendlistbox( list );
            break;
        case FLD_LISTBOX :
            list = field->ptr;
            list->box->attr = ATTR_EDIT;
            uipaintlistbox( list );
            break;
        case FLD_EDIT_MLE :
            list = field->ptr;
            list->box->attr = ATTR_NORMAL;
            uipaintlistbox( list );
            break;
        }
    }
    return( flag );
}
예제 #6
0
EVENT uilistbox( EVENT ev, a_list *list, bool permanent )
{
    int             listsize;
    int             maxline;
    int             newevent;
    a_list_info     *box;
    int             old_line;
    ORD             old_row;
    bool            close;

    if( Dclick ) {
        switch( ev ) {
        case EV_MOUSE_PRESS :
            Dclick = FALSE; /* must have gotten dlick without release */
            /* fall through */
        case EV_SCROLL_LINE_UP :
        case EV_SCROLL_LINE_DOWN :
        case EV_SCROLL_PAGE_UP :
        case EV_SCROLL_PAGE_DOWN :
        case EV_PAGE_UP :
        case EV_PAGE_DOWN :
        case EV_CURSOR_UP :
        case EV_CURSOR_DOWN :
            SelStart = FALSE;
            break;
        case EV_MOUSE_RELEASE :
            Dclick = FALSE;
            /* fall through */
        default :
            return( ev );
        }
    }
    close = FALSE;
    box = list->box;
    old_line = box->line;
    old_row = box->row;
    listsize = uilistsize( list );

    if( listsize > box->area.height ) {
        maxline = listsize - box->area.height;
    } else {
        maxline = 0;
    }

    if( maxline > 0 ) {
        ev = uigadgetfilter( ev, &box->gadget );
    }

    newevent = EV_NO_EVENT;
    switch( ev ) {
        case EV_MOUSE_DCLICK:
            Dclick = TRUE;
        case EV_MOUSE_PRESS:
        case EV_MOUSE_RELEASE:
        case EV_MOUSE_REPEAT:
        case EV_MOUSE_DRAG:
            {
                int         row, col, mpos;

                mpos = getmouseregion( list, &row, &col );
                newevent = ev;
                if( mpos == R_SEL ) {
                    SelStart = TRUE;
                    box->row  = (ORD) row - box->area.row;
                    box->row += box->line;
                }
                if( ev == EV_MOUSE_RELEASE ) {
                    if( mpos == R_SEL ) {
                        list->choice = list->box->row;
                        newevent = EV_LIST_BOX_CHANGED;
                    }
                    if( SelStart ) {
                        close = TRUE;
                        SelStart = FALSE;
                    }
                } else if( ev == EV_MOUSE_PRESS || ev == EV_MOUSE_DCLICK ) {
                    if( mpos == R_SEL ) {
                        if( ev == EV_MOUSE_DCLICK ) {
                            newevent = EV_LIST_BOX_DCLICK;
                        }
                    } else {
                        close = TRUE;
                    }
                } else if( mpos == R_UP  &&  box->line > 0  &&  SelStart ) {
                    box->line--;
                    box->row--;
                } else if( mpos == R_DOWN  &&  box->line < maxline ) {
                    box->line++;
                    box->row++;
                }
            }
            break;
        case EV_CURSOR_UP :
            if( box->row > 0 ) {
                if( box->row == box->line ) {
                    box->line--;
                }
                box->row--;
                list->choice = box->row;
                newevent = EV_LIST_BOX_CHANGED;
            }
            if( selectoutofrange( box ) ) {
                box->line = box->row;
                setstartline( list );
            }
            break;
        case EV_SCROLL_LINE_UP :
            if( box->line > 0 ) {
                box->line--;
            }
            break;
        case EV_CURSOR_DOWN :
            if( box->row < listsize - 1 ) {
                if( box->row - box->line == box->area.height - 1
                    && box->line < maxline ) {
                        ++box->line;
                }
                ++box->row;
                list->choice = box->row;
                newevent = EV_LIST_BOX_CHANGED;
            }
            if( selectoutofrange( box ) ) {
                box->line = box->row;
                setstartline( list );
            }
            break;
        case EV_SCROLL_LINE_DOWN :
            if( box->line < maxline ) {
                box->line++;
            }
            break;
        case EV_PAGE_UP :
            if( box->row == box->line ) {
                if( box->line < ( box->area.height - 1 ) ) {
                    box->line = 0;
                } else {
                    box->line -= ( box->area.height - 1 );
                }
                box->row -= old_line - box->line;
            } else {
                box->row = box->line;
            }
            if( box->row != old_row ) {
                list->choice = box->row;
                newevent = EV_LIST_BOX_CHANGED;
            }
            break;
        case EV_SCROLL_PAGE_UP :
            if( box->line < box->area.height ) {
                box->line = 0;
            } else {
                box->line -= box->area.height;
            }
            break;
        case EV_PAGE_DOWN :
            if( box->row == ( box->line + box->area.height - 1 ) ) {
                box->line += box->area.height - 1;
                if( box->line > maxline ) {
                    box->line = maxline;
                }
                box->row += ( box->line - old_line );
            } else {
                box->row = box->line + box->area.height - 1;
            }
            if( box->row != old_row ) {
                list->choice = box->row;
                newevent = EV_LIST_BOX_CHANGED;
            }
            break;
        case EV_SCROLL_PAGE_DOWN :
            box->line += box->area.height;
            if( box->line > maxline ) {
                box->line = maxline;
            }
            break;
        case EV_SCROLL_VERTICAL :
            box->line = box->gadget.pos;
            break;
        case EV_ALT_CURSOR_UP :
            close = TRUE;
            break;
        default :
            if( isalpha( ev ) ) {
                newevent = charselect( ev, list );
            } else {
                newevent = ev;
            }
            break;
    }
    if( ( old_line != box->line ) && ( maxline > 0 ) ) {
        uisetgadget( &box->gadget, box->line );
    }
    if( box->line != old_line || box->row != old_row ) {
        uipaintlistbox( list );
    }

    if( !permanent && close ) {
        uiendlistbox( list );
        newevent = EV_LIST_BOX_CLOSED;
    }
    return( newevent );
}