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 <applicat.cpp> inutilissimo
mask.*       Migliorato controllo campi con id duplicato


git-svn-id: svn://10.65.10.50/trunk@5765 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-12-17 14:36:43 +00:00
parent 412275444a
commit e394195ac8
6 changed files with 73 additions and 40 deletions

View File

@ -307,10 +307,15 @@ int TArray::add(
//
// @xref <mf TArray::insert>
{
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

View File

@ -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

View File

@ -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;
}

View File

@ -4,7 +4,6 @@
#define __ISAM_CPP
#ifndef FOXPRO
#include <applicat.h>
#include <expr.h>
#include <execp.h>
#include <progind.h>
@ -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);

View File

@ -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 <p id> 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;
}

View File

@ -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;