#ifndef __SHEET_H #define __SHEET_H #ifndef __STRINGS_H #include #endif #ifndef __WINDOW_H #include #endif #ifndef __RELATION_H class TCursor; #endif #ifndef __MASKFLD_H class TEdit_field; #endif // @doc EXTERNAL // @class TSheet | Classe per la definizione e la gestione degli sheet per le ricerche // // @base public | TScroll_window class TSheet : public TScroll_window // @author(:INTERNAL) Guido // @access Privete Member { // @ccost MAX_BUT | 8 | Numero massimo di bottoni enum { MAX_BUT = 8, // @ccost MAX_COL | 128 | Numero massimo di colonne MAX_COL = 128 }; // @cmember Array di stringhe con il contenuto dello sheet TString_array _page; // @cmember Numero di colonne dello sheet byte _columns; // @cmember Dimensione di ogni colonna byte _size[MAX_COL]; // @cmember Tipo di ogni colonne byte _type[MAX_COL]; // @cmember Riga corrente long _curr; // @cmember Indice della prima riga visibile long _last_update; // @cmember Numero di righe visibili short _visible_rows; // @cmember Indica se e' possibile inserire un check (X di selezione) sulle righe sheet bool _checkable; // @cmember Indica se e attivata la gestione dei check delle righe bool _check_enabled; // @cmember Array di righe attivate TBit_array _checked; // @cmember Array di righe disabilitate TBit_array _disabled; // @cmember Handles dei bottoni presenti nella finestra WINDOW _button[MAX_BUT]; // @cmember Tasto associato ad ogni bottone KEY _key[MAX_BUT]; // @cmember Maschera di bit corrispondente ai bottoni standard byte _buttonmask; // @access Protected Member protected: // @cmember Ritorna se il numero di colonne e' maggioer di 1!!! bool head_on() const { return _columns > 1; } // @cmember Indica se esitono i bottoni in fondo bool buttons_on() const { return *_button != NULL_WIN; } // @cmember Ritorna il numero di righe!!! visibili short visible_rows() const { return _visible_rows; } // @cmember Ritorna il numero di righe riservate ai bottoni virtual short reserved_rows() const; //ANDREA// void build_page(long first = -1); PNT log2dev(long x, long y) const; virtual void handler(WINDOW win, EVENT* ep); virtual bool on_key(KEY); virtual void update(); virtual void open(); void set_first(long n); // @cmember Ritorna se la riga!!!

-esima e' visibile bool is_visible(long n) const { return n >= first() && n < first()+visible_rows(); } int width() const; int row_to_page(long n) const; int row_to_win(long n) const; // @cmember ??? long first() const { return origin().y; } bool update_row(long n); void invert_row(long n); void set_row(const TToken_string& row, byte n); virtual void repos_buttons() const; virtual void page_build(long first, byte num) pure; void print(); // @access Public Member public: // @cmember Costruttore TSheet(short x,short y,short dx,short dy,const char* title,const char* head,byte buttons = 0,long first = 0L,WINDOW parent = NULL_WIN); void add_button(short id, const char* caption, KEY key = K_ESC); virtual long items() const pure; virtual TToken_string& row(long s = -1); // @cmember Ritorna il numero di cella corrente long selected() const { return _curr; } void select(long n); // @cmember Ritorna il tipo della colonna

-esima byte column_flag(int c) const { return _type[c]; } // @cmember Ritorna l'indirizzo??? del tipo della colonna

-esima byte& column_flag(int c) { return _type[c]; } // @cmember Ritorna se la cella

-esima possiede un check bool checked(long n) const { return _checked[n]; } void check(long n, bool on = TRUE); void uncheck(long n) { check(n, FALSE); } // @cmember Permette di abilitare (

= TRUE) o disbilitare (

= FALSE) // i check sullo sheet void enable_check(bool yn = TRUE) { _check_enabled = yn; } // @cmember Permette di disbilitare (

= FALSE) i check sullo sheet void disable_check() { enable_check(FALSE); } void enable(long n = -1, bool on = TRUE); void disable(long n = -1) { enable(n, FALSE); } bool enabled(long n) const { return !_disabled[n]; } bool disabled(long n) const { return _disabled[n]; } bool one_checked() const { return _checked.first_one() != -1; } long checked() const { return _checked.ones(); } }; class TArray_sheet : public TSheet { TString_array _data; protected: virtual void page_build(long first, byte num); TToken_string& data(long n) { return _data.row((int)n); } public: TArray_sheet(short x, short y, short dx, short dy, const char* caption, const char* head, byte buttons = 0, WINDOW parent = NULL_WIN); virtual long items() const { return _data.items(); } TString_array& rows_array() { return _data; } long add(const TToken_string& s); long add(TToken_string* s); long insert(const TToken_string& s, long n); virtual TToken_string& row(long s = -1) { return (s < 0) ? data(selected()) : data(s); } bool destroy(int i = -1); }; class TCursor_sheet : public TSheet { TArray _fields; // Array of TRecfield long _records; protected: TCursor* _cursor; virtual void page_build(long first, byte rows); public: TCursor_sheet(TCursor* cursor, const char* fields, const char* title, const char* head, byte buttons = 0); virtual ~TCursor_sheet() {} virtual long items() const { return _records; } virtual KEY run(); }; class TBrowse_sheet : public TCursor_sheet { TEdit_field* const _field; // Linked edit field int _sel; // Current listbox selection protected: virtual void handler(WINDOW win, EVENT* ep); virtual short reserved_rows() const; virtual void repos_buttons() const; virtual bool on_key(KEY k); TEdit_field& field() { return *_field; } public: TBrowse_sheet(TCursor* cursor, const char* fields, const char* title, const char* head, byte buttons, TEdit_field* f, TToken_string* siblings = NULL); virtual ~TBrowse_sheet() {} virtual KEY run(); }; #endif