Logo ROOT   6.08/07
Reference Guide
TGDockableFrame.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Abdelhalim Ssadik 07/07/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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_TGDockableFrame
13 #define ROOT_TGDockableFrame
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // A TGDockableFrame is a frame with handles that allow it to be //
19 // undocked (i.e. put in a transient frame of its own) and to be docked //
20 // again or hidden and shown again. It uses the TGDockButton, which is //
21 // a button with two vertical bars (||) and TGDockHideButton, which is //
22 // a button with a small triangle. The TGUndockedFrame is a transient //
23 // frame that on closure will put the frame back in the dock. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #ifndef ROOT_TGFrame
28 #include "TGFrame.h"
29 #endif
30 
31 #ifndef ROOT_TGWidget
32 #include "TGWidget.h"
33 #endif
34 
35 #ifndef ROOT_TGButton
36 #include "TGButton.h"
37 #endif
38 
39 #ifndef ROOT_TGWindow
40 #include "TGWindow.h"
41 #endif
42 
43 
44 class TGDockableFrame;
45 
46 
47 class TGDockButton : public TGButton {
48 protected:
49  Bool_t fMouseOn; // true when mouse on button
50  ULong_t fNormBg; // normal background color
51  ULong_t fHiBg; // highlighted background color
52 
53  virtual void DrawBorder();
54  virtual void DoRedraw();
55 
56 public:
57  TGDockButton(const TGCompositeFrame *p = 0, Int_t id = 1);
58  virtual ~TGDockButton();
59 
60  virtual Bool_t HandleCrossing(Event_t *event);
61 
62  ClassDef(TGDockButton,0) // Dock button
63 };
64 
65 
67 protected:
68  Int_t fAspectRatio; // triangle orientation
69 
70  virtual void DoRedraw();
71 
72 public:
73  TGDockHideButton(const TGCompositeFrame *p = 0);
74 
75  void SetAspectRatio(Int_t a) { fAspectRatio = a; DoRedraw(); }
76 
77  ClassDef(TGDockHideButton,0) // Hide dock button
78 };
79 
80 
82 
83 private:
84  TGUndockedFrame(const TGUndockedFrame&); // Not implemented
85  TGUndockedFrame& operator=(const TGUndockedFrame&); // Not implemented
86 
87 protected:
88  TGDockableFrame *fDockable; // orignal dockable frame
89 
90 public:
91  TGUndockedFrame(const TGWindow *p = 0, TGDockableFrame *dockable = 0);
92  virtual ~TGUndockedFrame();
93 
94  void FixSize();
95  void CloseWindow();
96 
97  ClassDef(TGUndockedFrame,0) // Undocked frame
98 };
99 
100 
101 class TGDockableFrame : public TGCompositeFrame, public TGWidget {
102 friend class TGUndockedFrame;
103 
104 private:
105  TGDockableFrame(const TGDockableFrame&); // Not implemented
106  TGDockableFrame& operator=(const TGDockableFrame&); // Not implemented
107 
108 protected:
109  Bool_t fHidden; // if frame is hidden
110  Bool_t fEnableHide; // if frame can be hidden
111  Bool_t fEnableUndock; // if frame can be undocked
112  Bool_t fDeleted; // kTRUE if it is being deleted
113  Bool_t fFixedSize; // kTRUE if fixed size when undocked
114  TString fDockName; // name of frame
115  TGCompositeFrame *fContainer; // container containing dockable frame
116  TGCompositeFrame *fButtons; // container containing dock and hide buttons
117  TGDockButton *fDockButton; // dock button
118  TGDockHideButton *fHideButton; // hide button
119  TGUndockedFrame *fFrame; // undocked frame
120  TGLayoutHints *fHints; // layout hints
121  TGLayoutHints *fLb, *fLc; // layout hints
122 
123 public:
124  TGDockableFrame(const TGWindow *p = 0, Int_t id = -1,
125  UInt_t options = kHorizontalFrame);
126  virtual ~TGDockableFrame();
127 
128  virtual void AddFrame(TGFrame *f, TGLayoutHints *hints);
129 
131  virtual void Docked() { Emit("Docked()"); } //*SIGNAL*
132  virtual void Undocked() { Emit("Undocked()"); } //*SIGNAL*
133 
134  void UndockContainer();
135  void DockContainer(Int_t del = kTRUE);
136 
137  void HideContainer();
138  void ShowContainer();
139 
140  void EnableUndock(Bool_t onoff);
141  Bool_t EnableUndock() const { return fEnableUndock; }
142  void EnableHide(Bool_t onoff);
143  Bool_t EnableHide() const { return fEnableHide; }
144 
145  void SetWindowName(const char *name);
146 
147  Bool_t IsUndocked() const { return (fFrame != 0); }
148  Bool_t IsHidden() const { return fHidden; }
149 
150  Bool_t IsFixedSize() const { return fFixedSize; }
151  void SetFixedSize(Bool_t fixed) { fFixedSize = fixed; }
152 
153  TGCompositeFrame *GetContainer() const { return fContainer; }
154  TGUndockedFrame *GetUndocked() const { return fFrame; }
155 
156  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
157 
158  ClassDef(TGDockableFrame,0) // Dockable widget
159 };
160 
161 #endif
TGDockButton(const TGCompositeFrame *p=0, Int_t id=1)
Create a dock button (i.e. button with two vertical bars).
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:246
virtual void DoRedraw()
Draw the dock button, i.e. two vertical lines.
TGLayoutHints * fLc
const char Option_t
Definition: RtypesCore.h:62
virtual void Docked()
void SetFixedSize(Bool_t fixed)
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
virtual ~TGDockButton()
Delete dock button.
TGCompositeFrame * fButtons
TGDockableFrame * fDockable
TGDockHideButton * fHideButton
Bool_t EnableUndock() const
Bool_t IsFixedSize() const
Bool_t EnableHide() const
#define ClassDef(name, id)
Definition: Rtypes.h:254
TGCompositeFrame * GetContainer() const
TGButton & operator=(const TGButton &)
Bool_t IsUndocked() const
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
Bool_t IsHidden() const
unsigned int UInt_t
Definition: RtypesCore.h:42
TGCompositeFrame * fContainer
long Long_t
Definition: RtypesCore.h:50
TGLayoutHints * fHints
double f(double x)
virtual void DrawBorder()
Draw borders of dock button.
TGDockButton * fDockButton
TGUndockedFrame * GetUndocked() const
virtual Bool_t HandleCrossing(Event_t *event)
Handle dock button crossing events.
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
void SetAspectRatio(Int_t a)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:1829
virtual void Undocked()
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
TGUndockedFrame * fFrame
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118