Class: wxSplitterWindow
A wxSplitterWindow manages one or two subwindows, allowing the user to change the position of a sash.
The following fragment shows how to create a splitter window, creating two subwindows and hiding one of them.
splitter = new wxSplitterWindow(this, 0, 0, 400, 400, wxSP_3D);
leftCanvas = new MyCanvas(splitter);
leftCanvas->SetBackground(wxRED_BRUSH);
leftCanvas->SetScrollbars(20, 20, 50, 50, 4, 4);
rightCanvas = new MyCanvas(splitter);
rightCanvas->SetBackground(wxCYAN_BRUSH);
rightCanvas->SetScrollbars(20, 20, 50, 50, 4, 4);
rightCanvas->Show(FALSE);
splitter->Initialize(leftCanvas);
// Set this to prevent unsplitting
// splitter->SetMinimumPaneSize(20);
The next fragment shows how the splitter window can be manipulated after creation.
void MyFrame::OnMenuCommand(int id)
{
switch (id)
{
case SPLIT_VERTICAL :
if ( splitter->IsSplit() )
splitter->Unsplit();
leftCanvas->Show(TRUE);
rightCanvas->Show(TRUE);
splitter->SplitVertically( leftCanvas, rightCanvas );
break;
case SPLIT_HORIZONTAL :
if ( splitter->IsSplit() )
splitter->Unsplit();
leftCanvas->Show(TRUE);
rightCanvas->Show(TRUE);
splitter->SplitHorizontally( leftCanvas, rightCanvas );
break;
case SPLIT_UNSPLIT :
if ( splitter->IsSplit() )
splitter->Unsplit();
break;
case SPLIT_QUIT:
this->Close(TRUE);
break;
default:
break;
}
}