X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6718d773ad43f5d7708b14de338131e72f20e99a..4f3449b43280a855e57280e6848610ea9fdaa3bb:/samples/splitter/splitter.cpp diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index 054e799a9c..4bde92e99a 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -35,8 +35,9 @@ public: class MySplitterWindow : public wxSplitterWindow { public: - MySplitterWindow(wxFrame *parent, wxWindowID id) - : wxSplitterWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSP_3D | wxSP_LIVE_UPDATE) + MySplitterWindow(wxFrame *parent, wxWindowID id) + : wxSplitterWindow(parent, id, wxDefaultPosition, wxDefaultSize, + wxSP_3D | wxSP_LIVE_UPDATE | wxCLIP_CHILDREN) { m_frame = parent; } @@ -45,14 +46,14 @@ public: { if ( !wxSplitterWindow::OnSashPositionChange(newSashPosition) ) return FALSE; - + wxString str; str.Printf( _T("Sash position = %d"), newSashPosition); m_frame->SetStatusText(str); return TRUE; } - + private: wxFrame *m_frame; }; @@ -90,8 +91,8 @@ DECLARE_EVENT_TABLE() class MyCanvas: public wxScrolledWindow { public: - MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h, const wxString &name); - virtual ~MyCanvas(); + MyCanvas(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxString& name = ""); + virtual ~MyCanvas(); virtual void OnDraw(wxDC& dc); @@ -126,7 +127,7 @@ bool MyApp::OnInit(void) // Show the frame frame->Show(TRUE); - + SetTopWindow(frame); return TRUE; @@ -145,8 +146,10 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) END_EVENT_TABLE() // My frame constructor -MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size): - wxFrame(frame, SPLITTER_FRAME, title, pos, size) +MyFrame::MyFrame(wxFrame* frame, const wxString& title, + const wxPoint& pos, const wxSize& size) + : wxFrame(frame, SPLITTER_FRAME, title, pos, size, + wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { CreateStatusBar(2); @@ -166,21 +169,29 @@ MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, cons SetMenuBar(menuBar); m_splitter = new MySplitterWindow(this, SPLITTER_WINDOW); - + +#if 0 wxSize sz( m_splitter->GetSize() ); wxLogMessage( "Initial splitter size: %d %d\n", (int)sz.x, (int)sz.y ); +#endif // 0 - m_leftCanvas = new MyCanvas(m_splitter, CANVAS1, 0, 0, 400, 400, "Test1" ); + m_leftCanvas = new MyCanvas(m_splitter, CANVAS1, wxPoint(0, 0), wxSize(400, 400), "Test1" ); m_leftCanvas->SetBackgroundColour(*wxRED); m_leftCanvas->SetScrollbars(20, 20, 50, 50); m_leftCanvas->SetCursor(wxCursor(wxCURSOR_MAGNIFIER)); - m_rightCanvas = new MyCanvas(m_splitter, CANVAS2, 0, 0, 400, 400, "Test2" ); + m_rightCanvas = new MyCanvas(m_splitter, CANVAS2, wxPoint(0, 0), wxSize(400, 400), "Test2" ); m_rightCanvas->SetBackgroundColour(*wxCYAN); m_rightCanvas->SetScrollbars(20, 20, 50, 50); - m_rightCanvas->Show(FALSE); + // you can also do this to start with a single window +#if 0 + m_rightCanvas->Show(FALSE); m_splitter->Initialize(m_leftCanvas); +#else + m_splitter->SplitVertically(m_leftCanvas, m_rightCanvas, 100); +#endif + SetStatusText("Min pane size = 0", 1); } @@ -256,8 +267,8 @@ void MyFrame::UpdatePosition() SetStatusText(str); } -MyCanvas::MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h, const wxString &name ) : - wxScrolledWindow(parent, id, wxPoint(x, y), wxSize(w, h), 0, name ) +MyCanvas::MyCanvas(wxWindow* parent, wxWindowID id, const wxPoint& point, const wxSize& size, const wxString &name ) : + wxScrolledWindow(parent, id, point, size, 0, name ) { }