The first issue is that the sash does not appear regardless of the style used- it is always an invisible line that can be dragged but has no other visual clue. Another thread (here) mentions this same behavior so I believe the issue is with wxWidgets, not my code. I can probably live with this by using boxes around the split panels, but this is less than ideal.
The second issue is that there does not appear to be a way to set the initial sash position. No matter what value is passed to the SplitVertically() call it will always set the sash at the minimum pane size. This is a serious issue for me since it essentially breaks my app.
Here is the test code:
Code: Select all
#include <wx/wx.h>
#include <wx/splitter.h>
#include <wx/sizer.h>
class EmptyPanel : public wxPanel
{
public:
EmptyPanel ( wxWindow *parent, std::string label_text ) : wxPanel ( parent )
{
wxStaticBoxSizer *sizer = new wxStaticBoxSizer ( wxVERTICAL, this, "" );
sizer->Add ( new wxStaticText ( sizer->GetStaticBox (), wxID_ANY, label_text ) );
SetSizerAndFit ( sizer );
}
virtual ~EmptyPanel () {};
};
class TestSplitterPanel : public wxPanel
{
public:
TestSplitterPanel ( wxWindow *parent )
: wxPanel ( parent )
{
// wxSP_3D wxSP_THIN_SASH wxSP_3DSASH wxSP_3DBORDER wxSP_BORDER wxSP_NOBORDER wxSP_NO_XP_THEME
long style = wxSP_3D;
wxSplitterWindow *splitter = new wxSplitterWindow ( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
splitter->SetMinimumPaneSize ( 50 );
wxPanel *left = new wxPanel ( splitter );
wxBoxSizer *left_sizer = new wxBoxSizer ( wxVERTICAL );
left_sizer->Add ( new EmptyPanel ( left, "Left Panel" ), 1, wxEXPAND | wxALL, 5 );
left->SetSizer ( left_sizer );
wxPanel *right = new wxPanel ( splitter );
wxBoxSizer *right_sizer = new wxBoxSizer ( wxVERTICAL );
right_sizer->Add ( new EmptyPanel ( right, "Right Panel" ), 1, wxEXPAND | wxALL, 5 );
right->SetSizer ( right_sizer );
splitter->SplitVertically ( left, right, 200 );
//splitter->SetSashInvisible ( false );
wxBoxSizer *sizer = new wxBoxSizer ( wxHORIZONTAL );
sizer->Add ( splitter, 1, wxEXPAND );
SetSizerAndFit ( sizer );
//splitter->SplitVertically (left, right);
}
virtual ~TestSplitterPanel () {};
};
class TestFrame : public wxFrame
{
public:
TestFrame () : wxFrame ( nullptr, -1, "Test" )
{
wxBoxSizer* sizer = new wxBoxSizer ( wxVERTICAL );
sizer->Add ( new TestSplitterPanel ( this ), wxSizerFlags ().Expand ().Proportion ( 1 ) );
SetSizerAndFit ( sizer );
SetSize ( 600, 400 );
Center ();
};
virtual ~TestFrame () {};
private:
};
class TestApp : public wxApp
{
public:
TestApp () {};
virtual ~TestApp () {};
virtual bool OnInit () override
{
wxFrame* mainFrame = new TestFrame ();
mainFrame->Show ( true );
return true;
};
};
wxIMPLEMENT_APP ( TestApp );