]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/framemanager.cpp
cache the item text size to optimize tree layout/painting (#9956)
[wxWidgets.git] / src / aui / framemanager.cpp
index b4ee254fd6551c10c6ebcc59eef1150be0e63957..fb46813dba2591c1b98e4d3533dcf7c1b1ae91b4 100644 (file)
@@ -29,6 +29,7 @@
 #include "wx/aui/dockart.h"
 #include "wx/aui/floatpane.h"
 #include "wx/aui/tabmdi.h"
+#include "wx/aui/auibar.h"
 
 #ifndef WX_PRECOMP
     #include "wx/panel.h"
@@ -64,7 +65,7 @@ DEFINE_EVENT_TYPE(wxEVT_AUI_FIND_MANAGER)
     // a few defines to avoid nameclashes
     #define __MAC_OS_X_MEMORY_MANAGER_CLEAN__ 1
     #define __AIFF__
-    #include "wx/mac/private.h"
+    #include "wx/osx/private.h"
 #endif
 
 #ifdef __WXMSW__
@@ -256,6 +257,9 @@ public:
         m_title = title;
 
         m_widget = gtk_window_new( GTK_WINDOW_POPUP );
+        g_object_ref(m_widget);
+
+        if (parent) parent->AddChild(this);
 
         g_signal_connect( m_widget, "realize",
                       G_CALLBACK (gtk_pseudo_window_realized_callback), this );
@@ -610,17 +614,6 @@ wxAuiManager::~wxAuiManager()
     }
 #endif
 
-    // We need to remove any reference to this wxAuiManager in any of the
-    // wxAuiFloatingFrames associated with this manager in case they haven't
-    // been deleted just yet.
-    // We need an array copy since Unregister removes the items.
-    wxAuiFloatingFramePtrArray array_copy = m_floating_frames;
-    int i, count = array_copy.GetCount();
-    for (i = 0; i < count; ++i)
-    {
-        UnregisterFloatingFrame(array_copy.Item(i));
-    }
-
     delete m_art;
 }
 
@@ -628,9 +621,7 @@ wxAuiManager::~wxAuiManager()
 wxAuiFloatingFrame* wxAuiManager::CreateFloatingFrame(wxWindow* parent,
                                                       const wxAuiPaneInfo& pane_info)
 {
-    wxAuiFloatingFrame* frame = new wxAuiFloatingFrame(parent, this, pane_info);
-    RegisterFloatingFrame(frame);
-    return frame;
+    return new wxAuiFloatingFrame(parent, this, pane_info);
 }
 
 bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p))
@@ -640,37 +631,6 @@ bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p))
     return !(wxGetKeyState(WXK_CONTROL) || wxGetKeyState(WXK_ALT));
 }
 
-// registers a floating frame with this manager (see header)
-void wxAuiManager::RegisterFloatingFrame(wxAuiFloatingFrame* frame)
-{
-    frame->SetOwnerManager(this);
-    int i, count = m_floating_frames.GetCount();
-    for (i = 0; i < count; ++i)
-    {
-        wxAuiFloatingFrame* f = m_floating_frames.Item(i);
-        if (f == frame)
-            // this frame is already registered
-            return;
-    }
-    m_floating_frames.Add(frame);
-}
-
-// unregisters a floating frame from this manager (see header)
-void wxAuiManager::UnregisterFloatingFrame(wxAuiFloatingFrame* frame)
-{
-    frame->SetOwnerManager(NULL);
-    int i, count = m_floating_frames.GetCount();
-    for (i = 0; i < count; ++i)
-    {
-        wxAuiFloatingFrame* f = m_floating_frames.Item(i);
-        if (f == frame)
-        {
-            m_floating_frames.Remove(f);
-            return;
-        }
-    }
-}
-
 // GetPane() looks up a wxAuiPaneInfo structure based
 // on the supplied window pointer.  Upon failure, GetPane()
 // returns an empty wxAuiPaneInfo, a condition which can be checked
@@ -981,6 +941,8 @@ void wxAuiManager::SetArtProvider(wxAuiDockArt* art_provider)
 
 bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
 {
+    wxASSERT_MSG(window, wxT("NULL window ptrs are not allowed"));
+    
     // check if the pane has a valid window
     if (!window)
         return false;
@@ -1014,7 +976,7 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
     if (pinfo.name.empty() || already_exists)
     {
         pinfo.name.Printf(wxT("%08lx%08x%08x%08lx"),
-             ((unsigned long)pinfo.window) & 0xffffffff,
+             wxPtrToUInt(pinfo.window) & 0xffffffff,
              (unsigned int)time(NULL),
 #ifdef __WXWINCE__
              (unsigned int)GetTickCount(),
@@ -1048,6 +1010,22 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
         button.button_id = wxAUI_BUTTON_CLOSE;
         pinfo.buttons.Add(button);
     }
+    
+    if (pinfo.HasGripper())
+    {
+        if (pinfo.window->IsKindOf(CLASSINFO(wxAuiToolBar)))
+        {
+            // prevent duplicate gripper -- both wxAuiManager and wxAuiToolBar
+            // have a gripper control.  The toolbar's built-in gripper
+            // meshes better with the look and feel of the control than ours,
+            // so turn wxAuiManager's gripper off, and the toolbar's on.
+            
+            wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(pinfo.window);
+            pinfo.SetFlag(wxAuiPaneInfo::optionGripper, false);
+            tb->SetGripperVisible(true);
+        }
+    }
+    
 
     if (pinfo.best_size == wxDefaultSize &&
         pinfo.window)
@@ -1079,6 +1057,8 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
         }
     }
 
+
+    
     return true;
 }
 
@@ -1116,6 +1096,8 @@ bool wxAuiManager::AddPane(wxWindow* window,
 bool wxAuiManager::InsertPane(wxWindow* window, const wxAuiPaneInfo& pane_info,
                                 int insert_level)
 {
+    wxASSERT_MSG(window, wxT("NULL window ptrs are not allowed"));
+
     // shift the panes around, depending on the insert level
     switch (insert_level)
     {
@@ -1176,6 +1158,8 @@ bool wxAuiManager::InsertPane(wxWindow* window, const wxAuiPaneInfo& pane_info,
 // method will not destroy the window that is removed.
 bool wxAuiManager::DetachPane(wxWindow* window)
 {
+    wxASSERT_MSG(window, wxT("NULL window ptrs are not allowed"));
+
     int i, count;
     for (i = 0, count = m_panes.GetCount(); i < count; ++i)
     {
@@ -2365,7 +2349,9 @@ wxSizer* wxAuiManager::LayoutAll(wxAuiPaneInfoArray& panes,
 
         if (middle->GetChildren().GetCount() > 0)
             cont->Add(middle, 1, wxEXPAND);
-
+             else
+            delete middle;
+            
 
 
         // find any bottom docks in this layer
@@ -2427,6 +2413,7 @@ void wxAuiManager::GetDockSizeConstraint(double* width_pct, double* height_pct)
 void wxAuiManager::Update()
 {
     m_hover_button = NULL;
+    m_action_part = NULL;
 
     wxSizer* sizer;
     int i, pane_count = m_panes.GetCount();
@@ -2905,7 +2892,8 @@ bool wxAuiManager::DoDrop(wxAuiDockInfoArray& docks,
                     (part->dock->dock_direction != wxAUI_DOCK_CENTER &&
                      part->dock->dock_direction != wxAUI_DOCK_NONE)))
                 {
-                    drop.Float();
+                    if (drop.IsFloatable())
+                        drop.Float();
                 }
 
                 m_skipping = false;
@@ -3273,7 +3261,7 @@ void wxAuiManager::ShowHint(const wxRect& rect)
         // nasty redrawn problems.
         clip.Intersect(m_frame->GetRect());
 
-        screendc.SetClippingRegion(clip);
+        screendc.SetDeviceClippingRegion(clip);
 
         wxBitmap stipple = wxPaneCreateStippleBitmap();
         wxBrush brush(stipple);
@@ -3606,7 +3594,6 @@ void wxAuiManager::OnFloatingPaneMoved(wxWindow* wnd, wxDirection dir)
     wxPoint frame_pos = pane.frame->GetPosition();
     wxPoint action_offset(pt.x-frame_pos.x, pt.y-frame_pos.y);
 
-
     // if a key modifier is pressed while dragging the frame,
     // don't dock the window
     if (CanDockPanel(pane))
@@ -4219,17 +4206,21 @@ void wxAuiManager::OnLeftUp(wxMouseEvent& event)
     {
         m_hover_button = NULL;
         m_frame->ReleaseMouse();
-        UpdateButtonOnScreen(m_action_part, event);
-
-        // make sure we're still over the item that was originally clicked
-        if (m_action_part == HitTest(event.GetX(), event.GetY()))
+        
+        if (m_action_part)
         {
-            // fire button-click event
-            wxAuiManagerEvent e(wxEVT_AUI_PANE_BUTTON);
-            e.SetManager(this);
-            e.SetPane(m_action_part->pane);
-            e.SetButton(m_action_part->button->button_id);
-            ProcessMgrEvent(e);
+            UpdateButtonOnScreen(m_action_part, event);
+
+            // make sure we're still over the item that was originally clicked
+            if (m_action_part == HitTest(event.GetX(), event.GetY()))
+            {
+                // fire button-click event
+                wxAuiManagerEvent e(wxEVT_AUI_PANE_BUTTON);
+                e.SetManager(this);
+                e.SetPane(m_action_part->pane);
+                e.SetButton(m_action_part->button->button_id);
+                ProcessMgrEvent(e);
+            }
         }
     }
     else if (m_action == actionClickCaption)
@@ -4292,20 +4283,23 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
 
     if (m_action == actionResize)
     {
-        wxPoint pos = m_action_part->rect.GetPosition();
-        if (m_action_part->orientation == wxHORIZONTAL)
-            pos.y = wxMax(0, event.m_y - m_action_offset.y);
-        else
-            pos.x = wxMax(0, event.m_x - m_action_offset.x);
+        if (m_action_part)
+        {
+            wxPoint pos = m_action_part->rect.GetPosition();
+            if (m_action_part->orientation == wxHORIZONTAL)
+                pos.y = wxMax(0, event.m_y - m_action_offset.y);
+            else
+                pos.x = wxMax(0, event.m_x - m_action_offset.x);
 
-        wxRect rect(m_frame->ClientToScreen(pos),
-                    m_action_part->rect.GetSize());
+            wxRect rect(m_frame->ClientToScreen(pos),
+                        m_action_part->rect.GetSize());
 
-        wxScreenDC dc;
-        if (!m_action_hintrect.IsEmpty())
-            DrawResizeHint(dc, m_action_hintrect);
-        DrawResizeHint(dc, rect);
-        m_action_hintrect = rect;
+            wxScreenDC dc;
+            if (!m_action_hintrect.IsEmpty())
+                DrawResizeHint(dc, m_action_hintrect);
+            DrawResizeHint(dc, rect);
+            m_action_hintrect = rect;
+        }
     }
     else if (m_action == actionClickCaption)
     {
@@ -4315,8 +4309,9 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
         // caption has been clicked.  we need to check if the mouse
         // is now being dragged. if it is, we need to change the
         // mouse action to 'drag'
-        if (abs(event.m_x - m_action_start.x) > drag_x_threshold ||
-            abs(event.m_y - m_action_start.y) > drag_y_threshold)
+        if (m_action_part &&
+            (abs(event.m_x - m_action_start.x) > drag_x_threshold ||
+             abs(event.m_y - m_action_start.y) > drag_y_threshold))
         {
             wxAuiPaneInfo* pane_info = m_action_part->pane;