| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. wxNotebookSizer #3635 Posted by: 2004-03-29 00:38:15 | Hi Folks:
I’m having some difficulty using the wxNotebookSizer class. Come to think of it, I’ve been bashing my head against the desk trying to figure it out.
I used the code snippet from the wxWidgets/wxWindows manual as a guideline and I also found a few code samples from the web, but I still could not get the notebook pane to resize properly (see source code below). The following is a summary of what the program does:
- create a frame. - create a panel inside the frame. - create a notebook on the panel. - create a pane in the notebook.
At this point, I’m totally wiped! Any help on this would be appreciated (See the program below). Thanks
Ray
------------------------- Source Code --------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/notebook.h>
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "mondrian.xpm"
#endif
class MyApp : public wxApp {
public:
virtual bool OnInit();
protected:
private:
};
class MyDataEntryPanel : public wxPanel {
public:
MyDataEntryPanel(wxWindow* parent, wxWindowID id = -1);
~MyDataEntryPanel();
protected:
private:
};
class MyFrame : public wxFrame {
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);
~MyFrame();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
protected:
private:
DECLARE_EVENT_TABLE()
wxNotebookSizer* m_pNotebookSizer;
wxBoxSizer* m_pDataEntrySizer;
wxPanel* m_pMainPanel;
wxNotebook* m_pNotebook;
wxNotebookPage* m_pDataEntryPage;
MyDataEntryPanel* m_pDataEntryPanel;
};
enum {
Minimal_Quit = 1,
Minimal_About = wxID_ABOUT
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit() {
MyFrame *frame = new MyFrame(_T("minimal sample"),
wxPoint(50, 50), wxSize(750, 550));
frame->Show(TRUE);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style) {
SetIcon(wxICON(mondrian));
#if wxUSE_MENUS
wxMenu *menuFile = new wxMenu;
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(menuBar);
#endif m_pDataEntrySizer = new wxBoxSizer(wxVERTICAL);
m_pMainPanel = new wxPanel(this, -1);
m_pNotebook = new wxNotebook(m_pMainPanel, -1, wxDefaultPosition, wxSize(740,470), 0, "notebook");
m_pNotebookSizer = new wxNotebookSizer(m_pNotebook);
m_pDataEntryPanel = new MyDataEntryPanel(m_pNotebook);
m_pNotebook->AddPage(m_pDataEntryPanel, "Enter Data", TRUE);
m_pDataEntryPanel->SetAutoLayout(TRUE);
m_pDataEntryPanel->SetSizer(m_pDataEntrySizer);
#if wxUSE_STATUSBAR
CreateStatusBar();
SetStatusText(_T("Welcome to wxWidgets"));
#endif }
MyFrame::~MyFrame() {
delete m_pNotebookSizer;
delete m_pDataEntrySizer;
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) {
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) {
wxString msg;
msg.Printf( _T("This is the About dialog of minimal sample.\n")
_T("Welcome to %s"), wxVERSION_STRING);
wxMessageBox(msg, _T("About minimal sample"), wxOK | wxICON_INFORMATION, this);
}
MyDataEntryPanel::MyDataEntryPanel(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) {
}
MyDataEntryPanel::~MyDataEntryPanel() {
}
| 2. Re: wxNotebookSizer #3638 Posted by: 2004-03-29 02:20:43 | YAHOO! I figured it out from some sample code (widgets.cpp) found at this Forum. The following are modified snippets from my source file:
class MyFrame : public wxFrame {
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);
~MyFrame();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
protected:
private:
DECLARE_EVENT_TABLE()
wxPanel* m_pMainPanel;
wxNotebook* m_pNotebook;
MyDataEntryPanel* m_pDataEntryPanel;
wxBoxSizer* m_pTopSizer;
wxNotebookSizer* m_pNotebookSizer;
};
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style) {
...
m_pMainPanel = new wxPanel(this, -1);
m_pNotebook = new wxNotebook(m_pMainPanel, -1, wxDefaultPosition, wxSize(740,470), 0, "notebook");
m_pDataEntryPanel = new MyDataEntryPanel(m_pNotebook);
m_pTopSizer = new wxBoxSizer(wxVERTICAL);
m_pNotebookSizer = new wxNotebookSizer(m_pNotebook);
m_pNotebook->AddPage(m_pDataEntryPanel, "Enter Data", TRUE);
m_pTopSizer->Add(m_pNotebookSizer, 1, wxGROW, 5);
m_pMainPanel->SetAutoLayout(TRUE);
m_pMainPanel->SetSizer(m_pTopSizer);
...
}
Frustration aside, definitely learned a lot from this exercise. Thanks to everyone that responded:-)
Ray
| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|