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