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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
24 #include "wx/treectrl.h"
25 #include "wx/imaglist.h"
26 #include "wx/notebook.h"
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"
36 // some extra fl plugins.
37 #include "wx/fl/barhintspl.h"
38 #include "wx/fl/hintanimpl.h"
40 #include "wx/fl/dyntbar.h"
41 #include "wx/fl/dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
45 /***** Implementation for class MyApp *****/
47 // Create a new application object
50 // `Main program' equivalent, creating windows and returning main app frame
51 bool MyApp::OnInit(void)
53 // Create the main frame window
54 MyFrame
*frame
= new MyFrame(NULL
, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540);
58 frame
->SetIcon(wxIcon(wxT("mondrian")));
61 frame
->SetIcon(wxIcon(wxT("aiai.xbm")));
65 wxMenu
*file_menu
= new wxMenu
;
66 wxMenu
*active_menu
= new wxMenu
;
68 file_menu
->Append( ID_LOAD
, _("&Load layouts") );
69 file_menu
->Append( ID_STORE
, _("&Store layouts") );
70 file_menu
->AppendSeparator();
72 file_menu
->Append( ID_AUTOSAVE
, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK
);
73 file_menu
->AppendSeparator();
75 file_menu
->Append(MINIMAL_ABOUT
, _("A&bout !"));
76 file_menu
->Append(MINIMAL_QUIT
, _("E&xit\tTab"));
78 //active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") );
79 //active_menu->AppendSeparator();
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();
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
);
90 wxMenuBar
*menu_bar
= new wxMenuBar
;
92 menu_bar
->Append(file_menu
, _("&File"));
93 menu_bar
->Append(active_menu
, _("Active &Layout"));
96 frame
->CreateStatusBar(3);
97 #endif // wxUSE_STATUSBAR
99 frame
->SetMenuBar(menu_bar
);
101 frame
->SyncMenuBarItems();
113 // frame-layouts is not a windows (objects), thus should
114 // be cleaned up manually
116 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
122 if ( mpNestedLayout
)
123 delete mpNestedLayout
;
124 if ( mpAboutBoxLayout
)
125 delete mpAboutBoxLayout
;
128 /***** Implementation for class MyFrame *****/
130 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
131 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
132 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
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
)
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
)
150 EVT_CHAR_HOOK( MyFrame::OnChar
)
153 // My frame constructor
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
),
160 mActiveLayoutNo( FIRST_LAYOUT
),
162 mSavedAlready( false ),
163 mpClntWindow( NULL
),
165 mImageList( 16,16, false, 2 )
169 mpInternalFrm
= (wxPanel
*)this;
171 mAboutBox
.Create( this, wxID_ANY
, _T("About box in wxWidgets style..."),
174 wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
176 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
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)
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
);
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
);
191 mImageList
.Add( bmp1
);
192 mImageList
.Add( bmp2
);
196 // create multiple layouts
200 mpClntWindow
= CreateTxtCtrl(wxT("client window"));
202 // Create all layouts
203 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
208 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
210 mLayouts
[i
]->HideBarWindows();
213 // activate first one
214 mLayouts
[FIRST_LAYOUT
]->Activate();
215 mActiveLayoutNo
= FIRST_LAYOUT
;
218 /*** event handlers ***/
220 bool MyFrame::OnClose(void)
222 // USEFUL TRICK:: avoids flickering of application's frame
223 // when closing NN windows on exit:
227 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
242 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
244 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
247 void MyFrame::OnStore( wxCommandEvent
& WXUNUSED(event
) )
249 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
252 void MyFrame::OnAutoSave( wxCommandEvent
& WXUNUSED(event
) )
254 mAutoSave
= !mAutoSave
;
262 void MyFrame::OnRemove( wxCommandEvent
& WXUNUSED(event
) )
264 RemoveLayout( mActiveLayoutNo
);
269 void MyFrame::OnRemoveAll( wxCommandEvent
& WXUNUSED(event
) )
271 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
280 void MyFrame::OnRecreate( wxCommandEvent
& event
)
282 OnRemove( event
); // first destroy active layout
284 CreateLayout( mActiveLayoutNo
);
286 mLayouts
[mActiveLayoutNo
]->Activate();
289 void MyFrame::OnFirst( wxCommandEvent
& WXUNUSED(event
) )
291 ActivateLayout( FIRST_LAYOUT
);
294 void MyFrame::OnSecond( wxCommandEvent
& WXUNUSED(event
) )
296 ActivateLayout( SECOND_LAYOUT
);
299 void MyFrame::OnThird( wxCommandEvent
& WXUNUSED(event
) )
301 ActivateLayout( THIRD_LAYOUT
);
304 void MyFrame::OnQuit( wxCommandEvent
& WXUNUSED(event
) )
306 // USEFUL TRICK:: avoids flickering of application's frame
307 // when closing NN windows on exit:
311 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
323 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
327 font
.SetFaceName(wxT("MS Sans Serif"));
329 font
.SetFamily( wxSWISS
);
332 font
.SetStyle( wxSLANT
);
333 font
.SetWeight( wxNORMAL
);
334 font
.SetPointSize( 8 );
337 font
.RealizeResource();
340 mAboutBox
.Center( wxBOTH
);
341 mAboutBox
.Show(true);
345 void MyFrame::OnChar( wxKeyEvent
& event
)
349 if ( event
.m_keyCode
== WXK_F1
)
355 if ( event
.m_keyCode
== WXK_F2
)
361 if ( event
.m_keyCode
== WXK_F3
)
365 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
368 wxMessageBox(_("There are only 3 layouts in this demo :-("));
372 if ( event
.m_keyCode
== WXK_TAB
)
374 // USEFUL TRICK:: avoids flickering of application's frame
375 // when closing NN windows on exit:
379 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
399 void MyFrame::OnSayItsOk( wxCommandEvent
& WXUNUSED(event
) )
401 wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
404 void MyFrame::OnBtnYes( wxCommandEvent
& WXUNUSED(event
) )
406 mAboutBox
.Show(false);
409 void MyFrame::OnBtnNo( wxCommandEvent
& WXUNUSED(event
) )
411 mAboutBox
.Show(false);
414 void MyFrame::OnBtnEsc( wxCommandEvent
& WXUNUSED(event
) )
416 mAboutBox
.Show(false);
419 /*** helper methods ***/
421 void MyFrame::InitAboutBox()
423 wxPanel
* pArea
= new wxPanel();
425 pArea
->Create( &mAboutBox
, wxID_ANY
);
427 new wxStaticText(pArea
, wxID_ANY
, _("This is wxFrameLayout contribution demo."),
430 new wxStaticText(pArea
, wxID_ANY
, _("Aleksandras Gluchovas (c) 1998"),
433 new wxStaticText(pArea
, wxID_ANY
, _("<mailto:alex@soften.ktu.lt>"),
436 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, true );
438 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
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
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
);
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"));
455 layout
.mBorderPen
.SetColour( 192, 192, 192 );
456 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
458 cbCommonPaneProperties props
;
460 layout
.GetPaneProperties( props
, FL_ALIGN_TOP
);
462 props
.mShow3DPaneBorderOn
= false;
464 layout
.SetPaneProperties( props
, wxALL_PANES
);
472 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
474 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
475 wxID_ANY
, txt
, wxDefaultPosition
, wxDefaultSize
,
479 wxButton
* MyFrame::CreateButton( const wxString
& label
,
480 wxWindow
* pParent
, long id
)
482 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
483 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
486 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
488 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, wxID_ANY
);
490 const wxTreeItemId rootid
= pTree
->AddRoot(label
);
492 if ( label
.StartsWith(_T("X")) )
494 pTree
->AppendItem(rootid
, _("Scully"));
495 pTree
->AppendItem(rootid
, _("Mulder"));
499 pTree
->AppendItem(rootid
, _("Leaf1"));
500 pTree
->AppendItem(rootid
, _("Leaf2"));
506 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
508 wxString choice_strings
[5];
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");
516 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
517 wxDefaultSize
, 5, choice_strings
);
519 choice
->SetSelection(0);
526 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* WXUNUSED(pParent
) )
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()
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()
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()
555 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
557 wxChoice
* pChoice
= new wxChoice( pTBar2
, wxID_ANY
, wxDefaultPosition
, wxSize( 140,25 ) );
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") );
566 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
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 ")) );
577 pTBar3
->EnableTool( 2, false );
580 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, wxID_ANY
);
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 );
589 pTBar4
->EnableTool( 4, false );
592 layout
.AddBar( pTBar2
,
593 sizes2
, FL_ALIGN_TOP
,
600 layout
.AddBar( pTBar3
,
601 sizes3
, FL_ALIGN_BOTTOM
,
608 layout
.AddBar( pTBar4
,
609 sizes4
, FL_ALIGN_BOTTOM
,
617 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
619 bool isNested
= (pParent
!= mpInternalFrm
);
621 // check if we're creating nested layout
624 layout
.mBorderPen
.SetColour( 128,255,128 );
626 // if so, than make border smaller
627 for( int i
= 0; i
!= MAX_PANES
; ++i
)
629 cbDockPane
& pane
= *layout
.GetPane( i
);
632 pane
.mBottomMargin
= 5;
633 pane
.mLeftMargin
= 5;
634 pane
.mRightMargin
= 5;
639 int cbHeight
= ( isNested
) ? 50 : 150;
641 cbDimInfo
sizes4( cbWidth
,cbHeight
,
643 cbWidth
,cbHeight
, false );
648 cbDimInfo
sizes5( cbWidth
,cbHeight
,
650 cbWidth
,cbHeight
, true,
651 3, // vertical gap (bar border)
652 3 // horizontal gap (bar border)
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 );
661 wxTreeCtrl
* pClassView
= new wxTreeCtrl( pParent
, wxID_ANY
,
662 wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
664 pClassView
->SetImageList( &mImageList
);
666 wxTreeItemId rootId
= pClassView
->AddRoot( wxT("wxWidgets 2.0 classes"), 0 );
668 pClassView
->AppendItem( rootId
, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
669 pClassView
->AppendItem( rootId
, _("serializer-classes (grabbed at run-time)"), 0 );
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 );
677 wxPanel
* pSheet3
= new wxPanel();
678 pSheet3
->Create( pTabbedArea
, wxID_ANY
);
679 pSheet3
->Show(false);
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"));
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") );
693 void MyFrame::DropInSomeBars( int layoutNo
)
695 /* create once... and forget! */
697 // setup dimension infos for various bar shapes
702 if ( layoutNo
== SECOND_LAYOUT
)
705 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
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
715 cbDimInfo
sizes1( cbWidth
,cbHeight
,
717 cbWidth
,cbHeight
, false ); // false - bar is "flexible"
722 cbDimInfo
sizes3( cbWidth
,cbHeight
,
724 cbWidth
,cbHeight
, true ); // -/-
729 cbDimInfo
sizes4( cbWidth
,cbHeight
,
731 cbWidth
,cbHeight
, false ); // -/-
736 cbDimInfo
sizes5( cbWidth
,cbHeight
,
738 cbWidth
,cbHeight
, true,
739 3, // vertical gap (bar border)
740 3 // horizontal gap (bar border)
744 if ( layoutNo
== FIRST_LAYOUT
)
746 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
748 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
750 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
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 );
760 if ( layoutNo
== SECOND_LAYOUT
)
762 // show off various wx-controls in the second layout
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") );
776 if ( layoutNo
== THIRD_LAYOUT
)
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
);
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") );
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()
802 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
804 pToolBar
->Create( mpInternalFrm
, wxID_ANY
);
806 // 1001-1006 ids of command events fired by added tool-buttons
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") );
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") );
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
824 // create first "developement" layout
825 AddSearchToolbars( layout
, mpInternalFrm
);
827 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
829 // create another ***secreat developement*** layout inside
830 // the third sheet of the outter one's output bar
832 mpNestedLayout
= new wxFrameLayout( pSheet3
,
833 CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3
), false );
835 CreateDevLayout( *mpNestedLayout
, pSheet3
);
837 mpNestedLayout
->Activate();
843 void MyFrame::CreateLayout( int layoutNo
)
845 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, false );
847 if ( layoutNo
== THIRD_LAYOUT
)
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
) );
854 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
857 mLayouts
[layoutNo
] = pLayout
;
859 DropInSomeBars( layoutNo
);
862 void MyFrame::RemoveLayout( int layoutNo
)
864 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
869 pLayout
->HideBarWindows();
871 // destroy nested layout first
873 if ( layoutNo
== THIRD_LAYOUT
)
875 if ( mpNestedLayout
)
876 delete mpNestedLayout
;
877 mpNestedLayout
= NULL
;
880 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
882 pLayout
->DestroyBarWindows();
886 mLayouts
[layoutNo
] = NULL
;
891 void MyFrame::SyncMenuBarItems()
893 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
895 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
898 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
901 void MyFrame::ActivateLayout( int layoutNo
)
903 if ( layoutNo
== mActiveLayoutNo
)
906 if ( mLayouts
[mActiveLayoutNo
] )
907 mLayouts
[mActiveLayoutNo
]->Deactivate();
909 mActiveLayoutNo
= layoutNo
;
911 if ( mLayouts
[mActiveLayoutNo
] )
912 mLayouts
[mActiveLayoutNo
]->Activate();
919 /***** Implementation for class StartButton95 (just for fun) *****/
921 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
923 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
924 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
925 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
926 EVT_PAINT ( StartButton95::OnPaint
)
929 void StartButton95::OnMouseDown( wxMouseEvent
& WXUNUSED(event
) )
936 void StartButton95::OnMouseUp( wxMouseEvent
& WXUNUSED(event
) )
938 // "this is not a bug"
940 SetCursor( wxCURSOR_WAIT
);
941 GetParent()->SetCursor( wxCURSOR_WAIT
);
942 ::wxSetCursor( wxCURSOR_WAIT
);
945 for( int i
= 1; i
!= 6; ++i
)
947 m_bPressed
= (i
% 2) != 0;
951 GetParent()->Close();
952 //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???
955 void StartButton95::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
961 if ( !m_PBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp") ) )
963 m_PBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP
);
969 if ( !m_DBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp") ) )
971 m_DBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP
);
979 mdc
.SelectObject( *pBmp
);
981 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
983 mdc
.SelectObject( wxNullBitmap
);