diff --git a/include/mask.h b/include/mask.h index edfbb89f0..e5c55dc88 100755 --- a/include/mask.h +++ b/include/mask.h @@ -325,7 +325,7 @@ public: // @cmember Ritorna il primo campo dirty short dirty() const; - // @cmember Setta lo sheet che gestisce la maschera + // @cmember Setta lo sheet di cui la maschera gestisce le righe void set_sheet(TSheet_field* s) { _sheet = s; } diff --git a/include/msksheet.cpp b/include/msksheet.cpp index a60918dd0..2a9c37344 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -174,8 +174,8 @@ public: bool cell_disabled(int row, int column) const; // @cmember Ritorna la maschera che appartiene allo spreadsheet - TMask& sheet_mask() - { return _mask; } + TMask& sheet_mask() const; + // @cmember Ritorna la maschera cui appartiene lo spreadsheet TMask& mask() const; @@ -265,7 +265,7 @@ TSpreadsheet::TSpreadsheet( init(); - _mask.set_sheet(o); + sheet_mask().set_sheet(o); // Calcolo larghezza massima tabella @@ -358,7 +358,7 @@ TSpreadsheet::TSpreadsheet( listdef->v.list->white_space_color = MASK_DARK_COLOR; word attr = XI_ATR_RJUST; - if (_mask.id2pos(FIRST_FIELD -1) != -1) + if (sheet_mask().id2pos(FIRST_FIELD -1) != -1) attr |= XI_ATR_SELECTABLE; XI_OBJ_DEF* coldef = xi_add_column_def(listdef, 0, attr, 0, NUMBER_WIDTH, NUMBER_WIDTH, @@ -430,9 +430,18 @@ TSpreadsheet::TSpreadsheet( TSpreadsheet::~TSpreadsheet() { + if (_getmask != NULL) + _getmask(0, _mask, TRUE); // Distrugge la maschera customizzata + set_win(NULL_WIN); } +TMask& TSpreadsheet::sheet_mask() const +{ + TMask& m = ((TSpreadsheet*)this)->_mask; + return (_getmask != NULL) ? *_getmask((int)_cur_rec, m, FALSE ) : m; +} + // Converts a row number in the correspondig record number int TSpreadsheet::row2rec(int& row) @@ -629,8 +638,6 @@ bool TSpreadsheet::destroy( if (ok && mask().is_running()) update(-1); - // Notifica l'avvenuta cancellazione - notify( rec, K_CTRL + K_DEL ); indestroy = FALSE; return ok; } @@ -808,13 +815,13 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) update(_cur_rec); // Forces update delayed by str2mask } - if (_mask.id2pos(FIRST_FIELD-1) != -1) + if (sheet_mask().id2pos(FIRST_FIELD-1) != -1) { - TMask_field& button = _mask.field(FIRST_FIELD-1); + TMask_field& button = sheet_mask().field(FIRST_FIELD-1); if (button.active()) { button.on_hit(); - if (_mask.dirty()) + if (sheet_mask().dirty()) { notify_change(); mask2str(_cur_rec); @@ -1010,7 +1017,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) const bool ok = _edit_field->on_key(k); if (!ok && k == K_F9) // Ricerca non completata? { - _edit_field = &_mask.fld(_mask.focus_field()); + _edit_field = &sheet_mask().fld(sheet_mask().focus_field()); const short foca = _edit_field->dlg(); const int col = (foca - FIRST_FIELD) % 100 +1; if (col > 0 && col != _cur_col) // Ricerca alternativa @@ -1176,7 +1183,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, : TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), _owner(o), _mask(maskname, maskno), _notify(NULL), /* Matteo */ _getmask( NULL ) { - _mask.set_sheet(o); + sheet_mask().set_sheet(o); } bool TSpreadsheet::on_key(KEY k) @@ -1247,8 +1254,8 @@ TMask& TSpreadsheet::mask() const // Ritorna il campo con l'identificatore dato della maschera dello sheet TMask_field* TSpreadsheet::field(short id) const { - const int pos = _mask.id2pos(id); - return pos < 0 ? NULL : &_mask.fld(pos); + const int pos = sheet_mask().id2pos(id); + return pos < 0 ? NULL : &sheet_mask().fld(pos); } @@ -1612,7 +1619,8 @@ KEY TSpreadsheet::edit(int n, KEY tasto) destroy(n); if (n < items()) str2mask(n); - } + notify(n, K_CTRL+K_DEL); // Notifica l'avvenuta cancellazione + } } else if (k == K_ESC)