Patch level : 4.0 414

Files correlati     : ve0
Ricompilazione Demo : [ ]
Commento            :
Potenziata gestione campi driver:
ora funzionano anche con drivers "virtuali"
che non esistono al momemnto della creazione del campo driven


git-svn-id: svn://10.65.10.50/trunk@13986 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2006-05-12 17:23:59 +00:00
parent baef024a0a
commit d089749aa5
4 changed files with 71 additions and 37 deletions

View File

@ -426,7 +426,14 @@ short TMask::dirty() const
void TMask::load_checks() const void TMask::load_checks() const
{ {
const int max = fields(); const int max = fields();
for (int i = 0; i < max; i++) int i;
for (i = 0; i < max; i++)
{
const TMask_field& f = fld(i);
if (f.is_edit())
((TEdit_field&)f).test_drivers();
}
for (i = 0; i < max; i++)
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.has_check()) if (f.has_check())
@ -1855,7 +1862,7 @@ TCurrency_field& TMask::add_currency (
int y, // @parm Coordinata y (in caratteri) int y, // @parm Coordinata y (in caratteri)
int dim, // @parm Lunghezza del campo sulla maschera int dim, // @parm Lunghezza del campo sulla maschera
const char* flags, // @parm Flag di controllo del campo (default "") const char* flags, // @parm Flag di controllo del campo (default "")
short driver) // @parm Numero di decimali (default 0) short driver) // @parm Campo con codice valuta
// @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_date> // @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_date>
// <mf TMask::add_button> <mf TMask::add_radio> <mf TMask::add_memo> // <mf TMask::add_button> <mf TMask::add_radio> <mf TMask::add_memo>

View File

@ -1256,46 +1256,70 @@ void TEditable_field::reset_driver(short id)
} }
} }
TOperable_field* TEditable_field::add_driver(short id) bool TEditable_field::add_driver(short id)
{
if (id != 0)
{
if (_drivers == NULL)
_drivers = new TPointer_array;
_drivers->add_long(id);
}
return id != 0;
}
TOperable_field* TEditable_field::get_driver(int n, bool test) const
{ {
TOperable_field* driver = NULL; TOperable_field* driver = NULL;
if (id < 0) if (_drivers != NULL)
{ {
TSheet_field* sheet = mask().get_sheet(); const short id = (short)_drivers->get_long(n);
if (sheet) if (id != 0)
{ {
const int pos = sheet->mask().id2pos(-id); if (id < 0)
if (pos >= 0)
{ {
driver = &(TOperable_field&)sheet->mask().fld(pos); TSheet_field* sheet = mask().get_sheet();
CHECKD(driver->is_kind_of(CLASS_OPERABLE_FIELD), "Field not operable ", -id); if (sheet)
{
const int pos = sheet->mask().id2pos(-id);
if (pos >= 0)
driver = (TOperable_field*)&sheet->mask().fld(pos);
}
}
else
{
const int pos = mask().id2pos(id);
if (pos >= 0)
{
driver = (TOperable_field*)&mask().fld(pos);
if (test)
{
TString16 msg; msg.format("CHECK,%d", dlg());
TToken_string* tok = driver->message(0, false);
if (tok == NULL || tok->get_pos(msg) < 0)
driver->message(0, true)->add(msg);
}
}
} }
} }
} }
else
{
const int pos = mask().id2pos(id);
if (pos >= 0)
{
driver = &(TOperable_field&)mask().fld(pos);
CHECKD(driver->is_kind_of(CLASS_OPERABLE_FIELD), "Field not operable ", id);
TString16 msg;
msg.format("CHECK,%d", dlg());
driver->message(0, TRUE)->add(msg);
}
}
if (driver != NULL)
{
CHECKD(driver->is_kind_of(CLASS_OPERABLE_FIELD), "Field not operable ", id);
if (_drivers == NULL)
_drivers = new TPointer_array;
_drivers->add(driver);
}
else
NFCHECK("Non esiste il campo driver %d per il campo %d", id, dlg());
return driver; return driver;
} }
TOperable_field* TEditable_field::driver(int n) const
{
return get_driver(n, false);
}
void TEditable_field::test_drivers() const
{
if (_drivers != NULL)
{
for (int i = 0; i < _drivers->items(); i++)
get_driver(i, true);
}
}
// Ritorna il messaggio d'errore associato al campo // Ritorna il messaggio d'errore associato al campo
const char* TEditable_field::get_warning() const const char* TEditable_field::get_warning() const
{ return _warning ? (const char*)*_warning : ""; } { return _warning ? (const char*)*_warning : ""; }

View File

@ -621,6 +621,7 @@ class TEditable_field : public TLoadable_field
protected: // TMask_field protected: // TMask_field
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
TOperable_field* get_driver(int n, bool test) const;
protected: protected:
// @cmember Valore corrente del campo // @cmember Valore corrente del campo
@ -693,12 +694,14 @@ public:
virtual bool is_editable() const { return true; } virtual bool is_editable() const { return true; }
// @cmember Ritorna un eventuale campo driver // @cmember Ritorna un eventuale campo driver
TOperable_field* driver(int n) const TOperable_field* driver(int n) const;
{ return _drivers ? (TOperable_field*)_drivers->objptr(n) : NULL; }
// @cmember Azzera i campi driver // @cmember Azzera i campi driver
void reset_driver(short id = -1); void reset_driver(short id = -1);
// @cmember Aggiunge un campo driver // @cmember Aggiunge un campo driver
TOperable_field* add_driver(short id); bool add_driver(short id);
// Controlla l'associazione driver/driven
void test_drivers() const;
TEditable_field(TMask* m); TEditable_field(TMask* m);
virtual ~TEditable_field(); virtual ~TEditable_field();

View File

@ -1,5 +1,3 @@
#include <limits.h>
#define XI_INTERNAL #define XI_INTERNAL
#include <xinclude.h> #include <xinclude.h>
@ -19,6 +17,8 @@ extern "C"
#include <utility.h> #include <utility.h>
#include <progind.h> #include <progind.h>
#include <limits.h>
class TCell_property : public TObject class TCell_property : public TObject
{ {
COLOR _back, _fore; COLOR _back, _fore;