Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:58

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   02/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGLayout
0013 #define ROOT_TGLayout
0014 
0015 
0016 #include "TObject.h"
0017 #include "TGDimension.h"
0018 #include "TRefCnt.h"
0019 
0020 //---- layout hints
0021 
0022 enum ELayoutHints {
0023    kLHintsNoHints = 0,
0024    kLHintsLeft    = BIT(0),
0025    kLHintsCenterX = BIT(1),
0026    kLHintsRight   = BIT(2),
0027    kLHintsTop     = BIT(3),
0028    kLHintsCenterY = BIT(4),
0029    kLHintsBottom  = BIT(5),
0030    kLHintsExpandX = BIT(6),
0031    kLHintsExpandY = BIT(7),
0032    kLHintsNormal  = (kLHintsLeft | kLHintsTop)
0033    // bits 8-11 used by ETableLayoutHints
0034 };
0035 
0036 class TGFrame;
0037 class TGCompositeFrame;
0038 class TGLayoutHints;
0039 class TList;
0040 class TGFrameElement;
0041 
0042 /** \class TGLayoutHints
0043     \ingroup guiwidgets
0044 
0045 This class describes layout hints used by the layout classes.
0046 
0047 */
0048 
0049 
0050 class TGLayoutHints : public TObject, public TRefCnt {
0051 
0052 friend class TGFrameElement;
0053 friend class TGCompositeFrame;
0054 
0055 private:
0056    TGFrameElement *fFE;       // back pointer to the last frame element
0057    TGFrameElement *fPrev;     // previous element sharing this layout_hints
0058 
0059    TGLayoutHints& operator=(const TGLayoutHints&) = delete;
0060 
0061 protected:
0062    ULong_t  fLayoutHints;     // layout hints (combination of ELayoutHints)
0063    Int_t    fPadtop;          // amount of top padding
0064    Int_t    fPadbottom;       // amount of bottom padding
0065    Int_t    fPadleft;         // amount of left padding
0066    Int_t    fPadright;        // amount of right padding
0067 
0068    void UpdateFrameElements(TGLayoutHints *l);
0069 
0070 public:
0071    TGLayoutHints(ULong_t hints = kLHintsNormal,
0072                  Int_t padleft = 0, Int_t padright = 0,
0073                  Int_t padtop = 0, Int_t padbottom = 0):
0074      fFE(nullptr), fPrev(nullptr), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
0075      fPadleft(padleft), fPadright(padright)
0076      { SetRefCount(0); }
0077 
0078    TGLayoutHints(const TGLayoutHints &lh);
0079 
0080    ~TGLayoutHints() override;
0081 
0082    ULong_t GetLayoutHints() const { return fLayoutHints; }
0083    Int_t   GetPadTop() const { return fPadtop; }
0084    Int_t   GetPadBottom() const { return fPadbottom; }
0085    Int_t   GetPadLeft() const { return fPadleft; }
0086    Int_t   GetPadRight() const { return fPadright; }
0087 
0088    virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
0089    virtual void SetPadTop(Int_t v)  {  fPadtop = v; }
0090    virtual void SetPadBottom(Int_t v)  {  fPadbottom = v; }
0091    virtual void SetPadLeft(Int_t v)  {  fPadleft = v; }
0092    virtual void SetPadRight(Int_t v)  {  fPadright = v; }
0093 
0094    void Print(Option_t* option = "") const override;
0095    void ls(Option_t* option = "") const override { Print(option); }
0096 
0097    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0098 
0099    ClassDefOverride(TGLayoutHints,0)  // Class describing GUI layout hints
0100 };
0101 
0102 // Temporarily public as we need to share this class definition
0103 // with the frame manager class
0104 
0105 class TGFrameElement : public TObject {
0106 
0107 private:
0108    TGFrameElement(const TGFrameElement&);
0109    TGFrameElement& operator=(const TGFrameElement&);
0110 
0111 public:
0112    TGFrame        *fFrame;    // frame used in layout
0113    Int_t           fState;    // EFrameState defined in TGFrame.h
0114    TGLayoutHints  *fLayout;   // layout hints used in layout
0115 
0116    TGFrameElement() : fFrame(nullptr), fState(0), fLayout(nullptr) { }
0117    TGFrameElement(TGFrame *f, TGLayoutHints *l);
0118    ~TGFrameElement() override;
0119 
0120    void Print(Option_t* option = "") const override;
0121    void ls(Option_t* option = "") const override { Print(option); }
0122 
0123    ClassDefOverride(TGFrameElement, 0); // Base class used in GUI containers
0124 };
0125 
0126 
0127 /** \class TGLayoutManager
0128     \ingroup guiwidgets
0129 
0130 Frame layout manager. This is an abstract class.
0131 
0132 */
0133 
0134 
0135 class TGLayoutManager : public TObject {
0136 protected:
0137    Bool_t            fModified;// kTRUE if positions of subframes changed after layout
0138 
0139 public:
0140    TGLayoutManager() : fModified(kTRUE) {}
0141 
0142    virtual void Layout() = 0;
0143    virtual TGDimension GetDefaultSize() const = 0;
0144    virtual void SetDefaultWidth(UInt_t /* w */) {}
0145    virtual void SetDefaultHeight(UInt_t /* h */) {}
0146    virtual Bool_t IsModified() const { return fModified; }
0147    virtual void SetModified(Bool_t flag = kTRUE) { fModified = flag; }
0148 
0149    ClassDefOverride(TGLayoutManager,0)  // Layout manager abstract base class
0150 };
0151 
0152 
0153 /** \class TGVerticalLayout
0154     \ingroup guiwidgets
0155 
0156 */
0157 
0158 
0159 class TGVerticalLayout : public TGLayoutManager {
0160 
0161 protected:
0162    TGCompositeFrame  *fMain;     // container frame
0163    TList             *fList;     // list of frames to arrange
0164 
0165    TGVerticalLayout(const TGVerticalLayout& gvl) :
0166      TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
0167    TGVerticalLayout& operator=(const TGVerticalLayout& gvl)
0168      {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
0169      fMain=gvl.fMain; fList=gvl.fList;} return *this;}
0170 
0171 public:
0172    TGVerticalLayout(TGCompositeFrame *main);
0173 
0174    void Layout() override;
0175    TGDimension GetDefaultSize() const override;
0176    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0177 
0178    ClassDefOverride(TGVerticalLayout,0)  // Vertical layout manager
0179 };
0180 
0181 /** \class TGHorizontalLayout
0182     \ingroup guiwidgets
0183 
0184 */
0185 
0186 
0187 class TGHorizontalLayout : public TGVerticalLayout {
0188 public:
0189    TGHorizontalLayout(TGCompositeFrame *main) : TGVerticalLayout(main) { }
0190 
0191    void Layout() override;
0192    TGDimension GetDefaultSize() const override;
0193    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0194 
0195    ClassDefOverride(TGHorizontalLayout,0)  // Horizontal layout manager
0196 };
0197 
0198 
0199 /** \class TGRowLayout
0200     \ingroup guiwidgets
0201 
0202 The following two layout managers do not make use of TGLayoutHints.
0203 
0204 */
0205 
0206 
0207 class TGRowLayout : public TGVerticalLayout {
0208 public:
0209    Int_t   fSep;             // interval between frames
0210 
0211    TGRowLayout(TGCompositeFrame *main, Int_t s = 0) :
0212       TGVerticalLayout(main), fSep(s) { }
0213 
0214    void Layout() override;
0215    TGDimension GetDefaultSize() const override;
0216    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0217 
0218    ClassDefOverride(TGRowLayout,0)  // Row layout manager
0219 };
0220 
0221 /** \class TGColumnLayout
0222     \ingroup guiwidgets
0223 
0224 The following layout manager do not make use of TGLayoutHints.
0225 
0226 */
0227 
0228 
0229 class TGColumnLayout : public TGRowLayout {
0230 public:
0231    TGColumnLayout(TGCompositeFrame *main, Int_t s = 0) : TGRowLayout(main, s) { }
0232 
0233    void Layout() override;
0234    TGDimension GetDefaultSize() const override;
0235    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0236 
0237    ClassDefOverride(TGColumnLayout,0)  // Column layout manager
0238 };
0239 
0240 
0241 /** \class TGMatrixLayout
0242     \ingroup guiwidgets
0243 
0244 This layout managers does not make use of TGLayoutHints.
0245 
0246 
0247 It arranges frames in a matrix-like way.
0248 This manager provides :
0249 - a column number (0 means unlimited)
0250 - a row number (0 means unlimited)
0251 - horizontal & vertical separators
0252 
0253 Notes : If both column and row are fixed values, any remaining
0254         frames outside the count won't be managed.
0255         Unlimited rows means the frame can expand downward
0256         (the default behaviour in most UI).
0257         Both unlimited rows and columns is undefined (read: will
0258         crash the algorithm ;-).
0259         With fixed dimensions, frames are always arranged in rows.
0260         That is: 1st frame is at position (0,0), next one is at
0261         row(0), column(1) and so on...
0262         When specifying one dimension as unlimited (i.e. row=0 or
0263         column=0) the frames are arranged according to the direction
0264         of the fixed dimension. This layout manager does not make
0265         use of TGLayoutHints.
0266 */
0267 
0268 
0269 class TGMatrixLayout : public TGLayoutManager {
0270 
0271 private:
0272    TGMatrixLayout(const TGMatrixLayout&) = delete;
0273    TGMatrixLayout& operator=(const TGMatrixLayout&) = delete;
0274 
0275 protected:
0276    TGCompositeFrame *fMain;           ///< container frame
0277    TList            *fList;           ///< list of frames to arrange
0278 
0279 public:
0280    Int_t   fSep;                      ///< interval between frames
0281    Int_t   fHints;                    ///< layout hints (currently not used)
0282    UInt_t  fRows;                     ///< number of rows
0283    UInt_t  fColumns;                  ///< number of columns
0284 
0285    TGMatrixLayout(TGCompositeFrame *main, UInt_t r, UInt_t c, Int_t s=0, Int_t h=0);
0286 
0287    void Layout() override;
0288    TGDimension GetDefaultSize() const override;
0289    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0290 
0291    ClassDefOverride(TGMatrixLayout,0)  // Matrix layout manager
0292 };
0293 
0294 
0295 /** \class TGTileLayout
0296     \ingroup guiwidgets
0297 
0298 This is a layout manager for the TGListView widget.
0299 
0300 */
0301 
0302 
0303 class TGTileLayout : public TGLayoutManager {
0304 
0305 private:
0306    TGTileLayout(const TGTileLayout&) = delete;
0307    TGTileLayout& operator=(const TGTileLayout&) = delete;
0308 
0309 protected:
0310    Int_t             fSep;     ///< separation between tiles
0311    TGCompositeFrame *fMain;    ///< container frame
0312    TList            *fList;     ///< list of frames to arrange
0313    Bool_t            fModified; ///< layout changed
0314 
0315 
0316 public:
0317    TGTileLayout(TGCompositeFrame *main, Int_t sep = 0);
0318 
0319    void Layout() override;
0320    TGDimension GetDefaultSize() const override;
0321    Bool_t IsModified() const override { return fModified; }
0322    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0323 
0324    ClassDefOverride(TGTileLayout,0)  // Tile layout manager
0325 };
0326 
0327 /** \class TGListLayout
0328     \ingroup guiwidgets
0329 
0330 This is a layout manager for the TGListView widget.
0331 
0332 */
0333 
0334 
0335 class TGListLayout : public TGTileLayout {
0336 public:
0337    TGListLayout(TGCompositeFrame *main, Int_t sep = 0) :
0338       TGTileLayout(main, sep) { }
0339 
0340    void Layout() override;
0341    TGDimension GetDefaultSize() const override;
0342    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0343 
0344    ClassDefOverride(TGListLayout,0)  // Layout manager for TGListView widget
0345 };
0346 
0347 /** \class TGListDetailsLayout
0348     \ingroup guiwidgets
0349 
0350 This is a layout manager for the TGListView widget.
0351 
0352 */
0353 
0354 
0355 class TGListDetailsLayout : public TGTileLayout {
0356 private:
0357    UInt_t fWidth; // width of listview container
0358 
0359 public:
0360    TGListDetailsLayout(TGCompositeFrame *main, Int_t sep = 0, UInt_t w = 0) :
0361       TGTileLayout(main, sep), fWidth(w) { }
0362 
0363    void Layout() override;
0364    TGDimension GetDefaultSize() const override;
0365    void SetDefaultWidth(UInt_t w) override { fWidth = w; }
0366    void SavePrimitive(std::ostream &out, Option_t * = "") override;
0367 
0368    ClassDefOverride(TGListDetailsLayout,0)  // Layout manager for TGListView details
0369 };
0370 
0371 #endif