ubit
ubox.hpp
1 /************************************************************************
2  *
3  * ubox.hpp: Box Elements (elements that manage 1 or N screen UView(s))
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 _ubox_hpp_
18 #define _ubox_hpp_ 1
19 #include <ubit/uelem.hpp>
20 namespace ubit {
21 
64  class UBox: public UElem {
65  public:
66  UCLASS(UBox)
67 
68  UBox(UArgs args = UArgs::none);
79  virtual ~UBox() {destructs();}
85  virtual UBox* toBox() {return this;}
86  virtual const UBox* toBox() const {return this;}
87 
88  static UStyle* createStyle();
93  virtual int getDisplayType() const {return BLOCK;} // redefined
94 
95  void repaint() {update(UUpdate::paint);} // redefined
96  void update() {update(UUpdate::layoutAndPaint);} // redefined
97  virtual void update(const UUpdate& update_options, UDisp* = null); // redefined
98  virtual void doUpdate(const UUpdate&, UDisp* = null); // redefined
99 
100  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101 
102  virtual int getViewCount() const;
104 
105  virtual int getViews(std::vector<UView*>&) const;
117  virtual UView* getView(int n = 0) const;
128  virtual UView* getView(const UInputEvent&) const;
130 
131  virtual UView* getView(UWin&, const UPoint& pos_in_win, UDisp* = null) const;
133 
134  virtual UView* getViewContaining(const UView& child_view) const;
140  virtual UView* getFirstViewInside(const UView& parent_view) const;
146  // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
147 
148 #ifndef NO_DOC
149 
150  virtual int retrieveRelatedViews(std::vector<UView*>& collating_vector) const;
151  /* returns the views that are related to this box.
152  * retrieves all the views that are currently controlled by this UBox.
153  *
154  * - this function does the same as getViews() except that 'collating_vector'
155  * is not emptied: the views are added to the end of what it already contains.
156  * - the function returns the number of views that were added (which may thus differ
157  * from the total size of 'collating_vector')
158  *
159  * Note that elements and boxes can have several parents, so that multiple wiews
160  * can be associated to the same widget (see UElem and UBox classes for details)
161  */
162 
163  virtual UView* getViewInImpl(UView* parent_view);
164 
165  virtual UView* getViewInImpl(UView* parent_view, UDimension&);
166  /* returns the object's view that is contained in this DIRECT parent view.
167  * 'parent_view' will contain several views of this object if it has been added
168  * several times to this parent.
169  */
170 
171  void setViewModes(int view_modes, bool);
172 
173  protected:
174  friend class UElem;
175  friend class UWin;
176  friend class UView;
177  friend class UAppliImpl;
178  UView* views;
179 
180  virtual void addViewImpl(UView*);
181  virtual void initView(UView* parent_view);
182  virtual void initChildViews(UElem*);
183  virtual void deleteViewsInside(const std::vector<UView*>& parent_views);
184  #endif
185  };
186 
187  inline UBox& ubox(const UArgs& args = UArgs::none) {return *new UBox(args);}
192  UBox& uvbox(UArgs args = UArgs::none);
194 
195  UBox& uhbox(UArgs args = UArgs::none);
197 
198 }
199 #endif
200 
2D Dimension.
Definition: ugeom.hpp:55
static const UUpdate layoutAndPaint
layout then paint: prefined constant for UUpdate(LAYOUT|PAINT);
Definition: uupdate.hpp:50
Box container.
Definition: ubox.hpp:64
2D Point.
Definition: ugeom.hpp:25
static const UUpdate paint
paint only: prefined constant for UUpdate(PAINT);
Definition: uupdate.hpp:47
Definition: uappliImpl.hpp:40
void update()
updates object graphics.
Definition: ubox.hpp:96
virtual ~UBox()
recursive destructor.
Definition: ubox.hpp:79
virtual void doUpdate(const UUpdate &, UDisp *=null)
updates the layout and/or the paint of this object right now.
Definition: ubox.cpp:415
Display Context.
Definition: udisp.hpp:44
virtual UBox * toBox()
dynamic cast: returns this object if it derives from UBox and null otherwise.
Definition: ubox.hpp:85
virtual const UBox * toBox() const
dynamic cast: returns this object if it derives from UBox and null otherwise.
Definition: ubox.hpp:86
virtual UView * getViewContaining(const UView &child_view) const
returns the view of this box that contains &#39;child_view&#39;.
Definition: ubox.cpp:223
specifies how to update UElem, UBox, UWin objects and subclasses.
Definition: uupdate.hpp:25
UBox(UArgs args=UArgs::none)
creates a new UBox; The argument can either be a single object pointer or reference, or a list of object pointers or references separated by + operators, example:
Definition: ubox.cpp:43
lightweight general purpose container.
Definition: uelem.hpp:44
virtual int getViewCount() const
returns the number of views of this box.
Definition: ubox.cpp:130
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
virtual UView * getView(int n=0) const
returns the Nth view of this box (see DETAILS).
virtual void destructs()
unlinks the object from its parents and destroys its children.
Definition: uelem.cpp:109
static UStyle * createStyle()
static function that returns the style of this class (see details!).
Definition: ubox.cpp:50
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
virtual int getViews(std::vector< UView *> &) const
returns the views of this box (see DETAILS).
Definition: ubox.cpp:136
Base class for windows and menus.
Definition: uwin.hpp:47
virtual UView * getFirstViewInside(const UView &parent_view) const
returns the first box view that is contained in &#39;parent_view&#39;.
Definition: ubox.cpp:230
Compiled Object Style.
Definition: ustyle.hpp:44