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 wxFloatingPane::wxFloatingPane(wxWindow
* parent
, 
  36                 wxFrameManager
* owner_mgr
, 
  37                 wxWindowID id 
/*= wxID_ANY*/, 
  38                 const wxPoint
& pos 
/*= wxDefaultPosition*/, 
  39                 const wxSize
& size 
/*= wxDefaultSize*/) 
  40                 : wxFloatingPaneBaseClass(parent
, id
, wxEmptyString
, pos
, size
, 
  41                         wxRESIZE_BORDER 
| wxSYSTEM_MENU 
| wxCAPTION 
| 
  42                         wxCLOSE_BOX 
| wxFRAME_NO_TASKBAR 
| 
  43                         wxFRAME_FLOAT_ON_PARENT 
| wxCLIP_CHILDREN
) 
  45     m_owner_mgr 
= owner_mgr
; 
  47     m_last_rect 
= wxRect(); 
  49     SetExtraStyle(wxWS_EX_PROCESS_IDLE
); 
  52 wxFloatingPane::~wxFloatingPane() 
  57 void wxFloatingPane::SetPaneWindow(const wxPaneInfo
& pane
) 
  59     m_pane_window 
= pane
.window
; 
  60     m_pane_window
->Reparent(this); 
  62     wxPaneInfo contained_pane 
= pane
; 
  63     contained_pane
.Dock().Center().Show(). 
  64                     CaptionVisible(false). 
  66                     Layer(0).Row(0).Position(0); 
  68     m_mgr
.AddPane(m_pane_window
, contained_pane
); 
  71     if (pane
.min_size
.IsFullySpecified()) 
  73         // because SetSizeHints() calls Fit() too (which sets the window 
  74         // size to its minimum allowed), we keep the size before calling 
  75         // SetSizeHints() and reset it afterwards... 
  76         wxSize tmp 
= GetSize(); 
  77         GetSizer()->SetSizeHints(this); 
  81     SetTitle(pane
.caption
); 
  83     if (contained_pane
.IsFixed()) 
  84         SetWindowStyle(GetWindowStyle() & ~wxRESIZE_BORDER
); 
  86     if (pane
.floating_size 
!= wxDefaultSize
) 
  88         SetSize(pane
.floating_size
); 
  92         wxSize size 
= pane
.best_size
; 
  93         if (size 
== wxDefaultSize
) 
  95         if (size 
== wxDefaultSize
) 
  96             size 
= m_pane_window
->GetSize(); 
  97         if (pane
.HasGripper()) 
  99             if (pane
.HasGripperTop()) 
 100                 size
.y 
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
); 
 102                 size
.x 
+= m_owner_mgr
->m_art
->GetMetric(wxAUI_ART_GRIPPER_SIZE
); 
 109 void wxFloatingPane::OnSize(wxSizeEvent
& event
) 
 111     m_owner_mgr
->OnFloatingPaneResized(m_pane_window
, event
.GetSize()); 
 114 void wxFloatingPane::OnClose(wxCloseEvent
& WXUNUSED(event
)) 
 116     m_owner_mgr
->OnFloatingPaneClosed(m_pane_window
); 
 120 void wxFloatingPane::OnMoveEvent(wxMoveEvent
& event
) 
 122     wxRect win_rect 
= GetRect(); 
 124     // skip the first move event 
 125     if (m_last_rect
.IsEmpty()) 
 127         m_last_rect 
= win_rect
; 
 131     // prevent frame redocking during resize 
 132     if (m_last_rect
.GetSize() != win_rect
.GetSize()) 
 134         m_last_rect 
= win_rect
; 
 138     m_last_rect 
= win_rect
; 
 149     OnMoving(event
.GetRect()); 
 152 void wxFloatingPane::OnIdle(wxIdleEvent
& event
) 
 168 void wxFloatingPane::OnMoveStart() 
 170     // notify the owner manager that the pane has started to move 
 171     m_owner_mgr
->OnFloatingPaneMoveStart(m_pane_window
); 
 174 void wxFloatingPane::OnMoving(const wxRect
& WXUNUSED(window_rect
)) 
 176     // notify the owner manager that the pane is moving 
 177     m_owner_mgr
->OnFloatingPaneMoving(m_pane_window
); 
 180 void wxFloatingPane::OnMoveFinished() 
 182     // notify the owner manager that the pane has finished moving 
 183     m_owner_mgr
->OnFloatingPaneMoved(m_pane_window
); 
 186 void wxFloatingPane::OnActivate(wxActivateEvent
& event
) 
 188     if (event
.GetActive()) 
 190         m_owner_mgr
->OnFloatingPaneActivated(m_pane_window
); 
 194 // utility function which determines the state of the mouse button 
 195 // (independant of having a wxMouseEvent handy) - utimately a better 
 196 // mechanism for this should be found (possibly by adding the 
 197 // functionality to wxWidgets itself) 
 198 bool wxFloatingPane::isMouseDown() 
 200     return wxGetMouseState().LeftDown(); 
 204 BEGIN_EVENT_TABLE(wxFloatingPane
, wxFloatingPaneBaseClass
) 
 205     EVT_SIZE(wxFloatingPane::OnSize
) 
 206     EVT_MOVE(wxFloatingPane::OnMoveEvent
) 
 207     EVT_MOVING(wxFloatingPane::OnMoveEvent
) 
 208     EVT_CLOSE(wxFloatingPane::OnClose
) 
 209     EVT_IDLE(wxFloatingPane::OnIdle
) 
 210     EVT_ACTIVATE(wxFloatingPane::OnActivate
)