diff --git a/src/include/controls.cpp b/src/include/controls.cpp index 55374cf5c..29da149ca 100755 --- a/src/include/controls.cpp +++ b/src/include/controls.cpp @@ -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 { // 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; } +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 { return _obj->cid; } diff --git a/src/include/controls.h b/src/include/controls.h index 7823f4042..d95acadf3 100755 --- a/src/include/controls.h +++ b/src/include/controls.h @@ -19,6 +19,7 @@ struct XI_PNT; struct XI_RCT; #endif +int get_maxx_col(); void init_controls(); void free_controls(); @@ -58,9 +59,6 @@ protected: // @cmember:(INTERNAL) Puntatore al TMask_field eventualmente associato 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) XI_OBJ* find_operable(XI_OBJ* container, bool forward, bool normal) const; @@ -81,6 +79,10 @@ public: 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); virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep); diff --git a/src/include/mask.cpp b/src/include/mask.cpp index 2634c3b7c..8d089d57b 100755 --- a/src/include/mask.cpp +++ b/src/include/mask.cpp @@ -592,7 +592,6 @@ void TMask::start_run() if (f.dirty() == 1) // Attenzione puo' valere anche 3 per i very dirty! f.set_dirty(false); } - _last_test = -1; } @@ -616,7 +615,6 @@ bool TMask::check_fields() break; // Page disabled: end of test curpage = f.parent(); // Update current page } - if (sheet) f.set_dirty(); // Force check in sheet masks if (f.on_key(K_ENTER) == false) { @@ -2402,13 +2400,14 @@ TList_field& TMask::add_list ( int dim, // @parm Lunghezza del campo sulla maschera const char* flags, // @parm Flag di controllo del campo (default "") 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 // { 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); add_field(f); return *f; @@ -2576,6 +2575,20 @@ TGolem_field& TMask::add_golem_tool(short id, const char* prompt, const char* fl 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) { TFilename tmp; tmp.temp("use"); @@ -2589,6 +2602,7 @@ void TMask::add_item(TMask_field & fld, const char * item) while (scan.pop() != "EN") fld.parse_item(scan); } + // @doc EXTERNAL // @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 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 append) const // @parm Indica se creare il file o appendere (true) le informazioni - // ad uno gia' esistente (false, default). + bool append, // @parm Indica se creare il file o appendere (true) le informazioni + bool save_sheets) const // @parm Indica se creare il file o appendere (true) le informazioni +// ad uno gia' esistente (false, default). { 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++) { 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"); fclose(f); return true; } - // @doc EXTERNAL // @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()) { t.rtrim(); + const int pos = id2pos(t.get_int(0)); 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); - if (c.is_kind_of(CLASS_DATE_FIELD) && (c.automagic() || val == "%o" || val == "%O")) - c.set(today); + if (c.is_sheet()) + { + 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 - if (c.is_kind_of(CLASS_EDIT_FIELD) && (c.is_firm() || val == "%f" || val == "%F")) - c.set(prefix().get_codditta()); + if (c.is_kind_of(CLASS_DATE_FIELD) && (c.automagic() || val == "%o" || val == "%O")) + c.set(today); 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 { - if (!f.is_firm()) - ini.set(name, f.get()); + if (!f.is_firm()) + ini.set(name, f.get()); } } } diff --git a/src/include/mask.h b/src/include/mask.h index f43c18dd6..1b6e9137f 100755 --- a/src/include/mask.h +++ b/src/include/mask.h @@ -142,7 +142,6 @@ protected: WINDOW create_bar(int height); // if height < 0 then BottomBar else TopBar // @cmember Aggiunge una pagina alla maschera void insert_page(WINDOW page, int pos); - WINDOW create_page(const char* title, int pos); // -1 <= pos < MAX_PAGES // @cmember Inizializza la maschera void init_mask(); // @cmember Legge la pagina da file @@ -165,6 +164,7 @@ protected: WINDOW notebook() const { return _notebook; } // @access Public Member public: + WINDOW create_page(const char* title, int pos); // -1 <= pos < MAX_PAGES // @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk) TMask(const char* filename, int num = 0, int max = MAX_PAGES); // @cmember Costruttore (crea una maschera vuota con i parametri dati) @@ -179,7 +179,7 @@ public: // @cmember Imposta i bit di read_only void set_locking(TBit_array & read_only, TToken_string & fields, bool on); // @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 virtual TMask_field* parse_field(TScanner& scanner); @@ -234,7 +234,7 @@ public: // @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); // @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 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 @@ -246,6 +246,9 @@ public: // @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); // @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); // @cmember Ritorna il numero di campi della maschera @@ -454,7 +457,7 @@ public: void set_workfile(const char* workfile) { _workfile = workfile; _lastpos = 0L;} // @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 bool load(const TFilename & fname = EMPTY_STRING, bool reset = false); // @cmember Copia i valori dei campi dalla maschera

@@ -512,6 +515,8 @@ public: // @cmember Viene eseguita se il campo viene modificato 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

int win2page(WINDOW p) const ; // @cmember Ritorna la finestra della toolbar diff --git a/src/include/msksheet.cpp b/src/include/msksheet.cpp index 2d0e72f17..39d93280d 100755 --- a/src/include/msksheet.cpp +++ b/src/include/msksheet.cpp @@ -23,6 +23,11 @@ int cid2index(short cid) return xvtil_cid2index(cid); } +int index2cid(short index) +{ + return xvtil_index2cid(index); +} + int first_cell_id(const int cid) { return xvtil_first_cell_id(cid); @@ -297,6 +302,9 @@ protected: int cid2col(short cid) const; // @cmember Ritorna la colonna logica con identificatore

static int cid2index(short cid); + // @cmember Ritorna l'identificatore

della colonna logica + static int index2cid(short index); + // @cmember Ritorna la colonna corrispondente al campo

della maschera 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) { TOperable_field* f = field(id); - if (f == NULL) + if (f == nullptr) break; // Search failed good = f; // We've found a field with the proper ID ... if (f->active()) @@ -835,6 +843,11 @@ int TSpreadsheet::cid2index(short cid) return xvtil_cid2index(cid); } +int TSpreadsheet::index2cid(short index) +{ + return xvtil_index2cid(index); +} + int TSpreadsheet::field2col(const TOperable_field* f) const { 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; - } + } break; case XIE_DBL_CELL: 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)) copy_cell2field(); } - if (!_edit_field->on_key(k)) { 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% void TSheet_field::reset() { @@ -3124,6 +3158,32 @@ void TSheet_field::create(WINDOW parent) ((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% TString_array& TSheet_field::rows_array() const { @@ -3423,6 +3483,11 @@ int TSheet_field::cid2index(short cid) const 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) { TSpreadsheet* s = (TSpreadsheet*)_ctl; @@ -3487,10 +3552,10 @@ void TSheet_field::show_column(int col, bool on) const } // Matteo was here! -void TSheet_field::delete_column( const int col ) const +void TSheet_field::delete_column(int column ) const { TSpreadsheet* s = (TSpreadsheet*)_ctl; - s->delete_column( col ); + s->delete_column( column ); } 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) { - if (compare == NULL) + if (compare == nullptr) compare = default_rows_compare; const long last = items()-1; @@ -3897,7 +3962,7 @@ void TSheet_field::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; const int current = s->_cur_rec; @@ -3918,7 +3983,9 @@ void TSheet_field::check_row(int n, int mode) if (f.has_check()) f.set_dirty(); } - row2mask(n, r, mode); + row2mask(n, r, mode); + if (final) + m.check_fields(); mask2row(n, r); m.set_mode(mask_mode); s->_cur_rec = current; diff --git a/src/include/msksheet.h b/src/include/msksheet.h index 4b9b3c151..556ee56e6 100755 --- a/src/include/msksheet.h +++ b/src/include/msksheet.h @@ -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); int cid2index(short cid); +int index2cid(short index); int first_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); //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"); } - // @access Public Member 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 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 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, char 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_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 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)); } @@ -210,6 +219,8 @@ public: void select(int r, int c, bool scrollto = false); // @cmember Prenota la selezione della riga

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 virtual void reset(); @@ -244,6 +255,8 @@ public: // @cmember Trasforma l'identificatore di un campo

in un numero di colonna logica int cid2index(short cid) const; + // @cmember Trasforma il numero di colonna logica in un identificatore di un campo

+ int index2cid(short index) const; // @cmember Abilita/disabilita una colonna dello spreadsheet (vedi ) void enable_column(int col, bool on = true); // @cmember Disabilita una colonna dello spreadsheet (vedi ) @@ -265,10 +278,10 @@ public: // @cmember Permette di visualizzare una colonna dello spreadsheet void show_column(int col, bool on) const; // @cmember Permette di eliminare una colonna dallo spreadsheet - void delete_column( const int col ) const; - bool exist_column(const int col) const; - // @cmember Sposta la colonna dalla posizione

alla posizione - //

+ void delete_column(int col) const; + // @cmember Controlla se esiste la colonna dallo spreadsheet + bool exist_column(int col) const; + // @cmember Sposta la colonna dalla posizione

alla posizione

void move_column( const int fromindex, const int toindex ) const; // @cmember Permette di invertire la posizione di due colonne 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; // @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 bool user_saved_columns_order() const; @@ -328,7 +341,7 @@ public: virtual void post_insert(int) { } // @cmember Esegue tutti i check iniziali sulla riga

- 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

void update_row(int n) { mask2row(n, row(n)); } @@ -377,7 +390,7 @@ public: #define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \ TString_array& sheetof##__riga = (__sheet).rows_array(); \ FOR_EACH_ARRAY_ROW_BACK(sheetof##__riga, __r, __riga) - + #define FOR_EACH_SHEET_ROW_LOOP(__sheet, __r) \ int it##__r = __sheet.items(); \ for( int __r = 0; __r < it##__r; __r++) diff --git a/src/include/printer.cpp b/src/include/printer.cpp index 64576ee48..18f5e06a7 100755 --- a/src/include/printer.cpp +++ b/src/include/printer.cpp @@ -2057,12 +2057,7 @@ void TPrinter::close() break; case exportprinter: if (_exportfile.full() && _txt.lines() > 0L) - { - ofstream txt(_exportfile); - for (long i = 0; i < _txt.lines(); i++) - txt << _txt.line_formatted(i) << '\n'; - txt.close(); - } + auto_export(_exportfile); break; case acrobatprinter: { diff --git a/src/include/printer.h b/src/include/printer.h index fa235082c..c971848e9 100755 --- a/src/include/printer.h +++ b/src/include/printer.h @@ -413,7 +413,7 @@ public: bool frozen() { return _frozen; } // @cmember Setta l'interruzione momentanea della stampante - void freeze(bool b = TRUE) + void freeze(bool b = true) { _frozen = b; } // @cmember Ritorna il testo da stampare @@ -544,10 +544,10 @@ public: const TFilename& get_export_file() const { return _exportfile; } // @cmember Dirige la stampa sul file specificato, preservando gli attributi di formato. // Se

= 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;} // @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 word rows() const { return word(_formlen-_headersize-_footersize); } diff --git a/src/include/sheet.cpp b/src/include/sheet.cpp index 46f736478..6ac33dd7a 100755 --- a/src/include/sheet.cpp +++ b/src/include/sheet.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -93,6 +94,8 @@ public: void update(long n = -1); 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, const char* flags, const char* head); @@ -1220,6 +1223,16 @@ bool TSheet::checked(long n) const long TSheet::checked() const { 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 { return _sheet->one_checked(); } @@ -1749,8 +1762,9 @@ bool TCursor_sheet::filter_dialog() const char * fname = rec.fieldname(nf); TString ffname = DAFILTRO; ffname << fname; TMask_field* f = &m.field(101 + i); + // Non dovrebbe succedere ma lascio il codice vecchio in caso di errori - if(f == NULL) + if(f == nullptr) f = m.find_by_fieldname(ffname); if (f) f->set(rec.get(fname)); @@ -1771,6 +1785,7 @@ bool TCursor_sheet::filter_dialog() const char* fname = rec.fieldname(nf); TString ffname = (j ? AFILTRO : DAFILTRO); ffname << fname; const TMask_field* f = m.find_by_fieldname(ffname); + if (f) prec->put(fname, f->get()); } prec = &torec; diff --git a/src/include/sheet.h b/src/include/sheet.h index 5e26abf8a..b00c9ee8c 100755 --- a/src/include/sheet.h +++ b/src/include/sheet.h @@ -83,6 +83,11 @@ public: // @cmember Permette di disattivare una riga (chiama ) void uncheck(long n) { 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 (

= true) o disabilitare (

= false) // la gestione dei check sullo sheet void enable_check(bool on = true); @@ -106,6 +111,8 @@ public: bool one_checked() const; // @cmember Ritorna il numero di elementi attivati (vedi ) long checked() const; + long first_one() const; + long last_one() const; // @cmember Forza l'aggiornamento di una o tutte le righe visibili void force_update(int r = -1); diff --git a/src/include/strings.h b/src/include/strings.h index 56b881a1a..9444f162e 100755 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -574,6 +574,7 @@ public: // @cmember Concatena un nome di file ad una directory TFilename& add(const char* n); + // @cmember Controlla se si tratta di un path assoluto bool is_absolute_path() const; @@ -683,6 +684,8 @@ public: void destroy(int pos); // @cmember Toglie la stringa di posizione pos e la ritorna const char* remove(int pos); + // @cmember Azzera la stringa + void reset() { cut(0); } // @cmember Ritorna il prossimo token const char* get(); @@ -792,7 +795,8 @@ protected: // @access Public Member public: // @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 virtual ~TParagraph_string() { } diff --git a/src/include/xvtility.cpp b/src/include/xvtility.cpp index 64158bece..a999352c2 100755 --- a/src/include/xvtility.cpp +++ b/src/include/xvtility.cpp @@ -849,6 +849,12 @@ int xvtil_cid2index(const int cid) 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) { CHECKD(cid >= FIRST_FIELD, "Bad column id ", cid); diff --git a/src/include/xvtility.h b/src/include/xvtility.h index 44e07f1b8..db99d9be6 100755 --- a/src/include/xvtility.h +++ b/src/include/xvtility.h @@ -46,6 +46,7 @@ bool xvtil_popup_error(const char* msg); bool xvtil_system_error(unsigned long lasterror, ...); int xvtil_cid2index(const int cid); +int xvtil_index2cid(const int index); int xvtil_first_cell_id(const int cid); int xvtil_next_cell_id(const int cid);