ubit
uwinImpl.hpp
1 /************************************************************************
2  *
3  * uwinImpl.hpp: ubit windows implementation
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uwinImpl_hpp_
18 #define _uwinImpl_hpp_ 1
19 #include <ubit/uwin.hpp>
20 namespace ubit {
21 
22  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23  /* [Impl] Window list.
24  * Used for implementation purpose, UWinList elements are not counted has parents
25  * when auto deleting children. They are considered as genuine lists, not viewable
26  * elements when displayingviews
27  */
28  class UWinList : public UElem {
29  public:
30  UCLASS(UWinList)
31  UWinList(const UArgs& a = UArgs::none) : UElem(a) {}
32  virtual int getDisplayType() const {return WINLIST;} // redefined
33  };
34 
35 
36  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 
38  class UWinImpl {
39  public:
41  enum WinType {
42  NONE,
43  //NOTUSED,
44  EXTWIN,
45  PIXMAP,
46  HARDWIN = 8, // can't be instanciated
47  SUBWIN,
48  TOPLEVEL = 16, // can't be instanciated
49  FRAME,
50  MAINFRAME,
51  DIALOG,
52  MENU
53  };
54  virtual ~UWinImpl() {};
55  };
56 
57  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58 
59  /* [Impl] Soft (= simulated) Window.
60  * abstract class: @see UHardwinX11, UHardwinGLUT, etc.
61  */
62  class USoftwinImpl : public UWinImpl {
63  public:
65  virtual ~USoftwinImpl();
66 
67  UPos& pos() {return *ppos;}
68 
69  UView* getActualView(UView* winviews);
70  void setActualView(UView* winview);
71 
72  void doUpdate(const UUpdate&, UWin*, UView* winview);
73 
74  private:
75  uptr<UPos> ppos;
76  UView* actual_view;
77  };
78 
79  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80 
81  /* [Impl] Hard (= real) Window.
82  * abstract class: @see UHardwinX11, UHardwinGLUT, etc.
83  */
84  class UHardwinImpl : public UWinImpl {
85  public:
86  virtual ~UHardwinImpl();
87 
88  UDisp* getDisp() const {return disp;}
89  UWin* getWin() const {return win;}
90  WinType getWinType() const {return WinType(wintype);}
91  UGlcontext* getGlcontext() const {return glcontext;}
92 
93  bool isPixmap() const {return wintype == PIXMAP;}
94  bool isSubwin() const {return wintype == SUBWIN;}
95  bool isHardwin() const {return wintype > HARDWIN;}
96  bool isTopLevel() const {return wintype > TOPLEVEL;}
97 
98  virtual void realize(WinType, float w, float h) = 0;
99  virtual bool isRealized() const = 0;
100 
101  virtual void show(bool = true) = 0;
102  virtual void toBack() = 0;
103  virtual void toFront() = 0;
104 
105  virtual UPoint getScreenPos() const = 0;
111  virtual UPoint getPos() const = 0;
117  virtual void setPos(const UPoint&) = 0;
123  virtual UDimension getSize() const = 0;
125 
126  virtual void setSize(const UDimension&) = 0;
128 
129  virtual UStr getTitle() const = 0;
131 
132  virtual void setTitle(const UStr&) = 0;
134 
135  virtual UStr getIconTitle() const = 0;
137 
138  virtual void setIconTitle(const UStr&) = 0;
140 
141  virtual void setCursor(const UCursor*) = 0;
143 
144  virtual void setClassProperty(const UStr& instance_name, const UStr& class_name) = 0;
146 
147  private:
148  UHardwinImpl(const UHardwinImpl&);
149  UHardwinImpl& operator=(const UHardwinImpl&);
150 
151  protected:
152  UHardwinImpl(UDisp*, UWin*);
153 
154  // - - - impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155 #ifndef NO_DOC
156  public:
157  UChildren* getSoftwinList();
158  UWinList* getSoftwins();
159  UWinList* obtainSoftwins();
160  void addSoftwin(UWin* softwin, UWin* hardwin, UDisp* disp, bool add_to_the_end);
161  // add to the end add_to_the_end is true, to the beginning otherwise
162  void removeSoftwin(UWin* softwin);
163 
164  void doUpdate(const UUpdate&, UWin*, UView* winview);
165  void doUpdateImpl(const UUpdate&, UWin*, UView* winview, const UDimension* size);
166 
167  protected:
168  friend class UDisp;
169  friend class UWin;
170  friend class UView;
171  friend class UGraph;
172  friend class UPaintEvent;
173  friend class UInputEvent;
174  friend class UAppliImpl;
175  friend class UGlcanvas;
176  unsigned char wintype; // one of UWinImpl::WinType
177  unsigned char must_update; // see UAppliImpl::processUpdateRequests
178  UDisp* disp;
179  UWin* win;
180  UChildren* softwin_list;
181  // glcanvas windows and GLUT window have their own UGlcontext
182  UGlcontext* glcontext;
183 #endif
184  };
185 
186 }
187 #endif
188 
189 
190 
2D Dimension.
Definition: ugeom.hpp:55
Widget position.
Definition: uboxgeom.hpp:91
2D Point.
Definition: ugeom.hpp:25
Definition: uappliImpl.hpp:40
class for drawing on widgets.
Definition: ugraph.hpp:44
Display Context.
Definition: udisp.hpp:44
Definition: uwinImpl.hpp:62
specifies how to update UElem, UBox, UWin objects and subclasses.
Definition: uupdate.hpp:25
Paint event.
Definition: uevent.hpp:377
Definition: uwinImpl.hpp:38
Definition: uwinImpl.hpp:28
lightweight general purpose container.
Definition: uelem.hpp:44
Child (or attribute) list.
Definition: uchild.hpp:79
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
Box View.
Definition: uview.hpp:65
Definition: uhardfont.hpp:31
Base class for UMouseEvent and UKeyEvent Note that this class inherits from class UModifier that defi...
Definition: uevent.hpp:75
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Definition: uwinImpl.hpp:84
Base class for windows and menus.
Definition: uwin.hpp:47
Mouse cursor property.
Definition: ucursor.hpp:31
virtual void show(bool=true)
shows/hides this object.
Definition: uelem.cpp:468
Ubit String.
Definition: ustr.hpp:72
WinType
window types.
Definition: uwinImpl.hpp:41