From edf71af3d7de646d1bbe571685efc9f5de0b6c6f Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 8 May 1996 12:27:33 +0000 Subject: [PATCH] Aggiunte varmask git-svn-id: svn://10.65.10.50/trunk@2784 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/varmask.cpp | 168 ++++++++++++++++++++++++++++++++++++++++++++ include/varmask.h | 82 +++++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100755 include/varmask.cpp create mode 100755 include/varmask.h diff --git a/include/varmask.cpp b/include/varmask.cpp new file mode 100755 index 000000000..5c11a1898 --- /dev/null +++ b/include/varmask.cpp @@ -0,0 +1,168 @@ +#include +#include + +const TString& TVariable_mask::get(short fld_id) const +{ + if (present( fld_id )) + return TMask::get( fld_id ); + else + return ""; +} + +void TVariable_mask::set_handler(short fld_id, CONTROL_HANDLER handler) +{ + if(present( fld_id )) + TMask::set_handler( fld_id, handler ); +} + +void TVariable_mask::set(short fld_id, const char* str, bool hit ) +{ + if(present( fld_id )) + TMask::set( fld_id, str, hit ); +} + +void TVariable_mask::show(short fld_id, bool on ) +{ + if(present( fld_id ) ) + TMask::show( fld_id, on ); +} + +void TVariable_mask::enable(short fld_id, bool on ) +{ + if(present( fld_id )) + TMask::enable( fld_id, on ); +} + +void TVariable_mask::check_field( short fld_id ) +{ + if (present( fld_id )) + TMask::check_field(fld_id); +} + +TMask_field* TVariable_mask::parse_field(TScanner& scanner) +{ + if (scanner.key() == "SP") + { + _sheets++; + return new TVariable_sheet_field(this); + } + + return TMask::parse_field(scanner); +} + +TVariable_mask::TVariable_mask(const char* name, int num, int max) : TMask() +{ + + if (name && *name) + read_mask(name, num, max); +} + + +TMask& TVariable_sheet_field::sheet_mask() const +{ + TMask& m = TSheet_field::sheet_mask(); + const int current = selected(); + + if (_getmask != NULL && current >= 0 && current < items()) + return *_getmask(current, m, FALSE); + return m; +} + +TVariable_sheet_field::~TVariable_sheet_field() +{ + TMask & m = TSheet_field::sheet_mask(); + if (_getmask != NULL) + _getmask(0, m, TRUE); // Distrugge la maschera customizzata +} + +KEY TVariable_sheet_field::run_editmask(int n) +{ + if(!_getmask) + return TSheet_field::run_editmask(n); // Esegue la maschera dello sheet_field + + + TMask& totalmask = TSheet_field::sheet_mask(); + TMask& usermask = *_getmask( n, totalmask, FALSE ); + + // Carico la maschera dell'utente con la maschera totale +/* + usermask.copy_values(totalmask); + + const int ncampi = usermask.fields(); + + for (int i = 0; i < ncampi; i++) + { + TMask_field& f = usermask.fld(i); + const short id = f.dlg( ); + + if (id >= FIRST_FIELD) + { + const int index = (id % 100) - 1; + const bool on = active() ? !cell_disabled(n, index) : FALSE; + + f.enable(on); + if (f.class_id() != CLASS_BUTTON_FIELD && + (f.active() || f.ghost())) + { + if (f.has_check()) + f.check(STARTING_CHECK); + f.set_dirty(FALSE); + f.on_hit(); + } + else + if (f.dirty() == TRUE) + f.set_dirty(FALSE); + } + } +*/ + + KEY k = usermask.run(); + +/* + // Carico la maschera totale con la maschera dell'utente + if (k == K_ENTER) + totalmask.copy_values(usermask); +// _getmask( n, totalmask, TRUE ); +*/ + return k; +} + +// Ricopia i campi della maschera nel record dato +void TVariable_sheet_field::mask2row(int n, TToken_string & rec) +{ + TSheet_field::mask2row(n,rec); +} + +// Ricopia i campi del record dato nella maschera +void TVariable_sheet_field::row2mask(int n, TToken_string & rec) +{ +/* + TString val(80); + + if ( _getmask != NULL) + { + TMask &m= TSheet_field::sheet_mask(); // Maschera completa dello sheet + const int ncampi = m.fields(); + + for (int i = 0; i < ncampi; i++) + { + TMask_field& f = m.fld(i); + const short id = f.dlg( ); + + if (id >= FIRST_FIELD) + { + const int index = (id % 100) - 1; + const bool on = active() ? !cell_disabled(n, index) : FALSE; + + val = rec.get(index); + f.set(val); + } + } + m.set_caption(format("Riga %d", n+1)); + } + else + */ + TSheet_field::row2mask(n,rec); +} + + diff --git a/include/varmask.h b/include/varmask.h new file mode 100755 index 000000000..54a5050ac --- /dev/null +++ b/include/varmask.h @@ -0,0 +1,82 @@ +#ifndef __VARMASK_H + +#define __VARMASK_H + +#include +#include + +// @doc EXTERNAL + +// @type SPREADSHEET_GETMASK | Prototipo funzione che ritorna una maschera di edit diversa a seconda della riga +typedef TMask* (*SPREADSHEET_GETMASK)( int numriga, TMask& fullmask, bool destroy ); + +// @doc EXTERNAL + +// @class TVariable_mask | Maschere con spreadsheet a righe variabili e con campi virtuali +// +// @base public | TMask +class TVariable_mask : public TMask +{ + // @author:(INTERNAL) Matteo + + protected: + bool present( short fld_id ) const { return ( id2pos( fld_id ) >= 0 ); }; + + public: + + // @cmember Esegue il check e i messaggi sul campo

della maschera + virtual void check_field( short fld_id ); + // @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk) + TVariable_mask( const char* name, int num = 0, int max = MAX_PAGES); + // @cmember Setta il campo con una stringa + virtual void set(short fld_id, const char* str, bool hit=FALSE); + // @cmember Ritorna il contenuto del campo

sotto forma di stringa + virtual const TString& get(short fld_id) const; + // @cmember Definsce l'handler del campo

+ virtual void set_handler(short fld_id, CONTROL_HANDLER handler); + // @cmember Permette di mostrare/nascondere un campo + virtual void show(short fld_id = -1, bool on = TRUE); + // @cmember Abilita/disabilita un campo + virtual void enable(short fld_id, bool on = TRUE); + // @cmember Legge il campo da file + virtual TMask_field* parse_field(TScanner& scanner); + +}; + +// @doc EXTERNAL + +// @class TVariable_sheet_field | Classe per la gestione dei campi di uno spreadsheet con righe variabili +// +// @base public | TSheet_field +class TVariable_sheet_field : public TSheet_field +{ + // @author:(INTERNAL) Alex + Guido + + // @cmember:(INTERNAL) Funzione per l'apertura della maschera di edit della riga + // (vedi ) + SPREADSHEET_GETMASK _getmask; + +protected: + // @cmember Ricopia i campi della maschera nel record

-esimo + virtual void mask2row(int n, TToken_string & rec); + // @cmember Ricopia i campi del record

-esimo nella maschera + virtual void row2mask(int n, TToken_string & rec); + + +public: + // @cmember Setta il membro

con il valore

+ void set_getmask(SPREADSHEET_GETMASK n) + { _getmask = n; } + + // @cmember esegue la maschera di edit dello speadsheet; + virtual KEY run_editmask(int n); + // @cmember Ritorna la maschera corrispondente ad una riga dello spreadsheet + virtual TMask& sheet_mask() const; + + // @cmember Costruttore + TVariable_sheet_field(TMask* m) : TSheet_field(m) {} + // @cmember Distruttore + virtual ~TVariable_sheet_field(); +}; + +#endif