From e394195ac8b2f30cbe738906b293ff5d5918b084 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 Dec 1997 14:36:43 +0000 Subject: [PATCH] array.cpp Corretto calcolo resize per array molto grandi (> 32000) array.h Corretto distruttore dei TPointer_array controls.cpp Corretto disegno cornice in maschere senza tag buttons isam.cpp Eliminato include inutilissimo mask.* Migliorato controllo campi con id duplicato git-svn-id: svn://10.65.10.50/trunk@5765 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/array.cpp | 13 +++++++---- include/array.h | 3 ++- include/controls.cpp | 26 ++++++++++------------ include/isam.cpp | 13 +++++------ include/mask.cpp | 52 ++++++++++++++++++++++++++++++++------------ include/mask.h | 6 +++++ 6 files changed, 73 insertions(+), 40 deletions(-) diff --git a/include/array.cpp b/include/array.cpp index 26208f82e..bd5edf6be 100755 --- a/include/array.cpp +++ b/include/array.cpp @@ -307,10 +307,15 @@ int TArray::add( // // @xref { - if (index < 0) for (index = _next; index < size() && _data[index]; index++); - - if (index >= size()) resize(int(3L*index/2) + 1); - + if (index < 0) + for (index = _next; index < size() && _data[index]; index++); + if (index >= size()) + { + long newsize = 3L * index / 2 + 1; + if (newsize > INT_MAX) + newsize = INT_MAX; + resize((int)newsize); + } if (_data[index] != NULL) { #ifdef DBG diff --git a/include/array.h b/include/array.h index 308017dee..5d95f0fbe 100755 --- a/include/array.h +++ b/include/array.h @@ -208,6 +208,7 @@ inline TObject& TArray::operator[] (int index) const class TPointer_array : public TArray { +public: virtual bool destroy(int index = -1, bool pack = FALSE); virtual int add(const TObject& object, int index); virtual int insert(const TObject& object, int index = 0, bool force = FALSE); @@ -216,7 +217,7 @@ class TPointer_array : public TArray TPointer_array() { } TPointer_array(int size) : TArray(size) { } TPointer_array(const TArray& a) { *this = a; } - virtual ~TPointer_array() { } + virtual ~TPointer_array() { destroy(); } }; // @doc EXTERNAL diff --git a/include/controls.cpp b/include/controls.cpp index 43d694fe0..9e3d32853 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -440,24 +440,22 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, xvt_vobj_move(win, &r); } + XI_RCT rct; xi_get_xi_rct(itf, &rct); if (tag) - { - XI_RCT rct; xi_get_xi_rct(itf, &rct); - rct.top += Y_FU_MULTIPLE; // Lascia lo spazio per i Bottoni di cambio pagina + rct.top += Y_FU_MULTIPLE; // Lascia lo spazio per i Bottoni di cambio pagina - def = xi_add_rect_def(NULL, MASK_RECT_ID, &rct, XI_ATR_VISIBLE, 0, 0); - XI_OBJ* obj = xi_create(itf, def); - CHECK(obj, "Can't create page rectangle"); + def = xi_add_rect_def(NULL, tag ? MASK_RECT_ID : -1, &rct, XI_ATR_VISIBLE, 0, 0); + XI_OBJ* obj = xi_create(itf, def); + CHECK(obj, "Can't create page rectangle"); - // Fa coincidere esattamente il rettangolo con la finestra che lo contiene - RCT& rect = obj->v.rect->rct; - const int oldy = rect.top; - xvt_vobj_get_client_rect(win, &rect); - rect.top = oldy; + // Fa coincidere esattamente il rettangolo con la finestra che lo contiene + RCT& rect = obj->v.rect->rct; + const int oldy = rect.top; + xvt_vobj_get_client_rect(win, &rect); + rect.top = oldy; - xi_dequeue(); - xi_tree_free(def); - } + xi_dequeue(); + xi_tree_free(def); return win; } diff --git a/include/isam.cpp b/include/isam.cpp index 55885faf4..2140f188a 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -4,7 +4,6 @@ #define __ISAM_CPP #ifndef FOXPRO -#include #include #include #include @@ -1984,7 +1983,7 @@ int TSystemisamfile::exec_convapp( TToken_string s(conv.get(v, NULL, num()), ' '); TFilename f(s.get(0)); f.ext(".exe"); - s << " " << main_app().get_firm(); + s << " " << prefix().get_codditta(); TExternal_app app(s); if (app.can_run()) @@ -2166,10 +2165,10 @@ int TSystemisamfile::update( TFieldtypes fld_type = nrec.type(fld_name); if (fld_type != _datefld) { - const int l1 = nrec.length(fld_name); - const int l2 = fld_val.len(); - if ( l1 < l2) - fld_val.cut(fld_type == _alfafld ? l1 : 0); + const int l1 = nrec.length(fld_name); + const int l2 = fld_val.len(); + if ( l1 < l2) + fld_val.cut(fld_type == _alfafld ? l1 : 0); } nrec.put(fld_name, fld_val); } @@ -2354,7 +2353,7 @@ int TSystemisamfile::load( TDate d(TODAY); TLocalisamfile ditte(LF_NDITTE); - firm.format("%05ld", main_app().get_firm()); + firm.format("%05ld", prefix().get_codditta()); year.format("%04d", d.year()); ditte.zero(); ditte.put("CODDITTA", firm); diff --git a/include/mask.cpp b/include/mask.cpp index e195ff557..fccc7b4a7 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -163,6 +163,20 @@ void TMask::read_mask( if (num == 0) _total_time = clock()-start_t; +} + +void TMask::add_field(TMask_field* f) +{ + const long pos = _field.add(f)+1; + const short id = f->dlg(); + if (id > 0 && id < 512) + { +#ifdef DBG + if (_position.objptr(id)) + NFCHECK("Il campo %d e' duplicato!", id); +#endif + _position.TArray::add((TObject*)pos, id); + } } void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel) @@ -172,8 +186,7 @@ void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel) pf->replace_items("1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16", tags); pf->set_default(sel); pf->create(_pagewin[pag]); - - _field.add(pf); + add_field(pf); } void TMask::add_tag_buttons(TToken_string& tags) @@ -494,6 +507,7 @@ int TMask::id2pos( // @comm Cerca nella maschera il campo con identificatore

e ne ritorna il numero ordinale // (es. il campo 120 e' il quarto della maschera) { +/* const int MAX_FIELDS = 256; static byte positions[MAX_FIELDS]; // 100 <= id < MAX_FIELDS const int max = fields(); @@ -523,6 +537,16 @@ int TMask::id2pos( } return -1; // Not found! +*/ + int pos = -1; + if (id > 0 && id < 512) + pos = int(long(_position.objptr(id))-1); + else + { + for (pos = fields()-1; pos >= 0; pos--) + if (fld(pos).dlg() == id) break; + } + return pos; } @@ -533,7 +557,7 @@ TMask_field& TMask::field(short id) const #ifdef DBG if (pos < 0) { - yesnofatal_box("Il campo %d non esiste", id); + NFCHECK("Il campo %d non esiste", id); pos = 0; } #endif @@ -937,7 +961,7 @@ WINDOW TMask::read_page( const long start = clock(); f->construct(scanner, w); - _field.add(f); + add_field(f); _build_time += clock()-start; } @@ -1498,7 +1522,7 @@ TMask_field& TMask::add_static ( { TText_field* f = new TText_field(this); f->construct(id, prompt, x, y, 0, _pagewin[page], flags); - _field.add(f); + add_field(f); return *f; } @@ -1522,7 +1546,7 @@ TEdit_field& TMask::add_string ( { TEdit_field* f = new TEdit_field(this); f->construct(id, prompt, x, y, dim, _pagewin[page], flags, width); - _field.add(f); + add_field(f); return *f; } @@ -1550,7 +1574,7 @@ TButton_field& TMask::add_button ( f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx); if (bmpup > 0) f->set_bmp(bmpup, bmpdn); - _field.add(f); + add_field(f); return *f; } @@ -1572,7 +1596,7 @@ TBoolean_field& TMask::add_boolean ( { TBoolean_field* f = new TBoolean_field(this); f->construct(id, prompt, x, y, strlen(prompt), _pagewin[page], flags); - _field.add(f); + add_field(f); return *f; } @@ -1596,7 +1620,7 @@ TReal_field& TMask::add_number ( { TReal_field* f = new TReal_field(this); f->construct(id, prompt, x, y, dim, _pagewin[page], flags, ndec); - _field.add(f); + add_field(f); return *f; } @@ -1618,7 +1642,7 @@ TDate_field& TMask::add_date ( { TDate_field* f = new TDate_field(this); f->construct(id, prompt, x, y, 10, _pagewin[page], flags); - _field.add(f); + add_field(f); return *f; } @@ -1644,7 +1668,7 @@ TList_field& TMask::add_list ( TList_field* f = new TList_field(this); f->construct(id, prompt, x, y, dim, _pagewin[page], flags); f->replace_items(codes,items); - _field.add(f); + add_field(f); return *f; } @@ -1670,7 +1694,7 @@ TRadio_field& TMask::add_radio( TRadio_field* f = new TRadio_field(this); f->replace_items(codes, items); f->construct(id, prompt, x, y, dx, _pagewin[page], flags, dx); - _field.add(f); + add_field(f); return *f; } @@ -1695,7 +1719,7 @@ TZoom_field& TMask::add_zoom ( { TZoom_field* f = new TZoom_field(this); f->construct(id, prompt, x, y, dim, _pagewin[page], flags, width); - _field.add(f); + add_field(f); return *f; } @@ -1719,7 +1743,7 @@ TMemo_field& TMask::add_memo( { TMemo_field* f = new TMemo_field(this); f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx); - _field.add(f); + add_field(f); return *f; } diff --git a/include/mask.h b/include/mask.h index 81da36048..f7eb0a41f 100755 --- a/include/mask.h +++ b/include/mask.h @@ -85,6 +85,9 @@ class TMask : public TWindow TFilename _workfile; // @cmember:(INTERNAL) Ultimo offset letto nel file di salvataggio long _lastpos; + + // @cmember:(INTERNAL) Array per convertire da id a posizione + TPointer_array _position; // @cmember:(INTERNAL) Cambio attuale per i cambi in valuta real _exchange; @@ -111,6 +114,9 @@ class TMask : public TWindow // @access Protected Member protected: TArray& fields_array() { return _field; } + + // Aggiunge un campo all'array _field + void add_field(TMask_field* f); // @cmember:(INTERNAL) Numero di sheet contenuti nella maschera int _sheets;