]> git.saurik.com Git - wxWidgets.git/blame - src/aui/floatpane.cpp
added possibility to strip only mnemonics, not accels, in wxStripMenuCodes(); added...
[wxWidgets.git] / src / aui / floatpane.cpp
CommitLineData
50acee04 1///////////////////////////////////////////////////////////////////////////////
be66f18e 2// Name: src/aui/floatpane.cpp
50acee04
JS
3// Purpose: wxaui: wx advanced user interface - docking window manager
4// Author: Benjamin I. Williams
5// Modified by:
6// Created: 2005-05-17
be66f18e 7// RCS-ID: $Id$
50acee04
JS
8// Copyright: (C) Copyright 2005-2006, Kirix Corporation, All Rights Reserved
9// Licence: wxWindows Library Licence, Version 3.1
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_AUI
27
28#include "wx/aui/framemanager.h"
29#include "wx/aui/floatpane.h"
30#include "wx/aui/dockart.h"
31
32#ifndef WX_PRECOMP
50acee04
JS
33#endif
34
e5ab82d3
AB
35IMPLEMENT_CLASS( wxFloatingPane, wxFloatingPaneBaseClass )
36
50acee04
JS
37wxFloatingPane::wxFloatingPane(wxWindow* parent,
38 wxFrameManager* owner_mgr,
e5ab82d3
AB
39 const wxPaneInfo& pane,
40 wxWindowID id /*= wxID_ANY*/)
41 : wxFloatingPaneBaseClass(parent, id, wxEmptyString,
42 pane.floating_pos, pane.floating_size,
50acee04 43 wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
96743140
BW
44 (pane.HasCloseButton()?wxCLOSE_BOX:0) |
45 wxFRAME_NO_TASKBAR |
e5ab82d3
AB
46 wxFRAME_FLOAT_ON_PARENT | wxCLIP_CHILDREN |
47 (pane.IsFixed()?0:wxRESIZE_BORDER)
48 )
50acee04
JS
49{
50 m_owner_mgr = owner_mgr;
51 m_moving = false;
52 m_last_rect = wxRect();
461125ea 53 m_mgr.SetManagedWindow(this);
50acee04
JS
54 SetExtraStyle(wxWS_EX_PROCESS_IDLE);
55}
56
57wxFloatingPane::~wxFloatingPane()
58{
59 m_mgr.UnInit();
60}
61
62void wxFloatingPane::SetPaneWindow(const wxPaneInfo& pane)
63{
64 m_pane_window = pane.window;
65 m_pane_window->Reparent(this);
be66f18e 66
50acee04
JS
67 wxPaneInfo contained_pane = pane;
68 contained_pane.Dock().Center().Show().
69 CaptionVisible(false).
70 PaneBorder(false).
71 Layer(0).Row(0).Position(0);
be66f18e 72
5c62cb6c
AB
73 // Carry over the minimum size
74 SetMinSize(pane.window->GetMinSize());
75
50acee04 76 m_mgr.AddPane(m_pane_window, contained_pane);
be66f18e 77 m_mgr.Update();
50acee04
JS
78
79 if (pane.min_size.IsFullySpecified())
80 {
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);
86 SetSize(tmp);
87 }
be66f18e 88
50acee04
JS
89 SetTitle(pane.caption);
90
50acee04
JS
91 if (pane.floating_size != wxDefaultSize)
92 {
93 SetSize(pane.floating_size);
94 }
95 else
96 {
97 wxSize size = pane.best_size;
98 if (size == wxDefaultSize)
99 size = pane.min_size;
100 if (size == wxDefaultSize)
101 size = m_pane_window->GetSize();
102 if (pane.HasGripper())
103 {
104 if (pane.HasGripperTop())
105 size.y += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
106 else
107 size.x += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
108 }
be66f18e 109
50acee04
JS
110 SetClientSize(size);
111 }
112}
113
114void wxFloatingPane::OnSize(wxSizeEvent& event)
115{
116 m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize());
117}
118
58754643 119void wxFloatingPane::OnClose(wxCloseEvent& evt)
50acee04 120{
58754643
BW
121 m_owner_mgr->OnFloatingPaneClosed(m_pane_window, evt);
122 if (!evt.GetVeto())
c68038f3 123 Destroy();
50acee04
JS
124}
125
126void wxFloatingPane::OnMoveEvent(wxMoveEvent& event)
127{
128 wxRect win_rect = GetRect();
129
130 // skip the first move event
131 if (m_last_rect.IsEmpty())
132 {
133 m_last_rect = win_rect;
134 return;
135 }
136
137 // prevent frame redocking during resize
138 if (m_last_rect.GetSize() != win_rect.GetSize())
139 {
140 m_last_rect = win_rect;
141 return;
142 }
143
144 m_last_rect = win_rect;
be66f18e 145
50acee04
JS
146 if (!isMouseDown())
147 return;
148
149 if (!m_moving)
150 {
151 OnMoveStart();
152 m_moving = true;
153 }
154
155 OnMoving(event.GetRect());
156}
157
158void wxFloatingPane::OnIdle(wxIdleEvent& event)
159{
160 if (m_moving)
161 {
162 if (!isMouseDown())
163 {
164 m_moving = false;
165 OnMoveFinished();
166 }
167 else
168 {
169 event.RequestMore();
170 }
171 }
172}
173
174void wxFloatingPane::OnMoveStart()
175{
176 // notify the owner manager that the pane has started to move
177 m_owner_mgr->OnFloatingPaneMoveStart(m_pane_window);
178}
179
180void wxFloatingPane::OnMoving(const wxRect& WXUNUSED(window_rect))
181{
182 // notify the owner manager that the pane is moving
183 m_owner_mgr->OnFloatingPaneMoving(m_pane_window);
184}
185
186void wxFloatingPane::OnMoveFinished()
187{
188 // notify the owner manager that the pane has finished moving
189 m_owner_mgr->OnFloatingPaneMoved(m_pane_window);
190}
191
192void wxFloatingPane::OnActivate(wxActivateEvent& event)
193{
194 if (event.GetActive())
195 {
196 m_owner_mgr->OnFloatingPaneActivated(m_pane_window);
197 }
198}
199
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)
204bool wxFloatingPane::isMouseDown()
205{
206 return wxGetMouseState().LeftDown();
207}
208
209
210BEGIN_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)
217END_EVENT_TABLE()
218
219
220#endif // wxUSE_AUI