diff --git a/include/bagn005.uml b/include/bagn005.uml index 0e6254354..436f1f42c 100755 --- a/include/bagn005.uml +++ b/include/bagn005.uml @@ -1,23 +1,23 @@ /* Maschera ricerca per viswin */ #include "bagn005.h" -PAGE "Cerca testo" -1 -1 55 11 +PAGE "Cerca testo" -1 -1 60 5 -STRING F_STRING 45 70 +STRING F_STRING 70 45 BEGIN - PROMPT 1 1 "Ricerca: " + PROMPT 1 1 "Ricerca " END -LIST F_DIRECT +LIST F_DIRECT 8 BEGIN - PROMPT 1 2 "Direzione " + PROMPT 1 2 "Direzione " ITEM "D|Avanti" ITEM "U|Indietro" END BOOLEAN F_CASE BEGIN - PROMPT 30 2 "Maiuscolo/Minuscolo" + PROMPT 36 2 "Maiuscolo/Minuscolo" END BUTTON DLG_OK 10 2 diff --git a/include/form.h b/include/form.h index 000159a70..e7d4ba10b 100755 --- a/include/form.h +++ b/include/form.h @@ -1,115 +1,115 @@ -#ifndef __FORM_H -#define __FORM_H - -#ifndef __PRINTER_H -#include -#endif - -#ifndef __SCANNER_H -#include -#endif - -#ifndef __MASK_H -class TMask; -#endif - -#ifndef __RELATION_H -class TRelation; -class TCursor; -#endif - -enum pagetype { odd_page, even_page, first_page, last_page }; - -class TForm; -class TForm_item; - -class TPrint_section : public TArray -{ - static TMask* _msk; - - word _height; // Altezza della sezione - - TForm* _form; // Form cui appartiene alla sezione - TArray _item; // Lista dei campi da stampare - - const TPrint_section& copy(const TPrint_section& ps); - -protected: - virtual void print_on(ostream& out) const; - TForm_item* parse_item(const TString& key); - TForm_item* parse_item(TScanner& scanner); - -public: - TPrintrow& row(int num); - TForm* form() const { return _form; } - - TForm_item& field(int n) const { return (TForm_item&)_item[n]; } - word fields() const { return _item.items(); } - word height() const { return _height; } - virtual bool ok() const { return height() > 0 || fields() > 0; } - - void reset(); - bool update(); - bool parse(TScanner& scanner); - - bool edit(const char* title); - - const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); } - TPrint_section(TForm* parent); - TPrint_section(const TPrint_section& ps) { copy(ps); } - virtual ~TPrint_section(); -}; - - -class TForm : public TObject -{ - friend class TForm_editor; - - TFilename _name; // Profile name - - TRelation* _relation; // Can be NULL - TCursor* _cursor; // Can be NULL - - TArray _head; // Headers - TArray _body; // Bodies - TArray _foot; // Footers - - bool _lastpage; // I am about to print the last page - - TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL - - static void header_handler(TPrinter& p); - static void footer_handler(TPrinter& p); - -protected: - // H = Header, B = Body, F = Footer, R = Relation - TPrint_section& section(char s = 'B', word page = 1); - word height(); // Height of first page - - void print_section(ostream& out, char s) const; - virtual void print_on(ostream& out) const; - bool edit_relation(); - - bool parse_use(TScanner&); - bool parse_join(TScanner&); - - word page(const TPrinter& p) const; - - virtual long records() const; - virtual word set_header(word p, bool u); - virtual word set_body(word p, bool u); - virtual word set_footer(word p, bool u); - -public: - bool print(long from = 0L, long to = -1L); - - const TFilename& name() const { return _name; } - - TRelation* relation() const { return _relation; } - TCursor* cursor() const { return _cursor; } - - TForm(const char* form); - virtual ~TForm(); -}; - -#endif +#ifndef __FORM_H +#define __FORM_H + +#ifndef __PRINTER_H +#include +#endif + +#ifndef __SCANNER_H +#include +#endif + +#ifndef __MASK_H +class TMask; +#endif + +#ifndef __RELATION_H +class TRelation; +class TCursor; +#endif + +enum pagetype { odd_page, even_page, first_page, last_page }; + +class TForm; +class TForm_item; + +class TPrint_section : public TArray +{ + static TMask* _msk; + + word _height; // Altezza della sezione + + TForm* _form; // Form cui appartiene alla sezione + TArray _item; // Lista dei campi da stampare + + const TPrint_section& copy(const TPrint_section& ps); + +protected: + virtual void print_on(ostream& out) const; + TForm_item* parse_item(const TString& key); + TForm_item* parse_item(TScanner& scanner); + +public: + TPrintrow& row(int num); + TForm* form() const { return _form; } + + TForm_item& field(int n) const { return (TForm_item&)_item[n]; } + word fields() const { return _item.items(); } + word height() const { return _height; } + virtual bool ok() const { return height() > 0 || fields() > 0; } + + void reset(); + bool update(); + bool parse(TScanner& scanner); + + bool edit(const char* title); + + const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); } + TPrint_section(TForm* parent); + TPrint_section(const TPrint_section& ps) { copy(ps); } + virtual ~TPrint_section(); +}; + + +class TForm : public TObject +{ + friend class TForm_editor; + + TFilename _name; // Profile name + + TRelation* _relation; // Can be NULL + TCursor* _cursor; // Can be NULL + + TArray _head; // Headers + TArray _body; // Bodies + TArray _foot; // Footers + + bool _lastpage; // I am about to print the last page + + TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL + + static void header_handler(TPrinter& p); + static void footer_handler(TPrinter& p); + +protected: + // H = Header, B = Body, F = Footer, R = Relation + TPrint_section& section(char s = 'B', word page = 1); + word height(); // Height of first page + + void print_section(ostream& out, char s) const; + virtual void print_on(ostream& out) const; + bool edit_relation(); + + bool parse_use(TScanner&); + bool parse_join(TScanner&); + + word page(const TPrinter& p) const; + + virtual long records() const; + virtual word set_header(word p, bool u); + virtual word set_body(word p, bool u); + virtual word set_footer(word p, bool u); + +public: + bool print(long from = 0L, long to = -1L); + + const TFilename& name() const { return _name; } + + TRelation* relation() const { return _relation; } + TCursor* cursor() const { return _cursor; } + + TForm(const char* form); + virtual ~TForm(); +}; + +#endif diff --git a/include/maskfld.h b/include/maskfld.h index e88b4f098..1eae102c4 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -1,567 +1,567 @@ -/* $Id: maskfld.h,v 1.18 1994-12-29 14:51:27 villa Exp $ */ -#ifndef __MASKFLD_H -#define __MASKFLD_H - -#ifndef __REAL_H -#include -#endif - -#ifndef __SCANNER_H -#include -#endif - -class TMask_field; - -class TRelation; // __RELATION_H -class TCursor; -class TFieldref; -class TArray_sheet; // __SHEET_H - -// @T -typedef bool (*CONTROL_HANDLER)(TMask_field& field, KEY key); -// @END - -enum CheckType { CHECK_NONE, CHECK_NORMAL, CHECK_REQUIRED }; -enum CheckTime { RUNNING_CHECK, STARTING_CHECK, FINAL_CHECK }; - -// @C -// Classe TMask_field : public TObject -// @END - -class TMask_field : public TObject -{ - // @DPRIV - friend class TMask; - - TMask* _mask; // The mask the control belongs to - - TString _help; // Help message - TFieldref* _field; // Corresponding field on the file - TBit_array _keys; // The keys the field belongs to - TBit_array _groups; // The groups the field belongs to - -protected: - // @DPROT - static int _x, _y; // Coordinate of the control - static int _width; // Size of the control - static TFixed_string _prompt;// Prompt of the field - CONTROL_HANDLER _handler; - - int _size; // Max length of the string - - WINDOW _win; // Window of the control (not its parent!) - WINDOW _promptwin; // Prompt of the control - short _dlg; // Identifier of the control - - int _validate_func; // Number of validation function - TArray _validate_parms; // Parameters for validation function - TArray _message; // Messages to send on modify - - struct TField_Flags - { - bool automagic : 1; - bool dirty : 2; // Modified during run ? - bool enabled : 1; // Is editable - bool enable_default : 1; - bool firm : 1; // Is the current firm ? - bool focusdirty : 1; // Modified during focus ? - bool ghost : 1; - bool password : 1; - bool persistent : 1; - bool rightjust : 1; - bool roman : 1; // Is a Roman number ? - bool shown : 1; // Is visible - bool show_default : 1; - bool trim : 1; // Trim the string - bool uppercase : 1; - bool exchange : 1; // Value exchange - bool zerofilled : 1; - - TField_Flags(); - char update(const char*); - } _flags; - - void construct(TScanner& scanner, WINDOW parent); - void construct(short id, const char* prompt, int x, int y, int len, - WINDOW parent, const char* flags = "", int width = 0); - - virtual WINDOW win() const { return _win; } - - WINDOW wincreate(WIN_TYPE ct, short dx, short dy, - const char* title, WINDOW parent, long flags); - int create_prompt(WINDOW parent, int width = 0, int heigth = 1); - - long default_flags() const; - - virtual void parse_head(TScanner& scanner); - virtual bool parse_item(TScanner& scanner); - - virtual void create(WINDOW parent); - virtual void destroy(); - virtual void highlight() const; - - virtual const char* get_window_data() const; - virtual void set_window_data(const char* data); - virtual void set_field_data(const char* data); - virtual const char* get_field_data() const; - virtual void exchange(bool show_value, const real& n) {} - - bool do_message(int n); - -public: - // @FPUB - short atodlg(const char* s) const; - - WINDOW parent() const; - short dlg() const { return _dlg; } - - virtual bool ok() const; - - bool dirty() const { return _flags.dirty; } - bool focusdirty() const { return _flags.focusdirty; } - void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; } - void set_dirty(bool d = TRUE); - - virtual const char* class_name() const; - virtual word class_id() const; - - int size() const { return _size; } - - bool roman() const { return _flags.roman; } - bool automagic() const { return _flags.automagic; } - bool ghost() const { return _flags.ghost; } - bool exchangeable() const { return _flags.exchange; } - - virtual bool has_check() const { return FALSE;} - virtual bool has_query() const { return FALSE;} - virtual bool has_message() const { return _message.items() > 0; } - - virtual CheckType check_type() const { return CHECK_NONE; } - bool required() const { return check_type() == CHECK_REQUIRED; } - virtual bool check(CheckTime = RUNNING_CHECK) { return TRUE;} - - virtual void reset(); - - virtual void enable(bool on = TRUE); - void disable() { enable(FALSE); } - bool enabled() const { return _flags.enabled; } - void enable_default(); - bool enabled_default() const { return _flags.enable_default; } - - virtual void show(bool on = TRUE); - void hide() { show(FALSE); } - bool shown() const { return _flags.shown; } - void show_default(); - - bool active() const; // Is visible and enabled? - - void set_handler(CONTROL_HANDLER handler) { _handler = handler; } - - bool is_edit() const; - bool to_check(KEY k, bool checkrun = FALSE) const; - - virtual bool on_hit(); - virtual bool on_key(KEY key); - - void set(const char* s); - TString& get() const; - - virtual const char* picture_data(const char* data, bool video); - virtual const char * warning() { return "";} - - bool autoload(const TRelation* r = NULL); - bool autosave(TRelation* r = NULL) const; - - void undo(); - - const char* prompt() const; - void set_prompt(const char* p); - - bool in_key(byte key) const { return _keys[key]; } - void set_key(byte key) { _keys.set(long(key)); _keys.set(0L);} - word last_key() const; - - bool in_group(byte group) const { return _groups[group]; } - void set_group(byte group) { _groups.set(long(group)); _groups.set(0L);} - - const TFieldref* field() const { return _field; } - - void set_focus() const; - void send_key(KEY k, short to); - - // set focus, message-box, set focus - bool message_box(const char* fmt, ...) const; - bool warning_box(const char* fmt, ...) const; - bool error_box(const char* fmt, ...) const; - bool yesno_box(const char* fmt, ...) const; - KEY yesnocancel_box(const char* fmt, ...) const; - - TMask& mask() const { return *_mask; } - TMask_field(TMask* mask); - virtual ~TMask_field(); -}; - - -// @C -// Classe TEdit_field : public TMask_field -// -// @END - -class TEdit_field : public TMask_field -{ - friend class TBrowse; - friend class TList_sheet; - friend class TBrowse_sheet; - -protected: - // @DPROT - TString80 _str; - TString16 _picture; - TString _warning; - CheckType _check; // Accettabilita' di valori nulli - bool _forced; - bool _check_enabled; // Abilitato - - TBrowse* _browse; - TList_sheet* _sheet; - WINDOW _buttonwin; - - const TBrowse* get_browse(TScanner& scanner) const; - - virtual word class_id() const; - virtual void parse_head(TScanner& scanner); - virtual bool parse_item(TScanner& scanner); - - virtual void create(WINDOW parent); - virtual void destroy(); - - bool validate(KEY k); - - virtual void set_window_data(const char* data); - virtual void set_field_data(const char* data); - virtual const char* get_field_data() const; - bool default_error_box() const; - -public: - // @FPUB - virtual bool on_hit(); - virtual bool on_key(KEY key); - virtual bool has_check() const; - virtual bool has_query() const { return _browse || _sheet;} - virtual const char* picture_data(const char* data, bool video); - virtual const char * warning() { return _warning;} - virtual void show(bool on = TRUE); - virtual void enable(bool on = TRUE); - virtual CheckType check_type() const { return _check; } - void check_type(CheckType c) { _check = c; } - - bool forced() const { return _forced;} - virtual bool check(CheckTime = RUNNING_CHECK); - TBrowse* browse() const { return _browse;} - TList_sheet* sheet() const { return _sheet;} - void enable_check(bool on = TRUE) ; - bool check_enabled() const { return _check_enabled;} - - const char* format(const char* data); - const char* picture() const { return _picture; } - - TEdit_field(TMask* mask); - virtual ~TEdit_field(); -}; - - -/////////////////////////////////////////////////////////// -// TBrowse -/////////////////////////////////////////////////////////// - -class TBrowse -{ - TEdit_field* _fld; // The field owning the sheet - TRelation* _relation; // Main relation - TCursor* _cursor; // Cursor on the relation - TString _insert; - TString _filter; - long _rec; - bool _secondary; - bool _checked; - - TToken_string _head, _items; - TToken_string _inp_id, _inp_fn; - TToken_string _out_id, _out_fn; - -protected: - void do_output(CheckTime = RUNNING_CHECK); - void do_clear(); - bool do_insert(); - - TMask_field& field(short n) const; - TToken_string& create_siblings(TToken_string& siblings); - -public: - int inputs(); - int do_input(bool filter = FALSE); // Serve ai TCursor_sheet - - TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = ""); - TBrowse(TEdit_field* f, TCursor* c); - ~TBrowse(); - - void parse_join(TScanner& scanner); - void parse_input(TScanner& scanner); - void parse_display(TScanner& scanner); - void parse_output(TScanner& scanner); - void parse_insert(TScanner& scanner); - bool parse_copy(const TString& what, const TBrowse& b); - - void set_insert(const char* s) { _insert = s;} - const TString& get_insert() const { return _insert;} - const TString& get_filter() const { return _filter;} - - TEdit_field& field() const { return *_fld; } - - bool check(CheckTime = RUNNING_CHECK); - bool empty_check(); - const TToken_string& head() const { return _head;} - const TToken_string& items() const { return _items;} - TCursor* cursor() const { return _cursor;} - bool checked() const { return _checked;} - bool secondary() const { return _secondary;} - - KEY run(); -}; - -/////////////////////////////////////////////////////////// -// TList_sheet -/////////////////////////////////////////////////////////// - -class TList_sheet -{ - TEdit_field* _fld; // The field owning the sheet - TArray_sheet* _sheet; // sheet with data; - int _row; - - TToken_string _inp_id; - TToken_string _out_id; - -protected: - int do_input(); - void do_output(CheckTime = RUNNING_CHECK); - bool do_insert(); - TMask_field& field(short id) const; - -public: - TList_sheet(TEdit_field* f, const char* caption, const char* head); - ~TList_sheet(); - - void parse_input(TScanner& scanner); - void read_item(TScanner& scanner); - void parse_output(TScanner& scanner); - TArray_sheet* sheet() { return _sheet; } - TEdit_field& field() const { return *_fld; } - - bool check(CheckTime = RUNNING_CHECK); - - KEY run(); -}; - -// @C -// class TReal_field : public TEdit_field -// @END - -class TReal_field : public TEdit_field -{ - int _decimals; - -protected: - // @FPROT - virtual word class_id() const; - - virtual const char* get_window_data() const; - virtual void set_window_data(const char* data); - virtual void exchange(bool show_value, const real& n); - - virtual void create(WINDOW parent); - virtual void parse_head(TScanner& scanner); - virtual bool on_key(KEY key); - -public: - // @FPUB - void set_decimals(int d); // Set precision & picture - int decimals() const { return _decimals; } // Get precision - - TReal_field(TMask* mask); -}; - - -// @C -// class TDate_field : public TEdit_field -//@END - -class TDate_field : public TEdit_field -{ -protected: - // @FPROT - virtual word class_id() const; - virtual void create(WINDOW parent); - virtual bool on_key(KEY key); - virtual const char* get_window_data() const; - virtual void set_window_data(const char* data); - -public: - // @FPUB - void parse_head(TScanner& scanner); - TDate_field(TMask* mask); -}; - - -// @C -// class TBoolean_field : public TMask_field -// @END - -class TBoolean_field : public TMask_field -{ -protected: - // @DPROT - bool _on; - - virtual word class_id() const; - - virtual void create(WINDOW parent); - virtual const char* get_window_data() const; - virtual void set_window_data(const char* data); - virtual void set_field_data(const char* data = NULL); - virtual const char* get_field_data() const; - virtual bool parse_item(TScanner& scanner); - virtual void enable(bool on); - virtual bool on_hit(); - virtual bool on_key(KEY key); - -public: - // @FPUB - TBoolean_field(TMask* mask); -}; - - -// @C -// class TList_field : public TMask_field -// @END - -class TList_field : public TMask_field -{ - // @FPRIV - void add_list(); - -protected: - // @FPROT - TToken_string _values; - TToken_string _codes; - TString80 _str; - - virtual word class_id() const; - - virtual void set_window_data(const char* data); - virtual const char* get_window_data() const; - virtual void set_field_data(const char* data = NULL); - virtual const char* get_field_data() const; - - virtual void create(WINDOW parent); - - virtual void current(int n); - virtual int current() const; - - int str2curr(const char* data); - virtual bool on_hit(); - virtual bool on_key(KEY key); - virtual void read_item(TScanner& scanner); - - virtual void parse_head(TScanner& scanner); - virtual bool parse_item(TScanner& scanner); - -public: - // @FPUB - TList_field(TMask* mask); - virtual void replace_items(const char* codes, const char* values); - virtual void add_item(const char* code_value); - virtual void delete_item(const char* code); - int items() const; -}; - - -// @C -// class TRadio_field : public TList_field -// @END - -class TRadio_field : public TList_field -{ - enum { MAX_RADIO = 8 }; - - // @FPRIV - int _nitems; - int _active_item; - WINDOW _radio_ctl_win[MAX_RADIO]; - -protected: - // @FPROT - virtual word class_id() const; - virtual void create(WINDOW parent); - virtual void destroy(); - virtual void enable(bool on); - virtual void show(bool on); - - virtual void current(int n); - virtual int current() const; - WINDOW win() const { return _radio_ctl_win[_active_item]; } - -public: - // @FPUB - TRadio_field(TMask* mask); - - void check_radiobutton(WINDOW checked); - bool move_focus(int d); -}; - - - -// @C -// class TButton_field : public TMask_field -// @END - -class TButton_field : public TMask_field -{ - KEY _virtual_key, _exit_key; - -protected: - // @FPROT - virtual word class_id() const; - virtual void create(WINDOW parent); - - void parse_head(TScanner& scanner); - bool parse_item(TScanner& scanner); - virtual void enable(bool); - virtual void show(bool); - virtual bool on_key(KEY key); - -public: - // @FPUB - TButton_field(TMask* mask); - KEY virtual_key() const { return _virtual_key; } - KEY exit_key() const { return _exit_key; } -}; - - -// @C -// class TGroup_field : public TMask_field -// @END - -class TGroup_field : public TMask_field -{ -protected: - // @DPROT - virtual void parse_head(TScanner& scanner); - virtual void create(WINDOW parent); - -public: - // @FPUB - TGroup_field(TMask* mask); -}; - -#endif // __MASKFLD_H +/* $Id: maskfld.h,v 1.19 1994-12-30 10:11:11 villa Exp $ */ +#ifndef __MASKFLD_H +#define __MASKFLD_H + +#ifndef __REAL_H +#include +#endif + +#ifndef __SCANNER_H +#include +#endif + +class TMask_field; + +class TRelation; // __RELATION_H +class TCursor; +class TFieldref; +class TArray_sheet; // __SHEET_H + +// @T +typedef bool (*CONTROL_HANDLER)(TMask_field& field, KEY key); +// @END + +enum CheckType { CHECK_NONE, CHECK_NORMAL, CHECK_REQUIRED }; +enum CheckTime { RUNNING_CHECK, STARTING_CHECK, FINAL_CHECK }; + +// @C +// Classe TMask_field : public TObject +// @END + +class TMask_field : public TObject +{ + // @DPRIV + friend class TMask; + + TMask* _mask; // The mask the control belongs to + + TString _help; // Help message + TFieldref* _field; // Corresponding field on the file + TBit_array _keys; // The keys the field belongs to + TBit_array _groups; // The groups the field belongs to + +protected: + // @DPROT + static int _x, _y; // Coordinate of the control + static int _width; // Size of the control + static TFixed_string _prompt;// Prompt of the field + CONTROL_HANDLER _handler; + + int _size; // Max length of the string + + WINDOW _win; // Window of the control (not its parent!) + WINDOW _promptwin; // Prompt of the control + short _dlg; // Identifier of the control + + int _validate_func; // Number of validation function + TArray _validate_parms; // Parameters for validation function + TArray _message; // Messages to send on modify + + struct TField_Flags + { + bool automagic : 1; + bool dirty : 2; // Modified during run ? + bool enabled : 1; // Is editable + bool enable_default : 1; + bool firm : 1; // Is the current firm ? + bool focusdirty : 1; // Modified during focus ? + bool ghost : 1; + bool password : 1; + bool persistent : 1; + bool rightjust : 1; + bool roman : 1; // Is a Roman number ? + bool shown : 1; // Is visible + bool show_default : 1; + bool trim : 1; // Trim the string + bool uppercase : 1; + bool exchange : 1; // Value exchange + bool zerofilled : 1; + + TField_Flags(); + char update(const char*); + } _flags; + + void construct(TScanner& scanner, WINDOW parent); + void construct(short id, const char* prompt, int x, int y, int len, + WINDOW parent, const char* flags = "", int width = 0); + + virtual WINDOW win() const { return _win; } + + WINDOW wincreate(WIN_TYPE ct, short dx, short dy, + const char* title, WINDOW parent, long flags); + int create_prompt(WINDOW parent, int width = 0, int heigth = 1); + + long default_flags() const; + + virtual void parse_head(TScanner& scanner); + virtual bool parse_item(TScanner& scanner); + + virtual void create(WINDOW parent); + virtual void destroy(); + virtual void highlight() const; + + virtual const char* get_window_data() const; + virtual void set_window_data(const char* data); + virtual void set_field_data(const char* data); + virtual const char* get_field_data() const; + virtual void exchange(bool show_value, const real& n) {} + + bool do_message(int n); + +public: + // @FPUB + short atodlg(const char* s) const; + + WINDOW parent() const; + short dlg() const { return _dlg; } + + virtual bool ok() const; + + bool dirty() const { return _flags.dirty; } + bool focusdirty() const { return _flags.focusdirty; } + void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; } + void set_dirty(bool d = TRUE); + + virtual const char* class_name() const; + virtual word class_id() const; + + int size() const { return _size; } + + bool roman() const { return _flags.roman; } + bool automagic() const { return _flags.automagic; } + bool ghost() const { return _flags.ghost; } + bool exchangeable() const { return _flags.exchange; } + + virtual bool has_check() const { return FALSE;} + virtual bool has_query() const { return FALSE;} + virtual bool has_message() const { return _message.items() > 0; } + + virtual CheckType check_type() const { return CHECK_NONE; } + bool required() const { return check_type() == CHECK_REQUIRED; } + virtual bool check(CheckTime = RUNNING_CHECK) { return TRUE;} + + virtual void reset(); + + virtual void enable(bool on = TRUE); + void disable() { enable(FALSE); } + bool enabled() const { return _flags.enabled; } + void enable_default(); + bool enabled_default() const { return _flags.enable_default; } + + virtual void show(bool on = TRUE); + void hide() { show(FALSE); } + bool shown() const { return _flags.shown; } + void show_default(); + + bool active() const; // Is visible and enabled? + + void set_handler(CONTROL_HANDLER handler) { _handler = handler; } + + bool is_edit() const; + bool to_check(KEY k, bool checkrun = FALSE) const; + + virtual bool on_hit(); + virtual bool on_key(KEY key); + + void set(const char* s); + TString& get() const; + + virtual const char* picture_data(const char* data, bool video); + virtual const char * warning() { return "";} + + bool autoload(const TRelation* r = NULL); + bool autosave(TRelation* r = NULL) const; + + void undo(); + + const char* prompt() const; + void set_prompt(const char* p); + + bool in_key(byte key) const { return _keys[key]; } + void set_key(byte key) { _keys.set(long(key)); _keys.set(0L);} + word last_key() const; + + bool in_group(byte group) const { return _groups[group]; } + void set_group(byte group) { _groups.set(long(group)); _groups.set(0L);} + + const TFieldref* field() const { return _field; } + + void set_focus() const; + void send_key(KEY k, short to); + + // set focus, message-box, set focus + bool message_box(const char* fmt, ...) const; + bool warning_box(const char* fmt, ...) const; + bool error_box(const char* fmt, ...) const; + bool yesno_box(const char* fmt, ...) const; + KEY yesnocancel_box(const char* fmt, ...) const; + + TMask& mask() const { return *_mask; } + TMask_field(TMask* mask); + virtual ~TMask_field(); +}; + + +// @C +// Classe TEdit_field : public TMask_field +// +// @END + +class TEdit_field : public TMask_field +{ + friend class TBrowse; + friend class TList_sheet; + friend class TBrowse_sheet; + +protected: + // @DPROT + TString80 _str; + TString16 _picture; + TString _warning; + CheckType _check; // Accettabilita' di valori nulli + bool _forced; + bool _check_enabled; // Abilitato + + TBrowse* _browse; + TList_sheet* _sheet; + WINDOW _buttonwin; + + const TBrowse* get_browse(TScanner& scanner) const; + + virtual word class_id() const; + virtual void parse_head(TScanner& scanner); + virtual bool parse_item(TScanner& scanner); + + virtual void create(WINDOW parent); + virtual void destroy(); + + bool validate(KEY k); + + virtual void set_window_data(const char* data); + virtual void set_field_data(const char* data); + virtual const char* get_field_data() const; + bool default_error_box() const; + +public: + // @FPUB + virtual bool on_hit(); + virtual bool on_key(KEY key); + virtual bool has_check() const; + virtual bool has_query() const { return _browse || _sheet;} + virtual const char* picture_data(const char* data, bool video); + virtual const char * warning() { return _warning;} + virtual void show(bool on = TRUE); + virtual void enable(bool on = TRUE); + virtual CheckType check_type() const { return _check; } + void check_type(CheckType c) { _check = c; } + + bool forced() const { return _forced;} + virtual bool check(CheckTime = RUNNING_CHECK); + TBrowse* browse() const { return _browse;} + TList_sheet* sheet() const { return _sheet;} + void enable_check(bool on = TRUE) ; + bool check_enabled() const { return _check_enabled;} + + const char* format(const char* data); + const char* picture() const { return _picture; } + + TEdit_field(TMask* mask); + virtual ~TEdit_field(); +}; + + +/////////////////////////////////////////////////////////// +// TBrowse +/////////////////////////////////////////////////////////// + +class TBrowse +{ + TEdit_field* _fld; // The field owning the sheet + TRelation* _relation; // Main relation + TCursor* _cursor; // Cursor on the relation + TString _insert; + TString _filter; + long _rec; + bool _secondary; + bool _checked; + + TToken_string _head, _items; + TToken_string _inp_id, _inp_fn; + TToken_string _out_id, _out_fn; + +protected: + void do_output(CheckTime = RUNNING_CHECK); + void do_clear(); + bool do_insert(); + + TMask_field& field(short n) const; + TToken_string& create_siblings(TToken_string& siblings); + +public: + int inputs(); + int do_input(bool filter = FALSE); // Serve ai TCursor_sheet + + TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = ""); + TBrowse(TEdit_field* f, TCursor* c); + ~TBrowse(); + + void parse_join(TScanner& scanner); + void parse_input(TScanner& scanner); + void parse_display(TScanner& scanner); + void parse_output(TScanner& scanner); + void parse_insert(TScanner& scanner); + bool parse_copy(const TString& what, const TBrowse& b); + + void set_insert(const char* s) { _insert = s;} + const TString& get_insert() const { return _insert;} + const TString& get_filter() const { return _filter;} + + TEdit_field& field() const { return *_fld; } + + bool check(CheckTime = RUNNING_CHECK); + bool empty_check(); + const TToken_string& head() const { return _head;} + const TToken_string& items() const { return _items;} + TCursor* cursor() const { return _cursor;} + bool checked() const { return _checked;} + bool secondary() const { return _secondary;} + + KEY run(); +}; + +/////////////////////////////////////////////////////////// +// TList_sheet +/////////////////////////////////////////////////////////// + +class TList_sheet +{ + TEdit_field* _fld; // The field owning the sheet + TArray_sheet* _sheet; // sheet with data; + int _row; + + TToken_string _inp_id; + TToken_string _out_id; + +protected: + int do_input(); + void do_output(CheckTime = RUNNING_CHECK); + bool do_insert(); + TMask_field& field(short id) const; + +public: + TList_sheet(TEdit_field* f, const char* caption, const char* head); + ~TList_sheet(); + + void parse_input(TScanner& scanner); + void read_item(TScanner& scanner); + void parse_output(TScanner& scanner); + TArray_sheet* sheet() { return _sheet; } + TEdit_field& field() const { return *_fld; } + + bool check(CheckTime = RUNNING_CHECK); + + KEY run(); +}; + +// @C +// class TReal_field : public TEdit_field +// @END + +class TReal_field : public TEdit_field +{ + int _decimals; + +protected: + // @FPROT + virtual word class_id() const; + + virtual const char* get_window_data() const; + virtual void set_window_data(const char* data); + virtual void exchange(bool show_value, const real& n); + + virtual void create(WINDOW parent); + virtual void parse_head(TScanner& scanner); + virtual bool on_key(KEY key); + +public: + // @FPUB + void set_decimals(int d); // Set precision & picture + int decimals() const { return _decimals; } // Get precision + + TReal_field(TMask* mask); +}; + + +// @C +// class TDate_field : public TEdit_field +//@END + +class TDate_field : public TEdit_field +{ +protected: + // @FPROT + virtual word class_id() const; + virtual void create(WINDOW parent); + virtual bool on_key(KEY key); + virtual const char* get_window_data() const; + virtual void set_window_data(const char* data); + +public: + // @FPUB + void parse_head(TScanner& scanner); + TDate_field(TMask* mask); +}; + + +// @C +// class TBoolean_field : public TMask_field +// @END + +class TBoolean_field : public TMask_field +{ +protected: + // @DPROT + bool _on; + + virtual word class_id() const; + + virtual void create(WINDOW parent); + virtual const char* get_window_data() const; + virtual void set_window_data(const char* data); + virtual void set_field_data(const char* data = NULL); + virtual const char* get_field_data() const; + virtual bool parse_item(TScanner& scanner); + virtual void enable(bool on); + virtual bool on_hit(); + virtual bool on_key(KEY key); + +public: + // @FPUB + TBoolean_field(TMask* mask); +}; + + +// @C +// class TList_field : public TMask_field +// @END + +class TList_field : public TMask_field +{ + // @FPRIV + void add_list(); + +protected: + // @FPROT + TToken_string _values; + TToken_string _codes; + TString80 _str; + + virtual word class_id() const; + + virtual void set_window_data(const char* data); + virtual const char* get_window_data() const; + virtual void set_field_data(const char* data = NULL); + virtual const char* get_field_data() const; + + virtual void create(WINDOW parent); + + virtual void current(int n); + virtual int current() const; + + int str2curr(const char* data); + virtual bool on_hit(); + virtual bool on_key(KEY key); + virtual void read_item(TScanner& scanner); + + virtual void parse_head(TScanner& scanner); + virtual bool parse_item(TScanner& scanner); + +public: + // @FPUB + TList_field(TMask* mask); + virtual void replace_items(const char* codes, const char* values); + virtual void add_item(const char* code_value); + virtual void delete_item(const char* code); + int items() const; +}; + + +// @C +// class TRadio_field : public TList_field +// @END + +class TRadio_field : public TList_field +{ + enum { MAX_RADIO = 8 }; + + // @FPRIV + int _nitems; + int _active_item; + WINDOW _radio_ctl_win[MAX_RADIO]; + +protected: + // @FPROT + virtual word class_id() const; + virtual void create(WINDOW parent); + virtual void destroy(); + virtual void enable(bool on); + virtual void show(bool on); + + virtual void current(int n); + virtual int current() const; + WINDOW win() const { return _radio_ctl_win[_active_item]; } + +public: + // @FPUB + TRadio_field(TMask* mask); + + void check_radiobutton(WINDOW checked); + bool move_focus(int d); +}; + + + +// @C +// class TButton_field : public TMask_field +// @END + +class TButton_field : public TMask_field +{ + KEY _virtual_key, _exit_key; + +protected: + // @FPROT + virtual word class_id() const; + virtual void create(WINDOW parent); + + void parse_head(TScanner& scanner); + bool parse_item(TScanner& scanner); + virtual void enable(bool); + virtual void show(bool); + virtual bool on_key(KEY key); + +public: + // @FPUB + TButton_field(TMask* mask); + KEY virtual_key() const { return _virtual_key; } + KEY exit_key() const { return _exit_key; } +}; + + +// @C +// class TGroup_field : public TMask_field +// @END + +class TGroup_field : public TMask_field +{ +protected: + // @DPROT + virtual void parse_head(TScanner& scanner); + virtual void create(WINDOW parent); + +public: + // @FPUB + TGroup_field(TMask* mask); +}; + +#endif // __MASKFLD_H diff --git a/include/viswin.cpp b/include/viswin.cpp index befd5b6b6..b9298cadd 100755 --- a/include/viswin.cpp +++ b/include/viswin.cpp @@ -1479,6 +1479,12 @@ bool TViswin::on_key (KEY key) switch (key) { + case K_F7: + find(); + break; + case K_F8: + find_next(); + break; case CTRL_E: if (_isedit) { @@ -1882,7 +1888,7 @@ void TViswin::goto_top() goto_pos(0l,0l);; } -void TViswin::goto_pos(long r, long c) +void TViswin::goto_pos(long r, long c, bool moveorigin) { if (r >= _txt.lines() || c >= 256) return; @@ -1891,7 +1897,9 @@ void TViswin::goto_pos(long r, long c) if (_isselection) erase_selection(); _point.x = c; _point.y = r; - update_thumb (c,r); + if (!moveorigin) + c = (c > (origin().x + _textcolumns)) ? c - origin().x : 0l; + update_thumb(c,r); check_link(&_point); if (_isselection) display_selection(); display_point(); @@ -1943,7 +1951,7 @@ void TViswin::find() } else { - goto_pos(l,(long)x); + goto_pos(l, (long)x, FALSE); _last_found.x = (long)x; _last_found.y = l; } @@ -1958,11 +1966,11 @@ void TViswin::find_next() beep(); else { - long l = search(_txt_to_find, x, _point.y, _down_dir); + long l = search(_txt_to_find, x, _point.y+(_down_dir ? 1l : -1l), _down_dir); if (l == -1) beep(); else - goto_pos(l,x); + goto_pos(l,x,FALSE); } } @@ -2136,13 +2144,18 @@ void TBrowsefile_field::parse_head(TScanner& scanner) // Certified 100% void TBrowsefile_field::create(WINDOW parent) -{ +{ + CURSOR oldcur = get_cursor(TASK_WIN); + set_cursor(TASK_WIN,CURSOR_WAIT); + const TMask& m = mask(); _viswin = new TViswin(_prompt, _prompt, FALSE, FALSE, FALSE, _x, _y, _size, _width, _flags.rightjust ? TRUE : FALSE, parent, this); _win = _viswin->win(); enable_window(_win, enabled()); show_window(_win, shown()); + + set_cursor(TASK_WIN, oldcur); } @@ -2153,6 +2166,9 @@ long TBrowsefile_field::set_text(const char* file, const char* line) FILE* instr = fopen(file,"r"); if (instr == NULL) fatal_box("File non trovato: %s", file); + + CURSOR oldcur = get_cursor(TASK_WIN); + set_cursor(TASK_WIN,CURSOR_WAIT); TString256 tmpp; long ret = -1l; @@ -2175,7 +2191,9 @@ long TBrowsefile_field::set_text(const char* file, const char* line) } fclose(instr); - _viswin->close_print(); + _viswin->close_print(); + set_cursor(TASK_WIN, oldcur); + return ret; } @@ -2243,7 +2261,7 @@ void TBrowsefile_field::close() void TBrowsefile_field::goto_pos(long r, long c) { - _viswin->goto_pos(r,c); + _viswin->goto_pos(r,c,TRUE); } void TBrowsefile_field::goto_top() diff --git a/include/viswin.h b/include/viswin.h index 575558c16..e63b56644 100755 --- a/include/viswin.h +++ b/include/viswin.h @@ -147,7 +147,7 @@ public: void goto_end(); void goto_top(); - void goto_pos(long,long); + void goto_pos(long r, long c, bool moveorigin = TRUE); void refresh(); void add_line(const char* l);