TGLayout.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGLayout.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   02/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGLayout
00013 #define ROOT_TGLayout
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // A number of different layout classes (TGLayoutManager,               //
00019 // TGVerticalLayout, TGHorizontalLayout, TGLayoutHints, etc.).          //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #ifndef ROOT_TObject
00024 #include "TObject.h"
00025 #endif
00026 #ifndef ROOT_TGDimension
00027 #include "TGDimension.h"
00028 #endif
00029 #ifndef ROOT_TRefCnt
00030 #include "TRefCnt.h"
00031 #endif
00032 
00033 //---- layout hints
00034 
00035 enum ELayoutHints {
00036    kLHintsNoHints = 0,
00037    kLHintsLeft    = BIT(0),
00038    kLHintsCenterX = BIT(1),
00039    kLHintsRight   = BIT(2),
00040    kLHintsTop     = BIT(3),
00041    kLHintsCenterY = BIT(4),
00042    kLHintsBottom  = BIT(5),
00043    kLHintsExpandX = BIT(6),
00044    kLHintsExpandY = BIT(7),
00045    kLHintsNormal  = (kLHintsLeft | kLHintsTop)
00046    // bits 8-11 used by ETableLayoutHints
00047 };
00048 
00049 class TGFrame;
00050 class TGCompositeFrame;
00051 class TGLayoutHints;
00052 class TList;
00053 class TGFrameElement;
00054 
00055 //////////////////////////////////////////////////////////////////////////
00056 //                                                                      //
00057 // TGLayoutHints                                                        //
00058 //                                                                      //
00059 // This class describes layout hints used by the layout classes.        //
00060 //                                                                      //
00061 //////////////////////////////////////////////////////////////////////////
00062 
00063 class TGLayoutHints : public TObject, public TRefCnt {
00064 
00065 friend class TGFrameElement;
00066 friend class TGCompositeFrame;
00067 
00068 private:
00069    TGFrameElement *fFE;       // back pointer to the last frame element
00070    TGFrameElement *fPrev;     // previous element sharing this layout_hints
00071 
00072    TGLayoutHints& operator=(const TGLayoutHints&);
00073 
00074 protected:
00075    ULong_t  fLayoutHints;     // layout hints (combination of ELayoutHints)
00076    Int_t    fPadtop;          // amount of top padding
00077    Int_t    fPadbottom;       // amount of bottom padding
00078    Int_t    fPadleft;         // amount of left padding
00079    Int_t    fPadright;        // amount of right padding
00080 
00081    void UpdateFrameElements(TGLayoutHints *l);
00082 
00083 public:
00084    TGLayoutHints(ULong_t hints = kLHintsNormal,
00085                  Int_t padleft = 0, Int_t padright = 0,
00086                  Int_t padtop = 0, Int_t padbottom = 0):
00087      fFE(0), fPrev(0), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
00088      fPadleft(padleft), fPadright(padright)
00089      { SetRefCount(0); }
00090 
00091    TGLayoutHints(const TGLayoutHints &lh);
00092 
00093    virtual ~TGLayoutHints();
00094 
00095    ULong_t GetLayoutHints() const { return fLayoutHints; }
00096    Int_t   GetPadTop() const { return fPadtop; }
00097    Int_t   GetPadBottom() const { return fPadbottom; }
00098    Int_t   GetPadLeft() const { return fPadleft; }
00099    Int_t   GetPadRight() const { return fPadright; }
00100 
00101    virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
00102    virtual void SetPadTop(Int_t v)  {  fPadtop = v; }
00103    virtual void SetPadBottom(Int_t v)  {  fPadbottom = v; }
00104    virtual void SetPadLeft(Int_t v)  {  fPadleft = v; }
00105    virtual void SetPadRight(Int_t v)  {  fPadright = v; }
00106 
00107    void Print(Option_t* option = "") const;
00108    void ls(Option_t* option = "") const { Print(option); }
00109 
00110    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00111 
00112    ClassDef(TGLayoutHints,0)  // Class describing GUI layout hints
00113 };
00114 
00115 // Temporarily public as we need to share this class definition
00116 // with the frame manager class
00117 
00118 class TGFrameElement : public TObject {
00119 
00120 private:
00121    TGFrameElement(const TGFrameElement&);
00122    TGFrameElement& operator=(const TGFrameElement&);
00123 
00124 public:
00125    TGFrame        *fFrame;    // frame used in layout
00126    Int_t           fState;    // EFrameState defined in TGFrame.h
00127    TGLayoutHints  *fLayout;   // layout hints used in layout
00128 
00129    TGFrameElement() : fFrame(0), fState(0), fLayout(0) { }
00130    TGFrameElement(TGFrame *f, TGLayoutHints *l);
00131    ~TGFrameElement();
00132 
00133    void Print(Option_t* option = "") const;
00134    void ls(Option_t* option = "") const { Print(option); }
00135 
00136    ClassDef(TGFrameElement, 0); // Base class used in GUI containers
00137 };
00138 
00139 
00140 //////////////////////////////////////////////////////////////////////////
00141 //                                                                      //
00142 // TGLayoutManager                                                      //
00143 //                                                                      //
00144 // Frame layout manager. This is an abstract class.                     //
00145 //                                                                      //
00146 //////////////////////////////////////////////////////////////////////////
00147 
00148 class TGLayoutManager : public TObject {
00149 protected:
00150    Bool_t            fModified;// kTRUE if positions of subframes changed after layout
00151 
00152 public:
00153    TGLayoutManager() : fModified(kTRUE) {}
00154 
00155    virtual void Layout() = 0;
00156    virtual TGDimension GetDefaultSize() const = 0;
00157    virtual void SetDefaultWidth(UInt_t /* w */) {}
00158    virtual void SetDefaultHeight(UInt_t /* h */) {}
00159    virtual Bool_t IsModified() const { return fModified; }
00160    virtual void   SetModified(Bool_t flag = kTRUE) { fModified = flag; }
00161 
00162    ClassDef(TGLayoutManager,0)  // Layout manager abstract base class
00163 };
00164 
00165 
00166 //////////////////////////////////////////////////////////////////////////
00167 //                                                                      //
00168 // TGVerticalLayout and TGHorizontalLayout managers.                    //
00169 //                                                                      //
00170 //////////////////////////////////////////////////////////////////////////
00171 
00172 class TGVerticalLayout : public TGLayoutManager {
00173 
00174 protected:
00175    TGCompositeFrame  *fMain;     // container frame
00176    TList             *fList;     // list of frames to arrange
00177 
00178    TGVerticalLayout(const TGVerticalLayout& gvl) :
00179      TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
00180    TGVerticalLayout& operator=(const TGVerticalLayout& gvl)
00181      {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
00182      fMain=gvl.fMain; fList=gvl.fList;} return *this;}
00183 
00184 public:
00185    TGVerticalLayout(TGCompositeFrame *main);
00186 
00187    virtual void Layout();
00188    virtual TGDimension GetDefaultSize() const;
00189    virtual void SavePrimitive(ostream &out, Option_t * = "");
00190 
00191    ClassDef(TGVerticalLayout,0)  // Vertical layout manager
00192 };
00193 
00194 class TGHorizontalLayout : public TGVerticalLayout {
00195 public:
00196    TGHorizontalLayout(TGCompositeFrame *main) : TGVerticalLayout(main) { }
00197 
00198    virtual void Layout();
00199    virtual TGDimension GetDefaultSize() const;
00200    virtual void SavePrimitive(ostream &out, Option_t * = "");
00201 
00202    ClassDef(TGHorizontalLayout,0)  // Horizontal layout manager
00203 };
00204 
00205 
00206 //////////////////////////////////////////////////////////////////////////
00207 //                                                                      //
00208 // TGRowLayout and TGColumnLayout managers.                             //
00209 //                                                                      //
00210 // The follwing two layout managers do not make use of TGLayoutHints.   //
00211 //                                                                      //
00212 //////////////////////////////////////////////////////////////////////////
00213 
00214 class TGRowLayout : public TGVerticalLayout {
00215 public:
00216    Int_t   fSep;             // interval between frames
00217 
00218    TGRowLayout(TGCompositeFrame *main, Int_t s = 0) :
00219       TGVerticalLayout(main), fSep(s) { }
00220 
00221    virtual void Layout();
00222    virtual TGDimension GetDefaultSize() const;
00223    virtual void SavePrimitive(ostream &out, Option_t * = "");
00224 
00225    ClassDef(TGRowLayout,0)  // Row layout manager
00226 };
00227 
00228 class TGColumnLayout : public TGRowLayout {
00229 public:
00230    TGColumnLayout(TGCompositeFrame *main, Int_t s = 0) : TGRowLayout(main, s) { }
00231 
00232    virtual void Layout();
00233    virtual TGDimension GetDefaultSize() const;
00234    virtual void SavePrimitive(ostream &out, Option_t * = "");
00235 
00236    ClassDef(TGColumnLayout,0)  // Column layout manager
00237 };
00238 
00239 
00240 //////////////////////////////////////////////////////////////////////////
00241 //                                                                      //
00242 // TGMatrixLayout manager.                                              //
00243 //                                                                      //
00244 // This layout managers does not make use of TGLayoutHints.             //
00245 //                                                                      //
00246 //////////////////////////////////////////////////////////////////////////
00247 
00248 class TGMatrixLayout : public TGLayoutManager {
00249 
00250 private:
00251    TGMatrixLayout(const TGMatrixLayout&);
00252    TGMatrixLayout& operator=(const TGMatrixLayout&);
00253 
00254 protected:
00255    TGCompositeFrame *fMain;      // container frame
00256    TList            *fList;      // list of frames to arrange
00257 
00258 public:
00259    Int_t   fSep;                      // interval between frames
00260    Int_t   fHints;                    // layout hints (currently not used)
00261    UInt_t  fRows;                     // number of rows
00262    UInt_t  fColumns;                  // number of columns
00263 
00264    TGMatrixLayout(TGCompositeFrame *main, UInt_t r, UInt_t c, Int_t s=0, Int_t h=0);
00265 
00266    virtual void Layout();
00267    virtual TGDimension GetDefaultSize() const;
00268    virtual void SavePrimitive(ostream &out, Option_t * = "");
00269 
00270    ClassDef(TGMatrixLayout,0)  // Matrix layout manager
00271 };
00272 
00273 
00274 //////////////////////////////////////////////////////////////////////////
00275 //                                                                      //
00276 // TGTileLayout, TGListLayout and TGListDetailsLayout managers.         //
00277 //                                                                      //
00278 // This are layout managers for the TGListView widget.                  //
00279 //                                                                      //
00280 //////////////////////////////////////////////////////////////////////////
00281 
00282 class TGTileLayout : public TGLayoutManager {
00283 
00284 private:
00285    TGTileLayout(const TGTileLayout&);
00286    TGTileLayout& operator=(const TGTileLayout&);
00287 
00288 protected:
00289    Int_t             fSep;    // separation between tiles
00290    TGCompositeFrame *fMain;   // container frame
00291    TList            *fList;   // list of frames to arrange
00292    Bool_t            fModified;// layout changed
00293 
00294 
00295 public:
00296    TGTileLayout(TGCompositeFrame *main, Int_t sep = 0);
00297 
00298    virtual void Layout();
00299    virtual TGDimension GetDefaultSize() const;
00300    virtual Bool_t IsModified() const { return fModified; }
00301    virtual void SavePrimitive(ostream &out, Option_t * = "");
00302 
00303    ClassDef(TGTileLayout,0)  // Tile layout manager
00304 };
00305 
00306 class TGListLayout : public TGTileLayout {
00307 public:
00308    TGListLayout(TGCompositeFrame *main, Int_t sep = 0) :
00309       TGTileLayout(main, sep) { }
00310 
00311    virtual void Layout();
00312    virtual TGDimension GetDefaultSize() const;
00313    virtual void SavePrimitive(ostream &out, Option_t * = "");
00314 
00315    ClassDef(TGListLayout,0)  // Layout manager for TGListView widget
00316 };
00317 
00318 class TGListDetailsLayout : public TGTileLayout {
00319 private:
00320    UInt_t fWidth; // width of listview container
00321 
00322 public:
00323    TGListDetailsLayout(TGCompositeFrame *main, Int_t sep = 0, UInt_t w = 0) :
00324       TGTileLayout(main, sep), fWidth(w) { }
00325 
00326    virtual void Layout();
00327    virtual TGDimension GetDefaultSize() const;
00328    virtual void SetDefaultWidth(UInt_t w) { fWidth = w; }
00329    virtual void SavePrimitive(ostream &out, Option_t * = "");
00330 
00331    ClassDef(TGListDetailsLayout,0)  // Layout manager for TGListView details
00332 };
00333 
00334 #endif

Generated on Tue Jul 5 14:20:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1