as I am still a wxNewbe, I am stuck again...
I would like to have a config-frame (like that one in Netscape or VLC) for my Program, so this was my try:
Code: Select all
enum
{
ID_BUTTON_SKIN = (wxID_HIGHEST+1),
};
BEGIN_EVENT_TABLE(config_frame, wxFrame)
END_EVENT_TABLE()
config_frame::config_frame(wxFrame *frame, const wxString& title)
:wxFrame((wxFrame *)NULL, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxSize(10, 10) )
{
// get a vertical top sizer
wxSizer* my_sizer=new wxBoxSizer(wxVERTICAL);
// get two child-sizers
wxSizer* my_sizer_bottom=new wxBoxSizer(wxHORIZONTAL);
wxSizer* my_sizer_above =new wxBoxSizer(wxVERTICAL);
// get a treebook
wxTreebook* my_treebook = new wxTreebook( this, -1, wxDefaultPosition, wxSize(480,480), 0, wxT("name" ) );
// ========================================================================
// Define first page of Treebook for General setup parameters
// ========================================================================
wxPanel* my_panel1 = new wxPanel(this);
wxBoxSizer* my_panel1_sizer0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* my_panel1_sizer1 = new wxBoxSizer( wxHORIZONTAL );
wxTextCtrl* skin_textctrl = new wxTextCtrl( my_panel1,
-1,
wxT("Default"),
wxDefaultPosition,
wxSize(256,24),
0,
wxDefaultValidator,
wxT("name") );
wxButton* skin_button1 = new wxButton( my_panel1, ID_BUTTON_SKIN, wxT("Select Skin"), wxT("name") );
my_panel1_sizer1->Add( skin_textctrl );
my_panel1_sizer1->Add( skin_button1 );
my_panel1_sizer0->Add( my_panel1_sizer1 );
my_panel1->SetSizer( my_panel1_sizer0 );
// leave these empty for the first try...
wxPanel* my_panel2 = new wxPanel(this);
wxPanel* my_panel3 = new wxPanel(this);
wxPanel* my_panel4 = new wxPanel(this);
my_treebook->AddPage( my_panel1, wxT("plane1"), false, 0 );
my_treebook->AddPage( my_panel2, wxT("plane2"), false, 0 );
my_treebook->AddPage( my_panel3, wxT("plane3"), false, 0 );
my_treebook->AddPage( my_panel4, wxT("plane4"), false, 0 );
my_sizer_above->Add( my_treebook, 1, wxEXPAND );
my_sizer_above->Layout();
my_sizer_above->Fit(this);
my_sizer_above->SetSizeHints(this);
// Add a Button to bottom sizer
my_sizer_bottom->Add(
new wxButton(this, wxID_ABORT, wxT("Cancel")),
0, // make vertically stretchable
0| // make horizontally stretchable
wxALL, // and make border all around
4 ); // set border width to 4
my_sizer_bottom->Add(
new wxButton(this, wxID_OK, wxT("OK")),
0, // make vertically stretchable
0| // make horizontally stretchable
wxALL, // and make border all around
4 ); // set border width to 4
my_sizer->Add( my_sizer_above );
my_sizer->Add( my_sizer_bottom );
my_sizer->Layout();
my_sizer->Fit(this);
my_sizer->SetSizeHints(this);
// Connect widgets to event-loop
Connect(ID_BUTTON_SKIN,
wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction)&config_frame::OnButtonPressed);
Connect(wxID_ABORT,
wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction)&config_frame::OnButtonPressed);
Connect(wxID_OK,
wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction)&config_frame::OnButtonPressed);
// Show frame
Show();
}
void config_frame::OnButtonPressed(wxCommandEvent& event)
{
std::cerr << "Button pressed in Config-screen...\n";
std::cerr << event.GetId() << "\n";
}
It seems like I have not fully understood, what I need to do here, to make this work... (BTW: I have taken a peek at the notebook-sample, but because of the lot's of #ifdefs inside I am as clueless as before... *sigh*)
Any help would be greatly appreciated...
Stefan