Corrette funzioni di trasferimento da/a maschera degli sheet:

str2mask e sua sorella mask2str.


git-svn-id: svn://10.65.10.50/trunk@1266 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-04-19 07:31:13 +00:00
parent f624c4e070
commit aef90e02ab

View File

@ -385,6 +385,7 @@ void TSpreadsheet::update_rec(int rec)
XI_OBJ row; XI_OBJ row;
XI_MAKE_ROW(&row, _list, riga); XI_MAKE_ROW(&row, _list, riga);
xi_cell_request(&row); // Update internal values xi_cell_request(&row); // Update internal values
if (_update)
xi_set_row_height(&row, CHARY+1); // Force row updating xi_set_row_height(&row, CHARY+1); // Force row updating
} }
} }
@ -568,7 +569,6 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
else else
{ {
src = format("%d", rec+1); src = format("%d", rec+1);
xiev->v.cell_request.color = COLOR_RED;
} }
char* dst = xiev->v.cell_request.s; char* dst = xiev->v.cell_request.s;
@ -681,13 +681,13 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (_row_dirty && _check_enabled) if (_row_dirty && _check_enabled)
{ {
_check_enabled = FALSE; // Avoid recursion! _check_enabled = FALSE; // Avoid recursion!
str2mask(_cur_rec); // It shouldn't have to be necessary // str2mask(_cur_rec); // It shouldn't have to be necessary
bool ok = sheet_mask().check_fields(); bool ok = sheet_mask().check_fields();
if (ok) if (ok)
{ {
const int next = _cur_rec + (_lastab == K_TAB ? +1 : -1); const int next = _cur_rec + (_lastab == K_TAB ? +1 : -1);
_update = rec2row(next) >= 0; // Disable update if next record is not visible _update = rec2row(next) >= 0; // Disable update if next record is not visible
mask2str(_cur_rec); // Update sheet for with mask contents mask2str(_cur_rec); // Update sheet with mask contents
ok = notify(_cur_rec, K_ENTER); // Notify edit ok = notify(_cur_rec, K_ENTER); // Notify edit
_update = TRUE; // Reenable update _update = TRUE; // Reenable update
} }
@ -792,13 +792,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
{ {
_check_enabled = FALSE; // Disable checks _check_enabled = FALSE; // Disable checks
notify_change(); notify_change();
if (_edit_field->on_key(k)) if (_edit_field->on_key(k) == FALSE && k == K_F9)
{
mask2str(_cur_rec);
}
else
{
if (k == K_F9)
{ {
_edit_field = &_mask.fld(_mask.focus_field()); _edit_field = &_mask.fld(_mask.focus_field());
const short foca = _edit_field->dlg(); const short foca = _edit_field->dlg();
@ -809,7 +803,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
dispatch_e_char(win(), K_F9); dispatch_e_char(win(), K_F9);
} }
} }
} mask2str(_cur_rec);
set_focus_cell(_cur_row, _cur_col); set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks _check_enabled = TRUE; // Enable checks
} }
@ -1123,40 +1117,48 @@ void TSpreadsheet::str2mask(int riga)
mask2str(riga); mask2str(riga);
return; return;
} }
TToken_string& r = row(riga); TToken_string& r = row(riga);
r.restart();
TString val(80); TString val(80);
for (short id = FIRST_FIELD; ; id++)
{
int pos = sheet_mask().id2pos(id);
if (pos < 0) break;
val = r.get(); // Value to set for (int i = 0; i < sheet_mask().fields(); i++)
int rid = id;
while (pos >= 0)
{ {
TMask_field& f = sheet_mask().fld(pos); TMask_field& f = sheet_mask().fld(i);
const short id = f.dlg();
if (id >= FIRST_FIELD)
{
const char* v = r.get((id % 100)-1);
if (v)
{
val = v; // Save the value, f.set(v) could use TString methods
f.set(val); f.set(val);
const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE; const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE;
f.enable(on); f.enable(on);
}
}
}
if (f.dirty() <= TRUE) for (i = 0; i < sheet_mask().fields(); i++)
{ {
if (f.active() || f.ghost()) TMask_field& f = sheet_mask().fld(i);
const short id = f.dlg();
if (id >= FIRST_FIELD && (f.active() || f.ghost()))
{ {
if (f.has_check()) f.check(STARTING_CHECK); if (f.has_check())
f.check(STARTING_CHECK);
f.set_dirty(FALSE); f.set_dirty(FALSE);
f.on_hit(); f.on_hit();
} }
f.set_dirty(FALSE);
} }
else
sheet_mask().first_focus(-rid);
rid += 100; for (i = 0; i < sheet_mask().fields(); i++)
pos = sheet_mask().id2pos(rid); {
TMask_field& f = sheet_mask().fld(i);
const short id = f.dlg();
if (id > FIRST_FIELD)
{
if (f.dirty() == TRUE)
f.set_dirty(FALSE);
} }
} }
@ -1187,7 +1189,9 @@ KEY TSpreadsheet::edit(int n, KEY tasto)
if (k == K_ENTER) if (k == K_ENTER)
{ {
#if XVT_OS != XVT_OS_WIN
mask2str(n); mask2str(n);
#endif
} else } else
if (k == K_DEL) if (k == K_DEL)
{ {