Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

uwin.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uwin.hpp
00004  *  Ubit Project  [Elc][2003]
00005  *  Author: Eric Lecolinet
00006  *
00007  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00008  *
00009  *  (C) 1999-2003 Eric Lecolinet @ ENST Paris
00010  *  WWW: http://www.enst.fr/~elc/ubit   Email: elc@enst.fr (subject: ubit)
00011  *
00012  * ***********************************************************************
00013  * COPYRIGHT NOTICE : 
00014  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00015  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00016  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00017  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00018  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00019  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00020  * ***********************************************************************
00021  *
00022  * ==================================================== [Elc:03] ======= *
00023  * ==================================================== ======== ======= */
00024 
00025 #ifndef _uwin_hpp_
00026 #define _uwin_hpp_
00027 //pragma ident  "@(#)uwin.hpp   ubit:03.06.04"
00028 #include <ubit/ubox.hpp>
00029 #include <ubit/uview.hpp>
00030 
00053 class UWin : public UBox {
00054 public:
00055   static UStyle *style;
00056 
00057   UWin(const UArgs&);
00059 
00060   virtual ~UWin();
00062 
00063   virtual class UWin* winCast() {return this;}
00064 
00065   virtual const UStyle& getStyle(UContext*) const {return makeStyle();}
00066   static  const UStyle& makeStyle();
00067 
00068   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00069 
00070   virtual void move(UWin*, u_pos x_in_win, u_pos y_in_win, UDisp* = null);
00072   
00073   virtual void move(class UView*, u_pos x_in_view, u_pos y_in_view);
00075   
00076   virtual void move(class UView*, class UPlacement&);
00078   
00079   virtual void move(class UEvent*, u_pos x_offset, u_pos y_offset);
00080   virtual void move(class UEvent&, u_pos x_offset, u_pos y_offset);
00082   
00083   virtual void moveOnScreen(u_pos x_in_screen, u_pos y_in_screen, UDisp* = null);
00085   
00086   virtual void moveAndCenter(UDisp* = null);
00088   
00089   virtual bool where(UWin*, u_pos &x, u_pos &y, UDisp* = null) const;
00091   
00092   virtual bool where(class UView*, u_pos &x, u_pos &y) const;
00094   
00095   virtual bool whereOnScreen(u_pos &x, u_pos &y, UDisp* = null) const;
00097   
00098   virtual void resize(u_dim width, u_dim height, UDisp* = null);
00100   
00101   virtual bool getSize(u_dim& width, u_dim& height, UDisp* = null) const;
00102   virtual u_dim getWidth( UDisp* = null) const;
00103   virtual u_dim getHeight( UDisp* = null) const;  
00105 
00106   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00107 
00108   virtual void highlight(bool state);
00109 
00110   virtual void close(int status = 0);
00124   virtual int lock(UDisp* = null);
00137   virtual void show(bool state, UDisp*);
00138   virtual void show(bool state = true);  //polymorphism
00147   virtual bool isShown() const;
00149 
00150   virtual void setModal(bool) ;
00152 
00153   virtual bool isModal() const;
00155 
00156   virtual void toBack(); 
00158  
00159   virtual void toFront();
00161 
00162   virtual void update();
00163   virtual void update(class UUpdate upmode);   //polymorphism
00164   virtual void update(class UUpdate upmode, UDisp*); 
00176   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00177 
00178   class UView* getWinViews() const {return winviews;}
00179   class UView* getWinView(class UDisp*) const;
00181 
00182   class UAppli* getAppli() const;
00184 
00185   //class UDisp* getDisp()  const {return winview ? winview->getDisp() : null;}
00187 
00188   virtual void setSoftwinMode(bool = true);
00189   UWin& softwin() {setSoftwinMode(true); return *this;}
00196   bool isHardwin() const {return is_hardwin;}
00197   bool isSoftwin() const {return !is_hardwin;}
00209   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00210   // implementation
00211 
00212   virtual bool realize() = 0;
00220   class UWinGraph* getWinGraph(class UDisp* = null) const;
00222 
00223   class UNatWin* getNatWin(class UDisp* = null) const;
00225 
00226 #ifndef NO_DOC
00227 
00228   friend class UBox;
00229   friend class UAppli;
00230   friend class UBoxLink;
00231   friend class UHardwinImpl;
00232   friend class USoftwinImpl;
00233   friend class UNatWin;
00234   friend class UNatDisp;
00235   
00236   class ULink* getSubSoftwinLink() const;
00237   void addWinView(class UView*);
00238   
00239   virtual void initView(ULink* selflink, UView* ancestor_view);
00240   virtual UView* _initView(ULink* selflink, UView* ancestor_view, UDisp*);
00241   virtual void deleteRelatedViews(class UView* parview, class ULink*);
00242   //NB: parview and link can be null for UWin::deleteRelatedViews
00243   
00244 protected:
00245   bool  is_hardwin;
00246   class UView* winviews;
00247   union {
00248     void* initialized;          // null if not initialized
00249     class USoftwinImpl* soft;
00250     class UHardwinImpl* hard;
00251   } impl;
00252 
00253   virtual UView* realizeSoftwin(UWin* hardwin, UView* hardwin_view);
00254   virtual bool realizeHardwin(bool (*xrealize)(class UNatDisp*, 
00255                                                class UNatWin*, UWin*));
00257 
00258   virtual void realizeChildren(class UView* winview);
00260 
00261 #endif
00262 };
00263 
00264 /* ==================================================== [Elc:03] ======= */
00265 /* ==================================================== ======== ======= */
00266 
00281 class UDialog : public UWin {
00282 public:
00283   static UStyle *style;
00284 
00285   UDialog(const UArgs& = UArgs::none);
00287 
00288   friend UDialog& udialog(const UArgs& a = UArgs::none) {return *new UDialog(a);}
00290 
00291   virtual ~UDialog() {destructs();}
00292 
00293   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00294 
00295   virtual void show(bool state, UDisp*);
00296   virtual void show(bool state = true);
00297   virtual bool realize();
00298 
00299   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00300 
00301   virtual const UStyle& getStyle(UContext*) const {return makeStyle();}
00302   static  const UStyle& makeStyle();
00303 
00304 #ifndef NO_DOC
00305   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00306   // implementation
00307 
00308   virtual void addingTo(class ULink *selflink, UGroup *parent);
00309   virtual void removingFrom(class ULink *selflink, UGroup *parent);
00311 
00312 private:
00313   UCall* open_call;
00314 #endif
00315 };
00316 
00317 /* ==================================================== [Elc:03] ======= */
00318 /* ==================================================== ======== ======= */
00319 
00335 class UFrame : public UDialog {
00336   friend class UAppli;
00337   bool is_main_frame;
00338 public:
00339   static UStyle *style;
00340  
00341   UFrame(const UArgs& a = UArgs::none);
00343 
00344   friend UFrame& uframe(const UArgs& a = UArgs::none) {return *new UFrame(a);}
00346 
00347   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00348 
00349   virtual const UStyle& getStyle(UContext*) const {return makeStyle();}
00350   static  const UStyle& makeStyle();
00351 
00352   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00353 
00354   virtual void close(int status);
00360   bool isMainFrame() const {return is_main_frame;}
00362 
00363   virtual bool realize();
00364 };
00365 
00366 /* ==================================================== [Elc:03] ======= */
00367 /* ==================================================== ======== ======= */
00368 
00371 class UPlacement {
00372 public:
00373   // Horizontal placement. 
00374   // -- Explicit if &uleft() or &uright()
00375   // -- Default placement if null or other UHalign values.
00376   class UHalign *halign;
00377 
00378   // vertical placement. Explicit if &utop() or &ubottom()
00379   class UValign *valign;
00380 
00381   // Relative location from reference object:
00382   //
00383   // if oppositeBorder is true:
00384   //    the specified border (eg. uleft()) of the reference object is 
00385   //    aligned with the OPPOSITE border of 'this' object (eg. right)
00386   //    --> this implies that 'this' object will be located OUTSIDE
00387   //    the ref. object (exemple: a cascaded submenu located on the
00388   //    right side of its parent menu)
00389   //
00390   // if oppositeBorder is false:
00391   //    same borders are used for both objects (eg. both left
00392   //    sides are aligned together)
00393   //    --> this implies that 'this' object will be located INSIDE
00394   //    the ref. object (in the same way as for usual UH/Valign rules)
00395 
00396   bool hoppositeBorder, voppositeBorder;
00397 
00398   // relative 'distance' between reference and 'this' object borders.
00399   // Usually 1 or 0. Can be < 0 as it is a relative 'distance'.
00400   u_dim hdist, vdist;
00401 
00402   UPlacement();
00403 };
00404 
00405 // Examples (R = reference object, T = this object)
00406 // --  RR TT   hplace = uright(),  hoppositeBorder = true,  hdist = 9
00407 //     RR      vplace = utop(),    hoppositeBorder = false, vdist = 0
00408 //
00409 // --  RR      hplace = uleft(),   hoppositeBorder  = false, hdist = 0
00410 //     RR      vplace = ubottom(), hoppositeBorder  = true,  vdist = 1
00411 //     TT
00412 //
00413 // --  TT      hplace = uleft(),   hoppositeBorder = true,  hdist = 0
00414 //     TTRR    vplace = ubottom(), hoppositeBorder = false, vdist = 0
00415 
00416 
00417 /* ==================================================== [Elc:03] ======= */
00418 /* ==================================================== ======== ======= */
00419 
00428 class UIncrust : public UWin {
00429 public:
00430   static UStyle *style;
00431 
00432   UIncrust(const UArgs& a = UArgs::none);
00433   virtual ~UIncrust();
00434 
00435   friend UIncrust& uincrust(const UArgs& a = UArgs::none);
00437 
00438   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00439 
00440   virtual const UStyle& getStyle(UContext*) const {return makeStyle();}
00441   static  const UStyle& makeStyle();
00442 
00443   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00444 
00445   virtual unsigned long getXWin() const {return xwin;}
00447 
00448   virtual void setExternalXWin(unsigned long external_xwin);
00454   virtual bool isExternalXWin() const {return is_external_win;}
00460   virtual bool realize();
00461 
00462   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00463   // Impl.
00464 
00465   virtual void initView(ULink* selflink, UView* ancestor_view);
00466   // [impl: must be redefined to init parent view]
00467 
00468 private:
00469   friend class UNatWin;
00470   bool is_external_win;
00471   unsigned long xwin;
00472 };
00473 
00474 #endif
00475 /* ==================================================== [TheEnd] ======= */
00476 /* ==================================================== [Elc:03] ======= */
00477 
00478 

Generated on Sat Feb 21 23:28:21 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.5