1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/aui/framemanager.cpp
3 // Purpose: wxaui: wx advanced user interface - docking window manager
4 // Author: Benjamin I. Williams
8 // Copyright: (C) Copyright 2005-2006, Kirix Corporation, All Rights Reserved
9 // Licence: wxWindows Library Licence, Version 3.1
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
28 #include "wx/aui/framemanager.h"
29 #include "wx/aui/dockart.h"
30 #include "wx/aui/floatpane.h"
34 #include "wx/settings.h"
36 #include "wx/dcclient.h"
37 #include "wx/dcscreen.h"
38 #include "wx/toolbar.h"
43 WX_CHECK_BUILD_OPTIONS("wxAUI")
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
)
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
)
62 // a few defines to avoid nameclashes
63 #define __MAC_OS_X_MEMORY_MANAGER_CLEAN__ 1
65 #include "wx/mac/private.h"
68 IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent
, wxEvent
)
70 class wxPseudoTransparentFrame
: public wxFrame
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
)
82 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
89 m_CanSetShape
= false; // have to wait for window create event on GTK
93 m_Region
= wxRegion(0, 0, 0, 0);
97 virtual bool SetTransparent(wxByte alpha
)
101 int w
=100; // some defaults
103 GetClientSize(&w
, &h
);
109 // m_Region.Union(0, 0, 1, m_MaxWidth);
112 for (int y
=0; y
<m_MaxHeight
; y
++)
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);
126 void OnPaint(wxPaintEvent
& WXUNUSED(event
))
130 if (m_Region
.IsEmpty())
134 dc
.SetBrush(wxColour(128, 192, 255));
136 dc
.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION
));
138 dc
.SetPen(*wxTRANSPARENT_PEN
);
140 wxRegionIterator
upd(GetUpdateRegion()); // get the update rect list
144 wxRect
rect(upd
.GetRect());
145 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
152 void OnWindowCreate(wxWindowCreateEvent
& WXUNUSED(event
))
159 void OnSize(wxSizeEvent
& event
)
161 // We sometimes get surplus size events
162 if ((event
.GetSize().GetWidth() == m_lastWidth
) &&
163 (event
.GetSize().GetHeight() == m_lastHeight
))
168 m_lastWidth
= event
.GetSize().GetWidth();
169 m_lastHeight
= event
.GetSize().GetHeight();
171 SetTransparent(m_Amount
);
172 m_Region
.Intersect(0, 0, event
.GetSize().GetWidth(),
173 event
.GetSize().GetHeight());
184 int m_lastWidth
,m_lastHeight
;
188 DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame
)
189 DECLARE_EVENT_TABLE()
193 IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame
, wxFrame
)
195 BEGIN_EVENT_TABLE(wxPseudoTransparentFrame
, wxFrame
)
196 EVT_PAINT(wxPseudoTransparentFrame::OnPaint
)
197 EVT_SIZE(wxPseudoTransparentFrame::OnSize
)
199 EVT_WINDOW_CREATE(wxPseudoTransparentFrame::OnWindowCreate
)
204 // -- static utility functions --
206 static wxBitmap
wxPaneCreateStippleBitmap()
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
);
213 static void DrawResizeHint(wxDC
& dc
, const wxRect
& rect
)
215 wxBitmap stipple
= wxPaneCreateStippleBitmap();
216 wxBrush
brush(stipple
);
218 dc
.SetPen(*wxTRANSPARENT_PEN
);
220 dc
.SetLogicalFunction(wxXOR
);
221 dc
.DrawRectangle(rect
);
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
231 static void CopyDocksAndPanes(wxAuiDockInfoArray
& dest_docks
,
232 wxAuiPaneInfoArray
& dest_panes
,
233 const wxAuiDockInfoArray
& src_docks
,
234 const wxAuiPaneInfoArray
& src_panes
)
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
)
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
);
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
)
253 int i
, dock_count
, max_layer
= 0;
254 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
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
;
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
)
269 int i
, pane_count
, max_row
= 0;
270 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
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
;
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
,
290 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
292 wxAuiPaneInfo
& pane
= panes
.Item(i
);
293 if (!pane
.IsFloating() &&
294 pane
.dock_direction
== dock_direction
&&
295 pane
.dock_layer
>= dock_layer
)
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
,
308 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
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
)
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
,
328 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
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
)
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
,
347 wxAuiDockInfoPtrArray
& arr
)
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;
356 // discover the maximum dock layer and the max row
357 for (i
= 0; i
< dock_count
; ++i
)
359 max_row
= wxMax(max_row
, docks
.Item(i
).dock_row
);
360 max_layer
= wxMax(max_layer
, docks
.Item(i
).dock_layer
);
363 // if no dock layer was specified, search all dock layers
364 if (dock_layer
== -1)
367 end_layer
= max_layer
;
370 // if no dock row was specified, search all dock row
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
)
383 wxAuiDockInfo
& d
= docks
.Item(i
);
384 if (dock_direction
== -1 || dock_direction
== d
.dock_direction
)
386 if (d
.dock_layer
== layer
&& d
.dock_row
== row
)
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
)
396 int i
, count
= dock
.panes
.GetCount();
397 for (i
= 0; i
< count
; ++i
)
399 wxAuiPaneInfo
* p
= dock
.panes
.Item(i
);
400 if (p
->window
== window
)
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
,
410 wxAuiDockInfo
* ex_cept
= NULL
)
413 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
415 wxAuiDockInfo
& d
= docks
.Item(i
);
418 wxAuiPaneInfo
* pi
= FindPaneInDock(d
, pane
.window
);
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
)
429 int i
, dock_count
, j
, pane_count
;
430 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
432 wxAuiDockInfo
& dock
= *docks
.Item(i
);
434 for (j
= 0, pane_count
= dock
.panes
.GetCount(); j
< pane_count
; ++j
)
435 dock
.panes
.Item(j
)->dock_row
= i
;
440 // SetActivePane() sets the active pane, as well as cycles through
441 // every other pane and makes sure that all others' active flags
443 static void SetActivePane(wxAuiPaneInfoArray
& panes
, wxWindow
* active_pane
)
446 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
448 wxAuiPaneInfo
& pane
= panes
.Item(i
);
449 pane
.state
&= ~wxAuiPaneInfo::optionActive
;
450 if (pane
.window
== active_pane
)
451 pane
.state
|= wxAuiPaneInfo::optionActive
;
456 // this function is used to sort panes by dock position
457 static int PaneSortFunc(wxAuiPaneInfo
** p1
, wxAuiPaneInfo
** p2
)
459 return ((*p1
)->dock_pos
< (*p2
)->dock_pos
) ? -1 : 1;
463 // -- wxAuiManager class implementation --
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
)
482 wxAuiManager::wxAuiManager(wxWindow
* managed_wnd
, unsigned int flags
)
484 m_action
= actionNone
;
485 m_last_mouse_move
= wxPoint();
486 m_hover_button
= NULL
;
487 m_art
= new wxAuiDefaultDockArt
;
491 m_has_maximized
= false;
496 SetManagedWindow(managed_wnd
);
500 wxAuiManager::~wxAuiManager()
505 // Creates a floating frame for the windows
506 wxAuiFloatingFrame
* wxAuiManager::CreateFloatingFrame(wxWindow
* parent
, const wxAuiPaneInfo
& p
)
508 return new wxAuiFloatingFrame(parent
, this, p
);
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().
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.
520 wxAuiPaneInfo
& wxAuiManager::GetPane(wxWindow
* window
)
523 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
525 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
526 if (p
.window
== window
)
529 return wxAuiNullPaneInfo
;
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
)
537 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
539 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
543 return wxAuiNullPaneInfo
;
546 // GetAllPanes() returns a reference to all the pane info structures
547 wxAuiPaneInfoArray
& wxAuiManager::GetAllPanes()
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
)
557 wxAuiDockUIPart
* result
= NULL
;
560 for (i
= 0, part_count
= m_uiparts
.GetCount(); i
< part_count
; ++i
)
562 wxAuiDockUIPart
* item
= &m_uiparts
.Item(i
);
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
)
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
)
578 // if the point is inside the rectangle, we have a hit
579 if (item
->rect
.Contains(x
,y
))
587 // SetFlags() and GetFlags() allow the owner to set various
588 // options which are global to wxAuiManager
589 void wxAuiManager::SetFlags(unsigned int flags
)
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;
605 UpdateHintWindowConfig();
609 unsigned int wxAuiManager::GetFlags() const
615 // don't use these anymore as they are deprecated
616 // use Set/GetManagedFrame() instead
617 void wxAuiManager::SetFrame(wxFrame
* frame
)
619 SetManagedWindow((wxWindow
*)frame
);
622 wxFrame
* wxAuiManager::GetFrame() const
624 return (wxFrame
*)m_frame
;
628 void wxAuiManager::UpdateHintWindowConfig()
630 // find out if the the system can do transparent frames
631 bool can_do_transparent
= false;
633 wxWindow
* w
= m_frame
;
636 if (w
->IsKindOf(CLASSINFO(wxFrame
)))
638 wxFrame
* f
= static_cast<wxFrame
*>(w
);
639 #if wxCHECK_VERSION(2,7,0)
640 can_do_transparent
= f
->CanSetTransparent();
648 // if there is an existing hint window, delete it
651 m_hint_wnd
->Destroy();
658 if ((m_flags
& wxAUI_MGR_TRANSPARENT_HINT
) && can_do_transparent
)
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
|
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
);
678 // Can't set the bg colour of a Frame in wxMac
679 wxPanel
* p
= new wxPanel(m_hint_wnd
);
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
685 p
->SetBackgroundColour(*wxBLUE
);
691 if ((m_flags
& wxAUI_MGR_TRANSPARENT_HINT
) != 0 ||
692 (m_flags
& wxAUI_MGR_VENETIAN_BLINDS_HINT
) != 0)
694 // system can't support transparent fade, or the venetian
695 // blinds effect was explicitly requested
696 m_hint_wnd
= new wxPseudoTransparentFrame(m_frame
,
701 wxFRAME_TOOL_WINDOW
|
702 wxFRAME_FLOAT_ON_PARENT
|
705 m_hint_fademax
= 128;
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
)
716 wxASSERT_MSG(wnd
, wxT("specified window must be non-NULL"));
719 m_frame
->PushEventHandler(this);
722 // if the owner is going to manage an MDI parent frame,
723 // we need to add the MDI client window as the default
726 if (m_frame
->IsKindOf(CLASSINFO(wxMDIParentFrame
)))
728 wxMDIParentFrame
* mdi_frame
= (wxMDIParentFrame
*)m_frame
;
729 wxWindow
* client_window
= mdi_frame
->GetClientWindow();
731 wxASSERT_MSG(client_window
, wxT("Client window is NULL!"));
733 AddPane(client_window
,
734 wxAuiPaneInfo().Name(wxT("mdiclient")).
735 CenterPane().PaneBorder(false));
739 UpdateHintWindowConfig();
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()
750 m_frame
->RemoveEventHandler(this);
754 // GetManagedWindow() returns the window pointer being managed
755 wxWindow
* wxAuiManager::GetManagedWindow() const
760 wxAuiDockArt
* wxAuiManager::GetArtProvider() const
765 void wxAuiManager::ProcessMgrEvent(wxAuiManagerEvent
& event
)
767 // first, give the owner frame a chance to override
770 if (m_frame
->ProcessEvent(event
))
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
)
784 // delete the last art provider, if any
787 // assign the new art provider
788 m_art
= art_provider
;
792 bool wxAuiManager::AddPane(wxWindow
* window
, const wxAuiPaneInfo
& pane_info
)
794 // check if the pane has a valid window
798 // check if the pane already exists
799 if (GetPane(pane_info
.window
).IsOk())
802 m_panes
.Add(pane_info
);
804 wxAuiPaneInfo
& pinfo
= m_panes
.Last();
806 // set the pane window
807 pinfo
.window
= window
;
809 // if the pane's name identifier is blank, create a random string
810 if (pinfo
.name
.empty())
812 pinfo
.name
.Printf(wxT("%08lx%08x%08x%08lx"),
813 ((unsigned long)pinfo
.window
) & 0xffffffff,
814 (unsigned int)time(NULL
),
816 (unsigned int)GetTickCount(),
818 (unsigned int)clock(),
820 (unsigned long)m_panes
.GetCount());
823 // set initial proportion (if not already set)
824 if (pinfo
.dock_proportion
== 0)
825 pinfo
.dock_proportion
= 100000;
827 if (pinfo
.HasMaximizeButton())
829 wxAuiPaneButton button
;
830 button
.button_id
= wxAUI_BUTTON_MAXIMIZE_RESTORE
;
831 pinfo
.buttons
.Add(button
);
834 if (pinfo
.HasCloseButton())
836 wxAuiPaneButton button
;
837 button
.button_id
= wxAUI_BUTTON_CLOSE
;
838 pinfo
.buttons
.Add(button
);
841 if (pinfo
.best_size
== wxDefaultSize
&&
844 pinfo
.best_size
= pinfo
.window
->GetClientSize();
846 if (pinfo
.window
->IsKindOf(CLASSINFO(wxToolBar
)))
848 // GetClientSize() doesn't get the best size for
849 // a toolbar under some newer versions of wxWidgets,
850 // so use GetBestSize()
851 pinfo
.best_size
= pinfo
.window
->GetBestSize();
853 // for some reason, wxToolBar::GetBestSize() is returning
854 // a size that is a pixel shy of the correct amount.
855 // I believe this to be the correct action, until
856 // wxToolBar::GetBestSize() is fixed. Is this assumption
861 if (pinfo
.min_size
!= wxDefaultSize
)
863 if (pinfo
.best_size
.x
< pinfo
.min_size
.x
)
864 pinfo
.best_size
.x
= pinfo
.min_size
.x
;
865 if (pinfo
.best_size
.y
< pinfo
.min_size
.y
)
866 pinfo
.best_size
.y
= pinfo
.min_size
.y
;
873 bool wxAuiManager::AddPane(wxWindow
* window
,
875 const wxString
& caption
)
878 pinfo
.Caption(caption
);
881 case wxTOP
: pinfo
.Top(); break;
882 case wxBOTTOM
: pinfo
.Bottom(); break;
883 case wxLEFT
: pinfo
.Left(); break;
884 case wxRIGHT
: pinfo
.Right(); break;
885 case wxCENTER
: pinfo
.CenterPane(); break;
887 return AddPane(window
, pinfo
);
890 bool wxAuiManager::AddPane(wxWindow
* window
,
891 const wxAuiPaneInfo
& pane_info
,
892 const wxPoint
& drop_pos
)
894 if (!AddPane(window
, pane_info
))
897 wxAuiPaneInfo
& pane
= GetPane(window
);
899 DoDrop(m_docks
, m_panes
, pane
, drop_pos
, wxPoint(0,0));
904 bool wxAuiManager::InsertPane(wxWindow
* window
, const wxAuiPaneInfo
& pane_info
,
907 // shift the panes around, depending on the insert level
908 switch (insert_level
)
910 case wxAUI_INSERT_PANE
:
911 DoInsertPane(m_panes
,
912 pane_info
.dock_direction
,
913 pane_info
.dock_layer
,
917 case wxAUI_INSERT_ROW
:
918 DoInsertDockRow(m_panes
,
919 pane_info
.dock_direction
,
920 pane_info
.dock_layer
,
923 case wxAUI_INSERT_DOCK
:
924 DoInsertDockLayer(m_panes
,
925 pane_info
.dock_direction
,
926 pane_info
.dock_layer
);
930 // if the window already exists, we are basically just moving/inserting the
931 // existing window. If it doesn't exist, we need to add it and insert it
932 wxAuiPaneInfo
& existing_pane
= GetPane(window
);
933 if (!existing_pane
.IsOk())
935 return AddPane(window
, pane_info
);
939 if (pane_info
.IsFloating())
941 existing_pane
.Float();
942 if (pane_info
.floating_pos
!= wxDefaultPosition
)
943 existing_pane
.FloatingPosition(pane_info
.floating_pos
);
944 if (pane_info
.floating_size
!= wxDefaultSize
)
945 existing_pane
.FloatingSize(pane_info
.floating_size
);
949 existing_pane
.Direction(pane_info
.dock_direction
);
950 existing_pane
.Layer(pane_info
.dock_layer
);
951 existing_pane
.Row(pane_info
.dock_row
);
952 existing_pane
.Position(pane_info
.dock_pos
);
960 // DetachPane() removes a pane from the frame manager. This
961 // method will not destroy the window that is removed.
962 bool wxAuiManager::DetachPane(wxWindow
* window
)
965 for (i
= 0, count
= m_panes
.GetCount(); i
< count
; ++i
)
967 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
968 if (p
.window
== window
)
972 // we have a floating frame which is being detached. We need to
973 // reparent it to m_frame and destroy the floating frame
976 p
.window
->SetSize(1,1);
978 if (p
.frame
->IsShown())
979 p
.frame
->Show(false);
981 // reparent to m_frame and destroy the pane
982 if(m_action_window
== p
.frame
) {
983 m_action_window
= NULL
;
985 p
.window
->Reparent(m_frame
);
986 p
.frame
->SetSizer(NULL
);
991 // make sure there are no references to this pane in our uiparts,
992 // just in case the caller doesn't call Update() immediately after
993 // the DetachPane() call. This prevets obscure crashes which would
994 // happen at window repaint if the caller forgets to call Update()
996 for (pi
= 0, part_count
= (int)m_uiparts
.GetCount(); pi
< part_count
; ++pi
)
998 wxAuiDockUIPart
& part
= m_uiparts
.Item(pi
);
1001 m_uiparts
.RemoveAt(pi
);
1008 m_panes
.RemoveAt(i
);
1015 // ClosePane() destroys or hides the pane depending on its
1017 void wxAuiManager::ClosePane(wxAuiPaneInfo
& pane_info
)
1019 // if we were maximized, restore
1020 if(pane_info
.IsMaximized()) {
1021 RestorePane(pane_info
);
1024 // first, hide the window
1025 if (pane_info
.window
&& pane_info
.window
->IsShown()) {
1026 pane_info
.window
->Show(false);
1029 // make sure that we are the parent of this window
1030 if(pane_info
.window
&& pane_info
.window
->GetParent() != m_frame
) {
1031 pane_info
.window
->Reparent(m_frame
);
1034 // if we have a frame, destroy it
1035 if(pane_info
.frame
) {
1036 pane_info
.frame
->Destroy();
1037 pane_info
.frame
= NULL
;
1040 // now we need to either destroy or hide the pane
1041 if(pane_info
.IsDestroyOnClose())
1043 wxWindow
* window
= pane_info
.window
;
1055 void wxAuiManager::MaximizePane(wxAuiPaneInfo
& pane_info
)
1059 // un-maximize and hide all other panes
1060 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
1062 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
1063 if(!p
.IsToolbar()) {
1070 // mark ourselves maximized
1071 pane_info
.Maximize();
1073 m_has_maximized
= true;
1075 // last, show the window
1076 if (pane_info
.window
&& !pane_info
.window
->IsShown()) {
1077 pane_info
.window
->Show(true);
1081 void wxAuiManager::RestorePane(wxAuiPaneInfo
& pane_info
)
1085 // restore all the panes
1086 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
1088 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
1089 if(!p
.IsToolbar()) {
1094 // mark ourselves non-maximized
1095 pane_info
.Restore();
1096 m_has_maximized
= false;
1098 // last, show the window
1099 if (pane_info
.window
&& !pane_info
.window
->IsShown()) {
1100 pane_info
.window
->Show(true);
1104 void wxAuiManager::RestoreMaximizedPane()
1108 // restore all the panes
1109 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
1111 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
1112 if(p
.IsMaximized()) {
1119 // EscapeDelimiters() changes ";" into "\;" and "|" into "\|"
1120 // in the input string. This is an internal functions which is
1121 // used for saving perspectives
1122 static wxString
EscapeDelimiters(const wxString
& s
)
1125 result
.Alloc(s
.length());
1126 const wxChar
* ch
= s
.c_str();
1129 if (*ch
== wxT(';') || *ch
== wxT('|'))
1130 result
+= wxT('\\');
1137 wxString
wxAuiManager::SavePaneInfo(wxAuiPaneInfo
& pane
)
1139 wxString result
= wxT("name=");
1140 result
+= EscapeDelimiters(pane
.name
);
1143 result
+= wxT("caption=");
1144 result
+= EscapeDelimiters(pane
.caption
);
1147 result
+= wxString::Format(wxT("state=%u;"), pane
.state
);
1148 result
+= wxString::Format(wxT("dir=%d;"), pane
.dock_direction
);
1149 result
+= wxString::Format(wxT("layer=%d;"), pane
.dock_layer
);
1150 result
+= wxString::Format(wxT("row=%d;"), pane
.dock_row
);
1151 result
+= wxString::Format(wxT("pos=%d;"), pane
.dock_pos
);
1152 result
+= wxString::Format(wxT("prop=%d;"), pane
.dock_proportion
);
1153 result
+= wxString::Format(wxT("bestw=%d;"), pane
.best_size
.x
);
1154 result
+= wxString::Format(wxT("besth=%d;"), pane
.best_size
.y
);
1155 result
+= wxString::Format(wxT("minw=%d;"), pane
.min_size
.x
);
1156 result
+= wxString::Format(wxT("minh=%d;"), pane
.min_size
.y
);
1157 result
+= wxString::Format(wxT("maxw=%d;"), pane
.max_size
.x
);
1158 result
+= wxString::Format(wxT("maxh=%d;"), pane
.max_size
.y
);
1159 result
+= wxString::Format(wxT("floatx=%d;"), pane
.floating_pos
.x
);
1160 result
+= wxString::Format(wxT("floaty=%d;"), pane
.floating_pos
.y
);
1161 result
+= wxString::Format(wxT("floatw=%d;"), pane
.floating_size
.x
);
1162 result
+= wxString::Format(wxT("floath=%d"), pane
.floating_size
.y
);
1167 // Load a "pane" with the pane infor settings in pane_part
1168 void wxAuiManager::LoadPaneInfo(wxString pane_part
, wxAuiPaneInfo
&pane
)
1170 // replace escaped characters so we can
1171 // split up the string easily
1172 pane_part
.Replace(wxT("\\|"), wxT("\a"));
1173 pane_part
.Replace(wxT("\\;"), wxT("\b"));
1177 wxString val_part
= pane_part
.BeforeFirst(wxT(';'));
1178 pane_part
= pane_part
.AfterFirst(wxT(';'));
1179 wxString val_name
= val_part
.BeforeFirst(wxT('='));
1180 wxString value
= val_part
.AfterFirst(wxT('='));
1181 val_name
.MakeLower();
1182 val_name
.Trim(true);
1183 val_name
.Trim(false);
1187 if (val_name
.empty())
1190 if (val_name
== wxT("name"))
1192 else if (val_name
== wxT("caption"))
1193 pane
.caption
= value
;
1194 else if (val_name
== wxT("state"))
1195 pane
.state
= (unsigned int)wxAtoi(value
.c_str());
1196 else if (val_name
== wxT("dir"))
1197 pane
.dock_direction
= wxAtoi(value
.c_str());
1198 else if (val_name
== wxT("layer"))
1199 pane
.dock_layer
= wxAtoi(value
.c_str());
1200 else if (val_name
== wxT("row"))
1201 pane
.dock_row
= wxAtoi(value
.c_str());
1202 else if (val_name
== wxT("pos"))
1203 pane
.dock_pos
= wxAtoi(value
.c_str());
1204 else if (val_name
== wxT("prop"))
1205 pane
.dock_proportion
= wxAtoi(value
.c_str());
1206 else if (val_name
== wxT("bestw"))
1207 pane
.best_size
.x
= wxAtoi(value
.c_str());
1208 else if (val_name
== wxT("besth"))
1209 pane
.best_size
.y
= wxAtoi(value
.c_str());
1210 else if (val_name
== wxT("minw"))
1211 pane
.min_size
.x
= wxAtoi(value
.c_str());
1212 else if (val_name
== wxT("minh"))
1213 pane
.min_size
.y
= wxAtoi(value
.c_str());
1214 else if (val_name
== wxT("maxw"))
1215 pane
.max_size
.x
= wxAtoi(value
.c_str());
1216 else if (val_name
== wxT("maxh"))
1217 pane
.max_size
.y
= wxAtoi(value
.c_str());
1218 else if (val_name
== wxT("floatx"))
1219 pane
.floating_pos
.x
= wxAtoi(value
.c_str());
1220 else if (val_name
== wxT("floaty"))
1221 pane
.floating_pos
.y
= wxAtoi(value
.c_str());
1222 else if (val_name
== wxT("floatw"))
1223 pane
.floating_size
.x
= wxAtoi(value
.c_str());
1224 else if (val_name
== wxT("floath"))
1225 pane
.floating_size
.y
= wxAtoi(value
.c_str());
1227 wxFAIL_MSG(wxT("Bad Perspective String"));
1231 // replace escaped characters so we can
1232 // split up the string easily
1233 pane
.name
.Replace(wxT("\a"), wxT("|"));
1234 pane
.name
.Replace(wxT("\b"), wxT(";"));
1235 pane
.caption
.Replace(wxT("\a"), wxT("|"));
1236 pane
.caption
.Replace(wxT("\b"), wxT(";"));
1237 pane_part
.Replace(wxT("\a"), wxT("|"));
1238 pane_part
.Replace(wxT("\b"), wxT(";"));
1244 // SavePerspective() saves all pane information as a single string.
1245 // This string may later be fed into LoadPerspective() to restore
1246 // all pane settings. This save and load mechanism allows an
1247 // exact pane configuration to be saved and restored at a later time
1249 wxString
wxAuiManager::SavePerspective()
1253 result
= wxT("layout1|");
1255 int pane_i
, pane_count
= m_panes
.GetCount();
1256 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1258 wxAuiPaneInfo
& pane
= m_panes
.Item(pane_i
);
1259 result
+= SavePaneInfo(pane
)+wxT("|");
1262 int dock_i
, dock_count
= m_docks
.GetCount();
1263 for (dock_i
= 0; dock_i
< dock_count
; ++dock_i
)
1265 wxAuiDockInfo
& dock
= m_docks
.Item(dock_i
);
1267 result
+= wxString::Format(wxT("dock_size(%d,%d,%d)=%d|"),
1268 dock
.dock_direction
, dock
.dock_layer
,
1269 dock
.dock_row
, dock
.size
);
1275 // LoadPerspective() loads a layout which was saved with SavePerspective()
1276 // If the "update" flag parameter is true, the GUI will immediately be updated
1278 bool wxAuiManager::LoadPerspective(const wxString
& layout
, bool update
)
1280 wxString input
= layout
;
1283 // check layout string version
1284 part
= input
.BeforeFirst(wxT('|'));
1285 input
= input
.AfterFirst(wxT('|'));
1288 if (part
!= wxT("layout1"))
1291 // mark all panes currently managed as docked and hidden
1292 int pane_i
, pane_count
= m_panes
.GetCount();
1293 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1294 m_panes
.Item(pane_i
).Dock().Hide();
1296 // clear out the dock array; this will be reconstructed
1299 // replace escaped characters so we can
1300 // split up the string easily
1301 input
.Replace(wxT("\\|"), wxT("\a"));
1302 input
.Replace(wxT("\\;"), wxT("\b"));
1308 wxString pane_part
= input
.BeforeFirst(wxT('|'));
1309 input
= input
.AfterFirst(wxT('|'));
1310 pane_part
.Trim(true);
1312 // if the string is empty, we're done parsing
1313 if (pane_part
.empty())
1316 if (pane_part
.Left(9) == wxT("dock_size"))
1318 wxString val_name
= pane_part
.BeforeFirst(wxT('='));
1319 wxString value
= pane_part
.AfterFirst(wxT('='));
1321 long dir
, layer
, row
, size
;
1322 wxString piece
= val_name
.AfterFirst(wxT('('));
1323 piece
= piece
.BeforeLast(wxT(')'));
1324 piece
.BeforeFirst(wxT(',')).ToLong(&dir
);
1325 piece
= piece
.AfterFirst(wxT(','));
1326 piece
.BeforeFirst(wxT(',')).ToLong(&layer
);
1327 piece
.AfterFirst(wxT(',')).ToLong(&row
);
1328 value
.ToLong(&size
);
1331 dock
.dock_direction
= dir
;
1332 dock
.dock_layer
= layer
;
1333 dock
.dock_row
= row
;
1339 // Undo our escaping as LoadPaneInfo needs to take an unescaped
1340 // name so it can be called by external callers
1341 pane_part
.Replace(wxT("\a"), wxT("|"));
1342 pane_part
.Replace(wxT("\b"), wxT(";"));
1344 LoadPaneInfo(pane_part
, pane
);
1346 wxAuiPaneInfo
& p
= GetPane(pane
.name
);
1349 // the pane window couldn't be found
1350 // in the existing layout
1364 void wxAuiManager::GetPanePositionsAndSizes(wxAuiDockInfo
& dock
,
1365 wxArrayInt
& positions
,
1368 int caption_size
= m_art
->GetMetric(wxAUI_ART_CAPTION_SIZE
);
1369 int pane_border_size
= m_art
->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
);
1370 int gripper_size
= m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
1375 int offset
, action_pane
= -1;
1376 int pane_i
, pane_count
= dock
.panes
.GetCount();
1378 // find the pane marked as our action pane
1379 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1381 wxAuiPaneInfo
& pane
= *(dock
.panes
.Item(pane_i
));
1383 if (pane
.state
& wxAuiPaneInfo::actionPane
)
1385 wxASSERT_MSG(action_pane
==-1, wxT("Too many fixed action panes"));
1386 action_pane
= pane_i
;
1390 // set up each panes default position, and
1391 // determine the size (width or height, depending
1392 // on the dock's orientation) of each pane
1393 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1395 wxAuiPaneInfo
& pane
= *(dock
.panes
.Item(pane_i
));
1396 positions
.Add(pane
.dock_pos
);
1399 if (pane
.HasBorder())
1400 size
+= (pane_border_size
*2);
1402 if (dock
.IsHorizontal())
1404 if (pane
.HasGripper() && !pane
.HasGripperTop())
1405 size
+= gripper_size
;
1406 size
+= pane
.best_size
.x
;
1410 if (pane
.HasGripper() && pane
.HasGripperTop())
1411 size
+= gripper_size
;
1413 if (pane
.HasCaption())
1414 size
+= caption_size
;
1415 size
+= pane
.best_size
.y
;
1421 // if there is no action pane, just return the default
1422 // positions (as specified in pane.pane_pos)
1423 if (action_pane
== -1)
1427 for (pane_i
= action_pane
-1; pane_i
>= 0; --pane_i
)
1429 int amount
= positions
[pane_i
+1] - (positions
[pane_i
] + sizes
[pane_i
]);
1434 positions
[pane_i
] -= -amount
;
1436 offset
+= sizes
[pane_i
];
1439 // if the dock mode is fixed, make sure none of the panes
1440 // overlap; we will bump panes that overlap
1442 for (pane_i
= action_pane
; pane_i
< pane_count
; ++pane_i
)
1444 int amount
= positions
[pane_i
] - offset
;
1448 positions
[pane_i
] += -amount
;
1450 offset
+= sizes
[pane_i
];
1455 void wxAuiManager::LayoutAddPane(wxSizer
* cont
,
1456 wxAuiDockInfo
& dock
,
1457 wxAuiPaneInfo
& pane
,
1458 wxAuiDockUIPartArray
& uiparts
,
1461 wxAuiDockUIPart part
;
1462 wxSizerItem
* sizer_item
;
1464 int caption_size
= m_art
->GetMetric(wxAUI_ART_CAPTION_SIZE
);
1465 int gripper_size
= m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
1466 int pane_border_size
= m_art
->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
);
1467 int pane_button_size
= m_art
->GetMetric(wxAUI_ART_PANE_BUTTON_SIZE
);
1469 // find out the orientation of the item (orientation for panes
1470 // is the same as the dock's orientation)
1472 if (dock
.IsHorizontal())
1473 orientation
= wxHORIZONTAL
;
1475 orientation
= wxVERTICAL
;
1477 // this variable will store the proportion
1478 // value that the pane will receive
1479 int pane_proportion
= pane
.dock_proportion
;
1481 wxBoxSizer
* horz_pane_sizer
= new wxBoxSizer(wxHORIZONTAL
);
1482 wxBoxSizer
* vert_pane_sizer
= new wxBoxSizer(wxVERTICAL
);
1484 if (pane
.HasGripper())
1486 if (pane
.HasGripperTop())
1487 sizer_item
= vert_pane_sizer
->Add(1, gripper_size
, 0, wxEXPAND
);
1489 sizer_item
= horz_pane_sizer
->Add(gripper_size
, 1, 0, wxEXPAND
);
1491 part
.type
= wxAuiDockUIPart::typeGripper
;
1495 part
.orientation
= orientation
;
1496 part
.cont_sizer
= horz_pane_sizer
;
1497 part
.sizer_item
= sizer_item
;
1501 if (pane
.HasCaption())
1503 // create the caption sizer
1504 wxBoxSizer
* caption_sizer
= new wxBoxSizer(wxHORIZONTAL
);
1506 sizer_item
= caption_sizer
->Add(1, caption_size
, 1, wxEXPAND
);
1508 part
.type
= wxAuiDockUIPart::typeCaption
;
1512 part
.orientation
= orientation
;
1513 part
.cont_sizer
= vert_pane_sizer
;
1514 part
.sizer_item
= sizer_item
;
1515 int caption_part_idx
= uiparts
.GetCount();
1518 // add pane buttons to the caption
1519 int i
, button_count
;
1520 for (i
= 0, button_count
= pane
.buttons
.GetCount();
1521 i
< button_count
; ++i
)
1523 wxAuiPaneButton
& button
= pane
.buttons
.Item(i
);
1525 sizer_item
= caption_sizer
->Add(pane_button_size
,
1529 part
.type
= wxAuiDockUIPart::typePaneButton
;
1532 part
.button
= &button
;
1533 part
.orientation
= orientation
;
1534 part
.cont_sizer
= caption_sizer
;
1535 part
.sizer_item
= sizer_item
;
1539 // add the caption sizer
1540 sizer_item
= vert_pane_sizer
->Add(caption_sizer
, 0, wxEXPAND
);
1542 uiparts
.Item(caption_part_idx
).sizer_item
= sizer_item
;
1545 // add the pane window itself
1548 sizer_item
= vert_pane_sizer
->Add(1, 1, 1, wxEXPAND
);
1552 sizer_item
= vert_pane_sizer
->Add(pane
.window
, 1, wxEXPAND
);
1553 // Don't do this because it breaks the pane size in floating windows
1554 // BIW: Right now commenting this out is causing problems with
1555 // an mdi client window as the center pane.
1556 vert_pane_sizer
->SetItemMinSize(pane
.window
, 1, 1);
1559 part
.type
= wxAuiDockUIPart::typePane
;
1563 part
.orientation
= orientation
;
1564 part
.cont_sizer
= vert_pane_sizer
;
1565 part
.sizer_item
= sizer_item
;
1569 // determine if the pane should have a minimum size; if the pane is
1570 // non-resizable (fixed) then we must set a minimum size. Alternitavely,
1571 // if the pane.min_size is set, we must use that value as well
1573 wxSize min_size
= pane
.min_size
;
1576 if (min_size
== wxDefaultSize
)
1578 min_size
= pane
.best_size
;
1579 pane_proportion
= 0;
1583 if (min_size
!= wxDefaultSize
)
1585 vert_pane_sizer
->SetItemMinSize(
1586 vert_pane_sizer
->GetChildren().GetCount()-1,
1587 min_size
.x
, min_size
.y
);
1591 // add the verticle sizer (caption, pane window) to the
1592 // horizontal sizer (gripper, verticle sizer)
1593 horz_pane_sizer
->Add(vert_pane_sizer
, 1, wxEXPAND
);
1595 // finally, add the pane sizer to the dock sizer
1597 if (pane
.HasBorder())
1599 // allowing space for the pane's border
1600 sizer_item
= cont
->Add(horz_pane_sizer
, pane_proportion
,
1601 wxEXPAND
| wxALL
, pane_border_size
);
1603 part
.type
= wxAuiDockUIPart::typePaneBorder
;
1607 part
.orientation
= orientation
;
1608 part
.cont_sizer
= cont
;
1609 part
.sizer_item
= sizer_item
;
1614 sizer_item
= cont
->Add(horz_pane_sizer
, pane_proportion
, wxEXPAND
);
1618 void wxAuiManager::LayoutAddDock(wxSizer
* cont
,
1619 wxAuiDockInfo
& dock
,
1620 wxAuiDockUIPartArray
& uiparts
,
1623 wxSizerItem
* sizer_item
;
1624 wxAuiDockUIPart part
;
1626 int sash_size
= m_art
->GetMetric(wxAUI_ART_SASH_SIZE
);
1627 int orientation
= dock
.IsHorizontal() ? wxHORIZONTAL
: wxVERTICAL
;
1629 // resizable bottom and right docks have a sash before them
1630 if (!m_has_maximized
&& !dock
.fixed
&& (dock
.dock_direction
== wxAUI_DOCK_BOTTOM
||
1631 dock
.dock_direction
== wxAUI_DOCK_RIGHT
))
1633 sizer_item
= cont
->Add(sash_size
, sash_size
, 0, wxEXPAND
);
1635 part
.type
= wxAuiDockUIPart::typeDockSizer
;
1636 part
.orientation
= orientation
;
1640 part
.cont_sizer
= cont
;
1641 part
.sizer_item
= sizer_item
;
1645 // create the sizer for the dock
1646 wxSizer
* dock_sizer
= new wxBoxSizer(orientation
);
1648 // add each pane to the dock
1649 bool has_maximized_pane
= false;
1650 int pane_i
, pane_count
= dock
.panes
.GetCount();
1654 wxArrayInt pane_positions
, pane_sizes
;
1656 // figure out the real pane positions we will
1657 // use, without modifying the each pane's pane_pos member
1658 GetPanePositionsAndSizes(dock
, pane_positions
, pane_sizes
);
1661 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1663 wxAuiPaneInfo
& pane
= *(dock
.panes
.Item(pane_i
));
1664 int pane_pos
= pane_positions
.Item(pane_i
);
1665 if(pane
.IsMaximized()) {
1666 has_maximized_pane
= true;
1669 int amount
= pane_pos
- offset
;
1672 if (dock
.IsVertical())
1673 sizer_item
= dock_sizer
->Add(1, amount
, 0, wxEXPAND
);
1675 sizer_item
= dock_sizer
->Add(amount
, 1, 0, wxEXPAND
);
1677 part
.type
= wxAuiDockUIPart::typeBackground
;
1681 part
.orientation
= (orientation
==wxHORIZONTAL
) ? wxVERTICAL
:wxHORIZONTAL
;
1682 part
.cont_sizer
= dock_sizer
;
1683 part
.sizer_item
= sizer_item
;
1689 LayoutAddPane(dock_sizer
, dock
, pane
, uiparts
, spacer_only
);
1691 offset
+= pane_sizes
.Item(pane_i
);
1694 // at the end add a very small stretchable background area
1695 sizer_item
= dock_sizer
->Add(1,1, 1, wxEXPAND
);
1697 part
.type
= wxAuiDockUIPart::typeBackground
;
1701 part
.orientation
= orientation
;
1702 part
.cont_sizer
= dock_sizer
;
1703 part
.sizer_item
= sizer_item
;
1708 for (pane_i
= 0; pane_i
< pane_count
; ++pane_i
)
1710 wxAuiPaneInfo
& pane
= *(dock
.panes
.Item(pane_i
));
1711 if(pane
.IsMaximized()) {
1712 has_maximized_pane
= true;
1715 // if this is not the first pane being added,
1716 // we need to add a pane sizer
1717 if (!m_has_maximized
&& pane_i
> 0)
1719 sizer_item
= dock_sizer
->Add(sash_size
, sash_size
, 0, wxEXPAND
);
1721 part
.type
= wxAuiDockUIPart::typePaneSizer
;
1723 part
.pane
= dock
.panes
.Item(pane_i
-1);
1725 part
.orientation
= (orientation
==wxHORIZONTAL
) ? wxVERTICAL
:wxHORIZONTAL
;
1726 part
.cont_sizer
= dock_sizer
;
1727 part
.sizer_item
= sizer_item
;
1731 LayoutAddPane(dock_sizer
, dock
, pane
, uiparts
, spacer_only
);
1735 if (dock
.dock_direction
== wxAUI_DOCK_CENTER
|| has_maximized_pane
)
1736 sizer_item
= cont
->Add(dock_sizer
, 1, wxEXPAND
);
1738 sizer_item
= cont
->Add(dock_sizer
, 0, wxEXPAND
);
1740 part
.type
= wxAuiDockUIPart::typeDock
;
1744 part
.orientation
= orientation
;
1745 part
.cont_sizer
= cont
;
1746 part
.sizer_item
= sizer_item
;
1749 if (dock
.IsHorizontal())
1750 cont
->SetItemMinSize(dock_sizer
, 0, dock
.size
);
1752 cont
->SetItemMinSize(dock_sizer
, dock
.size
, 0);
1754 // top and left docks have a sash after them
1755 if (!m_has_maximized
&& !dock
.fixed
&& (dock
.dock_direction
== wxAUI_DOCK_TOP
||
1756 dock
.dock_direction
== wxAUI_DOCK_LEFT
))
1758 sizer_item
= cont
->Add(sash_size
, sash_size
, 0, wxEXPAND
);
1760 part
.type
= wxAuiDockUIPart::typeDockSizer
;
1764 part
.orientation
= orientation
;
1765 part
.cont_sizer
= cont
;
1766 part
.sizer_item
= sizer_item
;
1771 wxSizer
* wxAuiManager::LayoutAll(wxAuiPaneInfoArray
& panes
,
1772 wxAuiDockInfoArray
& docks
,
1773 wxAuiDockUIPartArray
& uiparts
,
1776 wxBoxSizer
* container
= new wxBoxSizer(wxVERTICAL
);
1778 int pane_border_size
= m_art
->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
);
1779 int caption_size
= m_art
->GetMetric(wxAUI_ART_CAPTION_SIZE
);
1780 wxSize cli_size
= m_frame
->GetClientSize();
1781 int i
, dock_count
, pane_count
;
1784 // empty all docks out
1785 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
1786 docks
.Item(i
).panes
.Empty();
1789 // iterate through all known panes, filing each
1790 // of them into the appropriate dock. If the
1791 // pane does not exist in the dock, add it
1792 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
1794 wxAuiPaneInfo
& p
= panes
.Item(i
);
1796 // find any docks in this layer
1797 wxAuiDockInfo
* dock
;
1798 wxAuiDockInfoPtrArray arr
;
1799 FindDocks(docks
, p
.dock_direction
, p
.dock_layer
, p
.dock_row
, arr
);
1801 if (arr
.GetCount() > 0)
1807 // dock was not found, so we need to create a new one
1809 d
.dock_direction
= p
.dock_direction
;
1810 d
.dock_layer
= p
.dock_layer
;
1811 d
.dock_row
= p
.dock_row
;
1813 dock
= &docks
.Last();
1817 if (p
.IsDocked() && p
.IsShown())
1819 // remove the pane from any existing docks except this one
1820 RemovePaneFromDocks(docks
, p
, dock
);
1822 // pane needs to be added to the dock,
1823 // if it doesn't already exist
1824 if (!FindPaneInDock(*dock
, p
.window
))
1825 dock
->panes
.Add(&p
);
1829 // remove the pane from any existing docks
1830 RemovePaneFromDocks(docks
, p
);
1835 // remove any empty docks
1836 for (i
= docks
.GetCount()-1; i
>= 0; --i
)
1838 if (docks
.Item(i
).panes
.GetCount() == 0)
1842 // configure the docks further
1843 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
1845 wxAuiDockInfo
& dock
= docks
.Item(i
);
1846 int j
, dock_pane_count
= dock
.panes
.GetCount();
1848 // sort the dock pane array by the pane's
1849 // dock position (dock_pos), in ascending order
1850 dock
.panes
.Sort(PaneSortFunc
);
1852 // for newly created docks, set up their initial size
1857 for (j
= 0; j
< dock_pane_count
; ++j
)
1859 wxAuiPaneInfo
& pane
= *dock
.panes
.Item(j
);
1860 wxSize pane_size
= pane
.best_size
;
1861 if (pane_size
== wxDefaultSize
)
1862 pane_size
= pane
.min_size
;
1863 if (pane_size
== wxDefaultSize
)
1864 pane_size
= pane
.window
->GetSize();
1866 if (dock
.IsHorizontal())
1867 size
= wxMax(pane_size
.y
, size
);
1869 size
= wxMax(pane_size
.x
, size
);
1872 // add space for the border (two times), but only
1873 // if at least one pane inside the dock has a pane border
1874 for (j
= 0; j
< dock_pane_count
; ++j
)
1876 if (dock
.panes
.Item(j
)->HasBorder())
1878 size
+= (pane_border_size
*2);
1883 // if pane is on the top or bottom, add the caption height,
1884 // but only if at least one pane inside the dock has a caption
1885 if (dock
.IsHorizontal())
1887 for (j
= 0; j
< dock_pane_count
; ++j
)
1889 if (dock
.panes
.Item(j
)->HasCaption())
1891 size
+= caption_size
;
1897 // new dock's size may not be more than 1/3 of the frame size
1898 if (dock
.IsHorizontal())
1899 size
= wxMin(size
, cli_size
.y
/3);
1901 size
= wxMin(size
, cli_size
.x
/3);
1909 // determine the dock's minimum size
1910 bool plus_border
= false;
1911 bool plus_caption
= false;
1912 int dock_min_size
= 0;
1913 for (j
= 0; j
< dock_pane_count
; ++j
)
1915 wxAuiPaneInfo
& pane
= *dock
.panes
.Item(j
);
1916 if (pane
.min_size
!= wxDefaultSize
)
1918 if (pane
.HasBorder())
1920 if (pane
.HasCaption())
1921 plus_caption
= true;
1922 if (dock
.IsHorizontal())
1924 if (pane
.min_size
.y
> dock_min_size
)
1925 dock_min_size
= pane
.min_size
.y
;
1929 if (pane
.min_size
.x
> dock_min_size
)
1930 dock_min_size
= pane
.min_size
.x
;
1936 dock_min_size
+= (pane_border_size
*2);
1937 if (plus_caption
&& dock
.IsHorizontal())
1938 dock_min_size
+= (caption_size
);
1940 dock
.min_size
= dock_min_size
;
1943 // if the pane's current size is less than it's
1944 // minimum, increase the dock's size to it's minimum
1945 if (dock
.size
< dock
.min_size
)
1946 dock
.size
= dock
.min_size
;
1949 // determine the dock's mode (fixed or proportional);
1950 // determine whether the dock has only toolbars
1951 bool action_pane_marked
= false;
1953 dock
.toolbar
= true;
1954 for (j
= 0; j
< dock_pane_count
; ++j
)
1956 wxAuiPaneInfo
& pane
= *dock
.panes
.Item(j
);
1957 if (!pane
.IsFixed())
1959 if (!pane
.IsToolbar())
1960 dock
.toolbar
= false;
1961 if (pane
.state
& wxAuiPaneInfo::actionPane
)
1962 action_pane_marked
= true;
1966 // if the dock mode is proportional and not fixed-pixel,
1967 // reassign the dock_pos to the sequential 0, 1, 2, 3;
1968 // e.g. remove gaps like 1, 2, 30, 500
1971 for (j
= 0; j
< dock_pane_count
; ++j
)
1973 wxAuiPaneInfo
& pane
= *dock
.panes
.Item(j
);
1978 // if the dock mode is fixed, and none of the panes
1979 // are being moved right now, make sure the panes
1980 // do not overlap each other. If they do, we will
1981 // adjust the panes' positions
1982 if (dock
.fixed
&& !action_pane_marked
)
1984 wxArrayInt pane_positions
, pane_sizes
;
1985 GetPanePositionsAndSizes(dock
, pane_positions
, pane_sizes
);
1988 for (j
= 0; j
< dock_pane_count
; ++j
)
1990 wxAuiPaneInfo
& pane
= *(dock
.panes
.Item(j
));
1991 pane
.dock_pos
= pane_positions
[j
];
1993 int amount
= pane
.dock_pos
- offset
;
1997 pane
.dock_pos
+= -amount
;
1999 offset
+= pane_sizes
[j
];
2004 // discover the maximum dock layer
2006 for (i
= 0; i
< dock_count
; ++i
)
2007 max_layer
= wxMax(max_layer
, docks
.Item(i
).dock_layer
);
2010 // clear out uiparts
2013 // create a bunch of box sizers,
2014 // from the innermost level outwards.
2015 wxSizer
* cont
= NULL
;
2016 wxSizer
* middle
= NULL
;
2020 for (layer
= 0; layer
<= max_layer
; ++layer
)
2022 wxAuiDockInfoPtrArray arr
;
2024 // find any docks in this layer
2025 FindDocks(docks
, -1, layer
, -1, arr
);
2027 // if there aren't any, skip to the next layer
2031 wxSizer
* old_cont
= cont
;
2033 // create a container which will hold this layer's
2034 // docks (top, bottom, left, right)
2035 cont
= new wxBoxSizer(wxVERTICAL
);
2038 // find any top docks in this layer
2039 FindDocks(docks
, wxAUI_DOCK_TOP
, layer
, -1, arr
);
2040 RenumberDockRows(arr
);
2043 for (row
= 0, row_count
= arr
.GetCount(); row
< row_count
; ++row
)
2044 LayoutAddDock(cont
, *arr
.Item(row
), uiparts
, spacer_only
);
2048 // fill out the middle layer (which consists
2049 // of left docks, content area and right docks)
2051 middle
= new wxBoxSizer(wxHORIZONTAL
);
2053 // find any left docks in this layer
2054 FindDocks(docks
, wxAUI_DOCK_LEFT
, layer
, -1, arr
);
2055 RenumberDockRows(arr
);
2058 for (row
= 0, row_count
= arr
.GetCount(); row
< row_count
; ++row
)
2059 LayoutAddDock(middle
, *arr
.Item(row
), uiparts
, spacer_only
);
2062 // add content dock (or previous layer's sizer
2066 // find any center docks
2067 FindDocks(docks
, wxAUI_DOCK_CENTER
, -1, -1, arr
);
2070 for (row
= 0,row_count
= arr
.GetCount(); row
<row_count
; ++row
)
2071 LayoutAddDock(middle
, *arr
.Item(row
), uiparts
, spacer_only
);
2073 else if (!m_has_maximized
)
2075 // there are no center docks, add a background area
2076 wxSizerItem
* sizer_item
= middle
->Add(1,1, 1, wxEXPAND
);
2077 wxAuiDockUIPart part
;
2078 part
.type
= wxAuiDockUIPart::typeBackground
;
2082 part
.cont_sizer
= middle
;
2083 part
.sizer_item
= sizer_item
;
2089 middle
->Add(old_cont
, 1, wxEXPAND
);
2092 // find any right docks in this layer
2093 FindDocks(docks
, wxAUI_DOCK_RIGHT
, layer
, -1, arr
);
2094 RenumberDockRows(arr
);
2097 for (row
= arr
.GetCount()-1; row
>= 0; --row
)
2098 LayoutAddDock(middle
, *arr
.Item(row
), uiparts
, spacer_only
);
2101 cont
->Add(middle
, 1, wxEXPAND
);
2105 // find any bottom docks in this layer
2106 FindDocks(docks
, wxAUI_DOCK_BOTTOM
, layer
, -1, arr
);
2107 RenumberDockRows(arr
);
2110 for (row
= arr
.GetCount()-1; row
>= 0; --row
)
2111 LayoutAddDock(cont
, *arr
.Item(row
), uiparts
, spacer_only
);
2118 // no sizer available, because there are no docks,
2119 // therefore we will create a simple background area
2120 cont
= new wxBoxSizer(wxVERTICAL
);
2121 wxSizerItem
* sizer_item
= cont
->Add(1,1, 1, wxEXPAND
);
2122 wxAuiDockUIPart part
;
2123 part
.type
= wxAuiDockUIPart::typeBackground
;
2127 part
.cont_sizer
= middle
;
2128 part
.sizer_item
= sizer_item
;
2132 container
->Add(cont
, 1, wxEXPAND
);
2137 // Update() updates the layout. Whenever changes are made to
2138 // one or more panes, this function should be called. It is the
2139 // external entry point for running the layout engine.
2141 void wxAuiManager::Update()
2144 int i
, pane_count
= m_panes
.GetCount();
2146 // delete old sizer first
2147 m_frame
->SetSizer(NULL
);
2149 // destroy floating panes which have been
2150 // redocked or are becoming non-floating
2151 for (i
= 0; i
< pane_count
; ++i
)
2153 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
2155 if (!p
.IsFloating() && p
.frame
)
2157 // because the pane is no longer in a floating, we need to
2158 // reparent it to m_frame and destroy the floating frame
2161 p
.window
->SetSize(1,1);
2164 // the following block is a workaround for bug #1531361
2165 // (see wxWidgets sourceforge page). On wxGTK (only), when
2166 // a frame is shown/hidden, a move event unfortunately
2167 // also gets fired. Because we may be dragging around
2168 // a pane, we need to cancel that action here to prevent
2169 // a spurious crash.
2170 if (m_action_window
== p
.frame
)
2172 if (wxWindow::GetCapture() == m_frame
)
2173 m_frame
->ReleaseMouse();
2174 m_action
= actionNone
;
2175 m_action_window
= NULL
;
2179 if (p
.frame
->IsShown())
2180 p
.frame
->Show(false);
2182 // reparent to m_frame and destroy the pane
2183 if(m_action_window
== p
.frame
)
2185 m_action_window
= NULL
;
2188 p
.window
->Reparent(m_frame
);
2189 p
.frame
->SetSizer(NULL
);
2196 // create a layout for all of the panes
2197 sizer
= LayoutAll(m_panes
, m_docks
, m_uiparts
, false);
2199 // hide or show panes as necessary,
2200 // and float panes as necessary
2201 for (i
= 0; i
< pane_count
; ++i
)
2203 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
2207 if (p
.frame
== NULL
)
2209 // we need to create a frame for this
2210 // pane, which has recently been floated
2211 wxAuiFloatingFrame
* frame
= CreateFloatingFrame(m_frame
, p
);
2213 #if wxCHECK_VERSION(2,7,0)
2214 // on MSW and Mac, if the owner desires transparent dragging, and
2215 // the dragging is happening right now, then the floating
2216 // window should have this style by default
2217 if (m_action
== actionDragFloatingPane
&&
2218 (m_flags
& wxAUI_MGR_TRANSPARENT_DRAG
))
2219 frame
->SetTransparent(150);
2222 frame
->SetPaneWindow(p
);
2225 if (p
.IsShown() && !frame
->IsShown())
2230 // frame already exists, make sure it's position
2231 // and size reflect the information in wxAuiPaneInfo
2232 if (p
.frame
->GetPosition() != p
.floating_pos
)
2234 p
.frame
->SetSize(p
.floating_pos
.x
, p
.floating_pos
.y
,
2235 wxDefaultCoord
, wxDefaultCoord
,
2236 wxSIZE_USE_EXISTING
);
2237 //p.frame->Move(p.floating_pos.x, p.floating_pos.y);
2240 if (p
.frame
->IsShown() != p
.IsShown())
2241 p
.frame
->Show(p
.IsShown());
2246 if (p
.window
->IsShown() != p
.IsShown())
2247 p
.window
->Show(p
.IsShown());
2250 // if "active panes" are no longer allowed, clear
2251 // any optionActive values from the pane states
2252 if ((m_flags
& wxAUI_MGR_ALLOW_ACTIVE_PANE
) == 0)
2254 p
.state
&= ~wxAuiPaneInfo::optionActive
;
2259 // keep track of the old window rectangles so we can
2260 // refresh those windows whose rect has changed
2261 wxAuiRectArray old_pane_rects
;
2262 for (i
= 0; i
< pane_count
; ++i
)
2265 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
2267 if (p
.window
&& p
.IsShown() && p
.IsDocked())
2270 old_pane_rects
.Add(r
);
2276 // apply the new sizer
2277 m_frame
->SetSizer(sizer
);
2278 m_frame
->SetAutoLayout(false);
2283 // now that the frame layout is done, we need to check
2284 // the new pane rectangles against the old rectangles that
2285 // we saved a few lines above here. If the rectangles have
2286 // changed, the corresponding panes must also be updated
2287 for (i
= 0; i
< pane_count
; ++i
)
2289 wxAuiPaneInfo
& p
= m_panes
.Item(i
);
2290 if (p
.window
&& p
.window
->IsShown() && p
.IsDocked())
2292 if (p
.rect
!= old_pane_rects
[i
])
2294 p
.window
->Refresh();
2303 // set frame's minimum size
2306 // N.B. More work needs to be done on frame minimum sizes;
2307 // this is some intresting code that imposes the minimum size,
2308 // but we may want to include a more flexible mechanism or
2309 // options for multiple minimum-size modes, e.g. strict or lax
2310 wxSize min_size = sizer->GetMinSize();
2311 wxSize frame_size = m_frame->GetSize();
2312 wxSize client_size = m_frame->GetClientSize();
2314 wxSize minframe_size(min_size.x+frame_size.x-client_size.x,
2315 min_size.y+frame_size.y-client_size.y );
2317 m_frame->SetMinSize(minframe_size);
2319 if (frame_size.x < minframe_size.x ||
2320 frame_size.y < minframe_size.y)
2321 sizer->Fit(m_frame);
2326 // DoFrameLayout() is an internal function which invokes wxSizer::Layout
2327 // on the frame's main sizer, then measures all the various UI items
2328 // and updates their internal rectangles. This should always be called
2329 // instead of calling m_frame->Layout() directly
2331 void wxAuiManager::DoFrameLayout()
2336 for (i
= 0, part_count
= m_uiparts
.GetCount(); i
< part_count
; ++i
)
2338 wxAuiDockUIPart
& part
= m_uiparts
.Item(i
);
2340 // get the rectangle of the UI part
2341 // originally, this code looked like this:
2342 // part.rect = wxRect(part.sizer_item->GetPosition(),
2343 // part.sizer_item->GetSize());
2344 // this worked quite well, with one exception: the mdi
2345 // client window had a "deferred" size variable
2346 // that returned the wrong size. It looks like
2347 // a bug in wx, because the former size of the window
2348 // was being returned. So, we will retrieve the part's
2349 // rectangle via other means
2352 part
.rect
= part
.sizer_item
->GetRect();
2353 int flag
= part
.sizer_item
->GetFlag();
2354 int border
= part
.sizer_item
->GetBorder();
2357 part
.rect
.y
-= border
;
2358 part
.rect
.height
+= border
;
2362 part
.rect
.x
-= border
;
2363 part
.rect
.width
+= border
;
2365 if (flag
& wxBOTTOM
)
2366 part
.rect
.height
+= border
;
2368 part
.rect
.width
+= border
;
2371 if (part
.type
== wxAuiDockUIPart::typeDock
)
2372 part
.dock
->rect
= part
.rect
;
2373 if (part
.type
== wxAuiDockUIPart::typePane
)
2374 part
.pane
->rect
= part
.rect
;
2378 // GetPanePart() looks up the pane the pane border UI part (or the regular
2379 // pane part if there is no border). This allows the caller to get the exact
2380 // rectangle of the pane in question, including decorations like
2381 // caption and border (if any).
2383 wxAuiDockUIPart
* wxAuiManager::GetPanePart(wxWindow
* wnd
)
2386 for (i
= 0, part_count
= m_uiparts
.GetCount(); i
< part_count
; ++i
)
2388 wxAuiDockUIPart
& part
= m_uiparts
.Item(i
);
2389 if (part
.type
== wxAuiDockUIPart::typePaneBorder
&&
2390 part
.pane
&& part
.pane
->window
== wnd
)
2393 for (i
= 0, part_count
= m_uiparts
.GetCount(); i
< part_count
; ++i
)
2395 wxAuiDockUIPart
& part
= m_uiparts
.Item(i
);
2396 if (part
.type
== wxAuiDockUIPart::typePane
&&
2397 part
.pane
&& part
.pane
->window
== wnd
)
2405 // GetDockPixelOffset() is an internal function which returns
2406 // a dock's offset in pixels from the left side of the window
2407 // (for horizontal docks) or from the top of the window (for
2408 // vertical docks). This value is necessary for calculating
2409 // fixel-pane/toolbar offsets when they are dragged.
2411 int wxAuiManager::GetDockPixelOffset(wxAuiPaneInfo
& test
)
2413 // the only way to accurately calculate the dock's
2414 // offset is to actually run a theoretical layout
2416 int i
, part_count
, dock_count
;
2417 wxAuiDockInfoArray docks
;
2418 wxAuiPaneInfoArray panes
;
2419 wxAuiDockUIPartArray uiparts
;
2420 CopyDocksAndPanes(docks
, panes
, m_docks
, m_panes
);
2423 wxSizer
* sizer
= LayoutAll(panes
, docks
, uiparts
, true);
2424 wxSize client_size
= m_frame
->GetClientSize();
2425 sizer
->SetDimension(0, 0, client_size
.x
, client_size
.y
);
2428 for (i
= 0, part_count
= uiparts
.GetCount(); i
< part_count
; ++i
)
2430 wxAuiDockUIPart
& part
= uiparts
.Item(i
);
2431 part
.rect
= wxRect(part
.sizer_item
->GetPosition(),
2432 part
.sizer_item
->GetSize());
2433 if (part
.type
== wxAuiDockUIPart::typeDock
)
2434 part
.dock
->rect
= part
.rect
;
2439 for (i
= 0, dock_count
= docks
.GetCount(); i
< dock_count
; ++i
)
2441 wxAuiDockInfo
& dock
= docks
.Item(i
);
2442 if (test
.dock_direction
== dock
.dock_direction
&&
2443 test
.dock_layer
==dock
.dock_layer
&& test
.dock_row
==dock
.dock_row
)
2445 if (dock
.IsVertical())
2457 // ProcessDockResult() is a utility function used by DoDrop() - it checks
2458 // if a dock operation is allowed, the new dock position is copied into
2459 // the target info. If the operation was allowed, the function returns true.
2461 bool wxAuiManager::ProcessDockResult(wxAuiPaneInfo
& target
,
2462 const wxAuiPaneInfo
& new_pos
)
2464 bool allowed
= false;
2465 switch (new_pos
.dock_direction
)
2467 case wxAUI_DOCK_TOP
: allowed
= target
.IsTopDockable(); break;
2468 case wxAUI_DOCK_BOTTOM
: allowed
= target
.IsBottomDockable(); break;
2469 case wxAUI_DOCK_LEFT
: allowed
= target
.IsLeftDockable(); break;
2470 case wxAUI_DOCK_RIGHT
: allowed
= target
.IsRightDockable(); break;
2480 // DoDrop() is an important function. It basically takes a mouse position,
2481 // and determines where the pane's new position would be. If the pane is to be
2482 // dropped, it performs the drop operation using the specified dock and pane
2483 // arrays. By specifying copied dock and pane arrays when calling, a "what-if"
2484 // scenario can be performed, giving precise coordinates for drop hints.
2485 // If, however, wxAuiManager:m_docks and wxAuiManager::m_panes are specified
2486 // as parameters, the changes will be made to the main state arrays
2488 const int auiInsertRowPixels
= 10;
2489 const int auiNewRowPixels
= 40;
2490 const int auiLayerInsertPixels
= 40;
2491 const int auiLayerInsertOffset
= 5;
2493 bool wxAuiManager::DoDrop(wxAuiDockInfoArray
& docks
,
2494 wxAuiPaneInfoArray
& panes
,
2495 wxAuiPaneInfo
& target
,
2497 const wxPoint
& offset
)
2499 wxSize cli_size
= m_frame
->GetClientSize();
2501 wxAuiPaneInfo drop
= target
;
2504 // The result should always be shown
2508 // Check to see if the pane has been dragged outside of the window
2509 // (or near to the outside of the window), if so, dock it along the edge
2512 int layer_insert_offset
= auiLayerInsertOffset
;
2513 if (target
.IsToolbar())
2514 layer_insert_offset
= 0;
2516 if (pt
.x
< layer_insert_offset
&&
2517 pt
.x
> layer_insert_offset
-auiLayerInsertPixels
)
2521 Position(pt
.y
- GetDockPixelOffset(drop
) - offset
.y
);
2522 return ProcessDockResult(target
, drop
);
2524 else if (pt
.y
< layer_insert_offset
&&
2525 pt
.y
> layer_insert_offset
-auiLayerInsertPixels
)
2529 Position(pt
.x
- GetDockPixelOffset(drop
) - offset
.x
);
2530 return ProcessDockResult(target
, drop
);
2532 else if (pt
.x
>= cli_size
.x
- layer_insert_offset
&&
2533 pt
.x
< cli_size
.x
- layer_insert_offset
+ auiLayerInsertPixels
)
2535 drop
.Dock().Right().
2537 Position(pt
.y
- GetDockPixelOffset(drop
) - offset
.y
);
2538 return ProcessDockResult(target
, drop
);
2540 else if (pt
.y
>= cli_size
.y
- layer_insert_offset
&&
2541 pt
.y
< cli_size
.y
- layer_insert_offset
+ auiLayerInsertPixels
)
2543 int new_layer
= wxMax( wxMax( GetMaxLayer(docks
, wxAUI_DOCK_BOTTOM
),
2544 GetMaxLayer(docks
, wxAUI_DOCK_LEFT
)),
2545 GetMaxLayer(docks
, wxAUI_DOCK_RIGHT
)) + 1;
2547 drop
.Dock().Bottom().
2550 Position(pt
.x
- GetDockPixelOffset(drop
) - offset
.x
);
2551 return ProcessDockResult(target
, drop
);
2554 wxAuiDockUIPart
* part
= HitTest(pt
.x
, pt
.y
);
2557 if (drop
.IsToolbar())
2559 if (!part
|| !part
->dock
)
2562 // calculate the offset from where the dock begins
2563 // to the point where the user dropped the pane
2564 int dock_drop_offset
= 0;
2565 if (part
->dock
->IsHorizontal())
2566 dock_drop_offset
= pt
.x
- part
->dock
->rect
.x
- offset
.x
;
2568 dock_drop_offset
= pt
.y
- part
->dock
->rect
.y
- offset
.y
;
2571 // toolbars may only be moved in and to fixed-pane docks,
2572 // otherwise we will try to float the pane. Also, the pane
2573 // should float if being dragged over center pane windows
2574 if (!part
->dock
->fixed
|| part
->dock
->dock_direction
== wxAUI_DOCK_CENTER
)
2576 if (m_last_rect
.IsEmpty() || m_last_rect
.Contains(pt
.x
, pt
.y
))
2582 if ((m_flags
& wxAUI_MGR_ALLOW_FLOATING
) &&
2583 (drop
.IsFloatable() ||
2584 (part
->dock
->dock_direction
!= wxAUI_DOCK_CENTER
&&
2585 part
->dock
->dock_direction
!= wxAUI_DOCK_NONE
)))
2592 return ProcessDockResult(target
, drop
);
2595 drop
.Position(pt
.x
- GetDockPixelOffset(drop
) - offset
.x
);
2597 return ProcessDockResult(target
, drop
);
2606 m_last_rect
= part
->dock
->rect
;
2607 m_last_rect
.Inflate( 15, 15 );
2611 Direction(part
->dock
->dock_direction
).
2612 Layer(part
->dock
->dock_layer
).
2613 Row(part
->dock
->dock_row
).
2614 Position(dock_drop_offset
);
2617 ((pt
.y
< part
->dock
->rect
.y
+ 1) && part
->dock
->IsHorizontal()) ||
2618 ((pt
.x
< part
->dock
->rect
.x
+ 1) && part
->dock
->IsVertical())
2619 ) && part
->dock
->panes
.GetCount() > 1)
2621 if ((part
->dock
->dock_direction
== wxAUI_DOCK_TOP
) ||
2622 (part
->dock
->dock_direction
== wxAUI_DOCK_LEFT
))
2624 int row
= drop
.dock_row
;
2625 DoInsertDockRow(panes
, part
->dock
->dock_direction
,
2626 part
->dock
->dock_layer
,
2627 part
->dock
->dock_row
);
2628 drop
.dock_row
= row
;
2632 DoInsertDockRow(panes
, part
->dock
->dock_direction
,
2633 part
->dock
->dock_layer
,
2634 part
->dock
->dock_row
+1);
2635 drop
.dock_row
= part
->dock
->dock_row
+1;
2640 ((pt
.y
> part
->dock
->rect
.y
+ part
->dock
->rect
.height
- 2 ) && part
->dock
->IsHorizontal()) ||
2641 ((pt
.x
> part
->dock
->rect
.x
+ part
->dock
->rect
.width
- 2 ) && part
->dock
->IsVertical())
2642 ) && part
->dock
->panes
.GetCount() > 1)
2644 if ((part
->dock
->dock_direction
== wxAUI_DOCK_TOP
) ||
2645 (part
->dock
->dock_direction
== wxAUI_DOCK_LEFT
))
2647 DoInsertDockRow(panes
, part
->dock
->dock_direction
,
2648 part
->dock
->dock_layer
,
2649 part
->dock
->dock_row
+1);
2650 drop
.dock_row
= part
->dock
->dock_row
+1;
2654 int row
= drop
.dock_row
;
2655 DoInsertDockRow(panes
, part
->dock
->dock_direction
,
2656 part
->dock
->dock_layer
,
2657 part
->dock
->dock_row
);
2658 drop
.dock_row
= row
;
2662 return ProcessDockResult(target
, drop
);
2671 if (part
->type
== wxAuiDockUIPart::typePaneBorder
||
2672 part
->type
== wxAuiDockUIPart::typeCaption
||
2673 part
->type
== wxAuiDockUIPart::typeGripper
||
2674 part
->type
== wxAuiDockUIPart::typePaneButton
||
2675 part
->type
== wxAuiDockUIPart::typePane
||
2676 part
->type
== wxAuiDockUIPart::typePaneSizer
||
2677 part
->type
== wxAuiDockUIPart::typeDockSizer
||
2678 part
->type
== wxAuiDockUIPart::typeBackground
)
2680 if (part
->type
== wxAuiDockUIPart::typeDockSizer
)
2682 if (part
->dock
->panes
.GetCount() != 1)
2684 part
= GetPanePart(part
->dock
->panes
.Item(0)->window
);
2691 // If a normal frame is being dragged over a toolbar, insert it
2692 // along the edge under the toolbar, but over all other panes.
2693 // (this could be done much better, but somehow factoring this
2694 // calculation with the one at the beginning of this function)
2695 if (part
->dock
&& part
->dock
->toolbar
)
2699 switch (part
->dock
->dock_direction
)
2701 case wxAUI_DOCK_LEFT
:
2702 layer
= wxMax(wxMax(GetMaxLayer(docks
, wxAUI_DOCK_LEFT
),
2703 GetMaxLayer(docks
, wxAUI_DOCK_BOTTOM
)),
2704 GetMaxLayer(docks
, wxAUI_DOCK_TOP
));
2706 case wxAUI_DOCK_TOP
:
2707 layer
= wxMax(wxMax(GetMaxLayer(docks
, wxAUI_DOCK_TOP
),
2708 GetMaxLayer(docks
, wxAUI_DOCK_LEFT
)),
2709 GetMaxLayer(docks
, wxAUI_DOCK_RIGHT
));
2711 case wxAUI_DOCK_RIGHT
:
2712 layer
= wxMax(wxMax(GetMaxLayer(docks
, wxAUI_DOCK_RIGHT
),
2713 GetMaxLayer(docks
, wxAUI_DOCK_TOP
)),
2714 GetMaxLayer(docks
, wxAUI_DOCK_BOTTOM
));
2716 case wxAUI_DOCK_BOTTOM
:
2717 layer
= wxMax(wxMax(GetMaxLayer(docks
, wxAUI_DOCK_BOTTOM
),
2718 GetMaxLayer(docks
, wxAUI_DOCK_LEFT
)),
2719 GetMaxLayer(docks
, wxAUI_DOCK_RIGHT
));
2723 DoInsertDockRow(panes
, part
->dock
->dock_direction
,
2726 Direction(part
->dock
->dock_direction
).
2727 Layer(layer
).Row(0).Position(0);
2728 return ProcessDockResult(target
, drop
);
2735 part
= GetPanePart(part
->pane
->window
);
2739 bool insert_dock_row
= false;
2740 int insert_row
= part
->pane
->dock_row
;
2741 int insert_dir
= part
->pane
->dock_direction
;
2742 int insert_layer
= part
->pane
->dock_layer
;
2744 switch (part
->pane
->dock_direction
)
2746 case wxAUI_DOCK_TOP
:
2747 if (pt
.y
>= part
->rect
.y
&&
2748 pt
.y
< part
->rect
.y
+auiInsertRowPixels
)
2749 insert_dock_row
= true;
2751 case wxAUI_DOCK_BOTTOM
:
2752 if (pt
.y
> part
->rect
.y
+part
->rect
.height
-auiInsertRowPixels
&&
2753 pt
.y
<= part
->rect
.y
+ part
->rect
.height
)
2754 insert_dock_row
= true;
2756 case wxAUI_DOCK_LEFT
:
2757 if (pt
.x
>= part
->rect
.x
&&
2758 pt
.x
< part
->rect
.x
+auiInsertRowPixels
)
2759 insert_dock_row
= true;
2761 case wxAUI_DOCK_RIGHT
:
2762 if (pt
.x
> part
->rect
.x
+part
->rect
.width
-auiInsertRowPixels
&&
2763 pt
.x
<= part
->rect
.x
+part
->rect
.width
)
2764 insert_dock_row
= true;
2766 case wxAUI_DOCK_CENTER
:
2768 // "new row pixels" will be set to the default, but
2769 // must never exceed 20% of the window size
2770 int new_row_pixels_x
= auiNewRowPixels
;
2771 int new_row_pixels_y
= auiNewRowPixels
;
2773 if (new_row_pixels_x
> (part
->rect
.width
*20)/100)
2774 new_row_pixels_x
= (part
->rect
.width
*20)/100;
2776 if (new_row_pixels_y
> (part
->rect
.height
*20)/100)
2777 new_row_pixels_y
= (part
->rect
.height
*20)/100;
2780 // determine if the mouse pointer is in a location that
2781 // will cause a new row to be inserted. The hot spot positions
2782 // are along the borders of the center pane
2785 insert_dock_row
= true;
2786 if (pt
.x
>= part
->rect
.x
&&
2787 pt
.x
< part
->rect
.x
+new_row_pixels_x
)
2788 insert_dir
= wxAUI_DOCK_LEFT
;
2790 if (pt
.y
>= part
->rect
.y
&&
2791 pt
.y
< part
->rect
.y
+new_row_pixels_y
)
2792 insert_dir
= wxAUI_DOCK_TOP
;
2794 if (pt
.x
>= part
->rect
.x
+ part
->rect
.width
-new_row_pixels_x
&&
2795 pt
.x
< part
->rect
.x
+ part
->rect
.width
)
2796 insert_dir
= wxAUI_DOCK_RIGHT
;
2798 if (pt
.y
>= part
->rect
.y
+ part
->rect
.height
-new_row_pixels_y
&&
2799 pt
.y
< part
->rect
.y
+ part
->rect
.height
)
2800 insert_dir
= wxAUI_DOCK_BOTTOM
;
2804 insert_row
= GetMaxRow(panes
, insert_dir
, insert_layer
) + 1;
2808 if (insert_dock_row
)
2810 DoInsertDockRow(panes
, insert_dir
, insert_layer
, insert_row
);
2811 drop
.Dock().Direction(insert_dir
).
2812 Layer(insert_layer
).
2815 return ProcessDockResult(target
, drop
);
2818 // determine the mouse offset and the pane size, both in the
2819 // direction of the dock itself, and perpendicular to the dock
2823 if (part
->orientation
== wxVERTICAL
)
2825 offset
= pt
.y
- part
->rect
.y
;
2826 size
= part
->rect
.GetHeight();
2830 offset
= pt
.x
- part
->rect
.x
;
2831 size
= part
->rect
.GetWidth();
2834 int drop_position
= part
->pane
->dock_pos
;
2836 // if we are in the top/left part of the pane,
2837 // insert the pane before the pane being hovered over
2838 if (offset
<= size
/2)
2840 drop_position
= part
->pane
->dock_pos
;
2842 part
->pane
->dock_direction
,
2843 part
->pane
->dock_layer
,
2844 part
->pane
->dock_row
,
2845 part
->pane
->dock_pos
);
2848 // if we are in the bottom/right part of the pane,
2849 // insert the pane before the pane being hovered over
2850 if (offset
> size
/2)
2852 drop_position
= part
->pane
->dock_pos
+1;
2854 part
->pane
->dock_direction
,
2855 part
->pane
->dock_layer
,
2856 part
->pane
->dock_row
,
2857 part
->pane
->dock_pos
+1);
2861 Direction(part
->dock
->dock_direction
).
2862 Layer(part
->dock
->dock_layer
).
2863 Row(part
->dock
->dock_row
).
2864 Position(drop_position
);
2865 return ProcessDockResult(target
, drop
);
2872 void wxAuiManager::OnHintFadeTimer(wxTimerEvent
& WXUNUSED(event
))
2874 if (!m_hint_wnd
|| m_hint_fadeamt
>= m_hint_fademax
)
2876 m_hint_fadetimer
.Stop();
2880 m_hint_fadeamt
+= 4;
2881 #if wxCHECK_VERSION(2,7,0)
2882 m_hint_wnd
->SetTransparent(m_hint_fadeamt
);
2884 if (m_hint_wnd
->IsKindOf(CLASSINFO(wxPseudoTransparentFrame
)))
2885 ((wxPseudoTransparentFrame
*)m_hint_wnd
)->SetTransparent(m_hint_fadeamt
);
2889 void wxAuiManager::ShowHint(const wxRect
& rect
)
2893 // if the hint rect is the same as last time, don't do anything
2894 if (m_last_hint
== rect
)
2898 m_hint_fadeamt
= m_hint_fademax
;
2900 if ((m_flags
& wxAUI_MGR_HINT_FADE
)
2901 && !((m_hint_wnd
->IsKindOf(CLASSINFO(wxPseudoTransparentFrame
))) &&
2902 (m_flags
& wxAUI_MGR_NO_VENETIAN_BLINDS_FADE
))
2906 m_hint_wnd
->SetSize(rect
);
2908 if (!m_hint_wnd
->IsShown())
2911 // if we are dragging a floating pane, set the focus
2912 // back to that floating pane (otherwise it becomes unfocused)
2913 if (m_action
== actionDragFloatingPane
&& m_action_window
)
2914 m_action_window
->SetFocus();
2916 #if wxCHECK_VERSION(2,7,0)
2917 m_hint_wnd
->SetTransparent(m_hint_fadeamt
);
2919 if (m_hint_wnd
->IsKindOf(CLASSINFO(wxPseudoTransparentFrame
)))
2920 ((wxPseudoTransparentFrame
*)m_hint_wnd
)->SetTransparent(m_hint_fadeamt
);
2922 m_hint_wnd
->Raise();
2925 if (m_hint_fadeamt
!= m_hint_fademax
) // Only fade if we need to
2927 // start fade in timer
2928 m_hint_fadetimer
.SetOwner(this, 101);
2929 m_hint_fadetimer
.Start(5);
2932 else // Not using a transparent hint window...
2934 if (!(m_flags
& wxAUI_MGR_RECTANGLE_HINT
))
2937 if (m_last_hint
!= rect
)
2939 // remove the last hint rectangle
2945 wxScreenDC screendc
;
2946 wxRegion
clip(1, 1, 10000, 10000);
2948 // clip all floating windows, so we don't draw over them
2950 for (i
= 0, pane_count
= m_panes
.GetCount(); i
< pane_count
; ++i
)
2952 wxAuiPaneInfo
& pane
= m_panes
.Item(i
);
2954 if (pane
.IsFloating() &&
2955 pane
.frame
->IsShown())
2957 wxRect rect
= pane
.frame
->GetRect();
2959 // wxGTK returns the client size, not the whole frame size
2965 clip
.Subtract(rect
);
2969 // As we can only hide the hint by redrawing the managed window, we
2970 // need to clip the region to the managed window too or we get
2971 // nasty redrawn problems.
2972 clip
.Intersect(m_frame
->GetRect());
2974 screendc
.SetClippingRegion(clip
);
2976 wxBitmap stipple
= wxPaneCreateStippleBitmap();
2977 wxBrush
brush(stipple
);
2978 screendc
.SetBrush(brush
);
2979 screendc
.SetPen(*wxTRANSPARENT_PEN
);
2981 screendc
.DrawRectangle(rect
.x
, rect
.y
, 5, rect
.height
);
2982 screendc
.DrawRectangle(rect
.x
+5, rect
.y
, rect
.width
-10, 5);
2983 screendc
.DrawRectangle(rect
.x
+rect
.width
-5, rect
.y
, 5, rect
.height
);
2984 screendc
.DrawRectangle(rect
.x
+5, rect
.y
+rect
.height
-5, rect
.width
-10, 5);
2988 void wxAuiManager::HideHint()
2990 // hides a transparent window hint, if there is one
2993 if (m_hint_wnd
->IsShown())
2994 m_hint_wnd
->Show(false);
2995 #if wxCHECK_VERSION(2,7,0)
2996 m_hint_wnd
->SetTransparent(0);
2998 if (m_hint_wnd
->IsKindOf(CLASSINFO(wxPseudoTransparentFrame
)))
2999 ((wxPseudoTransparentFrame
*)m_hint_wnd
)->SetTransparent(0);
3001 m_hint_fadetimer
.Stop();
3002 m_last_hint
= wxRect();
3006 // hides a painted hint by redrawing the frame window
3007 if (!m_last_hint
.IsEmpty())
3011 m_last_hint
= wxRect();
3017 // DrawHintRect() draws a drop hint rectangle. First calls DoDrop() to
3018 // determine the exact position the pane would be at were if dropped. If
3019 // the pame would indeed become docked at the specified drop point,
3020 // DrawHintRect() then calls ShowHint() to indicate this drop rectangle.
3021 // "pane_window" is the window pointer of the pane being dragged, pt is
3022 // the mouse position, in client coordinates
3023 void wxAuiManager::DrawHintRect(wxWindow
* pane_window
,
3025 const wxPoint
& offset
)
3029 // we need to paint a hint rectangle; to find out the exact hint rectangle,
3030 // we will create a new temporary layout and then measure the resulting
3031 // rectangle; we will create a copy of the docking structures (m_dock)
3032 // so that we don't modify the real thing on screen
3034 int i
, pane_count
, part_count
;
3035 wxAuiDockInfoArray docks
;
3036 wxAuiPaneInfoArray panes
;
3037 wxAuiDockUIPartArray uiparts
;
3038 wxAuiPaneInfo hint
= GetPane(pane_window
);
3039 hint
.name
= wxT("__HINT__");
3045 CopyDocksAndPanes(docks
, panes
, m_docks
, m_panes
);
3047 // remove any pane already there which bears the same window;
3048 // this happens when you are moving a pane around in a dock
3049 for (i
= 0, pane_count
= panes
.GetCount(); i
< pane_count
; ++i
)
3051 if (panes
.Item(i
).window
== pane_window
)
3053 RemovePaneFromDocks(docks
, panes
.Item(i
));
3059 // find out where the new pane would be
3060 if (!DoDrop(docks
, panes
, hint
, pt
, offset
))
3068 wxSizer
* sizer
= LayoutAll(panes
, docks
, uiparts
, true);
3069 wxSize client_size
= m_frame
->GetClientSize();
3070 sizer
->SetDimension(0, 0, client_size
.x
, client_size
.y
);
3073 for (i
= 0, part_count
= uiparts
.GetCount();
3074 i
< part_count
; ++i
)
3076 wxAuiDockUIPart
& part
= uiparts
.Item(i
);
3078 if (part
.type
== wxAuiDockUIPart::typePaneBorder
&&
3079 part
.pane
&& part
.pane
->name
== wxT("__HINT__"))
3081 rect
= wxRect(part
.sizer_item
->GetPosition(),
3082 part
.sizer_item
->GetSize());
3095 // actually show the hint rectangle on the screen
3096 m_frame
->ClientToScreen(&rect
.x
, &rect
.y
);
3100 void wxAuiManager::OnFloatingPaneMoveStart(wxWindow
* wnd
)
3102 // try to find the pane
3103 wxAuiPaneInfo
& pane
= GetPane(wnd
);
3104 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3106 #if wxCHECK_VERSION(2,7,0)
3107 if (m_flags
& wxAUI_MGR_TRANSPARENT_DRAG
)
3108 pane
.frame
->SetTransparent(150);
3112 void wxAuiManager::OnFloatingPaneMoving(wxWindow
* wnd
, wxDirection dir
)
3114 // try to find the pane
3115 wxAuiPaneInfo
& pane
= GetPane(wnd
);
3116 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3118 wxPoint pt
= ::wxGetMousePosition();
3121 // Adapt pt to direction
3124 // move to pane's upper border
3126 pos
= wnd
->ClientToScreen( pos
);
3128 // and some more pixels for the title bar
3133 // move to pane's left border
3135 pos
= wnd
->ClientToScreen( pos
);
3140 // move to pane's right border
3141 wxPoint
pos( wnd
->GetSize().x
, 0 );
3142 pos
= wnd
->ClientToScreen( pos
);
3147 // move to pane's bottom border
3148 wxPoint
pos( 0, wnd
->GetSize().y
);
3149 pos
= wnd
->ClientToScreen( pos
);
3156 wxPoint client_pt
= m_frame
->ScreenToClient(pt
);
3158 // calculate the offset from the upper left-hand corner
3159 // of the frame to the mouse pointer
3160 wxPoint frame_pos
= pane
.frame
->GetPosition();
3161 wxPoint
action_offset(pt
.x
-frame_pos
.x
, pt
.y
-frame_pos
.y
);
3163 // no hint for toolbar floating windows
3164 if (pane
.IsToolbar() && m_action
== actionDragFloatingPane
)
3166 if (m_action
== actionDragFloatingPane
)
3168 wxAuiDockInfoArray docks
;
3169 wxAuiPaneInfoArray panes
;
3170 wxAuiDockUIPartArray uiparts
;
3171 wxAuiPaneInfo hint
= pane
;
3173 CopyDocksAndPanes(docks
, panes
, m_docks
, m_panes
);
3175 // find out where the new pane would be
3176 if (!DoDrop(docks
, panes
, hint
, client_pt
))
3178 if (hint
.IsFloating())
3182 m_action
= actionDragToolbarPane
;
3183 m_action_window
= pane
.window
;
3192 // if a key modifier is pressed while dragging the frame,
3193 // don't dock the window
3194 if (wxGetKeyState(WXK_CONTROL
) || wxGetKeyState(WXK_ALT
))
3201 DrawHintRect(wnd
, client_pt
, action_offset
);
3204 // this cleans up some screen artifacts that are caused on GTK because
3205 // we aren't getting the exact size of the window (see comment
3215 void wxAuiManager::OnFloatingPaneMoved(wxWindow
* wnd
, wxDirection dir
)
3217 // try to find the pane
3218 wxAuiPaneInfo
& pane
= GetPane(wnd
);
3219 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3221 wxPoint pt
= ::wxGetMousePosition();
3224 // Adapt pt to direction
3227 // move to pane's upper border
3229 pos
= wnd
->ClientToScreen( pos
);
3231 // and some more pixels for the title bar
3236 // move to pane's left border
3238 pos
= wnd
->ClientToScreen( pos
);
3243 // move to pane's right border
3244 wxPoint
pos( wnd
->GetSize().x
, 0 );
3245 pos
= wnd
->ClientToScreen( pos
);
3250 // move to pane's bottom border
3251 wxPoint
pos( 0, wnd
->GetSize().y
);
3252 pos
= wnd
->ClientToScreen( pos
);
3259 wxPoint client_pt
= m_frame
->ScreenToClient(pt
);
3261 // calculate the offset from the upper left-hand corner
3262 // of the frame to the mouse pointer
3263 wxPoint frame_pos
= pane
.frame
->GetPosition();
3264 wxPoint
action_offset(pt
.x
-frame_pos
.x
, pt
.y
-frame_pos
.y
);
3267 // if a key modifier is pressed while dragging the frame,
3268 // don't dock the window
3269 if (!wxGetKeyState(WXK_CONTROL
) && !wxGetKeyState(WXK_ALT
))
3271 // do the drop calculation
3272 DoDrop(m_docks
, m_panes
, pane
, client_pt
, action_offset
);
3275 // if the pane is still floating, update it's floating
3276 // position (that we store)
3277 if (pane
.IsFloating())
3279 pane
.floating_pos
= pane
.frame
->GetPosition();
3281 #if wxCHECK_VERSION(2,7,0)
3282 if (m_flags
& wxAUI_MGR_TRANSPARENT_DRAG
)
3283 pane
.frame
->SetTransparent(255);
3285 } else if(m_has_maximized
) {
3286 RestoreMaximizedPane();
3294 void wxAuiManager::OnFloatingPaneResized(wxWindow
* wnd
, const wxSize
& size
)
3296 // try to find the pane
3297 wxAuiPaneInfo
& pane
= GetPane(wnd
);
3298 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3300 pane
.floating_size
= size
;
3304 void wxAuiManager::OnFloatingPaneClosed(wxWindow
* wnd
, wxCloseEvent
& evt
)
3306 // try to find the pane
3307 wxAuiPaneInfo
& pane
= GetPane(wnd
);
3308 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3311 // fire pane close event
3312 wxAuiManagerEvent
e(wxEVT_AUI_PANECLOSE
);
3314 e
.SetCanVeto(evt
.CanVeto());
3330 void wxAuiManager::OnFloatingPaneActivated(wxWindow
* wnd
)
3332 if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE
)
3334 // try to find the pane
3335 wxASSERT_MSG(GetPane(wnd
).IsOk(), wxT("Pane window not found"));
3337 SetActivePane(m_panes
, wnd
);
3342 // OnRender() draws all of the pane captions, sashes,
3343 // backgrounds, captions, grippers, pane borders and buttons.
3344 // It renders the entire user interface.
3346 void wxAuiManager::OnRender(wxAuiManagerEvent
& evt
)
3348 wxDC
* dc
= evt
.GetDC();
3354 for (i
= 0, part_count
= m_uiparts
.GetCount();
3355 i
< part_count
; ++i
)
3357 wxAuiDockUIPart
& part
= m_uiparts
.Item(i
);
3359 // don't draw hidden pane items
3360 if (part
.sizer_item
&& !part
.sizer_item
->IsShown())
3365 case wxAuiDockUIPart::typeDockSizer
:
3366 case wxAuiDockUIPart::typePaneSizer
:
3367 m_art
->DrawSash(*dc
, m_frame
, part
.orientation
, part
.rect
);
3369 case wxAuiDockUIPart::typeBackground
:
3370 m_art
->DrawBackground(*dc
, m_frame
, part
.orientation
, part
.rect
);
3372 case wxAuiDockUIPart::typeCaption
:
3373 m_art
->DrawCaption(*dc
, m_frame
, part
.pane
->caption
, part
.rect
, *part
.pane
);
3375 case wxAuiDockUIPart::typeGripper
:
3376 m_art
->DrawGripper(*dc
, m_frame
, part
.rect
, *part
.pane
);
3378 case wxAuiDockUIPart::typePaneBorder
:
3379 m_art
->DrawBorder(*dc
, m_frame
, part
.rect
, *part
.pane
);
3381 case wxAuiDockUIPart::typePaneButton
:
3382 m_art
->DrawPaneButton(*dc
, m_frame
, part
.button
->button_id
,
3383 wxAUI_BUTTON_STATE_NORMAL
, part
.rect
, *part
.pane
);
3390 // Render() fire a render event, which is normally handled by
3391 // wxAuiManager::OnRender(). This allows the render function to
3392 // be overridden via the render event. This can be useful for paintin
3393 // custom graphics in the main window. Default behavior can be
3394 // invoked in the overridden function by calling OnRender()
3396 void wxAuiManager::Render(wxDC
* dc
)
3398 wxAuiManagerEvent
e(wxEVT_AUI_RENDER
);
3403 void wxAuiManager::Repaint(wxDC
* dc
)
3408 m_frame
->Refresh() ;
3414 m_frame
->GetClientSize(&w
, &h
);
3416 // figure out which dc to use; if one
3417 // has been specified, use it, otherwise
3419 wxClientDC
* client_dc
= NULL
;
3422 client_dc
= new wxClientDC(m_frame
);
3426 // if the frame has a toolbar, the client area
3427 // origin will not be (0,0).
3428 wxPoint pt
= m_frame
->GetClientAreaOrigin();
3429 if (pt
.x
!= 0 || pt
.y
!= 0)
3430 dc
->SetDeviceOrigin(pt
.x
, pt
.y
);
3432 // render all the items
3435 // if we created a client_dc, delete it
3440 void wxAuiManager::OnPaint(wxPaintEvent
& WXUNUSED(event
))
3442 wxPaintDC
dc(m_frame
);
3446 void wxAuiManager::OnEraseBackground(wxEraseEvent
& event
)
3455 void wxAuiManager::OnSize(wxSizeEvent
& event
)
3466 void wxAuiManager::OnSetCursor(wxSetCursorEvent
& event
)
3469 wxAuiDockUIPart
* part
= HitTest(event
.GetX(), event
.GetY());
3470 wxCursor cursor
= wxNullCursor
;
3474 if (part
->type
== wxAuiDockUIPart::typeDockSizer
||
3475 part
->type
== wxAuiDockUIPart::typePaneSizer
)
3477 // a dock may not be resized if it has a single
3478 // pane which is not resizable
3479 if (part
->type
== wxAuiDockUIPart::typeDockSizer
&& part
->dock
&&
3480 part
->dock
->panes
.GetCount() == 1 &&
3481 part
->dock
->panes
.Item(0)->IsFixed())
3484 // panes that may not be resized do not get a sizing cursor
3485 if (part
->pane
&& part
->pane
->IsFixed())
3488 if (part
->orientation
== wxVERTICAL
)
3489 cursor
= wxCursor(wxCURSOR_SIZEWE
);
3491 cursor
= wxCursor(wxCURSOR_SIZENS
);
3493 else if (part
->type
== wxAuiDockUIPart::typeGripper
)
3495 cursor
= wxCursor(wxCURSOR_SIZING
);
3499 event
.SetCursor(cursor
);
3504 void wxAuiManager::UpdateButtonOnScreen(wxAuiDockUIPart
* button_ui_part
,
3505 const wxMouseEvent
& event
)
3507 wxAuiDockUIPart
* hit_test
= HitTest(event
.GetX(), event
.GetY());
3509 int state
= wxAUI_BUTTON_STATE_NORMAL
;
3511 if (hit_test
== button_ui_part
)
3513 if (event
.LeftDown())
3514 state
= wxAUI_BUTTON_STATE_PRESSED
;
3516 state
= wxAUI_BUTTON_STATE_HOVER
;
3520 if (event
.LeftDown())
3521 state
= wxAUI_BUTTON_STATE_HOVER
;
3524 // now repaint the button with hover state
3525 wxClientDC
cdc(m_frame
);
3527 // if the frame has a toolbar, the client area
3528 // origin will not be (0,0).
3529 wxPoint pt
= m_frame
->GetClientAreaOrigin();
3530 if (pt
.x
!= 0 || pt
.y
!= 0)
3531 cdc
.SetDeviceOrigin(pt
.x
, pt
.y
);
3535 m_art
->DrawPaneButton(cdc
, m_frame
,
3536 button_ui_part
->button
->button_id
,
3538 button_ui_part
->rect
,
3543 void wxAuiManager::OnLeftDown(wxMouseEvent
& event
)
3545 wxAuiDockUIPart
* part
= HitTest(event
.GetX(), event
.GetY());
3548 if (part
->dock
&& part
->dock
->dock_direction
== wxAUI_DOCK_CENTER
)
3551 if (part
->type
== wxAuiDockUIPart::typeDockSizer
||
3552 part
->type
== wxAuiDockUIPart::typePaneSizer
)
3554 // a dock may not be resized if it has a single
3555 // pane which is not resizable
3556 if (part
->type
== wxAuiDockUIPart::typeDockSizer
&& part
->dock
&&
3557 part
->dock
->panes
.GetCount() == 1 &&
3558 part
->dock
->panes
.Item(0)->IsFixed())
3561 // panes that may not be resized should be ignored here
3562 if (part
->pane
&& part
->pane
->IsFixed())
3565 m_action
= actionResize
;
3566 m_action_part
= part
;
3567 m_action_hintrect
= wxRect();
3568 m_action_start
= wxPoint(event
.m_x
, event
.m_y
);
3569 m_action_offset
= wxPoint(event
.m_x
- part
->rect
.x
,
3570 event
.m_y
- part
->rect
.y
);
3571 m_frame
->CaptureMouse();
3573 else if (part
->type
== wxAuiDockUIPart::typePaneButton
)
3575 m_action
= actionClickButton
;
3576 m_action_part
= part
;
3577 m_action_start
= wxPoint(event
.m_x
, event
.m_y
);
3578 m_frame
->CaptureMouse();
3580 UpdateButtonOnScreen(part
, event
);
3582 else if (part
->type
== wxAuiDockUIPart::typeCaption
||
3583 part
->type
== wxAuiDockUIPart::typeGripper
)
3585 if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE
)
3587 // set the caption as active
3588 SetActivePane(m_panes
, part
->pane
->window
);
3592 m_action
= actionClickCaption
;
3593 m_action_part
= part
;
3594 m_action_start
= wxPoint(event
.m_x
, event
.m_y
);
3595 m_action_offset
= wxPoint(event
.m_x
- part
->rect
.x
,
3596 event
.m_y
- part
->rect
.y
);
3597 m_frame
->CaptureMouse();
3617 void wxAuiManager::OnLeftUp(wxMouseEvent
& event
)
3619 if (m_action
== actionResize
)
3621 m_frame
->ReleaseMouse();
3623 // get rid of the hint rectangle
3625 DrawResizeHint(dc
, m_action_hintrect
);
3627 // resize the dock or the pane
3628 if (m_action_part
&& m_action_part
->type
==wxAuiDockUIPart::typeDockSizer
)
3630 wxRect
& rect
= m_action_part
->dock
->rect
;
3632 wxPoint
new_pos(event
.m_x
- m_action_offset
.x
,
3633 event
.m_y
- m_action_offset
.y
);
3635 switch (m_action_part
->dock
->dock_direction
)
3637 case wxAUI_DOCK_LEFT
:
3638 m_action_part
->dock
->size
= new_pos
.x
- rect
.x
;
3640 case wxAUI_DOCK_TOP
:
3641 m_action_part
->dock
->size
= new_pos
.y
- rect
.y
;
3643 case wxAUI_DOCK_RIGHT
:
3644 m_action_part
->dock
->size
= rect
.x
+ rect
.width
-
3645 new_pos
.x
- m_action_part
->rect
.GetWidth();
3647 case wxAUI_DOCK_BOTTOM
:
3648 m_action_part
->dock
->size
= rect
.y
+ rect
.height
-
3649 new_pos
.y
- m_action_part
->rect
.GetHeight();
3656 else if (m_action_part
&&
3657 m_action_part
->type
== wxAuiDockUIPart::typePaneSizer
)
3659 wxAuiDockInfo
& dock
= *m_action_part
->dock
;
3660 wxAuiPaneInfo
& pane
= *m_action_part
->pane
;
3662 int total_proportion
= 0;
3663 int dock_pixels
= 0;
3664 int new_pixsize
= 0;
3666 int caption_size
= m_art
->GetMetric(wxAUI_ART_CAPTION_SIZE
);
3667 int pane_border_size
= m_art
->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
);
3668 int sash_size
= m_art
->GetMetric(wxAUI_ART_SASH_SIZE
);
3670 wxPoint
new_pos(event
.m_x
- m_action_offset
.x
,
3671 event
.m_y
- m_action_offset
.y
);
3673 // determine the pane rectangle by getting the pane part
3674 wxAuiDockUIPart
* pane_part
= GetPanePart(pane
.window
);
3675 wxASSERT_MSG(pane_part
,
3676 wxT("Pane border part not found -- shouldn't happen"));
3678 // determine the new pixel size that the user wants;
3679 // this will help us recalculate the pane's proportion
3680 if (dock
.IsHorizontal())
3681 new_pixsize
= new_pos
.x
- pane_part
->rect
.x
;
3683 new_pixsize
= new_pos
.y
- pane_part
->rect
.y
;
3685 // determine the size of the dock, based on orientation
3686 if (dock
.IsHorizontal())
3687 dock_pixels
= dock
.rect
.GetWidth();
3689 dock_pixels
= dock
.rect
.GetHeight();
3691 // determine the total proportion of all resizable panes,
3692 // and the total size of the dock minus the size of all
3694 int i
, dock_pane_count
= dock
.panes
.GetCount();
3695 int pane_position
= -1;
3696 for (i
= 0; i
< dock_pane_count
; ++i
)
3698 wxAuiPaneInfo
& p
= *dock
.panes
.Item(i
);
3699 if (p
.window
== pane
.window
)
3702 // while we're at it, subtract the pane sash
3703 // width from the dock width, because this would
3704 // skew our proportion calculations
3706 dock_pixels
-= sash_size
;
3708 // also, the whole size (including decorations) of
3709 // all fixed panes must also be subtracted, because they
3710 // are not part of the proportion calculation
3713 if (dock
.IsHorizontal())
3714 dock_pixels
-= p
.best_size
.x
;
3716 dock_pixels
-= p
.best_size
.y
;
3720 total_proportion
+= p
.dock_proportion
;
3724 // find a pane in our dock to 'steal' space from or to 'give'
3725 // space to -- this is essentially what is done when a pane is
3726 // resized; the pane should usually be the first non-fixed pane
3727 // to the right of the action pane
3728 int borrow_pane
= -1;
3729 for (i
= pane_position
+1; i
< dock_pane_count
; ++i
)
3731 wxAuiPaneInfo
& p
= *dock
.panes
.Item(i
);
3740 // demand that the pane being resized is found in this dock
3741 // (this assert really never should be raised)
3742 wxASSERT_MSG(pane_position
!= -1, wxT("Pane not found in dock"));
3744 // prevent division by zero
3745 if (dock_pixels
== 0 || total_proportion
== 0 || borrow_pane
== -1)
3747 m_action
= actionNone
;
3751 // calculate the new proportion of the pane
3752 int new_proportion
= (new_pixsize
*total_proportion
)/dock_pixels
;
3754 // default minimum size
3757 // check against the pane's minimum size, if specified. please note
3758 // that this is not enough to ensure that the minimum size will
3759 // not be violated, because the whole frame might later be shrunk,
3760 // causing the size of the pane to violate it's minimum size
3761 if (pane
.min_size
.IsFullySpecified())
3765 if (pane
.HasBorder())
3766 min_size
+= (pane_border_size
*2);
3768 // calculate minimum size with decorations (border,caption)
3769 if (pane_part
->orientation
== wxVERTICAL
)
3771 min_size
+= pane
.min_size
.y
;
3772 if (pane
.HasCaption())
3773 min_size
+= caption_size
;
3777 min_size
+= pane
.min_size
.x
;
3782 // for some reason, an arithmatic error somewhere is causing
3783 // the proportion calculations to always be off by 1 pixel;
3784 // for now we will add the 1 pixel on, but we really should
3785 // determine what's causing this.
3788 int min_proportion
= (min_size
*total_proportion
)/dock_pixels
;
3790 if (new_proportion
< min_proportion
)
3791 new_proportion
= min_proportion
;
3795 int prop_diff
= new_proportion
- pane
.dock_proportion
;
3797 // borrow the space from our neighbor pane to the
3798 // right or bottom (depending on orientation)
3799 dock
.panes
.Item(borrow_pane
)->dock_proportion
-= prop_diff
;
3800 pane
.dock_proportion
= new_proportion
;
3807 else if (m_action
== actionClickButton
)
3809 m_hover_button
= NULL
;
3810 m_frame
->ReleaseMouse();
3811 UpdateButtonOnScreen(m_action_part
, event
);
3813 // make sure we're still over the item that was originally clicked
3814 if (m_action_part
== HitTest(event
.GetX(), event
.GetY()))
3816 // fire button-click event
3817 wxAuiManagerEvent
e(wxEVT_AUI_PANEBUTTON
);
3818 e
.SetPane(m_action_part
->pane
);
3819 e
.SetButton(m_action_part
->button
->button_id
);
3823 else if (m_action
== actionClickCaption
)
3825 m_frame
->ReleaseMouse();
3827 else if (m_action
== actionDragFloatingPane
)
3829 m_frame
->ReleaseMouse();
3831 else if (m_action
== actionDragToolbarPane
)
3833 m_frame
->ReleaseMouse();
3835 wxAuiPaneInfo
& pane
= GetPane(m_action_window
);
3836 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3838 // save the new positions
3839 wxAuiDockInfoPtrArray docks
;
3840 FindDocks(m_docks
, pane
.dock_direction
,
3841 pane
.dock_layer
, pane
.dock_row
, docks
);
3842 if (docks
.GetCount() == 1)
3844 wxAuiDockInfo
& dock
= *docks
.Item(0);
3846 wxArrayInt pane_positions
, pane_sizes
;
3847 GetPanePositionsAndSizes(dock
, pane_positions
, pane_sizes
);
3849 int i
, dock_pane_count
= dock
.panes
.GetCount();
3850 for (i
= 0; i
< dock_pane_count
; ++i
)
3851 dock
.panes
.Item(i
)->dock_pos
= pane_positions
[i
];
3854 pane
.state
&= ~wxAuiPaneInfo::actionPane
;
3862 m_action
= actionNone
;
3863 m_last_mouse_move
= wxPoint(); // see comment in OnMotion()
3867 void wxAuiManager::OnMotion(wxMouseEvent
& event
)
3869 // sometimes when Update() is called from inside this method,
3870 // a spurious mouse move event is generated; this check will make
3871 // sure that only real mouse moves will get anywhere in this method;
3872 // this appears to be a bug somewhere, and I don't know where the
3873 // mouse move event is being generated. only verified on MSW
3875 wxPoint mouse_pos
= event
.GetPosition();
3876 if (m_last_mouse_move
== mouse_pos
)
3878 m_last_mouse_move
= mouse_pos
;
3881 if (m_action
== actionResize
)
3883 wxPoint pos
= m_action_part
->rect
.GetPosition();
3884 if (m_action_part
->orientation
== wxHORIZONTAL
)
3885 pos
.y
= wxMax(0, event
.m_y
- m_action_offset
.y
);
3887 pos
.x
= wxMax(0, event
.m_x
- m_action_offset
.x
);
3889 wxRect
rect(m_frame
->ClientToScreen(pos
),
3890 m_action_part
->rect
.GetSize());
3893 if (!m_action_hintrect
.IsEmpty())
3894 DrawResizeHint(dc
, m_action_hintrect
);
3895 DrawResizeHint(dc
, rect
);
3896 m_action_hintrect
= rect
;
3898 else if (m_action
== actionClickCaption
)
3900 int drag_x_threshold
= wxSystemSettings::GetMetric(wxSYS_DRAG_X
);
3901 int drag_y_threshold
= wxSystemSettings::GetMetric(wxSYS_DRAG_Y
);
3903 // caption has been clicked. we need to check if the mouse
3904 // is now being dragged. if it is, we need to change the
3905 // mouse action to 'drag'
3906 if (abs(event
.m_x
- m_action_start
.x
) > drag_x_threshold
||
3907 abs(event
.m_y
- m_action_start
.y
) > drag_y_threshold
)
3909 wxAuiPaneInfo
* pane_info
= m_action_part
->pane
;
3911 if (!pane_info
->IsToolbar())
3913 if ((m_flags
& wxAUI_MGR_ALLOW_FLOATING
) &&
3914 pane_info
->IsFloatable())
3916 m_action
= actionDragFloatingPane
;
3918 // set initial float position
3919 wxPoint pt
= m_frame
->ClientToScreen(event
.GetPosition());
3920 pane_info
->floating_pos
= wxPoint(pt
.x
- m_action_offset
.x
,
3921 pt
.y
- m_action_offset
.y
);
3924 if(pane_info
->IsMaximized()) {
3925 RestorePane(*pane_info
);
3930 m_action_window
= pane_info
->frame
;
3932 // action offset is used here to make it feel "natural" to the user
3933 // to drag a docked pane and suddenly have it become a floating frame.
3934 // Sometimes, however, the offset where the user clicked on the docked
3935 // caption is bigger than the width of the floating frame itself, so
3936 // in that case we need to set the action offset to a sensible value
3937 wxSize frame_size
= m_action_window
->GetSize();
3938 if (frame_size
.x
<= m_action_offset
.x
)
3939 m_action_offset
.x
= 30;
3944 m_action
= actionDragToolbarPane
;
3945 m_action_window
= pane_info
->window
;
3949 else if (m_action
== actionDragFloatingPane
)
3951 if(m_action_window
) {
3952 wxPoint pt
= m_frame
->ClientToScreen(event
.GetPosition());
3953 m_action_window
->Move(pt
.x
- m_action_offset
.x
,
3954 pt
.y
- m_action_offset
.y
);
3957 else if (m_action
== actionDragToolbarPane
)
3959 wxAuiPaneInfo
& pane
= GetPane(m_action_window
);
3960 wxASSERT_MSG(pane
.IsOk(), wxT("Pane window not found"));
3962 pane
.state
|= wxAuiPaneInfo::actionPane
;
3964 wxPoint pt
= event
.GetPosition();
3965 DoDrop(m_docks
, m_panes
, pane
, pt
, m_action_offset
);
3967 // if DoDrop() decided to float the pane, set up
3968 // the floating pane's initial position
3969 if (pane
.IsFloating())
3971 wxPoint pt
= m_frame
->ClientToScreen(event
.GetPosition());
3972 pane
.floating_pos
= wxPoint(pt
.x
- m_action_offset
.x
,
3973 pt
.y
- m_action_offset
.y
);
3976 // this will do the actiual move operation;
3977 // in the case that the pane has been floated,
3978 // this call will create the floating pane
3979 // and do the reparenting
3982 // if the pane has been floated, change the mouse
3983 // action actionDragFloatingPane so that subsequent
3984 // EVT_MOTION() events will move the floating pane
3985 if (pane
.IsFloating())
3987 pane
.state
&= ~wxAuiPaneInfo::actionPane
;
3988 m_action
= actionDragFloatingPane
;
3989 m_action_window
= pane
.frame
;
3994 wxAuiDockUIPart
* part
= HitTest(event
.GetX(), event
.GetY());
3995 if (part
&& part
->type
== wxAuiDockUIPart::typePaneButton
)
3997 if (part
!= m_hover_button
)
3999 // make the old button normal
4002 UpdateButtonOnScreen(m_hover_button
, event
);
4006 // mouse is over a button, so repaint the
4007 // button in hover mode
4008 UpdateButtonOnScreen(part
, event
);
4009 m_hover_button
= part
;
4017 m_hover_button
= NULL
;
4028 void wxAuiManager::OnLeaveWindow(wxMouseEvent
& WXUNUSED(event
))
4032 m_hover_button
= NULL
;
4037 void wxAuiManager::OnChildFocus(wxChildFocusEvent
& event
)
4039 // when a child pane has it's focus set, we should change the
4040 // pane's active state to reflect this. (this is only true if
4041 // active panes are allowed by the owner)
4042 if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE
)
4044 if (GetPane(event
.GetWindow()).IsOk())
4046 SetActivePane(m_panes
, event
.GetWindow());
4055 // OnPaneButton() is an event handler that is called
4056 // when a pane button has been pressed.
4057 void wxAuiManager::OnPaneButton(wxAuiManagerEvent
& evt
)
4059 wxASSERT_MSG(evt
.pane
, wxT("Pane Info passed to wxAuiManager::OnPaneButton must be non-null"));
4061 wxAuiPaneInfo
& pane
= *(evt
.pane
);
4063 if (evt
.button
== wxAUI_BUTTON_CLOSE
)
4065 // fire pane close event
4066 wxAuiManagerEvent
e(wxEVT_AUI_PANECLOSE
);
4067 e
.SetPane(evt
.pane
);
4076 else if (evt
.button
== wxAUI_BUTTON_MAXIMIZE_RESTORE
&& !pane
.IsMaximized())
4078 // fire pane close event
4079 wxAuiManagerEvent
e(wxEVT_AUI_PANEMAXIMIZE
);
4080 e
.SetPane(evt
.pane
);
4089 else if (evt
.button
== wxAUI_BUTTON_MAXIMIZE_RESTORE
&& pane
.IsMaximized())
4091 // fire pane close event
4092 wxAuiManagerEvent
e(wxEVT_AUI_PANERESTORE
);
4093 e
.SetPane(evt
.pane
);
4102 else if (evt
.button
== wxAUI_BUTTON_PIN
)
4104 if ((m_flags
& wxAUI_MGR_ALLOW_FLOATING
) &&