]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp
2 /////////////////////////////////////////////////////////////////////////////
3 // Name: FoldPanelBarTest.cpp
4 // Purpose: FoldPanelBarTest Test application
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
21 ID_COLLAPSEME
= 10000,
25 #include "wx/foldbar/foldpanelbar.h"
26 #include "foldtestpanel.h"
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 // the application icon (under Windows and OS/2 it is in resources)
33 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
34 #include "mondrian.xpm"
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 class MyApp
: public wxApp
44 virtual bool OnInit();
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 class MyAppFrame
: public wxFrame
54 MyAppFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
,
55 long style
= wxDEFAULT_FRAME_STYLE
);
58 void OnQuit(wxCommandEvent
& event
);
59 void OnAbout(wxCommandEvent
& event
);
61 // extra handlers for the bar, to show how it works
63 void OnCollapseMe(wxCommandEvent
&event
);
64 void OnExpandMe(wxCommandEvent
&event
);
67 wxMenuBar
*CreateMenuBar();
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
81 FoldPanelBarTest_Quit
= 1,
82 FoldPanelBarTest_About
= wxID_ABOUT
85 // ----------------------------------------------------------------------------
86 // event tables and other macros for wxWindows
87 // ----------------------------------------------------------------------------
89 BEGIN_EVENT_TABLE(MyAppFrame
, wxFrame
)
90 EVT_MENU(FoldPanelBarTest_Quit
, MyAppFrame::OnQuit
)
91 EVT_MENU(FoldPanelBarTest_About
, MyAppFrame::OnAbout
)
92 EVT_BUTTON(ID_COLLAPSEME
, MyAppFrame::OnCollapseMe
)
93 EVT_BUTTON(ID_EXPANDME
, MyAppFrame::OnExpandMe
)
98 // ============================================================================
100 // ============================================================================
102 // ----------------------------------------------------------------------------
103 // MyApp Implementation
104 // ----------------------------------------------------------------------------
108 MyAppFrame
*frame
= new MyAppFrame(_T("FoldPanelBarTest wxWindows Test Application"),
109 wxPoint(50, 50), wxSize(200, 500));
117 // ----------------------------------------------------------------------------
118 // MyAppFrame Implementation
119 // ----------------------------------------------------------------------------
121 MyAppFrame::MyAppFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
)
122 : wxFrame(NULL
, -1, title
, pos
, size
, style
)
124 SetIcon(wxICON(mondrian
));
126 SetMenuBar(CreateMenuBar());
129 SetStatusText(_T("Welcome to wxWindows!"));
131 _pnl
= new wxFoldPanelBar(this, -1, wxDefaultPosition
, wxDefaultSize
, wxFPB_DEFAULT_STYLE
, wxFPB_COLLAPSE_TO_BOTTOM
);
133 wxFoldPanel item
= _pnl
->AddFoldPanel("Test me", false);
134 _pnl
->AddFoldPanelWindow(item
, new wxButton(item
.GetParent(), ID_COLLAPSEME
, "Collapse Me"));
136 item
= _pnl
->AddFoldPanel("Test me too!", true);
137 _pnl
->AddFoldPanelWindow(item
, new wxButton(item
.GetParent(), ID_EXPANDME
, "Expand first one"));
138 _pnl
->AddFoldPanelSeperator(item
);
139 _pnl
->AddFoldPanelWindow(item
, new FoldTestPanel(item
.GetParent(), -1));
141 _pnl
->AddFoldPanelSeperator(item
);
143 _pnl
->AddFoldPanelWindow(item
, new wxTextCtrl(item
.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH
, wxFPB_DEFAULT_YSPACING
, 20);
145 item
= _pnl
->AddFoldPanel("Some opinions ...", false);
146 _pnl
->AddFoldPanelWindow(item
, new wxCheckBox(item
.GetParent(), -1, "I like this"));
147 _pnl
->AddFoldPanelWindow(item
, new wxCheckBox(item
.GetParent(), -1, "And also this"));
148 _pnl
->AddFoldPanelWindow(item
, new wxCheckBox(item
.GetParent(), -1, "And gimme this too"));
150 _pnl
->AddFoldPanelSeperator(item
);
152 _pnl
->AddFoldPanelWindow(item
, new wxCheckBox(item
.GetParent(), -1, "Check this too if you like"));
153 _pnl
->AddFoldPanelWindow(item
, new wxCheckBox(item
.GetParent(), -1, "What about this"));
156 item
= _pnl
->AddFoldPanel("Choose one ...", false);
157 _pnl
->AddFoldPanelWindow(item
, new wxStaticText(item
.GetParent(), -1, "Enter your comment"));
158 _pnl
->AddFoldPanelWindow(item
, new wxTextCtrl(item
.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH
, wxFPB_DEFAULT_YSPACING
, 20);
162 wxMenuBar
*MyAppFrame::CreateMenuBar()
164 wxMenuBar
*value
= 0;
166 wxMenu
*menuFile
= new wxMenu
;
167 menuFile
->Append(FoldPanelBarTest_Quit
, _T("E&xit\tAlt-X"), _T("Quit this program"));
169 wxMenu
*helpMenu
= new wxMenu
;
170 helpMenu
->Append(FoldPanelBarTest_About
, _T("&About...\tF1"), _T("Show about dialog"));
172 value
= new wxMenuBar();
173 value
->Append(menuFile
, _T("&File"));
174 value
->Append(helpMenu
, _T("&Help"));
183 void MyAppFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
185 // TRUE is to force the frame to close
189 void MyAppFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
192 msg
.Printf( _T("This is the About dialog of the FoldPanelBarTest application.\n")
193 _T("Welcome to %s"), wxVERSION_STRING
);
195 wxMessageBox(msg
, _T("About FoldPanelBarTest"), wxOK
| wxICON_INFORMATION
, this);
198 void MyAppFrame::OnCollapseMe(wxCommandEvent
&event
)
200 wxFoldPanel item
= _pnl
->Item(0);
201 _pnl
->Collapse(item
);
204 void MyAppFrame::OnExpandMe(wxCommandEvent
&event
)
206 _pnl
->Expand(_pnl
->Item(0));
207 _pnl
->Collapse(_pnl
->Item(1));