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,7 +385,8 @@ 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
xi_set_row_height(&row, CHARY+1); // Force row updating if (_update)
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
} }
@ -722,7 +722,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
_check_enabled = FALSE; _check_enabled = FALSE;
if (_cell_dirty) if (_cell_dirty)
{ {
TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error
const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE); const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE);
c->set(nuo); // Set new mask value c->set(nuo); // Set new mask value
c->set_dirty(); // Get it dirty! c->set_dirty(); // Get it dirty!
@ -792,24 +792,18 @@ 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); _edit_field = &_mask.fld(_mask.focus_field());
} const short foca = _edit_field->dlg();
else const int col = (foca - FIRST_FIELD) % 100 +1;
{ if (col > 0 && col != _cur_col)
if (k == K_F9)
{ {
_edit_field = &_mask.fld(_mask.focus_field()); _cur_col = col;
const short foca = _edit_field->dlg(); dispatch_e_char(win(), K_F9);
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
{
_cur_col = col;
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,42 +1117,50 @@ 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 (int i = 0; i < sheet_mask().fields(); i++)
for (short id = FIRST_FIELD; ; id++)
{ {
int pos = sheet_mask().id2pos(id); TMask_field& f = sheet_mask().fld(i);
if (pos < 0) break; const short id = f.dlg();
if (id >= FIRST_FIELD)
val = r.get(); // Value to set
int rid = id;
while (pos >= 0)
{ {
TMask_field& f = sheet_mask().fld(pos); const char* v = r.get((id % 100)-1);
f.set(val); if (v)
const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE; {
f.enable(on); val = v; // Save the value, f.set(v) could use TString methods
f.set(val);
if (f.dirty() <= TRUE) const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE;
{ f.enable(on);
if (f.active() || f.ghost())
{
if (f.has_check()) f.check(STARTING_CHECK);
f.set_dirty(FALSE);
f.on_hit();
}
f.set_dirty(FALSE);
} }
else
sheet_mask().first_focus(-rid);
rid += 100;
pos = sheet_mask().id2pos(rid);
} }
} }
for (i = 0; i < sheet_mask().fields(); i++)
{
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);
f.set_dirty(FALSE);
f.on_hit();
}
}
for (i = 0; i < sheet_mask().fields(); i++)
{
TMask_field& f = sheet_mask().fld(i);
const short id = f.dlg();
if (id > FIRST_FIELD)
{
if (f.dirty() == TRUE)
f.set_dirty(FALSE);
}
}
sheet_mask().set_caption(format("Riga %d", riga+1)); sheet_mask().set_caption(format("Riga %d", riga+1));
} }
@ -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)
{ {