From 45cc4b2e2002f463051f5fd7b4d82ad5592e066e Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 15 May 2008 14:59:21 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : librerie Ricompilazione Demo : [ ] Commento : Eliminato uso funzione localtime sostituendolo con xvt_time_now() Eliminato uso funzione localtime sostituendolo con xvt_time_now() Rese opzionali le griglie a lettura facilitata git-svn-id: svn://10.65.10.50/trunk@16626 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/alex.cpp | 3 +- include/applicat.cpp | 3 +- include/automask.cpp | 6 +- include/automask.h | 2 +- include/classes.h | 1 + include/colors.h | 1 + include/config.cpp | 3 +- include/controls.cpp | 60 +++++++++----- include/csort.c | 4 +- include/date.cpp | 10 +-- include/golem.cpp | 4 +- include/isam.cpp | 49 ++++-------- include/isamrpc.cpp | 4 +- include/mask.cpp | 25 ++++-- include/maskfld.cpp | 14 ++-- include/maskfld.h | 3 +- include/postman.cpp | 3 +- include/progind.cpp | 2 +- include/recset.cpp | 2 +- include/reprint.cpp | 4 +- include/sheet.cpp | 27 ++++--- include/sqlset.cpp | 2 +- include/strings.cpp | 2 +- include/treectrl.cpp | 185 ++++++++++++++++++++++++++++++++++++++++++- include/treectrl.h | 32 ++++++++ include/urldefid.h | 1 + include/utility.cpp | 11 +-- 27 files changed, 332 insertions(+), 131 deletions(-) diff --git a/include/alex.cpp b/include/alex.cpp index 637b4d4b4..3f3c2807c 100755 --- a/include/alex.cpp +++ b/include/alex.cpp @@ -1237,8 +1237,7 @@ bool TAlex_virtual_machine::get_usr_val(const TString& name, TVariant& var) cons } if (n == "TIME") { - time_t lt; time(<); - struct tm* t = localtime(<); + const struct tm* t = xvt_time_now(); TString16 str; str.format("%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec); var.set(str); diff --git a/include/applicat.cpp b/include/applicat.cpp index cca869937..7cc496a36 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -916,8 +916,7 @@ bool TApplication::get_next_pdf(int anno, long ditta, const char* codnum, if (numdoc <= 0) { - time_t lt; time(<); - struct tm& loc = *localtime(<); + const struct tm& loc = *xvt_time_now(); pdf << format("_%02d%02d%02d%02d%02d", loc.tm_mon, loc.tm_mday, loc.tm_hour, loc.tm_min, loc.tm_sec); } diff --git a/include/automask.cpp b/include/automask.cpp index f9a0cd35c..82f56c3ca 100755 --- a/include/automask.cpp +++ b/include/automask.cpp @@ -68,13 +68,9 @@ TField_event TAutomask::key2event(TMask_field& f, KEY key) const fe = f.focusdirty() ? fe_modify : fe_init; } break; - case K_SHIFT+K_SPACE: - if (f.is_kind_of(CLASS_TREE_FIELD)) - fe = fe_button; - break; case K_CTRL+K_SPACE: if (f.is_kind_of(CLASS_TREE_FIELD)) - fe = fe_select; + fe = fe_button; break; case K_ENTER: fe = fe_close; diff --git a/include/automask.h b/include/automask.h index 73793003e..720dcff7c 100755 --- a/include/automask.h +++ b/include/automask.h @@ -5,7 +5,7 @@ #include #endif -enum TField_event { fe_null, fe_init, fe_modify, fe_button, fe_close, fe_select, +enum TField_event { fe_null, fe_init, fe_modify, fe_button, fe_close, se_enter, se_leave, se_query_modify, se_notify_modify, se_query_add, se_notify_add, diff --git a/include/classes.h b/include/classes.h index c3cc6c930..7e8219c1f 100755 --- a/include/classes.h +++ b/include/classes.h @@ -53,6 +53,7 @@ #define CLASS_TREE_FIELD 251 #define CLASS_GOLEM_CLIENT_FIELD 252 #define CLASS_OUTLOOK_FIELD 253 +#define CLASS_SLIDER_FIELD 254 #define CLASS_TOOL_FIELD 280 #define CLASS_BUTTON_TOOL 281 diff --git a/include/colors.h b/include/colors.h index fd17d2049..0831cba48 100755 --- a/include/colors.h +++ b/include/colors.h @@ -37,6 +37,7 @@ extern bool AUTOSELECT; extern bool AUTOZOOM; extern bool AUTOEND; extern int TOOL_SIZE; +extern bool EASY_RIDER; const COLOR COLOR_DKCYAN = MAKE_COLOR(0,128,128); const COLOR COLOR_DKYELLOW = MAKE_COLOR(128,128, 0); diff --git a/include/config.cpp b/include/config.cpp index 1d65db6d6..bd86bf09e 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -23,8 +23,7 @@ bool TConfig::add_line(const TString& l) { if (val == "%yr%") { - time_t ora; time(&ora); - struct tm * oggi = localtime(&ora); + struct tm * oggi = xvt_time_now(); if (oggi != NULL) val.format("%04d", 1900 + oggi->tm_year); else diff --git a/include/controls.cpp b/include/controls.cpp index 6a98fbc39..0c16e1e05 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -41,6 +41,7 @@ bool AUTOZOOM = false; bool AUTOEND = false; bool NATIVE_CONTROLS = false; int TOOL_SIZE = 24; +bool EASY_RIDER = true; HIDDEN bool _button_blocked = false; HIDDEN int _last_mouse_button = 0; @@ -315,6 +316,7 @@ void customize_colors() AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, AUTOSELECT); AUTOZOOM = colors.get_bool("AutoZoom", NULL, -1, AUTOZOOM); ADVANCED_GRAPHICS = colors.get_bool("AdvancedGraphics", NULL, -1, ADVANCED_GRAPHICS); + EASY_RIDER = colors.get_bool("EasyRider", NULL, -1, EASY_RIDER); if (ADVANCED_GRAPHICS) { const long dt = xvt_vobj_get_attr(NULL_WIN, ATTR_DISPLAY_TYPE); @@ -357,17 +359,12 @@ void init_controls() xi_set_pref(XI_PREF_NATIVE_CTRLS, NATIVE_CONTROLS); xi_set_pref(XI_PREF_3D_LOOK, CAMPI_SCAVATI); xi_set_pref(XI_PREF_CARET_WIDTH, 2); -//#ifdef XI_R4 - xi_set_pref(XI_PREF_COMBO_ICON, ICO_COMBO); + xi_set_pref(XI_PREF_COMBO_ICON, ICO_COMBO); xi_set_pref(XI_PREF_OPTIMIZE_CELL_REQUESTS, true); -/* -#else - xi_set_pref(XI_PREF_COMBO_ICON, COMBO_ICON); -#endif - */ xi_init(); + memset(event_map, a_ignore, sizeof(event_map)); event_map[XIE_CHAR_FIELD] = a_obj; event_map[XIE_DBL_FIELD] = a_obj; event_map[XIE_CHG_FIELD] = a_obj; @@ -686,9 +683,29 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev) { TWindow* w = (TWindow*)xi_get_app_data(itf); if (w != NULL && w->win() != NULL_WIN) - w->handler(w->win(), &xiev->v.xvte); - if (xiev->v.xvte.type == E_MOUSE_UP) - _button_blocked = false; + { + switch (xiev->v.xvte.type) + { + case E_CONTROL: + switch (xiev->v.xvte.v.ctl.ci.type) + { + case WC_PUSHBUTTON: + case WC_RADIOBUTTON: + case WC_CHECKBOX: + break; // Ignora i bottoni altrimenti li preme due volte se nativi + default: + w->handler(w->win(), &xiev->v.xvte); + break; + } + break; + case E_MOUSE_UP: + _button_blocked = false; + // fall down + default: + w->handler(w->win(), &xiev->v.xvte); + break; + } + } } else notify_xvt = true; @@ -719,7 +736,7 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev) { xiev->refused = true; if (xiev->type == XIE_CHAR_FIELD || xiev->type == XIE_CHAR_CELL || - xiev->type == XIE_XVT_EVENT) + xiev->type == XIE_XVT_EVENT || xiev->type == XIE_BUTTON) notify_xvt = false; } } @@ -1379,7 +1396,6 @@ void TField_control::create(WINDOW win, short cid, { f->button = true; f->pixel_button_distance = 1; - f->button_width = 18; } } else // E' un multiline, quindi setto il rettangolo @@ -1908,7 +1924,6 @@ byte TRadiobutton_control::get_checked() const int children; XI_OBJ** child = xi_get_member_list(_obj, &children); int c; - for (c = children-1; c > 0; c--) if (xi_is_checked(child[c])) break; return (byte)c; @@ -1918,17 +1933,20 @@ void TRadiobutton_control::check_button(byte c) { int children; XI_OBJ** child = xi_get_member_list(_obj, &children); - CHECKD(c < children, "This radio is rather old, it doesn't have button ", c); - if (!xi_is_checked(child[c]) || NATIVE_CONTROLS) + if (child != NULL && c < children) xi_check(child[c], true); + else + NFCHECK("This radio is rather old, it doesn't have a button"); } void TRadiobutton_control::show_button(byte c, bool on) { int children; XI_OBJ** child = xi_get_member_list(_obj, &children); - CHECKD(c < children, "This radio is rather old, it doesn't have button ", c); - change_attrib(XI_ATR_VISIBLE, on, child[c]); + if (child != NULL && c < children) + change_attrib(XI_ATR_VISIBLE, on, child[c]); + else + NFCHECK("This radio is rather old, it doesn't have a button"); } bool TRadiobutton_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev) @@ -1939,8 +1957,8 @@ bool TRadiobutton_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev) XI_OBJ* obj = xiev->v.xi_obj; // Elemento del gruppo di radio buttons da premere if (xi_move_focus(obj)) // Tenta di dargli il focus { - if (!xi_is_checked(obj)) // Se non e' gia' premuto ... - { + if (!xi_is_checked(obj) || xi_get_native_controls(obj)) + { // Se non e' gia' premuto ... xi_check(obj, true); // ... allora premilo e ... ok = notify_key(K_SPACE); // ... avverti il mask_field proprietario } @@ -1958,9 +1976,9 @@ void TRadiobutton_control::set_focus() const int children; XI_OBJ** child = xi_get_member_list(_obj, &children); int c; - for (c = children-1; c > 0; c--) - if (xi_is_checked(child[c])) break; + if (xi_is_checked(child[c])) + break; xi_set_focus(child[c]); } diff --git a/include/csort.c b/include/csort.c index d232d0aff..d0bb73521 100755 --- a/include/csort.c +++ b/include/csort.c @@ -172,7 +172,7 @@ static void prep_merge() strcpy(fdname, f2name); strcpy(f2name, wname); fclose(fp2); - xvt_fsys_removefile(f2name); + xvt_fsys_remove_file(f2name); fp2 = NULL; /* @(:) 2.3.00.112 */ nrcds *= 2; @@ -471,7 +471,7 @@ static FILE *wopen(char* name) /* nome del file temporaneo */ if (!j) { fclose(fp1); /* none left */ - xvt_fsys_removefile(fdname); + xvt_fsys_remove_file(fdname); /* @(!) 2.3.00.112 eliminata if (fp2) */ /* @(!) 2.3.00.112 eliminata { */ /* @(!) 2.3.00.112 eliminata fclose(fp2); */ diff --git a/include/date.cpp b/include/date.cpp index 19e581805..53642c9f3 100755 --- a/include/date.cpp +++ b/include/date.cpp @@ -27,14 +27,8 @@ TDate::TDate(long l) : _val(l) { if (_val == TODAY) { - _val = NULLDATE; - time_t lt; - if (time(<) != -1) - { - struct tm * timeloc = localtime(<); - if (timeloc != NULL) - _val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900); - } + const struct tm * timeloc = xvt_time_now(); + _val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900); } else { diff --git a/include/golem.cpp b/include/golem.cpp index 82beab994..def2508e4 100755 --- a/include/golem.cpp +++ b/include/golem.cpp @@ -205,9 +205,7 @@ bool TGolem_mask::sheet_notify(TSheet_field& s, int r, KEY k) { TToken_string row = s.row(r); if (row.get_char(2)<=' ') - { - xvt_fsys_removefile(row.get(0)); - } + xvt_fsys_remove_file(row.get(0)); } return true; } diff --git a/include/isam.cpp b/include/isam.cpp index a24fa90a9..dbcfff327 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -826,7 +826,7 @@ TBaseisamfile::TBaseisamfile( } _lasterr = NOERR; TFilename filename(name); - CHECK(filename.not_empty(),"Must define the file to open!"); + CHECK(filename.full(),"Must define the file to open!"); _logicnum = prefix().get_handle(filename); _current = new TRectype(this); @@ -3477,12 +3477,12 @@ int TRectype::compare_key( HIDDEN bool fld_empty(const char* s, int len, bool number) { - if (*s) + if (s && *s) { for (; len; s++, len--) - if (*s != ' ') return FALSE; + if (*s != ' ') return false; } - return TRUE; + return true; } @@ -3515,7 +3515,6 @@ int TRectype::items() const return rec_des()->NFields; } - const char* TRectype::start(int nf) const { return string() + rec_des()->Fd[nf].RecOff; @@ -3585,53 +3584,35 @@ bool TRectype::is_equal(const TRectype& r) const return yes; } - TFieldtypes TRectype::type(const char* fieldname) const { const RecDes* recd = rec_des(); - int p = findfld(recd, fieldname); - - if (p != FIELDERR) - return (TFieldtypes) recd->Fd[p].TypeF; - else - return _nullfld; + const int p = findfld(recd, fieldname); + return p != FIELDERR ? (TFieldtypes)recd->Fd[p].TypeF : _nullfld; } - int TRectype::length(const char* fieldname) const { const RecDes * recd = rec_des(); - int p = findfld(recd, fieldname); - - if (p != FIELDERR) - return(recd->Fd[p].Len); - else - return(0); + const int p = findfld(recd, fieldname); + return p != FIELDERR ? recd->Fd[p].Len : 0; } int TRectype::ndec(const char* fieldname) const - { - const RecDes * recd = rec_des(); - int p = findfld(recd, fieldname); - - if (p != FIELDERR) - return(recd->Fd[p].Dec); - else - return(0); + const RecDes* recd = rec_des(); + const int p = findfld(recd, fieldname); + return p != FIELDERR ? recd->Fd[p].Dec : 0; } - bool TRectype::exist(const char* fieldname) const { - const bool ok = findfld(rec_des(), fieldname) != FIELDERR; - return ok; + return findfld(rec_des(), fieldname) != FIELDERR; } - const char* TRectype::fieldname(int i) const { - const RecDes * recd = rec_des(); + const RecDes* recd = rec_des(); return i >= 0 && i < recd->NFields ? recd->Fd[i].Name : NULL; } @@ -3639,9 +3620,9 @@ const TString& TRectype::get_str(const char* fieldname) const { const RecDes* recd = rec_des(); const int nf = findfld(recd, fieldname); - const RecFieldDes& fd = recd->Fd[nf]; if (nf != FIELDERR) { + const RecFieldDes& fd = recd->Fd[nf]; TString& tmp = get_tmp_string(fd.Len + (fd.TypeF == _datefld ? 2 : 0)); __getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, tmp, __file_is_crypted(num())); return tmp; @@ -4097,7 +4078,7 @@ bool TRectype::edit(int logicnum, const char* alternate_key_fields, const char* ok = result == "OK"; } - xvt_fsys_removefile(ininame); + xvt_fsys_remove_file(ininame); if (ok) rec_cache(logicnum).notify_change(); diff --git a/include/isamrpc.cpp b/include/isamrpc.cpp index c9ac6157f..a4d38b389 100755 --- a/include/isamrpc.cpp +++ b/include/isamrpc.cpp @@ -217,9 +217,7 @@ static unsigned int CreatePassword(TString& pass) { const int BASE = 19; unsigned int num = 0; - time_t lt; time(<); - struct tm* t = localtime(<); - + const struct tm* t = xvt_time_now(); srand(t->tm_hour * 10000 + t->tm_min *100 + t->tm_sec); do { diff --git a/include/mask.cpp b/include/mask.cpp index a3421e324..33c7fb582 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -831,7 +831,7 @@ void TMask::handler(WINDOW win, EVENT* ep) if (ep->type == E_CONTROL) { - if (is_running()) + if (is_running()) // Scarto a priori gli eventi di inizializzazione { switch (ep->v.ctl.ci.type) { @@ -839,13 +839,22 @@ void TMask::handler(WINDOW win, EVENT* ep) if (ep->v.ctl.ci.win == _notebook) { const int new_page = ep->v.ctl.ci.v.notebk.tab_no; - if (new_page != _page && new_page < _pages) + if (new_page != _page && new_page < _pages) // Cambio pagina effettivo show_page(new_page); } break; - case WC_PUSHBUTTON: - if (ep->v.ctl.ci.win == _toolbar) - field(ep->v.ctl.id).on_key(K_SPACE); + case WC_ICON: // In realta' trattasi di bottone di toolbar + if (ep->v.ctl.ci.win == toolbar()) // Test di sicurezza semi-inutile + field(ep->v.ctl.id).on_key(K_SPACE); // Gestisco l'evento di pressione del bottone + break; + case WC_HSCROLL: + case WC_VSCROLL: + if (id2pos(ep->v.ctl.id) >= 0) // potrebbero non avere un controllo associato + field(ep->v.ctl.id).on_key(K_SPACE); + break; + case WC_HSLIDER: + case WC_VSLIDER: + field(ep->v.ctl.id).on_key(K_SPACE); break; default: break; @@ -1010,6 +1019,8 @@ TMask_field* TMask::parse_field(TScanner& scanner) if (k == "SP") return new TSheet_field(this); if (k == "TR") return new TTree_field(this); if (k == "CL") return new TGolem_client_field(this); + if (k == "SL") return new TSlider_field(this); + return NULL; } @@ -1464,8 +1475,8 @@ void TMask::set( void TMask::set(short fld_id, long n, byte hit) { - char s[16]; - sprintf(s, "%ld", n); + TString16 s; + s << n; set(fld_id, s, hit); } diff --git a/include/maskfld.cpp b/include/maskfld.cpp index f3e0c9303..df710fe21 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -1058,9 +1058,7 @@ void TLoadable_field::set_default(const char* def) TButton_field::TButton_field(TMask* m) : TOperable_field(m) -{ -} - +{ } word TButton_field::class_id() const { return CLASS_BUTTON_FIELD; } @@ -1076,7 +1074,6 @@ void TButton_field::parse_head(TScanner& scanner) if (_ctl_data._height <= 0) _ctl_data._height = 1; } - bool TButton_field::parse_item(TScanner& scanner) { if (scanner.key() == "PI") @@ -1091,7 +1088,6 @@ bool TButton_field::parse_item(TScanner& scanner) return TOperable_field::parse_item(scanner); } - void TButton_field::create(WINDOW parent) { _exit_key = 0; @@ -1702,7 +1698,7 @@ void TBoolean_field::set_window_data(const char* data) TString& TBoolean_field::get_window_data() { - const bool on = _ctl ? ((TCheckbox_control*)_ctl)->checked() : FALSE; + const bool on = _ctl != NULL && ((TCheckbox_control*)_ctl)->checked(); _str = on ? "X" : ""; return _str; } @@ -1711,10 +1707,10 @@ bool TBoolean_field::parse_item(TScanner& scanner) { if (scanner.key() == "ME") { - const bool tf = scanner.integer() ? TRUE : FALSE; // Message TRUE or FALSE + const bool tf = scanner.integer() != 0; // Message TRUE or FALSE TToken_string* ts = message(tf, TRUE); ts->add(scanner.line().strip_spaces()); - return TRUE; + return true; } return TEditable_field::parse_item(scanner); @@ -4595,7 +4591,7 @@ bool TList_field::parse_item(TScanner& scanner) if (scanner.key() == "IT") // ITEM { read_item(scanner); - return TRUE; + return true; } return TEditable_field::parse_item(scanner); diff --git a/include/maskfld.h b/include/maskfld.h index 820cb69bc..c45c58547 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -1653,7 +1653,8 @@ class TField_window : public TScroll_window protected: virtual void update(); virtual void handler(WINDOW win, EVENT* ep); - + void set_owner(TWindowed_field* o); + public: virtual bool on_key(KEY k); TWindowed_field& owner() const { return *_owner; } diff --git a/include/postman.cpp b/include/postman.cpp index 0a6787648..9222c0c8a 100755 --- a/include/postman.cpp +++ b/include/postman.cpp @@ -326,8 +326,7 @@ bool TPostman::dispatch_transaction(const TRectype& rec, if (file_dest.items() > 0) { TString16 basename; - time_t lt; time(<); - struct tm * tl = localtime(<); + const struct tm * tl = xvt_time_now(); basename.format("%02d%02d%02d_%02d%02d%02d_0", tl->tm_year%100, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); diff --git a/include/progind.cpp b/include/progind.cpp index c5d964a1f..2fe47036c 100755 --- a/include/progind.cpp +++ b/include/progind.cpp @@ -155,7 +155,7 @@ void TIndwin::update_bar() { const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC; const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5); - TString8 str_res, str_tot; + TString16 str_res, str_tot; sec2str(total_time - elapsed_time, str_res); sec2str(total_time, str_tot); diff --git a/include/recset.cpp b/include/recset.cpp index 3b5b410da..9281ba89d 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -317,7 +317,7 @@ bool TRecordset::save_as_dbf(const char* table, int mode) n = volume; n.add(dirname); n.add(name); n.ext("*"); TString_array files; list_files(n, files); FOR_EACH_ARRAY_ROW(files, f, row) - xvt_fsys_removefile(*row); + xvt_fsys_remove_file(*row); } mode = 0x1; } diff --git a/include/reprint.cpp b/include/reprint.cpp index 1f948b42f..dde459764 100755 --- a/include/reprint.cpp +++ b/include/reprint.cpp @@ -1719,7 +1719,7 @@ void TBook::split_file(int colonne) // Sostituisce il file di stampa con quello splittato ed aggiorna l'indice delle pagine fcopy(temp, _file); - xvt_fsys_removefile(temp); + xvt_fsys_remove_file(temp); _index = index; _pages = _index.last(); } @@ -1806,7 +1806,7 @@ void TBook::join_file(int pps) // Sostituisce il file di stampa con quello joinato fcopy(temp, _file); - xvt_fsys_removefile(temp); + xvt_fsys_remove_file(temp); } bool TBook::can_split(int pages) const diff --git a/include/sheet.cpp b/include/sheet.cpp index 7e2e56a33..2e312d488 100755 --- a/include/sheet.cpp +++ b/include/sheet.cpp @@ -191,9 +191,10 @@ TSheet_control::TSheet_control( } // Calcola rettangolo massimo per lo sheet - RCT rct; coord2rct(parent, x, y, dx, dy, rct); - rct.right -= 2*XI_FU_MULTIPLE; // toglie scroll-bar - +// RCT rct; coord2rct(parent, x, y, dx, dy, rct); +// rct.right -= 2*XI_FU_MULTIPLE; // toglie scroll-bar + RCT rct; coord2rct(parent, x, y, -2, -2, rct); + // Controlla se ci sono troppe colonne fisse if ((f_width+max_width)*XI_FU_MULTIPLE > rct.right) fixed_columns = 1; @@ -1020,7 +1021,7 @@ TSheet::TSheet(short x, short y, short dx, short dy, if (buttons & 0x01) add_button(DLG_LINK, TR("Colle~ga"), K_CTRL+'G', BMP_LINK); if (buttons & 0x02) add_button(DLG_NEWREC, TR("~Nuovo"), K_INS, BMP_NEWREC); if (buttons & 0x04) add_button(DLG_DELREC, "~Elimina", K_DEL, BMP_DELREC); - if (!check_enabled()) + //if (!check_enabled()) { add_button(DLG_SAVEREC, TR("~Esporta"), 0, BMP_SAVEREC); set_handler(DLG_SAVEREC, export_handler); @@ -1029,7 +1030,7 @@ TSheet::TSheet(short x, short y, short dx, short dy, else add_button(DLG_CANCEL, "Annulla", K_ESC, BMP_CANCEL); xvt_toolbar_realize(toolbar()); // Necessario per calcolare dimensioni corrette dello sheet -} +} TSheet::~TSheet() { @@ -1075,8 +1076,6 @@ void TSheet::add_button( } else { - if (toolbar() == NULL_WIN) - create_bar(1); // Forza la creazione della top bar TButton_tool& butt = add_button_tool(id, caption, bmp_up); butt.set_exit_key(key); } @@ -1085,7 +1084,7 @@ void TSheet::add_button( bool TSheet::get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const { fore = back = 0; // Default colors - if (row & 1) + if (EASY_RIDER && (row & 1)) back = REQUIRED_BACK_COLOR; return false; // Not assigned } @@ -1132,13 +1131,15 @@ void TSheet::repos_buttons() const } } - // Aggiusta anche lo spreadsheet + // Aggiusta anche lo spreadsheet se necessario TMask_field& s = field(DLG_QUERY); xvt_vobj_get_client_rect(s.parent(), &wr); s.get_rect(br); -// br.right = wr.right - br.left + 2*CHARX; - br.bottom = wr.bottom - br.left; - s.set_rect(br); + if (br.bottom > wr.bottom || (wr.bottom-br.bottom) > 48) + { + br.bottom = wr.bottom - br.left; // Lascio uno spazio in fondo pari al bordo sinistro + s.set_rect(br); + } } void TSheet::force_update(int r) @@ -1863,7 +1864,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields, e = &add_number(c.dlg(), 0, p, 1, y++, csize, flags); break; case CLASS_DATE_FIELD: - e = &add_date (c.dlg(), 0, p, 1, y++, flags); + e = &add_date(c.dlg(), 0, p, 1, y++, flags); break; default: e = NULL; diff --git a/include/sqlset.cpp b/include/sqlset.cpp index f701d9a9b..483c053c7 100755 --- a/include/sqlset.cpp +++ b/include/sqlset.cpp @@ -67,7 +67,7 @@ sqlite3* TSQLite::open(const char* fname) if (err = SQLITE_CORRUPT) { close(); - xvt_fsys_removefile(_currdb); + xvt_fsys_remove_file(_currdb); err = sqlite3_open(_currdb, &_handle); } diff --git a/include/strings.cpp b/include/strings.cpp index 6f1883d1a..47d63729f 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -404,7 +404,7 @@ int TString::find(const char* s, int from) const bool TString::match(const char* pat, bool ignore_case) const { - return (pat && *pat) ? xvt_str_match(_str, pat, TRUE) != 0 : empty(); + return (pat && *pat) ? xvt_str_match(_str, pat, !ignore_case) != 0 : empty(); } int TString::replace(char find_char, char replace_char) diff --git a/include/treectrl.cpp b/include/treectrl.cpp index 2122bba85..3b005d327 100755 --- a/include/treectrl.cpp +++ b/include/treectrl.cpp @@ -73,18 +73,23 @@ void TField_window::update() const WINDOW pa = parent(); RCT rct; xvt_vobj_get_outer_rect(me, &rct); rct.left -= 2; rct.top -= 2; rct.right += 2; rct.bottom += 2; - xi_draw_3d_rect((XinWindow)pa, (XinRect *) &rct, TRUE, 2, // qui + xi_draw_3d_rect((XinWindow)pa, (XinRect *) &rct, TRUE, 2, MASK_LIGHT_COLOR, MASK_BACK_COLOR, MASK_DARK_COLOR); } xvt_dwin_clear(me, NORMAL_BACK_COLOR); set_font(); } +// Serve quando si chiama il costruttore senza owner +void TField_window::set_owner(TWindowed_field* o) +{ _owner = o; } + TField_window::TField_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner) : _owner(owner) { if (owner != NULL) { + CHECK(parent, "Null control parent"); create(x, y, dx, dy, "", WSF_HSCROLL | WSF_VSCROLL, W_PLAIN, parent); activate(owner->enabled()); if (owner->shown()) @@ -1371,3 +1376,181 @@ bool TOutlook_field::on_key(KEY key) } return TWindowed_field::on_key(key); } + +/////////////////////////////////////////////////////////// +// TSlider_window +/////////////////////////////////////////////////////////// + +class TSlider_window : public TField_window +{ +public: + void set(int pos); + int get() const; + void set_range(int mi, int ma); + TSlider_window(int x, int y, int dx, int dy, WINDOW parent, TSlider_field* owner); +}; + +void TSlider_window::set_range(int mi, int ma) +{ + if (mi != 0) + { + ma -= mi; + mi = 0; + } + if (ma < mi) + ma = 100; + xvt_sbar_set_range(win(), HVSLIDER, mi, ma); +} + +void TSlider_window::set(int pos) +{ xvt_sbar_set_pos(win(), HVSLIDER, pos); } + +int TSlider_window::get() const +{ return xvt_sbar_get_pos(win(), HVSLIDER); } + +TSlider_window::TSlider_window(int x, int y, int dx, int dy, WINDOW parent, TSlider_field* owner) + : TField_window(0, 0, 0, 0, NULL, NULL) +{ + set_owner(owner); + WIN_DEF wd; memset(&wd, 0, sizeof(wd)); + wd.rct = resize_rect(x, y, dx, dy, wd.wtype, parent); + wd.wtype = (wd.rct.right-wd.rct.left) > (wd.rct.bottom-wd.rct.top) ? WC_HSLIDER : WC_VSLIDER; + wd.v.ctl.ctrl_id = owner->dlg(); + + real mi, ma; owner->range(mi, ma); + const long limit = ma.integer() - mi.integer(); + set_win(xvt_ctl_create_def(&wd, parent, limit)); +} + +/////////////////////////////////////////////////////////// +// TSlider_field +/////////////////////////////////////////////////////////// + +void TSlider_field::set_window_data(const char* data) +{ + TSlider_window& sw = (TSlider_window&)win(); + const int sel = atoi(data); + sw.set(sel); +} + +const TString& TSlider_field::get_window_data() +{ + TSlider_window& sw = (TSlider_window&)win(); + TString& tmp = get_tmp_string(); + tmp << sw.get(); + return tmp; +} + +void TSlider_field::set(const char* data) +{ + if (!_range_min.is_zero()) + { + real n(data); + n -= _range_min; + data = n.string(); + } + set_window_data(data); + set_dirty(); +} + +const TString& TSlider_field::get() const +{ + TString& str = (TString&)((TSlider_field*)this)->get_window_data(); + if (!_range_min.is_zero()) + { + real n(str); + n += _range_min; + str = n.string(); + } + return str; +} + +const char* TSlider_field::get_buddy() const +{ + if (_buddy > 0) + { + const int pos = mask().id2pos(_buddy); + if (pos > 0) + { + real n = mask().fld(pos).get(); + if (n < _range_min) n = _range_min; + if (n > _range_max) n = _range_max; + return n.string(); + } + } + return EMPTY_STRING; +} + +void TSlider_field::set_buddy(const char* b) const +{ + if (_buddy > 0) + { + const int pos = mask().id2pos(_buddy); + if (pos > 0) + mask().fld(pos).set(b); + } +} + +bool TSlider_field::on_hit() +{ + if (!mask().is_running()) + { + set_range(_range_min, _range_max); // Imposto range dello slider + const char* b = get_buddy(); + if (b && *b) + set(b); + } + return TWindowed_field::on_hit(); +} + +word TSlider_field::class_id() const +{ return CLASS_SLIDER_FIELD; } + +bool TSlider_field::is_kind_of(word cid) const +{ return cid == CLASS_SLIDER_FIELD || TWindowed_field::is_kind_of(cid); } + +TField_window* TSlider_field::create_window(int x, int y, int dx, int dy, WINDOW parent) +{ return new TSlider_window(x, y, dx, dy, parent, this); } + +void TSlider_field::set_range(const real& mi, const real& ma) +{ + _range_min = mi; + _range_max = ma; + set_range(mi.integer(), ma.integer()); +} + +void TSlider_field::set_range(int mi, int ma) +{ + _range_min = mi; + _range_max = ma; + if (_win != NULL_WIN) + { + TSlider_window& sw = (TSlider_window&)win(); + sw.set_range(mi, ma); + } +} + +void TSlider_field::range(real& mi, real& ma) +{ mi = _range_min; ma = _range_max; } + +bool TSlider_field::parse_item(TScanner& scanner) +{ + if (scanner.key() == "DR") // DRIVENBY id + { + _buddy = scanner.integer(); + return true; + } + if (scanner.key() == "RA") // RANGE min max + { + const int mi = scanner.integer(); + const int ma = scanner.integer(); + set_range(mi, ma); + return true; + } + + return TWindowed_field::parse_item(scanner); +} + +TSlider_field::TSlider_field(TMask* m) + : TWindowed_field(m), _buddy(0), _range_min(ZERO), _range_max(CENTO) +{ } diff --git a/include/treectrl.h b/include/treectrl.h index 8b19486e6..b559b6497 100755 --- a/include/treectrl.h +++ b/include/treectrl.h @@ -91,4 +91,36 @@ public: virtual ~TOutlook_field() { } }; +class TSlider_field : public TWindowed_field +{ + short _buddy; + real _range_min, _range_max; + +protected: // TMask_field + virtual word class_id() const; + virtual bool is_kind_of(word cid) const; + + virtual const TString& get_window_data(); + virtual void set_window_data(const char* data); + +protected: // TWindowed_field + virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent); + virtual bool parse_item(TScanner& scanner); + + const char* get_buddy() const; + void set_buddy(const char* b) const; + +public: + virtual void set(const char* data); + virtual const TString& get() const; + virtual bool on_hit(); + + void set_range(const real& mi, const real& ma); + void set_range(int mi, int ma); + void range(real& mi, real& ma); + + TSlider_field(TMask* m); + virtual ~TSlider_field() { } +}; + #endif diff --git a/include/urldefid.h b/include/urldefid.h index ab130dab6..97cf17dde 100755 --- a/include/urldefid.h +++ b/include/urldefid.h @@ -124,6 +124,7 @@ #define TOOL_LASTREC 125 #define TOOL_FINDREC 126 #define TOOL_EMAIL 139 +#define TOOL_CONVERT 156 #define TOOL_INFO 162 #define TOOL_HELP 163 #define TOOL_SETPRINT 165 diff --git a/include/utility.cpp b/include/utility.cpp index b2b552dce..fae1713ea 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -585,15 +585,8 @@ const TString & get_hostname() long daytime() { - long t = 0L; - time_t lt; - if (time(<) != -1) - { - struct tm * timeloc = localtime(<); - if (timeloc != NULL) - t = timeloc->tm_sec + timeloc->tm_min * 100L + timeloc->tm_hour * 10000L; - } - return t; + const struct tm * timeloc = xvt_time_now(); + return timeloc->tm_sec + timeloc->tm_min * 100L + timeloc->tm_hour * 10000L; } bool is_power_station()