]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: foldpanelbartest.cpp
4 // Author: Jorgen Bodde
8 // Copyright: (c) Jorgen Bodde
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
24 ID_COLLAPSEME
= 10000,
28 #include "wx/foldbar/foldpanelbar.h"
29 #include "foldtestpanel.h"
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
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"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 class MyApp
: public wxApp
47 virtual bool OnInit();
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 class MyAppFrame
: public wxFrame
57 MyAppFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
,
58 long style
= wxDEFAULT_FRAME_STYLE
);
61 void OnQuit(wxCommandEvent
& event
);
62 void OnAbout(wxCommandEvent
& event
);
64 // extra handlers for the bar, to show how it works
66 void OnCollapseMe(wxCommandEvent
&event
);
67 void OnExpandMe(wxCommandEvent
&event
);
70 wxMenuBar
*CreateMenuBar();
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
84 FoldPanelBarTest_Quit
= 1,
85 FoldPanelBarTest_About
= wxID_ABOUT
88 // ----------------------------------------------------------------------------
89 // event tables and other macros for wxWindows
90 // ----------------------------------------------------------------------------
92 BEGIN_EVENT_TABLE(MyAppFrame
, wxFrame
)
93 EVT_MENU(FoldPanelBarTest_Quit
, MyAppFrame::OnQuit
)
94 EVT_MENU(FoldPanelBarTest_About
, MyAppFrame::OnAbout
)
95 EVT_BUTTON(ID_COLLAPSEME
, MyAppFrame::OnCollapseMe
)
96 EVT_BUTTON(ID_EXPANDME
, MyAppFrame::OnExpandMe
)
101 // ============================================================================
103 // ============================================================================
105 // ----------------------------------------------------------------------------
106 // MyApp Implementation
107 // ----------------------------------------------------------------------------
111 MyAppFrame
*frame
= new MyAppFrame(_T("FoldPanelBarTest wxWindows Test Application"),
112 wxPoint(50, 50), wxSize(200, 500));
120 // ----------------------------------------------------------------------------
121 // MyAppFrame Implementation
122 // ----------------------------------------------------------------------------
124 MyAppFrame::MyAppFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
)
125 : wxFrame(NULL
, wxID_ANY
, title
, pos
, size
, style
)
127 SetIcon(wxICON(mondrian
));
129 SetMenuBar(CreateMenuBar());
132 SetStatusText(_T("Welcome to wxWindows!"));
134 _pnl
= new wxFoldPanelBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, wxFPB_DEFAULT_STYLE
, wxFPB_COLLAPSE_TO_BOTTOM
);
136 wxFoldPanel item
= _pnl
->AddFoldPanel(_T("Test me"), false);
137 _pnl
->AddFoldPanelWindow(item
, new wxButton(item
.GetParent(), ID_COLLAPSEME
, _T("Collapse Me")));
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
));
144 _pnl
->AddFoldPanelSeperator(item
);
146 _pnl
->AddFoldPanelWindow(item
, new wxTextCtrl(item
.GetParent(), wxID_ANY
, _T("Comment")), wxFPB_ALIGN_WIDTH
, wxFPB_DEFAULT_YSPACING
, 20);
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")));
153 _pnl
->AddFoldPanelSeperator(item
);
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")));
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);
165 wxMenuBar
*MyAppFrame::CreateMenuBar()
167 wxMenu
*menuFile
= new wxMenu
;
168 menuFile
->Append(FoldPanelBarTest_Quit
, _T("E&xit\tAlt-X"), _T("Quit this program"));
170 wxMenu
*helpMenu
= new wxMenu
;
171 helpMenu
->Append(FoldPanelBarTest_About
, _T("&About...\tF1"), _T("Show about dialog"));
173 wxMenuBar
*value
= new wxMenuBar();
174 value
->Append(menuFile
, _T("&File"));
175 value
->Append(helpMenu
, _T("&Help"));
184 void MyAppFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
186 // true is to force the frame to close
190 void MyAppFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
193 msg
.Printf( _T("This is the About dialog of the FoldPanelBarTest application.\n")
194 _T("Welcome to %s"), wxVERSION_STRING
);
196 wxMessageBox(msg
, _T("About FoldPanelBarTest"), wxOK
| wxICON_INFORMATION
, this);
199 void MyAppFrame::OnCollapseMe(wxCommandEvent
&WXUNUSED(event
))
201 wxFoldPanel item
= _pnl
->Item(0);
202 _pnl
->Collapse(item
);
205 void MyAppFrame::OnExpandMe(wxCommandEvent
&WXUNUSED(event
))
207 _pnl
->Expand(_pnl
->Item(0));
208 _pnl
->Collapse(_pnl
->Item(1));