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_MAKE_ROW(&row, _list, riga);
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
{
src = format("%d", rec+1);
xiev->v.cell_request.color = COLOR_RED;
}
char* dst = xiev->v.cell_request.s;
@ -681,13 +681,13 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (_row_dirty && _check_enabled)
{
_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();
if (ok)
{
const int next = _cur_rec + (_lastab == K_TAB ? +1 : -1);
_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
_update = TRUE; // Reenable update
}
@ -722,7 +722,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
_check_enabled = FALSE;
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);
c->set(nuo); // Set new mask value
c->set_dirty(); // Get it dirty!
@ -792,24 +792,18 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
{
_check_enabled = FALSE; // Disable checks
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());
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
{
_edit_field = &_mask.fld(_mask.focus_field());
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
{
_cur_col = col;
dispatch_e_char(win(), K_F9);
}
_cur_col = col;
dispatch_e_char(win(), K_F9);
}
}
mask2str(_cur_rec);
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
}
@ -1123,42 +1117,50 @@ void TSpreadsheet::str2mask(int riga)
mask2str(riga);
return;
}
TToken_string& r = row(riga);
r.restart();
TString val(80);
TString val(80);
for (short id = FIRST_FIELD; ; id++)
for (int i = 0; i < sheet_mask().fields(); i++)
{
int pos = sheet_mask().id2pos(id);
if (pos < 0) break;
val = r.get(); // Value to set
int rid = id;
while (pos >= 0)
TMask_field& f = sheet_mask().fld(i);
const short id = f.dlg();
if (id >= FIRST_FIELD)
{
TMask_field& f = sheet_mask().fld(pos);
f.set(val);
const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE;
f.enable(on);
if (f.dirty() <= TRUE)
{
if (f.active() || f.ghost())
{
if (f.has_check()) f.check(STARTING_CHECK);
f.set_dirty(FALSE);
f.on_hit();
}
f.set_dirty(FALSE);
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);
const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE;
f.enable(on);
}
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));
}
@ -1187,7 +1189,9 @@ KEY TSpreadsheet::edit(int n, KEY tasto)
if (k == K_ENTER)
{
#if XVT_OS != XVT_OS_WIN
mask2str(n);
#endif
} else
if (k == K_DEL)
{