ROOT logo
// @(#)root/gui:$Id$
// Author: Brett Viren   04/15/2001

/*************************************************************************
 * Copyright (C) 2001, Brett Viren                                       *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGTableLayout
#define ROOT_TGTableLayout

#ifndef ROOT_TGLayout
#include "TGLayout.h"
#endif


// extension of ELayoutHints
enum ETableLayoutHints {
   kLHintsShrinkX = BIT(8),
   kLHintsShrinkY = BIT(9),
   kLHintsFillX   = BIT(10),
   kLHintsFillY   = BIT(11)
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGTableLayoutHints                                                   //
//                                                                      //
// This class describes layout hints used by the TGTableLayout class.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGTableLayoutHints : public TGLayoutHints {

private:
   TGTableLayoutHints(const TGTableLayoutHints&); // Not implemented
   TGTableLayoutHints& operator=(const TGTableLayoutHints&); // Not implemented

protected:
   UInt_t fAttachLeft;         // Column/row division number on which
   UInt_t fAttachRight;        // to attach the frame.  Starts at 0
   UInt_t fAttachTop;          // and goes to # columns / # rows
   UInt_t fAttachBottom;       // respectively

public:
   TGTableLayoutHints(UInt_t attach_left, UInt_t attach_right,
                      UInt_t attach_top, UInt_t attach_bottom,
                      ULong_t hints = kLHintsNormal,
                      UInt_t padleft = 0, UInt_t padright = 0,
                      UInt_t padtop = 0, UInt_t padbottom = 0)
      : TGLayoutHints(hints,padleft,padright,padtop,padbottom),
         fAttachLeft(attach_left),
         fAttachRight(attach_right),
         fAttachTop(attach_top),
         fAttachBottom(attach_bottom) { }
   virtual ~TGTableLayoutHints() { }

   UInt_t GetAttachLeft() const { return fAttachLeft; }
   UInt_t GetAttachRight() const { return fAttachRight; }
   UInt_t GetAttachTop() const { return fAttachTop; }
   UInt_t GetAttachBottom() const { return fAttachBottom; }
   virtual void SavePrimitive(ostream &out, Option_t * = "");

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


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGTableLayout                                                        //
//                                                                      //
// A LayoutManager which places child frames in a table. This uses      //
// TGTableLayoutHints (not TGLayoutHints). See TGTableLayoutHints       //
// for how to use these. This manager works like TGMatrixLayout with    //
// the addition that:                                                   //
//  - Child frames can span more than one column/row.                   //
//  - Child frames can resize with the frame.                           //
//  - Column and row sizes are not fixed nor (optionally) homogeneous.  //
//  - The number of columns and rows must be fully specified.           //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGTableLayout : public TGLayoutManager {

private:
   TGTableLayout(const TGTableLayout&); // Not implemented
   TGTableLayout& operator=(const TGTableLayout&); // Not implemented

protected:
   struct TableData_t {
      UInt_t fDefSize;        // Default size of col/rows
      UInt_t fRealSize;       // Real size of col/rows (eg, if table resize)
      Bool_t fNeedExpand;
      Bool_t fNeedShrink;
      Bool_t fExpand;
      Bool_t fShrink;
      Bool_t fEmpty;
   };
   TableData_t        *fRow;          // info about each row
   TableData_t        *fCol;          // info about each column
   TGCompositeFrame   *fMain;         // container frame
   TList              *fList;         // list of frames to arrange
   Bool_t              fHomogeneous;  // all cols/rows same size

   void FindRowColSizes();
   void FindRowColSizesInit();
   void FindRowColSizesHomogeneous();
   void FindRowColSizesSinglyAttached();
   void FindRowColSizesMultiplyAttached();

   void SetRowColSizes();
   void SetRowColSizesInit();

   void CheckSanity();

   static void SetRowColResize(UInt_t real_size, UInt_t nthings,
                               TableData_t *thing, Bool_t homogeneous);

public:
   // these are public in TGMatrixLayout ???  Perpetuate it.
   Int_t   fSep;               // interval between frames
   Int_t   fHints;             // layout hints (currently not used)
   UInt_t  fNrows;             // number of rows
   UInt_t  fNcols;             // number of columns

   TGTableLayout(TGCompositeFrame *main, UInt_t nrows, UInt_t ncols,
                 Bool_t homogeneous = kFALSE, Int_t sep = 0, Int_t hints = 0);
   virtual ~TGTableLayout();

   virtual void Layout();
   virtual TGDimension GetDefaultSize() const; // return sum of all child sizes
   virtual void SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGTableLayout,0)  // Table layout manager
};

#endif
 TGTableLayout.h:1
 TGTableLayout.h:2
 TGTableLayout.h:3
 TGTableLayout.h:4
 TGTableLayout.h:5
 TGTableLayout.h:6
 TGTableLayout.h:7
 TGTableLayout.h:8
 TGTableLayout.h:9
 TGTableLayout.h:10
 TGTableLayout.h:11
 TGTableLayout.h:12
 TGTableLayout.h:13
 TGTableLayout.h:14
 TGTableLayout.h:15
 TGTableLayout.h:16
 TGTableLayout.h:17
 TGTableLayout.h:18
 TGTableLayout.h:19
 TGTableLayout.h:20
 TGTableLayout.h:21
 TGTableLayout.h:22
 TGTableLayout.h:23
 TGTableLayout.h:24
 TGTableLayout.h:25
 TGTableLayout.h:26
 TGTableLayout.h:27
 TGTableLayout.h:28
 TGTableLayout.h:29
 TGTableLayout.h:30
 TGTableLayout.h:31
 TGTableLayout.h:32
 TGTableLayout.h:33
 TGTableLayout.h:34
 TGTableLayout.h:35
 TGTableLayout.h:36
 TGTableLayout.h:37
 TGTableLayout.h:38
 TGTableLayout.h:39
 TGTableLayout.h:40
 TGTableLayout.h:41
 TGTableLayout.h:42
 TGTableLayout.h:43
 TGTableLayout.h:44
 TGTableLayout.h:45
 TGTableLayout.h:46
 TGTableLayout.h:47
 TGTableLayout.h:48
 TGTableLayout.h:49
 TGTableLayout.h:50
 TGTableLayout.h:51
 TGTableLayout.h:52
 TGTableLayout.h:53
 TGTableLayout.h:54
 TGTableLayout.h:55
 TGTableLayout.h:56
 TGTableLayout.h:57
 TGTableLayout.h:58
 TGTableLayout.h:59
 TGTableLayout.h:60
 TGTableLayout.h:61
 TGTableLayout.h:62
 TGTableLayout.h:63
 TGTableLayout.h:64
 TGTableLayout.h:65
 TGTableLayout.h:66
 TGTableLayout.h:67
 TGTableLayout.h:68
 TGTableLayout.h:69
 TGTableLayout.h:70
 TGTableLayout.h:71
 TGTableLayout.h:72
 TGTableLayout.h:73
 TGTableLayout.h:74
 TGTableLayout.h:75
 TGTableLayout.h:76
 TGTableLayout.h:77
 TGTableLayout.h:78
 TGTableLayout.h:79
 TGTableLayout.h:80
 TGTableLayout.h:81
 TGTableLayout.h:82
 TGTableLayout.h:83
 TGTableLayout.h:84
 TGTableLayout.h:85
 TGTableLayout.h:86
 TGTableLayout.h:87
 TGTableLayout.h:88
 TGTableLayout.h:89
 TGTableLayout.h:90
 TGTableLayout.h:91
 TGTableLayout.h:92
 TGTableLayout.h:93
 TGTableLayout.h:94
 TGTableLayout.h:95
 TGTableLayout.h:96
 TGTableLayout.h:97
 TGTableLayout.h:98
 TGTableLayout.h:99
 TGTableLayout.h:100
 TGTableLayout.h:101
 TGTableLayout.h:102
 TGTableLayout.h:103
 TGTableLayout.h:104
 TGTableLayout.h:105
 TGTableLayout.h:106
 TGTableLayout.h:107
 TGTableLayout.h:108
 TGTableLayout.h:109
 TGTableLayout.h:110
 TGTableLayout.h:111
 TGTableLayout.h:112
 TGTableLayout.h:113
 TGTableLayout.h:114
 TGTableLayout.h:115
 TGTableLayout.h:116
 TGTableLayout.h:117
 TGTableLayout.h:118
 TGTableLayout.h:119
 TGTableLayout.h:120
 TGTableLayout.h:121
 TGTableLayout.h:122
 TGTableLayout.h:123
 TGTableLayout.h:124
 TGTableLayout.h:125
 TGTableLayout.h:126
 TGTableLayout.h:127
 TGTableLayout.h:128
 TGTableLayout.h:129
 TGTableLayout.h:130
 TGTableLayout.h:131
 TGTableLayout.h:132
 TGTableLayout.h:133
 TGTableLayout.h:134
 TGTableLayout.h:135
 TGTableLayout.h:136
 TGTableLayout.h:137
 TGTableLayout.h:138
 TGTableLayout.h:139
 TGTableLayout.h:140
 TGTableLayout.h:141