1 ///////////////////////////////////////////////////////////////////////////////
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"
33 // #include "wx/log.h"
36 wxFloatingPane::wxFloatingPane(wxWindow
* parent
,
37 wxFrameManager
* owner_mgr
,
38 wxWindowID id
/*= -1*/,
39 const wxPoint
& pos
/*= wxDefaultPosition*/,
40 const wxSize
& size
/*= wxDefaultSize*/)
41 : wxFloatingPaneBaseClass(parent
, id
, wxT(""), pos
, size
,
42 wxRESIZE_BORDER
| wxSYSTEM_MENU
| wxCAPTION
|
43 wxCLOSE_BOX
| wxFRAME_NO_TASKBAR
|
44 wxFRAME_FLOAT_ON_PARENT
| wxCLIP_CHILDREN
)
46 m_owner_mgr
= owner_mgr
;
48 m_last_rect
= wxRect();
50 SetExtraStyle(wxWS_EX_PROCESS_IDLE
);
53 wxFloatingPane::~wxFloatingPane()
58 void wxFloatingPane::SetPaneWindow(const wxPaneInfo
& pane
)
60 m_pane_window
= pane
.window
;
61 m_pane_window
->Reparent(this);
63 wxPaneInfo contained_pane
= pane
;
64 contained_pane
.Dock().Center().Show().
65 CaptionVisible(false).
67 Layer(0).Row(0).Position(0);
69 m_mgr
.AddPane(m_pane_window
, contained_pane
);
72 if (pane
.min_size
.IsFullySpecified())
74 // because SetSizeHints() calls Fit() too (which sets the window
75 // size to its minimum allowed), we keep the size before calling
76 // SetSizeHints() and reset it afterwards...
77 wxSize tmp
= GetSize();
78 GetSizer()->SetSizeHints(this);
82 SetTitle(pane
.caption
);
84 if (contained_pane
.IsFixed())
85 SetWindowStyle(GetWindowStyle() & ~wxRESIZE_BORDER
);
87 if (pane
.floating_size
!= wxDefaultSize
)
89 SetSize(pane
.floating_size
);
93 wxSize size
= pane
.best_size
;
94 if (size
== wxDefaultSize
)
96 if (size
== wxDefaultSize
)
97 size
= m_pane_window
->GetSize();
98 if (pane
.HasGripper())
100 if (pane
.HasGripperTop())
101 size
.y
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
103 size
.x
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
);
110 void wxFloatingPane::OnSize(wxSizeEvent
& event
)
112 m_owner_mgr
->OnFloatingPaneResized(m_pane_window
, event
.GetSize());
115 void wxFloatingPane::OnClose(wxCloseEvent
& WXUNUSED(event
))
117 m_owner_mgr
->OnFloatingPaneClosed(m_pane_window
);
121 void wxFloatingPane::OnMoveEvent(wxMoveEvent
& event
)
123 wxRect win_rect
= GetRect();
125 // skip the first move event
126 if (m_last_rect
.IsEmpty())
128 m_last_rect
= win_rect
;
132 // prevent frame redocking during resize
133 if (m_last_rect
.GetSize() != win_rect
.GetSize())
135 m_last_rect
= win_rect
;
139 m_last_rect
= win_rect
;
150 OnMoving(event
.GetRect());
153 void wxFloatingPane::OnIdle(wxIdleEvent
& event
)
169 void wxFloatingPane::OnMoveStart()
171 // notify the owner manager that the pane has started to move
172 m_owner_mgr
->OnFloatingPaneMoveStart(m_pane_window
);
175 void wxFloatingPane::OnMoving(const wxRect
& WXUNUSED(window_rect
))
177 // notify the owner manager that the pane is moving
178 m_owner_mgr
->OnFloatingPaneMoving(m_pane_window
);
181 void wxFloatingPane::OnMoveFinished()
183 // notify the owner manager that the pane has finished moving
184 m_owner_mgr
->OnFloatingPaneMoved(m_pane_window
);
187 void wxFloatingPane::OnActivate(wxActivateEvent
& event
)
189 if (event
.GetActive())
191 m_owner_mgr
->OnFloatingPaneActivated(m_pane_window
);
195 // utility function which determines the state of the mouse button
196 // (independant of having a wxMouseEvent handy) - utimately a better
197 // mechanism for this should be found (possibly by adding the
198 // functionality to wxWidgets itself)
199 bool wxFloatingPane::isMouseDown()
201 return wxGetMouseState().LeftDown();
205 BEGIN_EVENT_TABLE(wxFloatingPane
, wxFloatingPaneBaseClass
)
206 EVT_SIZE(wxFloatingPane::OnSize
)
207 EVT_MOVE(wxFloatingPane::OnMoveEvent
)
208 EVT_MOVING(wxFloatingPane::OnMoveEvent
)
209 EVT_CLOSE(wxFloatingPane::OnClose
)
210 EVT_IDLE(wxFloatingPane::OnIdle
)
211 EVT_ACTIVATE(wxFloatingPane::OnActivate
)