/[projects]/misc/wx_stdproject/main.cpp
ViewVC logotype

Annotation of /misc/wx_stdproject/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 329 - (hide annotations) (download)
Thu Sep 17 09:32:44 2009 UTC (14 years, 8 months ago) by torben
File size: 2209 byte(s)
Added wx_stdproject to list of old code

1 torben 329 #include <wx/wx.h>
2     #include <wx/grid.h>
3    
4     #include <wx/sizer.h>
5     #include <wx/panel.h>
6     #include <wx/dialog.h>
7     #include <wx/frame.h>
8    
9     int wxID_EDIT1 = wxNewId();
10     int wxID_EDIT2 = wxNewId();
11     int wxID_GRID = wxNewId();
12     int wxID_SHOWHIDE = wxNewId();
13    
14     class MyApp : public wxApp
15     {
16     virtual bool OnInit();
17     };
18    
19     DECLARE_APP(MyApp)
20    
21     IMPLEMENT_APP(MyApp)
22    
23     class MyFrame : public wxFrame
24     {
25     wxPanel* mpPanel;
26     wxButton* mpButton ;
27     wxBoxSizer* mpSizer;
28     wxTextCtrl* mpText;
29    
30     public:
31     MyFrame(const wxString& title);
32     ~MyFrame();
33     void OnQuit(wxCommandEvent &event);
34     void OnButtonPressed(wxCommandEvent &event);
35     void OnShowHide(wxCommandEvent &event);
36     DECLARE_EVENT_TABLE()
37     };
38    
39    
40     bool MyApp::OnInit()
41     {
42     MyFrame *frame = new MyFrame(wxT("test"));
43     frame->Show();
44     return true;
45     }
46    
47     //--------------------------------------------------
48    
49     BEGIN_EVENT_TABLE(MyFrame, wxFrame)
50     EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
51     EVT_BUTTON(wxID_ABOUT, MyFrame::OnButtonPressed)
52     EVT_BUTTON(wxID_OK, MyFrame::OnButtonPressed)
53     EVT_BUTTON(wxID_CANCEL, MyFrame::OnButtonPressed)
54     EVT_BUTTON(wxID_SHOWHIDE, MyFrame::OnShowHide)
55     END_EVENT_TABLE()
56    
57     MyFrame::MyFrame(const wxString& title)
58     : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,400), wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxRESIZE_BORDER)
59     {
60     wxMenu *filemenu = new wxMenu;
61    
62     filemenu->Append(wxID_EXIT, wxT("Exit\tAlt-X"), wxT("Quit this program"));
63    
64     wxMenuBar *bar = new wxMenuBar();
65    
66     bar->Append(filemenu, wxT("File") );
67    
68     SetMenuBar(bar);
69    
70     CreateStatusBar(2,0); //no sizegripper
71     SetStatusText(wxT("Welcome to wxWidgets"));
72    
73    
74     mpPanel = new wxPanel(this);
75    
76     mpButton = new wxButton(mpPanel, wxID_OK,wxT("Button"), wxDefaultPosition, wxDefaultSize);
77     mpText = new wxTextCtrl(mpPanel, wxID_ANY);
78    
79     mpSizer = new wxBoxSizer(wxVERTICAL);
80     mpSizer->Add(mpButton,0, wxALIGN_CENTER_HORIZONTAL);
81     mpSizer->Add(mpText, 1, wxEXPAND);
82    
83    
84     mpPanel->SetSizer(mpSizer);
85     mpPanel->Layout();
86    
87     }
88    
89     MyFrame::~MyFrame()
90     {
91     }
92    
93     void MyFrame::OnQuit(wxCommandEvent& event)
94     {
95     this->Close();
96     }
97    
98    
99     void MyFrame::OnButtonPressed(wxCommandEvent& event)
100     {
101     }
102    
103     void MyFrame::OnShowHide(wxCommandEvent& event)
104     {
105     }

  ViewVC Help
Powered by ViewVC 1.1.20