Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveWindow.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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_TEveWindow
13 #define ROOT_TEveWindow
14 
15 #include "TEveElement.h"
16 
17 #include "TGFrame.h"
18 #include "TContextMenu.h"
19 
20 class TEveWindow;
21 class TEveWindowSlot;
22 class TEveWindowFrame;
23 class TEveWindowMainFrame;
24 class TEveWindowPack;
25 class TEveWindowTab;
26 class TEveContextMenu;
27 
28 class TGButton;
29 class TGSplitButton;
30 class TGTextButton;
31 
32 class TGPack;
33 class TGTab;
34 
35 //==============================================================================
36 // TEveCompositeFrame
37 //==============================================================================
38 
39 class TEveCompositeFrame : public TGCompositeFrame
40 {
41  friend class TEveWindow;
42  friend class TEveWindowManager;
43 
44 public:
45  typedef TGFrame* (*IconBarCreator_foo)(TEveCompositeFrame*, TGCompositeFrame*, Int_t);
46 
47 private:
48  TEveCompositeFrame(const TEveCompositeFrame&); // Not implemented
49  TEveCompositeFrame& operator=(const TEveCompositeFrame&); // Not implemented
50 
51  static IconBarCreator_foo fgIconBarCreator;
52  static UInt_t fgTopFrameHeight;
53  static UInt_t fgMiniBarHeight;
54  static Bool_t fgAllowTopFrameCollapse;
55 
56 protected:
57  TGCompositeFrame *fTopFrame;
58  TGTextButton *fToggleBar;
59  TGTextButton *fTitleBar;
60  TGFrame *fIconBar;
61  TGLayoutHints *fEveWindowLH;
62 
63  TGFrame *fMiniBar;
64 
65  TEveElement *fEveParent;
66  TEveWindow *fEveWindow;
67 
68  Bool_t fShowInSync;
69 
70  static TEveContextMenu *fgCtxMenu;
71  static const TString fgkEmptyFrameName;
72 
73  static TList *fgFrameList;
74 
75 public:
76  TEveCompositeFrame(TGCompositeFrame* gui_parent, TEveWindow* eve_parent);
77  virtual ~TEveCompositeFrame();
78 
79  virtual void WindowNameChanged(const TString& name);
80 
81  virtual void Destroy() = 0;
82 
83  virtual void AcquireEveWindow(TEveWindow* ew);
84  virtual TEveWindow* RelinquishEveWindow(Bool_t reparent=kTRUE);
85 
86  TEveWindow* GetEveWindow() const { return fEveWindow; }
87  TEveWindow* GetEveParentAsWindow() const;
88 
89  virtual void SetCurrent(Bool_t curr);
90  virtual void SetShowTitleBar(Bool_t show);
91  virtual void HideAllDecorations();
92  virtual void ShowNormalDecorations();
93 
94  void ActionPressed();
95  void FlipTitleBarState();
96  void TitleBarClicked();
97 
98  static void SetupFrameMarkup(IconBarCreator_foo creator,
99  UInt_t top_frame_height = 14,
100  UInt_t mini_bar_height = 4,
101  Bool_t allow_top_collapse = kTRUE);
102 
103  ClassDef(TEveCompositeFrame, 0); // Composite frame containing eve-window-controls and eve-windows.
104 };
105 
106 
107 //==============================================================================
108 // TEveCompositeFrameInMainFrame
109 //==============================================================================
110 
111 class TEveCompositeFrameInMainFrame : public TEveCompositeFrame
112 {
113 private:
114  TEveCompositeFrameInMainFrame(const TEveCompositeFrameInMainFrame&); // Not implemented
115  TEveCompositeFrameInMainFrame& operator=(const TEveCompositeFrameInMainFrame&); // Not implemented
116 
117 protected:
118  TGMainFrame *fMainFrame;
119  TEveWindow *fOriginalSlot;
120  TEveWindow *fOriginalContainer;
121 
122 public:
123  TEveCompositeFrameInMainFrame(TGCompositeFrame* parent, TEveWindow* eve_parent,
124  TGMainFrame* mf);
125  virtual ~TEveCompositeFrameInMainFrame();
126 
127  virtual void WindowNameChanged(const TString& name);
128 
129  virtual void Destroy();
130 
131  void SetOriginalSlotAndContainer(TEveWindow* slot, TEveWindow* container);
132 
133  void SomeWindowClosed(TEveWindow* w);
134  void MainFrameClosed();
135 
136  TEveWindow* GetOriginalSlot() const { return fOriginalSlot; }
137  TEveWindow* GetOriginalContainer() const { return fOriginalContainer; }
138 
139  ClassDef(TEveCompositeFrameInMainFrame, 0); // Eve-composite-frame that is contained in one tab of a TGTab.
140 };
141 
142 
143 //==============================================================================
144 // TEveCompositeFrameInPack
145 //==============================================================================
146 
147 class TEveCompositeFrameInPack : public TEveCompositeFrame
148 {
149 private:
150  TEveCompositeFrameInPack(const TEveCompositeFrameInPack&); // Not implemented
151  TEveCompositeFrameInPack& operator=(const TEveCompositeFrameInPack&); // Not implemented
152 
153 protected:
154  TGPack *fPack;
155 
156 public:
157  TEveCompositeFrameInPack(TGCompositeFrame* parent, TEveWindow* eve_parent,
158  TGPack* pack);
159  virtual ~TEveCompositeFrameInPack();
160 
161  virtual void Destroy();
162 
163  ClassDef(TEveCompositeFrameInPack, 0); // Eve-composite-frame that is contained in a TGPack.
164 };
165 
166 
167 //==============================================================================
168 // TEveCompositeFrameInTab
169 //==============================================================================
170 
171 class TEveCompositeFrameInTab : public TEveCompositeFrame
172 {
173 private:
174  TEveCompositeFrameInTab(const TEveCompositeFrameInTab&); // Not implemented
175  TEveCompositeFrameInTab& operator=(const TEveCompositeFrameInTab&); // Not implemented
176 
177 protected:
178  TGTab *fTab;
179  TGCompositeFrame *fParentInTab;
180 
181  Int_t FindTabIndex();
182 
183 public:
184  TEveCompositeFrameInTab(TGCompositeFrame* parent, TEveWindow* eve_parent,
185  TGTab* tab);
186  virtual ~TEveCompositeFrameInTab();
187 
188  virtual void WindowNameChanged(const TString& name);
189 
190  virtual void Destroy();
191 
192  virtual void SetCurrent(Bool_t curr);
193 
194  ClassDef(TEveCompositeFrameInTab, 0); // Eve-composite-frame that is contained in one tab of a TGTab.
195 };
196 
197 
198 //==============================================================================
199 //==============================================================================
200 // TEveWindow classes
201 //==============================================================================
202 //==============================================================================
203 
204 
205 //==============================================================================
206 // TEveWindow
207 //==============================================================================
208 
209 class TEveWindow : public TEveElementList
210 {
211  friend class TEveWindowManager;
212 
213 private:
214  TEveWindow(const TEveWindow&); // Not implemented
215  TEveWindow& operator=(const TEveWindow&); // Not implemented
216 
217 protected:
218  TEveCompositeFrame *fEveFrame;
219  Bool_t fShowTitleBar;
220 
221  virtual void SetCurrent(Bool_t curr);
222 
223  static UInt_t fgMainFrameDefWidth;
224  static UInt_t fgMainFrameDefHeight;
225 
226  static Pixel_t fgCurrentBackgroundColor;
227  static Pixel_t fgMiniBarBackgroundColor;
228 
229  virtual void PreDeleteElement();
230 
231 public:
232  TEveWindow(const char* n="TEveWindow", const char* t="");
233  virtual ~TEveWindow();
234 
235  virtual void NameTitleChanged();
236 
237  virtual TGFrame* GetGUIFrame() = 0;
238  virtual void PreUndock();
239  virtual void PostDock();
240 
241  virtual Bool_t CanMakeNewSlots() const { return kFALSE; }
242  virtual TEveWindowSlot* NewSlot() { return 0; }
243 
244  void PopulateEmptyFrame(TEveCompositeFrame* ef);
245 
246  void SwapWindow(TEveWindow* w);
247  void SwapWindowWithCurrent(); // *MENU*
248 
249  void UndockWindow(); // *MENU*
250  void UndockWindowDestroySlot(); // *MENU*
251 
252  void ReplaceWindow(TEveWindow* w);
253 
254  virtual void DestroyWindow(); // *MENU*
255  virtual void DestroyWindowAndSlot(); // *MENU*
256 
257  TEveCompositeFrame* GetEveFrame() { return fEveFrame; }
258  void ClearEveFrame();
259 
260  void FlipShowTitleBar() { SetShowTitleBar(!fShowTitleBar); }
261  Bool_t GetShowTitleBar() const { return fShowTitleBar; }
262  void SetShowTitleBar(Bool_t x);
263 
264  Bool_t IsCurrent() const;
265  void MakeCurrent();
266 
267 
268  Bool_t IsAncestorOf(TEveWindow* win);
269 
270  void TitleBarClicked();
271 
272 
273  // Static helper functions for common window management scenarios.
274 
275  static TEveWindowSlot* CreateDefaultWindowSlot();
276  static TEveWindowSlot* CreateWindowMainFrame(TEveWindow* eve_parent=0);
277  static TEveWindowSlot* CreateWindowInTab(TGTab* tab, TEveWindow* eve_parent=0);
278 
279  static void SwapWindows(TEveWindow* w1, TEveWindow* w2);
280 
281  // Access to static data-members.
282 
283  static UInt_t GetMainFrameDefWidth();
284  static UInt_t GetMainFrameDefHeight();
285  static void SetMainFrameDefWidth (UInt_t x);
286  static void SetMainFrameDefHeight(UInt_t x);
287 
288  static Pixel_t GetCurrentBackgroundColor();
289  static Pixel_t GetMiniBarBackgroundColor();
290  static void SetCurrentBackgroundColor(Pixel_t p);
291  static void SetMiniBarBackgroundColor(Pixel_t p);
292 
293  ClassDef(TEveWindow, 0); // Abstract base-class for eve-windows.
294 };
295 
296 
297 //==============================================================================
298 // TEveWindowSlot
299 //==============================================================================
300 
301 class TEveWindowSlot : public TEveWindow
302 {
303 private:
304  TEveWindowSlot(const TEveWindowSlot&); // Not implemented
305  TEveWindowSlot& operator=(const TEveWindowSlot&); // Not implemented
306 
307 protected:
308  TGTextButton *fEmptyButt;
309  TGCompositeFrame *fEmbedBuffer;
310 
311  virtual void SetCurrent(Bool_t curr);
312 
313 public:
314  TEveWindowSlot(const char* n="TEveWindowSlot", const char* t="");
315  virtual ~TEveWindowSlot();
316 
317  virtual TGFrame* GetGUIFrame();
318 
319  TEveWindowPack* MakePack(); // *MENU*
320  TEveWindowTab* MakeTab(); // *MENU*
321 
322  TEveWindowFrame* MakeFrame(TGFrame* frame=0);
323 
324  TGCompositeFrame* StartEmbedding();
325  TEveWindowFrame* StopEmbedding(const char* name=0);
326 
327  ClassDef(TEveWindowSlot, 0); // An unoccupied eve-window slot.
328 };
329 
330 
331 //==============================================================================
332 // TEveWindowFrame
333 //==============================================================================
334 
335 class TEveWindowFrame : public TEveWindow
336 {
337 private:
338  TEveWindowFrame(const TEveWindowFrame&); // Not implemented
339  TEveWindowFrame& operator=(const TEveWindowFrame&); // Not implemented
340 
341 protected:
342  TGFrame *fGUIFrame;
343 
344 public:
345  TEveWindowFrame(TGFrame* frame, const char* n="TEveWindowFrame", const char* t="");
346  virtual ~TEveWindowFrame();
347 
348  virtual TGFrame* GetGUIFrame() { return fGUIFrame; }
349 
350  TGCompositeFrame* GetGUICompositeFrame();
351 
352  ClassDef(TEveWindowFrame, 0); // Eve-window containing any TGFrame.
353 };
354 
355 
356 //==============================================================================
357 // TEveWindowPack
358 //==============================================================================
359 
360 class TEveWindowPack : public TEveWindow
361 {
362 private:
363  TEveWindowPack(const TEveWindowPack&); // Not implemented
364  TEveWindowPack& operator=(const TEveWindowPack&); // Not implemented
365 
366 protected:
367  TGPack *fPack;
368 
369 public:
370  TEveWindowPack(TGPack* p, const char* n="TEveWindowPack", const char* t="");
371  virtual ~TEveWindowPack();
372 
373  virtual TGFrame* GetGUIFrame();
374 
375  virtual Bool_t CanMakeNewSlots() const { return kTRUE; }
376  virtual TEveWindowSlot* NewSlotWithWeight(Float_t w);
377  virtual TEveWindowSlot* NewSlot(); // *MENU*
378 
379  void FlipOrientation(); // *MENU*
380  void SetVertical(Bool_t x=kTRUE);
381  void SetHorizontal() { SetVertical(kFALSE); }
382 
383  void EqualizeFrames(); // *MENU*
384 
385  TGPack* GetPack() const { return fPack; }
386 
387  ClassDef(TEveWindowPack, 0); // Eve-window containing a TGPack.
388 };
389 
390 
391 //==============================================================================
392 // TEveWindowTab
393 //==============================================================================
394 
395 class TEveWindowTab : public TEveWindow
396 {
397 private:
398  TEveWindowTab(const TEveWindowTab&); // Not implemented
399  TEveWindowTab& operator=(const TEveWindowTab&); // Not implemented
400 
401 protected:
402  TGTab *fTab;
403 
404 public:
405  TEveWindowTab(TGTab* tab, const char* n="TEveWindowTab", const char* t="");
406  virtual ~TEveWindowTab();
407 
408  virtual TGFrame* GetGUIFrame();
409 
410  virtual Bool_t CanMakeNewSlots() const { return kTRUE; }
411  virtual TEveWindowSlot* NewSlot(); // *MENU*
412 
413  TGTab* GetTab() const { return fTab; }
414 
415  ClassDef(TEveWindowTab, 0); // Eve-window containing a TGTab.
416 };
417 
418 
419 //==============================================================================
420 //==============================================================================
421 // Helper classes
422 //==============================================================================
423 //==============================================================================
424 
425 
426 //==============================================================================
427 // TEveContextMenu
428 //==============================================================================
429 
430 class TEveContextMenu : public TContextMenu
431 {
432 public:
433  TEveContextMenu(const char *name, const char *title = "Eve context menu");
434 
435  void SetupAndPopup(TGWindow* button, TObject* obj);
436 
437  ClassDef(TEveContextMenu, 0) // Specialization of TContextMenu for Eve.
438 };
439 
440 #endif