ROOT logo
// @(#)root/eve:$Id: TGPack.h 29129 2009-06-22 09:39:20Z brun $
// Author: Matevz Tadel 2007

/*************************************************************************
 * Copyright (C) 1995-2007, 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_TGPack
#define ROOT_TGPack

#include "TGFrame.h"
#include "TGLayout.h"

class TGSplitter;


class  TGFrameElementPack : public TGFrameElement
{
private:
   TGFrameElementPack(const TGFrameElementPack&);            // Not implemented
   TGFrameElementPack& operator=(const TGFrameElementPack&); // Not implemented

public:
   Float_t fWeight;               // relative weight
   TGFrameElementPack* fSplitFE; //! cached varaible for optimisation

   TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = 0, Float_t weight = 1):
      TGFrameElement(frame, lh), fWeight(weight), fSplitFE(0) { }

   ClassDef(TGFrameElementPack, 0); // Class used in TGPack.
};

//==============================================================================

class TGPack : public TGCompositeFrame
{
private:
   TGPack(const TGPack&);            // Not implemented
   TGPack& operator=(const TGPack&); // Not implemented

protected:
   Bool_t         fVertical;
   Bool_t         fUseSplitters;
   Int_t          fSplitterLen;

   Int_t          fDragOverflow;  //!

   Float_t        fWeightSum;     // total sum of sub  frame weights
   Int_t          fNVisible;      //  number of visible frames

   Int_t          GetFrameLength(const TGFrame* f) const { return fVertical ? f->GetHeight() : f->GetWidth(); }
   Int_t          GetLength()                      const { return GetFrameLength(this); }
   Int_t          GetAvailableLength()             const;

   void           SetFrameLength  (TGFrame* f, Int_t len);
   void           SetFramePosition(TGFrame* f, Int_t pos);

   void           FindFrames(TGFrame* splitter, TGFrameElementPack*& f0, TGFrameElementPack*& f1) const;

   void           CheckSplitterVisibility();
   void           ResizeExistingFrames();
   void           RefitFramesToPack();

   void           AddFrameInternal(TGFrame *f, TGLayoutHints* l = 0, Float_t weight = 1);
   void           RemoveFrameInternal(TGFrame *f);


public:
   TGPack(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
          Pixel_t back = GetDefaultFrameBackground());
   TGPack(TGClient *c, Window_t id, const TGWindow *parent = 0);
   virtual ~TGPack();

   virtual void   AddFrameWithWeight(TGFrame *f, TGLayoutHints* l, Float_t w);
   virtual void   AddFrame(TGFrame *f, TGLayoutHints* l=0);

   virtual void   DeleteFrame(TGFrame *f);
   virtual void   RemoveFrame(TGFrame *f);
   virtual void   ShowFrame(TGFrame *f);
   virtual void   HideFrame(TGFrame *f);

   using          TGCompositeFrame::Resize;
   virtual void   Resize(UInt_t w = 0, UInt_t h = 0);

   using          TGCompositeFrame::MapSubwindows;
   virtual void   MapSubwindows();

   virtual void   MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0);
   virtual void   Layout();

   virtual void Dump() const;

   void EqualizeFrames();
   void HandleSplitterStart();
   void HandleSplitterResize(Int_t delta);

   // ----------------------------------------------------------------

   Bool_t GetVertical() const { return fVertical; }
   void   SetVertical(Bool_t x);

   // For now assume this is always true. Lenght of splitter = 4 pixels.
   Bool_t GetUseSplitters() const { return fUseSplitters; }
   void SetUseSplitters(Bool_t x) { fUseSplitters = x; }

   ClassDef(TGPack, 0); // Horizontal or vertical stack of frames.
};

#endif
 TGPack.h:1
 TGPack.h:2
 TGPack.h:3
 TGPack.h:4
 TGPack.h:5
 TGPack.h:6
 TGPack.h:7
 TGPack.h:8
 TGPack.h:9
 TGPack.h:10
 TGPack.h:11
 TGPack.h:12
 TGPack.h:13
 TGPack.h:14
 TGPack.h:15
 TGPack.h:16
 TGPack.h:17
 TGPack.h:18
 TGPack.h:19
 TGPack.h:20
 TGPack.h:21
 TGPack.h:22
 TGPack.h:23
 TGPack.h:24
 TGPack.h:25
 TGPack.h:26
 TGPack.h:27
 TGPack.h:28
 TGPack.h:29
 TGPack.h:30
 TGPack.h:31
 TGPack.h:32
 TGPack.h:33
 TGPack.h:34
 TGPack.h:35
 TGPack.h:36
 TGPack.h:37
 TGPack.h:38
 TGPack.h:39
 TGPack.h:40
 TGPack.h:41
 TGPack.h:42
 TGPack.h:43
 TGPack.h:44
 TGPack.h:45
 TGPack.h:46
 TGPack.h:47
 TGPack.h:48
 TGPack.h:49
 TGPack.h:50
 TGPack.h:51
 TGPack.h:52
 TGPack.h:53
 TGPack.h:54
 TGPack.h:55
 TGPack.h:56
 TGPack.h:57
 TGPack.h:58
 TGPack.h:59
 TGPack.h:60
 TGPack.h:61
 TGPack.h:62
 TGPack.h:63
 TGPack.h:64
 TGPack.h:65
 TGPack.h:66
 TGPack.h:67
 TGPack.h:68
 TGPack.h:69
 TGPack.h:70
 TGPack.h:71
 TGPack.h:72
 TGPack.h:73
 TGPack.h:74
 TGPack.h:75
 TGPack.h:76
 TGPack.h:77
 TGPack.h:78
 TGPack.h:79
 TGPack.h:80
 TGPack.h:81
 TGPack.h:82
 TGPack.h:83
 TGPack.h:84
 TGPack.h:85
 TGPack.h:86
 TGPack.h:87
 TGPack.h:88
 TGPack.h:89
 TGPack.h:90
 TGPack.h:91
 TGPack.h:92
 TGPack.h:93
 TGPack.h:94
 TGPack.h:95
 TGPack.h:96
 TGPack.h:97
 TGPack.h:98
 TGPack.h:99
 TGPack.h:100
 TGPack.h:101
 TGPack.h:102
 TGPack.h:103
 TGPack.h:104
 TGPack.h:105
 TGPack.h:106
 TGPack.h:107
 TGPack.h:108
 TGPack.h:109
 TGPack.h:110
 TGPack.h:111
 TGPack.h:112
 TGPack.h:113