I'm working on my first program with wxWidgets and trying to lay out controls onto a panel with two tool bars for this skeleton program, and the frame should be resizable. This is the cpp file shown below and I'm sure that the problem is a newbie issue but when I try to change the window size the panel size remains fixed. I changed the colour of the panel so it can easily be seen. I think there may be an issue with the order of the sizers or how I'm using them. Can anyone see what might be wrong? Thank you.
Code: Select all
#include "MainWindow.h"
#include "wx/toolbar.h"
#include <wx/artprov.h>
//#include "testicon.xpm"
#include "dish32.xpm"
// Static Event Table
wxBEGIN_EVENT_TABLE(MainWindow, wxFrame)
EVT_TEXT_ENTER(wxID_ANY, MainWindow::OnRadiusEntered)
wxEND_EVENT_TABLE()
MainWindow::MainWindow(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name):
wxFrame(parent, id, title, pos, wxSize(500, 400), style, name)
{
// Declare panel for controls
wxPanel *panel = new wxPanel(this, -1);
panel->SetBackgroundColour(wxColor(100, 200, 200));
// Set frame icon
wxIcon frameicon(dish32_xpm);
SetIcon(frameicon);
// Set menu bar
wxMenu *fileMenu = new wxMenu;
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog"));
fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(menuBar);
// Set toolbar1
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
toolbar1 = new wxToolBar(panel, wxID_ANY);
// Insert toolbar1 = AddTool...
toolbar1->AddTool(wxID_EXIT, _("Exit application"), wxArtProvider::GetBitmap("wxART_QUIT"));
toolbar1->Realize();
toolbar2 = new wxToolBar(panel, wxID_ANY);
// Insert toolbar2 = AddTool...
toolbar2->AddTool(wxID_EXIT, _("Exit application"), wxArtProvider::GetBitmap("wxART_QUIT"));
toolbar2->Realize();
vbox->Add(toolbar1, 0, wxEXPAND);
vbox->Add(toolbar2, 0, wxEXPAND);
//vbox->Add(panel, 1, wxEXPAND);
// Test code here
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
wxStaticText *EnterRadius = new wxStaticText(panel, wxID_ANY, wxT("Enter radius in mm"));
wxTextCtrl *RadiusEntered = new wxTextCtrl(panel, wxID_ANY, wxT(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_PROCESS_ENTER);
//hbox2->Add(vbox, 1, wxEXPAND);
hbox1->Add(EnterRadius, 1, wxLEFT | wxTOP , 20);
hbox1->Add(RadiusEntered, 1, wxRIGHT | wxTOP , 20);
vbox->Add(hbox2, 1, wxEXPAND);
SetSizer(vbox);
// Set status bar
CreateStatusBar(2);
SetStatusText(_T("Status Text 1"), 0);
SetStatusText(_T("Status Text 2"), 1);
}
void MainWindow::OnRadiusEntered(wxCommandEvent& event)
{
wxMessageBox("MainWindow::OnRadiusEntered");
}
MainWindow::~MainWindow()
{
}