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
, _("wxWindows 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"), TRUE
);
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"), 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
);
94 wxMenuBar
*menu_bar
= new wxMenuBar
;
96 menu_bar
->Append(file_menu
, _("&File"));
97 menu_bar
->Append(active_menu
, _("Active &Layout"));
99 frame
->CreateStatusBar(3);
101 frame
->SetMenuBar(menu_bar
);
103 frame
->SyncMenuBarItems();
115 // frame-layouts is not a windows (objects), thus should
116 // be cleaned up manually
118 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
124 if ( mpNestedLayout
)
125 delete mpNestedLayout
;
126 if ( mpAboutBoxLayout
)
127 delete mpAboutBoxLayout
;
130 /***** Implementation for class MyFrame *****/
132 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
133 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
134 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
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
)
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
)
152 EVT_CHAR_HOOK( MyFrame::OnChar
)
155 // My frame constructor
157 MyFrame::MyFrame(wxFrame
*frame
, const wxChar
*title
, int x
, int y
, int w
, int h
)
158 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
159 mpNestedLayout( NULL
),
160 mpAboutBoxLayout( NULL
),
162 mActiveLayoutNo( FIRST_LAYOUT
),
164 mSavedAlready( FALSE
),
165 mpClntWindow( NULL
),
167 mImageList( 16,16, FALSE
, 2 )
169 mpInternalFrm
= (wxPanel
*)this;
171 mAboutBox
.Create( this, -1, _T("About box in wxWindows style..."),
174 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
177 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
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)
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
);
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
);
192 mImageList
.Add( bmp1
);
193 mImageList
.Add( bmp2
);
197 // create multiple layouts
201 mpClntWindow
= CreateTxtCtrl(wxT("client window"));
203 // Create all layouts
204 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
209 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
211 mLayouts
[i
]->HideBarWindows();
214 // activate first one
215 mLayouts
[FIRST_LAYOUT
]->Activate();
216 mActiveLayoutNo
= FIRST_LAYOUT
;
219 /*** event handlers ***/
221 bool MyFrame::OnClose(void)
223 // USEFUL TRICK:: avoids flickering of application's frame
224 // when closing NN windows on exit:
228 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
243 void MyFrame::OnLoad( wxCommandEvent
& event
)
245 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
248 void MyFrame::OnStore( wxCommandEvent
& event
)
250 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
253 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
255 mAutoSave
= !mAutoSave
;
263 void MyFrame::OnRemove( wxCommandEvent
& event
)
265 RemoveLayout( mActiveLayoutNo
);
270 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
272 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
281 void MyFrame::OnRecreate( wxCommandEvent
& event
)
283 OnRemove( event
); // first destroy active layout
285 CreateLayout( mActiveLayoutNo
);
287 mLayouts
[mActiveLayoutNo
]->Activate();
290 void MyFrame::OnFirst( wxCommandEvent
& event
)
292 ActivateLayout( FIRST_LAYOUT
);
295 void MyFrame::OnSecond( wxCommandEvent
& event
)
297 ActivateLayout( SECOND_LAYOUT
);
300 void MyFrame::OnThird( wxCommandEvent
& event
)
302 ActivateLayout( THIRD_LAYOUT
);
305 void MyFrame::OnQuit( wxCommandEvent
& event
)
307 // USEFUL TRICK:: avoids flickering of application's frame
308 // when closing NN windows on exit:
312 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
324 void MyFrame::OnAbout( wxCommandEvent
& event
)
328 font
.SetFaceName(wxT("MS Sans Serif"));
330 font
.SetFamily( wxSWISS
);
333 font
.SetStyle( wxSLANT
);
334 font
.SetWeight( wxNORMAL
);
335 font
.SetPointSize( 8 );
338 font
.RealizeResource();
341 mAboutBox
.Center( wxBOTH
);
342 mAboutBox
.Show(TRUE
);
346 void MyFrame::OnChar( wxKeyEvent
& event
)
350 if ( event
.m_keyCode
== WXK_F1
)
352 this->OnFirst( evt
);
356 if ( event
.m_keyCode
== WXK_F2
)
358 this->OnSecond( evt
);
362 if ( event
.m_keyCode
== WXK_F3
)
364 this->OnThird( evt
);
366 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
369 wxMessageBox(_("There are only 3 layouts in this demo :-("));
373 if ( event
.m_keyCode
== WXK_TAB
)
375 // USEFUL TRICK:: avoids flickering of application's frame
376 // when closing NN windows on exit:
380 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
)
400 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
402 wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
405 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
407 mAboutBox
.Show(FALSE
);
410 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
412 mAboutBox
.Show(FALSE
);
415 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
417 mAboutBox
.Show(FALSE
);
420 /*** helper methods ***/
422 void MyFrame::InitAboutBox()
424 wxPanel
* pArea
= new wxPanel();
426 pArea
->Create( &mAboutBox
, -1 );
428 new wxStaticText(pArea
, -1, _("This is wxFrameLayout contribution demo."),
431 new wxStaticText(pArea
, -1, _("Aleksandras Gluchovas (c) 1998"),
434 new wxStaticText(pArea
, -1, _("<mailto:alex@soften.ktu.lt>"),
437 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
439 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
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
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
);
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"));
456 layout
.mBorderPen
.SetColour( 192, 192, 192 );
457 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
459 cbCommonPaneProperties props
;
461 layout
.GetPaneProperties( props
, FL_ALIGN_TOP
);
463 props
.mShow3DPaneBorderOn
= FALSE
;
465 layout
.SetPaneProperties( props
, wxALL_PANES
);
473 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
475 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
476 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
480 wxButton
* MyFrame::CreateButton( const wxString
& label
,
481 wxWindow
* pParent
, long id
)
483 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
484 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
487 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
489 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
491 int rootid
= pTree
->AppendItem( (long)0, label
, 0);
493 if ( label
[0] != 'X' )
495 pTree
->AppendItem(rootid
, _("Leaf1"), 0);
496 pTree
->AppendItem(rootid
, _("Leaf2"), 0);
500 pTree
->AppendItem(rootid
, _("Scully"), 0);
501 pTree
->AppendItem(rootid
, _("Mulder"), 0);
507 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
509 wxString choice_strings
[5];
511 choice_strings
[0] = txt
;
512 choice_strings
[1] = _("Julian");
513 choice_strings
[2] = _("Hattie");
514 choice_strings
[3] = _("Ken");
515 choice_strings
[4] = _("Dick");
517 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
518 wxDefaultSize
, 5, choice_strings
);
520 choice
->SetSelection(0);
527 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
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()
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()
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()
556 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
558 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
560 pTBar2
->AddTool( 1, pChoice
);
561 pTBar2
->AddTool( 2, wxString(wxT(BMP_DIR
)) + wxT("search.bmp") );
562 //pTBar2->AddSeparator();
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") );
567 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
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 ")) );
572 //pTBar3->AddSeparator();
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 ")) );
578 pTBar3
->EnableTool( 2, FALSE
);
581 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
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
);
586 //pTBar4->AddSeparator();
587 pTBar4
->AddTool( 4, wxString(wxT(BMP_DIR
)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP
, wxString(_("Search ")), TRUE
);
590 pTBar4
->EnableTool( 4, FALSE
);
593 layout
.AddBar( pTBar2
,
594 sizes2
, FL_ALIGN_TOP
,
601 layout
.AddBar( pTBar3
,
602 sizes3
, FL_ALIGN_BOTTOM
,
609 layout
.AddBar( pTBar4
,
610 sizes4
, FL_ALIGN_BOTTOM
,
618 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
620 bool isNested
= (pParent
!= mpInternalFrm
);
622 // check if we're craeting nested layout
625 layout
.mBorderPen
.SetColour( 128,255,128 );
627 // if so, than make border smaller
628 for( int i
= 0; i
!= MAX_PANES
; ++i
)
630 cbDockPane
& pane
= *layout
.GetPane( i
);
633 pane
.mBottomMargin
= 5;
634 pane
.mLeftMargin
= 5;
635 pane
.mRightMargin
= 5;
640 int cbHeight
= ( isNested
) ? 50 : 150;
642 cbDimInfo
sizes4( cbWidth
,cbHeight
,
644 cbWidth
,cbHeight
, FALSE
);
649 cbDimInfo
sizes5( cbWidth
,cbHeight
,
651 cbWidth
,cbHeight
, TRUE
,
652 3, // vertical gap (bar border)
653 3 // horizontal gap (bar border)
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 );
662 wxTreeCtrl
* pClassView
= new wxTreeCtrl( pParent
, -1,
663 wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
665 pClassView
->SetImageList( &mImageList
);
667 wxTreeItemId rootId
= pClassView
->AddRoot( wxT("wxWindows 2.0 classes"), 0 );
669 pClassView
->AppendItem( rootId
, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
670 pClassView
->AppendItem( rootId
, _("serializer-classes (grabbed at run-time)"), 0 );
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 );
678 wxPanel
* pSheet3
= new wxPanel();
679 pSheet3
->Create( pTabbedArea
, -1 );
680 pSheet3
->Show(FALSE
);
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"));
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") );
694 void MyFrame::DropInSomeBars( int layoutNo
)
696 /* create once... and forget! */
698 // setup dimension infos for various bar shapes
703 if ( layoutNo
== SECOND_LAYOUT
)
706 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
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
716 cbDimInfo
sizes1( cbWidth
,cbHeight
,
718 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
723 cbDimInfo
sizes3( cbWidth
,cbHeight
,
725 cbWidth
,cbHeight
, TRUE
); // -/-
730 cbDimInfo
sizes4( cbWidth
,cbHeight
,
732 cbWidth
,cbHeight
, FALSE
); // -/-
737 cbDimInfo
sizes5( cbWidth
,cbHeight
,
739 cbWidth
,cbHeight
, TRUE
,
740 3, // vertical gap (bar border)
741 3 // horizontal gap (bar border)
745 if ( layoutNo
== FIRST_LAYOUT
)
747 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
749 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
751 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
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
);
761 if ( layoutNo
== SECOND_LAYOUT
)
763 // show off various wx-controls in the second layout
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") );
777 if ( layoutNo
== THIRD_LAYOUT
)
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
);
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") );
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()
803 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
805 pToolBar
->Create( mpInternalFrm
, -1 );
807 // 1001-1006 ids of command events fired by added tool-buttons
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") );
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") );
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)
821 wxT("Real-Toolbar"), // name to refere in customization pop-ups
825 // create first "developement" layout
826 AddSearchToolbars( layout
, mpInternalFrm
);
828 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
830 // create another ***secreat developement*** layout inside
831 // the third sheet of the outter one's output bar
833 mpNestedLayout
= new wxFrameLayout( pSheet3
,
834 CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3
), FALSE
);
836 CreateDevLayout( *mpNestedLayout
, pSheet3
);
838 mpNestedLayout
->Activate();
844 void MyFrame::CreateLayout( int layoutNo
)
846 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
848 if ( layoutNo
== THIRD_LAYOUT
)
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
) );
855 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
858 mLayouts
[layoutNo
] = pLayout
;
860 DropInSomeBars( layoutNo
);
863 void MyFrame::RemoveLayout( int layoutNo
)
865 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
870 pLayout
->HideBarWindows();
872 // destroy nested layout first
874 if ( layoutNo
== THIRD_LAYOUT
)
876 if ( mpNestedLayout
)
877 delete mpNestedLayout
;
878 mpNestedLayout
= NULL
;
881 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
883 pLayout
->DestroyBarWindows();
887 mLayouts
[layoutNo
] = NULL
;
892 void MyFrame::SyncMenuBarItems()
894 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
896 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
899 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
902 void MyFrame::ActivateLayout( int layoutNo
)
904 if ( layoutNo
== mActiveLayoutNo
)
907 if ( mLayouts
[mActiveLayoutNo
] )
908 mLayouts
[mActiveLayoutNo
]->Deactivate();
910 mActiveLayoutNo
= layoutNo
;
912 if ( mLayouts
[mActiveLayoutNo
] )
913 mLayouts
[mActiveLayoutNo
]->Activate();
920 /***** Implementation for class StartButton95 (just for fun) *****/
922 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
924 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
925 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
926 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
927 EVT_PAINT ( StartButton95::OnPaint
)
930 void StartButton95::OnMouseDown( wxMouseEvent
& event
)
937 void StartButton95::OnMouseUp( wxMouseEvent
& event
)
939 // "this is not a bug"
941 SetCursor( wxCURSOR_WAIT
);
942 GetParent()->SetCursor( wxCURSOR_WAIT
);
943 ::wxSetCursor( wxCURSOR_WAIT
);
947 for( i
= 1; i
!= 6; ++i
)
949 m_bPressed
= (i
% 2) != 0;
953 GetParent()->Close();
954 //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???
957 void StartButton95::OnPaint( wxPaintEvent
& event
)
963 if ( !m_PBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp") ) )
965 m_PBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP
);
971 if ( !m_DBmp
.Ok() && wxFileExists( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp") ) )
973 m_DBmp
.LoadFile( wxString(wxT(BMP_DIR
)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP
);
981 mdc
.SelectObject( *pBmp
);
983 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
985 mdc
.SelectObject( wxNullBitmap
);