00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "framemanager.h"
00021 #include "floatpane.h"
00022 #include "dockart.h"
00023
00024 #if wxXTRA_AUI
00025
00026 IMPLEMENT_CLASS( wxAuiFloatingFrame, wxAuiFloatingFrameBaseClass )
00027
00028 wxAuiFloatingFrame::wxAuiFloatingFrame(wxWindow* parent,
00029 wxAuiManager* owner_mgr,
00030 const wxAuiPaneInfo& pane,
00031 wxWindowID id )
00032 : wxAuiFloatingFrameBaseClass(parent, id, wxEmptyString,
00033 pane.floating_pos, pane.floating_size,
00034 wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
00035 (pane.HasCloseButton()?wxCLOSE_BOX:0) |
00036 wxFRAME_NO_TASKBAR |
00037 wxFRAME_FLOAT_ON_PARENT | wxCLIP_CHILDREN |
00038 (pane.IsFixed()?0:wxRESIZE_BORDER)
00039 )
00040 {
00041 m_owner_mgr = owner_mgr;
00042 m_moving = false;
00043 m_last_rect = wxRect();
00044 m_mgr.SetManagedWindow(this);
00045 SetExtraStyle(wxWS_EX_PROCESS_IDLE);
00046 }
00047
00048 wxAuiFloatingFrame::~wxAuiFloatingFrame()
00049 {
00050 m_mgr.UnInit();
00051 }
00052
00053 void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane)
00054 {
00055 m_pane_window = pane.window;
00056 m_pane_window->Reparent(this);
00057
00058 wxAuiPaneInfo contained_pane = pane;
00059 contained_pane.Dock().Center().Show().
00060 CaptionVisible(false).
00061 PaneBorder(false).
00062 Layer(0).Row(0).Position(0);
00063
00064
00065 SetMinSize(pane.window->GetMinSize());
00066
00067 m_mgr.AddPane(m_pane_window, contained_pane);
00068 m_mgr.Update();
00069
00070 if (pane.min_size.IsFullySpecified())
00071 {
00072
00073
00074
00075 wxSize tmp = GetSize();
00076 GetSizer()->SetSizeHints(this);
00077 SetSize(tmp);
00078 }
00079
00080 SetTitle(pane.caption);
00081
00082 if (pane.floating_size != wxDefaultSize)
00083 {
00084 SetSize(pane.floating_size);
00085 }
00086 else
00087 {
00088 wxSize size = pane.best_size;
00089 if (size == wxDefaultSize)
00090 size = pane.min_size;
00091 if (size == wxDefaultSize)
00092 size = m_pane_window->GetSize();
00093 if (pane.HasGripper())
00094 {
00095 if (pane.HasGripperTop())
00096 size.y += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
00097 else
00098 size.x += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
00099 }
00100
00101 SetClientSize(size);
00102 }
00103 }
00104
00105 void wxAuiFloatingFrame::OnSize(wxSizeEvent& event)
00106 {
00107 m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize());
00108 }
00109
00110 void wxAuiFloatingFrame::OnClose(wxCloseEvent& evt)
00111 {
00112 m_owner_mgr->OnFloatingPaneClosed(m_pane_window, evt);
00113 if (!evt.GetVeto())
00114 Destroy();
00115 }
00116
00117 void wxAuiFloatingFrame::OnMoveEvent(wxMoveEvent& event)
00118 {
00119 #ifdef __WXGTK__
00120
00121
00122
00123
00124
00125
00126 m_owner_mgr->OnFloatingPaneResized(m_pane_window, GetSize());
00127 #endif
00128
00129 wxRect win_rect = GetRect();
00130
00131
00132 if (m_last_rect.IsEmpty())
00133 {
00134 m_last_rect = win_rect;
00135 return;
00136 }
00137
00138
00139 if (m_last_rect.GetSize() != win_rect.GetSize())
00140 {
00141 m_last_rect = win_rect;
00142 return;
00143 }
00144
00145 m_last_rect = win_rect;
00146
00147 if (!isMouseDown())
00148 return;
00149
00150 if (!m_moving)
00151 {
00152 OnMoveStart();
00153 m_moving = true;
00154 }
00155
00156 OnMoving(event.GetRect());
00157 }
00158
00159 void wxAuiFloatingFrame::OnIdle(wxIdleEvent& event)
00160 {
00161 if (m_moving)
00162 {
00163 if (!isMouseDown())
00164 {
00165 m_moving = false;
00166 OnMoveFinished();
00167 }
00168 else
00169 {
00170 event.RequestMore();
00171 }
00172 }
00173 }
00174
00175 void wxAuiFloatingFrame::OnMoveStart()
00176 {
00177
00178 m_owner_mgr->OnFloatingPaneMoveStart(m_pane_window);
00179 }
00180
00181 void wxAuiFloatingFrame::OnMoving(const wxRect& WXUNUSED(window_rect))
00182 {
00183
00184 m_owner_mgr->OnFloatingPaneMoving(m_pane_window);
00185 }
00186
00187 void wxAuiFloatingFrame::OnMoveFinished()
00188 {
00189
00190 m_owner_mgr->OnFloatingPaneMoved(m_pane_window);
00191 }
00192
00193 void wxAuiFloatingFrame::OnActivate(wxActivateEvent& event)
00194 {
00195 if (event.GetActive())
00196 {
00197 m_owner_mgr->OnFloatingPaneActivated(m_pane_window);
00198 }
00199 }
00200
00201
00202
00203
00204
00205 bool wxAuiFloatingFrame::isMouseDown()
00206 {
00207 return wxGetMouseState().LeftDown();
00208 }
00209
00210
00211 BEGIN_EVENT_TABLE(wxAuiFloatingFrame, wxAuiFloatingFrameBaseClass)
00212 EVT_SIZE(wxAuiFloatingFrame::OnSize)
00213 EVT_MOVE(wxAuiFloatingFrame::OnMoveEvent)
00214 EVT_MOVING(wxAuiFloatingFrame::OnMoveEvent)
00215 EVT_CLOSE(wxAuiFloatingFrame::OnClose)
00216 EVT_IDLE(wxAuiFloatingFrame::OnIdle)
00217 EVT_ACTIVATE(wxAuiFloatingFrame::OnActivate)
00218 END_EVENT_TABLE()
00219
00220 #endif