]>
Commit | Line | Data |
---|---|---|
50acee04 | 1 | /////////////////////////////////////////////////////////////////////////////// |
be66f18e | 2 | // Name: src/aui/framemanager.cpp |
50acee04 JS |
3 | // Purpose: wxaui: wx advanced user interface - docking window manager |
4 | // Author: Benjamin I. Williams | |
5 | // Modified by: | |
6 | // Created: 2005-05-17 | |
be66f18e | 7 | // RCS-ID: $Id$ |
50acee04 JS |
8 | // Copyright: (C) Copyright 2005-2006, Kirix Corporation, All Rights Reserved |
9 | // Licence: wxWindows Library Licence, Version 3.1 | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #if wxUSE_AUI | |
27 | ||
28 | #include "wx/aui/framemanager.h" | |
29 | #include "wx/aui/dockart.h" | |
30 | #include "wx/aui/floatpane.h" | |
f244aef2 | 31 | #include "wx/aui/tabmdi.h" |
50acee04 JS |
32 | |
33 | #ifndef WX_PRECOMP | |
5ff14574 | 34 | #include "wx/panel.h" |
be66f18e WS |
35 | #include "wx/settings.h" |
36 | #include "wx/app.h" | |
37 | #include "wx/dcclient.h" | |
38 | #include "wx/dcscreen.h" | |
4e3e485b | 39 | #include "wx/toolbar.h" |
59cf2e49 | 40 | #include "wx/mdi.h" |
155ecd4c | 41 | #include "wx/image.h" |
50acee04 JS |
42 | #endif |
43 | ||
50acee04 JS |
44 | WX_CHECK_BUILD_OPTIONS("wxAUI") |
45 | ||
46 | #include "wx/arrimpl.cpp" | |
47 | WX_DECLARE_OBJARRAY(wxRect, wxAuiRectArray); | |
48 | WX_DEFINE_OBJARRAY(wxAuiRectArray) | |
a3a5df9d BW |
49 | WX_DEFINE_OBJARRAY(wxAuiDockUIPartArray) |
50 | WX_DEFINE_OBJARRAY(wxAuiDockInfoArray) | |
51 | WX_DEFINE_OBJARRAY(wxAuiPaneButtonArray) | |
52 | WX_DEFINE_OBJARRAY(wxAuiPaneInfoArray) | |
50acee04 | 53 | |
a3a5df9d BW |
54 | wxAuiPaneInfo wxAuiNullPaneInfo; |
55 | wxAuiDockInfo wxAuiNullDockInfo; | |
bc07ab17 RD |
56 | DEFINE_EVENT_TYPE(wxEVT_AUI_PANE_BUTTON) |
57 | DEFINE_EVENT_TYPE(wxEVT_AUI_PANE_CLOSE) | |
58 | DEFINE_EVENT_TYPE(wxEVT_AUI_PANE_MAXIMIZE) | |
59 | DEFINE_EVENT_TYPE(wxEVT_AUI_PANE_RESTORE) | |
673727f3 | 60 | DEFINE_EVENT_TYPE(wxEVT_AUI_RENDER) |
bc07ab17 | 61 | DEFINE_EVENT_TYPE(wxEVT_AUI_FIND_MANAGER) |
50acee04 JS |
62 | |
63 | #ifdef __WXMAC__ | |
64 | // a few defines to avoid nameclashes | |
65 | #define __MAC_OS_X_MEMORY_MANAGER_CLEAN__ 1 | |
66 | #define __AIFF__ | |
67 | #include "wx/mac/private.h" | |
68 | #endif | |
69 | ||
be794d62 JS |
70 | #ifdef __WXMSW__ |
71 | #include "wx/msw/wrapwin.h" | |
72 | #include "wx/msw/private.h" | |
73 | #endif | |
74 | ||
a3a5df9d | 75 | IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent) |
4dc79cfb | 76 | IMPLEMENT_CLASS(wxAuiManager, wxEvtHandler) |
f71d596e | 77 | |
f71d596e BW |
78 | |
79 | ||
32e4b03c | 80 | const int auiToolBarLayer = 10; |
f71d596e | 81 | |
952a3bd4 RR |
82 | #ifndef __WXGTK20__ |
83 | ||
f71d596e | 84 | |
7a5b04a6 AB |
85 | class wxPseudoTransparentFrame : public wxFrame |
86 | { | |
87 | public: | |
88 | wxPseudoTransparentFrame(wxWindow* parent = NULL, | |
c08ee034 WS |
89 | wxWindowID id = wxID_ANY, |
90 | const wxString& title = wxEmptyString, | |
7a5b04a6 AB |
91 | const wxPoint& pos = wxDefaultPosition, |
92 | const wxSize& size = wxDefaultSize, | |
93 | long style = wxDEFAULT_FRAME_STYLE, | |
94 | const wxString &name = wxT("frame")) | |
95 | : wxFrame(parent, id, title, pos, size, style | wxFRAME_SHAPED, name) | |
96 | { | |
97 | SetBackgroundStyle(wxBG_STYLE_CUSTOM); | |
98 | m_Amount=0; | |
99 | m_MaxWidth=0; | |
100 | m_MaxHeight=0; | |
0ae3bace RR |
101 | m_lastWidth=0; |
102 | m_lastHeight=0; | |
7a5b04a6 AB |
103 | #ifdef __WXGTK__ |
104 | m_CanSetShape = false; // have to wait for window create event on GTK | |
105 | #else | |
106 | m_CanSetShape = true; | |
107 | #endif | |
8d361e83 | 108 | m_Region = wxRegion(0, 0, 0, 0); |
7a5b04a6 AB |
109 | SetTransparent(0); |
110 | } | |
111 | ||
112 | virtual bool SetTransparent(wxByte alpha) | |
113 | { | |
114 | if (m_CanSetShape) | |
115 | { | |
116 | int w=100; // some defaults | |
117 | int h=100; | |
118 | GetClientSize(&w, &h); | |
8d361e83 | 119 | |
b4ea182b | 120 | m_MaxWidth = w; |
8d361e83 RR |
121 | m_MaxHeight = h; |
122 | m_Amount = alpha; | |
123 | m_Region.Clear(); | |
124 | // m_Region.Union(0, 0, 1, m_MaxWidth); | |
125 | if (m_Amount) | |
7a5b04a6 | 126 | { |
8d361e83 | 127 | for (int y=0; y<m_MaxHeight; y++) |
7a5b04a6 | 128 | { |
8d361e83 RR |
129 | // Reverse the order of the bottom 4 bits |
130 | int j=((y&8)?1:0)|((y&4)?2:0)|((y&2)?4:0)|((y&1)?8:0); | |
131 | if ((j*16+8)<m_Amount) | |
132 | m_Region.Union(0, y, m_MaxWidth, 1); | |
7a5b04a6 | 133 | } |
7a5b04a6 | 134 | } |
8d361e83 RR |
135 | SetShape(m_Region); |
136 | Refresh(); | |
7a5b04a6 AB |
137 | } |
138 | return true; | |
139 | } | |
140 | ||
c08ee034 | 141 | void OnPaint(wxPaintEvent& WXUNUSED(event)) |
7a5b04a6 AB |
142 | { |
143 | wxPaintDC dc(this); | |
c08ee034 | 144 | |
8d361e83 RR |
145 | if (m_Region.IsEmpty()) |
146 | return; | |
147 | ||
148 | #ifdef __WXMAC__ | |
149 | dc.SetBrush(wxColour(128, 192, 255)); | |
150 | #else | |
7a5b04a6 | 151 | dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); |
8d361e83 | 152 | #endif |
7a5b04a6 | 153 | dc.SetPen(*wxTRANSPARENT_PEN); |
c08ee034 | 154 | |
7a5b04a6 | 155 | wxRegionIterator upd(GetUpdateRegion()); // get the update rect list |
c08ee034 | 156 | |
7a5b04a6 AB |
157 | while (upd) |
158 | { | |
159 | wxRect rect(upd.GetRect()); | |
160 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
161 | ||
cedd7b22 | 162 | ++upd; |
7a5b04a6 AB |
163 | } |
164 | } | |
165 | ||
166 | #ifdef __WXGTK__ | |
cf6fec73 BW |
167 | void OnWindowCreate(wxWindowCreateEvent& WXUNUSED(event)) |
168 | { | |
169 | m_CanSetShape=true; | |
170 | SetTransparent(0); | |
171 | } | |
7a5b04a6 AB |
172 | #endif |
173 | ||
8d361e83 RR |
174 | void OnSize(wxSizeEvent& event) |
175 | { | |
0ae3bace RR |
176 | // We sometimes get surplus size events |
177 | if ((event.GetSize().GetWidth() == m_lastWidth) && | |
178 | (event.GetSize().GetHeight() == m_lastHeight)) | |
179 | { | |
180 | event.Skip(); | |
181 | return; | |
182 | } | |
183 | m_lastWidth = event.GetSize().GetWidth(); | |
184 | m_lastHeight = event.GetSize().GetHeight(); | |
b4ea182b | 185 | |
8d361e83 RR |
186 | SetTransparent(m_Amount); |
187 | m_Region.Intersect(0, 0, event.GetSize().GetWidth(), | |
188 | event.GetSize().GetHeight()); | |
189 | SetShape(m_Region); | |
190 | Refresh(); | |
191 | event.Skip(); | |
192 | } | |
193 | ||
7a5b04a6 | 194 | private: |
b4ea182b | 195 | wxByte m_Amount; |
7a5b04a6 AB |
196 | int m_MaxWidth; |
197 | int m_MaxHeight; | |
198 | bool m_CanSetShape; | |
0ae3bace | 199 | int m_lastWidth,m_lastHeight; |
7a5b04a6 AB |
200 | |
201 | wxRegion m_Region; | |
202 | ||
f89f6b74 AB |
203 | DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame) |
204 | DECLARE_EVENT_TABLE() | |
7a5b04a6 AB |
205 | }; |
206 | ||
207 | ||
cf6fec73 | 208 | IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame) |
7a5b04a6 AB |
209 | |
210 | BEGIN_EVENT_TABLE(wxPseudoTransparentFrame, wxFrame) | |
211 | EVT_PAINT(wxPseudoTransparentFrame::OnPaint) | |
8d361e83 | 212 | EVT_SIZE(wxPseudoTransparentFrame::OnSize) |
7a5b04a6 AB |
213 | #ifdef __WXGTK__ |
214 | EVT_WINDOW_CREATE(wxPseudoTransparentFrame::OnWindowCreate) | |
215 | #endif | |
216 | END_EVENT_TABLE() | |
217 | ||
50acee04 | 218 | |
952a3bd4 RR |
219 | #else |
220 | // __WXGTK20__ | |
221 | ||
222 | #include "wx/gtk/private.h" | |
223 | ||
224 | static void | |
225 | gtk_pseudo_window_realized_callback( GtkWidget *m_widget, void *WXUNUSED(win) ) | |
226 | { | |
227 | wxSize disp = wxGetDisplaySize(); | |
228 | int amount = 128; | |
229 | wxRegion region; | |
230 | for (int y=0; y<disp.y; y++) | |
231 | { | |
232 | // Reverse the order of the bottom 4 bits | |
233 | int j=((y&8)?1:0)|((y&4)?2:0)|((y&2)?4:0)|((y&1)?8:0); | |
234 | if ((j*16+8)<amount) | |
235 | region.Union(0, y, disp.x, 1); | |
236 | } | |
237 | gdk_window_shape_combine_region(m_widget->window, region.GetRegion(), 0, 0); | |
238 | } | |
239 | ||
240 | ||
241 | class wxPseudoTransparentFrame: public wxFrame | |
242 | { | |
243 | public: | |
244 | wxPseudoTransparentFrame(wxWindow* parent = NULL, | |
245 | wxWindowID id = wxID_ANY, | |
246 | const wxString& title = wxEmptyString, | |
247 | const wxPoint& pos = wxDefaultPosition, | |
248 | const wxSize& size = wxDefaultSize, | |
249 | long style = wxDEFAULT_FRAME_STYLE, | |
250 | const wxString &name = wxT("frame")) | |
251 | { | |
252 | if (!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
253 | return; | |
254 | ||
255 | m_title = title; | |
be794d62 | 256 | |
952a3bd4 RR |
257 | m_widget = gtk_window_new( GTK_WINDOW_POPUP ); |
258 | ||
259 | g_signal_connect( m_widget, "realize", | |
260 | G_CALLBACK (gtk_pseudo_window_realized_callback), this ); | |
be794d62 | 261 | |
952a3bd4 RR |
262 | GdkColor col; |
263 | col.red = 128 * 256; | |
264 | col.green = 192 * 256; | |
265 | col.blue = 255 * 256; | |
266 | gtk_widget_modify_bg( m_widget, GTK_STATE_NORMAL, &col ); | |
267 | } | |
268 | ||
269 | bool SetTransparent(wxByte WXUNUSED(alpha)) | |
270 | { | |
271 | return true; | |
272 | } | |
be794d62 | 273 | |
952a3bd4 RR |
274 | private: |
275 | DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame) | |
276 | }; | |
277 | ||
278 | IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame) | |
279 | ||
280 | #endif | |
281 | // __WXGTK20__ | |
282 | ||
283 | ||
284 | ||
50acee04 JS |
285 | // -- static utility functions -- |
286 | ||
287 | static wxBitmap wxPaneCreateStippleBitmap() | |
288 | { | |
289 | unsigned char data[] = { 0,0,0,192,192,192, 192,192,192,0,0,0 }; | |
290 | wxImage img(2,2,data,true); | |
291 | return wxBitmap(img); | |
292 | } | |
293 | ||
294 | static void DrawResizeHint(wxDC& dc, const wxRect& rect) | |
295 | { | |
296 | wxBitmap stipple = wxPaneCreateStippleBitmap(); | |
297 | wxBrush brush(stipple); | |
be66f18e | 298 | dc.SetBrush(brush); |
be794d62 JS |
299 | #ifdef __WXMSW__ |
300 | PatBlt(GetHdcOf(dc), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT); | |
301 | #else | |
50acee04 JS |
302 | dc.SetPen(*wxTRANSPARENT_PEN); |
303 | ||
304 | dc.SetLogicalFunction(wxXOR); | |
305 | dc.DrawRectangle(rect); | |
be794d62 | 306 | #endif |
50acee04 JS |
307 | } |
308 | ||
50acee04 | 309 | |
50acee04 JS |
310 | |
311 | // CopyDocksAndPanes() - this utility function creates copies of | |
a3a5df9d BW |
312 | // the dock and pane info. wxAuiDockInfo's usually contain pointers |
313 | // to wxAuiPaneInfo classes, thus this function is necessary to reliably | |
50acee04 JS |
314 | // reconstruct that relationship in the new dock info and pane info arrays |
315 | ||
a3a5df9d BW |
316 | static void CopyDocksAndPanes(wxAuiDockInfoArray& dest_docks, |
317 | wxAuiPaneInfoArray& dest_panes, | |
318 | const wxAuiDockInfoArray& src_docks, | |
319 | const wxAuiPaneInfoArray& src_panes) | |
50acee04 JS |
320 | { |
321 | dest_docks = src_docks; | |
322 | dest_panes = src_panes; | |
323 | int i, j, k, dock_count, pc1, pc2; | |
324 | for (i = 0, dock_count = dest_docks.GetCount(); i < dock_count; ++i) | |
325 | { | |
a3a5df9d | 326 | wxAuiDockInfo& dock = dest_docks.Item(i); |
50acee04 JS |
327 | for (j = 0, pc1 = dock.panes.GetCount(); j < pc1; ++j) |
328 | for (k = 0, pc2 = src_panes.GetCount(); k < pc2; ++k) | |
329 | if (dock.panes.Item(j) == &src_panes.Item(k)) | |
330 | dock.panes.Item(j) = &dest_panes.Item(k); | |
331 | } | |
332 | } | |
333 | ||
334 | // GetMaxLayer() is an internal function which returns | |
335 | // the highest layer inside the specified dock | |
32e4b03c BW |
336 | static int GetMaxLayer(const wxAuiDockInfoArray& docks, |
337 | int dock_direction) | |
50acee04 JS |
338 | { |
339 | int i, dock_count, max_layer = 0; | |
340 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) | |
341 | { | |
a3a5df9d | 342 | wxAuiDockInfo& dock = docks.Item(i); |
50acee04 JS |
343 | if (dock.dock_direction == dock_direction && |
344 | dock.dock_layer > max_layer && !dock.fixed) | |
345 | max_layer = dock.dock_layer; | |
346 | } | |
347 | return max_layer; | |
348 | } | |
349 | ||
350 | ||
351 | // GetMaxRow() is an internal function which returns | |
352 | // the highest layer inside the specified dock | |
a3a5df9d | 353 | static int GetMaxRow(const wxAuiPaneInfoArray& panes, int direction, int layer) |
50acee04 JS |
354 | { |
355 | int i, pane_count, max_row = 0; | |
356 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
357 | { | |
a3a5df9d | 358 | wxAuiPaneInfo& pane = panes.Item(i); |
50acee04 | 359 | if (pane.dock_direction == direction && |
be66f18e | 360 | pane.dock_layer == layer && |
50acee04 JS |
361 | pane.dock_row > max_row) |
362 | max_row = pane.dock_row; | |
363 | } | |
364 | return max_row; | |
365 | } | |
366 | ||
367 | ||
368 | ||
369 | // DoInsertDockLayer() is an internal function that inserts a new dock | |
370 | // layer by incrementing all existing dock layer values by one | |
a3a5df9d | 371 | static void DoInsertDockLayer(wxAuiPaneInfoArray& panes, |
50acee04 JS |
372 | int dock_direction, |
373 | int dock_layer) | |
374 | { | |
375 | int i, pane_count; | |
376 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
377 | { | |
a3a5df9d | 378 | wxAuiPaneInfo& pane = panes.Item(i); |
50acee04 JS |
379 | if (!pane.IsFloating() && |
380 | pane.dock_direction == dock_direction && | |
381 | pane.dock_layer >= dock_layer) | |
382 | pane.dock_layer++; | |
383 | } | |
384 | } | |
385 | ||
386 | // DoInsertDockLayer() is an internal function that inserts a new dock | |
387 | // row by incrementing all existing dock row values by one | |
a3a5df9d | 388 | static void DoInsertDockRow(wxAuiPaneInfoArray& panes, |
50acee04 JS |
389 | int dock_direction, |
390 | int dock_layer, | |
391 | int dock_row) | |
392 | { | |
393 | int i, pane_count; | |
394 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
395 | { | |
a3a5df9d | 396 | wxAuiPaneInfo& pane = panes.Item(i); |
50acee04 JS |
397 | if (!pane.IsFloating() && |
398 | pane.dock_direction == dock_direction && | |
399 | pane.dock_layer == dock_layer && | |
400 | pane.dock_row >= dock_row) | |
401 | pane.dock_row++; | |
402 | } | |
403 | } | |
404 | ||
be66f18e | 405 | // DoInsertDockLayer() is an internal function that inserts a space for |
50acee04 | 406 | // another dock pane by incrementing all existing dock row values by one |
a3a5df9d | 407 | static void DoInsertPane(wxAuiPaneInfoArray& panes, |
50acee04 JS |
408 | int dock_direction, |
409 | int dock_layer, | |
410 | int dock_row, | |
411 | int dock_pos) | |
412 | { | |
413 | int i, pane_count; | |
414 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
415 | { | |
a3a5df9d | 416 | wxAuiPaneInfo& pane = panes.Item(i); |
50acee04 JS |
417 | if (!pane.IsFloating() && |
418 | pane.dock_direction == dock_direction && | |
419 | pane.dock_layer == dock_layer && | |
420 | pane.dock_row == dock_row && | |
421 | pane.dock_pos >= dock_pos) | |
422 | pane.dock_pos++; | |
423 | } | |
424 | } | |
425 | ||
426 | // FindDocks() is an internal function that returns a list of docks which meet | |
427 | // the specified conditions in the parameters and returns a sorted array | |
428 | // (sorted by layer and then row) | |
a3a5df9d | 429 | static void FindDocks(wxAuiDockInfoArray& docks, |
50acee04 JS |
430 | int dock_direction, |
431 | int dock_layer, | |
432 | int dock_row, | |
a3a5df9d | 433 | wxAuiDockInfoPtrArray& arr) |
50acee04 JS |
434 | { |
435 | int begin_layer = dock_layer; | |
436 | int end_layer = dock_layer; | |
437 | int begin_row = dock_row; | |
438 | int end_row = dock_row; | |
439 | int dock_count = docks.GetCount(); | |
440 | int layer, row, i, max_row = 0, max_layer = 0; | |
441 | ||
442 | // discover the maximum dock layer and the max row | |
443 | for (i = 0; i < dock_count; ++i) | |
444 | { | |
445 | max_row = wxMax(max_row, docks.Item(i).dock_row); | |
446 | max_layer = wxMax(max_layer, docks.Item(i).dock_layer); | |
447 | } | |
be66f18e | 448 | |
50acee04 JS |
449 | // if no dock layer was specified, search all dock layers |
450 | if (dock_layer == -1) | |
451 | { | |
452 | begin_layer = 0; | |
453 | end_layer = max_layer; | |
454 | } | |
be66f18e | 455 | |
50acee04 JS |
456 | // if no dock row was specified, search all dock row |
457 | if (dock_row == -1) | |
458 | { | |
459 | begin_row = 0; | |
460 | end_row = max_row; | |
461 | } | |
462 | ||
463 | arr.Clear(); | |
464 | ||
465 | for (layer = begin_layer; layer <= end_layer; ++layer) | |
466 | for (row = begin_row; row <= end_row; ++row) | |
467 | for (i = 0; i < dock_count; ++i) | |
468 | { | |
a3a5df9d | 469 | wxAuiDockInfo& d = docks.Item(i); |
50acee04 JS |
470 | if (dock_direction == -1 || dock_direction == d.dock_direction) |
471 | { | |
472 | if (d.dock_layer == layer && d.dock_row == row) | |
473 | arr.Add(&d); | |
474 | } | |
475 | } | |
476 | } | |
477 | ||
478 | // FindPaneInDock() looks up a specified window pointer inside a dock. | |
a3a5df9d BW |
479 | // If found, the corresponding wxAuiPaneInfo pointer is returned, otherwise NULL. |
480 | static wxAuiPaneInfo* FindPaneInDock(const wxAuiDockInfo& dock, wxWindow* window) | |
50acee04 JS |
481 | { |
482 | int i, count = dock.panes.GetCount(); | |
483 | for (i = 0; i < count; ++i) | |
484 | { | |
a3a5df9d | 485 | wxAuiPaneInfo* p = dock.panes.Item(i); |
50acee04 JS |
486 | if (p->window == window) |
487 | return p; | |
488 | } | |
489 | return NULL; | |
490 | } | |
491 | ||
492 | // RemovePaneFromDocks() removes a pane window from all docks | |
9259ed34 | 493 | // with a possible exception specified by parameter "ex_cept" |
a3a5df9d BW |
494 | static void RemovePaneFromDocks(wxAuiDockInfoArray& docks, |
495 | wxAuiPaneInfo& pane, | |
496 | wxAuiDockInfo* ex_cept = NULL ) | |
50acee04 JS |
497 | { |
498 | int i, dock_count; | |
499 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) | |
500 | { | |
a3a5df9d | 501 | wxAuiDockInfo& d = docks.Item(i); |
9259ed34 | 502 | if (&d == ex_cept) |
50acee04 | 503 | continue; |
a3a5df9d | 504 | wxAuiPaneInfo* pi = FindPaneInDock(d, pane.window); |
50acee04 JS |
505 | if (pi) |
506 | d.panes.Remove(pi); | |
507 | } | |
508 | } | |
509 | ||
1ca1b2b8 BW |
510 | /* |
511 | // This function works fine, and may be used in the future | |
512 | ||
50acee04 JS |
513 | // RenumberDockRows() takes a dock and assigns sequential numbers |
514 | // to existing rows. Basically it takes out the gaps; so if a | |
515 | // dock has rows with numbers 0,2,5, they will become 0,1,2 | |
a3a5df9d | 516 | static void RenumberDockRows(wxAuiDockInfoPtrArray& docks) |
50acee04 | 517 | { |
7afb5814 | 518 | int i, dock_count; |
50acee04 JS |
519 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) |
520 | { | |
a3a5df9d | 521 | wxAuiDockInfo& dock = *docks.Item(i); |
50acee04 | 522 | dock.dock_row = i; |
be794d62 | 523 | |
1ca1b2b8 BW |
524 | int j, pane_count; |
525 | for (j = 0, pane_count = dock.panes.GetCount(); j < pane_count; ++j) | |
526 | dock.panes.Item(j)->dock_row = i; | |
50acee04 JS |
527 | } |
528 | } | |
1ca1b2b8 | 529 | */ |
50acee04 JS |
530 | |
531 | ||
cc0196c7 BW |
532 | // SetActivePane() sets the active pane, as well as cycles through |
533 | // every other pane and makes sure that all others' active flags | |
534 | // are turned off | |
a3a5df9d | 535 | static void SetActivePane(wxAuiPaneInfoArray& panes, wxWindow* active_pane) |
50acee04 JS |
536 | { |
537 | int i, pane_count; | |
538 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
539 | { | |
a3a5df9d BW |
540 | wxAuiPaneInfo& pane = panes.Item(i); |
541 | pane.state &= ~wxAuiPaneInfo::optionActive; | |
50acee04 | 542 | if (pane.window == active_pane) |
a3a5df9d | 543 | pane.state |= wxAuiPaneInfo::optionActive; |
50acee04 JS |
544 | } |
545 | } | |
546 | ||
547 | ||
548 | // this function is used to sort panes by dock position | |
a3a5df9d | 549 | static int PaneSortFunc(wxAuiPaneInfo** p1, wxAuiPaneInfo** p2) |
50acee04 JS |
550 | { |
551 | return ((*p1)->dock_pos < (*p2)->dock_pos) ? -1 : 1; | |
552 | } | |
553 | ||
554 | ||
a3a5df9d | 555 | // -- wxAuiManager class implementation -- |
50acee04 JS |
556 | |
557 | ||
a3a5df9d | 558 | BEGIN_EVENT_TABLE(wxAuiManager, wxEvtHandler) |
bc07ab17 | 559 | EVT_AUI_PANE_BUTTON(wxAuiManager::OnPaneButton) |
a3a5df9d BW |
560 | EVT_AUI_RENDER(wxAuiManager::OnRender) |
561 | EVT_PAINT(wxAuiManager::OnPaint) | |
562 | EVT_ERASE_BACKGROUND(wxAuiManager::OnEraseBackground) | |
563 | EVT_SIZE(wxAuiManager::OnSize) | |
564 | EVT_SET_CURSOR(wxAuiManager::OnSetCursor) | |
565 | EVT_LEFT_DOWN(wxAuiManager::OnLeftDown) | |
566 | EVT_LEFT_UP(wxAuiManager::OnLeftUp) | |
567 | EVT_MOTION(wxAuiManager::OnMotion) | |
568 | EVT_LEAVE_WINDOW(wxAuiManager::OnLeaveWindow) | |
569 | EVT_CHILD_FOCUS(wxAuiManager::OnChildFocus) | |
bc07ab17 | 570 | EVT_AUI_FIND_MANAGER(wxAuiManager::OnFindManager) |
a3a5df9d | 571 | EVT_TIMER(101, wxAuiManager::OnHintFadeTimer) |
50acee04 JS |
572 | END_EVENT_TABLE() |
573 | ||
574 | ||
a3a5df9d | 575 | wxAuiManager::wxAuiManager(wxWindow* managed_wnd, unsigned int flags) |
50acee04 JS |
576 | { |
577 | m_action = actionNone; | |
578 | m_last_mouse_move = wxPoint(); | |
579 | m_hover_button = NULL; | |
a3a5df9d | 580 | m_art = new wxAuiDefaultDockArt; |
50acee04 JS |
581 | m_hint_wnd = NULL; |
582 | m_flags = flags; | |
c3008402 | 583 | m_skipping = false; |
37106ab2 | 584 | m_has_maximized = false; |
26da5e4f | 585 | m_frame = NULL; |
a6b7a521 VZ |
586 | m_dock_constraint_x = 0.3; |
587 | m_dock_constraint_y = 0.3; | |
1dc6ec2c | 588 | m_reserved = NULL; |
7608fd01 | 589 | |
461125ea | 590 | if (managed_wnd) |
50acee04 | 591 | { |
461125ea | 592 | SetManagedWindow(managed_wnd); |
50acee04 JS |
593 | } |
594 | } | |
595 | ||
a3a5df9d | 596 | wxAuiManager::~wxAuiManager() |
50acee04 | 597 | { |
46eac9e4 JS |
598 | // NOTE: It's possible that the windows have already been destroyed by the |
599 | // time this dtor is called, so this loop can result in memory access via | |
600 | // invalid pointers, resulting in a crash. So it will be disabled while | |
601 | // waiting for a better solution. | |
602 | #if 0 | |
fb48a5f8 | 603 | for ( size_t i = 0; i < m_panes.size(); i++ ) |
7608fd01 | 604 | { |
fb48a5f8 VZ |
605 | wxAuiPaneInfo& pinfo = m_panes[i]; |
606 | if (pinfo.window && !pinfo.window->GetParent()) | |
7608fd01 VZ |
607 | delete pinfo.window; |
608 | } | |
46eac9e4 | 609 | #endif |
7608fd01 | 610 | |
50acee04 JS |
611 | delete m_art; |
612 | } | |
613 | ||
9e1fc0e4 BW |
614 | // creates a floating frame for the windows |
615 | wxAuiFloatingFrame* wxAuiManager::CreateFloatingFrame(wxWindow* parent, | |
616 | const wxAuiPaneInfo& pane_info) | |
bc429ce0 | 617 | { |
9e1fc0e4 | 618 | return new wxAuiFloatingFrame(parent, this, pane_info); |
bc429ce0 RR |
619 | } |
620 | ||
858a3a7a JS |
621 | bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p)) |
622 | { | |
623 | // if a key modifier is pressed while dragging the frame, | |
624 | // don't dock the window | |
625 | return !(wxGetKeyState(WXK_CONTROL) || wxGetKeyState(WXK_ALT)); | |
626 | } | |
627 | ||
a3a5df9d | 628 | // GetPane() looks up a wxAuiPaneInfo structure based |
50acee04 | 629 | // on the supplied window pointer. Upon failure, GetPane() |
a3a5df9d BW |
630 | // returns an empty wxAuiPaneInfo, a condition which can be checked |
631 | // by calling wxAuiPaneInfo::IsOk(). | |
50acee04 JS |
632 | // |
633 | // The pane info's structure may then be modified. Once a pane's | |
a3a5df9d | 634 | // info is modified, wxAuiManager::Update() must be called to |
50acee04 JS |
635 | // realize the changes in the UI. |
636 | ||
a3a5df9d | 637 | wxAuiPaneInfo& wxAuiManager::GetPane(wxWindow* window) |
50acee04 JS |
638 | { |
639 | int i, pane_count; | |
640 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
641 | { | |
a3a5df9d | 642 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
643 | if (p.window == window) |
644 | return p; | |
645 | } | |
a3a5df9d | 646 | return wxAuiNullPaneInfo; |
50acee04 JS |
647 | } |
648 | ||
649 | // this version of GetPane() looks up a pane based on a | |
650 | // 'pane name', see above comment for more info | |
a3a5df9d | 651 | wxAuiPaneInfo& wxAuiManager::GetPane(const wxString& name) |
50acee04 JS |
652 | { |
653 | int i, pane_count; | |
654 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
655 | { | |
a3a5df9d | 656 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
657 | if (p.name == name) |
658 | return p; | |
659 | } | |
a3a5df9d | 660 | return wxAuiNullPaneInfo; |
50acee04 JS |
661 | } |
662 | ||
663 | // GetAllPanes() returns a reference to all the pane info structures | |
a3a5df9d | 664 | wxAuiPaneInfoArray& wxAuiManager::GetAllPanes() |
50acee04 JS |
665 | { |
666 | return m_panes; | |
667 | } | |
668 | ||
669 | // HitTest() is an internal function which determines | |
670 | // which UI item the specified coordinates are over | |
671 | // (x,y) specify a position in client coordinates | |
a3a5df9d | 672 | wxAuiDockUIPart* wxAuiManager::HitTest(int x, int y) |
50acee04 | 673 | { |
a3a5df9d | 674 | wxAuiDockUIPart* result = NULL; |
50acee04 JS |
675 | |
676 | int i, part_count; | |
677 | for (i = 0, part_count = m_uiparts.GetCount(); i < part_count; ++i) | |
678 | { | |
a3a5df9d | 679 | wxAuiDockUIPart* item = &m_uiparts.Item(i); |
be66f18e WS |
680 | |
681 | // we are not interested in typeDock, because this space | |
50acee04 JS |
682 | // isn't used to draw anything, just for measurements; |
683 | // besides, the entire dock area is covered with other | |
684 | // rectangles, which we are interested in. | |
a3a5df9d | 685 | if (item->type == wxAuiDockUIPart::typeDock) |
50acee04 | 686 | continue; |
be66f18e | 687 | |
50acee04 JS |
688 | // if we already have a hit on a more specific item, we are not |
689 | // interested in a pane hit. If, however, we don't already have | |
690 | // a hit, returning a pane hit is necessary for some operations | |
a3a5df9d BW |
691 | if ((item->type == wxAuiDockUIPart::typePane || |
692 | item->type == wxAuiDockUIPart::typePaneBorder) && result) | |
50acee04 | 693 | continue; |
be66f18e | 694 | |
50acee04 | 695 | // if the point is inside the rectangle, we have a hit |
22a35096 | 696 | if (item->rect.Contains(x,y)) |
50acee04 JS |
697 | result = item; |
698 | } | |
be66f18e | 699 | |
50acee04 JS |
700 | return result; |
701 | } | |
702 | ||
703 | ||
704 | // SetFlags() and GetFlags() allow the owner to set various | |
a3a5df9d BW |
705 | // options which are global to wxAuiManager |
706 | void wxAuiManager::SetFlags(unsigned int flags) | |
50acee04 | 707 | { |
cf6fec73 BW |
708 | // find out if we have to call UpdateHintWindowConfig() |
709 | bool update_hint_wnd = false; | |
710 | unsigned int hint_mask = wxAUI_MGR_TRANSPARENT_HINT | | |
711 | wxAUI_MGR_VENETIAN_BLINDS_HINT | | |
712 | wxAUI_MGR_RECTANGLE_HINT; | |
713 | if ((flags & hint_mask) != (m_flags & hint_mask)) | |
714 | update_hint_wnd = true; | |
715 | ||
716 | ||
717 | // set the new flags | |
50acee04 | 718 | m_flags = flags; |
7608fd01 | 719 | |
cf6fec73 BW |
720 | if (update_hint_wnd) |
721 | { | |
722 | UpdateHintWindowConfig(); | |
723 | } | |
50acee04 JS |
724 | } |
725 | ||
a3a5df9d | 726 | unsigned int wxAuiManager::GetFlags() const |
50acee04 JS |
727 | { |
728 | return m_flags; | |
729 | } | |
730 | ||
731 | ||
461125ea BW |
732 | // don't use these anymore as they are deprecated |
733 | // use Set/GetManagedFrame() instead | |
a3a5df9d | 734 | void wxAuiManager::SetFrame(wxFrame* frame) |
461125ea BW |
735 | { |
736 | SetManagedWindow((wxWindow*)frame); | |
737 | } | |
738 | ||
a3a5df9d | 739 | wxFrame* wxAuiManager::GetFrame() const |
461125ea BW |
740 | { |
741 | return (wxFrame*)m_frame; | |
742 | } | |
743 | ||
744 | ||
4dc79cfb BW |
745 | // this function will return the aui manager for a given |
746 | // window. The |window| parameter should be any child window | |
747 | // or grand-child window (and so on) of the frame/window | |
748 | // managed by wxAuiManager. The |window| parameter does not | |
749 | // need to be managed by the manager itself. | |
750 | wxAuiManager* wxAuiManager::GetManager(wxWindow* window) | |
751 | { | |
bc07ab17 | 752 | wxAuiManagerEvent evt(wxEVT_AUI_FIND_MANAGER); |
bc9e3321 | 753 | evt.SetManager(NULL); |
4dc79cfb BW |
754 | evt.ResumePropagation(wxEVENT_PROPAGATE_MAX); |
755 | if (!window->ProcessEvent(evt)) | |
756 | return NULL; | |
7608fd01 | 757 | |
4dc79cfb BW |
758 | return evt.GetManager(); |
759 | } | |
760 | ||
761 | ||
a3a5df9d | 762 | void wxAuiManager::UpdateHintWindowConfig() |
cf6fec73 BW |
763 | { |
764 | // find out if the the system can do transparent frames | |
765 | bool can_do_transparent = false; | |
7608fd01 | 766 | |
cf6fec73 BW |
767 | wxWindow* w = m_frame; |
768 | while (w) | |
769 | { | |
770 | if (w->IsKindOf(CLASSINFO(wxFrame))) | |
771 | { | |
772 | wxFrame* f = static_cast<wxFrame*>(w); | |
cf6fec73 | 773 | can_do_transparent = f->CanSetTransparent(); |
cf6fec73 BW |
774 | break; |
775 | } | |
7608fd01 | 776 | |
cf6fec73 BW |
777 | w = w->GetParent(); |
778 | } | |
7608fd01 | 779 | |
cf6fec73 BW |
780 | // if there is an existing hint window, delete it |
781 | if (m_hint_wnd) | |
782 | { | |
783 | m_hint_wnd->Destroy(); | |
784 | m_hint_wnd = NULL; | |
785 | } | |
786 | ||
787 | m_hint_fademax = 50; | |
788 | m_hint_wnd = NULL; | |
7608fd01 | 789 | |
cf6fec73 | 790 | if ((m_flags & wxAUI_MGR_TRANSPARENT_HINT) && can_do_transparent) |
7608fd01 | 791 | { |
cf6fec73 BW |
792 | // Make a window to use for a transparent hint |
793 | #if defined(__WXMSW__) || defined(__WXGTK__) | |
794 | m_hint_wnd = new wxFrame(m_frame, wxID_ANY, wxEmptyString, | |
795 | wxDefaultPosition, wxSize(1,1), | |
796 | wxFRAME_TOOL_WINDOW | | |
797 | wxFRAME_FLOAT_ON_PARENT | | |
798 | wxFRAME_NO_TASKBAR | | |
799 | wxNO_BORDER); | |
800 | ||
801 | m_hint_wnd->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); | |
802 | #elif defined(__WXMAC__) | |
803 | // Using a miniframe with float and tool styles keeps the parent | |
804 | // frame activated and highlighted as such... | |
805 | m_hint_wnd = new wxMiniFrame(m_frame, wxID_ANY, wxEmptyString, | |
806 | wxDefaultPosition, wxSize(1,1), | |
807 | wxFRAME_FLOAT_ON_PARENT | |
808 | | wxFRAME_TOOL_WINDOW ); | |
809 | ||
810 | // Can't set the bg colour of a Frame in wxMac | |
811 | wxPanel* p = new wxPanel(m_hint_wnd); | |
812 | ||
813 | // The default wxSYS_COLOUR_ACTIVECAPTION colour is a light silver | |
814 | // color that is really hard to see, especially transparent. | |
815 | // Until a better system color is decided upon we'll just use | |
816 | // blue. | |
817 | p->SetBackgroundColour(*wxBLUE); | |
818 | #endif | |
7608fd01 | 819 | |
cf6fec73 | 820 | } |
7608fd01 | 821 | else |
cf6fec73 BW |
822 | { |
823 | if ((m_flags & wxAUI_MGR_TRANSPARENT_HINT) != 0 || | |
824 | (m_flags & wxAUI_MGR_VENETIAN_BLINDS_HINT) != 0) | |
825 | { | |
826 | // system can't support transparent fade, or the venetian | |
827 | // blinds effect was explicitly requested | |
828 | m_hint_wnd = new wxPseudoTransparentFrame(m_frame, | |
829 | wxID_ANY, | |
830 | wxEmptyString, | |
831 | wxDefaultPosition, | |
832 | wxSize(1,1), | |
833 | wxFRAME_TOOL_WINDOW | | |
834 | wxFRAME_FLOAT_ON_PARENT | | |
835 | wxFRAME_NO_TASKBAR | | |
836 | wxNO_BORDER); | |
837 | m_hint_fademax = 128; | |
838 | } | |
839 | } | |
840 | } | |
461125ea BW |
841 | |
842 | ||
843 | // SetManagedWindow() is usually called once when the frame | |
50acee04 JS |
844 | // manager class is being initialized. "frame" specifies |
845 | // the frame which should be managed by the frame mananger | |
a3a5df9d | 846 | void wxAuiManager::SetManagedWindow(wxWindow* wnd) |
50acee04 | 847 | { |
cf6fec73 | 848 | wxASSERT_MSG(wnd, wxT("specified window must be non-NULL")); |
50acee04 | 849 | |
cf6fec73 | 850 | m_frame = wnd; |
50acee04 JS |
851 | m_frame->PushEventHandler(this); |
852 | ||
853 | #if wxUSE_MDI | |
854 | // if the owner is going to manage an MDI parent frame, | |
855 | // we need to add the MDI client window as the default | |
856 | // center pane | |
857 | ||
cf6fec73 | 858 | if (m_frame->IsKindOf(CLASSINFO(wxMDIParentFrame))) |
50acee04 | 859 | { |
cf6fec73 | 860 | wxMDIParentFrame* mdi_frame = (wxMDIParentFrame*)m_frame; |
9db1b540 | 861 | wxWindow* client_window = mdi_frame->GetClientWindow(); |
50acee04 JS |
862 | |
863 | wxASSERT_MSG(client_window, wxT("Client window is NULL!")); | |
864 | ||
865 | AddPane(client_window, | |
a3a5df9d | 866 | wxAuiPaneInfo().Name(wxT("mdiclient")). |
50acee04 JS |
867 | CenterPane().PaneBorder(false)); |
868 | } | |
cedd7b22 | 869 | else if (m_frame->IsKindOf(CLASSINFO(wxAuiMDIParentFrame))) |
f244aef2 BW |
870 | { |
871 | wxAuiMDIParentFrame* mdi_frame = (wxAuiMDIParentFrame*)m_frame; | |
872 | wxAuiMDIClientWindow* client_window = mdi_frame->GetClientWindow(); | |
873 | wxASSERT_MSG(client_window, wxT("Client window is NULL!")); | |
874 | ||
875 | AddPane(client_window, | |
876 | wxAuiPaneInfo().Name(wxT("mdiclient")). | |
877 | CenterPane().PaneBorder(false)); | |
878 | } | |
879 | ||
50acee04 | 880 | #endif |
50f3c41d | 881 | |
cf6fec73 | 882 | UpdateHintWindowConfig(); |
50acee04 JS |
883 | } |
884 | ||
885 | ||
886 | // UnInit() must be called, usually in the destructor | |
887 | // of the frame class. If it is not called, usually this | |
888 | // will result in a crash upon program exit | |
a3a5df9d | 889 | void wxAuiManager::UnInit() |
50acee04 | 890 | { |
26da5e4f BW |
891 | if (m_frame) |
892 | { | |
893 | m_frame->RemoveEventHandler(this); | |
894 | } | |
50acee04 JS |
895 | } |
896 | ||
461125ea | 897 | // GetManagedWindow() returns the window pointer being managed |
a3a5df9d | 898 | wxWindow* wxAuiManager::GetManagedWindow() const |
50acee04 JS |
899 | { |
900 | return m_frame; | |
901 | } | |
902 | ||
a3a5df9d | 903 | wxAuiDockArt* wxAuiManager::GetArtProvider() const |
50acee04 JS |
904 | { |
905 | return m_art; | |
906 | } | |
907 | ||
a3a5df9d | 908 | void wxAuiManager::ProcessMgrEvent(wxAuiManagerEvent& event) |
50acee04 JS |
909 | { |
910 | // first, give the owner frame a chance to override | |
911 | if (m_frame) | |
912 | { | |
913 | if (m_frame->ProcessEvent(event)) | |
914 | return; | |
915 | } | |
916 | ||
917 | ProcessEvent(event); | |
918 | } | |
919 | ||
a3a5df9d | 920 | // SetArtProvider() instructs wxAuiManager to use the |
50acee04 | 921 | // specified art provider for all drawing calls. This allows |
cc0196c7 | 922 | // plugable look-and-feel features. The pointer that is |
a3a5df9d | 923 | // passed to this method subsequently belongs to wxAuiManager, |
cc0196c7 | 924 | // and is deleted in the frame manager destructor |
a3a5df9d | 925 | void wxAuiManager::SetArtProvider(wxAuiDockArt* art_provider) |
50acee04 JS |
926 | { |
927 | // delete the last art provider, if any | |
928 | delete m_art; | |
be66f18e | 929 | |
50acee04 JS |
930 | // assign the new art provider |
931 | m_art = art_provider; | |
932 | } | |
933 | ||
cc0196c7 | 934 | |
a3a5df9d | 935 | bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info) |
50acee04 JS |
936 | { |
937 | // check if the pane has a valid window | |
938 | if (!window) | |
939 | return false; | |
940 | ||
dc4334d7 BW |
941 | // check if the window is already managed by us |
942 | if (GetPane(pane_info.window).IsOk()) | |
943 | return false; | |
944 | ||
945 | // check if the pane name already exists, this could reveal a | |
946 | // bug in the library user's application | |
2a8f8889 | 947 | bool already_exists = false; |
2a8f8889 BW |
948 | if (!pane_info.name.empty() && GetPane(pane_info.name).IsOk()) |
949 | { | |
950 | wxFAIL_MSG(wxT("A pane with that name already exists in the manager!")); | |
951 | already_exists = true; | |
952 | } | |
50acee04 | 953 | |
46067c35 | 954 | // if the new pane is docked then we should undo maximize |
32e4b03c | 955 | if (pane_info.IsDocked()) |
46067c35 BW |
956 | RestoreMaximizedPane(); |
957 | ||
50acee04 JS |
958 | m_panes.Add(pane_info); |
959 | ||
a3a5df9d | 960 | wxAuiPaneInfo& pinfo = m_panes.Last(); |
50acee04 JS |
961 | |
962 | // set the pane window | |
963 | pinfo.window = window; | |
be66f18e | 964 | |
2a8f8889 | 965 | |
50acee04 | 966 | // if the pane's name identifier is blank, create a random string |
2a8f8889 | 967 | if (pinfo.name.empty() || already_exists) |
50acee04 | 968 | { |
0e9c9923 | 969 | pinfo.name.Printf(wxT("%08lx%08x%08x%08lx"), |
50acee04 JS |
970 | ((unsigned long)pinfo.window) & 0xffffffff, |
971 | (unsigned int)time(NULL), | |
99ae6124 WS |
972 | #ifdef __WXWINCE__ |
973 | (unsigned int)GetTickCount(), | |
974 | #else | |
0e9c9923 | 975 | (unsigned int)clock(), |
99ae6124 | 976 | #endif |
0e9c9923 | 977 | (unsigned long)m_panes.GetCount()); |
50acee04 | 978 | } |
be66f18e | 979 | |
50acee04 JS |
980 | // set initial proportion (if not already set) |
981 | if (pinfo.dock_proportion == 0) | |
982 | pinfo.dock_proportion = 100000; | |
983 | ||
37106ab2 BW |
984 | if (pinfo.HasMaximizeButton()) |
985 | { | |
a3a5df9d | 986 | wxAuiPaneButton button; |
37106ab2 BW |
987 | button.button_id = wxAUI_BUTTON_MAXIMIZE_RESTORE; |
988 | pinfo.buttons.Add(button); | |
989 | } | |
7608fd01 | 990 | |
50d5ad7d BW |
991 | if (pinfo.HasPinButton()) |
992 | { | |
993 | wxAuiPaneButton button; | |
994 | button.button_id = wxAUI_BUTTON_PIN; | |
995 | pinfo.buttons.Add(button); | |
996 | } | |
7608fd01 | 997 | |
37106ab2 | 998 | if (pinfo.HasCloseButton()) |
50acee04 | 999 | { |
a3a5df9d | 1000 | wxAuiPaneButton button; |
4953f8cf | 1001 | button.button_id = wxAUI_BUTTON_CLOSE; |
50acee04 JS |
1002 | pinfo.buttons.Add(button); |
1003 | } | |
be66f18e | 1004 | |
50acee04 JS |
1005 | if (pinfo.best_size == wxDefaultSize && |
1006 | pinfo.window) | |
1007 | { | |
1008 | pinfo.best_size = pinfo.window->GetClientSize(); | |
1009 | ||
1010 | if (pinfo.window->IsKindOf(CLASSINFO(wxToolBar))) | |
1011 | { | |
1012 | // GetClientSize() doesn't get the best size for | |
1013 | // a toolbar under some newer versions of wxWidgets, | |
1014 | // so use GetBestSize() | |
1015 | pinfo.best_size = pinfo.window->GetBestSize(); | |
be66f18e | 1016 | |
50acee04 JS |
1017 | // for some reason, wxToolBar::GetBestSize() is returning |
1018 | // a size that is a pixel shy of the correct amount. | |
1019 | // I believe this to be the correct action, until | |
1020 | // wxToolBar::GetBestSize() is fixed. Is this assumption | |
1021 | // correct? | |
c118d8b0 JS |
1022 | // commented out by JACS 2007-9-08 after having added a pixel in wxMSW's wxToolBar::DoGetBestSize() |
1023 | // pinfo.best_size.y++; | |
50acee04 | 1024 | } |
be66f18e | 1025 | |
50acee04 JS |
1026 | if (pinfo.min_size != wxDefaultSize) |
1027 | { | |
1028 | if (pinfo.best_size.x < pinfo.min_size.x) | |
1029 | pinfo.best_size.x = pinfo.min_size.x; | |
1030 | if (pinfo.best_size.y < pinfo.min_size.y) | |
1031 | pinfo.best_size.y = pinfo.min_size.y; | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | return true; | |
1036 | } | |
1037 | ||
a3a5df9d | 1038 | bool wxAuiManager::AddPane(wxWindow* window, |
1dc6ec2c BW |
1039 | int direction, |
1040 | const wxString& caption) | |
50acee04 | 1041 | { |
a3a5df9d | 1042 | wxAuiPaneInfo pinfo; |
50acee04 JS |
1043 | pinfo.Caption(caption); |
1044 | switch (direction) | |
1045 | { | |
1046 | case wxTOP: pinfo.Top(); break; | |
1047 | case wxBOTTOM: pinfo.Bottom(); break; | |
1048 | case wxLEFT: pinfo.Left(); break; | |
1049 | case wxRIGHT: pinfo.Right(); break; | |
1050 | case wxCENTER: pinfo.CenterPane(); break; | |
1051 | } | |
1052 | return AddPane(window, pinfo); | |
1053 | } | |
1054 | ||
a3a5df9d | 1055 | bool wxAuiManager::AddPane(wxWindow* window, |
1dc6ec2c BW |
1056 | const wxAuiPaneInfo& pane_info, |
1057 | const wxPoint& drop_pos) | |
0603bb28 BW |
1058 | { |
1059 | if (!AddPane(window, pane_info)) | |
1060 | return false; | |
c08ee034 | 1061 | |
a3a5df9d | 1062 | wxAuiPaneInfo& pane = GetPane(window); |
c08ee034 | 1063 | |
0603bb28 | 1064 | DoDrop(m_docks, m_panes, pane, drop_pos, wxPoint(0,0)); |
c08ee034 | 1065 | |
0603bb28 BW |
1066 | return true; |
1067 | } | |
1068 | ||
a3a5df9d | 1069 | bool wxAuiManager::InsertPane(wxWindow* window, const wxAuiPaneInfo& pane_info, |
50acee04 JS |
1070 | int insert_level) |
1071 | { | |
1072 | // shift the panes around, depending on the insert level | |
1073 | switch (insert_level) | |
1074 | { | |
1075 | case wxAUI_INSERT_PANE: | |
1076 | DoInsertPane(m_panes, | |
1077 | pane_info.dock_direction, | |
1078 | pane_info.dock_layer, | |
1079 | pane_info.dock_row, | |
1080 | pane_info.dock_pos); | |
1081 | break; | |
1082 | case wxAUI_INSERT_ROW: | |
1083 | DoInsertDockRow(m_panes, | |
1084 | pane_info.dock_direction, | |
1085 | pane_info.dock_layer, | |
1086 | pane_info.dock_row); | |
1087 | break; | |
1088 | case wxAUI_INSERT_DOCK: | |
1089 | DoInsertDockLayer(m_panes, | |
1090 | pane_info.dock_direction, | |
1091 | pane_info.dock_layer); | |
1092 | break; | |
1093 | } | |
be66f18e | 1094 | |
50acee04 JS |
1095 | // if the window already exists, we are basically just moving/inserting the |
1096 | // existing window. If it doesn't exist, we need to add it and insert it | |
a3a5df9d | 1097 | wxAuiPaneInfo& existing_pane = GetPane(window); |
50acee04 JS |
1098 | if (!existing_pane.IsOk()) |
1099 | { | |
1100 | return AddPane(window, pane_info); | |
1101 | } | |
7608fd01 | 1102 | else |
50acee04 JS |
1103 | { |
1104 | if (pane_info.IsFloating()) | |
1105 | { | |
1106 | existing_pane.Float(); | |
1107 | if (pane_info.floating_pos != wxDefaultPosition) | |
1108 | existing_pane.FloatingPosition(pane_info.floating_pos); | |
1109 | if (pane_info.floating_size != wxDefaultSize) | |
1110 | existing_pane.FloatingSize(pane_info.floating_size); | |
1111 | } | |
7608fd01 | 1112 | else |
50acee04 | 1113 | { |
46067c35 BW |
1114 | // if the new pane is docked then we should undo maximize |
1115 | RestoreMaximizedPane(); | |
1116 | ||
50acee04 JS |
1117 | existing_pane.Direction(pane_info.dock_direction); |
1118 | existing_pane.Layer(pane_info.dock_layer); | |
1119 | existing_pane.Row(pane_info.dock_row); | |
1120 | existing_pane.Position(pane_info.dock_pos); | |
1121 | } | |
1122 | } | |
1123 | ||
1124 | return true; | |
1125 | } | |
1126 | ||
be66f18e | 1127 | |
cc0196c7 BW |
1128 | // DetachPane() removes a pane from the frame manager. This |
1129 | // method will not destroy the window that is removed. | |
a3a5df9d | 1130 | bool wxAuiManager::DetachPane(wxWindow* window) |
50acee04 JS |
1131 | { |
1132 | int i, count; | |
1133 | for (i = 0, count = m_panes.GetCount(); i < count; ++i) | |
1134 | { | |
a3a5df9d | 1135 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
1136 | if (p.window == window) |
1137 | { | |
1138 | if (p.frame) | |
1139 | { | |
1140 | // we have a floating frame which is being detached. We need to | |
1141 | // reparent it to m_frame and destroy the floating frame | |
1142 | ||
1143 | // reduce flicker | |
1144 | p.window->SetSize(1,1); | |
26178b5d BW |
1145 | |
1146 | if (p.frame->IsShown()) | |
1147 | p.frame->Show(false); | |
50acee04 JS |
1148 | |
1149 | // reparent to m_frame and destroy the pane | |
32e4b03c | 1150 | if (m_action_window == p.frame) |
7453065a | 1151 | { |
49fa1dbb RR |
1152 | m_action_window = NULL; |
1153 | } | |
7608fd01 | 1154 | |
50acee04 JS |
1155 | p.window->Reparent(m_frame); |
1156 | p.frame->SetSizer(NULL); | |
1157 | p.frame->Destroy(); | |
1158 | p.frame = NULL; | |
1159 | } | |
c08ee034 | 1160 | |
2f68106f BW |
1161 | // make sure there are no references to this pane in our uiparts, |
1162 | // just in case the caller doesn't call Update() immediately after | |
1163 | // the DetachPane() call. This prevets obscure crashes which would | |
1164 | // happen at window repaint if the caller forgets to call Update() | |
1165 | int pi, part_count; | |
1166 | for (pi = 0, part_count = (int)m_uiparts.GetCount(); pi < part_count; ++pi) | |
1167 | { | |
a3a5df9d | 1168 | wxAuiDockUIPart& part = m_uiparts.Item(pi); |
2f68106f BW |
1169 | if (part.pane == &p) |
1170 | { | |
1171 | m_uiparts.RemoveAt(pi); | |
1172 | part_count--; | |
1173 | pi--; | |
1174 | continue; | |
1175 | } | |
1176 | } | |
c08ee034 | 1177 | |
50acee04 JS |
1178 | m_panes.RemoveAt(i); |
1179 | return true; | |
1180 | } | |
1181 | } | |
1182 | return false; | |
1183 | } | |
1184 | ||
7da1b21e | 1185 | // ClosePane() destroys or hides the pane depending on its flags |
a3a5df9d | 1186 | void wxAuiManager::ClosePane(wxAuiPaneInfo& pane_info) |
fa96a36e | 1187 | { |
37106ab2 | 1188 | // if we were maximized, restore |
7453065a BW |
1189 | if (pane_info.IsMaximized()) |
1190 | { | |
37106ab2 BW |
1191 | RestorePane(pane_info); |
1192 | } | |
1193 | ||
fa96a36e | 1194 | // first, hide the window |
7453065a BW |
1195 | if (pane_info.window && pane_info.window->IsShown()) |
1196 | { | |
fa96a36e RR |
1197 | pane_info.window->Show(false); |
1198 | } | |
1199 | ||
1200 | // make sure that we are the parent of this window | |
7453065a BW |
1201 | if (pane_info.window && pane_info.window->GetParent() != m_frame) |
1202 | { | |
fa96a36e RR |
1203 | pane_info.window->Reparent(m_frame); |
1204 | } | |
1205 | ||
1206 | // if we have a frame, destroy it | |
7453065a BW |
1207 | if (pane_info.frame) |
1208 | { | |
fa96a36e RR |
1209 | pane_info.frame->Destroy(); |
1210 | pane_info.frame = NULL; | |
1211 | } | |
1212 | ||
1213 | // now we need to either destroy or hide the pane | |
7608fd01 | 1214 | if (pane_info.IsDestroyOnClose()) |
fa96a36e RR |
1215 | { |
1216 | wxWindow * window = pane_info.window; | |
1217 | DetachPane(window); | |
32e4b03c | 1218 | if (window) |
7453065a | 1219 | { |
fa96a36e RR |
1220 | window->Destroy(); |
1221 | } | |
7608fd01 VZ |
1222 | } |
1223 | else | |
fa96a36e RR |
1224 | { |
1225 | pane_info.Hide(); | |
1226 | } | |
1227 | } | |
50acee04 | 1228 | |
a3a5df9d | 1229 | void wxAuiManager::MaximizePane(wxAuiPaneInfo& pane_info) |
37106ab2 BW |
1230 | { |
1231 | int i, pane_count; | |
1232 | ||
1233 | // un-maximize and hide all other panes | |
1234 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
1235 | { | |
a3a5df9d | 1236 | wxAuiPaneInfo& p = m_panes.Item(i); |
7453065a BW |
1237 | if (!p.IsToolbar()) |
1238 | { | |
37106ab2 | 1239 | p.Restore(); |
7608fd01 | 1240 | |
8d0634ab | 1241 | // save hidden state |
1dc6ec2c BW |
1242 | p.SetFlag(wxAuiPaneInfo::savedHiddenState, |
1243 | p.HasFlag(wxAuiPaneInfo::optionHidden)); | |
8d0634ab BW |
1244 | |
1245 | // hide the pane, because only the newly | |
1246 | // maximized pane should show | |
37106ab2 BW |
1247 | p.Hide(); |
1248 | } | |
1249 | } | |
1250 | ||
1251 | // mark ourselves maximized | |
1252 | pane_info.Maximize(); | |
1253 | pane_info.Show(); | |
1254 | m_has_maximized = true; | |
1255 | ||
1256 | // last, show the window | |
7453065a BW |
1257 | if (pane_info.window && !pane_info.window->IsShown()) |
1258 | { | |
37106ab2 BW |
1259 | pane_info.window->Show(true); |
1260 | } | |
1261 | } | |
1262 | ||
a3a5df9d | 1263 | void wxAuiManager::RestorePane(wxAuiPaneInfo& pane_info) |
37106ab2 BW |
1264 | { |
1265 | int i, pane_count; | |
1266 | ||
1267 | // restore all the panes | |
1268 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
1269 | { | |
a3a5df9d | 1270 | wxAuiPaneInfo& p = m_panes.Item(i); |
7453065a BW |
1271 | if (!p.IsToolbar()) |
1272 | { | |
1dc6ec2c BW |
1273 | p.SetFlag(wxAuiPaneInfo::optionHidden, |
1274 | p.HasFlag(wxAuiPaneInfo::savedHiddenState)); | |
37106ab2 BW |
1275 | } |
1276 | } | |
1277 | ||
1278 | // mark ourselves non-maximized | |
1279 | pane_info.Restore(); | |
1280 | m_has_maximized = false; | |
1281 | ||
1282 | // last, show the window | |
7453065a BW |
1283 | if (pane_info.window && !pane_info.window->IsShown()) |
1284 | { | |
37106ab2 BW |
1285 | pane_info.window->Show(true); |
1286 | } | |
1287 | } | |
1288 | ||
a3a5df9d | 1289 | void wxAuiManager::RestoreMaximizedPane() |
37106ab2 BW |
1290 | { |
1291 | int i, pane_count; | |
1292 | ||
1293 | // restore all the panes | |
1294 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
1295 | { | |
a3a5df9d | 1296 | wxAuiPaneInfo& p = m_panes.Item(i); |
32e4b03c | 1297 | if (p.IsMaximized()) |
7453065a | 1298 | { |
37106ab2 BW |
1299 | RestorePane(p); |
1300 | break; | |
1301 | } | |
1302 | } | |
1303 | } | |
1304 | ||
50acee04 JS |
1305 | // EscapeDelimiters() changes ";" into "\;" and "|" into "\|" |
1306 | // in the input string. This is an internal functions which is | |
1307 | // used for saving perspectives | |
1308 | static wxString EscapeDelimiters(const wxString& s) | |
1309 | { | |
1310 | wxString result; | |
be66f18e | 1311 | result.Alloc(s.length()); |
50acee04 JS |
1312 | const wxChar* ch = s.c_str(); |
1313 | while (*ch) | |
1314 | { | |
1315 | if (*ch == wxT(';') || *ch == wxT('|')) | |
1316 | result += wxT('\\'); | |
1317 | result += *ch; | |
1318 | ++ch; | |
1319 | } | |
1320 | return result; | |
1321 | } | |
1322 | ||
a3a5df9d | 1323 | wxString wxAuiManager::SavePaneInfo(wxAuiPaneInfo& pane) |
75c8d68f AB |
1324 | { |
1325 | wxString result = wxT("name="); | |
1326 | result += EscapeDelimiters(pane.name); | |
1327 | result += wxT(";"); | |
1328 | ||
1329 | result += wxT("caption="); | |
1330 | result += EscapeDelimiters(pane.caption); | |
1331 | result += wxT(";"); | |
1332 | ||
1333 | result += wxString::Format(wxT("state=%u;"), pane.state); | |
1334 | result += wxString::Format(wxT("dir=%d;"), pane.dock_direction); | |
1335 | result += wxString::Format(wxT("layer=%d;"), pane.dock_layer); | |
1336 | result += wxString::Format(wxT("row=%d;"), pane.dock_row); | |
1337 | result += wxString::Format(wxT("pos=%d;"), pane.dock_pos); | |
1338 | result += wxString::Format(wxT("prop=%d;"), pane.dock_proportion); | |
1339 | result += wxString::Format(wxT("bestw=%d;"), pane.best_size.x); | |
1340 | result += wxString::Format(wxT("besth=%d;"), pane.best_size.y); | |
1341 | result += wxString::Format(wxT("minw=%d;"), pane.min_size.x); | |
1342 | result += wxString::Format(wxT("minh=%d;"), pane.min_size.y); | |
1343 | result += wxString::Format(wxT("maxw=%d;"), pane.max_size.x); | |
1344 | result += wxString::Format(wxT("maxh=%d;"), pane.max_size.y); | |
1345 | result += wxString::Format(wxT("floatx=%d;"), pane.floating_pos.x); | |
1346 | result += wxString::Format(wxT("floaty=%d;"), pane.floating_pos.y); | |
1347 | result += wxString::Format(wxT("floatw=%d;"), pane.floating_size.x); | |
1348 | result += wxString::Format(wxT("floath=%d"), pane.floating_size.y); | |
1349 | ||
1350 | return result; | |
1351 | } | |
1352 | ||
13201165 | 1353 | // Load a "pane" with the pane infor settings in pane_part |
a3a5df9d | 1354 | void wxAuiManager::LoadPaneInfo(wxString pane_part, wxAuiPaneInfo &pane) |
75c8d68f AB |
1355 | { |
1356 | // replace escaped characters so we can | |
1357 | // split up the string easily | |
1358 | pane_part.Replace(wxT("\\|"), wxT("\a")); | |
1359 | pane_part.Replace(wxT("\\;"), wxT("\b")); | |
1360 | ||
13201165 AB |
1361 | while(1) |
1362 | { | |
1363 | wxString val_part = pane_part.BeforeFirst(wxT(';')); | |
1364 | pane_part = pane_part.AfterFirst(wxT(';')); | |
1365 | wxString val_name = val_part.BeforeFirst(wxT('=')); | |
1366 | wxString value = val_part.AfterFirst(wxT('=')); | |
1367 | val_name.MakeLower(); | |
1368 | val_name.Trim(true); | |
1369 | val_name.Trim(false); | |
1370 | value.Trim(true); | |
1371 | value.Trim(false); | |
b4ea182b | 1372 | |
13201165 AB |
1373 | if (val_name.empty()) |
1374 | break; | |
b4ea182b | 1375 | |
13201165 AB |
1376 | if (val_name == wxT("name")) |
1377 | pane.name = value; | |
1378 | else if (val_name == wxT("caption")) | |
1379 | pane.caption = value; | |
1380 | else if (val_name == wxT("state")) | |
1381 | pane.state = (unsigned int)wxAtoi(value.c_str()); | |
1382 | else if (val_name == wxT("dir")) | |
1383 | pane.dock_direction = wxAtoi(value.c_str()); | |
1384 | else if (val_name == wxT("layer")) | |
1385 | pane.dock_layer = wxAtoi(value.c_str()); | |
1386 | else if (val_name == wxT("row")) | |
1387 | pane.dock_row = wxAtoi(value.c_str()); | |
1388 | else if (val_name == wxT("pos")) | |
1389 | pane.dock_pos = wxAtoi(value.c_str()); | |
1390 | else if (val_name == wxT("prop")) | |
1391 | pane.dock_proportion = wxAtoi(value.c_str()); | |
1392 | else if (val_name == wxT("bestw")) | |
1393 | pane.best_size.x = wxAtoi(value.c_str()); | |
1394 | else if (val_name == wxT("besth")) | |
1395 | pane.best_size.y = wxAtoi(value.c_str()); | |
1396 | else if (val_name == wxT("minw")) | |
1397 | pane.min_size.x = wxAtoi(value.c_str()); | |
1398 | else if (val_name == wxT("minh")) | |
1399 | pane.min_size.y = wxAtoi(value.c_str()); | |
1400 | else if (val_name == wxT("maxw")) | |
1401 | pane.max_size.x = wxAtoi(value.c_str()); | |
1402 | else if (val_name == wxT("maxh")) | |
1403 | pane.max_size.y = wxAtoi(value.c_str()); | |
1404 | else if (val_name == wxT("floatx")) | |
1405 | pane.floating_pos.x = wxAtoi(value.c_str()); | |
1406 | else if (val_name == wxT("floaty")) | |
1407 | pane.floating_pos.y = wxAtoi(value.c_str()); | |
1408 | else if (val_name == wxT("floatw")) | |
1409 | pane.floating_size.x = wxAtoi(value.c_str()); | |
1410 | else if (val_name == wxT("floath")) | |
1411 | pane.floating_size.y = wxAtoi(value.c_str()); | |
1412 | else { | |
1413 | wxFAIL_MSG(wxT("Bad Perspective String")); | |
1414 | } | |
75c8d68f AB |
1415 | } |
1416 | ||
1417 | // replace escaped characters so we can | |
1418 | // split up the string easily | |
1419 | pane.name.Replace(wxT("\a"), wxT("|")); | |
1420 | pane.name.Replace(wxT("\b"), wxT(";")); | |
1421 | pane.caption.Replace(wxT("\a"), wxT("|")); | |
1422 | pane.caption.Replace(wxT("\b"), wxT(";")); | |
1423 | pane_part.Replace(wxT("\a"), wxT("|")); | |
1424 | pane_part.Replace(wxT("\b"), wxT(";")); | |
1425 | ||
13201165 | 1426 | return; |
75c8d68f AB |
1427 | } |
1428 | ||
50acee04 JS |
1429 | |
1430 | // SavePerspective() saves all pane information as a single string. | |
1431 | // This string may later be fed into LoadPerspective() to restore | |
1432 | // all pane settings. This save and load mechanism allows an | |
1433 | // exact pane configuration to be saved and restored at a later time | |
1434 | ||
a3a5df9d | 1435 | wxString wxAuiManager::SavePerspective() |
50acee04 JS |
1436 | { |
1437 | wxString result; | |
1438 | result.Alloc(500); | |
1dc6ec2c | 1439 | result = wxT("layout2|"); |
50acee04 JS |
1440 | |
1441 | int pane_i, pane_count = m_panes.GetCount(); | |
1442 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1443 | { | |
a3a5df9d | 1444 | wxAuiPaneInfo& pane = m_panes.Item(pane_i); |
75c8d68f | 1445 | result += SavePaneInfo(pane)+wxT("|"); |
50acee04 | 1446 | } |
be66f18e | 1447 | |
50acee04 JS |
1448 | int dock_i, dock_count = m_docks.GetCount(); |
1449 | for (dock_i = 0; dock_i < dock_count; ++dock_i) | |
1450 | { | |
a3a5df9d | 1451 | wxAuiDockInfo& dock = m_docks.Item(dock_i); |
be66f18e | 1452 | |
50acee04 JS |
1453 | result += wxString::Format(wxT("dock_size(%d,%d,%d)=%d|"), |
1454 | dock.dock_direction, dock.dock_layer, | |
1455 | dock.dock_row, dock.size); | |
1456 | } | |
be66f18e | 1457 | |
50acee04 JS |
1458 | return result; |
1459 | } | |
1460 | ||
1461 | // LoadPerspective() loads a layout which was saved with SavePerspective() | |
1462 | // If the "update" flag parameter is true, the GUI will immediately be updated | |
1463 | ||
a3a5df9d | 1464 | bool wxAuiManager::LoadPerspective(const wxString& layout, bool update) |
50acee04 JS |
1465 | { |
1466 | wxString input = layout; | |
1467 | wxString part; | |
be66f18e | 1468 | |
50acee04 | 1469 | // check layout string version |
1dc6ec2c BW |
1470 | // 'layout1' = wxAUI 0.9.0 - wxAUI 0.9.2 |
1471 | // 'layout2' = wxAUI 0.9.2 (wxWidgets 2.8) | |
50acee04 JS |
1472 | part = input.BeforeFirst(wxT('|')); |
1473 | input = input.AfterFirst(wxT('|')); | |
1474 | part.Trim(true); | |
1475 | part.Trim(false); | |
1dc6ec2c | 1476 | if (part != wxT("layout2")) |
50acee04 | 1477 | return false; |
be66f18e | 1478 | |
50acee04 JS |
1479 | // mark all panes currently managed as docked and hidden |
1480 | int pane_i, pane_count = m_panes.GetCount(); | |
1481 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1482 | m_panes.Item(pane_i).Dock().Hide(); | |
1483 | ||
1484 | // clear out the dock array; this will be reconstructed | |
1485 | m_docks.Clear(); | |
be66f18e | 1486 | |
50acee04 JS |
1487 | // replace escaped characters so we can |
1488 | // split up the string easily | |
1489 | input.Replace(wxT("\\|"), wxT("\a")); | |
1490 | input.Replace(wxT("\\;"), wxT("\b")); | |
be66f18e | 1491 | |
50acee04 JS |
1492 | while (1) |
1493 | { | |
a3a5df9d | 1494 | wxAuiPaneInfo pane; |
50acee04 JS |
1495 | |
1496 | wxString pane_part = input.BeforeFirst(wxT('|')); | |
1497 | input = input.AfterFirst(wxT('|')); | |
1498 | pane_part.Trim(true); | |
1499 | ||
1500 | // if the string is empty, we're done parsing | |
be66f18e | 1501 | if (pane_part.empty()) |
50acee04 JS |
1502 | break; |
1503 | ||
50acee04 JS |
1504 | if (pane_part.Left(9) == wxT("dock_size")) |
1505 | { | |
1506 | wxString val_name = pane_part.BeforeFirst(wxT('=')); | |
1507 | wxString value = pane_part.AfterFirst(wxT('=')); | |
be66f18e | 1508 | |
50acee04 JS |
1509 | long dir, layer, row, size; |
1510 | wxString piece = val_name.AfterFirst(wxT('(')); | |
1511 | piece = piece.BeforeLast(wxT(')')); | |
1512 | piece.BeforeFirst(wxT(',')).ToLong(&dir); | |
1513 | piece = piece.AfterFirst(wxT(',')); | |
1514 | piece.BeforeFirst(wxT(',')).ToLong(&layer); | |
1515 | piece.AfterFirst(wxT(',')).ToLong(&row); | |
1516 | value.ToLong(&size); | |
be66f18e | 1517 | |
a3a5df9d | 1518 | wxAuiDockInfo dock; |
50acee04 JS |
1519 | dock.dock_direction = dir; |
1520 | dock.dock_layer = layer; | |
1521 | dock.dock_row = row; | |
1522 | dock.size = size; | |
1523 | m_docks.Add(dock); | |
1524 | continue; | |
1525 | } | |
1526 | ||
75c8d68f AB |
1527 | // Undo our escaping as LoadPaneInfo needs to take an unescaped |
1528 | // name so it can be called by external callers | |
1529 | pane_part.Replace(wxT("\a"), wxT("|")); | |
1530 | pane_part.Replace(wxT("\b"), wxT(";")); | |
1531 | ||
13201165 | 1532 | LoadPaneInfo(pane_part, pane); |
be66f18e | 1533 | |
a3a5df9d | 1534 | wxAuiPaneInfo& p = GetPane(pane.name); |
50acee04 JS |
1535 | if (!p.IsOk()) |
1536 | { | |
1537 | // the pane window couldn't be found | |
88664cda BW |
1538 | // in the existing layout -- skip it |
1539 | continue; | |
50acee04 | 1540 | } |
be66f18e | 1541 | |
75c8d68f | 1542 | p.SafeSet(pane); |
50acee04 | 1543 | } |
be66f18e | 1544 | |
50acee04 JS |
1545 | if (update) |
1546 | Update(); | |
1547 | ||
1548 | return true; | |
1549 | } | |
1550 | ||
a3a5df9d | 1551 | void wxAuiManager::GetPanePositionsAndSizes(wxAuiDockInfo& dock, |
bb38f6c8 BW |
1552 | wxArrayInt& positions, |
1553 | wxArrayInt& sizes) | |
50acee04 | 1554 | { |
254a3429 BW |
1555 | int caption_size = m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE); |
1556 | int pane_border_size = m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE); | |
1557 | int gripper_size = m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE); | |
50acee04 JS |
1558 | |
1559 | positions.Empty(); | |
1560 | sizes.Empty(); | |
1561 | ||
1562 | int offset, action_pane = -1; | |
1563 | int pane_i, pane_count = dock.panes.GetCount(); | |
1564 | ||
1565 | // find the pane marked as our action pane | |
1566 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1567 | { | |
a3a5df9d | 1568 | wxAuiPaneInfo& pane = *(dock.panes.Item(pane_i)); |
50acee04 | 1569 | |
a3a5df9d | 1570 | if (pane.state & wxAuiPaneInfo::actionPane) |
50acee04 JS |
1571 | { |
1572 | wxASSERT_MSG(action_pane==-1, wxT("Too many fixed action panes")); | |
1573 | action_pane = pane_i; | |
1574 | } | |
1575 | } | |
be66f18e | 1576 | |
50acee04 JS |
1577 | // set up each panes default position, and |
1578 | // determine the size (width or height, depending | |
1579 | // on the dock's orientation) of each pane | |
1580 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1581 | { | |
a3a5df9d | 1582 | wxAuiPaneInfo& pane = *(dock.panes.Item(pane_i)); |
50acee04 JS |
1583 | positions.Add(pane.dock_pos); |
1584 | int size = 0; | |
be66f18e | 1585 | |
50acee04 JS |
1586 | if (pane.HasBorder()) |
1587 | size += (pane_border_size*2); | |
be66f18e | 1588 | |
50acee04 JS |
1589 | if (dock.IsHorizontal()) |
1590 | { | |
1591 | if (pane.HasGripper() && !pane.HasGripperTop()) | |
1592 | size += gripper_size; | |
1593 | size += pane.best_size.x; | |
1594 | } | |
7608fd01 | 1595 | else |
50acee04 JS |
1596 | { |
1597 | if (pane.HasGripper() && pane.HasGripperTop()) | |
1598 | size += gripper_size; | |
1599 | ||
1600 | if (pane.HasCaption()) | |
be66f18e | 1601 | size += caption_size; |
50acee04 JS |
1602 | size += pane.best_size.y; |
1603 | } | |
be66f18e | 1604 | |
50acee04 JS |
1605 | sizes.Add(size); |
1606 | } | |
1607 | ||
1608 | // if there is no action pane, just return the default | |
1609 | // positions (as specified in pane.pane_pos) | |
1610 | if (action_pane == -1) | |
1611 | return; | |
1612 | ||
1613 | offset = 0; | |
1614 | for (pane_i = action_pane-1; pane_i >= 0; --pane_i) | |
1615 | { | |
1616 | int amount = positions[pane_i+1] - (positions[pane_i] + sizes[pane_i]); | |
1617 | ||
1618 | if (amount >= 0) | |
1619 | offset += amount; | |
7608fd01 | 1620 | else |
50acee04 JS |
1621 | positions[pane_i] -= -amount; |
1622 | ||
1623 | offset += sizes[pane_i]; | |
1624 | } | |
be66f18e | 1625 | |
50acee04 JS |
1626 | // if the dock mode is fixed, make sure none of the panes |
1627 | // overlap; we will bump panes that overlap | |
1628 | offset = 0; | |
1629 | for (pane_i = action_pane; pane_i < pane_count; ++pane_i) | |
1630 | { | |
1631 | int amount = positions[pane_i] - offset; | |
1632 | if (amount >= 0) | |
1633 | offset += amount; | |
7608fd01 | 1634 | else |
50acee04 JS |
1635 | positions[pane_i] += -amount; |
1636 | ||
1637 | offset += sizes[pane_i]; | |
1638 | } | |
1639 | } | |
1640 | ||
1641 | ||
a3a5df9d | 1642 | void wxAuiManager::LayoutAddPane(wxSizer* cont, |
1dc6ec2c BW |
1643 | wxAuiDockInfo& dock, |
1644 | wxAuiPaneInfo& pane, | |
1645 | wxAuiDockUIPartArray& uiparts, | |
1646 | bool spacer_only) | |
be66f18e | 1647 | { |
a3a5df9d | 1648 | wxAuiDockUIPart part; |
50acee04 JS |
1649 | wxSizerItem* sizer_item; |
1650 | ||
254a3429 BW |
1651 | int caption_size = m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE); |
1652 | int gripper_size = m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE); | |
1653 | int pane_border_size = m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE); | |
1654 | int pane_button_size = m_art->GetMetric(wxAUI_DOCKART_PANE_BUTTON_SIZE); | |
50acee04 JS |
1655 | |
1656 | // find out the orientation of the item (orientation for panes | |
1657 | // is the same as the dock's orientation) | |
1658 | int orientation; | |
1659 | if (dock.IsHorizontal()) | |
1660 | orientation = wxHORIZONTAL; | |
7608fd01 | 1661 | else |
50acee04 JS |
1662 | orientation = wxVERTICAL; |
1663 | ||
1664 | // this variable will store the proportion | |
1665 | // value that the pane will receive | |
1666 | int pane_proportion = pane.dock_proportion; | |
1667 | ||
1668 | wxBoxSizer* horz_pane_sizer = new wxBoxSizer(wxHORIZONTAL); | |
1669 | wxBoxSizer* vert_pane_sizer = new wxBoxSizer(wxVERTICAL); | |
1670 | ||
1671 | if (pane.HasGripper()) | |
1672 | { | |
1673 | if (pane.HasGripperTop()) | |
1674 | sizer_item = vert_pane_sizer ->Add(1, gripper_size, 0, wxEXPAND); | |
be66f18e | 1675 | else |
50acee04 JS |
1676 | sizer_item = horz_pane_sizer ->Add(gripper_size, 1, 0, wxEXPAND); |
1677 | ||
a3a5df9d | 1678 | part.type = wxAuiDockUIPart::typeGripper; |
50acee04 JS |
1679 | part.dock = &dock; |
1680 | part.pane = &pane; | |
1681 | part.button = NULL; | |
1682 | part.orientation = orientation; | |
1683 | part.cont_sizer = horz_pane_sizer; | |
1684 | part.sizer_item = sizer_item; | |
1685 | uiparts.Add(part); | |
1686 | } | |
1687 | ||
1688 | if (pane.HasCaption()) | |
1689 | { | |
1690 | // create the caption sizer | |
1691 | wxBoxSizer* caption_sizer = new wxBoxSizer(wxHORIZONTAL); | |
1692 | ||
1693 | sizer_item = caption_sizer->Add(1, caption_size, 1, wxEXPAND); | |
1694 | ||
a3a5df9d | 1695 | part.type = wxAuiDockUIPart::typeCaption; |
50acee04 JS |
1696 | part.dock = &dock; |
1697 | part.pane = &pane; | |
1698 | part.button = NULL; | |
1699 | part.orientation = orientation; | |
1700 | part.cont_sizer = vert_pane_sizer; | |
1701 | part.sizer_item = sizer_item; | |
1702 | int caption_part_idx = uiparts.GetCount(); | |
1703 | uiparts.Add(part); | |
1704 | ||
1705 | // add pane buttons to the caption | |
1706 | int i, button_count; | |
1707 | for (i = 0, button_count = pane.buttons.GetCount(); | |
1708 | i < button_count; ++i) | |
1709 | { | |
a3a5df9d | 1710 | wxAuiPaneButton& button = pane.buttons.Item(i); |
50acee04 JS |
1711 | |
1712 | sizer_item = caption_sizer->Add(pane_button_size, | |
1713 | caption_size, | |
1714 | 0, wxEXPAND); | |
1715 | ||
a3a5df9d | 1716 | part.type = wxAuiDockUIPart::typePaneButton; |
50acee04 JS |
1717 | part.dock = &dock; |
1718 | part.pane = &pane; | |
1719 | part.button = &button; | |
1720 | part.orientation = orientation; | |
1721 | part.cont_sizer = caption_sizer; | |
1722 | part.sizer_item = sizer_item; | |
1723 | uiparts.Add(part); | |
1724 | } | |
7608fd01 | 1725 | |
8896cb72 BW |
1726 | // if we have buttons, add a little space to the right |
1727 | // of them to ease visual crowding | |
1728 | if (button_count >= 1) | |
1729 | { | |
1730 | caption_sizer->Add(3,1); | |
1731 | } | |
50acee04 JS |
1732 | |
1733 | // add the caption sizer | |
1734 | sizer_item = vert_pane_sizer->Add(caption_sizer, 0, wxEXPAND); | |
1735 | ||
1736 | uiparts.Item(caption_part_idx).sizer_item = sizer_item; | |
1737 | } | |
1738 | ||
1739 | // add the pane window itself | |
1740 | if (spacer_only) | |
1741 | { | |
1742 | sizer_item = vert_pane_sizer->Add(1, 1, 1, wxEXPAND); | |
1743 | } | |
696978ee | 1744 | else |
50acee04 JS |
1745 | { |
1746 | sizer_item = vert_pane_sizer->Add(pane.window, 1, wxEXPAND); | |
5c62cb6c | 1747 | // Don't do this because it breaks the pane size in floating windows |
dec588bd BW |
1748 | // BIW: Right now commenting this out is causing problems with |
1749 | // an mdi client window as the center pane. | |
1750 | vert_pane_sizer->SetItemMinSize(pane.window, 1, 1); | |
50acee04 JS |
1751 | } |
1752 | ||
a3a5df9d | 1753 | part.type = wxAuiDockUIPart::typePane; |
50acee04 JS |
1754 | part.dock = &dock; |
1755 | part.pane = &pane; | |
1756 | part.button = NULL; | |
1757 | part.orientation = orientation; | |
1758 | part.cont_sizer = vert_pane_sizer; | |
1759 | part.sizer_item = sizer_item; | |
1760 | uiparts.Add(part); | |
1761 | ||
1762 | ||
1763 | // determine if the pane should have a minimum size; if the pane is | |
1dc6ec2c | 1764 | // non-resizable (fixed) then we must set a minimum size. Alternatively, |
50acee04 | 1765 | // if the pane.min_size is set, we must use that value as well |
be66f18e | 1766 | |
50acee04 JS |
1767 | wxSize min_size = pane.min_size; |
1768 | if (pane.IsFixed()) | |
1769 | { | |
1770 | if (min_size == wxDefaultSize) | |
1771 | { | |
1772 | min_size = pane.best_size; | |
1773 | pane_proportion = 0; | |
1774 | } | |
1775 | } | |
be66f18e | 1776 | |
50acee04 JS |
1777 | if (min_size != wxDefaultSize) |
1778 | { | |
1779 | vert_pane_sizer->SetItemMinSize( | |
1780 | vert_pane_sizer->GetChildren().GetCount()-1, | |
1781 | min_size.x, min_size.y); | |
1782 | } | |
1783 | ||
1784 | ||
1785 | // add the verticle sizer (caption, pane window) to the | |
1786 | // horizontal sizer (gripper, verticle sizer) | |
1787 | horz_pane_sizer->Add(vert_pane_sizer, 1, wxEXPAND); | |
1788 | ||
1789 | // finally, add the pane sizer to the dock sizer | |
1790 | ||
1791 | if (pane.HasBorder()) | |
1792 | { | |
1793 | // allowing space for the pane's border | |
1794 | sizer_item = cont->Add(horz_pane_sizer, pane_proportion, | |
1795 | wxEXPAND | wxALL, pane_border_size); | |
1796 | ||
a3a5df9d | 1797 | part.type = wxAuiDockUIPart::typePaneBorder; |
50acee04 JS |
1798 | part.dock = &dock; |
1799 | part.pane = &pane; | |
1800 | part.button = NULL; | |
1801 | part.orientation = orientation; | |
1802 | part.cont_sizer = cont; | |
1803 | part.sizer_item = sizer_item; | |
1804 | uiparts.Add(part); | |
1805 | } | |
7608fd01 | 1806 | else |
50acee04 JS |
1807 | { |
1808 | sizer_item = cont->Add(horz_pane_sizer, pane_proportion, wxEXPAND); | |
1809 | } | |
1810 | } | |
1811 | ||
a3a5df9d | 1812 | void wxAuiManager::LayoutAddDock(wxSizer* cont, |
bb38f6c8 BW |
1813 | wxAuiDockInfo& dock, |
1814 | wxAuiDockUIPartArray& uiparts, | |
1815 | bool spacer_only) | |
50acee04 JS |
1816 | { |
1817 | wxSizerItem* sizer_item; | |
a3a5df9d | 1818 | wxAuiDockUIPart part; |
50acee04 | 1819 | |
254a3429 | 1820 | int sash_size = m_art->GetMetric(wxAUI_DOCKART_SASH_SIZE); |
50acee04 JS |
1821 | int orientation = dock.IsHorizontal() ? wxHORIZONTAL : wxVERTICAL; |
1822 | ||
1823 | // resizable bottom and right docks have a sash before them | |
37106ab2 | 1824 | if (!m_has_maximized && !dock.fixed && (dock.dock_direction == wxAUI_DOCK_BOTTOM || |
50acee04 JS |
1825 | dock.dock_direction == wxAUI_DOCK_RIGHT)) |
1826 | { | |
1827 | sizer_item = cont->Add(sash_size, sash_size, 0, wxEXPAND); | |
1828 | ||
a3a5df9d | 1829 | part.type = wxAuiDockUIPart::typeDockSizer; |
50acee04 JS |
1830 | part.orientation = orientation; |
1831 | part.dock = &dock; | |
1832 | part.pane = NULL; | |
1833 | part.button = NULL; | |
1834 | part.cont_sizer = cont; | |
1835 | part.sizer_item = sizer_item; | |
1836 | uiparts.Add(part); | |
1837 | } | |
1838 | ||
1839 | // create the sizer for the dock | |
1840 | wxSizer* dock_sizer = new wxBoxSizer(orientation); | |
1841 | ||
1842 | // add each pane to the dock | |
37106ab2 | 1843 | bool has_maximized_pane = false; |
50acee04 JS |
1844 | int pane_i, pane_count = dock.panes.GetCount(); |
1845 | ||
1846 | if (dock.fixed) | |
1847 | { | |
1848 | wxArrayInt pane_positions, pane_sizes; | |
be66f18e | 1849 | |
50acee04 JS |
1850 | // figure out the real pane positions we will |
1851 | // use, without modifying the each pane's pane_pos member | |
1852 | GetPanePositionsAndSizes(dock, pane_positions, pane_sizes); | |
1853 | ||
1854 | int offset = 0; | |
1855 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1856 | { | |
a3a5df9d | 1857 | wxAuiPaneInfo& pane = *(dock.panes.Item(pane_i)); |
50acee04 | 1858 | int pane_pos = pane_positions.Item(pane_i); |
7608fd01 | 1859 | |
bb38f6c8 | 1860 | if (pane.IsMaximized()) |
37106ab2 | 1861 | has_maximized_pane = true; |
bb38f6c8 | 1862 | |
50acee04 JS |
1863 | |
1864 | int amount = pane_pos - offset; | |
1865 | if (amount > 0) | |
1866 | { | |
1867 | if (dock.IsVertical()) | |
1868 | sizer_item = dock_sizer->Add(1, amount, 0, wxEXPAND); | |
7608fd01 | 1869 | else |
50acee04 JS |
1870 | sizer_item = dock_sizer->Add(amount, 1, 0, wxEXPAND); |
1871 | ||
a3a5df9d | 1872 | part.type = wxAuiDockUIPart::typeBackground; |
50acee04 JS |
1873 | part.dock = &dock; |
1874 | part.pane = NULL; | |
1875 | part.button = NULL; | |
1876 | part.orientation = (orientation==wxHORIZONTAL) ? wxVERTICAL:wxHORIZONTAL; | |
1877 | part.cont_sizer = dock_sizer; | |
1878 | part.sizer_item = sizer_item; | |
1879 | uiparts.Add(part); | |
1880 | ||
1881 | offset += amount; | |
1882 | } | |
1883 | ||
1884 | LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only); | |
1885 | ||
1886 | offset += pane_sizes.Item(pane_i); | |
1887 | } | |
1888 | ||
1889 | // at the end add a very small stretchable background area | |
bb38f6c8 | 1890 | sizer_item = dock_sizer->Add(0,0, 1, wxEXPAND); |
50acee04 | 1891 | |
a3a5df9d | 1892 | part.type = wxAuiDockUIPart::typeBackground; |
50acee04 JS |
1893 | part.dock = &dock; |
1894 | part.pane = NULL; | |
1895 | part.button = NULL; | |
1896 | part.orientation = orientation; | |
1897 | part.cont_sizer = dock_sizer; | |
1898 | part.sizer_item = sizer_item; | |
1899 | uiparts.Add(part); | |
1900 | } | |
696978ee | 1901 | else |
50acee04 JS |
1902 | { |
1903 | for (pane_i = 0; pane_i < pane_count; ++pane_i) | |
1904 | { | |
a3a5df9d | 1905 | wxAuiPaneInfo& pane = *(dock.panes.Item(pane_i)); |
7608fd01 | 1906 | |
32e4b03c | 1907 | if (pane.IsMaximized()) |
37106ab2 | 1908 | has_maximized_pane = true; |
50acee04 JS |
1909 | |
1910 | // if this is not the first pane being added, | |
1911 | // we need to add a pane sizer | |
37106ab2 | 1912 | if (!m_has_maximized && pane_i > 0) |
50acee04 JS |
1913 | { |
1914 | sizer_item = dock_sizer->Add(sash_size, sash_size, 0, wxEXPAND); | |
1915 | ||
a3a5df9d | 1916 | part.type = wxAuiDockUIPart::typePaneSizer; |
50acee04 JS |
1917 | part.dock = &dock; |
1918 | part.pane = dock.panes.Item(pane_i-1); | |
1919 | part.button = NULL; | |
1920 | part.orientation = (orientation==wxHORIZONTAL) ? wxVERTICAL:wxHORIZONTAL; | |
1921 | part.cont_sizer = dock_sizer; | |
1922 | part.sizer_item = sizer_item; | |
1923 | uiparts.Add(part); | |
1924 | } | |
1925 | ||
1926 | LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only); | |
1927 | } | |
1928 | } | |
1929 | ||
37106ab2 | 1930 | if (dock.dock_direction == wxAUI_DOCK_CENTER || has_maximized_pane) |
50acee04 | 1931 | sizer_item = cont->Add(dock_sizer, 1, wxEXPAND); |
7608fd01 | 1932 | else |
50acee04 JS |
1933 | sizer_item = cont->Add(dock_sizer, 0, wxEXPAND); |
1934 | ||
a3a5df9d | 1935 | part.type = wxAuiDockUIPart::typeDock; |
50acee04 JS |
1936 | part.dock = &dock; |
1937 | part.pane = NULL; | |
1938 | part.button = NULL; | |
1939 | part.orientation = orientation; | |
1940 | part.cont_sizer = cont; | |
1941 | part.sizer_item = sizer_item; | |
1942 | uiparts.Add(part); | |
1943 | ||
1944 | if (dock.IsHorizontal()) | |
1945 | cont->SetItemMinSize(dock_sizer, 0, dock.size); | |
7608fd01 | 1946 | else |
50acee04 JS |
1947 | cont->SetItemMinSize(dock_sizer, dock.size, 0); |
1948 | ||
1949 | // top and left docks have a sash after them | |
bb38f6c8 BW |
1950 | if (!m_has_maximized && |
1951 | !dock.fixed && | |
1952 | (dock.dock_direction == wxAUI_DOCK_TOP || | |
1953 | dock.dock_direction == wxAUI_DOCK_LEFT)) | |
50acee04 JS |
1954 | { |
1955 | sizer_item = cont->Add(sash_size, sash_size, 0, wxEXPAND); | |
1956 | ||
a3a5df9d | 1957 | part.type = wxAuiDockUIPart::typeDockSizer; |
50acee04 JS |
1958 | part.dock = &dock; |
1959 | part.pane = NULL; | |
1960 | part.button = NULL; | |
1961 | part.orientation = orientation; | |
1962 | part.cont_sizer = cont; | |
1963 | part.sizer_item = sizer_item; | |
1964 | uiparts.Add(part); | |
1965 | } | |
1966 | } | |
1967 | ||
a3a5df9d | 1968 | wxSizer* wxAuiManager::LayoutAll(wxAuiPaneInfoArray& panes, |
8d0634ab BW |
1969 | wxAuiDockInfoArray& docks, |
1970 | wxAuiDockUIPartArray& uiparts, | |
1971 | bool spacer_only) | |
50acee04 JS |
1972 | { |
1973 | wxBoxSizer* container = new wxBoxSizer(wxVERTICAL); | |
1974 | ||
254a3429 BW |
1975 | int pane_border_size = m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE); |
1976 | int caption_size = m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE); | |
50acee04 JS |
1977 | wxSize cli_size = m_frame->GetClientSize(); |
1978 | int i, dock_count, pane_count; | |
be66f18e | 1979 | |
50acee04 JS |
1980 | |
1981 | // empty all docks out | |
1982 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) | |
03dc5fad BW |
1983 | { |
1984 | wxAuiDockInfo& dock = docks.Item(i); | |
7608fd01 | 1985 | |
03dc5fad BW |
1986 | // empty out all panes, as they will be readded below |
1987 | dock.panes.Empty(); | |
7608fd01 | 1988 | |
03dc5fad BW |
1989 | if (dock.fixed) |
1990 | { | |
1991 | // always reset fixed docks' sizes, because | |
1992 | // the contained windows may have been resized | |
1993 | dock.size = 0; | |
1994 | } | |
1995 | } | |
be66f18e | 1996 | |
37106ab2 | 1997 | |
50acee04 JS |
1998 | // iterate through all known panes, filing each |
1999 | // of them into the appropriate dock. If the | |
2000 | // pane does not exist in the dock, add it | |
2001 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
2002 | { | |
a3a5df9d | 2003 | wxAuiPaneInfo& p = panes.Item(i); |
50acee04 | 2004 | |
bb38f6c8 BW |
2005 | // find any docks with the same dock direction, dock layer, and |
2006 | // dock row as the pane we are working on | |
a3a5df9d BW |
2007 | wxAuiDockInfo* dock; |
2008 | wxAuiDockInfoPtrArray arr; | |
50acee04 JS |
2009 | FindDocks(docks, p.dock_direction, p.dock_layer, p.dock_row, arr); |
2010 | ||
2011 | if (arr.GetCount() > 0) | |
2012 | { | |
bb38f6c8 | 2013 | // found the right dock |
50acee04 JS |
2014 | dock = arr.Item(0); |
2015 | } | |
7608fd01 | 2016 | else |
50acee04 JS |
2017 | { |
2018 | // dock was not found, so we need to create a new one | |
a3a5df9d | 2019 | wxAuiDockInfo d; |
50acee04 JS |
2020 | d.dock_direction = p.dock_direction; |
2021 | d.dock_layer = p.dock_layer; | |
2022 | d.dock_row = p.dock_row; | |
2023 | docks.Add(d); | |
2024 | dock = &docks.Last(); | |
2025 | } | |
2026 | ||
2027 | ||
2028 | if (p.IsDocked() && p.IsShown()) | |
2029 | { | |
2030 | // remove the pane from any existing docks except this one | |
2031 | RemovePaneFromDocks(docks, p, dock); | |
2032 | ||
2033 | // pane needs to be added to the dock, | |
be66f18e | 2034 | // if it doesn't already exist |
50acee04 JS |
2035 | if (!FindPaneInDock(*dock, p.window)) |
2036 | dock->panes.Add(&p); | |
2037 | } | |
7608fd01 | 2038 | else |
50acee04 JS |
2039 | { |
2040 | // remove the pane from any existing docks | |
2041 | RemovePaneFromDocks(docks, p); | |
2042 | } | |
2043 | ||
2044 | } | |
2045 | ||
2046 | // remove any empty docks | |
2047 | for (i = docks.GetCount()-1; i >= 0; --i) | |
2048 | { | |
2049 | if (docks.Item(i).panes.GetCount() == 0) | |
2050 | docks.RemoveAt(i); | |
2051 | } | |
2052 | ||
2053 | // configure the docks further | |
2054 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) | |
2055 | { | |
a3a5df9d | 2056 | wxAuiDockInfo& dock = docks.Item(i); |
50acee04 | 2057 | int j, dock_pane_count = dock.panes.GetCount(); |
be66f18e | 2058 | |
50acee04 JS |
2059 | // sort the dock pane array by the pane's |
2060 | // dock position (dock_pos), in ascending order | |
2061 | dock.panes.Sort(PaneSortFunc); | |
2062 | ||
2063 | // for newly created docks, set up their initial size | |
2064 | if (dock.size == 0) | |
2065 | { | |
2066 | int size = 0; | |
2067 | ||
2068 | for (j = 0; j < dock_pane_count; ++j) | |
2069 | { | |
a3a5df9d | 2070 | wxAuiPaneInfo& pane = *dock.panes.Item(j); |
50acee04 JS |
2071 | wxSize pane_size = pane.best_size; |
2072 | if (pane_size == wxDefaultSize) | |
2073 | pane_size = pane.min_size; | |
2074 | if (pane_size == wxDefaultSize) | |
2075 | pane_size = pane.window->GetSize(); | |
be66f18e | 2076 | |
50acee04 JS |
2077 | if (dock.IsHorizontal()) |
2078 | size = wxMax(pane_size.y, size); | |
7608fd01 | 2079 | else |
50acee04 JS |
2080 | size = wxMax(pane_size.x, size); |
2081 | } | |
be66f18e | 2082 | |
50acee04 JS |
2083 | // add space for the border (two times), but only |
2084 | // if at least one pane inside the dock has a pane border | |
2085 | for (j = 0; j < dock_pane_count; ++j) | |
2086 | { | |
2087 | if (dock.panes.Item(j)->HasBorder()) | |
2088 | { | |
2089 | size += (pane_border_size*2); | |
2090 | break; | |
2091 | } | |
2092 | } | |
2093 | ||
2094 | // if pane is on the top or bottom, add the caption height, | |
2095 | // but only if at least one pane inside the dock has a caption | |
2096 | if (dock.IsHorizontal()) | |
2097 | { | |
2098 | for (j = 0; j < dock_pane_count; ++j) | |
2099 | { | |
2100 | if (dock.panes.Item(j)->HasCaption()) | |
2101 | { | |
2102 | size += caption_size; | |
2103 | break; | |
2104 | } | |
2105 | } | |
2106 | } | |
2107 | ||
a6b7a521 VZ |
2108 | |
2109 | // new dock's size may not be more than the dock constraint | |
2110 | // parameter specifies. See SetDockSizeConstraint() | |
7608fd01 | 2111 | |
a6b7a521 VZ |
2112 | int max_dock_x_size = (int)(m_dock_constraint_x * ((double)cli_size.x)); |
2113 | int max_dock_y_size = (int)(m_dock_constraint_y * ((double)cli_size.y)); | |
7608fd01 | 2114 | |
a6b7a521 VZ |
2115 | if (dock.IsHorizontal()) |
2116 | size = wxMin(size, max_dock_y_size); | |
7608fd01 | 2117 | else |
a6b7a521 VZ |
2118 | size = wxMin(size, max_dock_x_size); |
2119 | ||
2120 | // absolute minimum size for a dock is 10 pixels | |
50acee04 JS |
2121 | if (size < 10) |
2122 | size = 10; | |
7608fd01 | 2123 | |
50acee04 JS |
2124 | dock.size = size; |
2125 | } | |
2126 | ||
2127 | ||
2128 | // determine the dock's minimum size | |
2129 | bool plus_border = false; | |
2130 | bool plus_caption = false; | |
2131 | int dock_min_size = 0; | |
2132 | for (j = 0; j < dock_pane_count; ++j) | |
2133 | { | |
a3a5df9d | 2134 | wxAuiPaneInfo& pane = *dock.panes.Item(j); |
50acee04 JS |
2135 | if (pane.min_size != wxDefaultSize) |
2136 | { | |
2137 | if (pane.HasBorder()) | |
2138 | plus_border = true; | |
2139 | if (pane.HasCaption()) | |
2140 | plus_caption = true; | |
2141 | if (dock.IsHorizontal()) | |
2142 | { | |
2143 | if (pane.min_size.y > dock_min_size) | |
2144 | dock_min_size = pane.min_size.y; | |
2145 | } | |
7608fd01 | 2146 | else |
50acee04 JS |
2147 | { |
2148 | if (pane.min_size.x > dock_min_size) | |
2149 | dock_min_size = pane.min_size.x; | |
2150 | } | |
2151 | } | |
2152 | } | |
be66f18e | 2153 | |
50acee04 JS |
2154 | if (plus_border) |
2155 | dock_min_size += (pane_border_size*2); | |
2156 | if (plus_caption && dock.IsHorizontal()) | |
2157 | dock_min_size += (caption_size); | |
be66f18e | 2158 | |
50acee04 | 2159 | dock.min_size = dock_min_size; |
be66f18e WS |
2160 | |
2161 | ||
50acee04 JS |
2162 | // if the pane's current size is less than it's |
2163 | // minimum, increase the dock's size to it's minimum | |
2164 | if (dock.size < dock.min_size) | |
2165 | dock.size = dock.min_size; | |
2166 | ||
2167 | ||
2168 | // determine the dock's mode (fixed or proportional); | |
2169 | // determine whether the dock has only toolbars | |
2170 | bool action_pane_marked = false; | |
2171 | dock.fixed = true; | |
2172 | dock.toolbar = true; | |
2173 | for (j = 0; j < dock_pane_count; ++j) | |
2174 | { | |
a3a5df9d | 2175 | wxAuiPaneInfo& pane = *dock.panes.Item(j); |
50acee04 JS |
2176 | if (!pane.IsFixed()) |
2177 | dock.fixed = false; | |
2178 | if (!pane.IsToolbar()) | |
2179 | dock.toolbar = false; | |
c89e16e4 BW |
2180 | if (pane.HasFlag(wxAuiPaneInfo::optionDockFixed)) |
2181 | dock.fixed = true; | |
a3a5df9d | 2182 | if (pane.state & wxAuiPaneInfo::actionPane) |
50acee04 JS |
2183 | action_pane_marked = true; |
2184 | } | |
2185 | ||
2186 | ||
2187 | // if the dock mode is proportional and not fixed-pixel, | |
2188 | // reassign the dock_pos to the sequential 0, 1, 2, 3; | |
2189 | // e.g. remove gaps like 1, 2, 30, 500 | |
2190 | if (!dock.fixed) | |
2191 | { | |
2192 | for (j = 0; j < dock_pane_count; ++j) | |
2193 | { | |
a3a5df9d | 2194 | wxAuiPaneInfo& pane = *dock.panes.Item(j); |
50acee04 JS |
2195 | pane.dock_pos = j; |
2196 | } | |
2197 | } | |
2198 | ||
2199 | // if the dock mode is fixed, and none of the panes | |
2200 | // are being moved right now, make sure the panes | |
2201 | // do not overlap each other. If they do, we will | |
bb38f6c8 | 2202 | // adjust the positions of the panes |
50acee04 JS |
2203 | if (dock.fixed && !action_pane_marked) |
2204 | { | |
2205 | wxArrayInt pane_positions, pane_sizes; | |
2206 | GetPanePositionsAndSizes(dock, pane_positions, pane_sizes); | |
be66f18e | 2207 | |
50acee04 JS |
2208 | int offset = 0; |
2209 | for (j = 0; j < dock_pane_count; ++j) | |
2210 | { | |
a3a5df9d | 2211 | wxAuiPaneInfo& pane = *(dock.panes.Item(j)); |
50acee04 JS |
2212 | pane.dock_pos = pane_positions[j]; |
2213 | ||
2214 | int amount = pane.dock_pos - offset; | |
2215 | if (amount >= 0) | |
2216 | offset += amount; | |
7608fd01 | 2217 | else |
50acee04 JS |
2218 | pane.dock_pos += -amount; |
2219 | ||
2220 | offset += pane_sizes[j]; | |
2221 | } | |
2222 | } | |
2223 | } | |
be66f18e | 2224 | |
50acee04 JS |
2225 | // discover the maximum dock layer |
2226 | int max_layer = 0; | |
2227 | for (i = 0; i < dock_count; ++i) | |
2228 | max_layer = wxMax(max_layer, docks.Item(i).dock_layer); | |
be66f18e | 2229 | |
50acee04 JS |
2230 | |
2231 | // clear out uiparts | |
2232 | uiparts.Empty(); | |
2233 | ||
2234 | // create a bunch of box sizers, | |
2235 | // from the innermost level outwards. | |
2236 | wxSizer* cont = NULL; | |
2237 | wxSizer* middle = NULL; | |
2238 | int layer = 0; | |
2239 | int row, row_count; | |
2240 | ||
2241 | for (layer = 0; layer <= max_layer; ++layer) | |
2242 | { | |
a3a5df9d | 2243 | wxAuiDockInfoPtrArray arr; |
50acee04 JS |
2244 | |
2245 | // find any docks in this layer | |
2246 | FindDocks(docks, -1, layer, -1, arr); | |
2247 | ||
2248 | // if there aren't any, skip to the next layer | |
2249 | if (arr.IsEmpty()) | |
2250 | continue; | |
2251 | ||
2252 | wxSizer* old_cont = cont; | |
2253 | ||
2254 | // create a container which will hold this layer's | |
2255 | // docks (top, bottom, left, right) | |
2256 | cont = new wxBoxSizer(wxVERTICAL); | |
2257 | ||
2258 | ||
2259 | // find any top docks in this layer | |
2260 | FindDocks(docks, wxAUI_DOCK_TOP, layer, -1, arr); | |
50acee04 JS |
2261 | if (!arr.IsEmpty()) |
2262 | { | |
2263 | for (row = 0, row_count = arr.GetCount(); row < row_count; ++row) | |
2264 | LayoutAddDock(cont, *arr.Item(row), uiparts, spacer_only); | |
2265 | } | |
2266 | ||
be66f18e | 2267 | |
50acee04 JS |
2268 | // fill out the middle layer (which consists |
2269 | // of left docks, content area and right docks) | |
be66f18e | 2270 | |
50acee04 JS |
2271 | middle = new wxBoxSizer(wxHORIZONTAL); |
2272 | ||
2273 | // find any left docks in this layer | |
2274 | FindDocks(docks, wxAUI_DOCK_LEFT, layer, -1, arr); | |
50acee04 JS |
2275 | if (!arr.IsEmpty()) |
2276 | { | |
2277 | for (row = 0, row_count = arr.GetCount(); row < row_count; ++row) | |
2278 | LayoutAddDock(middle, *arr.Item(row), uiparts, spacer_only); | |
2279 | } | |
2280 | ||
2281 | // add content dock (or previous layer's sizer | |
2282 | // to the middle | |
2283 | if (!old_cont) | |
2284 | { | |
2285 | // find any center docks | |
2286 | FindDocks(docks, wxAUI_DOCK_CENTER, -1, -1, arr); | |
2287 | if (!arr.IsEmpty()) | |
2288 | { | |
2289 | for (row = 0,row_count = arr.GetCount(); row<row_count; ++row) | |
2290 | LayoutAddDock(middle, *arr.Item(row), uiparts, spacer_only); | |
2291 | } | |
7608fd01 | 2292 | else if (!m_has_maximized) |
50acee04 JS |
2293 | { |
2294 | // there are no center docks, add a background area | |
2295 | wxSizerItem* sizer_item = middle->Add(1,1, 1, wxEXPAND); | |
a3a5df9d BW |
2296 | wxAuiDockUIPart part; |
2297 | part.type = wxAuiDockUIPart::typeBackground; | |
50acee04 JS |
2298 | part.pane = NULL; |
2299 | part.dock = NULL; | |
2300 | part.button = NULL; | |
2301 | part.cont_sizer = middle; | |
2302 | part.sizer_item = sizer_item; | |
2303 | uiparts.Add(part); | |
2304 | } | |
2305 | } | |
7608fd01 | 2306 | else |
50acee04 JS |
2307 | { |
2308 | middle->Add(old_cont, 1, wxEXPAND); | |
2309 | } | |
2310 | ||
2311 | // find any right docks in this layer | |
2312 | FindDocks(docks, wxAUI_DOCK_RIGHT, layer, -1, arr); | |
50acee04 JS |
2313 | if (!arr.IsEmpty()) |
2314 | { | |
2315 | for (row = arr.GetCount()-1; row >= 0; --row) | |
2316 | LayoutAddDock(middle, *arr.Item(row), uiparts, spacer_only); | |
2317 | } | |
2318 | ||
2319 | cont->Add(middle, 1, wxEXPAND); | |
2320 | ||
2321 | ||
2322 | ||
2323 | // find any bottom docks in this layer | |
2324 | FindDocks(docks, wxAUI_DOCK_BOTTOM, layer, -1, arr); | |
50acee04 JS |
2325 | if (!arr.IsEmpty()) |
2326 | { | |
2327 | for (row = arr.GetCount()-1; row >= 0; --row) | |
2328 | LayoutAddDock(cont, *arr.Item(row), uiparts, spacer_only); | |
2329 | } | |
2330 | ||
2331 | } | |
2332 | ||
2333 | if (!cont) | |
2334 | { | |
2335 | // no sizer available, because there are no docks, | |
2336 | // therefore we will create a simple background area | |
2337 | cont = new wxBoxSizer(wxVERTICAL); | |
2338 | wxSizerItem* sizer_item = cont->Add(1,1, 1, wxEXPAND); | |
a3a5df9d BW |
2339 | wxAuiDockUIPart part; |
2340 | part.type = wxAuiDockUIPart::typeBackground; | |
50acee04 JS |
2341 | part.pane = NULL; |
2342 | part.dock = NULL; | |
2343 | part.button = NULL; | |
2344 | part.cont_sizer = middle; | |
2345 | part.sizer_item = sizer_item; | |
2346 | uiparts.Add(part); | |
2347 | } | |
2348 | ||
2349 | container->Add(cont, 1, wxEXPAND); | |
2350 | return container; | |
2351 | } | |
2352 | ||
2353 | ||
a6b7a521 VZ |
2354 | // SetDockSizeConstraint() allows the dock constraints to be set. For example, |
2355 | // specifying values of 0.5, 0.5 will mean that upon dock creation, a dock may | |
2356 | // not be larger than half of the window's size | |
2357 | ||
2358 | void wxAuiManager::SetDockSizeConstraint(double width_pct, double height_pct) | |
2359 | { | |
2360 | m_dock_constraint_x = wxMax(0.0, wxMin(1.0, width_pct)); | |
2361 | m_dock_constraint_y = wxMax(0.0, wxMin(1.0, height_pct)); | |
2362 | } | |
2363 | ||
2364 | void wxAuiManager::GetDockSizeConstraint(double* width_pct, double* height_pct) const | |
2365 | { | |
2366 | if (width_pct) | |
2367 | *width_pct = m_dock_constraint_x; | |
7608fd01 | 2368 | |
a6b7a521 VZ |
2369 | if (height_pct) |
2370 | *height_pct = m_dock_constraint_y; | |
2371 | } | |
2372 | ||
2373 | ||
2374 | ||
50acee04 JS |
2375 | // Update() updates the layout. Whenever changes are made to |
2376 | // one or more panes, this function should be called. It is the | |
2377 | // external entry point for running the layout engine. | |
2378 | ||
a3a5df9d | 2379 | void wxAuiManager::Update() |
50acee04 | 2380 | { |
987bb1c6 JS |
2381 | m_hover_button = NULL; |
2382 | ||
50acee04 JS |
2383 | wxSizer* sizer; |
2384 | int i, pane_count = m_panes.GetCount(); | |
2385 | ||
50acee04 JS |
2386 | |
2387 | // destroy floating panes which have been | |
2388 | // redocked or are becoming non-floating | |
2389 | for (i = 0; i < pane_count; ++i) | |
2390 | { | |
a3a5df9d | 2391 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
2392 | |
2393 | if (!p.IsFloating() && p.frame) | |
2394 | { | |
2395 | // because the pane is no longer in a floating, we need to | |
2396 | // reparent it to m_frame and destroy the floating frame | |
be66f18e | 2397 | |
50acee04 JS |
2398 | // reduce flicker |
2399 | p.window->SetSize(1,1); | |
26178b5d | 2400 | |
533bedbf | 2401 | |
cedd7b22 PC |
2402 | // the following block is a workaround for bug #1531361 |
2403 | // (see wxWidgets sourceforge page). On wxGTK (only), when | |
2404 | // a frame is shown/hidden, a move event unfortunately | |
2405 | // also gets fired. Because we may be dragging around | |
2406 | // a pane, we need to cancel that action here to prevent | |
2407 | // a spurious crash. | |
2408 | if (m_action_window == p.frame) | |
2409 | { | |
2410 | if (wxWindow::GetCapture() == m_frame) | |
533bedbf BW |
2411 | m_frame->ReleaseMouse(); |
2412 | m_action = actionNone; | |
cedd7b22 PC |
2413 | m_action_window = NULL; |
2414 | } | |
533bedbf | 2415 | |
cedd7b22 | 2416 | // hide the frame |
26178b5d BW |
2417 | if (p.frame->IsShown()) |
2418 | p.frame->Show(false); | |
be66f18e | 2419 | |
50acee04 | 2420 | // reparent to m_frame and destroy the pane |
32e4b03c | 2421 | if (m_action_window == p.frame) |
528a5e8f | 2422 | { |
49fa1dbb RR |
2423 | m_action_window = NULL; |
2424 | } | |
7608fd01 | 2425 | |
50acee04 JS |
2426 | p.window->Reparent(m_frame); |
2427 | p.frame->SetSizer(NULL); | |
2428 | p.frame->Destroy(); | |
2429 | p.frame = NULL; | |
2430 | } | |
2431 | } | |
2432 | ||
2433 | ||
852a7df6 BW |
2434 | // delete old sizer first |
2435 | m_frame->SetSizer(NULL); | |
2436 | ||
50acee04 JS |
2437 | // create a layout for all of the panes |
2438 | sizer = LayoutAll(m_panes, m_docks, m_uiparts, false); | |
2439 | ||
2440 | // hide or show panes as necessary, | |
2441 | // and float panes as necessary | |
2442 | for (i = 0; i < pane_count; ++i) | |
2443 | { | |
a3a5df9d | 2444 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
2445 | |
2446 | if (p.IsFloating()) | |
2447 | { | |
2448 | if (p.frame == NULL) | |
2449 | { | |
2450 | // we need to create a frame for this | |
2451 | // pane, which has recently been floated | |
00c1c94c | 2452 | wxAuiFloatingFrame* frame = CreateFloatingFrame(m_frame, p); |
be66f18e | 2453 | |
81cc4eb2 | 2454 | // on MSW and Mac, if the owner desires transparent dragging, and |
50acee04 | 2455 | // the dragging is happening right now, then the floating |
be66f18e | 2456 | // window should have this style by default |
50acee04 JS |
2457 | if (m_action == actionDragFloatingPane && |
2458 | (m_flags & wxAUI_MGR_TRANSPARENT_DRAG)) | |
07880314 | 2459 | frame->SetTransparent(150); |
be66f18e | 2460 | |
50acee04 JS |
2461 | frame->SetPaneWindow(p); |
2462 | p.frame = frame; | |
2463 | ||
26178b5d | 2464 | if (p.IsShown() && !frame->IsShown()) |
50acee04 | 2465 | frame->Show(); |
50acee04 | 2466 | } |
7608fd01 | 2467 | else |
50acee04 JS |
2468 | { |
2469 | // frame already exists, make sure it's position | |
a3a5df9d | 2470 | // and size reflect the information in wxAuiPaneInfo |
ab620250 | 2471 | if ((p.frame->GetPosition() != p.floating_pos) || (p.frame->GetSize() != p.floating_size)) |
50acee04 | 2472 | { |
9e1fc0e4 BW |
2473 | p.frame->SetSize(p.floating_pos.x, p.floating_pos.y, |
2474 | p.floating_size.x, p.floating_size.y, | |
2475 | wxSIZE_USE_EXISTING); | |
2476 | /* | |
50acee04 | 2477 | p.frame->SetSize(p.floating_pos.x, p.floating_pos.y, |
a1b3b608 WS |
2478 | wxDefaultCoord, wxDefaultCoord, |
2479 | wxSIZE_USE_EXISTING); | |
50acee04 | 2480 | //p.frame->Move(p.floating_pos.x, p.floating_pos.y); |
9e1fc0e4 | 2481 | */ |
50acee04 JS |
2482 | } |
2483 | ||
f88d1716 BW |
2484 | if (p.frame->IsShown() != p.IsShown()) |
2485 | p.frame->Show(p.IsShown()); | |
50acee04 JS |
2486 | } |
2487 | } | |
7608fd01 | 2488 | else |
50acee04 | 2489 | { |
26178b5d BW |
2490 | if (p.window->IsShown() != p.IsShown()) |
2491 | p.window->Show(p.IsShown()); | |
50acee04 JS |
2492 | } |
2493 | ||
2494 | // if "active panes" are no longer allowed, clear | |
2495 | // any optionActive values from the pane states | |
2496 | if ((m_flags & wxAUI_MGR_ALLOW_ACTIVE_PANE) == 0) | |
2497 | { | |
a3a5df9d | 2498 | p.state &= ~wxAuiPaneInfo::optionActive; |
50acee04 JS |
2499 | } |
2500 | } | |
2501 | ||
2502 | ||
2503 | // keep track of the old window rectangles so we can | |
2504 | // refresh those windows whose rect has changed | |
2505 | wxAuiRectArray old_pane_rects; | |
2506 | for (i = 0; i < pane_count; ++i) | |
2507 | { | |
2508 | wxRect r; | |
a3a5df9d | 2509 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
2510 | |
2511 | if (p.window && p.IsShown() && p.IsDocked()) | |
2512 | r = p.rect; | |
2513 | ||
2514 | old_pane_rects.Add(r); | |
2515 | } | |
2516 | ||
2517 | ||
2518 | ||
2519 | ||
2520 | // apply the new sizer | |
2521 | m_frame->SetSizer(sizer); | |
2522 | m_frame->SetAutoLayout(false); | |
2523 | DoFrameLayout(); | |
2524 | ||
2525 | ||
2526 | ||
2527 | // now that the frame layout is done, we need to check | |
2528 | // the new pane rectangles against the old rectangles that | |
2529 | // we saved a few lines above here. If the rectangles have | |
2530 | // changed, the corresponding panes must also be updated | |
2531 | for (i = 0; i < pane_count; ++i) | |
2532 | { | |
a3a5df9d | 2533 | wxAuiPaneInfo& p = m_panes.Item(i); |
50acee04 JS |
2534 | if (p.window && p.window->IsShown() && p.IsDocked()) |
2535 | { | |
2536 | if (p.rect != old_pane_rects[i]) | |
2537 | { | |
2538 | p.window->Refresh(); | |
2539 | p.window->Update(); | |
2540 | } | |
2541 | } | |
2542 | } | |
2543 | ||
2544 | ||
2545 | Repaint(); | |
be66f18e | 2546 | |
50acee04 | 2547 | // set frame's minimum size |
be66f18e | 2548 | |
50acee04 JS |
2549 | /* |
2550 | // N.B. More work needs to be done on frame minimum sizes; | |
2551 | // this is some intresting code that imposes the minimum size, | |
2552 | // but we may want to include a more flexible mechanism or | |
2553 | // options for multiple minimum-size modes, e.g. strict or lax | |
2554 | wxSize min_size = sizer->GetMinSize(); | |
2555 | wxSize frame_size = m_frame->GetSize(); | |
2556 | wxSize client_size = m_frame->GetClientSize(); | |
2557 | ||
2558 | wxSize minframe_size(min_size.x+frame_size.x-client_size.x, | |
2559 | min_size.y+frame_size.y-client_size.y ); | |
be66f18e | 2560 | |
50acee04 | 2561 | m_frame->SetMinSize(minframe_size); |
be66f18e | 2562 | |
50acee04 JS |
2563 | if (frame_size.x < minframe_size.x || |
2564 | frame_size.y < minframe_size.y) | |
2565 | sizer->Fit(m_frame); | |
2566 | */ | |
2567 | } | |
2568 | ||
2569 | ||
2570 | // DoFrameLayout() is an internal function which invokes wxSizer::Layout | |
2571 | // on the frame's main sizer, then measures all the various UI items | |
2572 | // and updates their internal rectangles. This should always be called | |
2573 | // instead of calling m_frame->Layout() directly | |
2574 | ||
a3a5df9d | 2575 | void wxAuiManager::DoFrameLayout() |
50acee04 JS |
2576 | { |
2577 | m_frame->Layout(); | |
be66f18e | 2578 | |
50acee04 JS |
2579 | int i, part_count; |
2580 | for (i = 0, part_count = m_uiparts.GetCount(); i < part_count; ++i) | |
2581 | { | |
a3a5df9d | 2582 | wxAuiDockUIPart& part = m_uiparts.Item(i); |
50acee04 JS |
2583 | |
2584 | // get the rectangle of the UI part | |
2585 | // originally, this code looked like this: | |
2586 | // part.rect = wxRect(part.sizer_item->GetPosition(), | |
2587 | // part.sizer_item->GetSize()); | |
2588 | // this worked quite well, with one exception: the mdi | |
be66f18e | 2589 | // client window had a "deferred" size variable |
50acee04 JS |
2590 | // that returned the wrong size. It looks like |
2591 | // a bug in wx, because the former size of the window | |
2592 | // was being returned. So, we will retrieve the part's | |
2593 | // rectangle via other means | |
2594 | ||
2595 | ||
2596 | part.rect = part.sizer_item->GetRect(); | |
2597 | int flag = part.sizer_item->GetFlag(); | |
2598 | int border = part.sizer_item->GetBorder(); | |
2599 | if (flag & wxTOP) | |
2600 | { | |
2601 | part.rect.y -= border; | |
2602 | part.rect.height += border; | |
2603 | } | |
2604 | if (flag & wxLEFT) | |
2605 | { | |
2606 | part.rect.x -= border; | |
2607 | part.rect.width += border; | |
2608 | } | |
2609 | if (flag & wxBOTTOM) | |
2610 | part.rect.height += border; | |
2611 | if (flag & wxRIGHT) | |
2612 | part.rect.width += border; | |
2613 | ||
2614 | ||
a3a5df9d | 2615 | if (part.type == wxAuiDockUIPart::typeDock) |
50acee04 | 2616 | part.dock->rect = part.rect; |
a3a5df9d | 2617 | if (part.type == wxAuiDockUIPart::typePane) |
50acee04 JS |
2618 | part.pane->rect = part.rect; |
2619 | } | |
2620 | } | |
2621 | ||
2622 | // GetPanePart() looks up the pane the pane border UI part (or the regular | |
2623 | // pane part if there is no border). This allows the caller to get the exact | |
2624 | // rectangle of the pane in question, including decorations like | |
2625 | // caption and border (if any). | |
2626 | ||
a3a5df9d | 2627 | wxAuiDockUIPart* wxAuiManager::GetPanePart(wxWindow* wnd) |
50acee04 JS |
2628 | { |
2629 | int i, part_count; | |
2630 | for (i = 0, part_count = m_uiparts.GetCount(); i < part_count; ++i) | |
2631 | { | |
a3a5df9d BW |
2632 | wxAuiDockUIPart& part = m_uiparts.Item(i); |
2633 | if (part.type == wxAuiDockUIPart::typePaneBorder && | |
50acee04 JS |
2634 | part.pane && part.pane->window == wnd) |
2635 | return ∂ | |
2636 | } | |
2637 | for (i = 0, part_count = m_uiparts.GetCount(); i < part_count; ++i) | |
2638 | { | |
a3a5df9d BW |
2639 | wxAuiDockUIPart& part = m_uiparts.Item(i); |
2640 | if (part.type == wxAuiDockUIPart::typePane && | |
50acee04 JS |
2641 | part.pane && part.pane->window == wnd) |
2642 | return ∂ | |
2643 | } | |
2644 | return NULL; | |
2645 | } | |
2646 | ||
2647 | ||
2648 | ||
2649 | // GetDockPixelOffset() is an internal function which returns | |
2650 | // a dock's offset in pixels from the left side of the window | |
2651 | // (for horizontal docks) or from the top of the window (for | |
2652 | // vertical docks). This value is necessary for calculating | |
2653 | // fixel-pane/toolbar offsets when they are dragged. | |
2654 | ||
a3a5df9d | 2655 | int wxAuiManager::GetDockPixelOffset(wxAuiPaneInfo& test) |
50acee04 JS |
2656 | { |
2657 | // the only way to accurately calculate the dock's | |
2658 | // offset is to actually run a theoretical layout | |
be66f18e | 2659 | |
50acee04 | 2660 | int i, part_count, dock_count; |
a3a5df9d BW |
2661 | wxAuiDockInfoArray docks; |
2662 | wxAuiPaneInfoArray panes; | |
2663 | wxAuiDockUIPartArray uiparts; | |
50acee04 JS |
2664 | CopyDocksAndPanes(docks, panes, m_docks, m_panes); |
2665 | panes.Add(test); | |
2666 | ||
2667 | wxSizer* sizer = LayoutAll(panes, docks, uiparts, true); | |
2668 | wxSize client_size = m_frame->GetClientSize(); | |
2669 | sizer->SetDimension(0, 0, client_size.x, client_size.y); | |
2670 | sizer->Layout(); | |
2671 | ||
2672 | for (i = 0, part_count = uiparts.GetCount(); i < part_count; ++i) | |
2673 | { | |
a3a5df9d | 2674 | wxAuiDockUIPart& part = uiparts.Item(i); |
50acee04 JS |
2675 | part.rect = wxRect(part.sizer_item->GetPosition(), |
2676 | part.sizer_item->GetSize()); | |
a3a5df9d | 2677 | if (part.type == wxAuiDockUIPart::typeDock) |
50acee04 JS |
2678 | part.dock->rect = part.rect; |
2679 | } | |
be66f18e | 2680 | |
50acee04 | 2681 | delete sizer; |
be66f18e | 2682 | |
50acee04 JS |
2683 | for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) |
2684 | { | |
a3a5df9d | 2685 | wxAuiDockInfo& dock = docks.Item(i); |
50acee04 JS |
2686 | if (test.dock_direction == dock.dock_direction && |
2687 | test.dock_layer==dock.dock_layer && test.dock_row==dock.dock_row) | |
2688 | { | |
2689 | if (dock.IsVertical()) | |
2690 | return dock.rect.y; | |
7608fd01 | 2691 | else |
50acee04 JS |
2692 | return dock.rect.x; |
2693 | } | |
2694 | } | |
2695 | ||
2696 | return 0; | |
2697 | } | |
2698 | ||
2699 | ||
2700 | ||
2701 | // ProcessDockResult() is a utility function used by DoDrop() - it checks | |
2702 | // if a dock operation is allowed, the new dock position is copied into | |
2703 | // the target info. If the operation was allowed, the function returns true. | |
2704 | ||
a3a5df9d | 2705 | bool wxAuiManager::ProcessDockResult(wxAuiPaneInfo& target, |
1dc6ec2c | 2706 | const wxAuiPaneInfo& new_pos) |
50acee04 JS |
2707 | { |
2708 | bool allowed = false; | |
2709 | switch (new_pos.dock_direction) | |
2710 | { | |
2711 | case wxAUI_DOCK_TOP: allowed = target.IsTopDockable(); break; | |
2712 | case wxAUI_DOCK_BOTTOM: allowed = target.IsBottomDockable(); break; | |
2713 | case wxAUI_DOCK_LEFT: allowed = target.IsLeftDockable(); break; | |
2714 | case wxAUI_DOCK_RIGHT: allowed = target.IsRightDockable(); break; | |
2715 | } | |
2716 | ||
2717 | if (allowed) | |
2718 | target = new_pos; | |
2719 | ||
2720 | return allowed; | |
2721 | } | |
2722 | ||
2723 | ||
2724 | // DoDrop() is an important function. It basically takes a mouse position, | |
2725 | // and determines where the pane's new position would be. If the pane is to be | |
2726 | // dropped, it performs the drop operation using the specified dock and pane | |
2727 | // arrays. By specifying copied dock and pane arrays when calling, a "what-if" | |
2728 | // scenario can be performed, giving precise coordinates for drop hints. | |
a3a5df9d | 2729 | // If, however, wxAuiManager:m_docks and wxAuiManager::m_panes are specified |
50acee04 JS |
2730 | // as parameters, the changes will be made to the main state arrays |
2731 | ||
2732 | const int auiInsertRowPixels = 10; | |
2733 | const int auiNewRowPixels = 40; | |
2734 | const int auiLayerInsertPixels = 40; | |
2735 | const int auiLayerInsertOffset = 5; | |
2736 | ||
a3a5df9d | 2737 | bool wxAuiManager::DoDrop(wxAuiDockInfoArray& docks, |
32e4b03c BW |
2738 | wxAuiPaneInfoArray& panes, |
2739 | wxAuiPaneInfo& target, | |
2740 | const wxPoint& pt, | |
2741 | const wxPoint& offset) | |
50acee04 JS |
2742 | { |
2743 | wxSize cli_size = m_frame->GetClientSize(); | |
2744 | ||
a3a5df9d | 2745 | wxAuiPaneInfo drop = target; |
50acee04 JS |
2746 | |
2747 | ||
2748 | // The result should always be shown | |
2749 | drop.Show(); | |
be66f18e | 2750 | |
50acee04 JS |
2751 | |
2752 | // Check to see if the pane has been dragged outside of the window | |
2753 | // (or near to the outside of the window), if so, dock it along the edge | |
2754 | ||
2755 | ||
2756 | int layer_insert_offset = auiLayerInsertOffset; | |
32e4b03c | 2757 | if (drop.IsToolbar()) |
50acee04 | 2758 | layer_insert_offset = 0; |
be66f18e | 2759 | |
32e4b03c | 2760 | |
50acee04 JS |
2761 | if (pt.x < layer_insert_offset && |
2762 | pt.x > layer_insert_offset-auiLayerInsertPixels) | |
2763 | { | |
613a0c4c BW |
2764 | int new_layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_LEFT), |
2765 | GetMaxLayer(docks, wxAUI_DOCK_BOTTOM)), | |
32e4b03c | 2766 | GetMaxLayer(docks, wxAUI_DOCK_TOP)) + 1; |
7608fd01 | 2767 | |
32e4b03c BW |
2768 | if (drop.IsToolbar()) |
2769 | new_layer = auiToolBarLayer; | |
7608fd01 | 2770 | |
50acee04 | 2771 | drop.Dock().Left(). |
613a0c4c | 2772 | Layer(new_layer). |
50acee04 JS |
2773 | Row(0). |
2774 | Position(pt.y - GetDockPixelOffset(drop) - offset.y); | |
2775 | return ProcessDockResult(target, drop); | |
2776 | } | |
696978ee WS |
2777 | else if (pt.y < layer_insert_offset && |
2778 | pt.y > layer_insert_offset-auiLayerInsertPixels) | |
50acee04 | 2779 | { |
613a0c4c BW |
2780 | int new_layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_TOP), |
2781 | GetMaxLayer(docks, wxAUI_DOCK_LEFT)), | |
2782 | GetMaxLayer(docks, wxAUI_DOCK_RIGHT)) + 1; | |
7608fd01 | 2783 | |
32e4b03c BW |
2784 | if (drop.IsToolbar()) |
2785 | new_layer = auiToolBarLayer; | |
7608fd01 | 2786 | |
50acee04 | 2787 | drop.Dock().Top(). |
613a0c4c | 2788 | Layer(new_layer). |
50acee04 JS |
2789 | Row(0). |
2790 | Position(pt.x - GetDockPixelOffset(drop) - offset.x); | |
2791 | return ProcessDockResult(target, drop); | |
2792 | } | |
696978ee WS |
2793 | else if (pt.x >= cli_size.x - layer_insert_offset && |
2794 | pt.x < cli_size.x - layer_insert_offset + auiLayerInsertPixels) | |
50acee04 | 2795 | { |
613a0c4c BW |
2796 | int new_layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_RIGHT), |
2797 | GetMaxLayer(docks, wxAUI_DOCK_TOP)), | |
7608fd01 VZ |
2798 | GetMaxLayer(docks, wxAUI_DOCK_BOTTOM)) + 1; |
2799 | ||
32e4b03c BW |
2800 | if (drop.IsToolbar()) |
2801 | new_layer = auiToolBarLayer; | |
7608fd01 | 2802 | |
50acee04 | 2803 | drop.Dock().Right(). |
613a0c4c | 2804 | Layer(new_layer). |
50acee04 JS |
2805 | Row(0). |
2806 | Position(pt.y - GetDockPixelOffset(drop) - offset.y); | |
2807 | return ProcessDockResult(target, drop); | |
2808 | } | |
696978ee WS |
2809 | else if (pt.y >= cli_size.y - layer_insert_offset && |
2810 | pt.y < cli_size.y - layer_insert_offset + auiLayerInsertPixels) | |
50acee04 | 2811 | { |
26d18378 RR |
2812 | int new_layer = wxMax( wxMax( GetMaxLayer(docks, wxAUI_DOCK_BOTTOM), |
2813 | GetMaxLayer(docks, wxAUI_DOCK_LEFT)), | |
2814 | GetMaxLayer(docks, wxAUI_DOCK_RIGHT)) + 1; | |
7608fd01 | 2815 | |
32e4b03c BW |
2816 | if (drop.IsToolbar()) |
2817 | new_layer = auiToolBarLayer; | |
7608fd01 | 2818 | |
50acee04 | 2819 | drop.Dock().Bottom(). |
26d18378 | 2820 | Layer(new_layer). |
50acee04 JS |
2821 | Row(0). |
2822 | Position(pt.x - GetDockPixelOffset(drop) - offset.x); | |
2823 | return ProcessDockResult(target, drop); | |
2824 | } | |
2825 | ||
32e4b03c | 2826 | |
a3a5df9d | 2827 | wxAuiDockUIPart* part = HitTest(pt.x, pt.y); |
50acee04 JS |
2828 | |
2829 | ||
2830 | if (drop.IsToolbar()) | |
2831 | { | |
2832 | if (!part || !part->dock) | |
2833 | return false; | |
93b9de86 | 2834 | |
50acee04 JS |
2835 | // calculate the offset from where the dock begins |
2836 | // to the point where the user dropped the pane | |
2837 | int dock_drop_offset = 0; | |
2838 | if (part->dock->IsHorizontal()) | |
2839 | dock_drop_offset = pt.x - part->dock->rect.x - offset.x; | |
7608fd01 | 2840 | else |
50acee04 JS |
2841 | dock_drop_offset = pt.y - part->dock->rect.y - offset.y; |
2842 | ||
2843 | ||
2844 | // toolbars may only be moved in and to fixed-pane docks, | |
2845 | // otherwise we will try to float the pane. Also, the pane | |
2846 | // should float if being dragged over center pane windows | |
2847 | if (!part->dock->fixed || part->dock->dock_direction == wxAUI_DOCK_CENTER) | |
2848 | { | |
22a35096 | 2849 | if (m_last_rect.IsEmpty() || m_last_rect.Contains(pt.x, pt.y )) |
c3008402 RR |
2850 | { |
2851 | m_skipping = true; | |
2852 | } | |
2853 | else | |
2854 | { | |
2855 | if ((m_flags & wxAUI_MGR_ALLOW_FLOATING) && | |
50acee04 JS |
2856 | (drop.IsFloatable() || |
2857 | (part->dock->dock_direction != wxAUI_DOCK_CENTER && | |
2858 | part->dock->dock_direction != wxAUI_DOCK_NONE))) | |
c3008402 RR |
2859 | { |
2860 | drop.Float(); | |
2861 | } | |
93b9de86 | 2862 | |
c3008402 | 2863 | m_skipping = false; |
93b9de86 | 2864 | |
c3008402 | 2865 | return ProcessDockResult(target, drop); |
50acee04 | 2866 | } |
93b9de86 | 2867 | |
c3008402 | 2868 | drop.Position(pt.x - GetDockPixelOffset(drop) - offset.x); |
be66f18e | 2869 | |
50acee04 JS |
2870 | return ProcessDockResult(target, drop); |
2871 | } | |
93b9de86 | 2872 | |
cedd7b22 PC |
2873 | m_skipping = false; |
2874 | ||
2875 | m_last_rect = part->dock->rect; | |
2876 | m_last_rect.Inflate( 15, 15 ); | |
be66f18e | 2877 | |
50acee04 JS |
2878 | drop.Dock(). |
2879 | Direction(part->dock->dock_direction). | |
2880 | Layer(part->dock->dock_layer). | |
2881 | Row(part->dock->dock_row). | |
2882 | Position(dock_drop_offset); | |
2883 | ||
2884 | if (( | |
12125a1e RR |
2885 | ((pt.y < part->dock->rect.y + 1) && part->dock->IsHorizontal()) || |
2886 | ((pt.x < part->dock->rect.x + 1) && part->dock->IsVertical()) | |
50acee04 JS |
2887 | ) && part->dock->panes.GetCount() > 1) |
2888 | { | |
26d18378 RR |
2889 | if ((part->dock->dock_direction == wxAUI_DOCK_TOP) || |
2890 | (part->dock->dock_direction == wxAUI_DOCK_LEFT)) | |
2891 | { | |
2892 | int row = drop.dock_row; | |
2893 | DoInsertDockRow(panes, part->dock->dock_direction, | |
2894 | part->dock->dock_layer, | |
2895 | part->dock->dock_row); | |
2896 | drop.dock_row = row; | |
2897 | } | |
2898 | else | |
2899 | { | |
2900 | DoInsertDockRow(panes, part->dock->dock_direction, | |
2901 | part->dock->dock_layer, | |
2902 | part->dock->dock_row+1); | |
2903 | drop.dock_row = part->dock->dock_row+1; | |
2904 | } | |
50acee04 | 2905 | } |
be66f18e | 2906 | |
50acee04 JS |
2907 | if (( |
2908 | ((pt.y > part->dock->rect.y + part->dock->rect.height - 2 ) && part->dock->IsHorizontal()) || | |
2909 | ((pt.x > part->dock->rect.x + part->dock->rect.width - 2 ) && part->dock->IsVertical()) | |
2910 | ) && part->dock->panes.GetCount() > 1) | |
2911 | { | |
26d18378 RR |
2912 | if ((part->dock->dock_direction == wxAUI_DOCK_TOP) || |
2913 | (part->dock->dock_direction == wxAUI_DOCK_LEFT)) | |
2914 | { | |
2915 | DoInsertDockRow(panes, part->dock->dock_direction, | |
2916 | part->dock->dock_layer, | |
2917 | part->dock->dock_row+1); | |
2918 | drop.dock_row = part->dock->dock_row+1; | |
2919 | } | |
2920 | else | |
2921 | { | |
2922 | int row = drop.dock_row; | |
2923 | DoInsertDockRow(panes, part->dock->dock_direction, | |
2924 | part->dock->dock_layer, | |
2925 | part->dock->dock_row); | |
2926 | drop.dock_row = row; | |
2927 | } | |
50acee04 JS |
2928 | } |
2929 | ||
2930 | return ProcessDockResult(target, drop); | |
2931 | } | |
2932 | ||
2933 | ||
2934 | ||
be66f18e | 2935 | |
50acee04 JS |
2936 | if (!part) |
2937 | return false; | |
2938 | ||
a3a5df9d BW |
2939 | if (part->type == wxAuiDockUIPart::typePaneBorder || |
2940 | part->type == wxAuiDockUIPart::typeCaption || | |
2941 | part->type == wxAuiDockUIPart::typeGripper || | |
2942 | part->type == wxAuiDockUIPart::typePaneButton || | |
2943 | part->type == wxAuiDockUIPart::typePane || | |
2944 | part->type == wxAuiDockUIPart::typePaneSizer || | |
2945 | part->type == wxAuiDockUIPart::typeDockSizer || | |
2946 | part->type == wxAuiDockUIPart::typeBackground) | |
50acee04 | 2947 | { |
a3a5df9d | 2948 | if (part->type == wxAuiDockUIPart::typeDockSizer) |
50acee04 JS |
2949 | { |
2950 | if (part->dock->panes.GetCount() != 1) | |
2951 | return false; | |
2952 | part = GetPanePart(part->dock->panes.Item(0)->window); | |
2953 | if (!part) | |
2954 | return false; | |
2955 | } | |
2956 | ||
2957 | ||
2958 | ||
2959 | // If a normal frame is being dragged over a toolbar, insert it | |
2960 | // along the edge under the toolbar, but over all other panes. | |
2961 | // (this could be done much better, but somehow factoring this | |
2962 | // calculation with the one at the beginning of this function) | |
2963 | if (part->dock && part->dock->toolbar) | |
2964 | { | |
2965 | int layer = 0; | |
2966 | ||
2967 | switch (part->dock->dock_direction) | |
2968 | { | |
2969 | case wxAUI_DOCK_LEFT: | |
2970 | layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_LEFT), | |
2971 | GetMaxLayer(docks, wxAUI_DOCK_BOTTOM)), | |
2972 | GetMaxLayer(docks, wxAUI_DOCK_TOP)); | |
2973 | break; | |
2974 | case wxAUI_DOCK_TOP: | |
2975 | layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_TOP), | |
2976 | GetMaxLayer(docks, wxAUI_DOCK_LEFT)), | |
2977 | GetMaxLayer(docks, wxAUI_DOCK_RIGHT)); | |
2978 | break; | |
2979 | case wxAUI_DOCK_RIGHT: | |
2980 | layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_RIGHT), | |
2981 | GetMaxLayer(docks, wxAUI_DOCK_TOP)), | |
2982 | GetMaxLayer(docks, wxAUI_DOCK_BOTTOM)); | |
2983 | break; | |
2984 | case wxAUI_DOCK_BOTTOM: | |
2985 | layer = wxMax(wxMax(GetMaxLayer(docks, wxAUI_DOCK_BOTTOM), | |
2986 | GetMaxLayer(docks, wxAUI_DOCK_LEFT)), | |
2987 | GetMaxLayer(docks, wxAUI_DOCK_RIGHT)); | |
2988 | break; | |
2989 | } | |
2990 | ||
2991 | DoInsertDockRow(panes, part->dock->dock_direction, | |
2992 | layer, 0); | |
2993 | drop.Dock(). | |
2994 | Direction(part->dock->dock_direction). | |
2995 | Layer(layer).Row(0).Position(0); | |
2996 | return ProcessDockResult(target, drop); | |
2997 | } | |
2998 | ||
2999 | ||
3000 | if (!part->pane) | |
3001 | return false; | |
3002 | ||
3003 | part = GetPanePart(part->pane->window); | |
3004 | if (!part) | |
3005 | return false; | |
be66f18e | 3006 | |
50acee04 JS |
3007 | bool insert_dock_row = false; |
3008 | int insert_row = part->pane->dock_row; | |
3009 | int insert_dir = part->pane->dock_direction; | |
3010 | int insert_layer = part->pane->dock_layer; | |
be66f18e | 3011 | |
50acee04 JS |
3012 | switch (part->pane->dock_direction) |
3013 | { | |
3014 | case wxAUI_DOCK_TOP: | |
3015 | if (pt.y >= part->rect.y && | |
3016 | pt.y < part->rect.y+auiInsertRowPixels) | |
3017 | insert_dock_row = true; | |
3018 | break; | |
3019 | case wxAUI_DOCK_BOTTOM: | |
3020 | if (pt.y > part->rect.y+part->rect.height-auiInsertRowPixels && | |
3021 | pt.y <= part->rect.y + part->rect.height) | |
3022 | insert_dock_row = true; | |
3023 | break; | |
3024 | case wxAUI_DOCK_LEFT: | |
3025 | if (pt.x >= part->rect.x && | |
3026 | pt.x < part->rect.x+auiInsertRowPixels) | |
3027 | insert_dock_row = true; | |
3028 | break; | |
3029 | case wxAUI_DOCK_RIGHT: | |
3030 | if (pt.x > part->rect.x+part->rect.width-auiInsertRowPixels && | |
3031 | pt.x <= part->rect.x+part->rect.width) | |
3032 | insert_dock_row = true; | |
3033 | break; | |
3034 | case wxAUI_DOCK_CENTER: | |
3035 | { | |
3036 | // "new row pixels" will be set to the default, but | |
3037 | // must never exceed 20% of the window size | |
3038 | int new_row_pixels_x = auiNewRowPixels; | |
3039 | int new_row_pixels_y = auiNewRowPixels; | |
3040 | ||
3041 | if (new_row_pixels_x > (part->rect.width*20)/100) | |
3042 | new_row_pixels_x = (part->rect.width*20)/100; | |
3043 | ||
3044 | if (new_row_pixels_y > (part->rect.height*20)/100) | |
3045 | new_row_pixels_y = (part->rect.height*20)/100; | |
3046 | ||
be66f18e | 3047 | |
50acee04 JS |
3048 | // determine if the mouse pointer is in a location that |
3049 | // will cause a new row to be inserted. The hot spot positions | |
3050 | // are along the borders of the center pane | |
3051 | ||
3052 | insert_layer = 0; | |
3053 | insert_dock_row = true; | |
7608fd01 VZ |
3054 | const wxRect& pr = part->rect; |
3055 | if (pt.x >= pr.x && pt.x < pr.x + new_row_pixels_x) | |
3056 | insert_dir = wxAUI_DOCK_LEFT; | |
3057 | else if (pt.y >= pr.y && pt.y < pr.y + new_row_pixels_y) | |
3058 | insert_dir = wxAUI_DOCK_TOP; | |
3059 | else if (pt.x >= pr.x + pr.width - new_row_pixels_x && | |
3060 | pt.x < pr.x + pr.width) | |
3061 | insert_dir = wxAUI_DOCK_RIGHT; | |
3062 | else if (pt.y >= pr.y+ pr.height - new_row_pixels_y && | |
3063 | pt.y < pr.y + pr.height) | |
3064 | insert_dir = wxAUI_DOCK_BOTTOM; | |
3065 | else | |
3066 | return false; | |
50acee04 JS |
3067 | |
3068 | insert_row = GetMaxRow(panes, insert_dir, insert_layer) + 1; | |
3069 | } | |
3070 | } | |
3071 | ||
3072 | if (insert_dock_row) | |
be66f18e | 3073 | { |
50acee04 JS |
3074 | DoInsertDockRow(panes, insert_dir, insert_layer, insert_row); |
3075 | drop.Dock().Direction(insert_dir). | |
3076 | Layer(insert_layer). | |
3077 | Row(insert_row). | |
3078 | Position(0); | |
3079 | return ProcessDockResult(target, drop); | |
3080 | } | |
be66f18e | 3081 | |
50acee04 JS |
3082 | // determine the mouse offset and the pane size, both in the |
3083 | // direction of the dock itself, and perpendicular to the dock | |
be66f18e | 3084 | |
50acee04 | 3085 | int offset, size; |
be66f18e | 3086 | |
50acee04 JS |
3087 | if (part->orientation == wxVERTICAL) |
3088 | { | |
3089 | offset = pt.y - part->rect.y; | |
be66f18e | 3090 | size = part->rect.GetHeight(); |
50acee04 | 3091 | } |
7608fd01 | 3092 | else |
50acee04 JS |
3093 | { |
3094 | offset = pt.x - part->rect.x; | |
3095 | size = part->rect.GetWidth(); | |
3096 | } | |
be66f18e | 3097 | |
50acee04 | 3098 | int drop_position = part->pane->dock_pos; |
be66f18e | 3099 | |
50acee04 JS |
3100 | // if we are in the top/left part of the pane, |
3101 | // insert the pane before the pane being hovered over | |
3102 | if (offset <= size/2) | |
3103 | { | |
3104 | drop_position = part->pane->dock_pos; | |
3105 | DoInsertPane(panes, | |
3106 | part->pane->dock_direction, | |
3107 | part->pane->dock_layer, | |
3108 | part->pane->dock_row, | |
3109 | part->pane->dock_pos); | |
3110 | } | |
3111 | ||
3112 | // if we are in the bottom/right part of the pane, | |
3113 | // insert the pane before the pane being hovered over | |
3114 | if (offset > size/2) | |
3115 | { | |
3116 | drop_position = part->pane->dock_pos+1; | |
3117 | DoInsertPane(panes, | |
3118 | part->pane->dock_direction, | |
3119 | part->pane->dock_layer, | |
3120 | part->pane->dock_row, | |
3121 | part->pane->dock_pos+1); | |
3122 | } | |
3123 | ||
3124 | drop.Dock(). | |
3125 | Direction(part->dock->dock_direction). | |
3126 | Layer(part->dock->dock_layer). | |
3127 | Row(part->dock->dock_row). | |
3128 | Position(drop_position); | |
3129 | return ProcessDockResult(target, drop); | |
3130 | } | |
3131 | ||
3132 | return false; | |
3133 | } | |
3134 | ||
3135 | ||
a3a5df9d | 3136 | void wxAuiManager::OnHintFadeTimer(wxTimerEvent& WXUNUSED(event)) |
50acee04 | 3137 | { |
7a5b04a6 | 3138 | if (!m_hint_wnd || m_hint_fadeamt >= m_hint_fademax) |
50acee04 JS |
3139 | { |
3140 | m_hint_fadetimer.Stop(); | |
3141 | return; | |
3142 | } | |
be66f18e | 3143 | |
7a5b04a6 | 3144 | m_hint_fadeamt += 4; |
07880314 | 3145 | m_hint_wnd->SetTransparent(m_hint_fadeamt); |
50acee04 JS |
3146 | } |
3147 | ||
a3a5df9d | 3148 | void wxAuiManager::ShowHint(const wxRect& rect) |
50acee04 | 3149 | { |
cf6fec73 | 3150 | if (m_hint_wnd) |
50acee04 | 3151 | { |
cf6fec73 | 3152 | // if the hint rect is the same as last time, don't do anything |
50acee04 JS |
3153 | if (m_last_hint == rect) |
3154 | return; | |
3155 | m_last_hint = rect; | |
be66f18e | 3156 | |
5826659c | 3157 | m_hint_fadeamt = m_hint_fademax; |
7608fd01 | 3158 | |
cf6fec73 | 3159 | if ((m_flags & wxAUI_MGR_HINT_FADE) |
5826659c | 3160 | && !((m_hint_wnd->IsKindOf(CLASSINFO(wxPseudoTransparentFrame))) && |
cf6fec73 | 3161 | (m_flags & wxAUI_MGR_NO_VENETIAN_BLINDS_FADE)) |
5826659c AB |
3162 | ) |
3163 | m_hint_fadeamt = 0; | |
be66f18e | 3164 | |
e65fbef6 | 3165 | m_hint_wnd->SetSize(rect); |
c2291b1f | 3166 | m_hint_wnd->SetTransparent(m_hint_fadeamt); |
b4ea182b | 3167 | |
cf6fec73 | 3168 | if (!m_hint_wnd->IsShown()) |
50acee04 JS |
3169 | m_hint_wnd->Show(); |
3170 | ||
50f3c41d RD |
3171 | // if we are dragging a floating pane, set the focus |
3172 | // back to that floating pane (otherwise it becomes unfocused) | |
3173 | if (m_action == actionDragFloatingPane && m_action_window) | |
3174 | m_action_window->SetFocus(); | |
50acee04 | 3175 | |
50f3c41d | 3176 | m_hint_wnd->Raise(); |
c08ee034 | 3177 | |
be66f18e | 3178 | |
5826659c | 3179 | if (m_hint_fadeamt != m_hint_fademax) // Only fade if we need to |
50acee04 JS |
3180 | { |
3181 | // start fade in timer | |
50acee04 JS |
3182 | m_hint_fadetimer.SetOwner(this, 101); |
3183 | m_hint_fadetimer.Start(5); | |
3184 | } | |
50acee04 | 3185 | } |
7608fd01 | 3186 | else // Not using a transparent hint window... |
50acee04 | 3187 | { |
cf6fec73 BW |
3188 | if (!(m_flags & wxAUI_MGR_RECTANGLE_HINT)) |
3189 | return; | |
7608fd01 | 3190 | |
50f3c41d RD |
3191 | if (m_last_hint != rect) |
3192 | { | |
3193 | // remove the last hint rectangle | |
3194 | m_last_hint = rect; | |
3195 | m_frame->Refresh(); | |
3196 | m_frame->Update(); | |
3197 | } | |
50acee04 | 3198 | |
50f3c41d RD |
3199 | wxScreenDC screendc; |
3200 | wxRegion clip(1, 1, 10000, 10000); | |
3201 | ||
3202 | // clip all floating windows, so we don't draw over them | |
3203 | int i, pane_count; | |
3204 | for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) | |
50acee04 | 3205 | { |
a3a5df9d | 3206 | wxAuiPaneInfo& pane = m_panes.Item(i); |
50f3c41d RD |
3207 | |
3208 | if (pane.IsFloating() && | |
3209 | pane.frame->IsShown()) | |
3210 | { | |
3211 | wxRect rect = pane.frame->GetRect(); | |
3212 | #ifdef __WXGTK__ | |
3213 | // wxGTK returns the client size, not the whole frame size | |
3214 | rect.width += 15; | |
3215 | rect.height += 35; | |
3216 | rect.Inflate(5); | |
3217 | #endif | |
3218 | ||
3219 | clip.Subtract(rect); | |
3220 | } | |
50acee04 | 3221 | } |
50acee04 | 3222 | |
8b001346 AB |
3223 | // As we can only hide the hint by redrawing the managed window, we |
3224 | // need to clip the region to the managed window too or we get | |
3225 | // nasty redrawn problems. | |
3226 | clip.Intersect(m_frame->GetRect()); | |
3227 | ||
50f3c41d | 3228 | screendc.SetClippingRegion(clip); |
50acee04 | 3229 | |
50f3c41d RD |
3230 | wxBitmap stipple = wxPaneCreateStippleBitmap(); |
3231 | wxBrush brush(stipple); | |
3232 | screendc.SetBrush(brush); | |
3233 | screendc.SetPen(*wxTRANSPARENT_PEN); | |
50acee04 | 3234 | |
50f3c41d RD |
3235 | screendc.DrawRectangle(rect.x, rect.y, 5, rect.height); |
3236 | screendc.DrawRectangle(rect.x+5, rect.y, rect.width-10, 5); | |
3237 | screendc.DrawRectangle(rect.x+rect.width-5, rect.y, 5, rect.height); | |
3238 | screendc.DrawRectangle(rect.x+5, rect.y+rect.height-5, rect.width-10, 5); | |
3239 | } | |
50acee04 JS |
3240 | } |
3241 | ||
a3a5df9d | 3242 | void wxAuiManager::HideHint() |
be66f18e | 3243 | { |
81cc4eb2 | 3244 | // hides a transparent window hint, if there is one |
50acee04 JS |
3245 | if (m_hint_wnd) |
3246 | { | |
26178b5d BW |
3247 | if (m_hint_wnd->IsShown()) |
3248 | m_hint_wnd->Show(false); | |
07880314 | 3249 | m_hint_wnd->SetTransparent(0); |
50acee04 JS |
3250 | m_hint_fadetimer.Stop(); |
3251 | m_last_hint = wxRect(); | |
3252 | return; | |
3253 | } | |
be66f18e | 3254 | |
50acee04 JS |
3255 | // hides a painted hint by redrawing the frame window |
3256 | if (!m_last_hint.IsEmpty()) | |
3257 | { | |
3258 | m_frame->Refresh(); | |
3259 | m_frame->Update(); | |
3260 | m_last_hint = wxRect(); | |
3261 | } | |
3262 | } | |
3263 | ||
3264 | ||
3265 | ||
cf37c9a9 BW |
3266 | void wxAuiManager::StartPaneDrag(wxWindow* pane_window, |
3267 | const wxPoint& offset) | |
3268 | { | |
3269 | wxAuiPaneInfo& pane = GetPane(pane_window); | |
3270 | if (!pane.IsOk()) | |
3271 | return; | |
7608fd01 | 3272 | |
cf37c9a9 BW |
3273 | if (pane.IsToolbar()) |
3274 | { | |
3275 | m_action = actionDragToolbarPane; | |
3276 | } | |
7608fd01 | 3277 | else |
cf37c9a9 BW |
3278 | { |
3279 | m_action = actionDragFloatingPane; | |
3280 | } | |
7608fd01 | 3281 | |
cf37c9a9 BW |
3282 | m_action_window = pane_window; |
3283 | m_action_offset = offset; | |
3284 | m_frame->CaptureMouse(); | |
3285 | } | |
3286 | ||
ce15b45f BW |
3287 | |
3288 | // CalculateHintRect() calculates the drop hint rectangle. The method | |
3289 | // first calls DoDrop() to determine the exact position the pane would | |
3290 | // be at were if dropped. If the pane would indeed become docked at the | |
3291 | // specified drop point, the the rectangle hint will be returned in | |
3292 | // screen coordinates. Otherwise, an empty rectangle is returned. | |
3293 | // |pane_window| is the window pointer of the pane being dragged, |pt| is | |
3294 | // the mouse position, in client coordinates. |offset| describes the offset | |
3295 | // that the mouse is from the upper-left corner of the item being dragged | |
3296 | ||
3297 | wxRect wxAuiManager::CalculateHintRect(wxWindow* pane_window, | |
3298 | const wxPoint& pt, | |
3299 | const wxPoint& offset) | |
50acee04 JS |
3300 | { |
3301 | wxRect rect; | |
3302 | ||
3303 | // we need to paint a hint rectangle; to find out the exact hint rectangle, | |
3304 | // we will create a new temporary layout and then measure the resulting | |
3305 | // rectangle; we will create a copy of the docking structures (m_dock) | |
3306 | // so that we don't modify the real thing on screen | |
3307 | ||
3308 | int i, pane_count, part_count; | |
a3a5df9d BW |
3309 | wxAuiDockInfoArray docks; |
3310 | wxAuiPaneInfoArray panes; | |
3311 | wxAuiDockUIPartArray uiparts; | |
3312 | wxAuiPaneInfo hint = GetPane(pane_window); | |
50acee04 | 3313 | hint.name = wxT("__HINT__"); |
479574aa | 3314 | hint.PaneBorder(true); |
483c90c2 | 3315 | hint.Show(); |
50acee04 JS |
3316 | |
3317 | if (!hint.IsOk()) | |
ce15b45f | 3318 | return rect; |
50acee04 JS |
3319 | |
3320 | CopyDocksAndPanes(docks, panes, m_docks, m_panes); | |
3321 | ||
3322 | // remove any pane already there which bears the same window; | |
3323 | // this happens when you are moving a pane around in a dock | |
3324 | for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) | |
3325 | { | |
3326 | if (panes.Item(i).window == pane_window) | |
3327 | { | |
3328 | RemovePaneFromDocks(docks, panes.Item(i)); | |
3329 | panes.RemoveAt(i); | |
3330 | break; | |
3331 | } | |
3332 | } | |
3333 | ||
3334 | // find out where the new pane would be | |
3335 | if (!DoDrop(docks, panes, hint, pt, offset)) | |
3336 | { | |
ce15b45f | 3337 | return rect; |
50acee04 JS |
3338 | } |
3339 | ||
3340 | panes.Add(hint); | |
3341 | ||
3342 | wxSizer* sizer = LayoutAll(panes, docks, uiparts, true); | |
3343 | wxSize client_size = m_frame->GetClientSize(); | |
3344 | sizer->SetDimension(0, 0, client_size.x, client_size.y); | |
3345 | sizer->Layout(); | |
3346 | ||
3347 | for (i = 0, part_count = uiparts.GetCount(); | |
3348 | i < part_count; ++i) | |
3349 | { | |
a3a5df9d | 3350 | wxAuiDockUIPart& part = uiparts.Item(i); |
50acee04 | 3351 | |
a3a5df9d | 3352 | if (part.type == wxAuiDockUIPart::typePaneBorder && |
50acee04 JS |
3353 | part.pane && part.pane->name == wxT("__HINT__")) |
3354 | { | |
3355 | rect = wxRect(part.sizer_item->GetPosition(), | |
3356 | part.sizer_item->GetSize()); | |
3357 | break; | |
3358 | } | |
3359 | } | |
be66f18e | 3360 | |
50acee04 JS |
3361 | delete sizer; |
3362 | ||
3363 | if (rect.IsEmpty()) | |
3364 | { | |
ce15b45f | 3365 | return rect; |
50acee04 JS |
3366 | } |
3367 | ||
3368 | // actually show the hint rectangle on the screen | |
3369 | m_frame->ClientToScreen(&rect.x, &rect.y); | |
ce15b45f | 3370 | |
f928b1ab VZ |
3371 | if ( m_frame->GetLayoutDirection() == wxLayout_RightToLeft ) |
3372 | { | |
3373 | // Mirror rectangle in RTL mode | |
3374 | rect.x -= rect.GetWidth(); | |
3375 | } | |
3376 | ||
ce15b45f BW |
3377 | return rect; |
3378 | } | |
3379 | ||
3380 | // DrawHintRect() calculates the hint rectangle by calling | |
3381 | // CalculateHintRect(). If there is a rectangle, it shows it | |
3382 | // by calling ShowHint(), otherwise it hides any hint | |
3383 | // rectangle currently shown | |
3384 | void wxAuiManager::DrawHintRect(wxWindow* pane_window, | |
3385 | const wxPoint& pt, | |
3386 | const wxPoint& offset) | |
3387 | { | |
3388 | wxRect rect = CalculateHintRect(pane_window, pt, offset); | |
7608fd01 | 3389 | |
ce15b45f BW |
3390 | if (rect.IsEmpty()) |
3391 | { | |
3392 | HideHint(); | |
3393 | } | |
7608fd01 | 3394 | else |
ce15b45f BW |
3395 | { |
3396 | ShowHint(rect); | |
3397 | } | |
50acee04 JS |
3398 | } |
3399 | ||
a3a5df9d | 3400 | void wxAuiManager::OnFloatingPaneMoveStart(wxWindow* wnd) |
50acee04 JS |
3401 | { |
3402 | // try to find the pane | |
a3a5df9d | 3403 | wxAuiPaneInfo& pane = GetPane(wnd); |
50acee04 | 3404 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
be66f18e | 3405 | |
50acee04 | 3406 | if (m_flags & wxAUI_MGR_TRANSPARENT_DRAG) |
07880314 | 3407 | pane.frame->SetTransparent(150); |
50acee04 JS |
3408 | } |
3409 | ||
a3a5df9d | 3410 | void wxAuiManager::OnFloatingPaneMoving(wxWindow* wnd, wxDirection dir) |
50acee04 JS |
3411 | { |
3412 | // try to find the pane | |
a3a5df9d | 3413 | wxAuiPaneInfo& pane = GetPane(wnd); |
50acee04 | 3414 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
be66f18e | 3415 | |
50acee04 | 3416 | wxPoint pt = ::wxGetMousePosition(); |
322c5ec4 | 3417 | |
f8a13949 | 3418 | #if 0 |
b4ea182b | 3419 | // Adapt pt to direction |
322c5ec4 RR |
3420 | if (dir == wxNORTH) |
3421 | { | |
3422 | // move to pane's upper border | |
3423 | wxPoint pos( 0,0 ); | |
3424 | pos = wnd->ClientToScreen( pos ); | |
3425 | pt.y = pos.y; | |
3426 | // and some more pixels for the title bar | |
3427 | pt.y -= 5; | |
7608fd01 VZ |
3428 | } |
3429 | else if (dir == wxWEST) | |
322c5ec4 RR |
3430 | { |
3431 | // move to pane's left border | |
3432 | wxPoint pos( 0,0 ); | |
3433 | pos = wnd->ClientToScreen( pos ); | |
3434 | pt.x = pos.x; | |
7608fd01 VZ |
3435 | } |
3436 | else if (dir == wxEAST) | |
322c5ec4 RR |
3437 | { |
3438 | // move to pane's right border | |
3439 | wxPoint pos( wnd->GetSize().x, 0 ); | |
3440 | pos = wnd->ClientToScreen( pos ); | |
3441 | pt.x = pos.x; | |
7608fd01 VZ |
3442 | } |
3443 | else if (dir == wxSOUTH) | |
322c5ec4 RR |
3444 | { |
3445 | // move to pane's bottom border | |
3446 | wxPoint pos( 0, wnd->GetSize().y ); | |
3447 | pos = wnd->ClientToScreen( pos ); | |
3448 | pt.y = pos.y; | |
3449 | } | |
93b9de86 WS |
3450 | #else |
3451 | wxUnusedVar(dir); | |
322c5ec4 RR |
3452 | #endif |
3453 | ||
50acee04 | 3454 | wxPoint client_pt = m_frame->ScreenToClient(pt); |
be66f18e | 3455 | |
50acee04 JS |
3456 | // calculate the offset from the upper left-hand corner |
3457 | // of the frame to the mouse pointer | |
3458 | wxPoint frame_pos = pane.frame->GetPosition(); | |
3459 | wxPoint action_offset(pt.x-frame_pos.x, pt.y-frame_pos.y); | |
3460 | ||
3461 | // no hint for toolbar floating windows | |
3462 | if (pane.IsToolbar() && m_action == actionDragFloatingPane) | |
3463 | { | |
cedd7b22 PC |
3464 | wxAuiDockInfoArray docks; |
3465 | wxAuiPaneInfoArray panes; | |
3466 | wxAuiDockUIPartArray uiparts; | |
3467 | wxAuiPaneInfo hint = pane; | |
be66f18e | 3468 | |
cedd7b22 | 3469 | CopyDocksAndPanes(docks, panes, m_docks, m_panes); |
50acee04 | 3470 | |
cedd7b22 PC |
3471 | // find out where the new pane would be |
3472 | if (!DoDrop(docks, panes, hint, client_pt)) | |
3473 | return; | |
3474 | if (hint.IsFloating()) | |
3475 | return; | |
be66f18e | 3476 | |
cedd7b22 PC |
3477 | pane = hint; |
3478 | m_action = actionDragToolbarPane; | |
3479 | m_action_window = pane.window; | |
be66f18e | 3480 | |
cedd7b22 | 3481 | Update(); |
be66f18e | 3482 | |
50acee04 JS |
3483 | return; |
3484 | } | |
3485 | ||
3486 | ||
3487 | // if a key modifier is pressed while dragging the frame, | |
3488 | // don't dock the window | |
858a3a7a | 3489 | if (!CanDockPanel(pane)) |
50acee04 JS |
3490 | { |
3491 | HideHint(); | |
3492 | return; | |
3493 | } | |
3494 | ||
3495 | ||
3496 | DrawHintRect(wnd, client_pt, action_offset); | |
3497 | ||
be66f18e | 3498 | #ifdef __WXGTK__ |
50acee04 JS |
3499 | // this cleans up some screen artifacts that are caused on GTK because |
3500 | // we aren't getting the exact size of the window (see comment | |
3501 | // in DrawHintRect) | |
3502 | //Refresh(); | |
be66f18e WS |
3503 | #endif |
3504 | ||
3505 | ||
50acee04 JS |
3506 | // reduces flicker |
3507 | m_frame->Update(); | |
3508 | } | |
3509 | ||
a3a5df9d | 3510 | void wxAuiManager::OnFloatingPaneMoved(wxWindow* wnd, wxDirection dir) |
50acee04 JS |
3511 | { |
3512 | // try to find the pane | |
a3a5df9d | 3513 | wxAuiPaneInfo& pane = GetPane(wnd); |
50acee04 | 3514 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
be66f18e | 3515 | |
50acee04 | 3516 | wxPoint pt = ::wxGetMousePosition(); |
322c5ec4 | 3517 | |
f8a13949 | 3518 | #if 0 |
b4ea182b | 3519 | // Adapt pt to direction |
322c5ec4 RR |
3520 | if (dir == wxNORTH) |
3521 | { | |
3522 | // move to pane's upper border | |
3523 | wxPoint pos( 0,0 ); | |
3524 | pos = wnd->ClientToScreen( pos ); | |
3525 | pt.y = pos.y; | |
3526 | // and some more pixels for the title bar | |
3527 | pt.y -= 10; | |
7608fd01 VZ |
3528 | } |
3529 | else if (dir == wxWEST) | |
322c5ec4 RR |
3530 | { |
3531 | // move to pane's left border | |
3532 | wxPoint pos( 0,0 ); | |
3533 | pos = wnd->ClientToScreen( pos ); | |
3534 | pt.x = pos.x; | |
7608fd01 VZ |
3535 | } |
3536 | else if (dir == wxEAST) | |
322c5ec4 RR |
3537 | { |
3538 | // move to pane's right border | |
3539 | wxPoint pos( wnd->GetSize().x, 0 ); | |
3540 | pos = wnd->ClientToScreen( pos ); | |
3541 | pt.x = pos.x; | |
7608fd01 VZ |
3542 | } |
3543 | else if (dir == wxSOUTH) | |
322c5ec4 RR |
3544 | { |
3545 | // move to pane's bottom border | |
3546 | wxPoint pos( 0, wnd->GetSize().y ); | |
3547 | pos = wnd->ClientToScreen( pos ); | |
3548 | pt.y = pos.y; | |
3549 | } | |
93b9de86 WS |
3550 | #else |
3551 | wxUnusedVar(dir); | |
322c5ec4 RR |
3552 | #endif |
3553 | ||
50acee04 | 3554 | wxPoint client_pt = m_frame->ScreenToClient(pt); |
be66f18e | 3555 | |
50acee04 JS |
3556 | // calculate the offset from the upper left-hand corner |
3557 | // of the frame to the mouse pointer | |
3558 | wxPoint frame_pos = pane.frame->GetPosition(); | |
3559 | wxPoint action_offset(pt.x-frame_pos.x, pt.y-frame_pos.y); | |
be66f18e | 3560 | |
50acee04 JS |
3561 | |
3562 | // if a key modifier is pressed while dragging the frame, | |
3563 | // don't dock the window | |
858a3a7a | 3564 | if (CanDockPanel(pane)) |
50acee04 | 3565 | { |
50f3c41d RD |
3566 | // do the drop calculation |
3567 | DoDrop(m_docks, m_panes, pane, client_pt, action_offset); | |
50acee04 | 3568 | } |
c08ee034 | 3569 | |
50acee04 JS |
3570 | // if the pane is still floating, update it's floating |
3571 | // position (that we store) | |
3572 | if (pane.IsFloating()) | |
3573 | { | |
3574 | pane.floating_pos = pane.frame->GetPosition(); | |
be66f18e | 3575 | |
50acee04 | 3576 | if (m_flags & wxAUI_MGR_TRANSPARENT_DRAG) |
07880314 | 3577 | pane.frame->SetTransparent(255); |
7453065a | 3578 | } |
7608fd01 | 3579 | else if (m_has_maximized) |
7453065a | 3580 | { |
37106ab2 | 3581 | RestoreMaximizedPane(); |
50acee04 | 3582 | } |
be66f18e | 3583 | |
50acee04 | 3584 | Update(); |
be66f18e | 3585 | |
50acee04 JS |
3586 | HideHint(); |
3587 | } | |
3588 | ||
a3a5df9d | 3589 | void wxAuiManager::OnFloatingPaneResized(wxWindow* wnd, const wxSize& size) |
50acee04 JS |
3590 | { |
3591 | // try to find the pane | |
a3a5df9d | 3592 | wxAuiPaneInfo& pane = GetPane(wnd); |
50acee04 | 3593 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
be66f18e | 3594 | |
50acee04 JS |
3595 | pane.floating_size = size; |
3596 | } | |
3597 | ||
58754643 | 3598 | |
a3a5df9d | 3599 | void wxAuiManager::OnFloatingPaneClosed(wxWindow* wnd, wxCloseEvent& evt) |
50acee04 JS |
3600 | { |
3601 | // try to find the pane | |
a3a5df9d | 3602 | wxAuiPaneInfo& pane = GetPane(wnd); |
50acee04 JS |
3603 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
3604 | ||
58754643 BW |
3605 | |
3606 | // fire pane close event | |
bc07ab17 | 3607 | wxAuiManagerEvent e(wxEVT_AUI_PANE_CLOSE); |
58754643 BW |
3608 | e.SetPane(&pane); |
3609 | e.SetCanVeto(evt.CanVeto()); | |
3610 | ProcessMgrEvent(e); | |
a1b3b608 | 3611 | |
58754643 BW |
3612 | if (e.GetVeto()) |
3613 | { | |
3614 | evt.Veto(); | |
3615 | return; | |
3616 | } | |
7608fd01 | 3617 | else |
58754643 | 3618 | { |
7da1b21e BW |
3619 | // close the pane, but check that it |
3620 | // still exists in our pane array first | |
3621 | // (the event handler above might have removed it) | |
3622 | ||
3623 | wxAuiPaneInfo& check = GetPane(wnd); | |
3624 | if (check.IsOk()) | |
3625 | { | |
3626 | ClosePane(pane); | |
3627 | } | |
58754643 | 3628 | } |
50acee04 JS |
3629 | } |
3630 | ||
58754643 BW |
3631 | |
3632 | ||
a3a5df9d | 3633 | void wxAuiManager::OnFloatingPaneActivated(wxWindow* wnd) |
50acee04 | 3634 | { |
4d83610e | 3635 | if ((GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE) && GetPane(wnd).IsOk()) |
50acee04 | 3636 | { |
50acee04 JS |
3637 | SetActivePane(m_panes, wnd); |
3638 | Repaint(); | |
3639 | } | |
3640 | } | |
3641 | ||
673727f3 | 3642 | // OnRender() draws all of the pane captions, sashes, |
50acee04 JS |
3643 | // backgrounds, captions, grippers, pane borders and buttons. |
3644 | // It renders the entire user interface. | |
3645 | ||
a3a5df9d | 3646 | void wxAuiManager::OnRender(wxAuiManagerEvent& evt) |
50acee04 | 3647 | { |
befda040 RR |
3648 | // if the frame is about to be deleted, don't bother |
3649 | if (!m_frame || wxPendingDelete.Member(m_frame)) | |
cedd7b22 PC |
3650 | return; |
3651 | ||
673727f3 | 3652 | wxDC* dc = evt.GetDC(); |
c08ee034 | 3653 | |
50acee04 JS |
3654 | #ifdef __WXMAC__ |
3655 | dc->Clear() ; | |
3656 | #endif | |
3657 | int i, part_count; | |
3658 | for (i = 0, part_count = m_uiparts.GetCount(); | |
3659 | i < part_count; ++i) | |
3660 | { | |
a3a5df9d | 3661 | wxAuiDockUIPart& part = m_uiparts.Item(i); |
50acee04 | 3662 | |
4d83610e JS |
3663 | // don't draw hidden pane items or items that aren't windows |
3664 | if (part.sizer_item && ((!part.sizer_item->IsWindow() && !part.sizer_item->IsSpacer() && !part.sizer_item->IsSizer()) || !part.sizer_item->IsShown())) | |
50acee04 | 3665 | continue; |
be66f18e | 3666 | |
50acee04 JS |
3667 | switch (part.type) |
3668 | { | |
a3a5df9d BW |
3669 | case wxAuiDockUIPart::typeDockSizer: |
3670 | case wxAuiDockUIPart::typePaneSizer: | |
32205ebb | 3671 | m_art->DrawSash(*dc, m_frame, part.orientation, part.rect); |
50acee04 | 3672 | break; |
a3a5df9d | 3673 | case wxAuiDockUIPart::typeBackground: |
32205ebb | 3674 | m_art->DrawBackground(*dc, m_frame, part.orientation, part.rect); |
50acee04 | 3675 | break; |
a3a5df9d | 3676 | case wxAuiDockUIPart::typeCaption: |
32205ebb | 3677 | m_art->DrawCaption(*dc, m_frame, part.pane->caption, part.rect, *part.pane); |
50acee04 | 3678 | break; |
a3a5df9d | 3679 | case wxAuiDockUIPart::typeGripper: |
32205ebb | 3680 | m_art->DrawGripper(*dc, m_frame, part.rect, *part.pane); |
be66f18e | 3681 | break; |
a3a5df9d | 3682 | case wxAuiDockUIPart::typePaneBorder: |
32205ebb | 3683 | m_art->DrawBorder(*dc, m_frame, part.rect, *part.pane); |
50acee04 | 3684 | break; |
a3a5df9d | 3685 | case wxAuiDockUIPart::typePaneButton: |
32205ebb | 3686 | m_art->DrawPaneButton(*dc, m_frame, part.button->button_id, |
50acee04 JS |
3687 | wxAUI_BUTTON_STATE_NORMAL, part.rect, *part.pane); |
3688 | break; | |
3689 | } | |
3690 | } | |
3691 | } | |
3692 | ||
673727f3 BW |
3693 | |
3694 | // Render() fire a render event, which is normally handled by | |
a3a5df9d | 3695 | // wxAuiManager::OnRender(). This allows the render function to |
673727f3 BW |
3696 | // be overridden via the render event. This can be useful for paintin |
3697 | // custom graphics in the main window. Default behavior can be | |
3698 | // invoked in the overridden function by calling OnRender() | |
3699 | ||
a3a5df9d | 3700 | void wxAuiManager::Render(wxDC* dc) |
673727f3 | 3701 | { |
a3a5df9d | 3702 | wxAuiManagerEvent e(wxEVT_AUI_RENDER); |
bc9e3321 | 3703 | e.SetManager(this); |
673727f3 BW |
3704 | e.SetDC(dc); |
3705 | ProcessMgrEvent(e); | |
3706 | } | |
3707 | ||
a3a5df9d | 3708 | void wxAuiManager::Repaint(wxDC* dc) |
50acee04 JS |
3709 | { |
3710 | #ifdef __WXMAC__ | |
3711 | if ( dc == NULL ) | |
3712 | { | |
3713 | m_frame->Refresh() ; | |
3714 | m_frame->Update() ; | |
3715 | return ; | |
3716 | } | |
3717 | #endif | |
3718 | int w, h; | |
3719 | m_frame->GetClientSize(&w, &h); | |
3720 | ||
3721 | // figure out which dc to use; if one | |
3722 | // has been specified, use it, otherwise | |
3723 | // make a client dc | |
3724 | wxClientDC* client_dc = NULL; | |
3725 | if (!dc) | |
3726 | { | |
3727 | client_dc = new wxClientDC(m_frame); | |
3728 | dc = client_dc; | |
3729 | } | |
3730 | ||
3731 | // if the frame has a toolbar, the client area | |
3732 | // origin will not be (0,0). | |
3733 | wxPoint pt = m_frame->GetClientAreaOrigin(); | |
3734 | if (pt.x != 0 || pt.y != 0) | |
3735 | dc->SetDeviceOrigin(pt.x, pt.y); | |
3736 | ||
3737 | // render all the items | |
3738 | Render(dc); | |
3739 | ||
3740 | // if we created a client_dc, delete it | |
3741 | if (client_dc) | |
3742 | delete client_dc; | |
3743 | } | |
3744 | ||
a3a5df9d | 3745 | void wxAuiManager::OnPaint(wxPaintEvent& WXUNUSED(event)) |
50acee04 JS |
3746 | { |
3747 | wxPaintDC dc(m_frame); | |
3748 | Repaint(&dc); | |
3749 | } | |
3750 | ||
a3a5df9d | 3751 | void wxAuiManager::OnEraseBackground(wxEraseEvent& event) |
50acee04 JS |
3752 | { |
3753 | #ifdef __WXMAC__ | |
3754 | event.Skip() ; | |
3755 | #else | |
3756 | wxUnusedVar(event); | |
3757 | #endif | |
3758 | } | |
3759 | ||
a3a5df9d | 3760 | void wxAuiManager::OnSize(wxSizeEvent& event) |
50acee04 JS |
3761 | { |
3762 | if (m_frame) | |
3763 | { | |
3764 | DoFrameLayout(); | |
3765 | Repaint(); | |
7608fd01 | 3766 | |
473016d6 BW |
3767 | #if wxUSE_MDI |
3768 | if (m_frame->IsKindOf(CLASSINFO(wxMDIParentFrame))) | |
3769 | { | |
3770 | // for MDI parent frames, this event must not | |
3771 | // be "skipped". In other words, the parent frame | |
3772 | // must not be allowed to resize the client window | |
3773 | // after we are finished processing sizing changes | |
3774 | return; | |
3775 | } | |
3776 | #endif | |
50acee04 | 3777 | } |
8d361e83 | 3778 | event.Skip(); |
50acee04 JS |
3779 | } |
3780 | ||
4dc79cfb BW |
3781 | void wxAuiManager::OnFindManager(wxAuiManagerEvent& evt) |
3782 | { | |
3783 | // get the window we are managing, if none, return NULL | |
3784 | wxWindow* window = GetManagedWindow(); | |
3785 | if (!window) | |
3786 | { | |
3787 | evt.SetManager(NULL); | |
3788 | return; | |
3789 | } | |
7608fd01 | 3790 | |
4dc79cfb BW |
3791 | // if we are managing a child frame, get the 'real' manager |
3792 | if (window->IsKindOf(CLASSINFO(wxAuiFloatingFrame))) | |
3793 | { | |
3794 | wxAuiFloatingFrame* float_frame = static_cast<wxAuiFloatingFrame*>(window); | |
3795 | evt.SetManager(float_frame->GetOwnerManager()); | |
3796 | return; | |
3797 | } | |
7608fd01 | 3798 | |
4dc79cfb BW |
3799 | // return pointer to ourself |
3800 | evt.SetManager(this); | |
3801 | } | |
50acee04 | 3802 | |
a3a5df9d | 3803 | void wxAuiManager::OnSetCursor(wxSetCursorEvent& event) |
50acee04 JS |
3804 | { |
3805 | // determine cursor | |
a3a5df9d | 3806 | wxAuiDockUIPart* part = HitTest(event.GetX(), event.GetY()); |
50acee04 JS |
3807 | wxCursor cursor = wxNullCursor; |
3808 | ||
3809 | if (part) | |
3810 | { | |
a3a5df9d BW |
3811 | if (part->type == wxAuiDockUIPart::typeDockSizer || |
3812 | part->type == wxAuiDockUIPart::typePaneSizer) | |
50acee04 JS |
3813 | { |
3814 | // a dock may not be resized if it has a single | |
3815 | // pane which is not resizable | |
a3a5df9d | 3816 | if (part->type == wxAuiDockUIPart::typeDockSizer && part->dock && |
50acee04 JS |
3817 | part->dock->panes.GetCount() == 1 && |
3818 | part->dock->panes.Item(0)->IsFixed()) | |
3819 | return; | |
3820 | ||
3821 | // panes that may not be resized do not get a sizing cursor | |
3822 | if (part->pane && part->pane->IsFixed()) | |
3823 | return; | |
3824 | ||
3825 | if (part->orientation == wxVERTICAL) | |
3826 | cursor = wxCursor(wxCURSOR_SIZEWE); | |
7608fd01 | 3827 | else |
50acee04 JS |
3828 | cursor = wxCursor(wxCURSOR_SIZENS); |
3829 | } | |
7608fd01 | 3830 | else if (part->type == wxAuiDockUIPart::typeGripper) |
50acee04 JS |
3831 | { |
3832 | cursor = wxCursor(wxCURSOR_SIZING); | |
3833 | } | |
3834 | } | |
be66f18e | 3835 | |
50acee04 JS |
3836 | event.SetCursor(cursor); |
3837 | } | |
3838 | ||
3839 | ||
3840 | ||
a3a5df9d | 3841 | void wxAuiManager::UpdateButtonOnScreen(wxAuiDockUIPart* button_ui_part, |
28169517 | 3842 | const wxMouseEvent& event) |
50acee04 | 3843 | { |
a3a5df9d | 3844 | wxAuiDockUIPart* hit_test = HitTest(event.GetX(), event.GetY()); |
a93d5af8 | 3845 | if (!hit_test || !button_ui_part) |
28169517 | 3846 | return; |
7608fd01 | 3847 | |
50acee04 | 3848 | int state = wxAUI_BUTTON_STATE_NORMAL; |
be66f18e | 3849 | |
50acee04 JS |
3850 | if (hit_test == button_ui_part) |
3851 | { | |
3852 | if (event.LeftDown()) | |
3853 | state = wxAUI_BUTTON_STATE_PRESSED; | |
7608fd01 | 3854 | else |
50acee04 JS |
3855 | state = wxAUI_BUTTON_STATE_HOVER; |
3856 | } | |
7608fd01 | 3857 | else |
50acee04 JS |
3858 | { |
3859 | if (event.LeftDown()) | |
3860 | state = wxAUI_BUTTON_STATE_HOVER; | |
3861 | } | |
3862 | ||
3863 | // now repaint the button with hover state | |
3864 | wxClientDC cdc(m_frame); | |
3865 | ||
3866 | // if the frame has a toolbar, the client area | |
3867 | // origin will not be (0,0). | |
3868 | wxPoint pt = m_frame->GetClientAreaOrigin(); | |
3869 | if (pt.x != 0 || pt.y != 0) | |
3870 | cdc.SetDeviceOrigin(pt.x, pt.y); | |
3871 | ||
37106ab2 BW |
3872 | if (hit_test->pane) |
3873 | { | |
3874 | m_art->DrawPaneButton(cdc, m_frame, | |
3875 | button_ui_part->button->button_id, | |
3876 | state, | |
3877 | button_ui_part->rect, | |
3878 | *hit_test->pane); | |
3879 | } | |
50acee04 JS |
3880 | } |
3881 | ||
a3a5df9d | 3882 | void wxAuiManager::OnLeftDown(wxMouseEvent& event) |
50acee04 | 3883 | { |
a3a5df9d | 3884 | wxAuiDockUIPart* part = HitTest(event.GetX(), event.GetY()); |
50acee04 JS |
3885 | if (part) |
3886 | { | |
a3a5df9d BW |
3887 | if (part->type == wxAuiDockUIPart::typeDockSizer || |
3888 | part->type == wxAuiDockUIPart::typePaneSizer) | |
50acee04 | 3889 | { |
f5dc1b7e JS |
3890 | // Removing this restriction so that a centre pane can be resized |
3891 | //if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER) | |
3892 | // return; | |
7608fd01 | 3893 | |
50acee04 JS |
3894 | // a dock may not be resized if it has a single |
3895 | // pane which is not resizable | |
a3a5df9d | 3896 | if (part->type == wxAuiDockUIPart::typeDockSizer && part->dock && |
50acee04 JS |
3897 | part->dock->panes.GetCount() == 1 && |
3898 | part->dock->panes.Item(0)->IsFixed()) | |
3899 | return; | |
3900 | ||
3901 | // panes that may not be resized should be ignored here | |
3902 | if (part->pane && part->pane->IsFixed()) | |
3903 | return; | |
3904 | ||
3905 | m_action = actionResize; | |
3906 | m_action_part = part; | |
3907 | m_action_hintrect = wxRect(); | |
3908 | m_action_start = wxPoint(event.m_x, event.m_y); | |
3909 | m_action_offset = wxPoint(event.m_x - part->rect.x, | |
3910 | event.m_y - part->rect.y); | |
3911 | m_frame->CaptureMouse(); | |
3912 | } | |
7608fd01 | 3913 | else if (part->type == wxAuiDockUIPart::typePaneButton) |
50acee04 JS |
3914 | { |
3915 | m_action = actionClickButton; | |
3916 | m_action_part = part; | |
3917 | m_action_start = wxPoint(event.m_x, event.m_y); | |
3918 | m_frame->CaptureMouse(); | |
3919 | ||
3920 | UpdateButtonOnScreen(part, event); | |
3921 | } | |
7608fd01 | 3922 | else if (part->type == wxAuiDockUIPart::typeCaption || |
a3a5df9d | 3923 | part->type == wxAuiDockUIPart::typeGripper) |
50acee04 | 3924 | { |
79bcf6f4 RD |
3925 | // if we are managing a wxAuiFloatingFrame window, then |
3926 | // we are an embedded wxAuiManager inside the wxAuiFloatingFrame. | |
3927 | // We want to initiate a toolbar drag in our owner manager | |
3928 | wxWindow* managed_wnd = GetManagedWindow(); | |
7608fd01 VZ |
3929 | |
3930 | if (part->pane && | |
79bcf6f4 RD |
3931 | part->pane->window && |
3932 | managed_wnd && | |
3933 | managed_wnd->IsKindOf(CLASSINFO(wxAuiFloatingFrame))) | |
3934 | { | |
3935 | wxAuiFloatingFrame* floating_frame = (wxAuiFloatingFrame*)managed_wnd; | |
3936 | wxAuiManager* owner_mgr = floating_frame->GetOwnerManager(); | |
3937 | owner_mgr->StartPaneDrag(part->pane->window, | |
3938 | wxPoint(event.m_x - part->rect.x, | |
3939 | event.m_y - part->rect.y)); | |
3940 | return; | |
3941 | } | |
7608fd01 VZ |
3942 | |
3943 | ||
3944 | ||
50acee04 JS |
3945 | if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE) |
3946 | { | |
3947 | // set the caption as active | |
3948 | SetActivePane(m_panes, part->pane->window); | |
3949 | Repaint(); | |
3950 | } | |
a4c721ee JS |
3951 | |
3952 | if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER) | |
3953 | return; | |
50acee04 JS |
3954 | |
3955 | m_action = actionClickCaption; | |
3956 | m_action_part = part; | |
3957 | m_action_start = wxPoint(event.m_x, event.m_y); | |
3958 | m_action_offset = wxPoint(event.m_x - part->rect.x, | |
3959 | event.m_y - part->rect.y); | |
3960 | m_frame->CaptureMouse(); | |
3961 | } | |
3962 | #ifdef __WXMAC__ | |
3963 | else | |
3964 | { | |
3965 | event.Skip(); | |
3966 | } | |
3967 | #endif | |
3968 | } | |
3969 | #ifdef __WXMAC__ | |
3970 | else | |
3971 | { | |
3972 | event.Skip(); | |
3973 | } | |
3974 | #else | |
3975 | event.Skip(); | |
3976 | #endif | |
3977 | } | |
3978 | ||
3979 | ||
a3a5df9d | 3980 | void wxAuiManager::OnLeftUp(wxMouseEvent& event) |
50acee04 JS |
3981 | { |
3982 | if (m_action == actionResize) | |
3983 | { | |
3984 | m_frame->ReleaseMouse(); | |
3985 | ||
3986 | // get rid of the hint rectangle | |
3987 | wxScreenDC dc; | |
3988 | DrawResizeHint(dc, m_action_hintrect); | |
3989 | ||
3990 | // resize the dock or the pane | |
a3a5df9d | 3991 | if (m_action_part && m_action_part->type==wxAuiDockUIPart::typeDockSizer) |
50acee04 JS |
3992 | { |
3993 | wxRect& rect = m_action_part->dock->rect; | |
3994 | ||
3995 | wxPoint new_pos(event.m_x - m_action_offset.x, | |
3996 | event.m_y - m_action_offset.y); | |
3997 | ||
3998 | switch (m_action_part->dock->dock_direction) | |
3999 | { | |
4000 | case wxAUI_DOCK_LEFT: | |
4001 | m_action_part->dock->size = new_pos.x - rect.x; | |
4002 | break; | |
4003 | case wxAUI_DOCK_TOP: | |
4004 | m_action_part->dock->size = new_pos.y - rect.y; | |
4005 | break; | |
4006 | case wxAUI_DOCK_RIGHT: | |
4007 | m_action_part->dock->size = rect.x + rect.width - | |
4008 | new_pos.x - m_action_part->rect.GetWidth(); | |
4009 | break; | |
4010 | case wxAUI_DOCK_BOTTOM: | |
4011 | m_action_part->dock->size = rect.y + rect.height - | |
4012 | new_pos.y - m_action_part->rect.GetHeight(); | |
4013 | break; | |
4014 | } | |
4015 | ||
4016 | Update(); | |
4017 | Repaint(NULL); | |
4018 | } | |
7608fd01 VZ |
4019 | else if (m_action_part && |
4020 | m_action_part->type == wxAuiDockUIPart::typePaneSizer) | |
50acee04 | 4021 | { |
a3a5df9d BW |
4022 | wxAuiDockInfo& dock = *m_action_part->dock; |
4023 | wxAuiPaneInfo& pane = *m_action_part->pane; | |
50acee04 JS |
4024 | |
4025 | int total_proportion = 0; | |
4026 | int dock_pixels = 0; | |
4027 | int new_pixsize = 0; | |
4028 | ||
254a3429 BW |
4029 | int caption_size = m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE); |
4030 | int pane_border_size = m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE); | |
4031 | int sash_size = m_art->GetMetric(wxAUI_DOCKART_SASH_SIZE); | |
50acee04 JS |
4032 | |
4033 | wxPoint new_pos(event.m_x - m_action_offset.x, | |
4034 | event.m_y - m_action_offset.y); | |
4035 | ||
4036 | // determine the pane rectangle by getting the pane part | |
a3a5df9d | 4037 | wxAuiDockUIPart* pane_part = GetPanePart(pane.window); |
50acee04 JS |
4038 | wxASSERT_MSG(pane_part, |
4039 | wxT("Pane border part not found -- shouldn't happen")); | |
4040 | ||
4041 | // determine the new pixel size that the user wants; | |
4042 | // this will help us recalculate the pane's proportion | |
4043 | if (dock.IsHorizontal()) | |
4044 | new_pixsize = new_pos.x - pane_part->rect.x; | |
7608fd01 | 4045 | else |
50acee04 JS |
4046 | new_pixsize = new_pos.y - pane_part->rect.y; |
4047 | ||
4048 | // determine the size of the dock, based on orientation | |
4049 | if (dock.IsHorizontal()) | |
4050 | dock_pixels = dock.rect.GetWidth(); | |
7608fd01 | 4051 | else |
50acee04 JS |
4052 | dock_pixels = dock.rect.GetHeight(); |
4053 | ||
4054 | // determine the total proportion of all resizable panes, | |
4055 | // and the total size of the dock minus the size of all | |
4056 | // the fixed panes | |
4057 | int i, dock_pane_count = dock.panes.GetCount(); | |
4058 | int pane_position = -1; | |
4059 | for (i = 0; i < dock_pane_count; ++i) | |
4060 | { | |
a3a5df9d | 4061 | wxAuiPaneInfo& p = *dock.panes.Item(i); |
50acee04 JS |
4062 | if (p.window == pane.window) |
4063 | pane_position = i; | |
be66f18e | 4064 | |
50acee04 JS |
4065 | // while we're at it, subtract the pane sash |
4066 | // width from the dock width, because this would | |
4067 | // skew our proportion calculations | |
4068 | if (i > 0) | |
4069 | dock_pixels -= sash_size; | |
be66f18e | 4070 | |
50acee04 JS |
4071 | // also, the whole size (including decorations) of |
4072 | // all fixed panes must also be subtracted, because they | |
4073 | // are not part of the proportion calculation | |
4074 | if (p.IsFixed()) | |
4075 | { | |
4076 | if (dock.IsHorizontal()) | |
4077 | dock_pixels -= p.best_size.x; | |
7608fd01 | 4078 | else |
50acee04 JS |
4079 | dock_pixels -= p.best_size.y; |
4080 | } | |
7608fd01 | 4081 | else |
50acee04 JS |
4082 | { |
4083 | total_proportion += p.dock_proportion; | |
4084 | } | |
4085 | } | |
be66f18e | 4086 | |
50acee04 JS |
4087 | // find a pane in our dock to 'steal' space from or to 'give' |
4088 | // space to -- this is essentially what is done when a pane is | |
4089 | // resized; the pane should usually be the first non-fixed pane | |
4090 | // to the right of the action pane | |
4091 | int borrow_pane = -1; | |
4092 | for (i = pane_position+1; i < dock_pane_count; ++i) | |
4093 | { | |
a3a5df9d | 4094 | wxAuiPaneInfo& p = *dock.panes.Item(i); |
50acee04 JS |
4095 | if (!p.IsFixed()) |
4096 | { | |
4097 | borrow_pane = i; | |
4098 | break; | |
4099 | } | |
4100 | } | |
be66f18e WS |
4101 | |
4102 | ||
50acee04 JS |
4103 | // demand that the pane being resized is found in this dock |
4104 | // (this assert really never should be raised) | |
4105 | wxASSERT_MSG(pane_position != -1, wxT("Pane not found in dock")); | |
be66f18e | 4106 | |
50acee04 JS |
4107 | // prevent division by zero |
4108 | if (dock_pixels == 0 || total_proportion == 0 || borrow_pane == -1) | |
4109 | { | |
4110 | m_action = actionNone; | |
4111 | return; | |
4112 | } | |
4113 | ||
4114 | // calculate the new proportion of the pane | |
4115 | int new_proportion = (new_pixsize*total_proportion)/dock_pixels; | |
be66f18e | 4116 | |
50acee04 JS |
4117 | // default minimum size |
4118 | int min_size = 0; | |
be66f18e | 4119 | |
50acee04 JS |
4120 | // check against the pane's minimum size, if specified. please note |
4121 | // that this is not enough to ensure that the minimum size will | |
4122 | // not be violated, because the whole frame might later be shrunk, | |
4123 | // causing the size of the pane to violate it's minimum size | |
4124 | if (pane.min_size.IsFullySpecified()) | |
4125 | { | |
4126 | min_size = 0; | |
be66f18e | 4127 | |
50acee04 JS |
4128 | if (pane.HasBorder()) |
4129 | min_size += (pane_border_size*2); | |
4130 | ||
4131 | // calculate minimum size with decorations (border,caption) | |
4132 | if (pane_part->orientation == wxVERTICAL) | |
4133 | { | |
4134 | min_size += pane.min_size.y; | |
4135 | if (pane.HasCaption()) | |
4136 | min_size += caption_size; | |
4137 | } | |
7608fd01 | 4138 | else |
50acee04 JS |
4139 | { |
4140 | min_size += pane.min_size.x; | |
4141 | } | |
4142 | } | |
be66f18e WS |
4143 | |
4144 | ||
50acee04 JS |
4145 | // for some reason, an arithmatic error somewhere is causing |
4146 | // the proportion calculations to always be off by 1 pixel; | |
4147 | // for now we will add the 1 pixel on, but we really should | |
4148 | // determine what's causing this. | |
4149 | min_size++; | |
4150 | ||
4151 | int min_proportion = (min_size*total_proportion)/dock_pixels; | |
be66f18e | 4152 | |
50acee04 JS |
4153 | if (new_proportion < min_proportion) |
4154 | new_proportion = min_proportion; | |
be66f18e WS |
4155 | |
4156 | ||
4157 | ||
50acee04 JS |
4158 | int prop_diff = new_proportion - pane.dock_proportion; |
4159 | ||
4160 | // borrow the space from our neighbor pane to the | |
4161 | // right or bottom (depending on orientation) | |
4162 | dock.panes.Item(borrow_pane)->dock_proportion -= prop_diff; | |
4163 | pane.dock_proportion = new_proportion; | |
be66f18e | 4164 | |
50acee04 JS |
4165 | // repaint |
4166 | Update(); | |
4167 | Repaint(NULL); | |
4168 | } | |
4169 | } | |
696978ee | 4170 | else if (m_action == actionClickButton) |
50acee04 JS |
4171 | { |
4172 | m_hover_button = NULL; | |
be66f18e | 4173 | m_frame->ReleaseMouse(); |
50acee04 JS |
4174 | UpdateButtonOnScreen(m_action_part, event); |
4175 | ||
4176 | // make sure we're still over the item that was originally clicked | |
4177 | if (m_action_part == HitTest(event.GetX(), event.GetY())) | |
be66f18e | 4178 | { |
50acee04 | 4179 | // fire button-click event |
bc07ab17 | 4180 | wxAuiManagerEvent e(wxEVT_AUI_PANE_BUTTON); |
bc9e3321 | 4181 | e.SetManager(this); |
50acee04 JS |
4182 | e.SetPane(m_action_part->pane); |
4183 | e.SetButton(m_action_part->button->button_id); | |
4184 | ProcessMgrEvent(e); | |
4185 | } | |
4186 | } | |
696978ee | 4187 | else if (m_action == actionClickCaption) |
50acee04 JS |
4188 | { |
4189 | m_frame->ReleaseMouse(); | |
4190 | } | |
696978ee | 4191 | else if (m_action == actionDragFloatingPane) |
50acee04 JS |
4192 | { |
4193 | m_frame->ReleaseMouse(); | |
4194 | } | |
696978ee | 4195 | else if (m_action == actionDragToolbarPane) |
50acee04 JS |
4196 | { |
4197 | m_frame->ReleaseMouse(); | |
4198 | ||
a3a5df9d | 4199 | wxAuiPaneInfo& pane = GetPane(m_action_window); |
50acee04 | 4200 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
be66f18e | 4201 | |
50acee04 | 4202 | // save the new positions |
a3a5df9d | 4203 | wxAuiDockInfoPtrArray docks; |
50acee04 JS |
4204 | FindDocks(m_docks, pane.dock_direction, |
4205 | pane.dock_layer, pane.dock_row, docks); | |
4206 | if (docks.GetCount() == 1) | |
4207 | { | |
a3a5df9d | 4208 | wxAuiDockInfo& dock = *docks.Item(0); |
be66f18e | 4209 | |
50acee04 JS |
4210 | wxArrayInt pane_positions, pane_sizes; |
4211 | GetPanePositionsAndSizes(dock, pane_positions, pane_sizes); | |
be66f18e | 4212 | |
50acee04 JS |
4213 | int i, dock_pane_count = dock.panes.GetCount(); |
4214 | for (i = 0; i < dock_pane_count; ++i) | |
4215 | dock.panes.Item(i)->dock_pos = pane_positions[i]; | |
4216 | } | |
be66f18e | 4217 | |
a3a5df9d | 4218 | pane.state &= ~wxAuiPaneInfo::actionPane; |
50acee04 JS |
4219 | Update(); |
4220 | } | |
696978ee | 4221 | else |
50acee04 JS |
4222 | { |
4223 | event.Skip(); | |
4224 | } | |
4225 | ||
4226 | m_action = actionNone; | |
4227 | m_last_mouse_move = wxPoint(); // see comment in OnMotion() | |
4228 | } | |
4229 | ||
4230 | ||
a3a5df9d | 4231 | void wxAuiManager::OnMotion(wxMouseEvent& event) |
50acee04 JS |
4232 | { |
4233 | // sometimes when Update() is called from inside this method, | |
4234 | // a spurious mouse move event is generated; this check will make | |
4235 | // sure that only real mouse moves will get anywhere in this method; | |
4236 | // this appears to be a bug somewhere, and I don't know where the | |
4237 | // mouse move event is being generated. only verified on MSW | |
be66f18e | 4238 | |
50acee04 JS |
4239 | wxPoint mouse_pos = event.GetPosition(); |
4240 | if (m_last_mouse_move == mouse_pos) | |
4241 | return; | |
4242 | m_last_mouse_move = mouse_pos; | |
4243 | ||
be66f18e | 4244 | |
50acee04 JS |
4245 | if (m_action == actionResize) |
4246 | { | |
4247 | wxPoint pos = m_action_part->rect.GetPosition(); | |
4248 | if (m_action_part->orientation == wxHORIZONTAL) | |
4249 | pos.y = wxMax(0, event.m_y - m_action_offset.y); | |
7608fd01 | 4250 | else |
50acee04 JS |
4251 | pos.x = wxMax(0, event.m_x - m_action_offset.x); |
4252 | ||
4253 | wxRect rect(m_frame->ClientToScreen(pos), | |
4254 | m_action_part->rect.GetSize()); | |
4255 | ||
4256 | wxScreenDC dc; | |
4257 | if (!m_action_hintrect.IsEmpty()) | |
4258 | DrawResizeHint(dc, m_action_hintrect); | |
4259 | DrawResizeHint(dc, rect); | |
4260 | m_action_hintrect = rect; | |
4261 | } | |
696978ee | 4262 | else if (m_action == actionClickCaption) |
50acee04 JS |
4263 | { |
4264 | int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X); | |
4265 | int drag_y_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_Y); | |
be66f18e | 4266 | |
50acee04 JS |
4267 | // caption has been clicked. we need to check if the mouse |
4268 | // is now being dragged. if it is, we need to change the | |
4269 | // mouse action to 'drag' | |
4270 | if (abs(event.m_x - m_action_start.x) > drag_x_threshold || | |
be66f18e | 4271 | abs(event.m_y - m_action_start.y) > drag_y_threshold) |
50acee04 | 4272 | { |
a3a5df9d | 4273 | wxAuiPaneInfo* pane_info = m_action_part->pane; |
50acee04 JS |
4274 | |
4275 | if (!pane_info->IsToolbar()) | |
4276 | { | |
4277 | if ((m_flags & wxAUI_MGR_ALLOW_FLOATING) && | |
be66f18e | 4278 | pane_info->IsFloatable()) |
50acee04 JS |
4279 | { |
4280 | m_action = actionDragFloatingPane; | |
4281 | ||
4282 | // set initial float position | |
4283 | wxPoint pt = m_frame->ClientToScreen(event.GetPosition()); | |
4284 | pane_info->floating_pos = wxPoint(pt.x - m_action_offset.x, | |
4285 | pt.y - m_action_offset.y); | |
49fa1dbb | 4286 | |
50acee04 | 4287 | // float the window |
cf37c9a9 | 4288 | if (pane_info->IsMaximized()) |
37106ab2 | 4289 | RestorePane(*pane_info); |
50acee04 JS |
4290 | pane_info->Float(); |
4291 | Update(); | |
4292 | ||
4293 | m_action_window = pane_info->frame; | |
be66f18e | 4294 | |
50acee04 JS |
4295 | // action offset is used here to make it feel "natural" to the user |
4296 | // to drag a docked pane and suddenly have it become a floating frame. | |
4297 | // Sometimes, however, the offset where the user clicked on the docked | |
4298 | // caption is bigger than the width of the floating frame itself, so | |
4299 | // in that case we need to set the action offset to a sensible value | |
4300 | wxSize frame_size = m_action_window->GetSize(); | |
4301 | if (frame_size.x <= m_action_offset.x) | |
4302 | m_action_offset.x = 30; | |
4303 | } | |
4304 | } | |
7608fd01 | 4305 | else |
50acee04 JS |
4306 | { |
4307 | m_action = actionDragToolbarPane; | |
4308 | m_action_window = pane_info->window; | |
4309 | } | |
4310 | } | |
4311 | } | |
696978ee | 4312 | else if (m_action == actionDragFloatingPane) |
50acee04 | 4313 | { |
32e4b03c BW |
4314 | if (m_action_window) |
4315 | { | |
49fa1dbb RR |
4316 | wxPoint pt = m_frame->ClientToScreen(event.GetPosition()); |
4317 | m_action_window->Move(pt.x - m_action_offset.x, | |
4318 | pt.y - m_action_offset.y); | |
4319 | } | |
50acee04 | 4320 | } |
696978ee | 4321 | else if (m_action == actionDragToolbarPane) |
50acee04 | 4322 | { |
a3a5df9d | 4323 | wxAuiPaneInfo& pane = GetPane(m_action_window); |
50acee04 JS |
4324 | wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found")); |
4325 | ||
a3a5df9d | 4326 | pane.state |= wxAuiPaneInfo::actionPane; |
50acee04 JS |
4327 | |
4328 | wxPoint pt = event.GetPosition(); | |
4329 | DoDrop(m_docks, m_panes, pane, pt, m_action_offset); | |
be66f18e | 4330 | |
50acee04 JS |
4331 | // if DoDrop() decided to float the pane, set up |
4332 | // the floating pane's initial position | |
4333 | if (pane.IsFloating()) | |
4334 | { | |
4335 | wxPoint pt = m_frame->ClientToScreen(event.GetPosition()); | |
4336 | pane.floating_pos = wxPoint(pt.x - m_action_offset.x, | |
4337 | pt.y - m_action_offset.y); | |
4338 | } | |
be66f18e | 4339 | |
50acee04 JS |
4340 | // this will do the actiual move operation; |
4341 | // in the case that the pane has been floated, | |
4342 | // this call will create the floating pane | |
4343 | // and do the reparenting | |
4344 | Update(); | |
be66f18e | 4345 | |
50acee04 JS |
4346 | // if the pane has been floated, change the mouse |
4347 | // action actionDragFloatingPane so that subsequent | |
4348 | // EVT_MOTION() events will move the floating pane | |
4349 | if (pane.IsFloating()) | |
4350 | { | |
a3a5df9d | 4351 | pane.state &= ~wxAuiPaneInfo::actionPane; |
50acee04 JS |
4352 | m_action = actionDragFloatingPane; |
4353 | m_action_window = pane.frame; | |
4354 | } | |
be66f18e WS |
4355 | } |
4356 | else | |
50acee04 | 4357 | { |
a3a5df9d BW |
4358 | wxAuiDockUIPart* part = HitTest(event.GetX(), event.GetY()); |
4359 | if (part && part->type == wxAuiDockUIPart::typePaneButton) | |
50acee04 JS |
4360 | { |
4361 | if (part != m_hover_button) | |
4362 | { | |
4363 | // make the old button normal | |
4364 | if (m_hover_button) | |
37106ab2 | 4365 | { |
50acee04 | 4366 | UpdateButtonOnScreen(m_hover_button, event); |
37106ab2 BW |
4367 | Repaint(); |
4368 | } | |
7608fd01 | 4369 | |
50acee04 JS |
4370 | // mouse is over a button, so repaint the |
4371 | // button in hover mode | |
4372 | UpdateButtonOnScreen(part, event); | |
4373 | m_hover_button = part; | |
7608fd01 | 4374 | |
50acee04 JS |
4375 | } |
4376 | } | |
7608fd01 | 4377 | else |
50acee04 JS |
4378 | { |
4379 | if (m_hover_button) | |
4380 | { | |
4381 | m_hover_button = NULL; | |
4382 | Repaint(); | |
4383 | } | |
7608fd01 | 4384 | else |
50acee04 JS |
4385 | { |
4386 | event.Skip(); | |
4387 | } | |
4388 | } | |
4389 | } | |
4390 | } | |
4391 | ||
a3a5df9d | 4392 | void wxAuiManager::OnLeaveWindow(wxMouseEvent& WXUNUSED(event)) |
50acee04 JS |
4393 | { |
4394 | if (m_hover_button) | |
4395 | { | |
4396 | m_hover_button = NULL; | |
4397 | Repaint(); | |
4398 | } | |
4399 | } | |
4400 | ||
a3a5df9d | 4401 | void wxAuiManager::OnChildFocus(wxChildFocusEvent& event) |
50acee04 | 4402 | { |
be66f18e WS |
4403 | // when a child pane has it's focus set, we should change the |
4404 | // pane's active state to reflect this. (this is only true if | |
50acee04 JS |
4405 | // active panes are allowed by the owner) |
4406 | if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE) | |
4407 | { | |
d7ad415c BW |
4408 | wxAuiPaneInfo& pane = GetPane(event.GetWindow()); |
4409 | if (pane.IsOk() && (pane.state & wxAuiPaneInfo::optionActive) == 0) | |
50acee04 JS |
4410 | { |
4411 | SetActivePane(m_panes, event.GetWindow()); | |
4412 | m_frame->Refresh(); | |
4413 | } | |
4414 | } | |
c08ee034 | 4415 | |
16541a4e | 4416 | event.Skip(); |
50acee04 JS |
4417 | } |
4418 | ||
4419 | ||
4420 | // OnPaneButton() is an event handler that is called | |
4421 | // when a pane button has been pressed. | |
a3a5df9d | 4422 | void wxAuiManager::OnPaneButton(wxAuiManagerEvent& evt) |
50acee04 | 4423 | { |
a3a5df9d | 4424 | wxASSERT_MSG(evt.pane, wxT("Pane Info passed to wxAuiManager::OnPaneButton must be non-null")); |
a1b3b608 | 4425 | |
a3a5df9d | 4426 | wxAuiPaneInfo& pane = *(evt.pane); |
be66f18e | 4427 | |
4953f8cf | 4428 | if (evt.button == wxAUI_BUTTON_CLOSE) |
50acee04 | 4429 | { |
e092fb2e | 4430 | // fire pane close event |
bc07ab17 | 4431 | wxAuiManagerEvent e(wxEVT_AUI_PANE_CLOSE); |
bc9e3321 | 4432 | e.SetManager(this); |
58754643 BW |
4433 | e.SetPane(evt.pane); |
4434 | ProcessMgrEvent(e); | |
a1b3b608 | 4435 | |
58754643 | 4436 | if (!e.GetVeto()) |
cf08f19a | 4437 | { |
7da1b21e BW |
4438 | // close the pane, but check that it |
4439 | // still exists in our pane array first | |
4440 | // (the event handler above might have removed it) | |
4441 | ||
4442 | wxAuiPaneInfo& check = GetPane(pane.window); | |
4443 | if (check.IsOk()) | |
4444 | { | |
4445 | ClosePane(pane); | |
4446 | } | |
be794d62 | 4447 | |
58754643 | 4448 | Update(); |
cf08f19a | 4449 | } |
37106ab2 BW |
4450 | } |
4451 | else if (evt.button == wxAUI_BUTTON_MAXIMIZE_RESTORE && !pane.IsMaximized()) | |
4452 | { | |
4453 | // fire pane close event | |
bc07ab17 | 4454 | wxAuiManagerEvent e(wxEVT_AUI_PANE_MAXIMIZE); |
bc9e3321 | 4455 | e.SetManager(this); |
37106ab2 BW |
4456 | e.SetPane(evt.pane); |
4457 | ProcessMgrEvent(e); | |
4458 | ||
4459 | if (!e.GetVeto()) | |
4460 | { | |
4461 | MaximizePane(pane); | |
4462 | Update(); | |
4463 | } | |
4464 | } | |
4465 | else if (evt.button == wxAUI_BUTTON_MAXIMIZE_RESTORE && pane.IsMaximized()) | |
4466 | { | |
4467 | // fire pane close event | |
bc07ab17 | 4468 | wxAuiManagerEvent e(wxEVT_AUI_PANE_RESTORE); |
bc9e3321 | 4469 | e.SetManager(this); |
37106ab2 BW |
4470 | e.SetPane(evt.pane); |
4471 | ProcessMgrEvent(e); | |
4472 | ||
4473 | if (!e.GetVeto()) | |
4474 | { | |
4475 | RestorePane(pane); | |
4476 | Update(); | |
4477 | } | |
50acee04 | 4478 | } |
7608fd01 | 4479 | else if (evt.button == wxAUI_BUTTON_PIN) |
50acee04 JS |
4480 | { |
4481 | if ((m_flags & wxAUI_MGR_ALLOW_FLOATING) && | |
4482 | pane.IsFloatable()) | |
4483 | pane.Float(); | |
4484 | Update(); | |
4485 | } | |
4486 | } | |
4487 | ||
4488 | #endif // wxUSE_AUI |