checks.cpp
mask.cpp Aggiunti metodi get_real e get_date msksheet.cpp Corretta gestione celle disabilitate git-svn-id: svn://10.65.10.50/trunk@2354 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0da41d73fc
commit
d7c234cee6
@ -205,7 +205,7 @@ int yesnofatal_box(
|
||||
#ifdef DBG
|
||||
char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg);
|
||||
const int ret = yesno_box("%s", s);
|
||||
if (!ret) fatal_box("");
|
||||
if (!ret) fatal_box(msg);
|
||||
#else
|
||||
fatal_box("%s", msg);
|
||||
#endif
|
||||
|
@ -1161,19 +1161,36 @@ void TMask::undo(short fld_id)
|
||||
|
||||
const TString& TMask::get(short fld_id) const
|
||||
{
|
||||
return field(fld_id).get();
|
||||
const TString& s = field(fld_id).get();
|
||||
return s;
|
||||
}
|
||||
|
||||
long TMask::get_long(short fld_id) const
|
||||
{
|
||||
return atol(field(fld_id).get());
|
||||
const TString& s = field(fld_id).get();
|
||||
return atol(s);
|
||||
}
|
||||
|
||||
bool TMask::get_bool(short fld_id) const
|
||||
{
|
||||
return field(fld_id).get().not_empty();
|
||||
{
|
||||
const TString& s = field(fld_id).get();
|
||||
return s.not_empty();
|
||||
}
|
||||
|
||||
real TMask::get_real(short fld_id) const
|
||||
{
|
||||
const TString& s = field(fld_id).get();
|
||||
return real(s);
|
||||
}
|
||||
|
||||
TDate TMask::get_date(short fld_id) const
|
||||
{
|
||||
const TString& s = field(fld_id).get();
|
||||
return TDate(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @mfunc Setta il campo con un valore
|
||||
void TMask::set(
|
||||
short fld_id, // @parm Identificatore del campo da settare
|
||||
|
@ -242,6 +242,10 @@ public:
|
||||
{ return (int)get_long(fld_id); }
|
||||
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di bool
|
||||
bool get_bool(short fld_id) const;
|
||||
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di real
|
||||
real get_real(short fld_id) const;
|
||||
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di data
|
||||
TDate get_date(short fld_id) const;
|
||||
|
||||
// @cmember Indica quale campo deve ricevere per primo il focus nella maschera
|
||||
int first_focus(short id);
|
||||
|
@ -268,7 +268,7 @@ TSpreadsheet::TSpreadsheet(
|
||||
WINDOW parent, // @parm Finestra alla quale appartiene lo spreadsheet
|
||||
TSheet_field* o) // @parm Indica il campo della maschera che contiene lo spreadsheet
|
||||
: _mask(maskname, maskno), _notify(NULL), _getmask( NULL ), _owner(o),
|
||||
_cur_row(0), _cur_col(0), _cur_rec(0), _edit_field(NULL), _active(TRUE),
|
||||
_cur_row(0), _cur_col(1), _cur_rec(0), _edit_field(NULL), _active(TRUE),
|
||||
_row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE),
|
||||
_needs_update(-1)
|
||||
{
|
||||
@ -529,7 +529,6 @@ TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
|
||||
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--)
|
||||
@ -576,30 +575,26 @@ int TSpreadsheet::find_enabled_column(int rec, int colonna, int direction) const
|
||||
{
|
||||
CHECKD(direction == +1 || direction == -1, "Bad column search direction", direction);
|
||||
|
||||
const int last = _columns - 1;
|
||||
if (colonna <= 0 || colonna > last)
|
||||
colonna = 1;
|
||||
|
||||
int num;
|
||||
XI_OBJ** column = xi_get_member_list(_list, &num);
|
||||
if (colonna <= 0 || colonna >= num)
|
||||
colonna = 1;
|
||||
|
||||
bool first = TRUE;
|
||||
for (int c = colonna; first || c != colonna; c += direction)
|
||||
int c = colonna;
|
||||
do
|
||||
{
|
||||
if (c > last)
|
||||
{
|
||||
c = 1; first = FALSE;
|
||||
}
|
||||
else
|
||||
if (c < 1)
|
||||
{
|
||||
c = last; first = FALSE;
|
||||
}
|
||||
|
||||
const short n = column[c]->cid - FIRST_FIELD;
|
||||
if (!cell_disabled(rec, n))
|
||||
return c;
|
||||
}
|
||||
|
||||
c += direction;
|
||||
if (c >= num)
|
||||
c = 1;
|
||||
else
|
||||
if (c <= 0)
|
||||
c = num-1;
|
||||
}
|
||||
while (c != colonna);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1047,7 +1042,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
||||
case XIE_GET_PERCENT:
|
||||
{
|
||||
const long rec = xiev->v.get_percent.record;
|
||||
long n = items(); if (n < 1) n = 1;
|
||||
long n = items(); if (n <= 0) n = 1;
|
||||
xiev->v.get_percent.percent = int(rec * 100L / n);
|
||||
}
|
||||
break;
|
||||
@ -1231,20 +1226,24 @@ XI_OBJ* TSpreadsheet::find_column(
|
||||
int col) const // @param Indice o identificatore colonna
|
||||
{
|
||||
CHECKD(col >= 0, "Bad column ", col);
|
||||
if (col < columns()) // Se e' un indice trasformalo in identificatore
|
||||
if (col < FIRST_FIELD) // Se e' un indice trasformalo in identificatore
|
||||
col += FIRST_FIELD;
|
||||
else
|
||||
if (col >= FIRST_FIELD+100) // Riportalo nel range 101 - 199
|
||||
col = FIRST_FIELD + (col % 100) -1;
|
||||
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
for (int c = 1; c < num; c++)
|
||||
for (int c = num-1; c > 0; c--)
|
||||
{
|
||||
if (columns[c]->cid == col)
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == num)
|
||||
if (c <= 0)
|
||||
{
|
||||
yesnofatal_box("Can't find column with id=%d", col);
|
||||
c = 0;
|
||||
c = 1;
|
||||
}
|
||||
|
||||
return columns[c];
|
||||
@ -1395,20 +1394,25 @@ TMask_field* TSpreadsheet::field(short id) const
|
||||
|
||||
// Ricopia i campi della maschera nel record dato ed aggiorna il display
|
||||
void TSpreadsheet::mask2str(int rec)
|
||||
{
|
||||
{
|
||||
const TMask& m = sheet_mask();
|
||||
TToken_string& r = row(rec);
|
||||
r.cut(0);
|
||||
for (short id = FIRST_FIELD; ; id++)
|
||||
{
|
||||
int pos = sheet_mask().id2pos(id);
|
||||
int pos = m.id2pos(id);
|
||||
if (pos < 0) break;
|
||||
|
||||
for(int dlg = id; pos >= 0; pos = sheet_mask().id2pos(dlg += 100))
|
||||
for(int dlg = id; pos >= 0; pos = m.id2pos(dlg += 100))
|
||||
{
|
||||
const TMask_field& f = sheet_mask().fld(pos);
|
||||
const TMask_field& f = m.fld(pos);
|
||||
if (f.shown() || f.ghost())
|
||||
{
|
||||
r.add(f.get());
|
||||
{
|
||||
r.add(f.get());
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
const bool on = f.enabled();
|
||||
enable_cell(rec, id-FIRST_FIELD, on);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1455,7 +1459,9 @@ void TSpreadsheet::enable_cell(
|
||||
}
|
||||
|
||||
if (column >= 0)
|
||||
{
|
||||
ba->set(column, !on);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (on)
|
||||
@ -1480,31 +1486,21 @@ void TSpreadsheet::enable_column(
|
||||
// @flag TRUE | Abilita la colonna (default)
|
||||
// @flag FALSE| Disabilita la colonna
|
||||
{
|
||||
if (col >= FIRST_FIELD)
|
||||
col = cid2col(col);
|
||||
const bool change = _column_disabled[col] == on;
|
||||
_column_disabled.set(col, !on);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if (change)
|
||||
{
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
for (int c = 1; c < num; c++)
|
||||
if (columns[c]->cid == FIRST_FIELD+col)
|
||||
{
|
||||
XI_OBJ* column = columns[c];
|
||||
dword attr = xi_get_attrib(column);
|
||||
if (on) attr |= XI_ATR_ENABLED;
|
||||
else attr &= ~XI_ATR_ENABLED;
|
||||
|
||||
// xi_move_focus(_itf); // Set focus to interface
|
||||
xi_set_attrib(column, attr); // Set new attributes
|
||||
/*
|
||||
RCT r; xi_get_rect(column, &r);
|
||||
xi_set_column_width(column, (r.right-r.left+1) / CHARX); // Force redraw
|
||||
*/
|
||||
update(-1);
|
||||
break;
|
||||
}
|
||||
XI_OBJ* column = find_column(col);
|
||||
dword attr = xi_get_attrib(column);
|
||||
if (on) attr |= XI_ATR_ENABLED;
|
||||
else attr &= ~XI_ATR_ENABLED;
|
||||
|
||||
// xi_move_focus(_itf); // Set focus to interface
|
||||
xi_set_attrib(column, attr); // Set new attributes
|
||||
update(-1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1615,10 +1611,13 @@ bool TSpreadsheet::cell_disabled(int row, int column) const
|
||||
TBit_array* ba = (TBit_array*)_disabled.objptr(row);
|
||||
bool d;
|
||||
if (column < 0)
|
||||
d = ba == NULL ? FALSE : (ba->ones() >= columns()-1);
|
||||
else
|
||||
d = ba == NULL ? _column_disabled[column] : (*ba)[column];
|
||||
|
||||
d = (ba == NULL) ? FALSE : (ba->ones() >= columns()-1);
|
||||
else
|
||||
{
|
||||
d = _column_disabled[column]; // Controlla la colonna
|
||||
if (d == FALSE && ba != NULL) // Se la colonna e' disabilitata e' inutile proseguire
|
||||
d = (*ba)[column]; // Controlla la cella
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -1636,22 +1635,27 @@ void TSpreadsheet::str2mask(int riga)
|
||||
TToken_string& r = row(riga);
|
||||
TString val(80);
|
||||
|
||||
for (int i = 0; i < sheet_mask().fields(); i++)
|
||||
TMask& m = sheet_mask();
|
||||
const int campi = m.fields();
|
||||
|
||||
for (int i = 0; i < campi; i++)
|
||||
{
|
||||
TMask_field& f = sheet_mask().fld(i);
|
||||
TMask_field& f = m.fld(i);
|
||||
const short id = f.dlg();
|
||||
if (id >= FIRST_FIELD)
|
||||
{
|
||||
val = r.get((id % 100)-1);
|
||||
{
|
||||
const int index = (id % 100)-1;
|
||||
val = r.get(index);
|
||||
f.set(val);
|
||||
const bool on = active() ? !cell_disabled(riga, id-FIRST_FIELD) : FALSE;
|
||||
f.enable(on);
|
||||
const bool on = !cell_disabled(riga, index);
|
||||
if (f.enabled() != on)
|
||||
f.enable(on);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sheet_mask().fields(); i++)
|
||||
for (i = 0; i < campi; i++)
|
||||
{
|
||||
TMask_field& f = sheet_mask().fld(i);
|
||||
TMask_field& f = m.fld(i);
|
||||
const short id = f.dlg();
|
||||
if (id >= FIRST_FIELD &&
|
||||
f.class_id() != CLASS_BUTTON_FIELD &&
|
||||
@ -1664,9 +1668,9 @@ void TSpreadsheet::str2mask(int riga)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sheet_mask().fields(); i++)
|
||||
for (i = 0; i < campi; i++)
|
||||
{
|
||||
TMask_field& f = sheet_mask().fld(i);
|
||||
TMask_field& f = m.fld(i);
|
||||
const short id = f.dlg();
|
||||
if (id > FIRST_FIELD)
|
||||
{
|
||||
@ -1675,7 +1679,7 @@ void TSpreadsheet::str2mask(int riga)
|
||||
}
|
||||
}
|
||||
|
||||
sheet_mask().set_caption(format("Riga %d", riga+1));
|
||||
m.set_caption(format("Riga %d", riga+1));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user