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