added wxAuiNotebook::Split(); hooked up wxAuiMDIParentFrame::Tile() to it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -494,7 +494,14 @@ public:
|
|||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0);
|
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,
|
bool AddPage(wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
@@ -509,7 +516,9 @@ public:
|
|||||||
bool DeletePage(size_t page);
|
bool DeletePage(size_t page);
|
||||||
bool RemovePage(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);
|
bool SetPageText(size_t page, const wxString& text);
|
||||||
wxString GetPageText(size_t page_idx) const;
|
wxString GetPageText(size_t page_idx) const;
|
||||||
@@ -520,17 +529,8 @@ public:
|
|||||||
size_t SetSelection(size_t new_page);
|
size_t SetSelection(size_t new_page);
|
||||||
int GetSelection() const;
|
int GetSelection() const;
|
||||||
|
|
||||||
size_t GetPageCount() const;
|
virtual void Split(size_t page, int direction);
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// these can be overridden
|
// these can be overridden
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
virtual wxAuiMDIClientWindow *OnCreateClient();
|
virtual wxAuiMDIClientWindow *OnCreateClient();
|
||||||
|
|
||||||
virtual void Cascade() { /* Has no effect */ }
|
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 ArrangeIcons() { /* Has no effect */ }
|
||||||
virtual void ActivateNext();
|
virtual void ActivateNext();
|
||||||
virtual void ActivatePrevious();
|
virtual void ActivatePrevious();
|
||||||
|
@@ -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)
|
void wxAuiNotebook::OnSize(wxSizeEvent& evt)
|
||||||
{
|
{
|
||||||
UpdateHintWindowSize();
|
UpdateHintWindowSize();
|
||||||
|
@@ -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
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user