File indexing completed on 2025-01-18 10:11:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
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
0034 };
0035
0036 class TGFrame;
0037 class TGCompositeFrame;
0038 class TGLayoutHints;
0039 class TList;
0040 class TGFrameElement;
0041
0042
0043
0044
0045
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;
0057 TGFrameElement *fPrev;
0058
0059 TGLayoutHints& operator=(const TGLayoutHints&) = delete;
0060
0061 protected:
0062 ULong_t fLayoutHints;
0063 Int_t fPadtop;
0064 Int_t fPadbottom;
0065 Int_t fPadleft;
0066 Int_t fPadright;
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)
0100 };
0101
0102
0103
0104
0105 class TGFrameElement : public TObject {
0106
0107 private:
0108 TGFrameElement(const TGFrameElement&);
0109 TGFrameElement& operator=(const TGFrameElement&);
0110
0111 public:
0112 TGFrame *fFrame;
0113 Int_t fState;
0114 TGLayoutHints *fLayout;
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);
0124 };
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 class TGLayoutManager : public TObject {
0136 protected:
0137 Bool_t fModified;
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 ) {}
0145 virtual void SetDefaultHeight(UInt_t ) {}
0146 virtual Bool_t IsModified() const { return fModified; }
0147 virtual void SetModified(Bool_t flag = kTRUE) { fModified = flag; }
0148
0149 ClassDefOverride(TGLayoutManager,0)
0150 };
0151
0152
0153
0154
0155
0156
0157
0158
0159 class TGVerticalLayout : public TGLayoutManager {
0160
0161 protected:
0162 TGCompositeFrame *fMain;
0163 TList *fList;
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)
0179 };
0180
0181
0182
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)
0196 };
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 class TGRowLayout : public TGVerticalLayout {
0208 public:
0209 Int_t fSep;
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)
0219 };
0220
0221
0222
0223
0224
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)
0238 };
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
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;
0277 TList *fList;
0278
0279 public:
0280 Int_t fSep;
0281 Int_t fHints;
0282 UInt_t fRows;
0283 UInt_t fColumns;
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)
0292 };
0293
0294
0295
0296
0297
0298
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;
0311 TGCompositeFrame *fMain;
0312 TList *fList;
0313 Bool_t fModified;
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)
0325 };
0326
0327
0328
0329
0330
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)
0345 };
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355 class TGListDetailsLayout : public TGTileLayout {
0356 private:
0357 UInt_t fWidth;
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)
0369 };
0370
0371 #endif