ROOT logo
// @(#)root/gui:$Id$
// Author: Fons Rademakers   02/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLayout
#define ROOT_TGLayout


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// A number of different layout classes (TGLayoutManager,               //
// TGVerticalLayout, TGHorizontalLayout, TGLayoutHints, etc.).          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TGDimension
#include "TGDimension.h"
#endif
#ifndef ROOT_TRefCnt
#include "TRefCnt.h"
#endif

//---- layout hints

enum ELayoutHints {
   kLHintsNoHints = 0,
   kLHintsLeft    = BIT(0),
   kLHintsCenterX = BIT(1),
   kLHintsRight   = BIT(2),
   kLHintsTop     = BIT(3),
   kLHintsCenterY = BIT(4),
   kLHintsBottom  = BIT(5),
   kLHintsExpandX = BIT(6),
   kLHintsExpandY = BIT(7),
   kLHintsNormal  = (kLHintsLeft | kLHintsTop)
   // bits 8-11 used by ETableLayoutHints
};

class TGFrame;
class TGCompositeFrame;
class TGLayoutHints;
class TList;
class TGFrameElement;

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGLayoutHints                                                        //
//                                                                      //
// This class describes layout hints used by the layout classes.        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGLayoutHints : public TObject, public TRefCnt {

friend class TGFrameElement;
friend class TGCompositeFrame;

private:
   TGFrameElement *fFE;       // back pointer to the last frame element
   TGFrameElement *fPrev;     // previous element sharing this layout_hints

   TGLayoutHints& operator=(const TGLayoutHints&);

protected:
   ULong_t  fLayoutHints;     // layout hints (combination of ELayoutHints)
   Int_t    fPadtop;          // amount of top padding
   Int_t    fPadbottom;       // amount of bottom padding
   Int_t    fPadleft;         // amount of left padding
   Int_t    fPadright;        // amount of right padding

   void UpdateFrameElements(TGLayoutHints *l);

public:
   TGLayoutHints(ULong_t hints = kLHintsNormal,
                 Int_t padleft = 0, Int_t padright = 0,
                 Int_t padtop = 0, Int_t padbottom = 0):
     fFE(0), fPrev(0), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
     fPadleft(padleft), fPadright(padright)
     { SetRefCount(0); }

   TGLayoutHints(const TGLayoutHints &lh);

   virtual ~TGLayoutHints();

   ULong_t GetLayoutHints() const { return fLayoutHints; }
   Int_t   GetPadTop() const { return fPadtop; }
   Int_t   GetPadBottom() const { return fPadbottom; }
   Int_t   GetPadLeft() const { return fPadleft; }
   Int_t   GetPadRight() const { return fPadright; }

   virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
   virtual void SetPadTop(Int_t v)  {  fPadtop = v; }
   virtual void SetPadBottom(Int_t v)  {  fPadbottom = v; }
   virtual void SetPadLeft(Int_t v)  {  fPadleft = v; }
   virtual void SetPadRight(Int_t v)  {  fPadright = v; }

   void Print(Option_t* option = "") const;
   void ls(Option_t* option = "") const { Print(option); }

   virtual void SavePrimitive(ostream &out, Option_t *option = "");

   ClassDef(TGLayoutHints,0)  // Class describing GUI layout hints
};

// Temporarily public as we need to share this class definition
// with the frame manager class

class TGFrameElement : public TObject {

private:
   TGFrameElement(const TGFrameElement&);
   TGFrameElement& operator=(const TGFrameElement&);

public:
   TGFrame        *fFrame;    // frame used in layout
   Int_t           fState;    // EFrameState defined in TGFrame.h
   TGLayoutHints  *fLayout;   // layout hints used in layout

   TGFrameElement() : fFrame(0), fState(0), fLayout(0) { }
   TGFrameElement(TGFrame *f, TGLayoutHints *l);
   ~TGFrameElement();

   void Print(Option_t* option = "") const;
   void ls(Option_t* option = "") const { Print(option); }

   ClassDef(TGFrameElement, 0); // Base class used in GUI containers
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGLayoutManager                                                      //
//                                                                      //
// Frame layout manager. This is an abstract class.                     //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGLayoutManager : public TObject {
protected:
   Bool_t            fModified;// kTRUE if positions of subframes changed after layout

public:
   TGLayoutManager() : fModified(kTRUE) {}

   virtual void Layout() = 0;
   virtual TGDimension GetDefaultSize() const = 0;
   virtual void SetDefaultWidth(UInt_t /* w */) {}
   virtual void SetDefaultHeight(UInt_t /* h */) {}
   virtual Bool_t IsModified() const { return fModified; }
   virtual void   SetModified(Bool_t flag = kTRUE) { fModified = flag; }

   ClassDef(TGLayoutManager,0)  // Layout manager abstract base class
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGVerticalLayout and TGHorizontalLayout managers.                    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGVerticalLayout : public TGLayoutManager {

protected:
   TGCompositeFrame  *fMain;     // container frame
   TList             *fList;     // list of frames to arrange

   TGVerticalLayout(const TGVerticalLayout& gvl) :
     TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
   TGVerticalLayout& operator=(const TGVerticalLayout& gvl)
     {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
     fMain=gvl.fMain; fList=gvl.fList;} return *this;}

public:
   TGVerticalLayout(TGCompositeFrame *main);

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGVerticalLayout,0)  // Vertical layout manager
};

class TGHorizontalLayout : public TGVerticalLayout {
public:
   TGHorizontalLayout(TGCompositeFrame *main) : TGVerticalLayout(main) { }

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGHorizontalLayout,0)  // Horizontal layout manager
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGRowLayout and TGColumnLayout managers.                             //
//                                                                      //
// The follwing two layout managers do not make use of TGLayoutHints.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGRowLayout : public TGVerticalLayout {
public:
   Int_t   fSep;             // interval between frames

   TGRowLayout(TGCompositeFrame *main, Int_t s = 0) :
      TGVerticalLayout(main), fSep(s) { }

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGRowLayout,0)  // Row layout manager
};

class TGColumnLayout : public TGRowLayout {
public:
   TGColumnLayout(TGCompositeFrame *main, Int_t s = 0) : TGRowLayout(main, s) { }

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGColumnLayout,0)  // Column layout manager
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGMatrixLayout manager.                                              //
//                                                                      //
// This layout managers does not make use of TGLayoutHints.             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGMatrixLayout : public TGLayoutManager {

private:
   TGMatrixLayout(const TGMatrixLayout&);
   TGMatrixLayout& operator=(const TGMatrixLayout&);

protected:
   TGCompositeFrame *fMain;      // container frame
   TList            *fList;      // list of frames to arrange

public:
   Int_t   fSep;                      // interval between frames
   Int_t   fHints;                    // layout hints (currently not used)
   UInt_t  fRows;                     // number of rows
   UInt_t  fColumns;                  // number of columns

   TGMatrixLayout(TGCompositeFrame *main, UInt_t r, UInt_t c, Int_t s=0, Int_t h=0);

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGMatrixLayout,0)  // Matrix layout manager
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGTileLayout, TGListLayout and TGListDetailsLayout managers.         //
//                                                                      //
// This are layout managers for the TGListView widget.                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGTileLayout : public TGLayoutManager {

private:
   TGTileLayout(const TGTileLayout&);
   TGTileLayout& operator=(const TGTileLayout&);

protected:
   Int_t             fSep;    // separation between tiles
   TGCompositeFrame *fMain;   // container frame
   TList            *fList;   // list of frames to arrange
   Bool_t            fModified;// layout changed


public:
   TGTileLayout(TGCompositeFrame *main, Int_t sep = 0);

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual Bool_t IsModified() const { return fModified; }
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGTileLayout,0)  // Tile layout manager
};

class TGListLayout : public TGTileLayout {
public:
   TGListLayout(TGCompositeFrame *main, Int_t sep = 0) :
      TGTileLayout(main, sep) { }

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGListLayout,0)  // Layout manager for TGListView widget
};

class TGListDetailsLayout : public TGTileLayout {
private:
   UInt_t fWidth; // width of listview container

public:
   TGListDetailsLayout(TGCompositeFrame *main, Int_t sep = 0, UInt_t w = 0) :
      TGTileLayout(main, sep), fWidth(w) { }

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const;
   virtual void SetDefaultWidth(UInt_t w) { fWidth = w; }
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGListDetailsLayout,0)  // Layout manager for TGListView details
};

#endif
 TGLayout.h:1
 TGLayout.h:2
 TGLayout.h:3
 TGLayout.h:4
 TGLayout.h:5
 TGLayout.h:6
 TGLayout.h:7
 TGLayout.h:8
 TGLayout.h:9
 TGLayout.h:10
 TGLayout.h:11
 TGLayout.h:12
 TGLayout.h:13
 TGLayout.h:14
 TGLayout.h:15
 TGLayout.h:16
 TGLayout.h:17
 TGLayout.h:18
 TGLayout.h:19
 TGLayout.h:20
 TGLayout.h:21
 TGLayout.h:22
 TGLayout.h:23
 TGLayout.h:24
 TGLayout.h:25
 TGLayout.h:26
 TGLayout.h:27
 TGLayout.h:28
 TGLayout.h:29
 TGLayout.h:30
 TGLayout.h:31
 TGLayout.h:32
 TGLayout.h:33
 TGLayout.h:34
 TGLayout.h:35
 TGLayout.h:36
 TGLayout.h:37
 TGLayout.h:38
 TGLayout.h:39
 TGLayout.h:40
 TGLayout.h:41
 TGLayout.h:42
 TGLayout.h:43
 TGLayout.h:44
 TGLayout.h:45
 TGLayout.h:46
 TGLayout.h:47
 TGLayout.h:48
 TGLayout.h:49
 TGLayout.h:50
 TGLayout.h:51
 TGLayout.h:52
 TGLayout.h:53
 TGLayout.h:54
 TGLayout.h:55
 TGLayout.h:56
 TGLayout.h:57
 TGLayout.h:58
 TGLayout.h:59
 TGLayout.h:60
 TGLayout.h:61
 TGLayout.h:62
 TGLayout.h:63
 TGLayout.h:64
 TGLayout.h:65
 TGLayout.h:66
 TGLayout.h:67
 TGLayout.h:68
 TGLayout.h:69
 TGLayout.h:70
 TGLayout.h:71
 TGLayout.h:72
 TGLayout.h:73
 TGLayout.h:74
 TGLayout.h:75
 TGLayout.h:76
 TGLayout.h:77
 TGLayout.h:78
 TGLayout.h:79
 TGLayout.h:80
 TGLayout.h:81
 TGLayout.h:82
 TGLayout.h:83
 TGLayout.h:84
 TGLayout.h:85
 TGLayout.h:86
 TGLayout.h:87
 TGLayout.h:88
 TGLayout.h:89
 TGLayout.h:90
 TGLayout.h:91
 TGLayout.h:92
 TGLayout.h:93
 TGLayout.h:94
 TGLayout.h:95
 TGLayout.h:96
 TGLayout.h:97
 TGLayout.h:98
 TGLayout.h:99
 TGLayout.h:100
 TGLayout.h:101
 TGLayout.h:102
 TGLayout.h:103
 TGLayout.h:104
 TGLayout.h:105
 TGLayout.h:106
 TGLayout.h:107
 TGLayout.h:108
 TGLayout.h:109
 TGLayout.h:110
 TGLayout.h:111
 TGLayout.h:112
 TGLayout.h:113
 TGLayout.h:114
 TGLayout.h:115
 TGLayout.h:116
 TGLayout.h:117
 TGLayout.h:118
 TGLayout.h:119
 TGLayout.h:120
 TGLayout.h:121
 TGLayout.h:122
 TGLayout.h:123
 TGLayout.h:124
 TGLayout.h:125
 TGLayout.h:126
 TGLayout.h:127
 TGLayout.h:128
 TGLayout.h:129
 TGLayout.h:130
 TGLayout.h:131
 TGLayout.h:132
 TGLayout.h:133
 TGLayout.h:134
 TGLayout.h:135
 TGLayout.h:136
 TGLayout.h:137
 TGLayout.h:138
 TGLayout.h:139
 TGLayout.h:140
 TGLayout.h:141
 TGLayout.h:142
 TGLayout.h:143
 TGLayout.h:144
 TGLayout.h:145
 TGLayout.h:146
 TGLayout.h:147
 TGLayout.h:148
 TGLayout.h:149
 TGLayout.h:150
 TGLayout.h:151
 TGLayout.h:152
 TGLayout.h:153
 TGLayout.h:154
 TGLayout.h:155
 TGLayout.h:156
 TGLayout.h:157
 TGLayout.h:158
 TGLayout.h:159
 TGLayout.h:160
 TGLayout.h:161
 TGLayout.h:162
 TGLayout.h:163
 TGLayout.h:164
 TGLayout.h:165
 TGLayout.h:166
 TGLayout.h:167
 TGLayout.h:168
 TGLayout.h:169
 TGLayout.h:170
 TGLayout.h:171
 TGLayout.h:172
 TGLayout.h:173
 TGLayout.h:174
 TGLayout.h:175
 TGLayout.h:176
 TGLayout.h:177
 TGLayout.h:178
 TGLayout.h:179
 TGLayout.h:180
 TGLayout.h:181
 TGLayout.h:182
 TGLayout.h:183
 TGLayout.h:184
 TGLayout.h:185
 TGLayout.h:186
 TGLayout.h:187
 TGLayout.h:188
 TGLayout.h:189
 TGLayout.h:190
 TGLayout.h:191
 TGLayout.h:192
 TGLayout.h:193
 TGLayout.h:194
 TGLayout.h:195
 TGLayout.h:196
 TGLayout.h:197
 TGLayout.h:198
 TGLayout.h:199
 TGLayout.h:200
 TGLayout.h:201
 TGLayout.h:202
 TGLayout.h:203
 TGLayout.h:204
 TGLayout.h:205
 TGLayout.h:206
 TGLayout.h:207
 TGLayout.h:208
 TGLayout.h:209
 TGLayout.h:210
 TGLayout.h:211
 TGLayout.h:212
 TGLayout.h:213
 TGLayout.h:214
 TGLayout.h:215
 TGLayout.h:216
 TGLayout.h:217
 TGLayout.h:218
 TGLayout.h:219
 TGLayout.h:220
 TGLayout.h:221
 TGLayout.h:222
 TGLayout.h:223
 TGLayout.h:224
 TGLayout.h:225
 TGLayout.h:226
 TGLayout.h:227
 TGLayout.h:228
 TGLayout.h:229
 TGLayout.h:230
 TGLayout.h:231
 TGLayout.h:232
 TGLayout.h:233
 TGLayout.h:234
 TGLayout.h:235
 TGLayout.h:236
 TGLayout.h:237
 TGLayout.h:238
 TGLayout.h:239
 TGLayout.h:240
 TGLayout.h:241
 TGLayout.h:242
 TGLayout.h:243
 TGLayout.h:244
 TGLayout.h:245
 TGLayout.h:246
 TGLayout.h:247
 TGLayout.h:248
 TGLayout.h:249
 TGLayout.h:250
 TGLayout.h:251
 TGLayout.h:252
 TGLayout.h:253
 TGLayout.h:254
 TGLayout.h:255
 TGLayout.h:256
 TGLayout.h:257
 TGLayout.h:258
 TGLayout.h:259
 TGLayout.h:260
 TGLayout.h:261
 TGLayout.h:262
 TGLayout.h:263
 TGLayout.h:264
 TGLayout.h:265
 TGLayout.h:266
 TGLayout.h:267
 TGLayout.h:268
 TGLayout.h:269
 TGLayout.h:270
 TGLayout.h:271
 TGLayout.h:272
 TGLayout.h:273
 TGLayout.h:274
 TGLayout.h:275
 TGLayout.h:276
 TGLayout.h:277
 TGLayout.h:278
 TGLayout.h:279
 TGLayout.h:280
 TGLayout.h:281
 TGLayout.h:282
 TGLayout.h:283
 TGLayout.h:284
 TGLayout.h:285
 TGLayout.h:286
 TGLayout.h:287
 TGLayout.h:288
 TGLayout.h:289
 TGLayout.h:290
 TGLayout.h:291
 TGLayout.h:292
 TGLayout.h:293
 TGLayout.h:294
 TGLayout.h:295
 TGLayout.h:296
 TGLayout.h:297
 TGLayout.h:298
 TGLayout.h:299
 TGLayout.h:300
 TGLayout.h:301
 TGLayout.h:302
 TGLayout.h:303
 TGLayout.h:304
 TGLayout.h:305
 TGLayout.h:306
 TGLayout.h:307
 TGLayout.h:308
 TGLayout.h:309
 TGLayout.h:310
 TGLayout.h:311
 TGLayout.h:312
 TGLayout.h:313
 TGLayout.h:314
 TGLayout.h:315
 TGLayout.h:316
 TGLayout.h:317
 TGLayout.h:318
 TGLayout.h:319
 TGLayout.h:320
 TGLayout.h:321
 TGLayout.h:322
 TGLayout.h:323
 TGLayout.h:324
 TGLayout.h:325
 TGLayout.h:326
 TGLayout.h:327
 TGLayout.h:328
 TGLayout.h:329
 TGLayout.h:330
 TGLayout.h:331
 TGLayout.h:332
 TGLayout.h:333
 TGLayout.h:334