1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by: Sebastian Haase (June 21, 2001)
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "fl_demo2.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/treectrl.h"
29 #include "wx/imaglist.h"
30 #include "wx/notebook.h"
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"
40 // some extra fl plugins.
41 #include "wx/fl/barhintspl.h"
42 #include "wx/fl/hintanimpl.h"
44 #include "wx/fl/dyntbar.h"
45 #include "wx/fl/dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
49 /***** Implementation for class MyApp *****/
51 // Create a new application object
54 // `Main program' equivalent, creating windows and returning main app frame
55 bool MyApp::OnInit(void)
57 // Create the main frame window
58 MyFrame
*frame
= new MyFrame(NULL
, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540);
62 frame
->SetIcon(wxIcon(wxT("mondrian")));
65 frame
->SetIcon(wxIcon(wxT("aiai.xbm")));
69 wxMenu
*file_menu
= new wxMenu
;
70 wxMenu
*active_menu
= new wxMenu
;
72 file_menu
->Append( ID_LOAD
, _("&Load layouts") );
73 file_menu
->Append( ID_STORE
, _("&Store layouts") );
74 file_menu
->AppendSeparator();
76 file_menu
->Append( ID_AUTOSAVE
, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK
);
77 file_menu
->AppendSeparator();
79 file_menu
->Append(MINIMAL_ABOUT
, _("A&bout !"));
80 file_menu
->Append(MINIMAL_QUIT
, _("E&xit\tTab"));
82 //active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") );
83 //active_menu->AppendSeparator();
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();
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
);
94 wxMenuBar
*menu_bar
= new wxMenuBar
;
96 menu_bar
->Append(file_menu
, _("&File"));
97 menu_bar
->Append(active_menu
, _("Active &Layout"));
100 frame
->CreateStatusBar(3);
101 #endif // wxUSE_STATUSBAR
103 frame
->SetMenuBar(menu_bar
);
105 frame
->SyncMenuBarItems();
117 // frame-layouts is not a windows (objects), thus should
118 // be cleaned up manually
120 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
126 if ( mpNestedLayout
)
127 delete mpNestedLayout
;
128 if ( mpAboutBoxLayout
)
129 delete mpAboutBoxLayout
;
132 /***** Implementation for class MyFrame *****/
134 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
135 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
136 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
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
)
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
)
154 EVT_CHAR_HOOK( MyFrame::OnChar
)
157 // My frame constructor
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
),
164 mActiveLayoutNo( FIRST_LAYOUT
),
166 mSavedAlready( false ),
167 mpClntWindow( NULL
),
169 mImageList( 16,16, false, 2 )
173 mpInternalFrm
= (wxPanel
*)this;
175 mAboutBox
.Create( this, wxID_ANY
, _T("About box in wxWidgets style..."),
178 wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
180 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
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)
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
);
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
);
195 mImageList
.Add( bmp1
);
196 mImageList
.Add( bmp2
);
200 // create multiple layouts
204 mpClntWindow
= CreateTxtCtrl(wxT("client window"));
206 // Create all layouts
207 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
212 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
214 mLayouts
[i
]->HideBarWindows();
217 // activate first one
218 mLayouts
[FIRST_LAYOUT
]->Activate();
219 mActiveLayoutNo
= FIRST_LAYOUT
;
222 /*** event handlers ***/
224 bool MyFrame::OnClose(void)
226 // USEFUL TRICK:: avoids flickering of application's frame
227 // when closing NN windows on exit:
231 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
246 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
248 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
251 void MyFrame::OnStore( wxCommandEvent
& WXUNUSED(event
) )
253 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
256 void MyFrame::OnAutoSave( wxCommandEvent
& WXUNUSED(event
) )
258 mAutoSave
= !mAutoSave
;
266 void MyFrame::OnRemove( wxCommandEvent
& WXUNUSED(event
) )
268 RemoveLayout( mActiveLayoutNo
);
273 void MyFrame::OnRemoveAll( wxCommandEvent
& WXUNUSED(event
) )
275 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
284 void MyFrame::OnRecreate( wxCommandEvent
& event
)
286 OnRemove( event
); // first destroy active layout
288 CreateLayout( mActiveLayoutNo
);
290 mLayouts
[mActiveLayoutNo
]->Activate();
293 void MyFrame::OnFirst( wxCommandEvent
& WXUNUSED(event
) )
295 ActivateLayout( FIRST_LAYOUT
);
298 void MyFrame::OnSecond( wxCommandEvent
& WXUNUSED(event
) )
300 ActivateLayout( SECOND_LAYOUT
);
303 void MyFrame::OnThird( wxCommandEvent
& WXUNUSED(event
) )
305 ActivateLayout( THIRD_LAYOUT
);
308 void MyFrame::OnQuit( wxCommandEvent
& WXUNUSED(event
) )
310 // USEFUL TRICK:: avoids flickering of application's frame
311 // when closing NN windows on exit:
315 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
327 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
331 font
.SetFaceName(wxT("MS Sans Serif"));
333 font
.SetFamily( wxSWISS
);
336 font
.SetStyle( wxSLANT
);
337 font
.SetWeight( wxNORMAL
);
338 font
.SetPointSize( 8 );
341 font
.RealizeResource();
344 mAboutBox
.Center( wxBOTH
);
345 mAboutBox
.Show(true);
349 void MyFrame::OnChar( wxKeyEvent
& event
)
353 if ( event
.m_keyCode
== WXK_F1
)
359 if ( event
.m_keyCode
== WXK_F2
)
365 if ( event
.m_keyCode
== WXK_F3
)
369 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
372 wxMessageBox(_("There are only 3 layouts in this demo :-("));
376 if ( event
.m_keyCode
== WXK_TAB
)
378 // USEFUL TRICK:: avoids flickering of application's frame
379 // when closing NN windows on exit:
383 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
403 void MyFrame::OnSayItsOk( wxCommandEvent
& WXUNUSED(event
) )
405 wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
408 void MyFrame::OnBtnYes( wxCommandEvent
& WXUNUSED(event
) )
410 mAboutBox
.Show(false);
413 void MyFrame::OnBtnNo( wxCommandEvent
& WXUNUSED(event
) )
415 mAboutBox
.Show(false);
418 void MyFrame::OnBtnEsc( wxCommandEvent
& WXUNUSED(event
) )
420 mAboutBox
.Show(false);
423 /*** helper methods ***/
425 void MyFrame::InitAboutBox()
427 wxPanel
* pArea
= new wxPanel();
429 pArea
->Create( &mAboutBox
, wxID_ANY
);
431 new wxStaticText(pArea
, wxID_ANY
, _("This is wxFrameLayout contribution demo."),
434 new wxStaticText(pArea
, wxID_ANY
, _("Aleksandras Gluchovas (c) 1998"),
437 new wxStaticText(pArea
, wxID_ANY
, _("<mailto:alex@soften.ktu.lt>"),
440 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, true );
442 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
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
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
);
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"));
459 layout
.mBorderPen
.SetColour( 192, 192, 192 );
460 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
462 cbCommonPaneProperties props
;
464 layout
.GetPaneProperties( props
, FL_ALIGN_TOP
);
466 props
.mShow3DPaneBorderOn
= false;
468 layout
.SetPaneProperties( props
, wxALL_PANES
);
476 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
478 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
479 wxID_ANY
, txt
, wxDefaultPosition
, wxDefaultSize
,
483 wxButton
* MyFrame::CreateButton( const wxString
& label
,
484 wxWindow
* pParent
, long id
)
486 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
487 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
490 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
492 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, wxID_ANY
);
494 const wxTreeItemId rootid
= pTree
->AddRoot(label
);
496 if ( label
.StartsWith(_T("X")) )
498 pTree
->AppendItem(rootid
, _("Scully"));
499 pTree
->AppendItem(rootid
, _("Mulder"));
503 pTree
->AppendItem(rootid
, _("Leaf1"));
504 pTree
->AppendItem(rootid
, _("Leaf2"));
510 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
512 wxString choice_strings
[5];
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");
520 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
521 wxDefaultSize
, 5, choice_strings
);
523 choice
->SetSelection(0);
530 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* WXUNUSED(pParent
) )
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()
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()
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()
559 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
561 wxChoice
* pChoice
= new wxChoice( pTBar2
, wxID_ANY
, wxDefaultPosition
, wxSize( 140,25 ) );
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") );
570 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
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 ")) );
581 pTBar3
->EnableTool( 2, false );
584 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
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 );
593 pTBar4
->EnableTool( 4, false );
596 layout
.AddBar( pTBar2
,
597 sizes2
, FL_ALIGN_TOP
,
604 layout
.AddBar( pTBar3
,
605 sizes3
, FL_ALIGN_BOTTOM
,
612 layout
.AddBar( pTBar4
,
613 sizes4
, FL_ALIGN_BOTTOM
,
621 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
623 bool isNested
= (pParent
!= mpInternalFrm
);
625 // check if we're craeting nested layout
628 layout
.mBorderPen
.SetColour( 128,255,128 );
630 // if so, than make border smaller
631 for( int i
= 0; i
!= MAX_PANES
; ++i
)
633 cbDockPane
& pane
= *layout
.GetPane( i
);
636 pane
.mBottomMargin
= 5;
637 pane
.mLeftMargin
= 5;
638 pane
.mRightMargin
= 5;
643 int cbHeight
= ( isNested
) ? 50 : 150;
645 cbDimInfo
sizes4( cbWidth
,cbHeight
,
647 cbWidth
,cbHeight
, false );
652 cbDimInfo
sizes5( cbWidth
,cbHeight
,
654 cbWidth
,cbHeight
, true,
655 3, // vertical gap (bar border)
656 3 // horizontal gap (bar border)
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 );
665 wxTreeCtrl
* pClassView
= new wxTreeCtrl( pParent
, wxID_ANY
,
666 wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
668 pClassView
->SetImageList( &mImageList
);
670 wxTreeItemId rootId
= pClassView
->AddRoot( wxT("wxWidgets 2.0 classes"), 0 );
672 pClassView
->AppendItem( rootId
, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
673 pClassView
->AppendItem( rootId
, _("serializer-classes (grabbed at run-time)"), 0 );
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 );
681 wxPanel
* pSheet3
= new wxPanel();
682 pSheet3
->Create( pTabbedArea
, wxID_ANY
);
683 pSheet3
->Show(false);
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"));
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") );
697 void MyFrame::DropInSomeBars( int layoutNo
)
699 /* create once... and forget! */
701 // setup dimension infos for various bar shapes
706 if ( layoutNo
== SECOND_LAYOUT
)
709 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
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
719 cbDimInfo
sizes1( cbWidth
,cbHeight
,
721 cbWidth
,cbHeight
, false ); // false - bar is "flexible"
726 cbDimInfo
sizes3( cbWidth
,cbHeight
,
728 cbWidth
,cbHeight
, true ); // -/-
733 cbDimInfo
sizes4( cbWidth
,cbHeight
,
735 cbWidth
,cbHeight
, false ); // -/-
740 cbDimInfo
sizes5( cbWidth
,cbHeight
,
742 cbWidth
,cbHeight
, true,
743 3, // vertical gap (bar border)
744 3 // horizontal gap (bar border)
748 if ( layoutNo
== FIRST_LAYOUT
)
750 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
752 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
754 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
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 );
764 if ( layoutNo
== SECOND_LAYOUT
)
766 // show off various wx-controls in the second layout
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") );
780 if ( layoutNo
== THIRD_LAYOUT
)
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
);
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") );
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()
806 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
808 pToolBar
->Create( mpInternalFrm
, wxID_ANY
);
810 // 1001-1006 ids of command events fired by added tool-buttons
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") );
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") );
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
828 // create first "developement" layout
829 AddSearchToolbars( layout
, mpInternalFrm
);
831 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
833 // create another ***secreat developement*** layout inside
834 // the third sheet of the outter one's output bar
836 mpNestedLayout
= new wxFrameLayout( pSheet3
,
837 CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3
), false );
839 CreateDevLayout( *mpNestedLayout
, pSheet3
);
841 mpNestedLayout
->Activate();
847 void MyFrame::CreateLayout( int layoutNo
)
849 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, false );
851 if ( layoutNo
== THIRD_LAYOUT
)
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
) );
858 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
861 mLayouts
[layoutNo
] = pLayout
;
863 DropInSomeBars( layoutNo
);
866 void MyFrame::RemoveLayout( int layoutNo
)
868 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
873 pLayout
->HideBarWindows();
875 // destroy nested layout first
877 if ( layoutNo
== THIRD_LAYOUT
)
879 if ( mpNestedLayout
)
880 delete mpNestedLayout
;
881 mpNestedLayout
= NULL
;
884 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
886 pLayout
->DestroyBarWindows();
890 mLayouts
[layoutNo
] = NULL
;
895 void MyFrame::SyncMenuBarItems()
897 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
899 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
902 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
905 void MyFrame::ActivateLayout( int layoutNo
)
907 if ( layoutNo
== mActiveLayoutNo
)
910 if ( mLayouts
[mActiveLayoutNo
] )
911 mLayouts
[mActiveLayoutNo
]->Deactivate();
913 mActiveLayoutNo
= layoutNo
;
915 if ( mLayouts
[mActiveLayoutNo
] )
916 mLayouts
[mActiveLayoutNo
]->Activate();
923 /***** Implementation for class StartButton95 (just for fun) *****/
925 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
927 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
928 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
929 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
930 EVT_PAINT ( StartButton95::OnPaint
)
933 void StartButton95::OnMouseDown( wxMouseEvent
& WXUNUSED(event
) )
940 void StartButton95::OnMouseUp( wxMouseEvent
& WXUNUSED(event
) )
942 // "this is not a bug"
944 SetCursor( wxCURSOR_WAIT
);
945 GetParent()->SetCursor( wxCURSOR_WAIT
);
946 ::wxSetCursor( wxCURSOR_WAIT
);
949 for( int i
= 1; i
!= 6; ++i
)
951 m_bPressed
= (i
% 2) != 0;
955 GetParent()->Close();
956 //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???
959 void StartButton95::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
965 if ( !m_PBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp") ) )
967 m_PBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP
);
973 if ( !m_DBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp") ) )
975 m_DBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP
);
983 mdc
.SelectObject( *pBmp
);
985 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
987 mdc
.SelectObject( wxNullBitmap
);