diff --git a/include/classes.h b/include/classes.h index 0ffff423b..488530453 100755 --- a/include/classes.h +++ b/include/classes.h @@ -52,6 +52,19 @@ #define CLASS_CURRENCY_FIELD 249 #define CLASS_GOLEM_CLIENT_FIELD 250 +#define CLASS_BASEISAMFILE 300 +#define CLASS_ISAMFILE 301 +#define CLASS_SYSTEMISAMFILE 302 +#define CLASS_LOCALISAMFILE 303 +#define CLASS_ISAMTEMPFILE 304 +#define CLASS_EXTERNISAMFILE 304 +#define CLASS_SORTEDFILE 310 + +#define CLASS_RECTYPE 350 +#define CLASS_VARIABLE_RECTYPE 351 +#define CLASS_AUTO_VARIABLE_RECTYPE 352 +#define CLASS_EXT_RECTYPE 353 + #define CLASS_GOLEM 900 // @END diff --git a/include/controls.cpp b/include/controls.cpp index 829732525..df4e160e6 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -55,17 +55,6 @@ short low_get_focus_id(WINDOW win) return obj->cid; } -// Doesn't work: DON'T USE! -void low_set_focus_id(WINDOW win, short cid) -{ - XI_OBJ * itf = xi_get_itf((XinWindow)win); - if (cid > 0) - { - } - else - itf->v.itf->focus_obj = NULL; -} - HIDDEN int X_FU_MULTIPLE = 0; HIDDEN int Y_FU_MULTIPLE = 0; HIDDEN const int ITF_CID = 30000; @@ -377,6 +366,32 @@ HIDDEN void init_fu_multiple(XI_OBJ* itf) #define MASK_RECT_ID -883 +HIDDEN XI_BITMAP* get_background_bitmap() +{ + static bool checked = FALSE; + static XI_BITMAP* bmp = NULL; + + if (ADVANCED_GRAPHICS) + { + if (bmp == NULL && !checked) + { + const char* ext[] = { "jpg", "gif", "bmp", NULL }; + bool ok = false; + TFilename back("back"); + for (int i = 0; !ok && ext[i]; i++) + { + back.ext(ext[i]); + ok = back.custom_path(); + } + if (ok) + bmp = xi_bitmap_create(back.get_buffer(), XI_BITMAP_TILE); + checked = TRUE; + } + return bmp; + } + return NULL; +} + WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, const char* caption, TWindow* msk, bool tag) { @@ -431,11 +446,15 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, def->v.itf->font_id = xvt_default_font(FALSE); def->v.itf->tab_on_enter = TRUE; def->v.itf->win = (XinWindow)win; - -#ifdef XI_R4 - def->v.itf->edit_menu = TRUE; // Update edit menu items + def->v.itf->edit_menu = TRUE; // Update edit menu items def->v.itf->menu_win = (XinWindow)TASK_WIN; // Window that owns the menu -#endif + + XI_BITMAP* bmpback = get_background_bitmap(); + if (bmpback != NULL) + { + def->v.itf->back_color = 0; + def->v.itf->bitmap = bmpback; + } XI_OBJ* itf = xi_create(NULL, def); CHECK(itf, "Can't create an interface"); @@ -462,7 +481,13 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, 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); + if (bmpback != NULL) + { + def->v.rect->back_color = 0; + def->v.rect->bitmap = bmpback; + } + + 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 diff --git a/include/expr.cpp b/include/expr.cpp index 76b7a3981..ef1eefa36 100755 --- a/include/expr.cpp +++ b/include/expr.cpp @@ -408,14 +408,14 @@ void TExpression::eval() { const real & r2 = evalstack.pop_real(); real & r1 = evalstack.peek_real(); - r1 = (!r1.is_zero() && !r2.is_zero()) ? 1.0 : 0.0; + r1 = (!r1.is_zero() && !r2.is_zero()) ? UNO : ZERO; } break; case _or: { const real & r2 = evalstack.pop_real(); real & r1 = evalstack.peek_real(); - r1 = (r1 != ZERO || r2 != ZERO) ? 1.0 : 0.0; + r1 = (r1 != ZERO || r2 != ZERO) ? UNO : ZERO; } break; case _not: diff --git a/include/isam.cpp b/include/isam.cpp index 15eb2889b..4ea577ad2 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -262,7 +262,7 @@ void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout) } if (!__field_changed) { - __field_changed = memcmp(s, &recout, l) != 0; + __field_changed = memcmp(s, recout, l) != 0; if (!__field_changed) return; } @@ -272,7 +272,7 @@ void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout) { if (exceeded) len = l; - __field_changed = memcmp(s, &recout, l) != 0; + __field_changed = memcmp(s, recout, len) != 0; if (!__field_changed) return; @@ -1262,7 +1262,7 @@ int TBaseisamfile::_open( _isam_handle = prefix().open_isamfile(_logicnum, filename, mode==_excllock, index); if (_isam_handle > 0) { - TCodeb_handle cb_handle = prefix().get_handle(_isam_handle); + TCodeb_handle cb_handle = prefix().get_handle(_isam_handle, _curr_key); const int dbfreclen = DB_reclen(cb_handle); const int trcreclen = prefix().get_reclen(_logicnum); const TRecnotype n = DB_reccount(cb_handle); @@ -3069,20 +3069,18 @@ const char* TRectype::fieldname(int i) const const TString& TRectype::get_str(const char* fieldname) const { - TString& tmp = get_tmp_string(256); - const RecDes * recd = rec_des(); + const RecDes* recd = rec_des(); const int nf = findfld(recd, fieldname); const RecFieldDes& fd = recd->Fd[nf]; - if (nf == FIELDERR) - { - unknown_field(fieldname); - tmp.cut(0); + if (nf != FIELDERR) + { + TString& tmp = get_tmp_string(fd.Len + (fd.TypeF == _datefld ? 2 : 0)); + __getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, tmp.get_buffer()); + return tmp; } else - { - __getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, tmp.get_buffer()); - } - return tmp; + unknown_field(fieldname); + return EMPTY_STRING; } const TString& TRectype::get(const char* fieldname) const @@ -3095,12 +3093,13 @@ const TString& TRectype::get(const char* fieldname) const return _memo_data->row( index ); if(_memo_data->recno() >= 0L) { - int orig = _memo_data->file(); + const int orig = _memo_data->file(); if (orig) { - TCodeb_handle cb_handle = prefix().get_handle(orig); + TCodeb_handle cb_handle = prefix().get_handle(orig, -1); CHECKD(cb_handle >= 0, "Can't read memo from file ", orig); - DB_go(cb_handle, _memo_data->recno()); + if (DB_recno(cb_handle) != _memo_data->recno()) + DB_go(cb_handle, _memo_data->recno()); _memo_data->add(DB_memoptr(cb_handle, fieldname), index); } else diff --git a/include/isam.h b/include/isam.h index 53d516eb6..d278f8ddf 100755 --- a/include/isam.h +++ b/include/isam.h @@ -256,6 +256,10 @@ public: // @cmember Inizializza un record staccato da un file. void init(int logicnum); + + virtual word class_id() const { return CLASS_RECTYPE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TSortable::is_kind_of(id); } + // @cmember Costruttore Costruisce un record staccato da un file. // Sarebbe meglio utilizzare una delle altre due TRectype(int logicnum); @@ -510,6 +514,9 @@ public: // @cmember Testa se il file e' cambiato dal momento

bool is_changed_since(long& stat) const; + + virtual word class_id() const { return CLASS_BASEISAMFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TObject::is_kind_of(id); } // @cmember Costruttore TBaseisamfile(int logicnum); @@ -542,6 +549,10 @@ public: // @cmember Chiude il file di isam int close() { return _close();} + + virtual word class_id() const { return CLASS_ISAMFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TBaseisamfile::is_kind_of(id); } + // @cmember Costruttore TIsamfile(int logicnum); // @cmember Distruttore @@ -600,6 +611,9 @@ public: // @cmember Esporta VERSO un file ascii. int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE, const char * filter =NULL); + virtual word class_id() const { return CLASS_SYSTEMISAMFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TIsamfile::is_kind_of(id); } + // @cmember Costruttore TSystemisamfile(int logicnum): TIsamfile(logicnum) {} @@ -643,6 +657,9 @@ public: virtual bool tab() const { return FALSE;} + virtual word class_id() const { return CLASS_LOCALISAMFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TBaseisamfile::is_kind_of(id); } + // @cmember Costruttore. TLocalisamfile(int logicnum); // @cmember Distruttore @@ -677,6 +694,10 @@ public: // @cmember Setta il valore di

a

void set_autodel(bool val=TRUE) {_autodel = val;} + + virtual word class_id() const { return CLASS_ISAMTEMPFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TLocalisamfile::is_kind_of(id); } + // @cmember Costruttore TIsamtempfile(int logicnum, const char* radix, bool create=TRUE, bool autodel=FALSE); // @cmember Distruttore @@ -713,6 +734,9 @@ public: // @cmember Cancella tutti i record del file int zap(); + virtual word class_id() const { return CLASS_EXTERNISAMFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TLocalisamfile::is_kind_of(id); } + // @cmember Costruttore.

indica se aprire il file in modo esclusivo. //

indica se aprire il file con indici o meno TExternisamfile(const char* name, bool exclusive = FALSE, bool index = TRUE); diff --git a/include/prefix.cpp b/include/prefix.cpp index c6d7adb1a..e9a72dd8a 100755 --- a/include/prefix.cpp +++ b/include/prefix.cpp @@ -392,9 +392,7 @@ void TFile_info::auto_close() int TFile_info::auto_open(int key) { if (_handle < 0) - { open_low(FALSE, TRUE); - } if (_handle >= 0) { @@ -660,13 +658,18 @@ TCodeb_handle TFile_manager::get_handle(TIsam_handle name, int key) if (_open_files >= _max_open_files) close_oldest(); + // Se ho passato key = -1 mi va bene la chiave principale + if (key < 0) + key = 1; + handle = i.auto_open(key); if (handle >= 0) _open_files++; } else { - if (i.last_key() != key) + // Se ho passato key = -1 mi va bene la chiave corrente + if (key >= 0 && i.last_key() != key) handle = i.auto_open(key); } // i.touch(); // Memorizza troppo spesso l'accesso diff --git a/include/relation.h b/include/relation.h index a4734d135..257f1b860 100755 --- a/include/relation.h +++ b/include/relation.h @@ -782,6 +782,9 @@ public: // @cmember Resetta la regione del file (chiama

void setregion(const TRectype &f, const TRectype &t, int tilde = 0x0); + virtual word class_id() const { return CLASS_SORTEDFILE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TLocalisamfile::is_kind_of(id); } + // TO REMOVE TRelation& relation() { return *_rel; } diff --git a/include/varrec.h b/include/varrec.h index 62c01b6eb..d2ee702de 100755 --- a/include/varrec.h +++ b/include/varrec.h @@ -161,6 +161,9 @@ public: // @cmember Costruttore. Costruisce il record a partire da

TVariable_rectype(const TVariable_rectype & r); + virtual word class_id() const { return CLASS_VARIABLE_RECTYPE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TRectype::is_kind_of(id); } + // @cmember Distruttore virtual ~TVariable_rectype() {} }; @@ -199,6 +202,9 @@ public: // @cmember Costruttore. Costruisce il record a partire da

TAuto_variable_rectype(const TVariable_rectype & r) : TVariable_rectype(r) {} + virtual word class_id() const { return CLASS_AUTO_VARIABLE_RECTYPE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TVariable_rectype::is_kind_of(id); } + // @cmember Distruttore virtual ~TAuto_variable_rectype() {} }; @@ -217,6 +223,10 @@ protected: // TRectype public: + virtual word class_id() const { return CLASS_EXT_RECTYPE; } + virtual bool is_kind_of(word id) const { return id == class_id() || TVariable_rectype::is_kind_of(id); } + + TExtrectype(const TTrec& r); // Costruisce il record a partire da r virtual ~TExtrectype() ; };