Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 2.1 598 git-svn-id: svn://10.65.10.50/trunk@13909 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			391 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			391 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #ifndef __WINDOW_H
 | |
| #define __WINDOW_H
 | |
| 
 | |
| #ifndef __STRINGS_H
 | |
| #include <strings.h>
 | |
| #endif           
 | |
| 
 | |
| #ifndef __XVTILITY_H
 | |
| #include <xvtility.h>
 | |
| #endif
 | |
| 
 | |
| void close_all_dialogs();
 | |
| bool can_close();
 | |
| WINDOW cur_win();
 | |
| 
 | |
| // @doc EXTERNAL
 | |
| 
 | |
| // @class TPoint | Struttura per la definizione di un punto sullo schermo
 | |
| //
 | |
| // @author:(INTERNAL) Guido
 | |
| struct TPoint
 | |
| {
 | |
|   // @cmember Coordinate del punto
 | |
|   long x,y; 
 | |
| 
 | |
|   void set(long sx, long sy) { x = sx; y = sy; }
 | |
|   // @cmember Operatore di assegnamento tra punti
 | |
|   TPoint& operator =(const TPoint& pnt)  { x = pnt.x; y = pnt.y; return *this; }
 | |
|   // @cmember Confronta se due punti sono uguali (TRUE se uguali)
 | |
|   bool operator ==(const TPoint& p) const { return p.x == x && p.y == y; }
 | |
|   // @cmember Confronta se due punti sono diversi (TRUE se diversi)
 | |
|   bool operator !=(const TPoint& p) const { return p.x != x || p.y != y; }
 | |
|   TPoint& operator +=(const TPoint& pnt)  { x += pnt.x; y += pnt.y; return *this; }
 | |
|   TPoint& operator -=(const TPoint& pnt)  { x -= pnt.x; y -= pnt.y; return *this; }
 | |
|   void reset() { x = y = 0; }
 | |
| 
 | |
|   // @cmember Costruttori
 | |
|   TPoint() : x(0), y(0) { }
 | |
|   TPoint(long sx, long sy) : x(sx), y(sy) { }
 | |
|   TPoint(const TPoint& p) : x(p.x), y(p.y) { }
 | |
| };
 | |
| 
 | |
| class TRectangle : public TPoint
 | |
| {
 | |
|   TPoint _size;
 | |
| 
 | |
| protected:
 | |
|   void copy(const TRectangle& r);
 | |
|   void normalize();
 | |
| 
 | |
| public:
 | |
|   long left() const { return x; }
 | |
|   long right() const { return x + _size.x; }
 | |
|   long top() const { return y; }
 | |
|   long bottom() const { return y + _size.y; }
 | |
|   long width() const { return _size.x; }
 | |
|   long height() const { return _size.y; }
 | |
|   const TPoint& pos() const { return *this; }
 | |
|   const TPoint& size() const { return _size; }
 | |
| 
 | |
|   void set_width(long w) { _size.x = w; normalize(); }
 | |
|   void set_height(long h) { _size.y = h; normalize(); }
 | |
|   void set(long cx, long cy, long dx, long dy);
 | |
|   void set(const TPoint& pt, const TPoint& sz);
 | |
|   void set_bounds(long left, long top, long right, long bottom);
 | |
| 
 | |
|   bool contains(const TPoint& p) const;
 | |
|   bool contains(const TRectangle& r) const;
 | |
|   bool intersects(const TRectangle& r) const;
 | |
|   void merge(const TRectangle& r);
 | |
|   void inflate(int dx, int dy);
 | |
|   void deflate(int dx, int dy);
 | |
|   bool is_empty() const { return _size.x == 0 || _size.y == 0; }
 | |
| 
 | |
|   // @cmember Confronta se due rettangoli sono uguali (TRUE se uguali)
 | |
|   bool operator ==(const TRectangle& p) const { return TPoint::operator ==(p) && _size == p._size; }
 | |
|   // @cmember Confronta se due rettangoli sono diversi (TRUE se diversi)
 | |
|   bool operator !=(const TRectangle& p) const { return TPoint::operator !=(p) || _size != p._size; }
 | |
| 
 | |
|   TRectangle& operator=(const TRectangle& r) { copy(r); return *this; }
 | |
|   TRectangle() : TPoint(0,0), _size(0,0) { }
 | |
|   TRectangle(const TPoint& p, const TPoint& s) : TPoint(p), _size(s) { }
 | |
|   TRectangle(long cx, long cy, long dx, long dy) { set(cx, cy, dx, dy); }
 | |
|   TRectangle(const TRectangle& r)  { copy(r); } 
 | |
| };
 | |
| 
 | |
| // @doc EXTERNAL
 | |
| 
 | |
| // @class TWindow | Classe per la definizione di una finestra generica
 | |
| class TWindow : public TObject
 | |
| {
 | |
|   // @author:(INTERNAL) Guido
 | |
| 
 | |
|   // @cfriend TWindow_manager
 | |
|   friend class TWindow_manager;
 | |
| 
 | |
|   // @access:(INTERNAL) Private Member
 | |
| 
 | |
|   // @cmember:(INTERNAL) Set di drawing tools (definito in xvttype.h)
 | |
|   static DRAW_CTOOLS _ct;
 | |
|   // @cmember:(INTERNAL) Indica se e' stato salvato il set di drawing tools
 | |
|   static bool _ctools_saved;
 | |
| 
 | |
|   // @cmember:(INTERNAL) Descrittore finestra
 | |
|   WINDOW _win;
 | |
|   // @cmember:(INTERNAL) Codice del tasto di uscita
 | |
|   KEY _lastkey;
 | |
| 
 | |
|   // @cmember:(INTERNAL) Compila la struttura <p _ct> con i valori correnti
 | |
|   //          (TRUE se la compilazione ha luogo)
 | |
|   bool save_ctools();
 | |
|   // @cmember:(INTERNAL) Ripristina i valori dalla struttura <p _ct> (TRUE se i valori
 | |
|   //          vengono recuperati)
 | |
|   bool restore_ctools();
 | |
| 
 | |
|   long _base_char_width;  // Lunghezza in pixel di una stringa di m
 | |
| 
 | |
|   // @access Protected Member
 | |
| protected:
 | |
|   // @cmember Indica che la finestra e' aperta
 | |
|   bool _open    : 1;
 | |
|   // @cmember Indica che la finestra e' modale
 | |
|   bool _modal   : 1;
 | |
|   // @cmember Indica che la finestra e' abilitata
 | |
|   bool _active  : 1;
 | |
|   // @cmember Indica che la finestra e' in esecuzione
 | |
|   bool _running : 1;
 | |
|   // @cmember Indica che le coordinate sono in pixel
 | |
|   bool _pixmap  : 1;
 | |
| 
 | |
|   // @cmember Intercetta tutti i messaggi diretti alla finestra di XVT
 | |
|   static long window_handler(WINDOW win, EVENT* ep);
 | |
|   // @cmember Crea la finestra
 | |
|   virtual WINDOW create(short x, short y, short dx, short dy, const char* title = "", long flags = WSF_NONE, WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN, int menu = 0) ;
 | |
| 
 | |
|   // @cmember Cambia l'handle della finestra di XVT (usare con cautela)
 | |
|   void set_win(WINDOW w)
 | |
|   { _win = w; }
 | |
| 
 | |
|   // @cmember Permette di modificare il flag <p _modal>
 | |
|   void set_modal(bool m)
 | |
|   { _modal = m; }
 | |
| 
 | |
|   // @cmember Fa' l'update della finstra
 | |
|   virtual void update()
 | |
|   {}
 | |
| 
 | |
|   int char2pixel(int len) const;
 | |
| 
 | |
|   // @access Public Member
 | |
| public:
 | |
|   // @cmember Costruttore
 | |
|   TWindow();
 | |
|   // @cmember Distruttore
 | |
|   virtual ~TWindow();
 | |
|   
 | |
|   // @cmember Ritorna l'handler della finestra padre
 | |
|   WINDOW parent() const;
 | |
| 
 | |
|   // @cmember Ritorna l'identificatore della classe finestra
 | |
|   virtual word class_id() const;
 | |
|   
 | |
|   // @cmember Gestisce la pressione dei bottoni
 | |
|   virtual void on_button(short dlg);
 | |
|   
 | |
|   // @cmember Gestisce gli eventi della finestra
 | |
|   virtual void handler(WINDOW win, EVENT* ep);
 | |
|   
 | |
|   // @cmember Mette la finestra in primo piano
 | |
|   virtual void set_focus();
 | |
|   // @cmember Ritorna il descrittore della finestra
 | |
|   virtual WINDOW win() const
 | |
|   { return _win; }   
 | |
| 
 | |
|   // @cmember Gestisce la pressione del tasto
 | |
|   virtual bool on_key(KEY)
 | |
|   { return TRUE; }
 | |
| 
 | |
|   // @cmember Ritorna TRUE se la finestra e' aperta
 | |
|   bool is_open() const
 | |
|   { return _open; }
 | |
|   // @cmember Ritorna TRUE se la finestra e' modale
 | |
|   bool is_modal() const
 | |
|   { return _modal; }
 | |
|   // @cmember Ritorna TRUE se la finestra e' in esecuzione
 | |
|   bool is_running() const
 | |
|   { return _running; }
 | |
|   // @cmember Ritorna TRUE se la finestra e' attiva
 | |
|   bool active() const
 | |
|   { return _active; }
 | |
| 
 | |
|   // @cmember Determina numero di righe e colonne nella finestra
 | |
|   TPoint size() const;
 | |
|   // @cmember Ritorna il numero di righe della finestra
 | |
|   short rows() const
 | |
|   { return (short)size().y; }
 | |
|   // @cmember Ritorna il numero di colonnedella finestra
 | |
|   short columns() const
 | |
|   { return (short)size().x; }
 | |
| 
 | |
|   // @cmember Inizia l'esecuzione della finestra
 | |
|   virtual void start_run()
 | |
|   {}
 | |
|   // @cmember Interrompe l'esecuzione della finestra
 | |
|   virtual bool stop_run(KEY key);
 | |
|   // @cmember Forza ridisegno della finestra
 | |
|   void force_update();
 | |
|   // @cmember Cambia il colore dello sfondo
 | |
|   void set_background_color(COLOR col);
 | |
|   // @cmember Mostra la finestra
 | |
|   virtual void open();
 | |
|   // @cmember  Nasconde la finestra
 | |
|   virtual void close();
 | |
|   // @cmember Indica se la finestra puo' essere chiusa brutalmente
 | |
|   virtual bool can_be_closed() const;
 | |
|   // @cmember Permette di fare tutti gli aggiornamenti necessari
 | |
|   virtual void on_idle();
 | |
| 
 | |
|   // @cmember Massimizza la finestra
 | |
|   void maximize() const;
 | |
|   // @cmember Minimizza (iconizza) la finestra
 | |
|   void minimize() const;
 | |
|   // @cmember Attiva/disattiva la finestra
 | |
|   virtual void activate(bool = TRUE);
 | |
|   // @cmember Disattiva la finestra (chiama <mf TWindow::activate>)
 | |
|   void deactivate()
 | |
|   { activate(FALSE); }
 | |
| 
 | |
|   // @cmember Mostra la finestra modale
 | |
|   void open_modal();
 | |
|   // @cmember Nasconde la finestra modale
 | |
|   void close_modal();
 | |
| 
 | |
|   // @cmember Esegue la finestra
 | |
|   virtual KEY run();
 | |
|   
 | |
|   // @cmember Ritorna l'ultimo tasto
 | |
|   KEY last_key() const
 | |
|   { return _lastkey; }
 | |
| 
 | |
|   // @cmember Permette di settare il titolo della finestra
 | |
|   virtual void set_caption(const char* title);
 | |
|   // @cmember Ritorna il titolo della finestra
 | |
|   virtual const char* get_caption(TString& str) const;
 | |
| 
 | |
|   // @cmember Riempie la finestra con il colore <p color>
 | |
|   void clear(COLOR color);
 | |
| 
 | |
|   // @cmember Setta il draw mode
 | |
|   void set_mode(DRAW_MODE mode);
 | |
| 
 | |
|   // @cmember Setta il colore della finestra e dello sfondo
 | |
|   void set_color(COLOR fore, COLOR back);
 | |
| 
 | |
|   // @cmember Setta opaque_text
 | |
|   void set_opaque_text(bool o);
 | |
| 
 | |
|   // @cmember Sceglie la penna da utilizzare nella finestra
 | |
|   void set_pen(COLOR color, int width = 1, PAT_STYLE pat = PAT_SOLID, PEN_STYLE st = P_SOLID);
 | |
|   // @cmember Nasconde la penna
 | |
|   void hide_pen();
 | |
|   // @cmember Nasconde il pennello
 | |
|   void hide_brush();
 | |
|   // @cmember Sceglie il pennello da utilizzare nella finestra (vedi <mf TWindow::set_pen>)
 | |
|   void set_brush(COLOR color, PAT_STYLE = PAT_SOLID);
 | |
|   // @cmember Sceglie il font da utilizzare nella finestra
 | |
|   void set_font(const char* family = NULL, int style = 0, int dim = 0);
 | |
| 
 | |
|   // @cmember Converte le coordinate logiche (caratteri) in coordinate fisiche (pixel)
 | |
|   virtual PNT log2dev(long x, long y) const;
 | |
|   // @cmember Converte le coordinate fisiche (pixel) in coordinate logiche (caratteri)
 | |
|   virtual TPoint dev2log(const PNT& p) const;
 | |
| 
 | |
|   virtual void log2dev(const TRectangle& rctl, RCT& rctd) const;
 | |
|   virtual void dev2log(const RCT& rctd, TRectangle& rctl) const;
 | |
| 
 | |
|   // @cmember Disegna un rettangolo con la possibilita' di settare la penna e il draw_mode
 | |
|   void frame(short left, short top, short right, short bottom, int flag);
 | |
| 
 | |
|   // @cmember Chiama <mf TWindow::frame> con il flag 2
 | |
|   void rect(short left, short top, short right, short bottom);
 | |
|   // @cmember Chiama <mf TWindow::frame> con il flag 1
 | |
|   void bar(short left, short top, short right, short bottom);
 | |
|   // @cmember Chiama <mf TWindow::frame> con il flag 5
 | |
|   void invert_bar(short left, short top, short right, short bottom);
 | |
| 
 | |
|   // @cmember Scrive una stringa nella finestra all posizione indicata
 | |
|   void stringat(short x, short y, const char* str);
 | |
|   // @cmember Scrive il testo formattato nella finestra all posizione indicata
 | |
|   void printat(short x, short y, const char* fmt, ...);
 | |
| 
 | |
|   // @cmember Disegna una linea nella finestra
 | |
|   void line(short x0, short y0, short x1, short y1);
 | |
|   // @cmember Disegna una icona nella finestra
 | |
|   void icon(short x0, short y0, int iconid = -1);
 | |
| 
 | |
|   // @cmember Aggiunge voci di menu' durante l'esecuzione di una finestra
 | |
|   bool add_menu(TString_array& menu, MENU_TAG id = 0, bool force = TRUE);
 | |
|   // @cmember Rimuove il menu' runtime dalla finestra
 | |
|   bool remove_menu(MENU_TAG id);
 | |
| 
 | |
|   // @cmember Chiamata ad ogni cambio ditta
 | |
|   virtual void on_firm_change() 
 | |
|   {}
 | |
| };
 | |
| 
 | |
| // @doc INTERNAL
 | |
| 
 | |
| // @class TTemp_window | Classe per la definizione di finestre temporanee
 | |
| //
 | |
| // @base public | TWindow
 | |
| class TTemp_window : public TWindow
 | |
| {
 | |
|   // @author:(INTERNAL) Guido
 | |
| 
 | |
|   // @access Public Member
 | |
| public:
 | |
|   // @cmember Costruttore
 | |
|   TTemp_window(WINDOW w);
 | |
|   // @cmember Distruttore
 | |
|   virtual ~TTemp_window();
 | |
| };
 | |
| 
 | |
| 
 | |
| // @doc EXTERNAL
 | |
| 
 | |
| // @class TScroll_window | Classe per la definizione di finestre con scrollbar
 | |
| //
 | |
| // @base public | TWindow
 | |
| class TScroll_window : public TWindow
 | |
| {
 | |
|   // @author:(INTERNAL) Guido
 | |
| 
 | |
|   // @access:(INTERNAL) Private Member
 | |
| 
 | |
|   // @cmember:(INTERNAL) Posizione attuale della scrollbar
 | |
|   TPoint _origin;
 | |
|   // @cmember:(INTERNAL) Massima lunghezza della scrollbar
 | |
|   TPoint _max;
 | |
|   // @cmember:(INTERNAL) Utilizzato per finestre molto grosse, per poter gestire l-intera finestra
 | |
|   short _shift;
 | |
| 
 | |
|   // @cmember:(INTERNAL) Indica se sommare (TRUE) o no alle coordinate attuali le coordinate passate
 | |
|   bool _autoscroll  : 1;
 | |
|   // @cmember:(INTERNAL) Indica che la finestra ha la barra di scorrimento orizzontale
 | |
|   bool _has_hscroll : 1;
 | |
|   // @cmember:(INTERNAL) Indica che la finestra ha la barra di scorrimento verticale
 | |
|   bool _has_vscroll : 1;
 | |
| 
 | |
|   // @access Protected Member
 | |
| protected:
 | |
|   // @cmember Crea la finestra (vedi <mf TWindow::create>)
 | |
|   virtual WINDOW create(short x, short y, short dx, short dy, const char* title = "", long flags = WSF_NONE, WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN, int menu = 0) ;
 | |
| 
 | |
|   // @cmember Converte le coordinate logiche (caratteri) in coordinate fisiche (pixel)
 | |
|   virtual PNT log2dev(long x, long y) const;
 | |
| 
 | |
|   // @access Public Member
 | |
| public:
 | |
|   // @cmember Costruttore
 | |
|   TScroll_window();
 | |
| 
 | |
|   // @cmember Gestice la pressione del tasto
 | |
|   virtual bool on_key(KEY key);
 | |
| 
 | |
|   // @cmember Gestisce l'handler della finestra (vedi <mf TWindow::handler>)
 | |
|   virtual void handler(WINDOW win, EVENT* ep);
 | |
| 
 | |
|   // @cmember Setta punto di massimo scroll
 | |
|   void set_scroll_max(long maxx, long maxy);
 | |
|   // @cmember Aggiorna la scrollbar
 | |
|   void update_thumb(long x = -1, long y = -1);
 | |
| 
 | |
|   // @cmember Setta il member <p _autoscroll>
 | |
|   void autoscroll(bool on)
 | |
|   { _autoscroll = on; }
 | |
| 
 | |
|   // @cmember Ritorna il membro <p _autoscroll>
 | |
|   bool autoscrolling() const
 | |
|   { return _autoscroll; }
 | |
| 
 | |
|   // @cmember Ritorna il punto di origine
 | |
|   const TPoint& origin() const
 | |
|   { return _origin; }
 | |
|   // @cmember Ritorna il punto massimo
 | |
|   const TPoint& range() const
 | |
|   { return _max; }
 | |
| };
 | |
| 
 | |
| #endif // __WINDOW_H
 |