Logo ROOT   6.12/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 #include "TGFrame.h"
28 
29 #include "TGWidget.h"
30 
31 #include "TGButton.h"
32 
33 #include "TGWindow.h"
34 
35 
36 class TGDockableFrame;
37 
38 
39 class TGDockButton : public TGButton {
40 protected:
41  Bool_t fMouseOn; // true when mouse on button
42  ULong_t fNormBg; // normal background color
43  ULong_t fHiBg; // highlighted background color
44 
45  virtual void DrawBorder();
46  virtual void DoRedraw();
47 
48 public:
49  TGDockButton(const TGCompositeFrame *p = 0, Int_t id = 1);
50  virtual ~TGDockButton();
51 
52  virtual Bool_t HandleCrossing(Event_t *event);
53 
54  ClassDef(TGDockButton,0) // Dock button
55 };
56 
57 
59 protected:
60  Int_t fAspectRatio; // triangle orientation
61 
62  virtual void DoRedraw();
63 
64 public:
65  TGDockHideButton(const TGCompositeFrame *p = 0);
66 
67  void SetAspectRatio(Int_t a) { fAspectRatio = a; DoRedraw(); }
68 
69  ClassDef(TGDockHideButton,0) // Hide dock button
70 };
71 
72 
74 
75 private:
76  TGUndockedFrame(const TGUndockedFrame&); // Not implemented
77  TGUndockedFrame& operator=(const TGUndockedFrame&); // Not implemented
78 
79 protected:
80  TGDockableFrame *fDockable; // orignal dockable frame
81 
82 public:
83  TGUndockedFrame(const TGWindow *p = 0, TGDockableFrame *dockable = 0);
84  virtual ~TGUndockedFrame();
85 
86  void FixSize();
87  void CloseWindow();
88 
89  ClassDef(TGUndockedFrame,0) // Undocked frame
90 };
91 
92 
93 class TGDockableFrame : public TGCompositeFrame, public TGWidget {
94 friend class TGUndockedFrame;
95 
96 private:
97  TGDockableFrame(const TGDockableFrame&); // Not implemented
98  TGDockableFrame& operator=(const TGDockableFrame&); // Not implemented
99 
100 protected:
101  Bool_t fHidden; // if frame is hidden
102  Bool_t fEnableHide; // if frame can be hidden
103  Bool_t fEnableUndock; // if frame can be undocked
104  Bool_t fDeleted; // kTRUE if it is being deleted
105  Bool_t fFixedSize; // kTRUE if fixed size when undocked
106  TString fDockName; // name of frame
107  TGCompositeFrame *fContainer; // container containing dockable frame
108  TGCompositeFrame *fButtons; // container containing dock and hide buttons
109  TGDockButton *fDockButton; // dock button
110  TGDockHideButton *fHideButton; // hide button
111  TGUndockedFrame *fFrame; // undocked frame
112  TGLayoutHints *fHints; // layout hints
113  TGLayoutHints *fLb, *fLc; // layout hints
114 
115 public:
116  TGDockableFrame(const TGWindow *p = 0, Int_t id = -1,
117  UInt_t options = kHorizontalFrame);
118  virtual ~TGDockableFrame();
119 
120  virtual void AddFrame(TGFrame *f, TGLayoutHints *hints);
121 
123  virtual void Docked() { Emit("Docked()"); } //*SIGNAL*
124  virtual void Undocked() { Emit("Undocked()"); } //*SIGNAL*
125 
126  void UndockContainer();
127  void DockContainer(Int_t del = kTRUE);
128 
129  void HideContainer();
130  void ShowContainer();
131 
132  void EnableUndock(Bool_t onoff);
133  Bool_t EnableUndock() const { return fEnableUndock; }
134  void EnableHide(Bool_t onoff);
135  Bool_t EnableHide() const { return fEnableHide; }
136 
137  void SetWindowName(const char *name);
138 
139  Bool_t IsUndocked() const { return (fFrame != 0); }
140  Bool_t IsHidden() const { return fHidden; }
141 
142  Bool_t IsFixedSize() const { return fFixedSize; }
143  void SetFixedSize(Bool_t fixed) { fFixedSize = fixed; }
144 
145  TGCompositeFrame *GetContainer() const { return fContainer; }
146  TGUndockedFrame *GetUndocked() const { return fFrame; }
147 
148  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
149 
150  ClassDef(TGDockableFrame,0) // Dockable widget
151 };
152 
153 #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:230
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:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:320
TGCompositeFrame * GetContainer() const
TGButton & operator=(const TGButton &)
Bool_t IsUndocked() const
Bool_t IsHidden() const
auto * a
Definition: textangle.C:12
unsigned int UInt_t
Definition: RtypesCore.h:42
TGCompositeFrame * fContainer
long Long_t
Definition: RtypesCore.h:50
TGLayoutHints * fHints
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()
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
TGUndockedFrame * fFrame
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118