TGSplitFrame.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGSplitFrame.h 25229 2008-08-25 15:14:34Z bellenot $
00002 // Author: Bertrand Bellenot 23/01/2008
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, 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_TGSplitFrame
00013 #define ROOT_TGSplitFrame
00014 
00015 #ifndef ROOT_TGFrame
00016 #include "TGFrame.h"
00017 #endif
00018 
00019 #ifndef ROOT_TMap
00020 #include "TMap.h"
00021 #endif
00022 
00023 class TGSplitter;
00024 class TContextMenu;
00025 
00026 class TGRectMap : public TObject {
00027 
00028 private:
00029    TGRectMap(const TGRectMap&);             // not implemented
00030    TGRectMap& operator=(const TGRectMap&);  // not implemented
00031 
00032 public:
00033    Int_t         fX;    // x position
00034    Int_t         fY;    // y position
00035    UInt_t        fW;    // width
00036    UInt_t        fH;    // height
00037 
00038    // constructors
00039    TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
00040              fX(rx), fY(ry), fW(rw), fH(rh) { }
00041    virtual ~TGRectMap() { }
00042 
00043    // methods
00044    Bool_t Contains(Int_t px, Int_t py) const
00045                 { return ((px >= fX) && (px < fX + (Int_t) fW) &&
00046                           (py >= fY) && (py < fY + (Int_t) fH)); }
00047 
00048    ClassDef(TGRectMap, 0)  // Rectangle used in TMap
00049 };
00050 
00051 class TGSplitTool : public TGCompositeFrame {
00052 
00053 private:
00054    const TGFrame     *fWindow;      // frame to which tool tip is associated
00055    TGGC               fRectGC;      // rectangles drawing context
00056    TMap               fMap;         // map of rectangles/subframes
00057    TContextMenu      *fContextMenu; // Context menu for the splitter
00058    Int_t              fX;           // X position in fWindow where to popup
00059    Int_t              fY;           // Y position in fWindow where to popup
00060 
00061    TGSplitTool(const TGSplitTool&);             // not implemented
00062    TGSplitTool& operator=(const TGSplitTool&);  // not implemented
00063 
00064 public:
00065    TGSplitTool(const TGWindow *p = 0, const TGFrame *f = 0);
00066    virtual ~TGSplitTool();
00067 
00068    void   AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h);
00069    void   DoRedraw();
00070    void   DrawBorder();
00071    Bool_t HandleButton(Event_t *event);
00072    Bool_t HandleMotion(Event_t *event);
00073    void   Show(Int_t x, Int_t y);
00074    void   Hide();
00075    void   Reset();
00076    void   SetPosition(Int_t x, Int_t y);
00077 
00078    ClassDef(TGSplitTool, 0)  // Split frame tool utility
00079 };
00080 
00081 class TGSplitFrame : public TGCompositeFrame {
00082 
00083 private:
00084    TGSplitFrame(const TGSplitFrame&); // Not implemented
00085    TGSplitFrame& operator=(const TGSplitFrame&); // Not implemented
00086 
00087 protected:
00088    TGFrame          *fFrame;       // Pointer to the embedded frame (if any)
00089    TGTransientFrame *fUndocked;    // Main frame used when "undocking" frame
00090    TGSplitter       *fSplitter;    // Pointer to the (H/V) Splitter (if any)
00091    TGSplitFrame     *fFirst;       // Pointer to the first child (if any)
00092    TGSplitFrame     *fSecond;      // Pointer to the second child (if any)
00093    TGSplitTool      *fSplitTool;   // SplitFrame Tool
00094    Float_t           fWRatio;      // Width ratio between the first child and this
00095    Float_t           fHRatio;      // Height ratio between the first child and this
00096 
00097 public:
00098    TGSplitFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00099                 UInt_t options = 0);
00100    virtual ~TGSplitFrame();
00101 
00102    virtual void   AddFrame(TGFrame *f, TGLayoutHints *l = 0);
00103    virtual void   Cleanup();
00104    virtual Bool_t HandleConfigureNotify(Event_t *);
00105    virtual void   HSplit(UInt_t h = 0);
00106    virtual void   VSplit(UInt_t w = 0);
00107    virtual void   RemoveFrame(TGFrame *f);
00108 
00109    TGSplitFrame  *GetFirst() const { return fFirst; }
00110    TGFrame       *GetFrame() const { return fFrame; }
00111    TGSplitFrame  *GetSecond() const { return fSecond; }
00112    TGSplitter    *GetSplitter() const { return fSplitter; }
00113    TGSplitTool   *GetSplitTool() const { return fSplitTool; }
00114    TGSplitFrame  *GetTopFrame();
00115    TGFrame       *GetUndocked() const { return fUndocked; }
00116    Float_t        GetHRatio() const { return fHRatio; }
00117    Float_t        GetWRatio() const { return fWRatio; }
00118    void           MapToSPlitTool(TGSplitFrame *top);
00119    void           OnSplitterClicked(Event_t *event);
00120    void           SetHRatio(Float_t r) { fHRatio = r; }
00121    void           SetWRatio(Float_t r) { fWRatio = r; }
00122    void           SplitHorizontal(const char *side = "top");
00123    void           SplitVertical(const char *side = "left");
00124    void           UnSplit(const char *which);
00125 
00126    // methods accessible via context menu
00127 
00128    void           Close();             // *MENU*
00129    void           CloseAndCollapse();  // *MENU*
00130    void           ExtractFrame();      // *MENU*
00131    void           SwallowBack();       // *MENU*
00132    void           SwitchToMain();      // *MENU*
00133    void           SplitHor();          // *MENU*
00134    void           SplitVer();          // *MENU*
00135 
00136    void           Docked(TGFrame* frame);    //*SIGNAL*
00137    void           Undocked(TGFrame* frame);  //*SIGNAL*
00138 
00139    static  void   SwitchFrames(TGFrame *frame, TGCompositeFrame *dest,
00140                                TGFrame *prev);
00141    virtual void   SavePrimitive(ostream &out, Option_t *option = "");
00142 
00143    ClassDef(TGSplitFrame, 0) // Splittable composite frame
00144 };
00145 
00146 #endif

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