forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveWindowManager.cxx
222 lines (178 loc) · 6.38 KB
/
TEveWindowManager.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveWindowManager.h"
#include "TEveWindow.h"
/** \class TEveWindowManager
\ingroup TEve
Manager for EVE windows.
Provides the concept of the current window and takes care for proper
destruction of the windows.
It is also the EVE-parent of windows that are not attached into the
hierarchy of EVE-windows.
Window-manager is created by the EVE-manager and can be retrieved via:
~~~ {.cpp}
gEve->GetWindowManager.
~~~
*/
ClassImp(TEveWindowManager);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveWindowManager::TEveWindowManager(const char* n, const char* t) :
TEveElementList(n, t),
TQObject (),
fCurrentWindow (0),
fDefaultContainer (0)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Destructor.
TEveWindowManager::~TEveWindowManager()
{
}
////////////////////////////////////////////////////////////////////////////////
/// Entry-point for communicating the fact that a window was acted
/// upon in such a way that it should become the current window.
/// If the passed window is already the current one, it is deselected.
///
/// For example, this is called from title-bar, when creating a new
/// window slot, etc.
///
/// If the change is accepted (the manager can refuse to make a
/// window current), the state of window is changed accordingly and
/// WindowSelected() signal is emitted.
void TEveWindowManager::SelectWindow(TEveWindow* window)
{
if (window == fCurrentWindow)
window = 0;
if (fCurrentWindow)
fCurrentWindow->SetCurrent(kFALSE);
fCurrentWindow = window;
if (fCurrentWindow)
fCurrentWindow->SetCurrent(kTRUE);
WindowSelected(fCurrentWindow);
}
////////////////////////////////////////////////////////////////////////////////
/// Called by a window before it gets deleted.
void TEveWindowManager::DeleteWindow(TEveWindow* window)
{
if (window == fCurrentWindow)
{
fCurrentWindow = 0;
WindowSelected(fCurrentWindow);
}
WindowDeleted(window);
}
////////////////////////////////////////////////////////////////////////////////
/// Emit the "WindowDocked(TEveWindow*)" signal.
void TEveWindowManager::WindowDocked(TEveWindow* window)
{
Emit("WindowDocked(TEveWindow*)", (Long_t)window);
}
////////////////////////////////////////////////////////////////////////////////
/// Emit the "WindowUndocked(TEveWindow*)" signal.
void TEveWindowManager::WindowUndocked(TEveWindow* window)
{
Emit("WindowUndocked(TEveWindow*)", (Long_t)window);
}
////////////////////////////////////////////////////////////////////////////////
/// Emit the "WindowSelected(TEveWindow*)" signal.
void TEveWindowManager::WindowSelected(TEveWindow* window)
{
Emit("WindowSelected(TEveWindow*)", (Long_t)window);
}
////////////////////////////////////////////////////////////////////////////////
/// Emit the "WindowDeleted(TEveWindow*)" signal.
void TEveWindowManager::WindowDeleted(TEveWindow* window)
{
Emit("WindowDeleted(TEveWindow*)", (Long_t)window);
}
////////////////////////////////////////////////////////////////////////////////
/// Return current window dynamic-casted to TEveWindowSlot.
TEveWindowSlot* TEveWindowManager::GetCurrentWindowAsSlot() const
{
return dynamic_cast<TEveWindowSlot*>(fCurrentWindow);
}
void TEveWindowManager::SetDefaultContainer(TEveWindow* w)
{
// Set default container window.
// It has to be able to create new slots.
// When main-frames are closed they will place the windows here.
static const TEveException kEH("TEveWindowManager::SetDefaultContainer ");
if ( ! w->CanMakeNewSlots())
throw kEH + "Given window can not make new slots.";
fDefaultContainer = w;
}
////////////////////////////////////////////////////////////////////////////////
/// Destroy window's children and then the window itself.
/// Protected method used during shutdown.
void TEveWindowManager::DestroyWindowRecursively(TEveWindow* window)
{
while (window->HasChildren())
{
TEveWindow* w = dynamic_cast<TEveWindow*>(window->FirstChild());
if (w)
DestroyWindowRecursively(w);
else
window->RemoveElement(window->FirstChild());
}
window->DestroyWindowAndSlot();
}
////////////////////////////////////////////////////////////////////////////////
/// Wait for all windows to shut-down.
void TEveWindowManager::DestroyWindows()
{
while (HasChildren())
{
TEveWindow* w = dynamic_cast<TEveWindow*>(FirstChild());
if (w)
DestroyWindowRecursively(w);
else
RemoveElement(FirstChild());
}
}
////////////////////////////////////////////////////////////////////////////////
/// Hide all eve decorations (title-bar and mini-bar) on all frames.
void TEveWindowManager::HideAllEveDecorations()
{
TEveCompositeFrame *ecf = 0;
TIter wins(TEveCompositeFrame::fgFrameList);
while ((ecf = (TEveCompositeFrame*) wins()))
{
ecf->HideAllDecorations();
ecf->Layout();
}
}
////////////////////////////////////////////////////////////////////////////////
/// Show eve decorations (title-bar or mini-bar) as specified for
/// the contained window on all frames.
void TEveWindowManager::ShowNormalEveDecorations()
{
TEveCompositeFrame *ecf = 0;
TIter wins(TEveCompositeFrame::fgFrameList);
while ((ecf = (TEveCompositeFrame*) wins()))
{
ecf->ShowNormalDecorations();
ecf->Layout();
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set show title-bar state on all frames.
/// This does not modify the per-window settings - call
/// ShowNormalEveDecorations() to restore them.
void TEveWindowManager::SetShowTitleBars(Bool_t state)
{
TEveCompositeFrame *ecf = 0;
TIter wins(TEveCompositeFrame::fgFrameList);
while ((ecf = (TEveCompositeFrame*) wins()))
{
ecf->SetShowTitleBar(state);
ecf->Layout();
}
}