1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/aui/floatpane.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/floatpane.h"
30 #include "wx/aui/dockart.h"
35 IMPLEMENT_CLASS( wxFloatingPane
, wxFloatingPaneBaseClass
)
37 wxFloatingPane::wxFloatingPane(wxWindow
* parent
,
38 wxFrameManager
* owner_mgr
,
39 const wxPaneInfo
& pane
,
40 wxWindowID id
/*= wxID_ANY*/)
41 : wxFloatingPaneBaseClass(parent
, id
, wxEmptyString
,
42 pane
.floating_pos
, pane
.floating_size
,
43 wxRESIZE_BORDER
| wxSYSTEM_MENU
| wxCAPTION
|
44 (pane
.HasCloseButton()?wxCLOSE_BOX
:0) |
46 wxFRAME_FLOAT_ON_PARENT
| wxCLIP_CHILDREN
|
47 (pane
.IsFixed()?0:wxRESIZE_BORDER
)
50 m_owner_mgr
= owner_mgr
;
52 m_last_rect
= wxRect();
53 m_mgr
.SetManagedWindow(this);
54 SetExtraStyle(wxWS_EX_PROCESS_IDLE
);
57 wxFloatingPane::~wxFloatingPane()
62 void wxFloatingPane::SetPaneWindow(const wxPaneInfo
& pane
)
64 m_pane_window
= pane
.window
;
65 m_pane_window
->Reparent(this);
67 wxPaneInfo contained_pane
= pane
;
68 contained_pane
.Dock().Center().Show().
69 CaptionVisible(false).
71 Layer(0).Row(0).Position(0);
73 // Carry over the minimum size
74 SetMinSize(pane
.window
->GetMinSize());
76 m_mgr
.AddPane(m_pane_window
, contained_pane
);
79 if (pane
.min_size
.IsFullySpecified())
81 // because SetSizeHints() calls Fit() too (which sets the window
82 // size to its minimum allowed), we keep the size before calling
83 // SetSizeHints() and reset it afterwards...
84 wxSize tmp
= GetSize();
85 GetSizer()->SetSizeHints(this);
89 SetTitle(pane
.caption
);
91 if (pane
.floating_size
!= wxDefaultSize
)
93 SetSize(pane
.floating_size
);
97 wxSize size
= pane
.best_size
;
98 if (size
== wxDefaultSize
)
100 if (size
== wxDefaultSize
)
101 size
= m_pane_window
->GetSize();
102 if (pane
.HasGripper())
104 if (pane
.HasGripperTop())
105 size
.y
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
107 size
.x
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
114 void wxFloatingPane::OnSize(wxSizeEvent
& event
)
116 m_owner_mgr
->OnFloatingPaneResized(m_pane_window
, event
.GetSize());
119 void wxFloatingPane::OnClose(wxCloseEvent
& evt
)
121 m_owner_mgr
->OnFloatingPaneClosed(m_pane_window
, evt
);
126 void wxFloatingPane::OnMoveEvent(wxMoveEvent
& event
)
128 wxRect win_rect
= GetRect();
130 // skip the first move event
131 if (m_last_rect
.IsEmpty())
133 m_last_rect
= win_rect
;
137 // prevent frame redocking during resize
138 if (m_last_rect
.GetSize() != win_rect
.GetSize())
140 m_last_rect
= win_rect
;
144 m_last_rect
= win_rect
;
155 OnMoving(event
.GetRect());
158 void wxFloatingPane::OnIdle(wxIdleEvent
& event
)
174 void wxFloatingPane::OnMoveStart()
176 // notify the owner manager that the pane has started to move
177 m_owner_mgr
->OnFloatingPaneMoveStart(m_pane_window
);
180 void wxFloatingPane::OnMoving(const wxRect
& WXUNUSED(window_rect
))
182 // notify the owner manager that the pane is moving
183 m_owner_mgr
->OnFloatingPaneMoving(m_pane_window
);
186 void wxFloatingPane::OnMoveFinished()
188 // notify the owner manager that the pane has finished moving
189 m_owner_mgr
->OnFloatingPaneMoved(m_pane_window
);
192 void wxFloatingPane::OnActivate(wxActivateEvent
& event
)
194 if (event
.GetActive())
196 m_owner_mgr
->OnFloatingPaneActivated(m_pane_window
);
200 // utility function which determines the state of the mouse button
201 // (independant of having a wxMouseEvent handy) - utimately a better
202 // mechanism for this should be found (possibly by adding the
203 // functionality to wxWidgets itself)
204 bool wxFloatingPane::isMouseDown()
206 return wxGetMouseState().LeftDown();
210 BEGIN_EVENT_TABLE(wxFloatingPane
, wxFloatingPaneBaseClass
)
211 EVT_SIZE(wxFloatingPane::OnSize
)
212 EVT_MOVE(wxFloatingPane::OnMoveEvent
)
213 EVT_MOVING(wxFloatingPane::OnMoveEvent
)
214 EVT_CLOSE(wxFloatingPane::OnClose
)
215 EVT_IDLE(wxFloatingPane::OnIdle
)
216 EVT_ACTIVATE(wxFloatingPane::OnActivate
)