Gesione is_edit
git-svn-id: svn://10.65.10.50/trunk@1911 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3203d1369f
commit
3be0b7343f
@ -109,15 +109,6 @@ TMask_field::~TMask_field()
|
||||
if (_field) delete _field;
|
||||
}
|
||||
|
||||
|
||||
// Certified 100%
|
||||
bool TMask_field::is_edit() const
|
||||
{
|
||||
const word c = class_id();
|
||||
return c == CLASS_EDIT_FIELD || c == CLASS_REAL_FIELD || c == CLASS_DATE_FIELD;
|
||||
}
|
||||
|
||||
|
||||
// Certified 100%
|
||||
const char* TMask_field::class_name() const
|
||||
{ return "Field"; }
|
||||
|
@ -271,8 +271,8 @@ public:
|
||||
void set_handler(CONTROL_HANDLER handler)
|
||||
{ _handler = handler; }
|
||||
|
||||
// @cmember Ritorna TRUE se il campo e' editabile
|
||||
bool is_edit() const;
|
||||
// @cmember Ritorna TRUE se il campo e' di tipo edit
|
||||
virtual bool is_edit() const { return FALSE; }
|
||||
// @cmember Permette di spedire il check
|
||||
bool to_check(KEY k, bool checkrun = FALSE) const;
|
||||
|
||||
@ -403,6 +403,8 @@ protected:
|
||||
virtual void parse_head(TScanner& scanner);
|
||||
// @cmember Legge un item del controllo dal file <p scanner>
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
|
||||
virtual bool is_edit() const { return TRUE; }
|
||||
|
||||
// @cmember Crea il controllo
|
||||
virtual void create(WINDOW parent);
|
||||
|
@ -90,8 +90,11 @@ class TSpreadsheet : public TWindow
|
||||
// @access Protected Member
|
||||
protected:
|
||||
//@cmember Gestisce gli eventi delle celle (chiamata dal <mf TSpreadsheet::xiev_handler>)
|
||||
void list_handler(XI_EVENT *xiev);
|
||||
|
||||
void list_handler(XI_EVENT* xiev);
|
||||
|
||||
//@cmember Gestisce l'uscita delle celle (chiamata dal <mf TSpreadsheet::list_handler>)
|
||||
bool off_cell_handler(XI_OBJ* cell);
|
||||
|
||||
// @cmember Ritorna il campo della maschera corrispondente alla cella dello
|
||||
// spreadsheet indicata da <p pos>
|
||||
TMask_field* col2field(int pos) const;
|
||||
@ -674,6 +677,21 @@ HIDDEN void XVT_CALLCONV1 xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
|
||||
TSpreadsheet* es = (TSpreadsheet*)xi_get_app_data(itf);
|
||||
CHECK(es, "NULL Edit sheet in xi event");
|
||||
es->list_handler(xiev);
|
||||
}
|
||||
|
||||
bool TSpreadsheet::off_cell_handler(XI_OBJ *cell)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (_edit_field != NULL)
|
||||
{
|
||||
const char* nuo = _edit_field->picture_data(xi_get_text(cell, NULL, -1), TRUE);
|
||||
_edit_field->set(nuo); // Set new mask value
|
||||
_edit_field->set_dirty(); // Get it dirty!
|
||||
if (_edit_field->on_key(_edit_field->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it
|
||||
ok = *nuo != '\0';
|
||||
mask2str(_cur_rec); // Update sheet row
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Certified 75%
|
||||
@ -770,26 +788,37 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
||||
break;
|
||||
case XIE_SELECT:
|
||||
if (xiev->v.xi_obj->type == XIT_ROW)
|
||||
{
|
||||
{
|
||||
_check_enabled = FALSE;
|
||||
|
||||
if (_edit_field != NULL && _cell_dirty)
|
||||
{
|
||||
XI_OBJ cell;
|
||||
XI_MAKE_CELL(&cell, _list, _cur_row, _cur_col);
|
||||
off_cell_handler(&cell);
|
||||
}
|
||||
|
||||
const int oldrec = _cur_rec;
|
||||
set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column);
|
||||
if (oldrec != _cur_rec)
|
||||
{
|
||||
_row_dirty = FALSE;
|
||||
|
||||
str2mask(_cur_rec);
|
||||
update(_cur_rec); // Forces update delayed by str2mask
|
||||
str2mask(_cur_rec);
|
||||
update(_cur_rec); // Forces update delayed by str2mask
|
||||
}
|
||||
|
||||
if (_mask.id2pos(FIRST_FIELD-1) != -1)
|
||||
{
|
||||
TMask_field* button = &_mask.field(FIRST_FIELD-1);
|
||||
button->on_hit();
|
||||
if (_mask.dirty())
|
||||
{
|
||||
notify_change();
|
||||
mask2str(_cur_rec);
|
||||
}
|
||||
TMask_field& button = _mask.field(FIRST_FIELD-1);
|
||||
if (button.active())
|
||||
{
|
||||
button.on_hit();
|
||||
if (_mask.dirty())
|
||||
{
|
||||
notify_change();
|
||||
mask2str(_cur_rec);
|
||||
}
|
||||
}
|
||||
}
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
@ -901,21 +930,11 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
||||
}
|
||||
break;
|
||||
case XIE_OFF_CELL:
|
||||
if (_edit_field && _check_enabled)
|
||||
if (_edit_field && _check_enabled && _cell_dirty)
|
||||
{
|
||||
_check_enabled = FALSE;
|
||||
if (_cell_dirty)
|
||||
{
|
||||
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!
|
||||
if (c->on_key(c->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it
|
||||
xiev->refused = *nuo != '\0';
|
||||
|
||||
if (!xiev->refused)
|
||||
mask2str(_cur_rec); // Update sheet row
|
||||
}
|
||||
XI_OBJ* cell = xiev->v.xi_obj;
|
||||
xiev->refused = !off_cell_handler(cell);
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user