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