maskfld.cpp Corretto check search

git-svn-id: svn://10.65.10.50/trunk@2328 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-20 16:17:48 +00:00
parent 609afe9ac3
commit 8852136b8e
2 changed files with 55 additions and 19 deletions

View File

@ -1792,8 +1792,10 @@ bool TBrowse::check(CheckTime t)
const TMaskmode mode = (TMaskmode)field().mask().mode();
CheckType chk = _fld->check_type();
if (chk == CHECK_REQUIRED && (t == STARTING_CHECK || mode == MODE_QUERY))
chk = CHECK_NORMAL;
const int ne = do_input(TRUE);
if (t == STARTING_CHECK || mode == MODE_QUERY) chk = CHECK_NORMAL;
if (ne || chk == CHECK_REQUIRED)
{
_cursor->setkey();
@ -1809,7 +1811,7 @@ bool TBrowse::check(CheckTime t)
}
else
{
if (t == CHECK_SEARCH)
if (chk == CHECK_SEARCH)
{
passed = TRUE;
}

View File

@ -104,6 +104,11 @@ protected:
// @cmember Ritorna il campo della maschera corrispondente alla cella dello
// spreadsheet indicata da <p cell> (chiama <mf TMask::col2field>)
TMask_field* cell2field(const XI_OBJ* cell) const;
// @cmember Ritorna la posizione della colonna con identificatore <p cid>
int cid2col(short cid) const;
// @cmember Ritorna la colonna corrispondente al campo <p f> della maschera
int field2col(const TMask_field* f) const;
// @cmember Aggiorna il record sullo spreadsheet
void update_rec(int rec);
TMask_field* field(short id) const;
@ -521,6 +526,26 @@ TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
return col2field(cell->v.cell.column);
}
int TSpreadsheet::cid2col(short cid) const
{
CHECKD(cid >= FIRST_FIELD, "Bad column id ", cid);
int num;
XI_OBJ** column = xi_get_member_list(_list, &num);
for (int c = num-1; c > 1; c--)
{
if (column[c]->cid == cid)
break;
}
return c;
}
int TSpreadsheet::field2col(const TMask_field* f) const
{
const short cid = FIRST_FIELD + (f->dlg() % 100) - 1;
return cid2col(cid);
}
void TSpreadsheet::update_rec(int rec)
{
const int riga = rec2row(rec);
@ -545,6 +570,8 @@ void TSpreadsheet::update_rec(int rec)
// Cerca una colonna abilitata a partire da colonna
// La prima cella utilizzabile ha indice 1
// rec e' un numero di record assoluto
// colonna e' un numero di colonna a video: puo' succedere che la 3 corrisponda al campo 107
int TSpreadsheet::find_enabled_column(int rec, int colonna, int direction) const
{
CHECKD(direction == +1 || direction == -1, "Bad column search direction", direction);
@ -553,22 +580,30 @@ int TSpreadsheet::find_enabled_column(int rec, int colonna, int direction) const
if (colonna <= 0 || colonna > last)
colonna = 1;
if (!cell_disabled(rec, colonna-1))
return colonna;
int num;
XI_OBJ** column = xi_get_member_list(_list, &num);
for (int c = colonna+direction ; c != colonna; c += direction)
bool first = TRUE;
for (int c = colonna; first || c != colonna; c += direction)
{
if (c > last)
c = 1;
{
c = 1; first = FALSE;
}
else
if (c < 1) c = last;
if (!cell_disabled(rec, c-1))
if (c < 1)
{
c = last; first = FALSE;
}
const short n = column[c]->cid - FIRST_FIELD;
if (!cell_disabled(rec, n))
return c;
}
return 0;
}
// riga (da 0), colonna (0 = numero, 1 = prima cella, ...)
void TSpreadsheet::set_focus_cell(int riga, int colonna)
{
@ -668,7 +703,6 @@ bool TSpreadsheet::destroy(
{
_disabled.destroy(rec, TRUE); // Destroy enable info
ok = _str.destroy(rec, TRUE); // Destroy line
// enable_cell(_str.items(), -1); // Enable last line
}
if (ok && mask().is_running())
@ -890,7 +924,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if ( xiev->v.xi_obj != NULL )
{
set_pos(xiev->v.xi_obj->v.cell.row, xiev->v.xi_obj->v.cell.column);
};
}
if (oldrec != _cur_rec || !_row_dirty)
{
@ -979,11 +1013,12 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (_check_enabled)
{
TMask_field* f = cell2field(xiev->v.xi_obj);
const int col = (f->dlg()-FIRST_FIELD) % 100;
if (cell_disabled(_cur_rec, col)) // If the cell is disabled ...
const int logical_column = (f->dlg()-FIRST_FIELD) % 100;
const int physical_column = xiev->v.xi_obj->v.cell.column;
if (cell_disabled(_cur_rec, logical_column)) // If the cell is disabled ...
{
const int dir = _lastab == K_TAB ? +1 : -1;
const int nex = find_enabled_column(_cur_rec, col+1, dir);
const int nex = find_enabled_column(_cur_rec, physical_column, dir);
if (nex > 0) // If at least one enabled cell exists
{
// _edit_field = NULL;
@ -995,7 +1030,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
else
{
_edit_field = f;
_cur_col = col+1;
_cur_col = physical_column;
_edit_field->set_focusdirty(_cell_dirty = FALSE);
}
}
@ -1078,9 +1113,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (!ok && k == K_F9) // Ricerca non completata?
{
_edit_field = &sheet_mask().focus_field();
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col) // Ricerca alternativa
const int col = field2col(_edit_field);
if (col != _cur_col) // Ricerca alternativa
{
_cur_col = col;
dispatch_e_char(win(), K_F9);
@ -1206,7 +1240,7 @@ XI_OBJ* TSpreadsheet::find_column(
if (columns[c]->cid == col)
break;
}
if (c == num)
{
yesnofatal_box("Can't find column with id=%d", col);