campo-sirio/include/varmask.cpp

169 lines
3.6 KiB
C++
Raw Normal View History

#include <varmask.h>
#include <utility.h>
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);
}