ubox.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  ubox.hpp : UBox container.
00004  *  Ubit Project
00005  *  Author: Eric Lecolinet
00006  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00007  *  (C) 1999-2006 /s EricLecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00008  *
00009  * ***********************************************************************
00010  * COPYRIGHT NOTICE : 
00011  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00012  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00013  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00014  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00015  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00016  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00017  * ***********************************************************************
00018  * ==================================================== [(c)Elc] ======= *
00019  * ==================================================== ======== ======= */
00020 
00021 #ifndef _ubox_hpp_
00022 #define _ubox_hpp_
00023 //pragma ident  "@(#)ubox.hpp           ubit:05.05.00"
00024 #include <ubit/ugroup.hpp>
00025 namespace ubit {
00026 
00027 /* ==================================================== ===== ======= */
00068 class UBox: public UGroup {
00069 public:
00070   UBIT_ELEMENT_CLASS(UBox, UGroup)
00078   static UStyle* createStyle();
00083   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00084 
00085   UBox(const UArgs& a = UArgs::none);  
00087 
00088   friend UBox& ubox(const UArgs& a = UArgs::none) {return *new UBox(a);}
00093   virtual ~UBox() {destructs();}
00099   virtual UBox* boxCast() {return this;}
00101 
00102   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00103 
00104   virtual UBorder* getBorder() const;
00105   virtual UBorder* getBorder(bool create_if_none);
00110   virtual UBox& addlist(const UArgs& a) {UGroup::addlist(a); return *this;}
00119   virtual UBox* getChildAt(const UPoint&, UView* box_view = null) const;
00125   virtual UBox* findChildAt(const UPoint&, UView* box_view = null) const;
00131   virtual UDimension getViewSize(UView* box_view = null) const; 
00137   virtual UPoint getViewPos(UView* box_view = null) const;  
00143   virtual UPoint getEventPos(const UMouseEvent&) const;
00148   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00149 
00150   virtual int getViewCount() const;
00152 
00153   virtual int getViews(std::vector<UView*>&) const;
00162   virtual int getRelatedViews(std::vector<UView*>& v) const {return getViews(v);}
00163 
00164   virtual UView* getView(int n = 0) const;
00174   virtual UView* getViewAt(const UMouseEvent&) const;
00176  
00177   virtual UView* getViewContaining(const UView* child_view) const;
00183   virtual UView* getFirstViewInside(const UView* parent_view) const;
00189   void setViewModes(int view_modes, bool);
00190 
00191   virtual void repaint() {update(UUpdate::paint);}          // redefined from UGroup
00192   virtual void update() {update(UUpdate::layoutAndPaint);}  // redefined from UGroup
00193   virtual void update(const UUpdate&);                      // redefined from UGroup
00194   
00195   // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00196 
00197 #ifndef NO_DOC
00198   virtual UView* getViewInImpl(UView* parent_view, UChild*);
00199   virtual UView* getViewInImpl(UView* parent_view, UChild*, int& w, int& h);
00207   virtual void addView(UView*);
00208   virtual void updateView(UEvent&, UView*, const UUpdate&);
00209   virtual UBox* getChildAtImpl(const UPoint&, UView* box_view) const;
00210 
00211 protected:
00212   friend class UGroup;
00213   friend class UWin;
00214   UView* views;
00215 
00216   virtual void initView(UChild* self, UView *ancestor_view);
00217   virtual void initChildViews(UGroup*, UChild* childlink);
00218   virtual void deleteRelatedViews(UView* parview, UChild*);
00219   //NB: link can be null (but not parview) for UBox::deleteRelatedViews
00220   
00221   static void updateImpl(const class UUpdate& upmode, 
00222                          UView* winview, UView* layoutview, UView* showview,
00223                          bool impose_size, int w, int h); 
00224 public:
00225   UBox& onChildEvent(const UArgs&);
00226   /* [obsolete] detects events that have been received by children.
00227     * Example:
00228     * <pre>
00229     *   box->onChildEvent(UOn::mmove / ucall(...) + UOn::mpress / ucall(...))
00230     * </pre>
00231     *
00232     * See also:
00233     * - UOn::filterEvent to detect and filter events *before* they reach children.
00234     *
00235     * Notes:
00236     * - abstracts events can't be detected by this function, except if they were
00237     *   actually processed by the child target.
00238     * -  UEvent methods (such as getSource(), getX(), getY() ...) are relative
00239     *    to the child target that received the event.
00240     */
00241   
00242 #endif
00243 };
00244 
00245 }
00246 #endif
00247 /* ==================================================== [TheEnd] ======= */
00248 /* ==================================================== [(c)Elc] ======= */

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