uwin.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uwin.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 _uwin_hpp_
00021 #define _uwin_hpp_
00022 //pragma ident  "@(#)uwin.hpp   ubit:05.05.00"
00023 #include <ubit/ubox.hpp>
00024 #include <ubit/uview.hpp>
00025 namespace ubit {
00026 
00027 class UWinImpl;
00028 class UPlacement;
00029 
00030 /* ==================================================== ====== ======= */
00051 class UWin : public UBox {
00052 public:
00053   UBIT_ELEMENT_CLASS(UWin, UBox)
00054 
00055   UWin(const UArgs& = UArgs::none);
00057 
00058   virtual ~UWin();
00064   virtual class UWin* winCast() {return this;}
00065 
00066   // - - - position - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00067   
00068   UWin& addlist(const UArgs& a) {UGroup::addlist(a); return *this;}
00069   
00070   virtual UWin& setTitle(const UStr&, UDisp* = null);
00072   
00073   virtual void setPos(UMouseEvent&, float x = 0, float y = 0);
00078   virtual void setPos(const UWin& win, const UPoint&, UDisp* = null);
00080 
00081   virtual void setPos(const UView& view, const UPoint&);
00083   
00084   virtual void setPos(const UView& view, const UPlacement&);
00086   
00087   virtual void setPosOnScreen(const UPoint&, UDisp* = null);
00089   
00090   virtual void centerOnScreen(UDisp* = null);
00091   // centers the window on the screen.
00092 
00093   virtual UPoint getPos(const UWin& win, UDisp* = null) const;
00095   
00096   virtual UPoint getPos(const UView& view) const;
00098   
00099   virtual UPoint getPosOnScreen(UDisp* = null) const;
00101 
00102   // - - - size and stacking order - - - - - - - - - - - - - - - - - - - - - - -
00103 
00104   virtual float getWidth(UDisp* = null) const;
00106   
00107   virtual float getHeight(UDisp* = null) const;
00109 
00110   virtual UDimension getSize(UDisp* = null) const;
00112   
00113   virtual void setSize(const UDimension&, UDisp* = null);
00115 
00116   virtual void adjustSize();
00122   virtual void setFullScreen(bool state, UDisp* = null);
00124 
00125   virtual void toBack(UDisp* = null);
00127   
00128   virtual void toFront(UDisp* = null);
00130        
00131   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00132 
00133   virtual bool isShown() const;
00134   virtual bool isShown(UDisp*) const;
00136   
00137   virtual void show(bool state, UDisp*);
00138   virtual void show(bool state = true) {UWin::show(state, null);}
00146   virtual bool isModal() const;
00148   
00149   virtual void setModal(bool = true) ;
00151   
00152   virtual int showModal(UDisp* = null);
00163   virtual void close(int status = 0);
00174   virtual void repaint() {update(UUpdate::paint);}          // redefined from UBox
00175   virtual void update() {update(UUpdate::layoutAndPaint);}  // redefined from UBox
00176   virtual void update(const UUpdate& mode);                 // redefined from UBox
00177   
00178   virtual void update(const UUpdate&, UDisp*);
00187   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00188 
00189   bool isHardWin() const {return is_hardwin;}
00190   bool isSoftWin() const {return !is_hardwin;}
00201   virtual UWin& setSoftWin(bool = true);
00208   // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00209   
00210   static  UStyle* createStyle();  
00211 
00212   virtual bool realize();
00217   UNatWin* getNatWin(UDisp* = null) const;
00219   
00220   UView* getWinView(UDisp*) const;
00222   
00223   virtual void highlight(bool state);
00225 
00226 #ifndef NO_DOC
00227   friend class UBox;
00228   friend class UAppli;
00229   friend class UHardWinImpl;
00230   friend class USoftWinImpl;
00231   friend class UNatWin;
00232   friend class UNatDisp;
00233   
00234   virtual void initView(UChild* self, UView* ancestor_view);
00235   virtual UView* initViewImpl(UChild* self, UView* ancestor_view, UDisp*);
00236   virtual void deleteRelatedViews(UView* parview, UChild*);
00237   //NB: parview and link can be null for UWin::deleteRelatedViews
00238   
00239   void addWinView(UView*);
00240   UGroup* getSoftWins();
00241   UChildren* getSoftWinList(); 
00242   UHardWinImpl* hardImpl(UDisp*, const char* errmess = "") const;
00243   USoftWinImpl* softImpl(UDisp*, const char* errmess = "") const;
00244 
00245 protected:
00246   bool is_hardwin;
00247   std::vector<UWinImpl*> wimpl; // pour multiwins
00248   
00249   virtual UView* realizeSoftWin(UWin* hardwin, UView* hardwin_view,
00250                                 UDisp* disp, bool add_to_the_end);
00251   
00252   virtual bool realizeHardWin(unsigned short window_type);
00253   // internal realization function (window_type as defined in UNatWin).
00254   
00255   virtual void realizeChildren(UView* winview);
00256   // called by realize() to create the views of the children
00257   
00258   UView* getCurrentViewOfSoftwin() const;
00259 #endif
00260 };
00261 
00262 /* ==================================================== [Elc:] ======= */
00263 /* ==================================================== ====== ======= */
00272 class UDialog : public UWin {
00273 public:
00274   UBIT_ELEMENT_CLASS(UDialog, UWin)
00275   
00276   UDialog(const UArgs& = UArgs::none);
00277   friend UDialog& udialog(const UArgs& a = UArgs::none) {return *new UDialog(a);}
00279 
00280   virtual ~UDialog() {destructs();}
00281   
00282   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00283 
00284   virtual void show(bool state, UDisp*);
00285   virtual void show(bool state = true) {UDialog::show(state, null);}
00286 
00287   // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00288 
00289   static  UStyle* createStyle();
00290   virtual bool realize();
00291 
00292 #ifndef NO_DOC
00293   virtual void addingTo(UChild* self, UGroup *parent);
00294   virtual void removingFrom(UChild* self, UGroup *parent);  
00295 private:
00296   UCall* open_call;
00297 #endif
00298 };
00299 
00300 /* ==================================================== [Elc:] ======= */
00301 /* ==================================================== ====== ======= */
00312 class UFrame : public UDialog {
00313 public: 
00314   UBIT_ELEMENT_CLASS(UFrame, UDialog)
00315 
00316   UFrame(const UArgs& a = UArgs::none);
00318 
00319   friend UFrame& uframe(const UArgs& a = UArgs::none) {return *new UFrame(a);}
00321 
00322   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00323 
00324   bool isMainFrame() const {return is_main_frame;}
00326 
00327   virtual void show(bool state, UDisp*);
00328   virtual void show(bool state = true) {UFrame::show(state, null);}
00329 
00330   virtual void close(int status = 0);
00336   // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00337   
00338   static UStyle* createStyle();
00339   virtual bool realize();
00340   
00341 private:
00342   friend class UAppli;
00343   bool is_main_frame;
00344 };
00345 
00346 /* ==================================================== [Elc:] ======= */
00347 /* ==================================================== ====== ======= */
00360 struct UPlacement {
00361   UPlacement();
00362 
00363   // Horizontal placement. 
00364   // -- Explicit if &uleft() or &uright()
00365   // -- Default placement if null or other UHalign values.
00366   UHalign* halign;
00367 
00368   // vertical placement. Explicit if &utop() or &ubottom()
00369   UValign* valign;
00370 
00371   // Relative location from reference object:
00372   //
00373   // if oppositeBorder is true:
00374   //    the specified border (eg. uleft()) of the reference object is 
00375   //    aligned with the OPPOSITE border of 'this' object (eg. right)
00376   //    --> this implies that 'this' object will be located OUTSIDE
00377   //    the ref. object (exemple: a cascaded submenu located on the
00378   //    right side of its parent menu)
00379   //
00380   // if oppositeBorder is false:
00381   //    same borders are used for both objects (eg. both left
00382   //    sides are aligned together)
00383   //    --> this implies that 'this' object will be located INSIDE
00384   //    the ref. object (in the same way as for usual UH/Valign rules)
00385 
00386   bool hoppositeBorder, voppositeBorder;
00387 
00388   // relative 'distance' between reference and 'this' object borders.
00389   // Usually 1 or 0. Can be < 0 as it is a relative 'distance'.
00390   int hdist, vdist;
00391 };
00392 
00393 }
00394 #endif
00395 /* ==================================================== [TheEnd] ======= */
00396 /* ==================================================== [(c)Elc] ======= */
00397 
00398 

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