TGPack.h

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TGPack.h 29129 2009-06-22 09:39:20Z brun $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
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_TGPack
00013 #define ROOT_TGPack
00014 
00015 #include "TGFrame.h"
00016 #include "TGLayout.h"
00017 
00018 class TGSplitter;
00019 
00020 
00021 class  TGFrameElementPack : public TGFrameElement
00022 {
00023 private:
00024    TGFrameElementPack(const TGFrameElementPack&);            // Not implemented
00025    TGFrameElementPack& operator=(const TGFrameElementPack&); // Not implemented
00026 
00027 public:
00028    Float_t fWeight;               // relative weight
00029    TGFrameElementPack* fSplitFE; //! cached varaible for optimisation
00030 
00031    TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = 0, Float_t weight = 1):
00032       TGFrameElement(frame, lh), fWeight(weight), fSplitFE(0) { }
00033 
00034    ClassDef(TGFrameElementPack, 0); // Class used in TGPack.
00035 };
00036 
00037 //==============================================================================
00038 
00039 class TGPack : public TGCompositeFrame
00040 {
00041 private:
00042    TGPack(const TGPack&);            // Not implemented
00043    TGPack& operator=(const TGPack&); // Not implemented
00044 
00045 protected:
00046    Bool_t         fVertical;
00047    Bool_t         fUseSplitters;
00048    Int_t          fSplitterLen;
00049 
00050    Int_t          fDragOverflow;  //!
00051 
00052    Float_t        fWeightSum;     // total sum of sub  frame weights
00053    Int_t          fNVisible;      //  number of visible frames
00054 
00055    Int_t          GetFrameLength(const TGFrame* f) const { return fVertical ? f->GetHeight() : f->GetWidth(); }
00056    Int_t          GetLength()                      const { return GetFrameLength(this); }
00057    Int_t          GetAvailableLength()             const;
00058 
00059    void           SetFrameLength  (TGFrame* f, Int_t len);
00060    void           SetFramePosition(TGFrame* f, Int_t pos);
00061 
00062    void           FindFrames(TGFrame* splitter, TGFrameElementPack*& f0, TGFrameElementPack*& f1) const;
00063 
00064    void           CheckSplitterVisibility();
00065    void           ResizeExistingFrames();
00066    void           RefitFramesToPack();
00067 
00068    void           AddFrameInternal(TGFrame *f, TGLayoutHints* l = 0, Float_t weight = 1);
00069    void           RemoveFrameInternal(TGFrame *f);
00070 
00071 
00072 public:
00073    TGPack(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
00074           Pixel_t back = GetDefaultFrameBackground());
00075    TGPack(TGClient *c, Window_t id, const TGWindow *parent = 0);
00076    virtual ~TGPack();
00077 
00078    virtual void   AddFrameWithWeight(TGFrame *f, TGLayoutHints* l, Float_t w);
00079    virtual void   AddFrame(TGFrame *f, TGLayoutHints* l=0);
00080 
00081    virtual void   DeleteFrame(TGFrame *f);
00082    virtual void   RemoveFrame(TGFrame *f);
00083    virtual void   ShowFrame(TGFrame *f);
00084    virtual void   HideFrame(TGFrame *f);
00085 
00086    using          TGCompositeFrame::Resize;
00087    virtual void   Resize(UInt_t w = 0, UInt_t h = 0);
00088 
00089    using          TGCompositeFrame::MapSubwindows;
00090    virtual void   MapSubwindows();
00091 
00092    virtual void   MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0);
00093    virtual void   Layout();
00094 
00095    virtual void Dump() const;
00096 
00097    void EqualizeFrames();
00098    void HandleSplitterStart();
00099    void HandleSplitterResize(Int_t delta);
00100 
00101    // ----------------------------------------------------------------
00102 
00103    Bool_t GetVertical() const { return fVertical; }
00104    void   SetVertical(Bool_t x);
00105 
00106    // For now assume this is always true. Lenght of splitter = 4 pixels.
00107    Bool_t GetUseSplitters() const { return fUseSplitters; }
00108    void SetUseSplitters(Bool_t x) { fUseSplitters = x; }
00109 
00110    ClassDef(TGPack, 0); // Horizontal or vertical stack of frames.
00111 };
00112 
00113 #endif

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