]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_demo2.cpp
Regenerated makefiles for runtime lib change
[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 #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
27 // wxWidgets headers.
28 #include "wx/treectrl.h"
29 #include "wx/imaglist.h"
30 #include "wx/notebook.h"
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
58 MyFrame *frame = new MyFrame(NULL, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540);
59
60 // Give it an icon
61 #ifdef __WINDOWS__
62 frame->SetIcon(wxIcon(wxT("mondrian")));
63 #endif
64 #ifdef __X__
65 frame->SetIcon(wxIcon(wxT("aiai.xbm")));
66 #endif
67
68 // Make a menubar
69 wxMenu *file_menu = new wxMenu;
70 wxMenu *active_menu = new wxMenu;
71
72 file_menu->Append( ID_LOAD, _("&Load layouts") );
73 file_menu->Append( ID_STORE, _("&Store layouts") );
74 file_menu->AppendSeparator();
75
76 file_menu->Append( ID_AUTOSAVE, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK );
77 file_menu->AppendSeparator();
78
79 file_menu->Append(MINIMAL_ABOUT, _("A&bout !"));
80 file_menu->Append(MINIMAL_QUIT, _("E&xit\tTab"));
81
82 //active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") );
83 //active_menu->AppendSeparator();
84
85 active_menu->Append( ID_REMOVE, _("&Remove Active") );
86 active_menu->Append( ID_REMOVEALL, _("Remove &All") );
87 active_menu->Append( ID_RECREATE, _("Re&create") );
88 active_menu->AppendSeparator();
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
94 wxMenuBar *menu_bar = new wxMenuBar;
95
96 menu_bar->Append(file_menu, _("&File"));
97 menu_bar->Append(active_menu, _("Active &Layout"));
98
99 #if wxUSE_STATUSBAR
100 frame->CreateStatusBar(3);
101 #endif // wxUSE_STATUSBAR
102
103 frame->SetMenuBar(menu_bar);
104
105 frame->SyncMenuBarItems();
106
107 // Show the frame
108 frame->Show(true);
109
110 SetTopWindow(frame);
111
112 return true;
113 }
114
115 MyFrame::~MyFrame()
116 {
117 // frame-layouts is not a windows (objects), thus should
118 // be cleaned up manually
119
120 for( int i = 0; i != MAX_LAYOUTS; ++i )
121 {
122 if ( mLayouts[i] )
123 delete mLayouts[i];
124 }
125
126 if ( mpNestedLayout )
127 delete mpNestedLayout;
128 if ( mpAboutBoxLayout )
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
159 MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h)
160 : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
161 mpNestedLayout( NULL ),
162 mpAboutBoxLayout( NULL ),
163
164 mActiveLayoutNo( FIRST_LAYOUT ),
165 mAutoSave( true ),
166 mSavedAlready( false ),
167 mpClntWindow( NULL ),
168
169 mImageList( 16,16, false, 2 )
170 {
171 int i;
172
173 mpInternalFrm = (wxPanel*)this;
174
175 mAboutBox.Create( this, wxID_ANY, _T("About box in wxWidgets style..."),
176 wxDefaultPosition,
177 wxSize( 385,220),
178 wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL );
179
180 for( i = 0; i != MAX_LAYOUTS; ++i )
181 mLayouts[i] = NULL;
182
183 // image-list is one of the few objects which
184 // currently cannot be serialized, create it first
185 // and use it as initial reference (IR)
186
187 wxBitmap bmp1,bmp2;
188
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 );
191
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 );
194
195 mImageList.Add( bmp1 );
196 mImageList.Add( bmp2 );
197
198 InitAboutBox();
199
200 // create multiple layouts
201
202 mpNestedLayout = 0;
203
204 mpClntWindow = CreateTxtCtrl(wxT("client window"));
205
206 // Create all layouts
207 for( i = 0; i != MAX_LAYOUTS; ++i )
208 {
209 CreateLayout( i );
210 }
211 // hide others
212 for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i )
213 {
214 mLayouts[i]->HideBarWindows();
215 }
216
217 // activate first one
218 mLayouts[FIRST_LAYOUT]->Activate();
219 mActiveLayoutNo = FIRST_LAYOUT;
220 }
221
222 /*** event handlers ***/
223
224 bool MyFrame::OnClose(void)
225 {
226 // USEFUL TRICK:: avoids flickering of application's frame
227 // when closing NN windows on exit:
228
229 Show(false);
230
231 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
232 {
233 }
234 else
235 {
236 wxCommandEvent evt;
237 OnStore(evt);
238 }
239
240 mAboutBox.Destroy();
241 Destroy();
242
243 return true;
244 }
245
246 void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) )
247 {
248 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
249 }
250
251 void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) )
252 {
253 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
254 }
255
256 void MyFrame::OnAutoSave( wxCommandEvent& WXUNUSED(event) )
257 {
258 mAutoSave = !mAutoSave;
259
260 wxCommandEvent evt;
261 OnStore(evt);
262
263 SyncMenuBarItems();
264 }
265
266 void MyFrame::OnRemove( wxCommandEvent& WXUNUSED(event) )
267 {
268 RemoveLayout( mActiveLayoutNo );
269
270 Refresh();
271 }
272
273 void MyFrame::OnRemoveAll( wxCommandEvent& WXUNUSED(event) )
274 {
275 for( int i = 0; i != MAX_LAYOUTS; ++i )
276 {
277 RemoveLayout( i );
278 }
279
280 Refresh();
281 }
282
283
284 void MyFrame::OnRecreate( wxCommandEvent& event )
285 {
286 OnRemove( event ); // first destroy active layout
287
288 CreateLayout( mActiveLayoutNo );
289
290 mLayouts[mActiveLayoutNo]->Activate();
291 }
292
293 void MyFrame::OnFirst( wxCommandEvent& WXUNUSED(event) )
294 {
295 ActivateLayout( FIRST_LAYOUT );
296 }
297
298 void MyFrame::OnSecond( wxCommandEvent& WXUNUSED(event) )
299 {
300 ActivateLayout( SECOND_LAYOUT );
301 }
302
303 void MyFrame::OnThird( wxCommandEvent& WXUNUSED(event) )
304 {
305 ActivateLayout( THIRD_LAYOUT );
306 }
307
308 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
309 {
310 // USEFUL TRICK:: avoids flickering of application's frame
311 // when closing NN windows on exit:
312
313 Show(false);
314
315 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
316 {
317 }
318 else
319 {
320 wxCommandEvent evt;
321 OnStore(evt);
322 }
323
324 Destroy();
325 }
326
327 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
328 {
329 wxFont font;
330 #ifdef __WXMSW__
331 font.SetFaceName(wxT("MS Sans Serif"));
332 #else
333 font.SetFamily( wxSWISS );
334 #endif
335
336 font.SetStyle( wxSLANT );
337 font.SetWeight( wxNORMAL );
338 font.SetPointSize( 8 );
339
340 #ifdef __WXMSW__
341 font.RealizeResource();
342 #endif
343
344 mAboutBox.Center( wxBOTH );
345 mAboutBox.Show(true);
346
347 }
348
349 void MyFrame::OnChar( wxKeyEvent& event )
350 {
351 wxCommandEvent evt;
352
353 if ( event.m_keyCode == WXK_F1 )
354 {
355 OnFirst( evt );
356 }
357 else
358 {
359 if ( event.m_keyCode == WXK_F2 )
360 {
361 OnSecond( evt );
362 }
363 else
364 {
365 if ( event.m_keyCode == WXK_F3 )
366 {
367 OnThird( evt );
368 }
369 if ( event.m_keyCode == WXK_F4 && !event.AltDown() )
370 {
371 // "AI" :-)
372 wxMessageBox(_("There are only 3 layouts in this demo :-("));
373 }
374 else
375 {
376 if ( event.m_keyCode == WXK_TAB )
377 {
378 // USEFUL TRICK:: avoids flickering of application's frame
379 // when closing NN windows on exit:
380
381 Show(false);
382
383 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
384 {
385 }
386 else
387 {
388 wxCommandEvent evt;
389 OnStore(evt);
390 }
391
392 Destroy();
393 }
394 else
395 {
396 event.Skip();
397 }
398 }
399 }
400 }
401 }
402
403 void MyFrame::OnSayItsOk( wxCommandEvent& WXUNUSED(event) )
404 {
405 wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
406 }
407
408 void MyFrame::OnBtnYes( wxCommandEvent& WXUNUSED(event) )
409 {
410 mAboutBox.Show(false);
411 }
412
413 void MyFrame::OnBtnNo( wxCommandEvent& WXUNUSED(event) )
414 {
415 mAboutBox.Show(false);
416 }
417
418 void MyFrame::OnBtnEsc( wxCommandEvent& WXUNUSED(event) )
419 {
420 mAboutBox.Show(false);
421 }
422
423 /*** helper methods ***/
424
425 void MyFrame::InitAboutBox()
426 {
427 wxPanel* pArea = new wxPanel();
428
429 pArea->Create( &mAboutBox, wxID_ANY );
430
431 new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."),
432 wxPoint(10, 10) );
433
434 new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"),
435 wxPoint(10, 30) );
436
437 new wxStaticText(pArea, wxID_ANY, _("<mailto:alex@soften.ktu.lt>"),
438 wxPoint(10, 50) );
439
440 mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true );
441
442 wxFrameLayout& layout = *mpAboutBoxLayout;
443
444 cbDimInfo sizes( 90,40, // when docked horizontally
445 45,55, // when docked vertically
446 90,40, // when floated
447 true, 4, 4 // true - bar is fixed-size
448 );
449
450
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 );
454
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"));
458
459 layout.mBorderPen.SetColour( 192, 192, 192 );
460 layout.SetMargins( 15, 15, 15, 15, wxALL_PANES );
461
462 cbCommonPaneProperties props;
463
464 layout.GetPaneProperties( props, FL_ALIGN_TOP );
465
466 props.mShow3DPaneBorderOn = false;
467
468 layout.SetPaneProperties( props, wxALL_PANES );
469
470 layout.Activate();
471
472 pYes->SetDefault();
473 pYes->SetFocus();
474 }
475
476 wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent )
477 {
478 return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm,
479 wxID_ANY, txt, wxDefaultPosition, wxDefaultSize,
480 wxTE_MULTILINE );
481 }
482
483 wxButton* MyFrame::CreateButton( const wxString& label,
484 wxWindow* pParent, long id )
485 {
486 return new wxButton( (pParent)?pParent : mpInternalFrm, id,
487 label, wxPoint( 0,0 ), wxSize( 0,0 ) );
488 }
489
490 wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label )
491 {
492 wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, wxID_ANY );
493
494 const wxTreeItemId rootid = pTree->AddRoot(label);
495
496 if ( label.StartsWith(_T("X")) )
497 {
498 pTree->AppendItem(rootid, _("Scully"));
499 pTree->AppendItem(rootid, _("Mulder"));
500 }
501 else
502 {
503 pTree->AppendItem(rootid, _("Leaf1"));
504 pTree->AppendItem(rootid, _("Leaf2"));
505 }
506
507 return pTree;
508 }
509
510 wxChoice* MyFrame::CreateChoice( const wxString& txt )
511 {
512 wxString choice_strings[5];
513
514 choice_strings[0] = txt;
515 choice_strings[1] = _("Julian");
516 choice_strings[2] = _("Hattie");
517 choice_strings[3] = _("Ken");
518 choice_strings[4] = _("Dick");
519
520 wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition,
521 wxDefaultSize, 5, choice_strings);
522
523 choice->SetSelection(0);
524
525 return choice;
526 }
527
528 // helper
529
530 void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* WXUNUSED(pParent) )
531 {
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
536 4, // vertical gap (bar border)
537 4, // horizontal gap (bar border)
538 new cbDynToolBarDimHandler()
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
545 4, // vertical gap (bar border)
546 4, // horizontal gap (bar border)
547 new cbDynToolBarDimHandler()
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
554 4, // vertical gap (bar border)
555 4, // horizontal gap (bar border)
556 new cbDynToolBarDimHandler()
557 );
558
559 wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
560
561 wxChoice* pChoice = new wxChoice( pTBar2, wxID_ANY, wxDefaultPosition, wxSize( 140,25 ) );
562
563 pTBar2->AddTool( 1, pChoice );
564 pTBar2->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("search.bmp") );
565 //pTBar2->AddSeparator();
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") );
569
570 wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
571
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 ")) );
575 //pTBar3->AddSeparator();
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 ")) );
579
580 #ifdef __WXMSW__
581 pTBar3->EnableTool( 2, false );
582 #endif
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 );
589 //pTBar4->AddSeparator();
590 pTBar4->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Search ")), true );
591
592 #ifdef __WXMSW__
593 pTBar4->EnableTool( 4, false );
594 #endif
595
596 layout.AddBar( pTBar2,
597 sizes2, FL_ALIGN_TOP,
598 0,
599 0,
600 wxT("Search"),
601 true
602 );
603
604 layout.AddBar( pTBar3,
605 sizes3, FL_ALIGN_BOTTOM,
606 0,
607 0,
608 wxT("Titled"),
609 true
610 );
611
612 layout.AddBar( pTBar4,
613 sizes4, FL_ALIGN_BOTTOM,
614 1,
615 0,
616 wxT("Bookmarks"),
617 true
618 );
619 }
620
621 wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
622 {
623 bool isNested = (pParent != mpInternalFrm);
624
625 // check if we're craeting nested layout
626 if ( isNested )
627 {
628 layout.mBorderPen.SetColour( 128,255,128 );
629
630 // if so, than make border smaller
631 for( int i = 0; i != MAX_PANES; ++i )
632 {
633 cbDockPane& pane = *layout.GetPane( i );
634
635 pane.mTopMargin = 5;
636 pane.mBottomMargin = 5;
637 pane.mLeftMargin = 5;
638 pane.mRightMargin = 5;
639 }
640 }
641
642 int cbWidth = 200;
643 int cbHeight = ( isNested ) ? 50 : 150;
644
645 cbDimInfo sizes4( cbWidth,cbHeight,
646 cbWidth,cbHeight,
647 cbWidth,cbHeight, false );
648
649 cbWidth = 75;
650 cbHeight = 31;
651
652 cbDimInfo sizes5( cbWidth,cbHeight,
653 42,65,
654 cbWidth,cbHeight, true,
655 3, // vertical gap (bar border)
656 3 // horizontal gap (bar border)
657 );
658
659 // create "workplace" window in the third layout
660 // SEB: originally here was a wxpp (wxWorkshop) class demotrated
661 // wxTabbedWindow* pMiniTabArea = new wxTabbedWindow();
662 // pMiniTabArea->Create( pParent, wxID_ANY );
663
664
665 wxTreeCtrl* pClassView = new wxTreeCtrl( pParent, wxID_ANY,
666 wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS );
667
668 pClassView->SetImageList( &mImageList );
669
670 wxTreeItemId rootId = pClassView->AddRoot( wxT("wxWidgets 2.0 classes"), 0 );
671
672 pClassView->AppendItem( rootId, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
673 pClassView->AppendItem( rootId, _("serializer-classes (grabbed at run-time)"), 0 );
674
675 // now create "output" window
676 wxNotebook* pTabbedArea = new wxNotebook(pParent, wxID_ANY);
677 // SEB: originally here was a wxpp (wxWorkshop) class used
678 // wxPaggedWindow* pTabbedArea = new wxPaggedWindow();
679 // pTabbedArea->Create( pParent, wxID_ANY );
680
681 wxPanel* pSheet3 = new wxPanel();
682 pSheet3->Create( pTabbedArea, wxID_ANY );
683 pSheet3->Show(false);
684
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"));
689
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") );
693
694 return pSheet3;
695 }
696
697 void MyFrame::DropInSomeBars( int layoutNo )
698 {
699 /* create once... and forget! */
700
701 // setup dimension infos for various bar shapes
702
703 int cbWidth = 90;
704 int cbHeight = 30;
705
706 if ( layoutNo == SECOND_LAYOUT )
707 cbHeight = 60;
708
709 wxFrameLayout& layout = *mLayouts[layoutNo];
710
711 cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally
712 cbWidth,cbHeight, // when docked vertically
713 cbWidth,cbHeight, // when floated
714 true // true - bar is fixed-size
715 );
716
717 cbWidth = 120;
718
719 cbDimInfo sizes1( cbWidth,cbHeight,
720 cbWidth,cbHeight,
721 cbWidth,cbHeight, false ); // false - bar is "flexible"
722
723 cbWidth = 120;
724 cbHeight = 40;
725
726 cbDimInfo sizes3( cbWidth,cbHeight,
727 cbWidth,cbHeight,
728 cbWidth,cbHeight, true ); // -/-
729
730 cbWidth = 200;
731 cbHeight = 150;
732
733 cbDimInfo sizes4( cbWidth,cbHeight,
734 cbWidth,cbHeight,
735 cbWidth,cbHeight, false ); // -/-
736
737 cbWidth = 63;
738 cbHeight = 31;
739
740 cbDimInfo sizes5( cbWidth,cbHeight,
741 cbHeight,cbWidth,
742 cbWidth,cbHeight, true,
743 3, // vertical gap (bar border)
744 3 // horizontal gap (bar border)
745 ); // -/-
746
747
748 if ( layoutNo == FIRST_LAYOUT )
749 {
750 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
751
752 wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm);
753
754 pGreenOne->SetBackgroundColour( wxColour(128,255,128) );
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 );
761 }
762 else
763 {
764 if ( layoutNo == SECOND_LAYOUT )
765 {
766 // show off various wx-controls in the second layout
767
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") );
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 );
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") );
777 }
778 else
779 {
780 if ( layoutNo == THIRD_LAYOUT )
781 {
782 #if defined(__WXGTK__) || defined(__WXX11__)
783 cbCommonPaneProperties props;
784 layout.GetPaneProperties( props );
785 props.mRealTimeUpdatesOn = false; // real-time OFF for gtk!!!
786 layout.SetPaneProperties( props, wxALL_PANES );
787 #endif
788
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") );
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
801 4, // vertical gap (bar border)
802 4, // horizontal gap (bar border)
803 new cbDynToolBarDimHandler()
804 );
805
806 wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
807
808 pToolBar->Create( mpInternalFrm, wxID_ANY );
809
810 // 1001-1006 ids of command events fired by added tool-buttons
811
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") );
815
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") );
819
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)
824 wxT("Real-Toolbar"), // name to refere in customization pop-ups
825 false
826 );
827
828 // create first "developement" layout
829 AddSearchToolbars( layout, mpInternalFrm);
830
831 wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm);
832
833 // create another ***secreat developement*** layout inside
834 // the third sheet of the outter one's output bar
835
836 mpNestedLayout = new wxFrameLayout( pSheet3,
837 CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3), false );
838
839 CreateDevLayout( *mpNestedLayout, pSheet3 );
840
841 mpNestedLayout->Activate();
842 }
843 }
844 }
845 }
846
847 void MyFrame::CreateLayout( int layoutNo )
848 {
849 wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, false );
850
851 if ( layoutNo == THIRD_LAYOUT )
852 {
853 pLayout->PushDefaultPlugins();
854 pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
855 #if defined(__WXGTK__) || defined(__WXX11__)
856 pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
857 #endif
858 pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
859 }
860
861 mLayouts[layoutNo] = pLayout;
862
863 DropInSomeBars( layoutNo );
864 }
865
866 void MyFrame::RemoveLayout( int layoutNo )
867 {
868 wxFrameLayout* pLayout = mLayouts[layoutNo];
869
870 if ( !pLayout )
871 return;
872
873 pLayout->HideBarWindows();
874
875 // destroy nested layout first
876
877 if ( layoutNo == THIRD_LAYOUT )
878 {
879 if ( mpNestedLayout )
880 delete mpNestedLayout;
881 mpNestedLayout = NULL;
882 }
883
884 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
885
886 pLayout->DestroyBarWindows();
887
888 delete pLayout;
889
890 mLayouts[layoutNo] = NULL;
891
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 }
901
902 GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave );
903 }
904
905 void MyFrame::ActivateLayout( int layoutNo )
906 {
907 if ( layoutNo == mActiveLayoutNo )
908 return;
909
910 if ( mLayouts[mActiveLayoutNo] )
911 mLayouts[mActiveLayoutNo]->Deactivate();
912
913 mActiveLayoutNo = layoutNo;
914
915 if ( mLayouts[mActiveLayoutNo] )
916 mLayouts[mActiveLayoutNo]->Activate();
917 else
918 Refresh();
919
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
933 void StartButton95::OnMouseDown( wxMouseEvent& WXUNUSED(event) )
934 {
935 m_bPressed = true;
936 Refresh();
937 CaptureMouse();
938 }
939
940 void StartButton95::OnMouseUp( wxMouseEvent& WXUNUSED(event) )
941 {
942 // "this is not a bug"
943
944 SetCursor( wxCURSOR_WAIT );
945 GetParent()->SetCursor( wxCURSOR_WAIT );
946 ::wxSetCursor( wxCURSOR_WAIT );
947 wxSleep(1);
948
949 for( int i = 1; i != 6; ++i )
950 {
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
959 void StartButton95::OnPaint( wxPaintEvent& WXUNUSED(event) )
960 {
961 wxBitmap* pBmp;
962
963 if ( m_bPressed )
964 {
965 if ( !m_PBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp") ) )
966
967 m_PBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP );
968
969 pBmp = &m_PBmp;
970 }
971 else
972 {
973 if ( !m_DBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp") ) )
974
975 m_DBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP );
976
977 pBmp = &m_DBmp;
978 }
979
980 if (!pBmp) return;
981 wxMemoryDC mdc;
982 wxPaintDC dc(this);
983 mdc.SelectObject( *pBmp );
984
985 dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY );
986
987 mdc.SelectObject( wxNullBitmap );
988 }