udisp.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  udisp.hpp
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _udisp_hpp_
00021 #define _udisp_hpp_
00022 //pragma ident  "@(#)udisp.hpp  ubit:05.05.00"
00023 #include <ubit/ubrick.hpp>
00024 #include <ubit/ustr.hpp>
00025 #include <ubit/ugroup.hpp>
00026 namespace ubit {
00027 
00028 /* ==================================================== ======== ======= */
00036 class UDisp {
00037 public:
00038   UDisp(const UStr& display_name);
00039   UDisp(UConf&);
00051   virtual ~UDisp();
00052 
00053   const UConf& getConf() const {return conf;}
00055 
00056   int getID() const {return id;}
00061   bool isOpened() const;
00063   
00064   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00065 
00066   virtual void add(UWin&);
00075   virtual void remove(UWin&, bool auto_delete);
00080   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00081   
00082   int getDepth() const;
00084   
00085   const UStr& getDisplayName() const;
00087 
00088   int getScreenWidth() const;
00089   int getScreenHeight() const;
00091   
00092   int getScreenNumber() const;
00094   
00095   int getScreenCount() const;
00096   //< returns the total number of Screens on this X Server.
00097 
00098   void flush();
00100   
00101   bool isRealized() const;
00103    
00104   // - - - pointer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00105 
00106   void setPointerPos(const UPoint& screen_pos, int channel = 0) const;
00108 
00109   UPoint getPointerPos(int channel = 0) const;
00111 
00112   int getPointerState(int channel = 0) const;
00114 
00115   bool grabPointer(const UCursor* = null);
00124   void ungrabPointer();
00129   bool pickWindow(UNatWin& picked_win, int& x_in_win, int& y_in_win, 
00130                   UCursor* = null);
00131   bool pickWindow(UNatWin& picked_win, int& x_in_win, int& y_in_win, 
00132                   UCall& callback, UCursor* = null);
00144   // - - - event flow - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00145   
00146   UEventFlow* getDispFlow(int channel) const;
00156   UEventFlow* obtainDispFlow(int channel);
00162   USelection* getDispSelection(int channel);
00167   // - - - impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00168 
00169 #ifndef WITH_GDK
00170   int setTrueColors(int depth_hint);
00171   int setPseudoColors(int depth_hint);
00185 #endif
00186 
00187   virtual void realize();
00194   UNatDisp* getNatDisp() const {return natdisp;}
00196 
00197   void copySelection(UEvent&, USelection&);
00202   void pasteSelection(UEvent& e, UStr* _paste_to_str, int _paste_to_pos);
00208   void addHardWin(UWin*);
00209   void removeHardWin(UWin*);
00211 
00212   void realizeFont(const UFont&);
00213   bool realizeColor(UColor&);
00214   bool realizeCursor(UCursor&);
00216   
00217   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00218 #ifndef NO_DOC
00219 protected:
00220   friend class UConf;
00221   friend class UWin;
00222   friend class UHardWinImpl;
00223   friend class UView;
00224   friend class UGraph;
00225   friend class UNatDisp;
00226   friend class UEvent;
00227   friend class UFontMetrics;
00228 
00229   // attention: l'ordre de destruction importe ici: winlist doit etre
00230   // detruit en premier ca ca entraine des destructions qui font reference
00231   // a flowlist => winlist doit etre declare en DERNIER
00232 
00233   int id;
00234   UConf& conf;             // configuration data (may be shared with the UAppli)
00235   UStr display_name;       // name of the X Display
00236   UNatDisp* natdisp;       // native Display
00237   UChildren hardwin_list;  // list of hardwins that are event managed
00238 
00239   // copySelection() copies the content of the selection in this buffer
00240   // note: there is 1 selection per UEventFlow but only 1 copy_buffer per UDisp
00241   UStr copy_buffer;
00242 
00243   // pasteSelection() specifies that the selection will be pasted in this
00244   // UStr at this pos (uptr<> to avoid deletion)
00245   uptr<UStr> paste_to_str;
00246   int paste_to_pos;
00247 
00248   // attention: winlist doit etre detruit en premier!
00249   UGroup winlist;  // list of windows belonging to this display
00250   
00251   bool pickWindow(UNatWin& w, int& x, int& y, UCall* call, UCursor* curs);
00252 #endif
00253 };
00254 
00255 }
00256 #endif
00257 /* ==================================================== [TheEnd] ======= */

Generated on Mon Jan 29 00:20:37 2007 for Ubit by  doxygen 1.4.7