Patch level : 12.00

Files correlati     :

Commento:
Aggiunto vetabadd.txt per fatture di acquisto
Corretta renum_key
Modificata la save delle maschere per non salvare gli sheet
Corretta l'esportazione delle stampe in printer
first_one last_one check_all uncheck_all degli sheet
Costruttore delle paragraph_string vuoto
This commit is contained in:
Alessandro Bonazzi 2024-10-28 00:20:44 +01:00
parent 6e2ed8ce9c
commit 78d79f1d13
13 changed files with 295 additions and 50 deletions

View File

@ -969,6 +969,11 @@ void TControl::update_tab_cid()
} }
} }
int get_maxx_col()
{
return 80;
}
XI_RCT TControl::coord2rct(XI_OBJ* itf, short x, short y, short dx, short dy) const XI_RCT TControl::coord2rct(XI_OBJ* itf, short x, short y, short dx, short dy) const
{ {
// Spazio da lasciare prima di toccare i bordi // Spazio da lasciare prima di toccare i bordi
@ -1048,6 +1053,83 @@ XI_RCT TControl::coord2rct(XI_OBJ* itf, short x, short y, short dx, short dy) co
return rct; return rct;
} }
RCT TControl::coord2rect(XI_OBJ* itf, short x, short y, short dx, short dy) const
{
// Spazio da lasciare prima di toccare i bordi
const int X_DELTA = CHARX / 4;
const int Y_DELTA = CHARY / 8;
RCT rct;
RCT max_rct; xvt_vobj_get_client_rect((WINDOW)xi_get_window(itf), &max_rct);
const short MAXX = max_rct.right;
const short MAXY = max_rct.bottom;
int width = CHARX;
if (dx > 0)
width = dx * CHARX;
int height = CHARY;
if (dy > 1)
height += (dy - 1) * ROWY;
if (x < 0)
{
x = -x;
if (x > 10)
{
const int num = x / 10 - 1;
const int tot = x % 10;
const int spc = (MAXX - tot * width) / (tot + 1);
rct.left = spc + num * (spc + width);
}
else
rct.left = MAXX - width - x * CHARX - X_DELTA;
}
else
{
rct.left = x * CHARX + X_DELTA;
if (dx > 0 && MAXX > get_maxx_col() * CHARX)
{
if (itf->app_data2 & 0x1) // Full screen
{
// Don't offset fields
}
else
{
rct.left += (MAXX - get_maxx_col() * CHARX) / 2; // Normal flow
}
}
}
if (y < 0)
{
y = -y;
if (y > 10)
{
const int num = y / 10 - 1;
const int tot = y % 10;
const int spc = (MAXY - tot * height) / (tot + 1);
rct.top = spc + num * (spc + height);
}
else
rct.top = MAXY - height - (y - 1) * ROWY - Y_DELTA;
}
else
rct.top = y * ROWY + Y_DELTA;
if (dx > 0)
rct.right = rct.left + width;
else
rct.right = MAXX + (dx - 1) * CHARX - X_DELTA;
if (dy > 0)
rct.bottom = rct.top + height;
else
rct.bottom = MAXY + dy * ROWY - Y_DELTA;
return rct;
}
short TControl::id() const short TControl::id() const
{ return _obj->cid; } { return _obj->cid; }

View File

@ -19,6 +19,7 @@ struct XI_PNT;
struct XI_RCT; struct XI_RCT;
#endif #endif
int get_maxx_col();
void init_controls(); void init_controls();
void free_controls(); void free_controls();
@ -58,9 +59,6 @@ protected:
// @cmember:(INTERNAL) Puntatore al TMask_field eventualmente associato // @cmember:(INTERNAL) Puntatore al TMask_field eventualmente associato
TMask_field* _fld; TMask_field* _fld;
// @cmember Ricava l'interfaccia da una finestra
XI_OBJ* get_interface(WINDOW win = 0L) const;
// @cmember Cerca un controllo operabile (in avanti o all'indietro) // @cmember Cerca un controllo operabile (in avanti o all'indietro)
XI_OBJ* find_operable(XI_OBJ* container, bool forward, bool normal) const; XI_OBJ* find_operable(XI_OBJ* container, bool forward, bool normal) const;
@ -81,6 +79,10 @@ public:
TControl(); TControl();
virtual ~TControl(); virtual ~TControl();
RCT coord2rect(XI_OBJ* itf, short x, short y, short dx, short dy) const;
// @cmember Ricava l'interfaccia da una finestra
XI_OBJ* get_interface(WINDOW win = 0L) const;
static KEY xiev_to_key(const XI_EVENT* xiev); static KEY xiev_to_key(const XI_EVENT* xiev);
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep); virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep);

View File

@ -592,7 +592,6 @@ void TMask::start_run()
if (f.dirty() == 1) // Attenzione puo' valere anche 3 per i very dirty! if (f.dirty() == 1) // Attenzione puo' valere anche 3 per i very dirty!
f.set_dirty(false); f.set_dirty(false);
} }
_last_test = -1; _last_test = -1;
} }
@ -616,7 +615,6 @@ bool TMask::check_fields()
break; // Page disabled: end of test break; // Page disabled: end of test
curpage = f.parent(); // Update current page curpage = f.parent(); // Update current page
} }
if (sheet) f.set_dirty(); // Force check in sheet masks if (sheet) f.set_dirty(); // Force check in sheet masks
if (f.on_key(K_ENTER) == false) if (f.on_key(K_ENTER) == false)
{ {
@ -2402,13 +2400,14 @@ TList_field& TMask::add_list (
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 "")
const char* codes, // @parm tokenstring con i codici (NULL def.) const char* codes, // @parm tokenstring con i codici (NULL def.)
const char* items) // @parm tokenstring con gli items (NULL def.) const char* items, // @parm tokenstring con gli items (NULL def.)
int width) // @parm larghezza campo a video
// @xref <mf TMask::add_static> <mf TMask::add_number> <mf TMask::add_date> // @xref <mf TMask::add_static> <mf TMask::add_number> <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>
{ {
TList_field* f = new TList_field(this); TList_field* f = new TList_field(this);
f->construct(id, prompt, x, y, dim, page_win(page), flags); f->construct(id, prompt, x, y, dim, page_win(page), flags, width);
f->replace_items(codes,items); f->replace_items(codes,items);
add_field(f); add_field(f);
return *f; return *f;
@ -2576,6 +2575,20 @@ TGolem_field& TMask::add_golem_tool(short id, const char* prompt, const char* fl
return *g; return *g;
} }
TSheet_field & TMask::add_sheet(short id, int page, const char * prompt, const char * maskname, int maskno,
const char * head, int x, int y, int width, int height, const char* flags )
{
TSheet_field * sh = new TSheet_field(this);
sh->create(page_win(page), id, prompt, maskname, maskno, unesc(head), x, y, width, height, flags);
add_field(sh);
TMask & m = sh->sheet_mask();
if (m.get_sheet() == nullptr)
m.set_sheet(sh);
return *sh;
}
void TMask::add_item(TMask_field & fld, const char * item) void TMask::add_item(TMask_field & fld, const char * item)
{ {
TFilename tmp; tmp.temp("use"); TFilename tmp; tmp.temp("use");
@ -2589,6 +2602,7 @@ void TMask::add_item(TMask_field & fld, const char * item)
while (scan.pop() != "EN") while (scan.pop() != "EN")
fld.parse_item(scan); fld.parse_item(scan);
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Salva i valori dei campi della maschera sul file di salvataggio // @mfunc Salva i valori dei campi della maschera sul file di salvataggio
@ -2598,8 +2612,9 @@ void TMask::add_item(TMask_field & fld, const char * item)
// @flag true | Se l'operazione e' avvenuta corretamente // @flag true | Se l'operazione e' avvenuta corretamente
// @flag false | Se non si riesce a creare il file di salvataggio // @flag false | Se non si riesce a creare il file di salvataggio
bool TMask::save(const TFilename & fname, // @parm nome del file, se vuoto usa _workfile bool TMask::save(const TFilename & fname, // @parm nome del file, se vuoto usa _workfile
bool append) const // @parm Indica se creare il file o appendere (true) le informazioni bool append, // @parm Indica se creare il file o appendere (true) le informazioni
// ad uno gia' esistente (false, default). bool save_sheets) const // @parm Indica se creare il file o appendere (true) le informazioni
// ad uno gia' esistente (false, default).
{ {
if (fname.full()) if (fname.full())
@ -2614,15 +2629,34 @@ bool TMask::save(const TFilename & fname, // @parm nome del file, se vuoto usa _
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TMask_field& c = fld(i); TMask_field& c = fld(i);
if (c.is_editable())
fprintf(f, "%d|%s\n", c.dlg(), c.automagic()|| c.is_firm() ? "" : (const char*)c.get()); if (c.is_sheet())
{
if (save_sheets)
{
TSheet_field & s = (TSheet_field &)c;
int ncols = s.columns();
FOR_EACH_SHEET_ROW_LOOP(s, r)
{
for (int c = 0; c < ncols; c++)
{
const TString & val(s.get_str_row_cell(r, index2cid(c)));
fprintf(f, "%d;%d;%d|%s\n", s.dlg(), r, index2cid(c), val.blank() ? "" : (const char*)val);
}
}
}
}
else
if (c.is_editable())
fprintf(f, "%d|%s\n", c.dlg(), c.automagic()|| c.is_firm() ? "" : (const char*)c.get());
} }
fprintf(f, "[EOM]\n"); fprintf(f, "[EOM]\n");
fclose(f); fclose(f);
return true; return true;
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Legge i valori dei campi della maschera da file di salvataggioo // @mfunc Legge i valori dei campi della maschera da file di salvataggioo
@ -2656,6 +2690,7 @@ bool TMask::load(const TFilename & fname, // @parm nome del file, se vuoto usa _
if (t.not_empty()) if (t.not_empty())
{ {
t.rtrim(); t.rtrim();
const int pos = id2pos(t.get_int(0)); const int pos = id2pos(t.get_int(0));
const TString val = t.get(); const TString val = t.get();
@ -2663,13 +2698,26 @@ bool TMask::load(const TFilename & fname, // @parm nome del file, se vuoto usa _
{ {
TMask_field& c = fld(pos); TMask_field& c = fld(pos);
if (c.is_kind_of(CLASS_DATE_FIELD) && (c.automagic() || val == "%o" || val == "%O")) if (c.is_sheet())
c.set(today); {
TSheet_field & s = (TSheet_field &)c;
int ncols = s.columns();
TToken_string strid(t.get(0), ';');
int row = strid.get_int(1);
int id = strid.get_int(2);
if (row >= s.items())
s.row();
s.set_row_cell(id, val, row);
}
else else
if (c.is_kind_of(CLASS_EDIT_FIELD) && (c.is_firm() || val == "%f" || val == "%F")) if (c.is_kind_of(CLASS_DATE_FIELD) && (c.automagic() || val == "%o" || val == "%O"))
c.set(prefix().get_codditta()); c.set(today);
else else
c.set(val); if (c.is_kind_of(CLASS_EDIT_FIELD) && (c.is_firm() || val == "%f" || val == "%F"))
c.set(prefix().get_codditta());
else
c.set(val);
} }
} }
} }
@ -2774,8 +2822,8 @@ int TMask::save_profile(int num, const char* desc) const
} }
else else
{ {
if (!f.is_firm()) if (!f.is_firm())
ini.set(name, f.get()); ini.set(name, f.get());
} }
} }
} }

View File

@ -142,7 +142,6 @@ protected:
WINDOW create_bar(int height); // if height < 0 then BottomBar else TopBar WINDOW create_bar(int height); // if height < 0 then BottomBar else TopBar
// @cmember Aggiunge una pagina alla maschera // @cmember Aggiunge una pagina alla maschera
void insert_page(WINDOW page, int pos); void insert_page(WINDOW page, int pos);
WINDOW create_page(const char* title, int pos); // -1 <= pos < MAX_PAGES
// @cmember Inizializza la maschera // @cmember Inizializza la maschera
void init_mask(); void init_mask();
// @cmember Legge la pagina da file // @cmember Legge la pagina da file
@ -165,6 +164,7 @@ protected:
WINDOW notebook() const { return _notebook; } WINDOW notebook() const { return _notebook; }
// @access Public Member // @access Public Member
public: public:
WINDOW create_page(const char* title, int pos); // -1 <= pos < MAX_PAGES
// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk) // @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
TMask(const char* filename, int num = 0, int max = MAX_PAGES); TMask(const char* filename, int num = 0, int max = MAX_PAGES);
// @cmember Costruttore (crea una maschera vuota con i parametri dati) // @cmember Costruttore (crea una maschera vuota con i parametri dati)
@ -179,7 +179,7 @@ public:
// @cmember Imposta i bit di read_only // @cmember Imposta i bit di read_only
void set_locking(TBit_array & read_only, TToken_string & fields, bool on); void set_locking(TBit_array & read_only, TToken_string & fields, bool on);
// @cmember Legge la maschera da file // @cmember Legge la maschera da file
void read_mask(const char* name, int num, int max); void read_mask(const char* name, int num = 0, int max = MAX_PAGES);
// @cmember Legge il campo da file // @cmember Legge il campo da file
virtual TMask_field* parse_field(TScanner& scanner); virtual TMask_field* parse_field(TScanner& scanner);
@ -234,7 +234,7 @@ public:
// @cmember Aggiunge runtime un campo zoom alla maschera // @cmember Aggiunge runtime un campo zoom alla maschera
TZoom_field& add_zoom (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", int width = 0); TZoom_field& add_zoom (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", int width = 0);
// @cmember Aggiunge runtime un campo lista alla maschera // @cmember Aggiunge runtime un campo lista alla maschera
TList_field& add_list (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", const char* codes = NULL, const char* items = NULL); TList_field& add_list (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", const char* codes = nullptr, const char* items = nullptr, int width = 0);
// @cmember Aggiunge runtime un campo albero // @cmember Aggiunge runtime un campo albero
TTree_field& add_tree (short id, int page, int x, int y, int dx, int dy, const char* flags = ""); TTree_field& add_tree (short id, int page, int x, int y, int dx, int dy, const char* flags = "");
// @cmember Aggiunge runtime un group box alla maschera // @cmember Aggiunge runtime un group box alla maschera
@ -246,6 +246,9 @@ public:
// @cmember Aggiunge runtime un campo golem alla toolbar // @cmember Aggiunge runtime un campo golem alla toolbar
TGolem_field& add_golem_tool(short id, const char* prompt, const char* flags, bool archive, short bmpup = 0, short bmpdn = 0); TGolem_field& add_golem_tool(short id, const char* prompt, const char* flags, bool archive, short bmpup = 0, short bmpdn = 0);
// @cmember Aggiunge runtime un campo sheet alla maschera // @cmember Aggiunge runtime un campo sheet alla maschera
TSheet_field & add_sheet(short id, int page, const char * prompt, const char * maskname, int maskno,
const char * head, int x, int y, int width = 0, int height = 0, const char* flags = "");
// @cmember Aggiunge runtime un campo sheet alla maschera
void add_item(TMask_field & fld, const char * item); void add_item(TMask_field & fld, const char * item);
// @cmember Ritorna il numero di campi della maschera // @cmember Ritorna il numero di campi della maschera
@ -454,7 +457,7 @@ public:
void set_workfile(const char* workfile) void set_workfile(const char* workfile)
{ _workfile = workfile; _lastpos = 0L;} { _workfile = workfile; _lastpos = 0L;}
// @cmember Salva i valori dei campi della maschera sul file di salvataggio // @cmember Salva i valori dei campi della maschera sul file di salvataggio
bool save(const TFilename & fname = EMPTY_STRING, bool append = false) const; bool save(const TFilename & fname = EMPTY_STRING, bool append = false, bool save_sheets = true) const;
// @cmember Legge i valori dei campi della maschera da file di salvataggio // @cmember Legge i valori dei campi della maschera da file di salvataggio
bool load(const TFilename & fname = EMPTY_STRING, bool reset = false); bool load(const TFilename & fname = EMPTY_STRING, bool reset = false);
// @cmember Copia i valori dei campi dalla maschera <p m> // @cmember Copia i valori dei campi dalla maschera <p m>
@ -512,6 +515,8 @@ public:
// @cmember Viene eseguita se il campo viene modificato // @cmember Viene eseguita se il campo viene modificato
virtual bool on_dirty(TMask_field& c); virtual bool on_dirty(TMask_field& c);
// @cmember Ritorna l'ultima pagina
int last_page() const { return _pages - 1; }
// @cmember Ritorna la pagina identificata da <p w> // @cmember Ritorna la pagina identificata da <p w>
int win2page(WINDOW p) const ; int win2page(WINDOW p) const ;
// @cmember Ritorna la finestra della toolbar // @cmember Ritorna la finestra della toolbar

View File

@ -23,6 +23,11 @@ int cid2index(short cid)
return xvtil_cid2index(cid); return xvtil_cid2index(cid);
} }
int index2cid(short index)
{
return xvtil_index2cid(index);
}
int first_cell_id(const int cid) int first_cell_id(const int cid)
{ {
return xvtil_first_cell_id(cid); return xvtil_first_cell_id(cid);
@ -297,6 +302,9 @@ protected:
int cid2col(short cid) const; int cid2col(short cid) const;
// @cmember Ritorna la colonna logica con identificatore <p cid> // @cmember Ritorna la colonna logica con identificatore <p cid>
static int cid2index(short cid); static int cid2index(short cid);
// @cmember Ritorna l'identificatore <p cid> della colonna logica <index>
static int index2cid(short index);
// @cmember Ritorna la colonna corrispondente al campo <p f> della maschera // @cmember Ritorna la colonna corrispondente al campo <p f> della maschera
int field2col(const TOperable_field* f) const; int field2col(const TOperable_field* f) const;
@ -783,7 +791,7 @@ TOperable_field* TSpreadsheet::test_field(int pos) const
for (short id = column[pos]->cid; ; id += 100) for (short id = column[pos]->cid; ; id += 100)
{ {
TOperable_field* f = field(id); TOperable_field* f = field(id);
if (f == NULL) if (f == nullptr)
break; // Search failed break; // Search failed
good = f; // We've found a field with the proper ID ... good = f; // We've found a field with the proper ID ...
if (f->active()) if (f->active())
@ -835,6 +843,11 @@ int TSpreadsheet::cid2index(short cid)
return xvtil_cid2index(cid); return xvtil_cid2index(cid);
} }
int TSpreadsheet::index2cid(short index)
{
return xvtil_index2cid(index);
}
int TSpreadsheet::field2col(const TOperable_field* f) const int TSpreadsheet::field2col(const TOperable_field* f) const
{ {
const short cid = FIRST_FIELD + cid2index(f->dlg()); const short cid = FIRST_FIELD + cid2index(f->dlg());
@ -1473,7 +1486,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
} }
} }
_check_enabled = true; _check_enabled = true;
} }
break; break;
case XIE_DBL_CELL: case XIE_DBL_CELL:
if (!_cell_dirty || off_cell_handler()) if (!_cell_dirty || off_cell_handler())
@ -1909,7 +1922,6 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if ((_edit_field->class_id() == CLASS_ZOOM_FIELD)) if ((_edit_field->class_id() == CLASS_ZOOM_FIELD))
copy_cell2field(); copy_cell2field();
} }
if (!_edit_field->on_key(k)) if (!_edit_field->on_key(k))
{ {
refused = true; refused = true;
@ -2973,6 +2985,28 @@ TSheet_field::~TSheet_field()
} }
void TSheet_field::set_rect(short cx, short cy, short cwidth, short cheight, short clen)
{
if (_ctl)
{
XI_OBJ* itf = _ctl->get_interface(_ctl->parent());
RCT rct = _ctl->coord2rect(itf, cx, cy, cwidth + 1, cheight);
_ctl->set_rect(rct);
}
}
void TSheet_field::set_rect(const RCT& r)
{
if (_ctl)
{
XI_OBJ* itf = _ctl->get_interface(_ctl->parent());
_ctl->set_rect(r);
}
}
// Certified 100% // Certified 100%
void TSheet_field::reset() void TSheet_field::reset()
{ {
@ -3124,6 +3158,32 @@ void TSheet_field::create(WINDOW parent)
((TSpreadsheet*)_ctl)->load_columns_order(); ((TSpreadsheet*)_ctl)->load_columns_order();
} }
void TSheet_field::create(WINDOW parent, short id, const char * prompt, const char * maskname, int maskno, const char * head, int x, int y, int width, int height, const char * flags)
{
_ctl = new TSpreadsheet(parent, id, x, y, width, height, maskname, maskno, head, this);
if (!_flags.enable_default)
{
_flags.enabled = true; // Lo sheet e' sempre operabile anche se non editabile
disable();
((TSpreadsheet*)_ctl)->activate(false);
}
if (_flags.read_only)
{
((TSpreadsheet*)_ctl)->activate(false);
}
const TMask& s = sheet_mask();
for (short id = FIRST_FIELD; ; id++)
{
if (s.id2pos(id) < 0)
{
_last_column_id = id - 1;
break;
}
}
((TSpreadsheet*)_ctl)->load_columns_order();
}
// Certified 100% // Certified 100%
TString_array& TSheet_field::rows_array() const TString_array& TSheet_field::rows_array() const
{ {
@ -3423,6 +3483,11 @@ int TSheet_field::cid2index(short cid) const
return s->cid2index(cid); return s->cid2index(cid);
} }
int TSheet_field::index2cid(short index) const
{
TSpreadsheet* s = (TSpreadsheet*)_ctl;
return s->index2cid(index);
}
void TSheet_field::enable_row(int row, bool on) void TSheet_field::enable_row(int row, bool on)
{ {
TSpreadsheet* s = (TSpreadsheet*)_ctl; TSpreadsheet* s = (TSpreadsheet*)_ctl;
@ -3487,10 +3552,10 @@ void TSheet_field::show_column(int col, bool on) const
} }
// Matteo was here! // Matteo was here!
void TSheet_field::delete_column( const int col ) const void TSheet_field::delete_column(int column ) const
{ {
TSpreadsheet* s = (TSpreadsheet*)_ctl; TSpreadsheet* s = (TSpreadsheet*)_ctl;
s->delete_column( col ); s->delete_column( column );
} }
void TSheet_field::move_column( const int fromindex, const int toindex ) const void TSheet_field::move_column( const int fromindex, const int toindex ) const
@ -3556,7 +3621,7 @@ static int default_rows_compare(TSheet_field &s, int i, int j)
void TSheet_field::sort(ROWS_COMPARE_FUNCTION compare) void TSheet_field::sort(ROWS_COMPARE_FUNCTION compare)
{ {
if (compare == NULL) if (compare == nullptr)
compare = default_rows_compare; compare = default_rows_compare;
const long last = items()-1; const long last = items()-1;
@ -3897,7 +3962,7 @@ void TSheet_field::save_columns_order()
s.save_columns_order(); s.save_columns_order();
} }
void TSheet_field::check_row(int n, int mode) void TSheet_field::check_row(int n, int mode, bool final)
{ {
TSpreadsheet* s = (TSpreadsheet*)_ctl; TSpreadsheet* s = (TSpreadsheet*)_ctl;
const int current = s->_cur_rec; const int current = s->_cur_rec;
@ -3918,7 +3983,9 @@ void TSheet_field::check_row(int n, int mode)
if (f.has_check()) if (f.has_check())
f.set_dirty(); f.set_dirty();
} }
row2mask(n, r, mode); row2mask(n, r, mode);
if (final)
m.check_fields();
mask2row(n, r); mask2row(n, r);
m.set_mode(mask_mode); m.set_mode(mask_mode);
s->_cur_rec = current; s->_cur_rec = current;

View File

@ -37,6 +37,7 @@ typedef bool (*SPREADSHEET_NOTIFY)(TSheet_field& s, int r, KEY k);
typedef void (*SHEET_USERGETPUT)(TSheet_field &fld_righe, int item); typedef void (*SHEET_USERGETPUT)(TSheet_field &fld_righe, int item);
int cid2index(short cid); int cid2index(short cid);
int index2cid(short index);
int first_cell_id(const int cid); int first_cell_id(const int cid);
int next_cell_id(const int cid); int next_cell_id(const int cid);
@ -109,9 +110,13 @@ protected:
bool set_focus_cell(int riga, int colonna); bool set_focus_cell(int riga, int colonna);
//Copy Costructor per impedire la duplicazione accidentale degli sheet //Copy Costructor per impedire la duplicazione accidentale degli sheet
TSheet_field(const TSheet_field& s) : TLoadable_field(&s.mask()) { CHECK(false, "Can't duplicate TSheet_field"); } TSheet_field(const TSheet_field& s) : TLoadable_field(&s.mask()) { CHECK(false, "Can't duplicate TSheet_field"); }
// @access Public Member // @access Public Member
public: public:
virtual void create(WINDOW parent, short id, const char * prompt, const char * maskname, int maskno,
const char * head, int x, int y, int width, int height, const char * flags);
virtual void set_rect(short cx, short cy, short cwidth, short cheight, short clen = 0);
virtual void set_rect(const RCT& r);
// @cmember Permette di mettere il focus su una cella // @cmember Permette di mettere il focus su una cella
bool set_focus_cell_id(long rec, short cid); bool set_focus_cell_id(long rec, short cid);
@ -171,6 +176,8 @@ public:
virtual void set_row_cell(TToken_string & row, short id, const bool value) { row.add(value ? "X" : "", cid2index(id)); } virtual void set_row_cell(TToken_string & row, short id, const bool value) { row.add(value ? "X" : "", cid2index(id)); }
virtual int set_row_cell_currency(TToken_string& row, short id, const real& n); virtual int set_row_cell_currency(TToken_string& row, short id, const real& n);
virtual void clear_row_cell(TToken_string & row, short id) { set_row_cell(row, id, ""); }
virtual int set_row_cell(short id, const char * value, int nrow = -1); virtual int set_row_cell(short id, const char * value, int nrow = -1);
virtual int set_row_cell(short id, char value, int nrow = -1); virtual int set_row_cell(short id, char value, int nrow = -1);
virtual int set_row_cell(short id, long value, int nrow = -1); virtual int set_row_cell(short id, long value, int nrow = -1);
@ -180,6 +187,8 @@ public:
virtual int set_row_cell(short id, const bool value, int nrow = -1); virtual int set_row_cell(short id, const bool value, int nrow = -1);
virtual int set_row_cell_currency(short id, const real& n, int nrow = -1); virtual int set_row_cell_currency(short id, const real& n, int nrow = -1);
virtual int clear_row_cell(short id, int nrow = -1) { return set_row_cell(id, "", nrow); }
virtual const char * get_str_row_cell(TToken_string & row, short id) { return row.get(cid2index(id)); } virtual const char * get_str_row_cell(TToken_string & row, short id) { return row.get(cid2index(id)); }
virtual char get_char_row_cell(TToken_string & row, short id) { return row.get_char(cid2index(id)); } virtual char get_char_row_cell(TToken_string & row, short id) { return row.get_char(cid2index(id)); }
virtual long get_long_row_cell(TToken_string & row, short id) { return row.get_long(cid2index(id)); } virtual long get_long_row_cell(TToken_string & row, short id) { return row.get_long(cid2index(id)); }
@ -210,6 +219,8 @@ public:
void select(int r, int c, bool scrollto = false); void select(int r, int c, bool scrollto = false);
// @cmember Prenota la selezione della riga <p r> // @cmember Prenota la selezione della riga <p r>
void post_select(int r); void post_select(int r);
// @cmember numero di colonne dello sheet
int columns() const { return cid2index(_last_column_id) + 1; }
// @cmember Vuota tutto lo spreadsheet // @cmember Vuota tutto lo spreadsheet
virtual void reset(); virtual void reset();
@ -244,6 +255,8 @@ public:
// @cmember Trasforma l'identificatore di un campo <p cid> in un numero di colonna logica // @cmember Trasforma l'identificatore di un campo <p cid> in un numero di colonna logica
int cid2index(short cid) const; int cid2index(short cid) const;
// @cmember Trasforma il numero di colonna logica in un identificatore di un campo <p cid>
int index2cid(short index) const;
// @cmember Abilita/disabilita una colonna dello spreadsheet (vedi <mf TSpreadsheet::enable_column>) // @cmember Abilita/disabilita una colonna dello spreadsheet (vedi <mf TSpreadsheet::enable_column>)
void enable_column(int col, bool on = true); void enable_column(int col, bool on = true);
// @cmember Disabilita una colonna dello spreadsheet (vedi <mf TSpreadsheet::enable_column>) // @cmember Disabilita una colonna dello spreadsheet (vedi <mf TSpreadsheet::enable_column>)
@ -265,10 +278,10 @@ public:
// @cmember Permette di visualizzare una colonna dello spreadsheet // @cmember Permette di visualizzare una colonna dello spreadsheet
void show_column(int col, bool on) const; void show_column(int col, bool on) const;
// @cmember Permette di eliminare una colonna dallo spreadsheet // @cmember Permette di eliminare una colonna dallo spreadsheet
void delete_column( const int col ) const; void delete_column(int col) const;
bool exist_column(const int col) const; // @cmember Controlla se esiste la colonna dallo spreadsheet
// @cmember Sposta la colonna dalla posizione <p fromindex> alla posizione bool exist_column(int col) const;
// <p toindex> // @cmember Sposta la colonna dalla posizione <p fromindex> alla posizione <p toindex>
void move_column( const int fromindex, const int toindex ) const; void move_column( const int fromindex, const int toindex ) const;
// @cmember Permette di invertire la posizione di due colonne // @cmember Permette di invertire la posizione di due colonne
void swap_columns(const int fromid, const int toid) const; void swap_columns(const int fromid, const int toid) const;
@ -284,7 +297,7 @@ public:
void move_row(const int fromindex, const int toindex) const; void move_row(const int fromindex, const int toindex) const;
// @cmember Permette di ordinare le righe dello sheet // @cmember Permette di ordinare le righe dello sheet
void sort(ROWS_COMPARE_FUNCTION = NULL); void sort(ROWS_COMPARE_FUNCTION = nullptr);
// @cmember Controlla se l'utente ha salvato la disposizione delle colonne // @cmember Controlla se l'utente ha salvato la disposizione delle colonne
bool user_saved_columns_order() const; bool user_saved_columns_order() const;
@ -328,7 +341,7 @@ public:
virtual void post_insert(int) { } virtual void post_insert(int) { }
// @cmember Esegue tutti i check iniziali sulla riga <p n> // @cmember Esegue tutti i check iniziali sulla riga <p n>
void check_row(int n, int mode = 0x3); void check_row(int n, int mode = 0x3, bool final = false);
// @cmember Trasferisce i valori dalla maschera alla riga <p n> // @cmember Trasferisce i valori dalla maschera alla riga <p n>
void update_row(int n) { mask2row(n, row(n)); } void update_row(int n) { mask2row(n, row(n)); }
@ -377,7 +390,7 @@ public:
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \ #define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \
TString_array& sheetof##__riga = (__sheet).rows_array(); \ TString_array& sheetof##__riga = (__sheet).rows_array(); \
FOR_EACH_ARRAY_ROW_BACK(sheetof##__riga, __r, __riga) FOR_EACH_ARRAY_ROW_BACK(sheetof##__riga, __r, __riga)
#define FOR_EACH_SHEET_ROW_LOOP(__sheet, __r) \ #define FOR_EACH_SHEET_ROW_LOOP(__sheet, __r) \
int it##__r = __sheet.items(); \ int it##__r = __sheet.items(); \
for( int __r = 0; __r < it##__r; __r++) for( int __r = 0; __r < it##__r; __r++)

View File

@ -2057,12 +2057,7 @@ void TPrinter::close()
break; break;
case exportprinter: case exportprinter:
if (_exportfile.full() && _txt.lines() > 0L) if (_exportfile.full() && _txt.lines() > 0L)
{ auto_export(_exportfile);
ofstream txt(_exportfile);
for (long i = 0; i < _txt.lines(); i++)
txt << _txt.line_formatted(i) << '\n';
txt.close();
}
break; break;
case acrobatprinter: case acrobatprinter:
{ {

View File

@ -413,7 +413,7 @@ public:
bool frozen() bool frozen()
{ return _frozen; } { return _frozen; }
// @cmember Setta l'interruzione momentanea della stampante // @cmember Setta l'interruzione momentanea della stampante
void freeze(bool b = TRUE) void freeze(bool b = true)
{ _frozen = b; } { _frozen = b; }
// @cmember Ritorna il testo da stampare // @cmember Ritorna il testo da stampare
@ -544,10 +544,10 @@ public:
const TFilename& get_export_file() const { return _exportfile; } const TFilename& get_export_file() const { return _exportfile; }
// @cmember Dirige la stampa sul file specificato, preservando gli attributi di formato. // @cmember Dirige la stampa sul file specificato, preservando gli attributi di formato.
// Se <p header> = TRUE si stampano su file anche gli header // Se <p header> = TRUE si stampano su file anche gli header
void set_export_file(const char* n, bool header = TRUE, int len = 0) void set_export_file(const char* n, bool header = true, int len = 0)
{ _printertype = exportprinter; _exportfile = n; _export_header = header; _export_header_len = len;} { _printertype = exportprinter; _exportfile = n; _export_header = header; _export_header_len = len;}
// @cmember Inserisce un file di export fatto da un'altra printer // @cmember Inserisce un file di export fatto da un'altra printer
void merge_export_file(const char* file, bool header = TRUE); void merge_export_file(const char* file, bool header = true);
// @cmember Ritorna il numero di righe disponibili poer la stampa // @cmember Ritorna il numero di righe disponibili poer la stampa
word rows() const word rows() const
{ return word(_formlen-_headersize-_footersize); } { return word(_formlen-_headersize-_footersize); }

View File

@ -7,6 +7,7 @@
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
#include <dongle.h> #include <dongle.h>
#include <files.h>
#include <relation.h> #include <relation.h>
#include <sheet.h> #include <sheet.h>
#include <toolfld.h> #include <toolfld.h>
@ -93,6 +94,8 @@ public:
void update(long n = -1); void update(long n = -1);
bool head(int c, TString& str) const; bool head(int c, TString& str) const;
long first_one() const { return _checked.first_one(); }
long last_one() const { return _checked.last_one(); }
TSheet_control(WINDOW sheet, short cid, short x, short y, short dx, short dy, TSheet_control(WINDOW sheet, short cid, short x, short y, short dx, short dy,
const char* flags, const char* head); const char* flags, const char* head);
@ -1220,6 +1223,16 @@ bool TSheet::checked(long n) const
long TSheet::checked() const long TSheet::checked() const
{ return _sheet->checked(); } { return _sheet->checked(); }
long TSheet::first_one() const
{
return _sheet == nullptr ? 0L : _sheet->first_one();
}
long TSheet::last_one() const
{
return _sheet == nullptr ? 0L : _sheet->last_one();
}
bool TSheet::one_checked() const bool TSheet::one_checked() const
{ return _sheet->one_checked(); } { return _sheet->one_checked(); }
@ -1749,8 +1762,9 @@ bool TCursor_sheet::filter_dialog()
const char * fname = rec.fieldname(nf); const char * fname = rec.fieldname(nf);
TString ffname = DAFILTRO; ffname << fname; TString ffname = DAFILTRO; ffname << fname;
TMask_field* f = &m.field(101 + i); TMask_field* f = &m.field(101 + i);
// Non dovrebbe succedere ma lascio il codice vecchio in caso di errori // Non dovrebbe succedere ma lascio il codice vecchio in caso di errori
if(f == NULL) if(f == nullptr)
f = m.find_by_fieldname(ffname); f = m.find_by_fieldname(ffname);
if (f) if (f)
f->set(rec.get(fname)); f->set(rec.get(fname));
@ -1771,6 +1785,7 @@ bool TCursor_sheet::filter_dialog()
const char* fname = rec.fieldname(nf); const char* fname = rec.fieldname(nf);
TString ffname = (j ? AFILTRO : DAFILTRO); ffname << fname; TString ffname = (j ? AFILTRO : DAFILTRO); ffname << fname;
const TMask_field* f = m.find_by_fieldname(ffname); const TMask_field* f = m.find_by_fieldname(ffname);
if (f) prec->put(fname, f->get()); if (f) prec->put(fname, f->get());
} }
prec = &torec; prec = &torec;

View File

@ -83,6 +83,11 @@ public:
// @cmember Permette di disattivare una riga (chiama <mf TSheet::check>) // @cmember Permette di disattivare una riga (chiama <mf TSheet::check>)
void uncheck(long n) void uncheck(long n)
{ check(n, false); } { check(n, false); }
// @cmember Permette di attivare/disattivare tutte le righe
void check_all(bool on = true) { for (int i = 0; i < items(); i++) check(i, on); }
// @cmember Permette di disattivare tutte le righe
void uncheck_all() { check_all(false); }
// @cmember Permette di abilitare (<p yn> = true) o disabilitare (<p yn> = false) // @cmember Permette di abilitare (<p yn> = true) o disabilitare (<p yn> = false)
// la gestione dei check sullo sheet // la gestione dei check sullo sheet
void enable_check(bool on = true); void enable_check(bool on = true);
@ -106,6 +111,8 @@ public:
bool one_checked() const; bool one_checked() const;
// @cmember Ritorna il numero di elementi attivati (vedi <mf TBit_array::ones>) // @cmember Ritorna il numero di elementi attivati (vedi <mf TBit_array::ones>)
long checked() const; long checked() const;
long first_one() const;
long last_one() const;
// @cmember Forza l'aggiornamento di una o tutte le righe visibili // @cmember Forza l'aggiornamento di una o tutte le righe visibili
void force_update(int r = -1); void force_update(int r = -1);

View File

@ -574,6 +574,7 @@ public:
// @cmember Concatena un nome di file ad una directory // @cmember Concatena un nome di file ad una directory
TFilename& add(const char* n); TFilename& add(const char* n);
// @cmember Controlla se si tratta di un path assoluto // @cmember Controlla se si tratta di un path assoluto
bool is_absolute_path() const; bool is_absolute_path() const;
@ -683,6 +684,8 @@ public:
void destroy(int pos); void destroy(int pos);
// @cmember Toglie la stringa di posizione pos e la ritorna // @cmember Toglie la stringa di posizione pos e la ritorna
const char* remove(int pos); const char* remove(int pos);
// @cmember Azzera la stringa
void reset() { cut(0); }
// @cmember Ritorna il prossimo token // @cmember Ritorna il prossimo token
const char* get(); const char* get();
@ -792,7 +795,8 @@ protected:
// @access Public Member // @access Public Member
public: public:
// @cmember Costruttore // @cmember Costruttore
TParagraph_string(const char* s, int width); TParagraph_string(int width) : TToken_string("", '|'), _width(width) {}
TParagraph_string(const char* s, int width);
// @cmember Distruttore // @cmember Distruttore
virtual ~TParagraph_string() { } virtual ~TParagraph_string() { }

View File

@ -849,6 +849,12 @@ int xvtil_cid2index(const int cid)
return (cid % 100) - 1; return (cid % 100) - 1;
} }
int xvtil_index2cid(const int index)
{
CHECKD(index < FIRST_FIELD, "Bad column id ", index);
return index + FIRST_FIELD;
}
int xvtil_first_cell_id(const int cid) int xvtil_first_cell_id(const int cid)
{ {
CHECKD(cid >= FIRST_FIELD, "Bad column id ", cid); CHECKD(cid >= FIRST_FIELD, "Bad column id ", cid);

View File

@ -46,6 +46,7 @@ bool xvtil_popup_error(const char* msg);
bool xvtil_system_error(unsigned long lasterror, ...); bool xvtil_system_error(unsigned long lasterror, ...);
int xvtil_cid2index(const int cid); int xvtil_cid2index(const int cid);
int xvtil_index2cid(const int index);
int xvtil_first_cell_id(const int cid); int xvtil_first_cell_id(const int cid);
int xvtil_next_cell_id(const int cid); int xvtil_next_cell_id(const int cid);