Logo ROOT   6.08/07
Reference Guide
TGSplitFrame.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 23/01/2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGSplitFrame
13 #define ROOT_TGSplitFrame
14 
15 #ifndef ROOT_TGFrame
16 #include "TGFrame.h"
17 #endif
18 
19 #ifndef ROOT_TMap
20 #include "TMap.h"
21 #endif
22 
23 class TGSplitter;
24 class TContextMenu;
25 
26 class TGRectMap : public TObject {
27 
28 private:
29  TGRectMap(const TGRectMap&); // not implemented
30  TGRectMap& operator=(const TGRectMap&); // not implemented
31 
32 public:
33  Int_t fX; // x position
34  Int_t fY; // y position
35  UInt_t fW; // width
36  UInt_t fH; // height
37 
38  // constructors
39  TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
40  fX(rx), fY(ry), fW(rw), fH(rh) { }
41  virtual ~TGRectMap() { }
42 
43  // methods
44  Bool_t Contains(Int_t px, Int_t py) const
45  { return ((px >= fX) && (px < fX + (Int_t) fW) &&
46  (py >= fY) && (py < fY + (Int_t) fH)); }
47 
48  ClassDef(TGRectMap, 0) // Rectangle used in TMap
49 };
50 
51 class TGSplitTool : public TGCompositeFrame {
52 
53 private:
54  const TGFrame *fWindow; // frame to which tool tip is associated
55  TGGC fRectGC; // rectangles drawing context
56  TMap fMap; // map of rectangles/subframes
57  TContextMenu *fContextMenu; // Context menu for the splitter
58  Int_t fX; // X position in fWindow where to popup
59  Int_t fY; // Y position in fWindow where to popup
60 
61  TGSplitTool(const TGSplitTool&); // not implemented
62  TGSplitTool& operator=(const TGSplitTool&); // not implemented
63 
64 public:
65  TGSplitTool(const TGWindow *p = 0, const TGFrame *f = 0);
66  virtual ~TGSplitTool();
67 
68  void AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h);
69  void DoRedraw();
70  void DrawBorder();
71  Bool_t HandleButton(Event_t *event);
72  Bool_t HandleMotion(Event_t *event);
73  void Show(Int_t x, Int_t y);
74  void Hide();
75  void Reset();
76  void SetPosition(Int_t x, Int_t y);
77 
78  ClassDef(TGSplitTool, 0) // Split frame tool utility
79 };
80 
82 
83 private:
84  TGSplitFrame(const TGSplitFrame&); // Not implemented
85  TGSplitFrame& operator=(const TGSplitFrame&); // Not implemented
86 
87 protected:
88  TGFrame *fFrame; // Pointer to the embedded frame (if any)
89  TGTransientFrame *fUndocked; // Main frame used when "undocking" frame
90  TGSplitter *fSplitter; // Pointer to the (H/V) Splitter (if any)
91  TGSplitFrame *fFirst; // Pointer to the first child (if any)
92  TGSplitFrame *fSecond; // Pointer to the second child (if any)
93  TGSplitTool *fSplitTool; // SplitFrame Tool
94  Float_t fWRatio; // Width ratio between the first child and this
95  Float_t fHRatio; // Height ratio between the first child and this
96 
97 public:
98  TGSplitFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
99  UInt_t options = 0);
100  virtual ~TGSplitFrame();
101 
102  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
103  virtual void Cleanup();
104  virtual Bool_t HandleConfigureNotify(Event_t *);
105  virtual void HSplit(UInt_t h = 0);
106  virtual void VSplit(UInt_t w = 0);
107  virtual void RemoveFrame(TGFrame *f);
108 
109  TGSplitFrame *GetFirst() const { return fFirst; }
110  TGFrame *GetFrame() const { return fFrame; }
111  TGSplitFrame *GetSecond() const { return fSecond; }
112  TGSplitter *GetSplitter() const { return fSplitter; }
113  TGSplitTool *GetSplitTool() const { return fSplitTool; }
114  TGSplitFrame *GetTopFrame();
115  TGFrame *GetUndocked() const { return fUndocked; }
116  Float_t GetHRatio() const { return fHRatio; }
117  Float_t GetWRatio() const { return fWRatio; }
118  void MapToSPlitTool(TGSplitFrame *top);
119  void OnSplitterClicked(Event_t *event);
120  void SetHRatio(Float_t r) { fHRatio = r; }
121  void SetWRatio(Float_t r) { fWRatio = r; }
122  void SplitHorizontal(const char *side = "top");
123  void SplitVertical(const char *side = "left");
124  void UnSplit(const char *which);
125 
126  // methods accessible via context menu
127 
128  void Close(); // *MENU*
129  void CloseAndCollapse(); // *MENU*
130  void ExtractFrame(); // *MENU*
131  void SwallowBack(); // *MENU*
132  void SwitchToMain(); // *MENU*
133  void SplitHor(); // *MENU*
134  void SplitVer(); // *MENU*
135 
136  void Docked(TGFrame* frame); //*SIGNAL*
137  void Undocked(TGFrame* frame); //*SIGNAL*
138 
139  static void SwitchFrames(TGFrame *frame, TGCompositeFrame *dest,
140  TGFrame *prev);
141  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
142 
143  ClassDef(TGSplitFrame, 0) // Splittable composite frame
144 };
145 
146 #endif
Int_t fX
Definition: TGSplitFrame.h:33
TGFrame * fFrame
Definition: TGSplitFrame.h:88
TGTransientFrame * fUndocked
Definition: TGSplitFrame.h:89
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
TH1 * h
Definition: legend2.C:5
Float_t GetWRatio() const
Definition: TGSplitFrame.h:117
Float_t GetHRatio() const
Definition: TGSplitFrame.h:116
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGRectMap(const TGRectMap &)
void SetWRatio(Float_t r)
Definition: TGSplitFrame.h:121
TGSplitFrame * GetSecond() const
Definition: TGSplitFrame.h:111
Double_t x[n]
Definition: legend1.C:17
TContextMenu * fContextMenu
Definition: TGSplitFrame.h:57
#define ClassDef(name, id)
Definition: Rtypes.h:254
UInt_t fH
Definition: TGSplitFrame.h:36
TGSplitFrame * GetFirst() const
Definition: TGSplitFrame.h:109
virtual ~TGRectMap()
Definition: TGSplitFrame.h:41
TGFrame * GetUndocked() const
Definition: TGSplitFrame.h:115
Float_t fHRatio
Definition: TGSplitFrame.h:95
UInt_t fW
Definition: TGSplitFrame.h:35
TGSplitter * GetSplitter() const
Definition: TGSplitFrame.h:112
TGFrame * GetFrame() const
Definition: TGSplitFrame.h:110
Bool_t Contains(Int_t px, Int_t py) const
Definition: TGSplitFrame.h:44
Int_t fY
Definition: TGSplitFrame.h:34
TRandom2 r(17)
const TGFrame * fWindow
Definition: TGSplitFrame.h:54
void SetHRatio(Float_t r)
Definition: TGSplitFrame.h:120
TGSplitTool * GetSplitTool() const
Definition: TGSplitFrame.h:113
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
unsigned int UInt_t
Definition: RtypesCore.h:42
TLine * l
Definition: textangle.C:4
TGSplitter * fSplitter
Definition: TGSplitFrame.h:90
void Reset(Detail::TBranchProxy *x)
T2 fSecond
Definition: X11Events.mm:87
double f(double x)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
TGSplitFrame * fSecond
Definition: TGSplitFrame.h:92
Double_t y[n]
Definition: legend1.C:17
Mother of all ROOT objects.
Definition: TObject.h:37
#define dest(otri, vertexptr)
Definition: triangle.c:1040
TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh)
Definition: TGSplitFrame.h:39
TGSplitTool * fSplitTool
Definition: TGSplitFrame.h:93
TGSplitFrame * fFirst
Definition: TGSplitFrame.h:91
Definition: TGGC.h:35
Float_t fWRatio
Definition: TGSplitFrame.h:94
TGRectMap & operator=(const TGRectMap &)
T1 fFirst
Definition: X11Events.mm:86
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:709