TGTableLayout.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTableLayout.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Brett Viren   04/15/2001
00003 
00004 /*************************************************************************
00005  * Copyright (C) 2001, Brett Viren                                       *
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_TGTableLayout
00013 #define ROOT_TGTableLayout
00014 
00015 #ifndef ROOT_TGLayout
00016 #include "TGLayout.h"
00017 #endif
00018 
00019 
00020 // extension of ELayoutHints
00021 enum ETableLayoutHints {
00022    kLHintsShrinkX = BIT(8),
00023    kLHintsShrinkY = BIT(9),
00024    kLHintsFillX   = BIT(10),
00025    kLHintsFillY   = BIT(11)
00026 };
00027 
00028 
00029 //////////////////////////////////////////////////////////////////////////
00030 //                                                                      //
00031 // TGTableLayoutHints                                                   //
00032 //                                                                      //
00033 // This class describes layout hints used by the TGTableLayout class.   //
00034 //                                                                      //
00035 //////////////////////////////////////////////////////////////////////////
00036 
00037 class TGTableLayoutHints : public TGLayoutHints {
00038 
00039 private:
00040    TGTableLayoutHints(const TGTableLayoutHints&); // Not implemented
00041    TGTableLayoutHints& operator=(const TGTableLayoutHints&); // Not implemented
00042 
00043 protected:
00044    UInt_t fAttachLeft;         // Column/row division number on which
00045    UInt_t fAttachRight;        // to attach the frame.  Starts at 0
00046    UInt_t fAttachTop;          // and goes to # columns / # rows
00047    UInt_t fAttachBottom;       // respectively
00048 
00049 public:
00050    TGTableLayoutHints(UInt_t attach_left, UInt_t attach_right,
00051                       UInt_t attach_top, UInt_t attach_bottom,
00052                       ULong_t hints = kLHintsNormal,
00053                       UInt_t padleft = 0, UInt_t padright = 0,
00054                       UInt_t padtop = 0, UInt_t padbottom = 0)
00055       : TGLayoutHints(hints,padleft,padright,padtop,padbottom),
00056          fAttachLeft(attach_left),
00057          fAttachRight(attach_right),
00058          fAttachTop(attach_top),
00059          fAttachBottom(attach_bottom) { }
00060    virtual ~TGTableLayoutHints() { }
00061 
00062    UInt_t GetAttachLeft() const { return fAttachLeft; }
00063    UInt_t GetAttachRight() const { return fAttachRight; }
00064    UInt_t GetAttachTop() const { return fAttachTop; }
00065    UInt_t GetAttachBottom() const { return fAttachBottom; }
00066    virtual void SavePrimitive(ostream &out, Option_t * = "");
00067 
00068    ClassDef(TGTableLayoutHints,0)  // Class describing GUI table layout hints
00069 };
00070 
00071 
00072 //////////////////////////////////////////////////////////////////////////
00073 //                                                                      //
00074 // TGTableLayout                                                        //
00075 //                                                                      //
00076 // A LayoutManager which places child frames in a table. This uses      //
00077 // TGTableLayoutHints (not TGLayoutHints). See TGTableLayoutHints       //
00078 // for how to use these. This manager works like TGMatrixLayout with    //
00079 // the addition that:                                                   //
00080 //  - Child frames can span more than one column/row.                   //
00081 //  - Child frames can resize with the frame.                           //
00082 //  - Column and row sizes are not fixed nor (optionally) homogeneous.  //
00083 //  - The number of columns and rows must be fully specified.           //
00084 //                                                                      //
00085 //////////////////////////////////////////////////////////////////////////
00086 
00087 class TGTableLayout : public TGLayoutManager {
00088 
00089 private:
00090    TGTableLayout(const TGTableLayout&); // Not implemented
00091    TGTableLayout& operator=(const TGTableLayout&); // Not implemented
00092 
00093 protected:
00094    struct TableData_t {
00095       UInt_t fDefSize;        // Default size of col/rows
00096       UInt_t fRealSize;       // Real size of col/rows (eg, if table resize)
00097       Bool_t fNeedExpand;
00098       Bool_t fNeedShrink;
00099       Bool_t fExpand;
00100       Bool_t fShrink;
00101       Bool_t fEmpty;
00102    };
00103    TableData_t        *fRow;          // info about each row
00104    TableData_t        *fCol;          // info about each column
00105    TGCompositeFrame   *fMain;         // container frame
00106    TList              *fList;         // list of frames to arrange
00107    Bool_t              fHomogeneous;  // all cols/rows same size
00108 
00109    void FindRowColSizes();
00110    void FindRowColSizesInit();
00111    void FindRowColSizesHomogeneous();
00112    void FindRowColSizesSinglyAttached();
00113    void FindRowColSizesMultiplyAttached();
00114 
00115    void SetRowColSizes();
00116    void SetRowColSizesInit();
00117 
00118    void CheckSanity();
00119 
00120    static void SetRowColResize(UInt_t real_size, UInt_t nthings,
00121                                TableData_t *thing, Bool_t homogeneous);
00122 
00123 public:
00124    // these are public in TGMatrixLayout ???  Perpetuate it.
00125    Int_t   fSep;               // interval between frames
00126    Int_t   fHints;             // layout hints (currently not used)
00127    UInt_t  fNrows;             // number of rows
00128    UInt_t  fNcols;             // number of columns
00129 
00130    TGTableLayout(TGCompositeFrame *main, UInt_t nrows, UInt_t ncols,
00131                  Bool_t homogeneous = kFALSE, Int_t sep = 0, Int_t hints = 0);
00132    virtual ~TGTableLayout();
00133 
00134    virtual void Layout();
00135    virtual TGDimension GetDefaultSize() const; // return sum of all child sizes
00136    virtual void SavePrimitive(ostream &out, Option_t * = "");
00137 
00138    ClassDef(TGTableLayout,0)  // Table layout manager
00139 };
00140 
00141 #endif

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