EVENT pulldownfilter( EVENT ev, a_dialog *info ) { a_list *list = NULL; a_combo_box *combo; VSCREEN *vs; SAREA area; VFIELD *fld; fld = info->curr; if( fld->typ == FLD_PULLDOWN ) { list = fld->ptr; } else if( fld->typ == FLD_COMBOBOX ) { combo = fld->ptr; list = &combo->list; } if( list->get == NULL ) { list->get = ( bool (*) ( void *, unsigned, char *, unsigned ) ) uigetlistelement; // set get_element function } switch( ev ) { case EV_MOUSE_DCLICK: case EV_MOUSE_PRESS: { ORD row, col; uivmousepos( info->vs, &row, &col ); area = fld->area; area.width += 1; /* extra column for button */ if( fld->typ == FLD_COMBOBOX ) { /* mouse press must be on little button at right */ area.col += area.width; area.width = 1; } if( fld->typ == FLD_COMBOBOX || fld->typ == FLD_PULLDOWN ) { /* mouse press must be on top line */ area.height = 1; } if( row < area.row || row >= area.row + area.height ) break; if( col < area.col || col >= area.col + area.width ) break; /* FALLS into next case */ } case EV_CURSOR_DOWN: case EV_ALT_CURSOR_DOWN: /* list->box must be null */ area = fld->area; vs = info->vs; area.row += ( vs->area.row + 2 ); area.col += vs->area.col; if( fld->typ == FLD_COMBOBOX ) { area.col++; } if( area.row + area.height >= UIData->height ) { area.row -= area.height + 3; } vs = uiopen( &area, NULL, V_DIALOGUE | V_LISTBOX ); area.row = 0; area.col = 0; list->box = uibeglistbox( vs, &area, list ); if( ev != EV_MOUSE_PRESS && ev != EV_MOUSE_DCLICK && fld->typ == FLD_COMBOBOX ) { info->dirty = TRUE; setcombobuffer( info, fld ); print_field( info->vs, fld, TRUE ); } break; } return( ev ); }
static ui_event pulldownfilter( ui_event ui_ev, a_dialog *ui_dlg_info ) { a_list *list = NULL; a_combo_box *combo; VSCREEN *vs; SAREA area; VFIELD *fld; fld = ui_dlg_info->curr; if( fld->typ == FLD_PULLDOWN ) { list = fld->u.list; } else if( fld->typ == FLD_COMBOBOX ) { combo = fld->u.combo; list = &combo->list; } switch( ui_ev ) { case EV_MOUSE_DCLICK: case EV_MOUSE_PRESS: { ORD row, col; uivmousepos( ui_dlg_info->vs, &row, &col ); area = fld->area; area.width += 1; /* extra column for button */ if( fld->typ == FLD_COMBOBOX ) { /* mouse press must be on little button at right */ area.col += area.width; area.width = 1; } if( fld->typ == FLD_COMBOBOX || fld->typ == FLD_PULLDOWN ) { /* mouse press must be on top line */ area.height = 1; } if( row < area.row || row >= area.row + area.height ) break; if( col < area.col || col >= area.col + area.width ) { break; } /* FALLS into next case */ } case EV_CURSOR_DOWN: case EV_ALT_CURSOR_DOWN: /* list->box must be null */ area = fld->area; vs = ui_dlg_info->vs; area.row += ( vs->area.row + 2 ); area.col += vs->area.col; if( fld->typ == FLD_COMBOBOX ) { area.col++; } if( area.row + area.height >= UIData->height ) { area.row -= area.height + 3; } vs = uiopen( &area, NULL, V_DIALOGUE | V_LISTBOX ); area.row = 0; area.col = 0; list->box = uibeglistbox( vs, &area, list ); if( ui_ev != EV_MOUSE_PRESS && ui_ev != EV_MOUSE_DCLICK && fld->typ == FLD_COMBOBOX ) { ui_dlg_info->dirty = true; setcombobuffer( ui_dlg_info, fld ); print_field( ui_dlg_info->vs, fld, true ); } break; } return( ui_ev ); }
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 ); }
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 ); }