diff --git a/include/maskfld.cpp b/include/maskfld.cpp index e52da0c65..b1cb529af 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -55,7 +55,7 @@ TMask_field::TField_Flags::TField_Flags() enabled = enable_default = TRUE; shown = show_default = TRUE; uppercase = rightjust = FALSE; - zerofilled = FALSE; + zerofilled = button = FALSE; dirty = focusdirty = FALSE; roman = exchange = FALSE; firm = ghost = FALSE; @@ -81,6 +81,8 @@ char TMask_field::TField_Flags::update(const char* f) password = TRUE; break; case 'A': automagic = persistent = TRUE; break; + case 'B': + button = TRUE; break; case 'D': enable_default = enabled = FALSE; break; case 'F': @@ -101,8 +103,8 @@ char TMask_field::TField_Flags::update(const char* f) exchange = TRUE; break; case 'Z': zerofilled = TRUE; break; - default : - CHECKS(*s == 'B', "FLAG sconosciuto in ", f); + default : + CHECKS(FALSE, "FLAG sconosciuto in ", f); break; } return *s; @@ -686,6 +688,10 @@ void TOperable_field::set_focus() const mask().set_focus_field(dlg()); } +// Certified 100% +bool TOperable_field::is_kind_of(word cid) const +{ return cid == CLASS_OPERABLE_FIELD || TMask_field::is_kind_of(cid); } + void TOperable_field::enable(bool on) { TMask_field::enable(on); @@ -1220,23 +1226,20 @@ word TEditable_field::first_key() const if (_keys == NULL) return 0; const int last = last_key(); - for (long i = 1; i <= last; i++) - if ((*_keys)[i] == TRUE) + for (int i = 1; i <= last; i++) + if (in_key(i) == TRUE) break; return (word)i; } // Certified 70% -bool TEditable_field::has_a_common_key(const TEditable_field & e) const +bool TEditable_field::has_a_common_key(const TMask_field & f) const { - if (_keys != NULL && e._keys != NULL) - { - const int last = last_key(); - for (long i = 1; i <= last; i++) - if ((*_keys)[i] == TRUE && (*e._keys)[i] == TRUE) - return TRUE; - } + const int last = last_key(); + for (int i = 1; i <= last; i++) + if (in_key(i) && f.in_key(i)) + return TRUE; return FALSE; } @@ -2184,14 +2187,9 @@ KEY TBrowse::run() byte buttons = 0; if (_insert.not_empty()) { - buttons = 3; // Mette il bottone di gestione, a meno che ... -/* - if (_insert[0] == 'G') // Gestione Golem - { - buttons |= 2; - } - else -*/ + // Mette il bottone di gestione, a meno che ... + if (_cursor->items() == 0) buttons = 2; // Non mette il bottone collega se non ci sono elementi + else buttons = 3; if (_insert[0] != 'G') { const TString& maskname = field().mask().source_file(); @@ -2733,6 +2731,7 @@ bool TEdit_field::default_error_box() const bool TEdit_field::on_key(KEY key) { const int vf = validate_func(); + static bool search_in_progress = FALSE; switch(key) { @@ -2769,8 +2768,14 @@ bool TEdit_field::on_key(KEY key) } else { - if (check_enabled() && (!query || forced()) && vf != 21) - ok = browse()->check(); +// if (check_enabled() && (!query || forced()) && vf != 21) + if (check_enabled() && vf != 21) + { + if (!query || forced()) + ok = browse()->check(); + else + browse()->check(); + } } } if (ok) @@ -2820,14 +2825,16 @@ bool TEdit_field::on_key(KEY key) else ok = browse()->empty_check(); } } - if (!ok) return default_error_box(); } + else + ok = !required() || get().not_empty(); + if (!ok) return default_error_box(); + } break; case K_F9: if (check_enabled()) { - enable_check(FALSE); if (focusdirty()) get_window_data(); @@ -2836,7 +2843,6 @@ bool TEdit_field::on_key(KEY key) else beep(); if (k != K_F9) set_focus(); - enable_check(TRUE); if (k == K_ENTER) { @@ -2851,16 +2857,19 @@ bool TEdit_field::on_key(KEY key) { test_key_complete(); } - else - { +// else +// { send_key(K_TAB, 0); // Passa al campo successivo - } +// } } return TRUE; } else return FALSE; } + else + if (_browse == NULL && has_button()) + handler(K_F9); break; case K_CTRL+K_SPACE: set_dirty(TRUE); diff --git a/include/maskfld.h b/include/maskfld.h index 444c65b33..19cfd2452 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -94,7 +94,8 @@ protected: // @cmember | _flags | | Flag indicante lo stato del campo struct TField_Flags { - bool automagic : 1; + bool automagic : 1; + bool button : 1; bool dirty : 2; // Modified during run ? bool enabled : 1; // Is editable bool enable_default : 1; @@ -203,6 +204,9 @@ public: // @cmember Ritorna TRUE se il campo e' automagic bool automagic() const { return _flags.automagic; } + // @cmember Ritorna TRUE se ha un bottone di campo + bool has_button() const + { return _flags.button; } // @cmember Ritorna TRUE se si tratta di campo fantasma bool ghost() const { return _flags.ghost; } @@ -429,6 +433,7 @@ protected: // TMask_field virtual void highlight() const; public: + virtual bool is_kind_of(word cid) const; // @cmember Esegue processo in background virtual void on_idle() {} @@ -569,8 +574,8 @@ public: word last_key() const; // @cmember Ritorna l'ultima chiave di appartenenza del campo word first_key() const; - // @cmember Verifica che il campo abbia almeno una chiave in con il campo

- bool has_a_common_key(const TEditable_field & e) const; + // @cmember Verifica che il campo abbia almeno una chiave in con il campo

+ bool has_a_common_key(const TMask_field & f) const; // @cmember Ritorna il nome del campo corrsipondente sul file virtual const TFieldref* field() const