]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxAuiNotebook::Split(); hooked up wxAuiMDIParentFrame::Tile() to it
authorBenjamin Williams <bwilliams@kirix.com>
Tue, 28 Nov 2006 15:25:59 +0000 (15:25 +0000)
committerBenjamin Williams <bwilliams@kirix.com>
Tue, 28 Nov 2006 15:25:59 +0000 (15:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/aui/auibook.h
include/wx/aui/tabmdi.h
src/aui/auibook.cpp
src/aui/tabmdi.cpp

index fe6ba7da57690b78abf648c0ef31b6b6233139b5..15eae356c0925c5567981b12fe3bda10fd80583b 100644 (file)
@@ -494,7 +494,14 @@ public:
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = 0);
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = 0);
-
+                
+    void SetWindowStyleFlag(long style);
+    void SetArtProvider(wxAuiTabArt* art);
+    wxAuiTabArt* GetArtProvider() const;
+    
+    virtual void SetUniformBitmapSize(const wxSize& size);
+    virtual void SetTabCtrlHeight(int height);
     bool AddPage(wxWindow* page,
                  const wxString& caption,
                  bool select = false,
     bool AddPage(wxWindow* page,
                  const wxString& caption,
                  bool select = false,
@@ -509,7 +516,9 @@ public:
     bool DeletePage(size_t page);
     bool RemovePage(size_t page);
     
     bool DeletePage(size_t page);
     bool RemovePage(size_t page);
     
-    void SetWindowStyleFlag(long style);
+    size_t GetPageCount() const;
+    wxWindow* GetPage(size_t page_idx) const;
+    int GetPageIndex(wxWindow* page_wnd) const;
 
     bool SetPageText(size_t page, const wxString& text);
     wxString GetPageText(size_t page_idx) const;
 
     bool SetPageText(size_t page, const wxString& text);
     wxString GetPageText(size_t page_idx) const;
@@ -520,17 +529,8 @@ public:
     size_t SetSelection(size_t new_page);
     int GetSelection() const;
 
     size_t SetSelection(size_t new_page);
     int GetSelection() const;
 
-    size_t GetPageCount() const;
-    wxWindow* GetPage(size_t page_idx) const;
-
-    int GetPageIndex(wxWindow* page_wnd) const;
-
-    void SetArtProvider(wxAuiTabArt* art);
-    wxAuiTabArt* GetArtProvider() const;
-    
-    virtual void SetUniformBitmapSize(const wxSize& size);
-    virtual void SetTabCtrlHeight(int height);
-    
+    virtual void Split(size_t page, int direction);
+   
 protected:
 
     // these can be overridden
 protected:
 
     // these can be overridden
index 018d4ea8fc612715e92878d3b490f7c56ad149c1..43b9479bb7874823489cda6527bf82f14d3cd411 100644 (file)
@@ -80,7 +80,7 @@ public:
     virtual wxAuiMDIClientWindow *OnCreateClient();
 
     virtual void Cascade() { /* Has no effect */ }
     virtual wxAuiMDIClientWindow *OnCreateClient();
 
     virtual void Cascade() { /* Has no effect */ }
-    virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { }
+    virtual void Tile(wxOrientation orient = wxHORIZONTAL);
     virtual void ArrangeIcons() { /* Has no effect */ }
     virtual void ActivateNext();
     virtual void ActivatePrevious();
     virtual void ArrangeIcons() { /* Has no effect */ }
     virtual void ActivateNext();
     virtual void ActivatePrevious();
index c050aca7b1ab4febb752e26597ef5371f4822609..87fcc7845443acea9615757eea0405a23f1fc6a5 100644 (file)
@@ -2960,6 +2960,120 @@ bool wxAuiNotebook::FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx)
     return false;
 }
 
     return false;
 }
 
+void wxAuiNotebook::Split(size_t page, int direction)
+{
+    wxSize cli_size = GetClientSize();
+    
+    // get the page's window pointer
+    wxWindow* wnd = GetPage(page);
+    if (!wnd)
+        return;
+    
+    // notebooks with 1 or less pages can't be split
+    if (GetPageCount() < 2)
+        return;
+        
+    // find out which tab control the page currently belongs to
+    wxAuiTabCtrl *src_tabs, *dest_tabs;
+    int src_idx = -1;
+    src_tabs = NULL;
+    if (!FindTab(wnd, &src_tabs, &src_idx))
+        return;
+    if (!src_tabs || src_idx == -1)
+        return;
+    
+    // choose a split size
+    wxSize split_size;
+    if (GetPageCount() > 2)
+    {
+        split_size = CalculateNewSplitSize();
+    }
+     else
+    {
+        // because there are two panes, always split them
+        // equally
+        split_size = GetClientSize();
+        split_size.x /= 2;
+        split_size.y /= 2;
+    }
+    
+    
+    // create a new tab frame
+    wxTabFrame* new_tabs = new wxTabFrame;
+    new_tabs->m_rect = wxRect(wxPoint(0,0), split_size);
+    new_tabs->SetTabCtrlHeight(m_tab_ctrl_height);
+    new_tabs->m_tabs = new wxAuiTabCtrl(this,
+                                        m_tab_id_counter++,
+                                        wxDefaultPosition,
+                                        wxDefaultSize,
+                                        wxNO_BORDER);
+    new_tabs->m_tabs->SetArtProvider(m_tabs.GetArtProvider()->Clone());
+    new_tabs->m_tabs->SetFlags(m_flags);
+    dest_tabs = new_tabs->m_tabs;
+
+    // create a pane info structure with the information
+    // about where the pane should be added
+    wxAuiPaneInfo pane_info = wxAuiPaneInfo().Bottom().CaptionVisible(false);
+    wxPoint mouse_pt;
+        
+    if (direction == wxLEFT)
+    {
+        pane_info.Left();
+        mouse_pt = wxPoint(0, cli_size.y/2);
+    }
+     else if (direction == wxRIGHT)
+    {
+        pane_info.Right();
+        mouse_pt = wxPoint(cli_size.x, cli_size.y/2);
+    }
+     else if (direction == wxTOP)
+    {
+        pane_info.Top();
+        mouse_pt = wxPoint(cli_size.x/2, 0);
+    }
+     else if (direction == wxBOTTOM)
+    {
+        pane_info.Bottom();
+        mouse_pt = wxPoint(cli_size.x/2, cli_size.y);
+    }
+        
+    m_mgr.AddPane(new_tabs, pane_info, mouse_pt);
+    m_mgr.Update();
+            
+    // remove the page from the source tabs
+    wxAuiNotebookPage page_info = src_tabs->GetPage(src_idx);
+    page_info.active = false;
+    src_tabs->RemovePage(page_info.window);
+    if (src_tabs->GetPageCount() > 0)
+    {
+        src_tabs->SetActivePage((size_t)0);
+        src_tabs->DoShowHide();
+        src_tabs->Refresh();
+    }
+
+
+    // add the page to the destination tabs
+    dest_tabs->InsertPage(page_info.window, page_info, 0);
+
+    if (src_tabs->GetPageCount() == 0)
+    {
+        RemoveEmptyTabFrames();
+    }
+
+    DoSizing();
+    dest_tabs->DoShowHide();
+    dest_tabs->Refresh();
+
+    // force the set selection function reset the selection
+    m_curpage = -1;
+    
+    // set the active page to the one we just split off
+    SetSelection(m_tabs.GetIdxFromWindow(page_info.window));
+    
+    UpdateHintWindowSize();
+}
+
+
 void wxAuiNotebook::OnSize(wxSizeEvent& evt)
 {
     UpdateHintWindowSize();
 void wxAuiNotebook::OnSize(wxSizeEvent& evt)
 {
     UpdateHintWindowSize();
index dd9046aef829ebb7f13aae9a758fd09f49d1052a..df5d01c82bf6284f2db5afd3a142e0327408b404 100644 (file)
@@ -354,6 +354,26 @@ void wxAuiMDIParentFrame::DoGetClientSize(int* width, int* height) const
     wxFrame::DoGetClientSize(width, height);
 }
 
     wxFrame::DoGetClientSize(width, height);
 }
 
+void wxAuiMDIParentFrame::Tile(wxOrientation orient)
+{
+    wxAuiMDIClientWindow* client_window = GetClientWindow();
+    wxASSERT_MSG(client_window, wxT("Missing MDI Client Window"));
+    
+    int cur_idx = client_window->GetSelection();
+    if (cur_idx == -1)
+        return;
+        
+    if (orient == wxVERTICAL)
+    {
+        client_window->Split(cur_idx, wxLEFT);
+    }
+     else if (orient == wxHORIZONTAL)
+    {
+        client_window->Split(cur_idx, wxTOP);
+    }
+}
+
+
 //-----------------------------------------------------------------------------
 // wxAuiMDIChildFrame
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // wxAuiMDIChildFrame
 //-----------------------------------------------------------------------------