need help with wxSplitterWindow inside another wxSplitterWindow

Ram Bhamidipaty rambham at gmail.com
Sun Mar 18 10:43:40 PDT 2007


I need some help with wxSplitterWindow and wxTreeCtrl. I need to
have three "areas" in my app. The left area needs to have some
buttons and the middle and right area should have a tree control.

I've written the code do that but I can't find a way to make all
the "areas" be fully visible when the app starts. My app needs to
use wxWidgets on top of Motif.

My code is at the bottom of this mesage.

The problem I'm having is getting the two tree controls to be fully
visible when the app first starts. I also want to make sure that the
sash between the two tree controls cannot be moved too far to the
right or left.

Thanks for any help.
-Ram


----------------------------------------------
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/splitter.h"
#include "wx/treectrl.h"
#include "wx/panel.h"
#include "wx/radiobut.h"

class MyApp : public wxApp {
public:
  virtual bool OnInit();
};

class MyFrame : public wxFrame {
 public:
  MyFrame(const wxString& title);

 private:
  wxSplitterWindow *split1;
  wxSplitterWindow *split2;
  wxPanel          *m_left;
  wxRadioButton    *button_r1;
  wxRadioButton    *button_r2;
  wxTreeCtrl       *tree_l;
  wxTreeCtrl       *tree_r;
};

IMPLEMENT_APP(MyApp)

bool
MyApp::OnInit()
{
  if ( !wxApp::OnInit() )
    return false;

  MyFrame *frame = new MyFrame(_T("My Tool"));
  frame->Show(true);
  return true;
}

MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title)
{
  split1 = new wxSplitterWindow(this, wxID_ANY);
  split2 = new wxSplitterWindow(split1, wxID_ANY);

  split1->SetSashGravity(0.20);

  m_left = new wxPanel(split1, wxID_ANY);
  button_r1 =  new wxRadioButton(m_left, wxID_ANY,
				  wxString("radio1"), wxPoint(20,20));
  button_r2 = new wxRadioButton(m_left, wxID_ANY,
				  wxString("radio2"), wxPoint(20,60));

  tree_l   = new wxTreeCtrl(split2, wxID_ANY);
  wxTreeItemId root1 = tree_l->AddRoot(wxString("Root1"));
  tree_l->AppendItem(root1, wxString("root1-item1"));
  tree_l->AppendItem(root1, wxString("root1-item2"));

  tree_r = new wxTreeCtrl(split2, wxID_ANY);
  wxTreeItemId root2 = tree_r->AddRoot(wxString("Root1"));
  tree_r->AppendItem(root2, wxString("root2-item1"));
  tree_r->AppendItem(root2, wxString("root2-item2"));


  split2->SetSashGravity(0.5);
  tree_l->Show(true);
  tree_r->Show(true);
  split2->SplitVertically(tree_l, tree_r);

  split1->SplitVertically(m_left, split2);
}
----------------------------------------------




More information about the wx-users mailing list