]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/auibook.cpp
Restore setting focus to generic wxDataViewCtrl on any mouse click.
[wxWidgets.git] / src / aui / auibook.cpp
index 3d423f25e68c51f035079e0d3091bfcbe3d4b676..30691c1c036a1e581a046a2e0c10abb84fbda6b9 100644 (file)
@@ -24,7 +24,8 @@
 
 #ifndef WX_PRECOMP
     #include "wx/settings.h"
 
 #ifndef WX_PRECOMP
     #include "wx/settings.h"
-    #include "wx/clientdc.h"
+    #include "wx/dcclient.h"
+    #include "wx/dcmemory.h"
 #endif
 
 #include "wx/aui/tabmdi.h"
 #endif
 
 #include "wx/aui/tabmdi.h"
@@ -526,10 +527,8 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
     int left_buttons_width = 0;
     int right_buttons_width = 0;
 
     int left_buttons_width = 0;
     int right_buttons_width = 0;
 
-    int offset = 0;
-
     // draw the buttons on the right side
     // draw the buttons on the right side
-    offset = m_rect.x + m_rect.width;
+    int offset = m_rect.x + m_rect.width;
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
@@ -742,10 +741,8 @@ bool wxAuiTabContainer::IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWin
     int left_buttons_width = 0;
     int right_buttons_width = 0;
 
     int left_buttons_width = 0;
     int right_buttons_width = 0;
 
-    int offset = 0;
-
     // calculate size of the buttons on the right side
     // calculate size of the buttons on the right side
-    offset = m_rect.x + m_rect.width;
+    int offset = m_rect.x + m_rect.width;
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
@@ -924,7 +921,7 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y,
 static void ShowWnd(wxWindow* wnd, bool show)
 {
 #if wxUSE_MDI
 static void ShowWnd(wxWindow* wnd, bool show)
 {
 #if wxUSE_MDI
-    if (wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
+    if (wxDynamicCast(wnd, wxAuiMDIChildFrame))
     {
         wxAuiMDIChildFrame* cf = (wxAuiMDIChildFrame*)wnd;
         cf->DoShow(show);
     {
         wxAuiMDIChildFrame* cf = (wxAuiMDIChildFrame*)wnd;
         cf->DoShow(show);
@@ -1049,8 +1046,8 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt)
         // wxAuiNotebooks always want to receive this event
         // even if the tab is already active, because they may
         // have multiple tab controls
         // wxAuiNotebooks always want to receive this event
         // even if the tab is already active, because they may
         // have multiple tab controls
-        if (new_selection != GetActivePage() ||
-            GetParent()->IsKindOf(CLASSINFO(wxAuiNotebook)))
+        if ((new_selection != GetActivePage() ||
+            wxDynamicCast(GetParent(), wxAuiNotebook)) && !m_hoverButton)
         {
             wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId);
             e.SetSelection(new_selection);
         {
             wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId);
             e.SetSelection(new_selection);
@@ -1096,11 +1093,11 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt)
     {
         m_isDragging = false;
 
     {
         m_isDragging = false;
 
-        wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, m_windowId);
-        evt.SetSelection(GetIdxFromWindow(m_clickTab));
-        evt.SetOldSelection(evt.GetSelection());
-        evt.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(evt);
+        wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, m_windowId);
+        e.SetSelection(GetIdxFromWindow(m_clickTab));
+        e.SetOldSelection(e.GetSelection());
+        e.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(e);
 
         return;
     }
 
         return;
     }
@@ -1124,11 +1121,11 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt)
 
         if (!(m_pressedButton->curState & wxAUI_BUTTON_STATE_DISABLED))
         {
 
         if (!(m_pressedButton->curState & wxAUI_BUTTON_STATE_DISABLED))
         {
-            wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId);
-            evt.SetSelection(GetIdxFromWindow(m_clickTab));
-            evt.SetInt(m_pressedButton->id);
-            evt.SetEventObject(this);
-            GetEventHandler()->ProcessEvent(evt);
+            wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId);
+            e.SetSelection(GetIdxFromWindow(m_clickTab));
+            e.SetInt(m_pressedButton->id);
+            e.SetEventObject(this);
+            GetEventHandler()->ProcessEvent(e);
         }
 
         m_pressedButton = NULL;
         }
 
         m_pressedButton = NULL;
@@ -1236,17 +1233,32 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt)
         }
     }
 
         }
     }
 
+    wxWindow* wnd = NULL;
 
 
+#if wxUSE_TOOLTIPS
+   if (evt.Moving() && TabHitTest(evt.m_x, evt.m_y, &wnd))
+    {
+        wxString tooltip(m_pages[GetIdxFromWindow(wnd)].tooltip);
+
+        // If the text changes, set it else, keep old, to avoid
+        // 'moving tooltip' effect
+        if (GetToolTipText() != tooltip)
+            SetToolTip(tooltip);
+    }
+    else
+        UnsetToolTip();
+#endif
+   
     if (!evt.LeftIsDown() || m_clickPt == wxDefaultPosition)
         return;
 
     if (m_isDragging)
     {
     if (!evt.LeftIsDown() || m_clickPt == wxDefaultPosition)
         return;
 
     if (m_isDragging)
     {
-        wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, m_windowId);
-        evt.SetSelection(GetIdxFromWindow(m_clickTab));
-        evt.SetOldSelection(evt.GetSelection());
-        evt.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(evt);
+        wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, m_windowId);
+        e.SetSelection(GetIdxFromWindow(m_clickTab));
+        e.SetOldSelection(e.GetSelection());
+        e.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(e);
         return;
     }
 
         return;
     }
 
@@ -1257,11 +1269,11 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt)
     if (abs(pos.x - m_clickPt.x) > drag_x_threshold ||
         abs(pos.y - m_clickPt.y) > drag_y_threshold)
     {
     if (abs(pos.x - m_clickPt.x) > drag_x_threshold ||
         abs(pos.y - m_clickPt.y) > drag_y_threshold)
     {
-        wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, m_windowId);
-        evt.SetSelection(GetIdxFromWindow(m_clickTab));
-        evt.SetOldSelection(evt.GetSelection());
-        evt.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(evt);
+        wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, m_windowId);
+        e.SetSelection(GetIdxFromWindow(m_clickTab));
+        e.SetOldSelection(e.GetSelection());
+        e.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(e);
 
         m_isDragging = true;
     }
 
         m_isDragging = true;
     }
@@ -1531,7 +1543,10 @@ public:
 
         for (i = 0; i < page_count; ++i)
         {
 
         for (i = 0; i < page_count; ++i)
         {
-            int height = m_rect.height - m_tabCtrlHeight;
+            wxAuiNotebookPage& page = pages.Item(i);
+            int border_space = m_tabs->GetArtProvider()->GetAdditionalBorderSpace(page.window);
+
+            int height = m_rect.height - m_tabCtrlHeight - border_space;
             if ( height < 0 )
             {
                 // avoid passing negative height to wxWindow::SetSize(), this
             if ( height < 0 )
             {
                 // avoid passing negative height to wxWindow::SetSize(), this
@@ -1539,21 +1554,25 @@ public:
                 height = 0;
             }
 
                 height = 0;
             }
 
-            wxAuiNotebookPage& page = pages.Item(i);
             if (m_tabs->GetFlags() & wxAUI_NB_BOTTOM)
             {
             if (m_tabs->GetFlags() & wxAUI_NB_BOTTOM)
             {
-                page.window->SetSize(m_rect.x, m_rect.y, m_rect.width, height);
+                page.window->SetSize(m_rect.x + border_space,
+                                     m_rect.y + border_space,
+                                     m_rect.width - 2 * border_space,
+                                     height);
             }
             else //TODO: if (GetFlags() & wxAUI_NB_TOP)
             {
             }
             else //TODO: if (GetFlags() & wxAUI_NB_TOP)
             {
-                page.window->SetSize(m_rect.x, m_rect.y + m_tabCtrlHeight,
-                                     m_rect.width, height);
+                page.window->SetSize(m_rect.x + border_space,
+                                     m_rect.y + m_tabCtrlHeight,
+                                     m_rect.width - 2 * border_space,
+                                     height);
             }
             // TODO: else if (GetFlags() & wxAUI_NB_LEFT){}
             // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){}
 
 #if wxUSE_MDI
             }
             // TODO: else if (GetFlags() & wxAUI_NB_LEFT){}
             // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){}
 
 #if wxUSE_MDI
-            if (page.window->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
+            if (wxDynamicCast(page.window, wxAuiMDIChildFrame))
             {
                 wxAuiMDIChildFrame* wnd = (wxAuiMDIChildFrame*)page.window;
                 wnd->ApplyMDIChildFrameRect();
             {
                 wxAuiMDIChildFrame* wnd = (wxAuiMDIChildFrame*)page.window;
                 wnd->ApplyMDIChildFrameRect();
@@ -1972,7 +1991,7 @@ bool wxAuiNotebook::DeletePage(size_t page_idx)
 
 #if wxUSE_MDI
     // actually destroy the window now
 
 #if wxUSE_MDI
     // actually destroy the window now
-    if (wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
+    if (wxDynamicCast(wnd, wxAuiMDIChildFrame))
     {
         // delete the child frame with pending delete, as is
         // customary with frame windows
     {
         // delete the child frame with pending delete, as is
         // customary with frame windows
@@ -2125,6 +2144,37 @@ wxString wxAuiNotebook::GetPageText(size_t page_idx) const
     return page_info.caption;
 }
 
     return page_info.caption;
 }
 
+bool wxAuiNotebook::SetPageToolTip(size_t page_idx, const wxString& text)
+{
+    if (page_idx >= m_tabs.GetPageCount())
+        return false;
+
+    // update our own tab catalog
+    wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx);
+    page_info.tooltip = text;
+
+    wxAuiTabCtrl* ctrl;
+    int ctrl_idx;
+    if (!FindTab(page_info.window, &ctrl, &ctrl_idx))
+        return false;
+
+    wxAuiNotebookPage& info = ctrl->GetPage(ctrl_idx);
+    info.tooltip = text;
+
+    // NB: we don't update the tooltip if it is already being displayed, it
+    //     typically never happens, no need to code that
+    return true;
+}
+
+wxString wxAuiNotebook::GetPageToolTip(size_t page_idx) const
+{
+    if (page_idx >= m_tabs.GetPageCount())
+        return wxString();
+
+    const wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx);
+    return page_info.tooltip;
+}
+
 bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmap& bitmap)
 {
     if (page_idx >= m_tabs.GetPageCount())
 bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmap& bitmap)
 {
     if (page_idx >= m_tabs.GetPageCount())
@@ -2514,11 +2564,11 @@ void wxAuiNotebook::OnTabDragMotion(wxAuiNotebookEvent& evt)
             return;
 
         // make sure we are not over the hint window
             return;
 
         // make sure we are not over the hint window
-        if (!tab_ctrl->IsKindOf(CLASSINFO(wxFrame)))
+        if (!wxDynamicCast(tab_ctrl, wxFrame))
         {
             while (tab_ctrl)
             {
         {
             while (tab_ctrl)
             {
-                if (tab_ctrl->IsKindOf(CLASSINFO(wxAuiTabCtrl)))
+                if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl))
                     break;
                 tab_ctrl = tab_ctrl->GetParent();
             }
                     break;
                 tab_ctrl = tab_ctrl->GetParent();
             }
@@ -2600,7 +2650,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt)
 
         while (tab_ctrl)
         {
 
         while (tab_ctrl)
         {
-            if (tab_ctrl->IsKindOf(CLASSINFO(wxAuiTabCtrl)))
+            if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl))
                 break;
             tab_ctrl = tab_ctrl->GetParent();
         }
                 break;
             tab_ctrl = tab_ctrl->GetParent();
         }
@@ -3050,7 +3100,7 @@ void wxAuiNotebook::OnTabButton(wxAuiNotebookEvent& evt)
 
 
 #if wxUSE_MDI
 
 
 #if wxUSE_MDI
-            if (close_wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
+            if (wxDynamicCast(close_wnd, wxAuiMDIChildFrame))
             {
                 close_wnd->Close();
             }
             {
                 close_wnd->Close();
             }
@@ -3188,34 +3238,6 @@ int wxAuiNotebook::GetHeightForPageHeight(int pageHeight)
     return tabCtrlHeight + pageHeight + decorHeight;
 }
 
     return tabCtrlHeight + pageHeight + decorHeight;
 }
 
-// Advances the selection, generation page selection events
-void wxAuiNotebook::AdvanceSelection(bool forward)
-{
-    if (GetPageCount() <= 1)
-        return;
-
-    int currentSelection = GetSelection();
-
-    if (forward)
-    {
-        if (currentSelection == (int) (GetPageCount() - 1))
-            return;
-        else if (currentSelection == -1)
-            currentSelection = 0;
-        else
-            currentSelection ++;
-    }
-    else
-    {
-        if (currentSelection <= 0)
-            return;
-        else
-            currentSelection --;
-    }
-
-    SetSelection(currentSelection);
-}
-
 // Shows the window menu
 bool wxAuiNotebook::ShowWindowMenu()
 {
 // Shows the window menu
 bool wxAuiNotebook::ShowWindowMenu()
 {
@@ -3237,11 +3259,11 @@ bool wxAuiNotebook::ShowWindowMenu()
         return false;
 }
 
         return false;
 }
 
-void wxAuiNotebook::Thaw()
+void wxAuiNotebook::DoThaw()
 {
     DoSizing();
 
 {
     DoSizing();
 
-    wxControl::Thaw();
+    wxBookCtrlBase::DoThaw();
 }
 
 void wxAuiNotebook::SetPageSize (const wxSize& WXUNUSED(size))
 }
 
 void wxAuiNotebook::SetPageSize (const wxSize& WXUNUSED(size))
@@ -3266,13 +3288,6 @@ bool wxAuiNotebook::SetPageImage(size_t n, int imageId)
     return SetPageBitmap(n, GetImageList()->GetBitmap(imageId));
 }
 
     return SetPageBitmap(n, GetImageList()->GetBitmap(imageId));
 }
 
-wxWindow* wxAuiNotebook::GetCurrentPage () const
-{
-    const int sel = GetSelection();
-
-    return sel == wxNOT_FOUND ? NULL : GetPage(sel);
-}
-
 int wxAuiNotebook::ChangeSelection(size_t n)
 {
     return DoModifySelection(n, false);
 int wxAuiNotebook::ChangeSelection(size_t n)
 {
     return DoModifySelection(n, false);