Logo ROOT  
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 #include "TGFrame.h"
16 
17 #include "TMap.h"
18 
19 class TGSplitter;
20 class TContextMenu;
21 
22 class TGRectMap : public TObject {
23 
24 private:
25  TGRectMap(const TGRectMap&); // not implemented
26  TGRectMap& operator=(const TGRectMap&); // not implemented
27 
28 public:
29  Int_t fX; // x position
30  Int_t fY; // y position
31  UInt_t fW; // width
32  UInt_t fH; // height
33 
34  // constructors
35  TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
36  fX(rx), fY(ry), fW(rw), fH(rh) { }
37  virtual ~TGRectMap() { }
38 
39  // methods
40  Bool_t Contains(Int_t px, Int_t py) const
41  { return ((px >= fX) && (px < fX + (Int_t) fW) &&
42  (py >= fY) && (py < fY + (Int_t) fH)); }
43 
44  ClassDef(TGRectMap, 0) // Rectangle used in TMap
45 };
46 
47 class TGSplitTool : public TGCompositeFrame {
48 
49 private:
50  const TGFrame *fWindow; // frame to which tool tip is associated
51  TGGC fRectGC; // rectangles drawing context
52  TMap fMap; // map of rectangles/subframes
53  TContextMenu *fContextMenu; // Context menu for the splitter
54  Int_t fX; // X position in fWindow where to popup
55  Int_t fY; // Y position in fWindow where to popup
56 
57  TGSplitTool(const TGSplitTool&); // not implemented
58  TGSplitTool& operator=(const TGSplitTool&); // not implemented
59 
60 public:
61  TGSplitTool(const TGWindow *p = 0, const TGFrame *f = 0);
62  virtual ~TGSplitTool();
63 
64  void AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h);
65  void DoRedraw();
66  void DrawBorder();
67  Bool_t HandleButton(Event_t *event);
68  Bool_t HandleMotion(Event_t *event);
69  void Show(Int_t x, Int_t y);
70  void Hide();
71  void Reset();
72  void SetPosition(Int_t x, Int_t y);
73 
74  ClassDef(TGSplitTool, 0) // Split frame tool utility
75 };
76 
78 
79 private:
80  TGSplitFrame(const TGSplitFrame&); // Not implemented
81  TGSplitFrame& operator=(const TGSplitFrame&); // Not implemented
82 
83 protected:
84  TGFrame *fFrame; // Pointer to the embedded frame (if any)
85  TGTransientFrame *fUndocked; // Main frame used when "undocking" frame
86  TGSplitter *fSplitter; // Pointer to the (H/V) Splitter (if any)
87  TGSplitFrame *fFirst; // Pointer to the first child (if any)
88  TGSplitFrame *fSecond; // Pointer to the second child (if any)
89  TGSplitTool *fSplitTool; // SplitFrame Tool
90  Float_t fWRatio; // Width ratio between the first child and this
91  Float_t fHRatio; // Height ratio between the first child and this
92 
93 public:
94  TGSplitFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
95  UInt_t options = 0);
96  virtual ~TGSplitFrame();
97 
98  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
99  virtual void Cleanup();
101  virtual void HSplit(UInt_t h = 0);
102  virtual void VSplit(UInt_t w = 0);
103  virtual void RemoveFrame(TGFrame *f);
104 
105  TGSplitFrame *GetFirst() const { return fFirst; }
106  TGFrame *GetFrame() const { return fFrame; }
107  TGSplitFrame *GetSecond() const { return fSecond; }
108  TGSplitter *GetSplitter() const { return fSplitter; }
109  TGSplitTool *GetSplitTool() const { return fSplitTool; }
111  TGFrame *GetUndocked() const { return fUndocked; }
112  Float_t GetHRatio() const { return fHRatio; }
113  Float_t GetWRatio() const { return fWRatio; }
114  void MapToSPlitTool(TGSplitFrame *top);
115  void OnSplitterClicked(Event_t *event);
116  void SetHRatio(Float_t r) { fHRatio = r; }
117  void SetWRatio(Float_t r) { fWRatio = r; }
118  void SplitHorizontal(const char *side = "top");
119  void SplitVertical(const char *side = "left");
120  void UnSplit(const char *which);
121 
122  // methods accessible via context menu
123 
124  void Close(); // *MENU*
125  void CloseAndCollapse(); // *MENU*
126  void ExtractFrame(); // *MENU*
127  void SwallowBack(); // *MENU*
128  void SwitchToMain(); // *MENU*
129  void SplitHor(); // *MENU*
130  void SplitVer(); // *MENU*
131 
132  void Docked(TGFrame* frame); //*SIGNAL*
133  void Undocked(TGFrame* frame); //*SIGNAL*
134 
135  static void SwitchFrames(TGFrame *frame, TGCompositeFrame *dest,
136  TGFrame *prev);
137  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
138 
139  ClassDef(TGSplitFrame, 0) // Splittable composite frame
140 };
141 
142 #endif
TGSplitFrame::GetUndocked
TGFrame * GetUndocked() const
Definition: TGSplitFrame.h:111
TGSplitFrame::Docked
void Docked(TGFrame *frame)
Emit Undocked() signal.
Definition: TGSplitFrame.cxx:344
l
auto * l
Definition: textangle.C:4
TGRectMap::~TGRectMap
virtual ~TGRectMap()
Definition: TGSplitFrame.h:37
TGSplitTool::fMap
TMap fMap
Definition: TGSplitFrame.h:52
TGSplitFrame::fHRatio
Float_t fHRatio
Definition: TGSplitFrame.h:91
TGTransientFrame
Definition: TGFrame.h:553
TGSplitFrame::Cleanup
virtual void Cleanup()
Recursively cleanup child frames.
Definition: TGSplitFrame.cxx:287
TGSplitTool
Definition: TGSplitFrame.h:47
TGRectMap
Definition: TGSplitFrame.h:22
TGWindow
Definition: TGWindow.h:31
TGSplitFrame::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a splittable frame as a C++ statement(s) on output stream out.
Definition: TGSplitFrame.cxx:741
TGSplitTool::DrawBorder
void DrawBorder()
Draw border of tool window.
Definition: TGSplitFrame.cxx:110
TGSplitFrame::TGSplitFrame
TGSplitFrame(const TGSplitFrame &)
f
#define f(i)
Definition: RSha256.hxx:122
dest
#define dest(otri, vertexptr)
Definition: triangle.c:1040
TGSplitFrame::SetWRatio
void SetWRatio(Float_t r)
Definition: TGSplitFrame.h:117
TGSplitFrame::OnSplitterClicked
void OnSplitterClicked(Event_t *event)
Handle mouse click events on the splitter.
Definition: TGSplitFrame.cxx:502
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TGSplitTool::fContextMenu
TContextMenu * fContextMenu
Definition: TGSplitFrame.h:53
TGSplitTool::~TGSplitTool
virtual ~TGSplitTool()
TGSplitTool destructor.
Definition: TGSplitFrame.cxx:76
TGSplitFrame::HSplit
virtual void HSplit(UInt_t h=0)
Horizontally split the frame.
Definition: TGSplitFrame.cxx:412
Float_t
float Float_t
Definition: RtypesCore.h:57
TGSplitFrame::ExtractFrame
void ExtractFrame()
Extract the frame contained in this split frame an reparent it in a transient frame.
Definition: TGSplitFrame.cxx:354
TGSplitFrame::SplitVertical
void SplitVertical(const char *side="left")
Vertically split the frame, and if it contains a child frame, ask the user where to keep it (left or ...
Definition: TGSplitFrame.cxx:592
TGSplitFrame::fUndocked
TGTransientFrame * fUndocked
Definition: TGSplitFrame.h:85
TGSplitFrame::SwallowBack
void SwallowBack()
Swallow back the child frame previously extracted, and close its parent (transient frame).
Definition: TGSplitFrame.cxx:620
x
Double_t x[n]
Definition: legend1.C:17
TGSplitFrame::SplitVer
void SplitVer()
Vertically split the frame, and if it contains a child frame, ask the user where to keep it (left or ...
Definition: TGSplitFrame.cxx:573
TGSplitFrame::RemoveFrame
virtual void RemoveFrame(TGFrame *f)
Add a frame in the split frame using layout hints l.
Definition: TGSplitFrame.cxx:277
TGSplitFrame::fSecond
TGSplitFrame * fSecond
Definition: TGSplitFrame.h:88
TGSplitTool::Show
void Show(Int_t x, Int_t y)
Show tool window.
Definition: TGSplitFrame.cxx:227
TGFrame
Definition: TGFrame.h:105
TGSplitTool::DoRedraw
void DoRedraw()
Redraw split frame tool.
Definition: TGSplitFrame.cxx:94
TGRectMap::TGRectMap
TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh)
Definition: TGSplitFrame.h:35
TGSplitFrame::GetHRatio
Float_t GetHRatio() const
Definition: TGSplitFrame.h:112
TGSplitFrame::fFirst
TGSplitFrame * fFirst
Definition: TGSplitFrame.h:87
bool
TGSplitFrame::fSplitTool
TGSplitTool * fSplitTool
Definition: TGSplitFrame.h:89
TGSplitTool::fWindow
const TGFrame * fWindow
Definition: TGSplitFrame.h:50
TGSplitFrame::~TGSplitFrame
virtual ~TGSplitFrame()
Destructor. Make cleanup.
Definition: TGSplitFrame.cxx:259
TGSplitFrame::SetHRatio
void SetHRatio(Float_t r)
Definition: TGSplitFrame.h:116
TContextMenu
Definition: TContextMenu.h:44
TGSplitFrame
Definition: TGSplitFrame.h:77
TGSplitFrame::fWRatio
Float_t fWRatio
Definition: TGSplitFrame.h:90
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGSplitFrame::GetSecond
TGSplitFrame * GetSecond() const
Definition: TGSplitFrame.h:107
TGSplitFrame::GetTopFrame
TGSplitFrame * GetTopFrame()
Return the top level split frame.
Definition: TGSplitFrame.cxx:299
h
#define h(i)
Definition: RSha256.hxx:124
TGSplitTool::fY
Int_t fY
Definition: TGSplitFrame.h:55
TGGC
Definition: TGGC.h:31
TGSplitFrame::SplitHor
void SplitHor()
Horizontally split the frame, and if it contains a child frame, ask the user where to keep it (top or...
Definition: TGSplitFrame.cxx:525
TGRectMap::fH
UInt_t fH
Definition: TGSplitFrame.h:32
TGSplitTool::AddRectangle
void AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h)
Add a rectangle representation of a split frame in the map, together with the frame itself.
Definition: TGSplitFrame.cxx:85
TGFrame.h
TGSplitFrame::VSplit
virtual void VSplit(UInt_t w=0)
Vertically split the frame.
Definition: TGSplitFrame.cxx:441
TGLayoutHints
Definition: TGLayout.h:57
TGRectMap::operator=
TGRectMap & operator=(const TGRectMap &)
TGSplitFrame::GetFirst
TGSplitFrame * GetFirst() const
Definition: TGSplitFrame.h:105
TGSplitFrame::GetSplitter
TGSplitter * GetSplitter() const
Definition: TGSplitFrame.h:108
TGSplitFrame::MapToSPlitTool
void MapToSPlitTool(TGSplitFrame *top)
Map this split frame in the small overview tooltip.
Definition: TGSplitFrame.cxx:470
y
Double_t y[n]
Definition: legend1.C:17
TGSplitTool::fX
Int_t fX
Definition: TGSplitFrame.h:54
TGSplitTool::operator=
TGSplitTool & operator=(const TGSplitTool &)
TGSplitFrame::Undocked
void Undocked(TGFrame *frame)
Emit Undocked() signal.
Definition: TGSplitFrame.cxx:700
TGSplitTool::SetPosition
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
Definition: TGSplitFrame.cxx:206
TGSplitter
Definition: TGSplitter.h:29
TGRectMap::TGRectMap
TGRectMap(const TGRectMap &)
unsigned int
TGSplitTool::Hide
void Hide()
Hide tool window. Use this method to hide the tool in a client class.
Definition: TGSplitFrame.cxx:185
TGSplitFrame::SwitchFrames
static void SwitchFrames(TGFrame *frame, TGCompositeFrame *dest, TGFrame *prev)
Switch (exchange) two frames.
Definition: TGSplitFrame.cxx:648
TGRectMap::fY
Int_t fY
Definition: TGSplitFrame.h:30
TGSplitFrame::UnSplit
void UnSplit(const char *which)
Close (unmap and remove from the list of frames) the frame contained in this split frame.
Definition: TGSplitFrame.cxx:709
TGSplitFrame::GetSplitTool
TGSplitTool * GetSplitTool() const
Definition: TGSplitFrame.h:109
TGSplitTool::fRectGC
TGGC fRectGC
Definition: TGSplitFrame.h:51
TGSplitFrame::GetWRatio
Float_t GetWRatio() const
Definition: TGSplitFrame.h:113
TGSplitTool::HandleMotion
Bool_t HandleMotion(Event_t *event)
handle mouse motion events
Definition: TGSplitFrame.cxx:151
TGRectMap::fX
Int_t fX
Definition: TGSplitFrame.h:29
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGSplitFrame::operator=
TGSplitFrame & operator=(const TGSplitFrame &)
TMap.h
Event_t
Definition: GuiTypes.h:173
TGSplitFrame::Close
void Close()
Close (unmap and remove from the list of frames) the frame contained in this split frame.
Definition: TGSplitFrame.cxx:316
TGRectMap::Contains
Bool_t Contains(Int_t px, Int_t py) const
Definition: TGSplitFrame.h:40
TGSplitFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add a frame in the split frame using layout hints l.
Definition: TGSplitFrame.cxx:268
TGSplitFrame::fSplitter
TGSplitter * fSplitter
Definition: TGSplitFrame.h:86
TGSplitFrame::fFrame
TGFrame * fFrame
Definition: TGSplitFrame.h:84
TGSplitTool::Reset
void Reset()
Reset tool tip popup delay timer.
Definition: TGSplitFrame.cxx:196
TGSplitTool::HandleButton
Bool_t HandleButton(Event_t *event)
Handle mouse click events in the tool.
Definition: TGSplitFrame.cxx:121
TGSplitTool::TGSplitTool
TGSplitTool(const TGSplitTool &)
TGSplitFrame::GetFrame
TGFrame * GetFrame() const
Definition: TGSplitFrame.h:106
TGSplitFrame::SwitchToMain
void SwitchToMain()
Switch the actual embedded frame to the main (first) split frame.
Definition: TGSplitFrame.cxx:688
TGCompositeFrame
Definition: TGFrame.h:324
TGRectMap::fW
UInt_t fW
Definition: TGSplitFrame.h:31
TGSplitFrame::SplitHorizontal
void SplitHorizontal(const char *side="top")
Horizontally split the frame, and if it contains a child frame, ask the user where to keep it (top or...
Definition: TGSplitFrame.cxx:544
int
TGSplitFrame::CloseAndCollapse
void CloseAndCollapse()
Close (unmap, remove from the list of frames and destroy) the frame contained in this split frame.
Definition: TGSplitFrame.cxx:329
TMap
Definition: TMap.h:40
TGSplitFrame::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *)
Handles resize events for this frame.
Definition: TGSplitFrame.cxx:376