Modifica 95/6
Gestione maschere diverse negli shee git-svn-id: svn://10.65.10.50/trunk@1677 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
343db0c0ec
commit
3186c582fb
@ -30,6 +30,8 @@ class TSpreadsheet : public TWindow
|
||||
XI_OBJ *_list, *_itf;
|
||||
|
||||
SPREADSHEET_NOTIFY _notify;
|
||||
// Matteo
|
||||
SPREADSHEET_GETMASK _getmask;
|
||||
|
||||
TSheet_field* _owner; // Owner
|
||||
|
||||
@ -71,6 +73,13 @@ public:
|
||||
void set_focus_cell(int riga, int colonna);
|
||||
void activate(bool on);
|
||||
void enable_column(int col, bool on = TRUE);
|
||||
// Matteo
|
||||
void delete_column( const int col ) const;
|
||||
void move_column( const int fromindex, const int toindex ) const;
|
||||
void set_column_width( const int col, const int width ) const;
|
||||
void set_column_header( const int col, const TString& header ) const;
|
||||
|
||||
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
@ -91,6 +100,9 @@ public:
|
||||
bool active() const { return _active; }
|
||||
bool test_focus_change();
|
||||
|
||||
// Matteo
|
||||
void set_getmask(SPREADSHEET_GETMASK n) { _getmask = n; }
|
||||
|
||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
||||
|
||||
TSpreadsheet(short x, short y, short dx, short dy, const char* maskname, int maskno,
|
||||
@ -117,7 +129,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
const char* maskname, int maskno,
|
||||
const char* head, WINDOW parent,
|
||||
TSheet_field* o)
|
||||
: _mask(maskname, maskno), _notify(NULL), _edit_field(NULL),
|
||||
: _mask(maskname, maskno), _notify(NULL), _edit_field(NULL), /* Matteo */ _getmask( NULL ),
|
||||
_owner(o), _cur_row(0), _cur_col(0), _active(TRUE),
|
||||
_row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE),
|
||||
_needs_update(-1)
|
||||
@ -894,11 +906,15 @@ class TSpreadsheet : public TArray_sheet
|
||||
{
|
||||
TMask _mask;
|
||||
SPREADSHEET_NOTIFY _notify;
|
||||
// Matteo
|
||||
SPREADSHEET_GETMASK _getmask;
|
||||
|
||||
TSheet_field * _owner;
|
||||
|
||||
TBit_array _column_disabled;
|
||||
TArray _disabled; // Array di TBit_array
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
virtual bool on_key(KEY key);
|
||||
KEY edit(int n, KEY tasto);
|
||||
@ -913,6 +929,9 @@ public:
|
||||
TMask& sheet_mask() { return _mask; }
|
||||
TMask& mask() const;
|
||||
|
||||
// Matteo
|
||||
void set_getmask(SPREADSHEET_GETMASK n) { _getmask = n; }
|
||||
|
||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
||||
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);}
|
||||
bool dirty() const { return _owner->dirty(); }
|
||||
@ -922,6 +941,12 @@ public:
|
||||
void str2mask(int riga);
|
||||
|
||||
void enable_column(int col, bool on);
|
||||
// Matteo
|
||||
void delete_column( const int col ) const;
|
||||
void move_column( const int fromindex, const int toindex ) const;
|
||||
void set_column_width( const int col, const int width ) const;
|
||||
void set_column_header( const int col, const TString& header ) const;
|
||||
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
bool cell_disabled(int row, int column) const;
|
||||
virtual ~TSpreadsheet() {}
|
||||
@ -932,7 +957,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
const char* head, WINDOW parent,
|
||||
TSheet_field* o)
|
||||
: TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), _owner(o),
|
||||
_mask(maskname, maskno), _notify(NULL)
|
||||
_mask(maskname, maskno), _notify(NULL), /* Matteo */ _getmask( NULL )
|
||||
{}
|
||||
|
||||
bool TSpreadsheet::on_key(KEY k)
|
||||
@ -1114,6 +1139,61 @@ void TSpreadsheet::enable_column(int col, bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Matteo
|
||||
|
||||
void TSpreadsheet::delete_column( const int col ) const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
CHECKD( col+1 < num, "Can't delete column ", col );
|
||||
XI_OBJ* column = columns[ col+1];
|
||||
|
||||
xi_delete( column );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void TSpreadsheet::move_column( const int fromindex, const int toindex) const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
CHECKD(fromindex+1 < num, "Can't move column ", fromindex);
|
||||
XI_OBJ* column = columns[fromindex+1];
|
||||
|
||||
xi_move_column( column, toindex );
|
||||
#endif
|
||||
}
|
||||
|
||||
void TSpreadsheet::set_column_width(const int col, const int width) const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
CHECKD(col+1 < num, "Can't set column width ", col);
|
||||
XI_OBJ* column = columns[col+1];
|
||||
|
||||
xi_set_column_width(column, width); // Force redraw
|
||||
#endif
|
||||
}
|
||||
|
||||
void TSpreadsheet::set_column_header(const int col, const TString& header) const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
CHECKD(col+1 < num, "Can't set column width ", col);
|
||||
XI_OBJ* column = columns[col+1];
|
||||
|
||||
xi_set_text(column, (char *)(const char *)header );
|
||||
RCT r; xi_get_rect(column, &r);
|
||||
xi_set_column_width(column, (r.right-r.left+1) / CHARX); // Force redraw
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Certified 99%
|
||||
bool TSpreadsheet::cell_disabled(int row, int column) const
|
||||
@ -1196,11 +1276,39 @@ KEY TSpreadsheet::edit(int n, KEY tasto)
|
||||
KEY TSpreadsheet::edit(int n)
|
||||
#endif
|
||||
{
|
||||
KEY k;
|
||||
const int olditems = items();
|
||||
str2mask(n);
|
||||
|
||||
const KEY k = sheet_mask().run();
|
||||
|
||||
if( _getmask )
|
||||
{
|
||||
TMask& totalmask = sheet_mask();
|
||||
TMask& usermask = *_getmask( n, totalmask, FALSE );
|
||||
|
||||
// Carico la maschera dell'utente con la maschera totale
|
||||
for( int i = 0; i < usermask.fields(); i ++ )
|
||||
{ TMask_field& dest_field = usermask.fld( i );
|
||||
if ( dest_field.dlg( ) > 100 )
|
||||
{ TMask_field& source_field = totalmask.field( dest_field.dlg( ) );
|
||||
dest_field.set( source_field.get( ) ); }
|
||||
};
|
||||
k = usermask.run();
|
||||
if (k == K_ENTER)
|
||||
// Carico la maschera totale con la maschera dell'utente
|
||||
for( i = 0; i < usermask.fields(); i ++ )
|
||||
{
|
||||
TMask_field& source_field = usermask.fld( i );
|
||||
if ( source_field.dlg( ) > 100 )
|
||||
{ TMask_field& dest_field = totalmask.field( source_field.dlg() );
|
||||
dest_field.set( source_field.get( ) ); }
|
||||
};
|
||||
_getmask( n, totalmask, TRUE );
|
||||
|
||||
}
|
||||
else
|
||||
k = sheet_mask().run();
|
||||
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
mask2str(n);
|
||||
@ -1350,6 +1458,11 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
|
||||
_sheet->set_notify(n);
|
||||
}
|
||||
|
||||
void TSheet_field::set_getmask(SPREADSHEET_GETMASK n)
|
||||
{
|
||||
_sheet->set_getmask( n );
|
||||
}
|
||||
|
||||
void TSheet_field::highlight() const
|
||||
{
|
||||
TMask_field::highlight();
|
||||
@ -1384,6 +1497,27 @@ bool TSheet_field::cell_disabled(int row, int column) const
|
||||
return _sheet->cell_disabled(row, column);
|
||||
}
|
||||
|
||||
// Matteo
|
||||
void TSheet_field::delete_column( const int col ) const
|
||||
{
|
||||
_sheet->delete_column( col );
|
||||
}
|
||||
|
||||
void TSheet_field::move_column( const int fromindex, const int toindex ) const
|
||||
{
|
||||
_sheet->move_column(fromindex, toindex );
|
||||
}
|
||||
|
||||
void TSheet_field::set_column_width( const int col, const int width ) const
|
||||
{
|
||||
_sheet->set_column_width(col, width);
|
||||
}
|
||||
|
||||
void TSheet_field::set_column_header( const int col, const TString& header ) const
|
||||
{
|
||||
_sheet->set_column_header(col, header);
|
||||
}
|
||||
|
||||
|
||||
TMask& TSheet_field::sheet_mask() const
|
||||
{
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
class TSpreadsheet;
|
||||
typedef bool (*SPREADSHEET_NOTIFY)(int r, KEY k);
|
||||
// Matteo
|
||||
typedef TMask* (*SPREADSHEET_GETMASK)( int numriga, TMask& fullmask, bool destroy );
|
||||
|
||||
|
||||
class TSheet_field : public TMask_field
|
||||
@ -46,11 +48,18 @@ public:
|
||||
|
||||
TMask& sheet_mask() const;
|
||||
void set_notify(SPREADSHEET_NOTIFY n);
|
||||
|
||||
void set_getmask(SPREADSHEET_GETMASK n);
|
||||
|
||||
void enable_column(int col, bool on = TRUE);
|
||||
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
void disable_cell(int row, int column) { enable_cell(row, column, FALSE); }
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
void delete_column( const int col ) const;
|
||||
void move_column( const int fromindex, const int toindex ) const;
|
||||
void set_column_width( const int col, const int width ) const;
|
||||
void set_column_header( const int col, const TString& header ) const;
|
||||
void set_append(bool on = TRUE) { _append = on;}
|
||||
bool append() const { return _append;}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user