]>
Commit | Line | Data |
---|---|---|
03206f17 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: No names yet. | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: Sebastian Haase (June 21, 2001) | |
6 | // Created: 04/11/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "fl_demo2.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx/wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | #endif | |
26 | ||
be5a51fb | 27 | // wxWidgets headers. |
03206f17 VS |
28 | #include "wx/treectrl.h" |
29 | #include "wx/imaglist.h" | |
2a21ac15 | 30 | #include "wx/notebook.h" |
03206f17 VS |
31 | |
32 | // fl headers. | |
33 | #include "wx/fl/controlbar.h" | |
34 | #include "wx/fl/rowlayoutpl.h" | |
35 | #include "wx/fl/antiflickpl.h" | |
36 | #include "wx/fl/bardragpl.h" | |
37 | #include "wx/fl/cbcustom.h" | |
38 | #include "wx/fl/rowdragpl.h" | |
39 | ||
40 | // some extra fl plugins. | |
41 | #include "wx/fl/barhintspl.h" | |
42 | #include "wx/fl/hintanimpl.h" | |
43 | ||
44 | #include "wx/fl/dyntbar.h" | |
45 | #include "wx/fl/dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar | |
46 | ||
47 | #include "fl_demo2.h" | |
48 | ||
49 | /***** Implementation for class MyApp *****/ | |
50 | ||
51 | // Create a new application object | |
52 | IMPLEMENT_APP (MyApp) | |
53 | ||
54 | // `Main program' equivalent, creating windows and returning main app frame | |
55 | bool MyApp::OnInit(void) | |
56 | { | |
57 | // Create the main frame window | |
be5a51fb | 58 | MyFrame *frame = new MyFrame(NULL, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540); |
2a21ac15 | 59 | |
03206f17 VS |
60 | // Give it an icon |
61 | #ifdef __WINDOWS__ | |
05aa1fc7 | 62 | frame->SetIcon(wxIcon(wxT("mondrian"))); |
03206f17 VS |
63 | #endif |
64 | #ifdef __X__ | |
05aa1fc7 | 65 | frame->SetIcon(wxIcon(wxT("aiai.xbm"))); |
03206f17 | 66 | #endif |
2a21ac15 | 67 | |
03206f17 VS |
68 | // Make a menubar |
69 | wxMenu *file_menu = new wxMenu; | |
70 | wxMenu *active_menu = new wxMenu; | |
2a21ac15 | 71 | |
05aa1fc7 JS |
72 | file_menu->Append( ID_LOAD, _("&Load layouts") ); |
73 | file_menu->Append( ID_STORE, _("&Store layouts") ); | |
03206f17 | 74 | file_menu->AppendSeparator(); |
2a21ac15 DS |
75 | |
76 | file_menu->Append( ID_AUTOSAVE, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK ); | |
03206f17 | 77 | file_menu->AppendSeparator(); |
2a21ac15 | 78 | |
05aa1fc7 JS |
79 | file_menu->Append(MINIMAL_ABOUT, _("A&bout !")); |
80 | file_menu->Append(MINIMAL_QUIT, _("E&xit\tTab")); | |
2a21ac15 | 81 | |
05aa1fc7 | 82 | //active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") ); |
03206f17 | 83 | //active_menu->AppendSeparator(); |
2a21ac15 | 84 | |
05aa1fc7 JS |
85 | active_menu->Append( ID_REMOVE, _("&Remove Active") ); |
86 | active_menu->Append( ID_REMOVEALL, _("Remove &All") ); | |
87 | active_menu->Append( ID_RECREATE, _("Re&create") ); | |
03206f17 | 88 | active_menu->AppendSeparator(); |
2a21ac15 DS |
89 | |
90 | active_menu->Append( ID_FIRST, _("Activate f&irst layout \tF1"), _("activate it"), wxITEM_CHECK ); | |
91 | active_menu->Append( ID_SECOND, _("Activate &second layout\tF2"), _("activate it"), wxITEM_CHECK ); | |
92 | active_menu->Append( ID_THIRD, _("Activate &third layout\tF3"), _("activate it"), wxITEM_CHECK ); | |
93 | ||
03206f17 | 94 | wxMenuBar *menu_bar = new wxMenuBar; |
2a21ac15 | 95 | |
05aa1fc7 JS |
96 | menu_bar->Append(file_menu, _("&File")); |
97 | menu_bar->Append(active_menu, _("Active &Layout")); | |
2a21ac15 | 98 | |
d96cdd4a | 99 | #if wxUSE_STATUSBAR |
03206f17 | 100 | frame->CreateStatusBar(3); |
d96cdd4a | 101 | #endif // wxUSE_STATUSBAR |
2a21ac15 | 102 | |
03206f17 | 103 | frame->SetMenuBar(menu_bar); |
2a21ac15 | 104 | |
03206f17 | 105 | frame->SyncMenuBarItems(); |
2a21ac15 | 106 | |
03206f17 | 107 | // Show the frame |
2a21ac15 DS |
108 | frame->Show(true); |
109 | ||
03206f17 | 110 | SetTopWindow(frame); |
2a21ac15 DS |
111 | |
112 | return true; | |
03206f17 VS |
113 | } |
114 | ||
115 | MyFrame::~MyFrame() | |
116 | { | |
117 | // frame-layouts is not a windows (objects), thus should | |
118 | // be cleaned up manually | |
2a21ac15 | 119 | |
03206f17 VS |
120 | for( int i = 0; i != MAX_LAYOUTS; ++i ) |
121 | { | |
2a21ac15 | 122 | if ( mLayouts[i] ) |
03206f17 VS |
123 | delete mLayouts[i]; |
124 | } | |
2a21ac15 DS |
125 | |
126 | if ( mpNestedLayout ) | |
03206f17 | 127 | delete mpNestedLayout; |
2a21ac15 | 128 | if ( mpAboutBoxLayout ) |
03206f17 VS |
129 | delete mpAboutBoxLayout; |
130 | } | |
131 | ||
132 | /***** Implementation for class MyFrame *****/ | |
133 | ||
134 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
135 | EVT_MENU( MINIMAL_QUIT, MyFrame::OnQuit ) | |
136 | EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout ) | |
137 | ||
138 | EVT_MENU( ID_LOAD, MyFrame::OnLoad ) | |
139 | EVT_MENU( ID_STORE, MyFrame::OnStore ) | |
140 | EVT_MENU( ID_AUTOSAVE, MyFrame::OnAutoSave ) | |
141 | //EVT_MENU( ID_SETTINGS, MyFrame::OnSettings ) | |
142 | EVT_MENU( ID_REMOVE, MyFrame::OnRemove ) | |
143 | EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll ) | |
144 | EVT_MENU( ID_RECREATE, MyFrame::OnRecreate ) | |
145 | EVT_MENU( ID_FIRST, MyFrame::OnFirst ) | |
146 | EVT_MENU( ID_SECOND, MyFrame::OnSecond ) | |
147 | EVT_MENU( ID_THIRD, MyFrame::OnThird ) | |
148 | ||
149 | EVT_BUTTON( ID_SAY_ITSOK, MyFrame::OnSayItsOk ) | |
150 | EVT_BUTTON( ID_BTN_YES, MyFrame::OnBtnYes ) | |
151 | EVT_BUTTON( ID_BTN_NO, MyFrame::OnBtnNo ) | |
152 | EVT_BUTTON( ID_BTN_ESC, MyFrame::OnBtnEsc ) | |
153 | ||
154 | EVT_CHAR_HOOK( MyFrame::OnChar ) | |
155 | END_EVENT_TABLE() | |
156 | ||
157 | // My frame constructor | |
158 | ||
05aa1fc7 | 159 | MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h) |
2a21ac15 | 160 | : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)), |
03206f17 VS |
161 | mpNestedLayout( NULL ), |
162 | mpAboutBoxLayout( NULL ), | |
163 | ||
164 | mActiveLayoutNo( FIRST_LAYOUT ), | |
2a21ac15 DS |
165 | mAutoSave( true ), |
166 | mSavedAlready( false ), | |
03206f17 VS |
167 | mpClntWindow( NULL ), |
168 | ||
2a21ac15 | 169 | mImageList( 16,16, false, 2 ) |
03206f17 | 170 | { |
8552e6f0 MB |
171 | int i; |
172 | ||
03206f17 | 173 | mpInternalFrm = (wxPanel*)this; |
2a21ac15 DS |
174 | |
175 | mAboutBox.Create( this, wxID_ANY, _T("About box in wxWidgets style..."), | |
03206f17 VS |
176 | wxDefaultPosition, |
177 | wxSize( 385,220), | |
2a21ac15 DS |
178 | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL ); |
179 | ||
180 | for( i = 0; i != MAX_LAYOUTS; ++i ) | |
03206f17 | 181 | mLayouts[i] = NULL; |
2a21ac15 | 182 | |
03206f17 | 183 | // image-list is one of the few objects which |
2a21ac15 | 184 | // currently cannot be serialized, create it first |
03206f17 | 185 | // and use it as initial reference (IR) |
2a21ac15 | 186 | |
03206f17 | 187 | wxBitmap bmp1,bmp2; |
2a21ac15 | 188 | |
05aa1fc7 JS |
189 | if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp") ) ) |
190 | bmp1.LoadFile( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp"), wxBITMAP_TYPE_BMP ); | |
2a21ac15 | 191 | |
05aa1fc7 JS |
192 | if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp") ) ) |
193 | bmp2.LoadFile( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp"), wxBITMAP_TYPE_BMP ); | |
2a21ac15 | 194 | |
03206f17 VS |
195 | mImageList.Add( bmp1 ); |
196 | mImageList.Add( bmp2 ); | |
2a21ac15 | 197 | |
03206f17 | 198 | InitAboutBox(); |
2a21ac15 | 199 | |
03206f17 | 200 | // create multiple layouts |
2a21ac15 | 201 | |
03206f17 | 202 | mpNestedLayout = 0; |
2a21ac15 | 203 | |
05aa1fc7 | 204 | mpClntWindow = CreateTxtCtrl(wxT("client window")); |
2a21ac15 | 205 | |
03206f17 VS |
206 | // Create all layouts |
207 | for( i = 0; i != MAX_LAYOUTS; ++i ) | |
c82c42d4 | 208 | { |
03206f17 VS |
209 | CreateLayout( i ); |
210 | } | |
211 | // hide others | |
212 | for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i ) | |
213 | { | |
214 | mLayouts[i]->HideBarWindows(); | |
215 | } | |
2a21ac15 DS |
216 | |
217 | // activate first one | |
03206f17 VS |
218 | mLayouts[FIRST_LAYOUT]->Activate(); |
219 | mActiveLayoutNo = FIRST_LAYOUT; | |
220 | } | |
221 | ||
222 | /*** event handlers ***/ | |
223 | ||
224 | bool MyFrame::OnClose(void) | |
225 | { | |
2a21ac15 | 226 | // USEFUL TRICK:: avoids flickering of application's frame |
03206f17 | 227 | // when closing NN windows on exit: |
2a21ac15 DS |
228 | |
229 | Show(false); | |
230 | ||
03206f17 VS |
231 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ) |
232 | { | |
233 | } | |
234 | else | |
235 | { | |
236 | wxCommandEvent evt; | |
2a21ac15 | 237 | OnStore(evt); |
03206f17 | 238 | } |
2a21ac15 | 239 | |
03206f17 | 240 | mAboutBox.Destroy(); |
2a21ac15 DS |
241 | Destroy(); |
242 | ||
243 | return true; | |
03206f17 VS |
244 | } |
245 | ||
8552e6f0 | 246 | void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 247 | { |
05aa1fc7 | 248 | wxMessageBox(_("Hey - you found a BIG question-mark !!")); |
03206f17 VS |
249 | } |
250 | ||
8552e6f0 | 251 | void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 252 | { |
05aa1fc7 | 253 | wxMessageBox(_("Hey - you found another BIG question-mark !!")); |
03206f17 VS |
254 | } |
255 | ||
8552e6f0 | 256 | void MyFrame::OnAutoSave( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
257 | { |
258 | mAutoSave = !mAutoSave; | |
2a21ac15 | 259 | |
03206f17 | 260 | wxCommandEvent evt; |
2a21ac15 DS |
261 | OnStore(evt); |
262 | ||
03206f17 VS |
263 | SyncMenuBarItems(); |
264 | } | |
265 | ||
8552e6f0 | 266 | void MyFrame::OnRemove( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
267 | { |
268 | RemoveLayout( mActiveLayoutNo ); | |
2a21ac15 | 269 | |
03206f17 VS |
270 | Refresh(); |
271 | } | |
272 | ||
8552e6f0 | 273 | void MyFrame::OnRemoveAll( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
274 | { |
275 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
2a21ac15 | 276 | { |
03206f17 VS |
277 | RemoveLayout( i ); |
278 | } | |
279 | ||
280 | Refresh(); | |
281 | } | |
282 | ||
283 | ||
284 | void MyFrame::OnRecreate( wxCommandEvent& event ) | |
285 | { | |
286 | OnRemove( event ); // first destroy active layout | |
2a21ac15 | 287 | |
03206f17 | 288 | CreateLayout( mActiveLayoutNo ); |
2a21ac15 | 289 | |
03206f17 VS |
290 | mLayouts[mActiveLayoutNo]->Activate(); |
291 | } | |
292 | ||
8552e6f0 | 293 | void MyFrame::OnFirst( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
294 | { |
295 | ActivateLayout( FIRST_LAYOUT ); | |
296 | } | |
297 | ||
8552e6f0 | 298 | void MyFrame::OnSecond( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
299 | { |
300 | ActivateLayout( SECOND_LAYOUT ); | |
301 | } | |
302 | ||
8552e6f0 | 303 | void MyFrame::OnThird( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
304 | { |
305 | ActivateLayout( THIRD_LAYOUT ); | |
306 | } | |
307 | ||
8552e6f0 | 308 | void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 309 | { |
2a21ac15 | 310 | // USEFUL TRICK:: avoids flickering of application's frame |
03206f17 | 311 | // when closing NN windows on exit: |
2a21ac15 DS |
312 | |
313 | Show(false); | |
314 | ||
03206f17 VS |
315 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ) |
316 | { | |
317 | } | |
318 | else | |
319 | { | |
320 | wxCommandEvent evt; | |
2a21ac15 | 321 | OnStore(evt); |
03206f17 | 322 | } |
2a21ac15 | 323 | |
03206f17 VS |
324 | Destroy(); |
325 | } | |
326 | ||
8552e6f0 | 327 | void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
328 | { |
329 | wxFont font; | |
330 | #ifdef __WXMSW__ | |
05aa1fc7 | 331 | font.SetFaceName(wxT("MS Sans Serif")); |
03206f17 VS |
332 | #else |
333 | font.SetFamily( wxSWISS ); | |
334 | #endif | |
2a21ac15 | 335 | |
03206f17 VS |
336 | font.SetStyle( wxSLANT ); |
337 | font.SetWeight( wxNORMAL ); | |
338 | font.SetPointSize( 8 ); | |
2a21ac15 | 339 | |
03206f17 VS |
340 | #ifdef __WXMSW__ |
341 | font.RealizeResource(); | |
342 | #endif | |
2a21ac15 | 343 | |
03206f17 | 344 | mAboutBox.Center( wxBOTH ); |
2a21ac15 DS |
345 | mAboutBox.Show(true); |
346 | ||
03206f17 VS |
347 | } |
348 | ||
349 | void MyFrame::OnChar( wxKeyEvent& event ) | |
350 | { | |
351 | wxCommandEvent evt; | |
2a21ac15 | 352 | |
03206f17 VS |
353 | if ( event.m_keyCode == WXK_F1 ) |
354 | { | |
2a21ac15 | 355 | OnFirst( evt ); |
03206f17 VS |
356 | } |
357 | else | |
358 | { | |
359 | if ( event.m_keyCode == WXK_F2 ) | |
360 | { | |
2a21ac15 | 361 | OnSecond( evt ); |
03206f17 VS |
362 | } |
363 | else | |
364 | { | |
365 | if ( event.m_keyCode == WXK_F3 ) | |
2a21ac15 DS |
366 | { |
367 | OnThird( evt ); | |
03206f17 VS |
368 | } |
369 | if ( event.m_keyCode == WXK_F4 && !event.AltDown() ) | |
2a21ac15 | 370 | { |
03206f17 | 371 | // "AI" :-) |
05aa1fc7 | 372 | wxMessageBox(_("There are only 3 layouts in this demo :-(")); |
03206f17 VS |
373 | } |
374 | else | |
375 | { | |
376 | if ( event.m_keyCode == WXK_TAB ) | |
377 | { | |
2a21ac15 | 378 | // USEFUL TRICK:: avoids flickering of application's frame |
03206f17 | 379 | // when closing NN windows on exit: |
2a21ac15 DS |
380 | |
381 | Show(false); | |
382 | ||
03206f17 VS |
383 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ) |
384 | { | |
385 | } | |
386 | else | |
387 | { | |
388 | wxCommandEvent evt; | |
2a21ac15 | 389 | OnStore(evt); |
03206f17 | 390 | } |
2a21ac15 | 391 | |
03206f17 VS |
392 | Destroy(); |
393 | } | |
394 | else | |
395 | { | |
396 | event.Skip(); | |
397 | } | |
398 | } | |
399 | } | |
400 | } | |
401 | } | |
402 | ||
8552e6f0 | 403 | void MyFrame::OnSayItsOk( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 404 | { |
05aa1fc7 | 405 | wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") ); |
03206f17 VS |
406 | } |
407 | ||
8552e6f0 | 408 | void MyFrame::OnBtnYes( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 409 | { |
2a21ac15 | 410 | mAboutBox.Show(false); |
03206f17 VS |
411 | } |
412 | ||
8552e6f0 | 413 | void MyFrame::OnBtnNo( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 414 | { |
2a21ac15 | 415 | mAboutBox.Show(false); |
03206f17 VS |
416 | } |
417 | ||
8552e6f0 | 418 | void MyFrame::OnBtnEsc( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 419 | { |
2a21ac15 | 420 | mAboutBox.Show(false); |
03206f17 VS |
421 | } |
422 | ||
423 | /*** helper methods ***/ | |
424 | ||
425 | void MyFrame::InitAboutBox() | |
426 | { | |
427 | wxPanel* pArea = new wxPanel(); | |
2a21ac15 DS |
428 | |
429 | pArea->Create( &mAboutBox, wxID_ANY ); | |
430 | ||
431 | new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."), | |
03206f17 | 432 | wxPoint(10, 10) ); |
2a21ac15 DS |
433 | |
434 | new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"), | |
03206f17 | 435 | wxPoint(10, 30) ); |
2a21ac15 DS |
436 | |
437 | new wxStaticText(pArea, wxID_ANY, _("<mailto:alex@soften.ktu.lt>"), | |
03206f17 | 438 | wxPoint(10, 50) ); |
2a21ac15 DS |
439 | |
440 | mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true ); | |
441 | ||
03206f17 | 442 | wxFrameLayout& layout = *mpAboutBoxLayout; |
2a21ac15 | 443 | |
03206f17 VS |
444 | cbDimInfo sizes( 90,40, // when docked horizontally |
445 | 45,55, // when docked vertically | |
446 | 90,40, // when floated | |
2a21ac15 DS |
447 | true, 4, 4 // true - bar is fixed-size |
448 | ); | |
449 | ||
450 | ||
05aa1fc7 JS |
451 | wxButton* pYes = CreateButton(_("&Yes"), &mAboutBox, ID_SAY_ITSOK ); |
452 | wxButton* pNo = CreateButton(_("&No"), &mAboutBox, ID_BTN_NO ); | |
453 | wxButton* pEsc = CreateButton(_("Cancel"), &mAboutBox, ID_BTN_ESC ); | |
2a21ac15 | 454 | |
05aa1fc7 JS |
455 | layout.AddBar( pEsc, sizes, FL_ALIGN_BOTTOM, 0, 20, _("cancel button")); |
456 | layout.AddBar( pNo, sizes, FL_ALIGN_BOTTOM, 0, 20, _("no button")); | |
457 | layout.AddBar( pYes, sizes, FL_ALIGN_BOTTOM, 0, 20, _("yes button")); | |
2a21ac15 | 458 | |
03206f17 VS |
459 | layout.mBorderPen.SetColour( 192, 192, 192 ); |
460 | layout.SetMargins( 15, 15, 15, 15, wxALL_PANES ); | |
2a21ac15 | 461 | |
03206f17 | 462 | cbCommonPaneProperties props; |
2a21ac15 | 463 | |
03206f17 | 464 | layout.GetPaneProperties( props, FL_ALIGN_TOP ); |
2a21ac15 DS |
465 | |
466 | props.mShow3DPaneBorderOn = false; | |
467 | ||
03206f17 | 468 | layout.SetPaneProperties( props, wxALL_PANES ); |
2a21ac15 | 469 | |
03206f17 | 470 | layout.Activate(); |
2a21ac15 | 471 | |
03206f17 VS |
472 | pYes->SetDefault(); |
473 | pYes->SetFocus(); | |
474 | } | |
475 | ||
2a21ac15 | 476 | wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent ) |
03206f17 VS |
477 | { |
478 | return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm, | |
2a21ac15 | 479 | wxID_ANY, txt, wxDefaultPosition, wxDefaultSize, |
03206f17 VS |
480 | wxTE_MULTILINE ); |
481 | } | |
482 | ||
483 | wxButton* MyFrame::CreateButton( const wxString& label, | |
484 | wxWindow* pParent, long id ) | |
485 | { | |
2a21ac15 | 486 | return new wxButton( (pParent)?pParent : mpInternalFrm, id, |
03206f17 VS |
487 | label, wxPoint( 0,0 ), wxSize( 0,0 ) ); |
488 | } | |
489 | ||
490 | wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label ) | |
491 | { | |
2a21ac15 DS |
492 | wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, wxID_ANY ); |
493 | ||
63a24a91 | 494 | const wxTreeItemId rootid = pTree->AddRoot(label); |
2a21ac15 | 495 | |
63a24a91 | 496 | if ( label.StartsWith(_T("X")) ) |
03206f17 | 497 | { |
63a24a91 WS |
498 | pTree->AppendItem(rootid, _("Scully")); |
499 | pTree->AppendItem(rootid, _("Mulder")); | |
03206f17 VS |
500 | } |
501 | else | |
502 | { | |
63a24a91 WS |
503 | pTree->AppendItem(rootid, _("Leaf1")); |
504 | pTree->AppendItem(rootid, _("Leaf2")); | |
03206f17 | 505 | } |
2a21ac15 | 506 | |
03206f17 VS |
507 | return pTree; |
508 | } | |
509 | ||
510 | wxChoice* MyFrame::CreateChoice( const wxString& txt ) | |
511 | { | |
512 | wxString choice_strings[5]; | |
2a21ac15 | 513 | |
03206f17 | 514 | choice_strings[0] = txt; |
05aa1fc7 JS |
515 | choice_strings[1] = _("Julian"); |
516 | choice_strings[2] = _("Hattie"); | |
517 | choice_strings[3] = _("Ken"); | |
518 | choice_strings[4] = _("Dick"); | |
2a21ac15 DS |
519 | |
520 | wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition, | |
03206f17 | 521 | wxDefaultSize, 5, choice_strings); |
2a21ac15 | 522 | |
03206f17 | 523 | choice->SetSelection(0); |
2a21ac15 | 524 | |
03206f17 VS |
525 | return choice; |
526 | } | |
527 | ||
528 | // helper | |
529 | ||
8552e6f0 | 530 | void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* WXUNUSED(pParent) ) |
03206f17 | 531 | { |
2a21ac15 DS |
532 | cbDimInfo sizes2( 275,38, // when docked horizontally |
533 | 45,275, // when docked vertically | |
534 | 80,30, // when floated | |
535 | true, // the bar is fixed-size | |
03206f17 VS |
536 | 4, // vertical gap (bar border) |
537 | 4, // horizontal gap (bar border) | |
538 | new cbDynToolBarDimHandler() | |
2a21ac15 DS |
539 | ); |
540 | ||
541 | cbDimInfo sizes3( 275,55, // when docked horizontally | |
542 | 275,60, // when docked vertically | |
543 | 45,130, // when floated | |
544 | true, // the bar is fixed-size | |
03206f17 VS |
545 | 4, // vertical gap (bar border) |
546 | 4, // horizontal gap (bar border) | |
547 | new cbDynToolBarDimHandler() | |
2a21ac15 DS |
548 | ); |
549 | ||
550 | cbDimInfo sizes4( 430,35, // when docked horizontally | |
551 | 44,375, // when docked vertically | |
552 | 80,100, // when floated | |
553 | true, // the bar is fixed-size | |
03206f17 VS |
554 | 4, // vertical gap (bar border) |
555 | 4, // horizontal gap (bar border) | |
556 | new cbDynToolBarDimHandler() | |
2a21ac15 DS |
557 | ); |
558 | ||
559 | wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY ); | |
560 | ||
561 | wxChoice* pChoice = new wxChoice( pTBar2, wxID_ANY, wxDefaultPosition, wxSize( 140,25 ) ); | |
562 | ||
03206f17 | 563 | pTBar2->AddTool( 1, pChoice ); |
05aa1fc7 | 564 | pTBar2->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("search.bmp") ); |
03206f17 | 565 | //pTBar2->AddSeparator(); |
05aa1fc7 JS |
566 | pTBar2->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp") ); |
567 | pTBar2->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp") ); | |
568 | pTBar2->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp") ); | |
2a21ac15 DS |
569 | |
570 | wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY ); | |
571 | ||
05aa1fc7 JS |
572 | pTBar3->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("open.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) ); |
573 | pTBar3->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("save.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save ")) ); | |
574 | pTBar3->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("saveall.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save All ")) ); | |
03206f17 | 575 | //pTBar3->AddSeparator(); |
05aa1fc7 JS |
576 | pTBar3->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("cut.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) ); |
577 | pTBar3->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("copy.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Copy ")) ); | |
578 | pTBar3->AddTool( 6, wxString(wxT(BMP_DIR)) + wxT("paste.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Paste ")) ); | |
2a21ac15 | 579 | |
03206f17 | 580 | #ifdef __WXMSW__ |
2a21ac15 | 581 | pTBar3->EnableTool( 2, false ); |
03206f17 | 582 | #endif |
2a21ac15 DS |
583 | |
584 | wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY ); | |
585 | ||
586 | pTBar4->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Bookmarks ")), true ); | |
587 | pTBar4->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Next bookmark ")), true ); | |
588 | pTBar4->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Prev bookmark ")), true ); | |
03206f17 | 589 | //pTBar4->AddSeparator(); |
2a21ac15 DS |
590 | pTBar4->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Search ")), true ); |
591 | ||
03206f17 | 592 | #ifdef __WXMSW__ |
2a21ac15 | 593 | pTBar4->EnableTool( 4, false ); |
03206f17 | 594 | #endif |
2a21ac15 DS |
595 | |
596 | layout.AddBar( pTBar2, | |
597 | sizes2, FL_ALIGN_TOP, | |
598 | 0, | |
599 | 0, | |
600 | wxT("Search"), | |
601 | true | |
03206f17 | 602 | ); |
2a21ac15 DS |
603 | |
604 | layout.AddBar( pTBar3, | |
605 | sizes3, FL_ALIGN_BOTTOM, | |
606 | 0, | |
607 | 0, | |
608 | wxT("Titled"), | |
609 | true | |
03206f17 | 610 | ); |
2a21ac15 DS |
611 | |
612 | layout.AddBar( pTBar4, | |
613 | sizes4, FL_ALIGN_BOTTOM, | |
614 | 1, | |
615 | 0, | |
616 | wxT("Bookmarks"), | |
617 | true | |
03206f17 VS |
618 | ); |
619 | } | |
620 | ||
621 | wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent ) | |
622 | { | |
623 | bool isNested = (pParent != mpInternalFrm); | |
2a21ac15 | 624 | |
03206f17 VS |
625 | // check if we're craeting nested layout |
626 | if ( isNested ) | |
627 | { | |
628 | layout.mBorderPen.SetColour( 128,255,128 ); | |
2a21ac15 | 629 | |
03206f17 VS |
630 | // if so, than make border smaller |
631 | for( int i = 0; i != MAX_PANES; ++i ) | |
632 | { | |
633 | cbDockPane& pane = *layout.GetPane( i ); | |
2a21ac15 | 634 | |
03206f17 VS |
635 | pane.mTopMargin = 5; |
636 | pane.mBottomMargin = 5; | |
637 | pane.mLeftMargin = 5; | |
638 | pane.mRightMargin = 5; | |
639 | } | |
640 | } | |
2a21ac15 | 641 | |
03206f17 VS |
642 | int cbWidth = 200; |
643 | int cbHeight = ( isNested ) ? 50 : 150; | |
2a21ac15 | 644 | |
03206f17 VS |
645 | cbDimInfo sizes4( cbWidth,cbHeight, |
646 | cbWidth,cbHeight, | |
2a21ac15 DS |
647 | cbWidth,cbHeight, false ); |
648 | ||
03206f17 VS |
649 | cbWidth = 75; |
650 | cbHeight = 31; | |
2a21ac15 | 651 | |
03206f17 VS |
652 | cbDimInfo sizes5( cbWidth,cbHeight, |
653 | 42,65, | |
2a21ac15 | 654 | cbWidth,cbHeight, true, |
03206f17 VS |
655 | 3, // vertical gap (bar border) |
656 | 3 // horizontal gap (bar border) | |
2a21ac15 DS |
657 | ); |
658 | ||
03206f17 VS |
659 | // create "workplace" window in the third layout |
660 | // SEB: originally here was a wxpp (wxWorkshop) class demotrated | |
661 | // wxTabbedWindow* pMiniTabArea = new wxTabbedWindow(); | |
2a21ac15 DS |
662 | // pMiniTabArea->Create( pParent, wxID_ANY ); |
663 | ||
664 | ||
665 | wxTreeCtrl* pClassView = new wxTreeCtrl( pParent, wxID_ANY, | |
03206f17 | 666 | wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS ); |
2a21ac15 | 667 | |
03206f17 | 668 | pClassView->SetImageList( &mImageList ); |
2a21ac15 | 669 | |
be5a51fb | 670 | wxTreeItemId rootId = pClassView->AddRoot( wxT("wxWidgets 2.0 classes"), 0 ); |
2a21ac15 | 671 | |
05aa1fc7 JS |
672 | pClassView->AppendItem( rootId, _("wxWin Dynamic classes (grabbed at run-time)"), 0 ); |
673 | pClassView->AppendItem( rootId, _("serializer-classes (grabbed at run-time)"), 0 ); | |
2a21ac15 | 674 | |
03206f17 | 675 | // now create "output" window |
c82c42d4 | 676 | wxNotebook* pTabbedArea = new wxNotebook(pParent, wxID_ANY); |
03206f17 VS |
677 | // SEB: originally here was a wxpp (wxWorkshop) class used |
678 | // wxPaggedWindow* pTabbedArea = new wxPaggedWindow(); | |
2a21ac15 DS |
679 | // pTabbedArea->Create( pParent, wxID_ANY ); |
680 | ||
03206f17 | 681 | wxPanel* pSheet3 = new wxPanel(); |
2a21ac15 DS |
682 | pSheet3->Create( pTabbedArea, wxID_ANY ); |
683 | pSheet3->Show(false); | |
684 | ||
05aa1fc7 JS |
685 | pTabbedArea->AddPage( CreateTxtCtrl(wxT("build"), pTabbedArea), wxT("Build")); |
686 | pTabbedArea->AddPage( CreateTxtCtrl(wxT("debug"), pTabbedArea), wxT("Debug")); | |
687 | pTabbedArea->AddPage( pSheet3, wxT("is THIS recursive - or what !?")); | |
688 | pTabbedArea->AddPage( CreateTxtCtrl(wxT("profile"), pTabbedArea), wxT("Profile")); | |
2a21ac15 | 689 | |
05aa1fc7 JS |
690 | layout.AddBar( new StartButton95(pParent), sizes5, FL_ALIGN_TOP, 0, 0, wxT("Start...") ); |
691 | layout.AddBar( pClassView, sizes4, FL_ALIGN_LEFT, 0, 0, wxT("Project Workplace") ); | |
692 | layout.AddBar( pTabbedArea, sizes4, FL_ALIGN_BOTTOM, 0, 50, wxT("Output") ); | |
2a21ac15 | 693 | |
03206f17 VS |
694 | return pSheet3; |
695 | } | |
696 | ||
697 | void MyFrame::DropInSomeBars( int layoutNo ) | |
698 | { | |
699 | /* create once... and forget! */ | |
2a21ac15 | 700 | |
03206f17 | 701 | // setup dimension infos for various bar shapes |
2a21ac15 | 702 | |
03206f17 VS |
703 | int cbWidth = 90; |
704 | int cbHeight = 30; | |
2a21ac15 DS |
705 | |
706 | if ( layoutNo == SECOND_LAYOUT ) | |
03206f17 | 707 | cbHeight = 60; |
2a21ac15 | 708 | |
03206f17 | 709 | wxFrameLayout& layout = *mLayouts[layoutNo]; |
2a21ac15 | 710 | |
03206f17 VS |
711 | cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally |
712 | cbWidth,cbHeight, // when docked vertically | |
713 | cbWidth,cbHeight, // when floated | |
2a21ac15 DS |
714 | true // true - bar is fixed-size |
715 | ); | |
716 | ||
03206f17 | 717 | cbWidth = 120; |
2a21ac15 | 718 | |
03206f17 VS |
719 | cbDimInfo sizes1( cbWidth,cbHeight, |
720 | cbWidth,cbHeight, | |
2a21ac15 | 721 | cbWidth,cbHeight, false ); // false - bar is "flexible" |
03206f17 VS |
722 | |
723 | cbWidth = 120; | |
724 | cbHeight = 40; | |
2a21ac15 | 725 | |
03206f17 VS |
726 | cbDimInfo sizes3( cbWidth,cbHeight, |
727 | cbWidth,cbHeight, | |
2a21ac15 DS |
728 | cbWidth,cbHeight, true ); // -/- |
729 | ||
03206f17 VS |
730 | cbWidth = 200; |
731 | cbHeight = 150; | |
2a21ac15 | 732 | |
03206f17 VS |
733 | cbDimInfo sizes4( cbWidth,cbHeight, |
734 | cbWidth,cbHeight, | |
2a21ac15 DS |
735 | cbWidth,cbHeight, false ); // -/- |
736 | ||
03206f17 VS |
737 | cbWidth = 63; |
738 | cbHeight = 31; | |
2a21ac15 | 739 | |
03206f17 VS |
740 | cbDimInfo sizes5( cbWidth,cbHeight, |
741 | cbHeight,cbWidth, | |
2a21ac15 | 742 | cbWidth,cbHeight, true, |
03206f17 VS |
743 | 3, // vertical gap (bar border) |
744 | 3 // horizontal gap (bar border) | |
745 | ); // -/- | |
2a21ac15 DS |
746 | |
747 | ||
03206f17 VS |
748 | if ( layoutNo == FIRST_LAYOUT ) |
749 | { | |
750 | // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info) | |
2a21ac15 | 751 | |
03206f17 | 752 | wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm); |
2a21ac15 | 753 | |
03206f17 | 754 | pGreenOne->SetBackgroundColour( wxColour(128,255,128) ); |
2a21ac15 DS |
755 | |
756 | layout.AddBar( pGreenOne, sizes, FL_ALIGN_TOP, 0, 50, wxT("Bar1"), true ); | |
757 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_TOP, 2, 50, wxT("Bar2"), true ); | |
758 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_BOTTOM, 2, 50, wxT("Bar3"), true ); | |
759 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_LEFT, 2, 50, wxT("Bar4"), true ); | |
760 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes1, wxCBAR_HIDDEN, 2, 50, wxT("Super-Bar"), true ); | |
03206f17 VS |
761 | } |
762 | else | |
763 | { | |
764 | if ( layoutNo == SECOND_LAYOUT ) | |
765 | { | |
766 | // show off various wx-controls in the second layout | |
2a21ac15 | 767 | |
05aa1fc7 JS |
768 | layout.AddBar( CreateTxtCtrl(), sizes, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area&0") ); |
769 | layout.AddBar( CreateButton(wxT("OK")), sizes, FL_ALIGN_TOP, 0, 100, wxT("First Button") ); | |
770 | layout.AddBar( CreateTxtCtrl(), sizes1, FL_ALIGN_BOTTOM, 0, 50, wxT("First Tree") ); | |
771 | layout.AddBar( CreateTreeCtrl(wxT("Root")), sizes1, FL_ALIGN_LEFT, 0, 0, wxT("TreeCtrl Window") ); | |
2a21ac15 DS |
772 | layout.AddBar( CreateChoice(wxT("Choice 1")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 1 (buggy)"), false, wxCBAR_HIDDEN ); |
773 | layout.AddBar( CreateChoice(wxT("Choice 2")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 2 (buggy)"), false, wxCBAR_HIDDEN ); | |
05aa1fc7 JS |
774 | layout.AddBar( CreateTreeCtrl(wxT("X-Files")), sizes1, FL_ALIGN_RIGHT, 0, 100, wxT("X-Files") ); |
775 | layout.AddBar( CreateTxtCtrl(wxT("smaller1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("smaller Area1") ); | |
776 | layout.AddBar( CreateTxtCtrl(wxT("smaller2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("sm&ller Area2") ); | |
03206f17 VS |
777 | } |
778 | else | |
779 | { | |
780 | if ( layoutNo == THIRD_LAYOUT ) | |
781 | { | |
782 | #if defined(__WXGTK__) || defined(__WXX11__) | |
783 | cbCommonPaneProperties props; | |
784 | layout.GetPaneProperties( props ); | |
2a21ac15 | 785 | props.mRealTimeUpdatesOn = false; // real-time OFF for gtk!!! |
03206f17 VS |
786 | layout.SetPaneProperties( props, wxALL_PANES ); |
787 | #endif | |
2a21ac15 | 788 | |
05aa1fc7 JS |
789 | layout.AddBar( CreateTxtCtrl(wxT("Tool1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area1") ); |
790 | layout.AddBar( CreateTxtCtrl(wxT("Tool2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area2") ); | |
791 | layout.AddBar( CreateTxtCtrl(wxT("Tool3")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area3") ); | |
792 | layout.AddBar( CreateTxtCtrl(wxT("Tool4")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area4") ); | |
793 | layout.AddBar( CreateTxtCtrl(wxT("Tool5")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area5") ); | |
794 | layout.AddBar( CreateTxtCtrl(wxT("Tool6")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area6") ); | |
795 | layout.AddBar( CreateTxtCtrl(wxT("Tool7")), sizes3, FL_ALIGN_TOP, 2,250, wxT("Fixed text Area7") ); | |
2a21ac15 DS |
796 | |
797 | cbDimInfo sizes10( 175,35, // when docked horizontally | |
798 | 175,38, // when docked vertically | |
799 | 170,35, // when floated | |
800 | true, // the bar is not fixed-size | |
03206f17 VS |
801 | 4, // vertical gap (bar border) |
802 | 4, // horizontal gap (bar border) | |
803 | new cbDynToolBarDimHandler() | |
2a21ac15 DS |
804 | ); |
805 | ||
03206f17 | 806 | wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); |
2a21ac15 DS |
807 | |
808 | pToolBar->Create( mpInternalFrm, wxID_ANY ); | |
809 | ||
03206f17 | 810 | // 1001-1006 ids of command events fired by added tool-buttons |
2a21ac15 | 811 | |
05aa1fc7 JS |
812 | pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") ); |
813 | pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") ); | |
814 | pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") ); | |
2a21ac15 | 815 | |
05aa1fc7 JS |
816 | pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") ); |
817 | pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") ); | |
818 | pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") ); | |
2a21ac15 | 819 | |
03206f17 VS |
820 | layout.AddBar( pToolBar, // bar window (can be NULL) |
821 | sizes10, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) | |
822 | 0, // insert into 0th row (vert. position) | |
823 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 824 | wxT("Real-Toolbar"), // name to refere in customization pop-ups |
2a21ac15 | 825 | false |
03206f17 | 826 | ); |
2a21ac15 | 827 | |
03206f17 VS |
828 | // create first "developement" layout |
829 | AddSearchToolbars( layout, mpInternalFrm); | |
2a21ac15 | 830 | |
03206f17 | 831 | wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm); |
2a21ac15 | 832 | |
03206f17 VS |
833 | // create another ***secreat developement*** layout inside |
834 | // the third sheet of the outter one's output bar | |
2a21ac15 DS |
835 | |
836 | mpNestedLayout = new wxFrameLayout( pSheet3, | |
837 | CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3), false ); | |
838 | ||
03206f17 | 839 | CreateDevLayout( *mpNestedLayout, pSheet3 ); |
2a21ac15 | 840 | |
03206f17 VS |
841 | mpNestedLayout->Activate(); |
842 | } | |
843 | } | |
844 | } | |
2a21ac15 | 845 | } |
03206f17 VS |
846 | |
847 | void MyFrame::CreateLayout( int layoutNo ) | |
848 | { | |
2a21ac15 DS |
849 | wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, false ); |
850 | ||
03206f17 VS |
851 | if ( layoutNo == THIRD_LAYOUT ) |
852 | { | |
853 | pLayout->PushDefaultPlugins(); | |
854 | pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars | |
2a21ac15 | 855 | #if defined(__WXGTK__) || defined(__WXX11__) |
03206f17 VS |
856 | pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); |
857 | #endif | |
2a21ac15 | 858 | pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); |
03206f17 | 859 | } |
2a21ac15 | 860 | |
03206f17 | 861 | mLayouts[layoutNo] = pLayout; |
2a21ac15 | 862 | |
03206f17 VS |
863 | DropInSomeBars( layoutNo ); |
864 | } | |
865 | ||
866 | void MyFrame::RemoveLayout( int layoutNo ) | |
867 | { | |
868 | wxFrameLayout* pLayout = mLayouts[layoutNo]; | |
2a21ac15 DS |
869 | |
870 | if ( !pLayout ) | |
03206f17 | 871 | return; |
2a21ac15 | 872 | |
03206f17 | 873 | pLayout->HideBarWindows(); |
2a21ac15 | 874 | |
03206f17 | 875 | // destroy nested layout first |
2a21ac15 | 876 | |
03206f17 VS |
877 | if ( layoutNo == THIRD_LAYOUT ) |
878 | { | |
2a21ac15 | 879 | if ( mpNestedLayout ) |
03206f17 VS |
880 | delete mpNestedLayout; |
881 | mpNestedLayout = NULL; | |
882 | } | |
2a21ac15 DS |
883 | |
884 | // NOTE:: bar windows are NOT destroyed automatically by frame-layout | |
885 | ||
03206f17 | 886 | pLayout->DestroyBarWindows(); |
2a21ac15 | 887 | |
03206f17 | 888 | delete pLayout; |
2a21ac15 | 889 | |
03206f17 | 890 | mLayouts[layoutNo] = NULL; |
2a21ac15 | 891 | |
03206f17 VS |
892 | Refresh(); |
893 | } | |
894 | ||
895 | void MyFrame::SyncMenuBarItems() | |
896 | { | |
897 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
898 | { | |
899 | GetMenuBar()->Check( ID_FIRST+i, mActiveLayoutNo == FIRST_LAYOUT+i ); | |
900 | } | |
2a21ac15 | 901 | |
03206f17 VS |
902 | GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave ); |
903 | } | |
904 | ||
905 | void MyFrame::ActivateLayout( int layoutNo ) | |
906 | { | |
2a21ac15 | 907 | if ( layoutNo == mActiveLayoutNo ) |
03206f17 | 908 | return; |
2a21ac15 | 909 | |
03206f17 VS |
910 | if ( mLayouts[mActiveLayoutNo] ) |
911 | mLayouts[mActiveLayoutNo]->Deactivate(); | |
2a21ac15 | 912 | |
03206f17 | 913 | mActiveLayoutNo = layoutNo; |
2a21ac15 DS |
914 | |
915 | if ( mLayouts[mActiveLayoutNo] ) | |
03206f17 VS |
916 | mLayouts[mActiveLayoutNo]->Activate(); |
917 | else | |
918 | Refresh(); | |
2a21ac15 | 919 | |
03206f17 VS |
920 | SyncMenuBarItems(); |
921 | } | |
922 | ||
923 | /***** Implementation for class StartButton95 (just for fun) *****/ | |
924 | ||
925 | IMPLEMENT_DYNAMIC_CLASS( StartButton95, wxPanel ) | |
926 | ||
927 | BEGIN_EVENT_TABLE( StartButton95, wxPanel ) | |
928 | EVT_LEFT_DOWN( StartButton95::OnMouseDown ) | |
929 | EVT_LEFT_UP ( StartButton95::OnMouseUp ) | |
930 | EVT_PAINT ( StartButton95::OnPaint ) | |
931 | END_EVENT_TABLE() | |
932 | ||
8552e6f0 | 933 | void StartButton95::OnMouseDown( wxMouseEvent& WXUNUSED(event) ) |
03206f17 | 934 | { |
2a21ac15 | 935 | m_bPressed = true; |
03206f17 VS |
936 | Refresh(); |
937 | CaptureMouse(); | |
938 | } | |
939 | ||
8552e6f0 | 940 | void StartButton95::OnMouseUp( wxMouseEvent& WXUNUSED(event) ) |
03206f17 VS |
941 | { |
942 | // "this is not a bug" | |
2a21ac15 | 943 | |
03206f17 VS |
944 | SetCursor( wxCURSOR_WAIT ); |
945 | GetParent()->SetCursor( wxCURSOR_WAIT ); | |
2a21ac15 | 946 | ::wxSetCursor( wxCURSOR_WAIT ); |
03206f17 | 947 | wxSleep(1); |
2a21ac15 DS |
948 | |
949 | for( int i = 1; i != 6; ++i ) | |
950 | { | |
03206f17 VS |
951 | m_bPressed = (i % 2) != 0; |
952 | Refresh(); | |
953 | wxSleep(1); | |
954 | } | |
955 | GetParent()->Close(); | |
956 | //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this??? | |
957 | } | |
958 | ||
8552e6f0 | 959 | void StartButton95::OnPaint( wxPaintEvent& WXUNUSED(event) ) |
03206f17 | 960 | { |
8552e6f0 | 961 | wxBitmap* pBmp; |
2a21ac15 | 962 | |
03206f17 VS |
963 | if ( m_bPressed ) |
964 | { | |
05aa1fc7 | 965 | if ( !m_PBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp") ) ) |
2a21ac15 | 966 | |
05aa1fc7 | 967 | m_PBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP ); |
2a21ac15 | 968 | |
03206f17 VS |
969 | pBmp = &m_PBmp; |
970 | } | |
971 | else | |
972 | { | |
05aa1fc7 | 973 | if ( !m_DBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp") ) ) |
2a21ac15 | 974 | |
05aa1fc7 | 975 | m_DBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP ); |
2a21ac15 | 976 | |
03206f17 VS |
977 | pBmp = &m_DBmp; |
978 | } | |
2a21ac15 | 979 | |
03206f17 VS |
980 | if (!pBmp) return; |
981 | wxMemoryDC mdc; | |
982 | wxPaintDC dc(this); | |
983 | mdc.SelectObject( *pBmp ); | |
2a21ac15 | 984 | |
03206f17 | 985 | dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY ); |
2a21ac15 | 986 | |
03206f17 VS |
987 | mdc.SelectObject( wxNullBitmap ); |
988 | } |