]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp
reSWIGged
[wxWidgets.git] / contrib / samples / foldbar / foldpanelbar / foldpanelbartest.cpp
CommitLineData
957f5ab7 1/////////////////////////////////////////////////////////////////////////////
f857e441
WS
2// Name: foldpanelbartest.cpp
3// Purpose:
4// Author: Jorgen Bodde
5// Modified by:
6// Created: 18/06/2004
7// RCS-ID: $Id$
8// Copyright: (c) Jorgen Bodde
957f5ab7
VZ
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#ifndef WX_PRECOMP
19 #include "wx/wx.h"
20#endif
21
22enum
23{
f857e441
WS
24 ID_COLLAPSEME = 10000,
25 ID_EXPANDME
957f5ab7
VZ
26};
27
28#include "wx/foldbar/foldpanelbar.h"
29#include "foldtestpanel.h"
30
31// ----------------------------------------------------------------------------
32// resources
33// ----------------------------------------------------------------------------
34
35// the application icon (under Windows and OS/2 it is in resources)
36#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
37 #include "mondrian.xpm"
38#endif
39
40// ----------------------------------------------------------------------------
41// MyApp Class
42// ----------------------------------------------------------------------------
43
44class MyApp : public wxApp
45{
46public:
47 virtual bool OnInit();
48};
49
50// ----------------------------------------------------------------------------
51// MyAppFrame Class
52// ----------------------------------------------------------------------------
53
54class MyAppFrame : public wxFrame
55{
56public:
57 MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
58 long style = wxDEFAULT_FRAME_STYLE);
59
60private:
61 void OnQuit(wxCommandEvent& event);
62 void OnAbout(wxCommandEvent& event);
63
f857e441 64 // extra handlers for the bar, to show how it works
957f5ab7 65
f857e441
WS
66 void OnCollapseMe(wxCommandEvent &event);
67 void OnExpandMe(wxCommandEvent &event);
957f5ab7
VZ
68
69private:
f857e441
WS
70 wxMenuBar *CreateMenuBar();
71 wxFoldPanelBar *_pnl;
957f5ab7
VZ
72
73private:
74 DECLARE_EVENT_TABLE()
75};
76
77// ----------------------------------------------------------------------------
78// constants
79// ----------------------------------------------------------------------------
80
81enum
82{
83 // menu items
84 FoldPanelBarTest_Quit = 1,
85 FoldPanelBarTest_About = wxID_ABOUT
86};
87
88// ----------------------------------------------------------------------------
0b47cf6f 89// event tables and other macros for wxWidgets
957f5ab7
VZ
90// ----------------------------------------------------------------------------
91
92BEGIN_EVENT_TABLE(MyAppFrame, wxFrame)
93 EVT_MENU(FoldPanelBarTest_Quit, MyAppFrame::OnQuit)
94 EVT_MENU(FoldPanelBarTest_About, MyAppFrame::OnAbout)
f857e441
WS
95 EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe)
96 EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe)
957f5ab7
VZ
97END_EVENT_TABLE()
98
99IMPLEMENT_APP(MyApp)
100
101// ============================================================================
102// implementation
103// ============================================================================
104
105// ----------------------------------------------------------------------------
106// MyApp Implementation
107// ----------------------------------------------------------------------------
108
109bool MyApp::OnInit()
110{
0b47cf6f 111 MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWidgets Test Application"),
957f5ab7
VZ
112 wxPoint(50, 50), wxSize(200, 500));
113
f857e441 114 SetTopWindow(frame);
957f5ab7 115
f857e441
WS
116 frame->Show(true);
117 return true;
957f5ab7
VZ
118}
119
120// ----------------------------------------------------------------------------
121// MyAppFrame Implementation
122// ----------------------------------------------------------------------------
123
124MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
f857e441 125 : wxFrame(NULL, wxID_ANY, title, pos, size, style)
957f5ab7
VZ
126{
127 SetIcon(wxICON(mondrian));
128
129 SetMenuBar(CreateMenuBar());
130
131 CreateStatusBar(2);
0b47cf6f 132 SetStatusText(_T("Welcome to wxWidgets!"));
957f5ab7 133
f857e441
WS
134 _pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
135
136 wxFoldPanel item = _pnl->AddFoldPanel(_T("Test me"), false);
137 _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse Me")));
138
139 item = _pnl->AddFoldPanel(_T("Test me too!"), true);
140 _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_EXPANDME, _T("Expand first one")));
141 _pnl->AddFoldPanelSeperator(item);
142 _pnl->AddFoldPanelWindow(item, new FoldTestPanel(item.GetParent(), wxID_ANY));
957f5ab7 143
f857e441 144 _pnl->AddFoldPanelSeperator(item);
957f5ab7 145
f857e441 146 _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
957f5ab7 147
f857e441
WS
148 item = _pnl->AddFoldPanel(_T("Some opinions ..."), false);
149 _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("I like this")));
150 _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And also this")));
151 _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And gimme this too")));
957f5ab7 152
f857e441 153 _pnl->AddFoldPanelSeperator(item);
957f5ab7 154
f857e441
WS
155 _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("Check this too if you like")));
156 _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("What about this")));
957f5ab7
VZ
157
158
f857e441
WS
159 item = _pnl->AddFoldPanel(_T("Choose one ..."), false);
160 _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter your comment")));
161 _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
957f5ab7
VZ
162
163}
164
165wxMenuBar *MyAppFrame::CreateMenuBar()
166{
957f5ab7
VZ
167 wxMenu *menuFile = new wxMenu;
168 menuFile->Append(FoldPanelBarTest_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
169
170 wxMenu *helpMenu = new wxMenu;
171 helpMenu->Append(FoldPanelBarTest_About, _T("&About...\tF1"), _T("Show about dialog"));
172
f857e441 173 wxMenuBar *value = new wxMenuBar();
957f5ab7
VZ
174 value->Append(menuFile, _T("&File"));
175 value->Append(helpMenu, _T("&Help"));
f857e441 176
957f5ab7 177 return value;
f857e441 178}
957f5ab7
VZ
179
180// event handlers
181
182
183
184void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
185{
f857e441
WS
186 // true is to force the frame to close
187 Close(true);
957f5ab7
VZ
188}
189
190void MyAppFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
191{
192 wxString msg;
193 msg.Printf( _T("This is the About dialog of the FoldPanelBarTest application.\n")
194 _T("Welcome to %s"), wxVERSION_STRING);
195
196 wxMessageBox(msg, _T("About FoldPanelBarTest"), wxOK | wxICON_INFORMATION, this);
197}
198
f857e441 199void MyAppFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event))
957f5ab7 200{
f857e441
WS
201 wxFoldPanel item = _pnl->Item(0);
202 _pnl->Collapse(item);
957f5ab7
VZ
203}
204
f857e441 205void MyAppFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
957f5ab7 206{
f857e441
WS
207 _pnl->Expand(_pnl->Item(0));
208 _pnl->Collapse(_pnl->Item(1));
957f5ab7 209}