diff --git a/include/controls.cpp b/include/controls.cpp index 210e9b6e0..e343bf57a 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -1339,17 +1339,25 @@ void TButton_control::create(WINDOW win, short cid, TString txt(text); char mnemonic = '\0'; - int underscore = txt.find('~'); - if (underscore < 0) - underscore = txt.find('&'); - if (underscore >= 0) - mnemonic = txt[underscore+1]; - - txt.strip("&~"); + int underscore = -1; + if (wc == WC_PUSHBUTTON) + { + underscore = txt.find('~'); + if (underscore < 0) + underscore = txt.find('&'); + if (underscore >= 0) + mnemonic = txt[underscore+1]; + txt.strip("&~"); + } const char* t = parse_caption(txt, bold, color); if (width <= 0) width = strlen(t)+3; RCT rct; coord2rct(win, left, top, width, height, rct); + if (wc == WC_PUSHBUTTON && height == 1) // Troppo bassi! + { + rct.top--; + rct.bottom++; + } const unsigned long attrib = flags2attr(flags); XI_OBJ_DEF* def = xi_add_button_def(NULL, cid, (XinRect *) &rct, attrib, (char*)t, cid); diff --git a/include/form.cpp b/include/form.cpp index 4e5fd208c..6043dd059 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -17,7 +17,7 @@ #include #endif -#include "../ba/bafrm.h" +#include "/u/guy/p.due/ba/bafrm.h" // per lo sheet di edit campi HIDDEN const int idt_id = 101; diff --git a/include/journal.h b/include/journal.h new file mode 100755 index 000000000..10ef60507 --- /dev/null +++ b/include/journal.h @@ -0,0 +1,21 @@ +#ifndef __JOURNAL_H +#define __JOURNAL_H + +#pragma pack(4) + +struct TJournalHeader +{ + char _signature[4]; + long _header_length; + time_t _time; + long _firm; + long _logic_num; + char _operation[4]; + char _type[4]; + long _data_size; + char _name[32]; +}; + +#pragma pack() + +#endif diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 69da486f6..4897d198f 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -1053,6 +1053,8 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev) if (xiev->v.xi_obj->type == XIT_ROW) { _check_enabled = FALSE; + owner().mask().notify_focus_field(owner().dlg()); + if (_cell_dirty) off_cell_handler(); @@ -1090,13 +1092,10 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev) TMask_field& button = sm.fld(button_pos); if (button.active()) { - str2mask(_cur_rec); // Non commentare! + notify_change(); button.on_hit(); if (sm.dirty()) - { - notify_change(); mask2str(_cur_rec); - } } } owner().highlight(); @@ -1428,13 +1427,10 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev) TMask_field& button = sm.fld(button_pos); if (button.active()) { - str2mask(_cur_rec); + notify_change(); button.on_hit(); if (sm.dirty()) - { - notify_change(); mask2str(_cur_rec); - } } } _check_enabled = TRUE; diff --git a/include/recarray.cpp b/include/recarray.cpp index 64c9381b2..f479fd204 100755 --- a/include/recarray.cpp +++ b/include/recarray.cpp @@ -402,6 +402,9 @@ int TRecord_array::remove() const // TFile_cache /////////////////////////////////////////////////////////// +unsigned long TFile_cache::_hits = 0; +unsigned long TFile_cache::_miss = 0; + TFile_cache::TFile_cache(TLocalisamfile *f , int key) : _file(NULL), _key(key), _last_firm(-883), _test_changes(FALSE), _last_read(0), _limit(0) @@ -558,7 +561,10 @@ const TObject& TFile_cache::query(const char* code) } obj = rec2obj(curr); _cache.add(_code, obj); + _miss++; } + else + _hits++; return *obj; } @@ -581,6 +587,7 @@ long TFile_cache::fill() test_firm(); TLocalisamfile& f = file(); + TRectype& curr = f.curr(); const RecDes* recd = curr.rec_des(); // Descrizione del record della testata const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave diff --git a/include/recarray.h b/include/recarray.h index 9f9a79c3f..3d78b8516 100755 --- a/include/recarray.h +++ b/include/recarray.h @@ -152,6 +152,8 @@ class TFile_cache : public TObject long _last_read, _limit; bool _test_changes; + static unsigned long _hits, _miss; + protected: TAssoc_array _cache; diff --git a/include/relapp.cpp b/include/relapp.cpp index e50c2616c..38bc9691e 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -519,28 +519,26 @@ int TRelation_application::delete_mode() TToken_string items(brw->items()); items.insert(" |", 0); - TPointer_array keys; int tab1 = 0, tab2 = 0, y = 0; - for (int kf = 0; ; kf++) + // Nuovo modo basato sugli input + TToken_string inplist = brw->get_input_fields(); + if (inplist.not_empty()) { - TEditable_field* e = _mask->get_key_field(1, kf == 0); - if (e) - { - if (e->shown()) + FOR_EACH_TOKEN(inplist, tok) + { + if (*tok != '"' && strchr(tok, '@') == NULL) { - keys.add(e); - if (e->enabled()) + TMask_field& e = _mask->field(short(atoi(tok))); + if (e.active()) { - const int len = strlen(e->prompt()); + const int len = strlen(e.prompt()); if (len > tab1) tab1 = len; - const int size = e->size(); + const int size = e.size(); if (size > tab2) tab2 = size; y++; } } } - else - break; } tab1 += 5; tab2 += tab1+2; @@ -550,11 +548,15 @@ int TRelation_application::delete_mode() y = -1; // Posizione del campo precedente TString prompt; // Prompt del campo corrente - for(int k = 0; k < keys.items(); k++) + + FOR_EACH_TOKEN(inplist, tok) { - TEditable_field& e = (TEditable_field&)keys[k]; - if (e.enabled()) + if (*tok != '"' && strchr(tok, '@') == NULL) { + TMask_field& e = _mask->field(atoi(tok)); + if (!e.active()) + continue; + const short id = 1000+e.dlg(); prompt = "Da "; prompt << e.prompt(); sht.add_static(DLG_NULL, 0, prompt, 1, ++y); @@ -584,7 +586,7 @@ int TRelation_application::delete_mode() } } - sht.open(); + sht.open_modal(); KEY tasto; bool keep_running = TRUE; @@ -594,18 +596,40 @@ int TRelation_application::delete_mode() if (tasto == K_ENTER) { TRectype rec_from(cur.file().num()), rec_to(cur.file().num()); - for(int k = 0; k < keys.items(); k++) - { - TEditable_field& e = (TEditable_field&)keys[k]; - const TFieldref* ref = e.field(); - if (ref) - { - const TString& fr = e.enabled() ? sht.get(e.dlg()+1000) : e.get(); - ref->write(fr, rec_from); - const TString& to = e.enabled() ? sht.get(e.dlg()+2000) : e.get(); - if (to.not_empty()) ref->write(to, rec_to); + TToken_string fldlist = brw->get_input_field_names(); + TString80 str; + int fi = 0; + for (TString80 tok = inplist.get(fi); tok.not_empty(); tok = inplist.get(), fi++) + { + const TString16 fn = fldlist.get(fi); + if (*tok == '"') + { + str = tok; + str.ltrim(1); str.rtrim(1); + rec_from.put(fn, str); + rec_to.put(fn, str); } + else + { + const short id = short(atoi(tok)); + if (sht.id2pos(id+1000) >= 0) + { + str = sht.get(id+1000); + if (str.not_empty()) + rec_from.put(fn, str); + str = sht.get(id+2000); + if (str.not_empty()) + rec_to.put(fn, str); + } + else + { + str = _mask->get(id); + rec_from.put(fn, str); + rec_to.put(fn, str); + } + } } + cur.curr() = rec_from; cur.read(); while (cur.file().status() == NOERR && cur.curr() <= rec_to) @@ -619,23 +643,23 @@ int TRelation_application::delete_mode() keep_running = FALSE; if (tasto == K_DEL && sht.checked() == 0) { - error_box("Non e' stato selezionato nessun documento"); + error_box("Non e' stato selezionato nessun elemento"); sht.select(0); keep_running = TRUE; } } } - sht.close(); + sht.close_modal(); if (tasto == K_DEL) { long deleting = sht.checked(); TString msg; - msg = "Confermate l'eliminazione de"; + msg = "Confermate l'eliminazione d"; if (deleting == 1) - msg << "l documento selezionato?"; + msg << "ell'elemento selezionato?"; else - msg << "i " << deleting << " documenti selezionati?"; + msg << "i " << deleting << " elementi selezionati?"; bool can_delete = yesno_box(msg); if (can_delete && deleting > 100) @@ -679,9 +703,9 @@ int TRelation_application::delete_mode() if (skipped > 0) { if (skipped == 1) - warning_box("Un documento non e' stato cancellato in quanto protetto."); + warning_box("Un elemento non e' stato cancellato in quanto protetto."); else - warning_box("%ld documenti non sono stati cancellati in quanto protetti.", skipped); + warning_box("%ld elementi non sono stati cancellati in quanto protetti.", skipped); } } } diff --git a/include/strings.cpp b/include/strings.cpp index ffc418b81..736deac10 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -395,9 +395,14 @@ int TString::find( // Nel caso

sia maggiore della lunghezza della stringa manda // un messaggio di errore { - CHECKD(from <= len(), "Trying to find past end of string", from); - const char* p = strchr(_str + from, c); - return p ? int(p - _str) : -1; + int pos = -1; + if (from < len()) + { + const char* p = strchr(_str + from, c); + if (p) + pos = int(p - _str); + } + return pos; } int TString::rfind( @@ -429,9 +434,14 @@ HIDDEN char* strstr(const char* string1, const char* string2) // Certified 100% int TString::find(const char* s, int from) const { - CHECKD(from <= len(), "Trying to find past end of string", from); - const char* p = strstr(_str + from, s); - return p ? int(p - _str) : -1; + int pos = -1; + if (from < len()) + { + const char* p = strstr(_str + from, s); + if (p) + pos = int(p - _str); + } + return pos; } bool TString::match(const char* pat) const