1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "minimal.cpp"
14 #pragma interface "minimal.cpp"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 #include "wx/treectrl.h"
29 #include "wx/imaglist.h"
31 #include "settingsdlg.h"
34 #include "controlbar.h"
35 #include "rowlayoutpl.h"
36 #include "antiflickpl.h"
37 #include "bardragpl.h"
39 #include "rowdragpl.h"
43 #include "barhintspl.h"
44 #include "hintanimpl.h"
45 #include "controlarea.h"
49 #include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
53 // ADDED by alex (linker complaints...):
54 #ifndef wxDUMMY_OBJ_INCLUDED
58 /***** Implementation for class MyApp *****/
60 // Create a new application object
63 // `Main program' equivalent, creating windows and returning main app frame
64 bool MyApp::OnInit(void)
66 // Create the main frame window
67 MyFrame
*frame
= new MyFrame(NULL
, "wxWindows 2.0 wxFrameLayout demo", 50, 50, 650, 540);
71 frame
->SetIcon(wxIcon("mondrian"));
74 frame
->SetIcon(wxIcon("aiai.xbm"));
78 wxMenu
*file_menu
= new wxMenu
;
79 wxMenu
*active_menu
= new wxMenu
;
81 file_menu
->Append( ID_LOAD
, "&Load layouts" );
82 file_menu
->Append( ID_STORE
, "&Store layouts" );
83 file_menu
->AppendSeparator();
85 file_menu
->Append( ID_AUTOSAVE
, "&Auto Save Layouts", "save layouts on exit", TRUE
);
86 file_menu
->AppendSeparator();
88 file_menu
->Append(MINIMAL_ABOUT
, "A&bout !");
89 file_menu
->Append(MINIMAL_QUIT
, "E&xit\tTab");
91 active_menu
->Append( ID_SETTINGS
, "&Settings...\tCtrl" );
92 active_menu
->AppendSeparator();
94 active_menu
->Append( ID_REMOVE
, "&Remove Active" );
95 active_menu
->Append( ID_REMOVEALL
, "Remove &All" );
96 active_menu
->Append( ID_RECREATE
, "Re&create" );
97 active_menu
->AppendSeparator();
99 active_menu
->Append( ID_FIRST
, "Activate f&irst layout \tF1", "activate it", TRUE
);
100 active_menu
->Append( ID_SECOND
, "Activate &second layout\tF2","activate it", TRUE
);
101 active_menu
->Append( ID_THIRD
, "Activate &third layout\tF3","activate it", TRUE
);
103 wxMenuBar
*menu_bar
= new wxMenuBar
;
105 menu_bar
->Append(file_menu
, "&File");
106 menu_bar
->Append(active_menu
, "Active &Layout");
108 frame
->CreateStatusBar(3);
110 frame
->SetMenuBar(menu_bar
);
112 frame
->SyncMenuBarItems();
124 // frame-layouts is not a windows (objects), thus should
125 // be cleaned up manually
127 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
129 if ( mLayouts
[i
] ) delete mLayouts
[i
];
131 if ( mpNestedLayout
) delete mpNestedLayout
;
132 if ( mpAboutBoxLayout
) delete mpAboutBoxLayout
;
135 /***** Implementation for class StartButton95 (just for fun) *****/
137 class StartButton95
: public wxPanel
139 DECLARE_DYNAMIC_CLASS( StartButton95
)
146 StartButton95(void) : mPressed(FALSE
) {}
148 StartButton95(wxWindow
* parent
)
149 : mPressed(FALSE
) { wxPanel::Create(parent
,-1); }
151 void OnMouseDown( wxMouseEvent
& event
);
152 void OnMouseUp( wxMouseEvent
& event
);
153 void OnPaint( wxPaintEvent
& event
);
155 DECLARE_EVENT_TABLE();
158 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
160 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
162 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
163 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
164 EVT_PAINT ( StartButton95::OnPaint
)
168 void StartButton95::OnMouseDown( wxMouseEvent
& event
)
175 void StartButton95::OnMouseUp( wxMouseEvent
& event
)
177 // "this is not a bug"
179 SetCursor( wxCURSOR_WAIT
);
180 GetParent()->SetCursor( wxCURSOR_WAIT
);
181 ::wxSetCursor( wxCURSOR_WAIT
); wxSleep(1);
183 for( i
= 1; i
!= 6; ++i
) {
184 mPressed
= i
% 2;Refresh();wxSleep(1);
186 GetParent()->Close();*((char*)(i
)-3) = 'X';
189 void StartButton95::OnPaint( wxPaintEvent
& event
)
198 mPBmp
.LoadFile( "start95_pr_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
200 if ( !mPBmp
.Ok() && wxFileExists( "start95_pr.bmp" ) )
202 mPBmp
.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP
);
212 mDBmp
.LoadFile( "start95_dp_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
215 if ( !mDBmp
.Ok() && wxFileExists( "start95_dp.bmp" ) )
217 mDBmp
.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP
);
225 mdc
.SelectObject( *pBmp
);
227 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
229 mdc
.SelectObject( wxNullBitmap
);
232 /***** Implementation for class MyFrame *****/
234 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
236 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
237 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
239 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
240 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
241 EVT_MENU( ID_AUTOSAVE
, MyFrame::OnAutoSave
)
242 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
243 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
244 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
245 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
246 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
247 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
248 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
250 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
251 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
252 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
253 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
255 EVT_CHAR_HOOK( MyFrame::OnChar
)
259 // My frame constructor
261 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
263 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
264 mImageList( 16,16, FALSE
, 2 ),
265 mSavedAlready( FALSE
),
268 mpClntWindow( NULL
),
269 mpNestedLayout( NULL
),
270 mpAboutBoxLayout( NULL
),
271 mActiveLayoutNo( FIRST_LAYOUT
)
275 mpInternalFrm
= (wxPanel
*)this;
277 mpInternalFrm
= new wxPanel( this, -1 );
280 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
283 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
286 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
288 // image-list is one of the few objects which
289 // currently cannot be serialized, create it first
290 // and use it as initial reference (IR)
294 bmp1
.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
295 bmp2
.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE
);
297 if ( wxFileExists( "folder_icon.bmp" ) )
298 bmp1
.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP
);
300 if ( wxFileExists( "class_icon1.bmp" ) )
301 bmp2
.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP
);
303 int idx1
= mImageList
.Add( bmp1
);
304 int idx2
= mImageList
.Add( bmp2
);
306 // load configuation if present
308 if ( wxFileExists( "layouts_for_demo.dat" ) )
317 // create multiple layouts
321 mpClntWindow
= CreateTxtCtrl("client window");
323 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
327 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
330 mLayouts
[i
]->HideBarWindows();
332 // activate first one
334 mLayouts
[FIRST_LAYOUT
]->Activate();
336 mActiveLayoutNo
= FIRST_LAYOUT
;
340 /*** event handlers ***/
342 bool MyFrame::OnClose(void)
344 // USEFUL TRICK:: avoids flickering of application's frame
345 // when closing NN windows on exit:
350 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
363 void MyFrame::OnLoad( wxCommandEvent
& event
)
365 if ( !wxFileExists( "layouts_for_demo.dat" ) )
369 "File \"layouts_for_demo.dat\" was not found,\n select\
370 (File|Store Layouts) menu item to store layout information first"
377 wxIOStreamWrapper stm
;
378 stm
.CreateForInput( "layouts_for_demo.dat" );
380 wxObjectStorage
store( stm
);
382 SerializeMe( store
);
384 if ( mLayouts
[mActiveLayoutNo
] )
386 mLayouts
[mActiveLayoutNo
]->Activate();
389 void MyFrame::OnStore( wxCommandEvent
& event
)
391 wxIOStreamWrapper stm
;
392 stm
.CreateForOutput( "layouts_for_demo.dat" );
394 wxObjectStorage
store( stm
);
396 SerializeMe( store
);
398 mSavedAlready
= TRUE
;
401 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
403 mAutoSave
= !mAutoSave
;
411 void MyFrame::OnSettings( wxCommandEvent
& event
)
413 SettingsDlg
dlg( this );
415 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
417 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
422 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
425 dlg
.Center( wxBOTH
);
426 if ( dlg
.ShowModal() == wxID_APPLY
)
428 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
435 void MyFrame::OnRemove( wxCommandEvent
& event
)
437 RemoveLayout( mActiveLayoutNo
);
442 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
444 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
452 void MyFrame::OnRecreate( wxCommandEvent
& event
)
454 OnRemove( event
); // first destroy active layout
456 CreateLayout( mActiveLayoutNo
);
458 mLayouts
[mActiveLayoutNo
]->Activate();
461 void MyFrame::OnFirst( wxCommandEvent
& event
)
463 ActivateLayout( FIRST_LAYOUT
);
466 void MyFrame::OnSecond( wxCommandEvent
& event
)
468 ActivateLayout( SECOND_LAYOUT
);
471 void MyFrame::OnThird( wxCommandEvent
& event
)
473 ActivateLayout( THIRD_LAYOUT
);
476 void MyFrame::OnQuit( wxCommandEvent
& event
)
478 // USEFUL TRICK:: avoids flickering of application's frame
479 // when closing NN windows on exit:
483 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
493 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
495 // make controls in frame window look like in dialog
496 // by setting dialog's font to all controls
498 #ifdef __HACK_MY_MSDEV40__
500 wxNode
* pWNode
= pParent
->GetChildren()->First();
504 wxNode
* pWNode
= pParent
->GetChildren().First();
510 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
514 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
517 ((wxButton
*)(pWnd
))->SetDefault();
521 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
523 set_dlg_font( pWnd
, font
);
525 pWNode
= pWNode
->Next();
529 void MyFrame::OnAbout( wxCommandEvent
& event
)
533 font
.SetFaceName("MS Sans Serif");
535 font
.SetFamily( wxSWISS
);
540 font
.SetPointSize( 8 );
543 font
.RealizeResource();
546 mAboutBox
.Center( wxBOTH
);
547 mAboutBox
.Show(TRUE
);
549 set_dlg_font( &mAboutBox
, font
);
552 void MyFrame::OnChar( wxKeyEvent
& event
)
556 if ( event
.m_keyCode
== WXK_F1
)
558 this->OnFirst( evt
);
560 if ( event
.m_keyCode
== WXK_F2
)
562 this->OnSecond( evt
);
564 if ( event
.m_keyCode
== WXK_F3
)
566 this->OnThird( evt
);
567 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
570 wxMessageBox("There are only 3 layouts in this demo :-(");
572 if ( event
.m_keyCode
== WXK_TAB
)
574 // USEFUL TRICK:: avoids flickering of application's frame
575 // when closing NN windows on exit:
579 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
589 if ( event
.m_keyCode
== WXK_CONTROL
)
591 this->OnSettings( evt
);
596 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
598 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
601 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
603 mAboutBox
.Show(FALSE
);
606 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
608 mAboutBox
.Show(FALSE
);
611 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
613 mAboutBox
.Show(FALSE
);
616 /*** helper methods ***/
618 void MyFrame::InitAboutBox()
620 wxPanel
* pArea
= new wxPanel();
622 pArea
->Create( &mAboutBox
, -1 );
624 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
627 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
630 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
633 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
635 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
637 cbDimInfo
sizes( 90,40, // when docked horizontally
638 45,55, // when docked vertically
639 90,40, // when floated
640 TRUE
, 4, 4 // true - bar is fixed-size
644 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
645 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
646 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
648 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
649 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
650 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
652 layout
.mBorderPen
.SetColour( 192, 192, 192 );
653 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
655 cbCommonPaneProperties props
;
657 layout
.GetPaneProperties( props
, wxTOP
);
659 props
.mShow3DPaneBorderOn
= FALSE
;
661 layout
.SetPaneProperties( props
, wxALL_PANES
);
669 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
671 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
672 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
676 wxButton
* MyFrame::CreateButton( const wxString
& label
,
677 wxWindow
* pParent
, long id
)
679 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
680 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
683 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
685 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
687 int rootid
= pTree
->AppendItem( (long)0, label
, -1);
689 if ( label
[0] != 'X' )
691 pTree
->AppendItem(rootid
, "Leaf1", -1);
692 pTree
->AppendItem(rootid
, "Leaf2", -1);
696 pTree
->AppendItem(rootid
, "Scully", -1);
697 pTree
->AppendItem(rootid
, "Mulder", -1);
703 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
705 wxString choice_strings
[5];
707 choice_strings
[0] = txt
;
708 choice_strings
[1] = "Julian";
709 choice_strings
[2] = "Hattie";
710 choice_strings
[3] = "Ken";
711 choice_strings
[4] = "Dick";
713 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
714 wxDefaultSize
, 5, choice_strings
);
716 choice
->SetSelection(0);
721 static const char helloworld_src
[] =
723 "#include <iostream.h>\n\
727 cout << \"Hello World\";\n\
733 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
735 cbDimInfo
sizes2( 275,38, // when docked horizontally
736 45,275, // when docked vertically
737 80,30, // when floated
738 TRUE
, // the bar is fixed-size
739 4, // vertical gap (bar border)
740 4, // horizontal gap (bar border)
741 new cbDynToolBarDimHandler()
744 cbDimInfo
sizes3( 275,55, // when docked horizontally
745 275,60, // when docked vertically
746 45,130, // when floated
747 TRUE
, // the bar is fixed-size
748 4, // vertical gap (bar border)
749 4, // horizontal gap (bar border)
750 new cbDynToolBarDimHandler()
753 cbDimInfo
sizes4( 430,35, // when docked horizontally
754 44,375, // when docked vertically
755 80,100, // when floated
756 TRUE
, // the bar is fixed-size
757 4, // vertical gap (bar border)
758 4, // horizontal gap (bar border)
759 new cbDynToolBarDimHandler()
762 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
764 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
766 pTBar2
->AddTool( 1, pChoice
);
768 pTBar2
->AddTool( 2, wxBitmap("search_icon") );
769 //pTBar2->AddSeparator();
770 pTBar2
->AddTool( 3, wxBitmap("bookmarks_icon") );
771 pTBar2
->AddTool( 4, wxBitmap("nextmark_icon") );
772 pTBar2
->AddTool( 5, wxBitmap("prevmark_icon") );
776 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
778 pTBar3
->AddTool( 1, wxBitmap("open_icon"), " Open " );
779 pTBar3
->AddTool( 2, wxBitmap("save_icon"), " Save " );
780 pTBar3
->AddTool( 3, wxBitmap("saveall_icon"), " Save All " );
781 //pTBar3->AddSeparator();
782 pTBar3
->AddTool( 4, wxBitmap("cut_icon"), " Open " );
783 pTBar3
->AddTool( 5, wxBitmap("copy_icon"), " Copy " );
784 pTBar3
->AddTool( 6, wxBitmap("paste_icon")," Paste " );
786 pTBar3
->EnableTool( 2, FALSE
);
788 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
790 pTBar4
->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE
);
791 pTBar4
->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE
);
792 pTBar4
->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE
);
793 //pTBar4->AddSeparator();
794 pTBar4
->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE
);
796 pTBar4
->EnableTool( 4, FALSE
);
799 pTBar2
->AddTool( 2, "search.bmp" );
800 //pTBar2->AddSeparator();
801 pTBar2
->AddTool( 3, "bookmarks.bmp" );
802 pTBar2
->AddTool( 4, "nextmark.bmp" );
803 pTBar2
->AddTool( 5, "prevmark.bmp" );
806 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
808 pTBar3
->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP
, " Open " );
809 pTBar3
->AddTool( 2, "save.bmp", wxBITMAP_TYPE_BMP
, " Save " );
810 pTBar3
->AddTool( 3, "saveall.bmp", wxBITMAP_TYPE_BMP
, " Save All " );
811 //pTBar3->AddSeparator();
812 pTBar3
->AddTool( 4, "cut.bmp", wxBITMAP_TYPE_BMP
, " Open " );
813 pTBar3
->AddTool( 5, "copy.bmp", wxBITMAP_TYPE_BMP
, " Copy " );
814 pTBar3
->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP
, " Paste " );
816 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
818 pTBar4
->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP
, "Bookmarks ", TRUE
);
819 pTBar4
->AddTool( 2, "nextmark.bmp", wxBITMAP_TYPE_BMP
, "Next bookmark ", TRUE
);
820 pTBar4
->AddTool( 3, "prevmark.bmp", wxBITMAP_TYPE_BMP
, "Prev bookmark ", TRUE
);
821 //pTBar4->AddSeparator();
822 pTBar4
->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP
, "Search ", TRUE
);
825 layout
.AddBar( pTBar2
,
833 layout
.AddBar( pTBar3
,
841 layout
.AddBar( pTBar4
,
850 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
852 bool isNested
= pParent
!= mpInternalFrm
;
854 // check if we're craeting nested layout
857 layout
.mBorderPen
.SetColour( 128,255,128 );
859 // if so, than make border smaller
860 for( int i
= 0; i
!= MAX_PANES
; ++i
)
862 cbDockPane
& pane
= *layout
.GetPane( i
);
865 pane
.mBottomMargin
= 5;
866 pane
.mLeftMargin
= 5;
867 pane
.mRightMargin
= 5;
872 int cbHeight
= ( isNested
) ? 50 : 150;
874 cbDimInfo
sizes4( cbWidth
,cbHeight
,
876 cbWidth
,cbHeight
, FALSE
);
881 cbDimInfo
sizes5( cbWidth
,cbHeight
,
883 cbWidth
,cbHeight
, TRUE
,
884 3, // vertical gap (bar border)
885 3 // horizontal gap (bar border)
888 // create "workplace" window in the third layout
890 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
892 pMiniTabArea
->Create( pParent
, -1 );
894 wxTreeCtrl
* pClassView
=
895 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
896 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
898 pClassView
->SetImageList( &mImageList
);
900 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
902 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
903 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
905 // functions from "wxinfo.h"
906 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
907 ::wxCreateSerializerInfoTree( pClassView
, serId
, 1 );
910 // (default arg anyway)
911 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap("class_icon"));
912 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") );
913 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap("file_icon") );
914 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap("help_icon") );
915 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
916 pMiniTabArea
), "HelloWorld", &wxBitmap("help_icon") );
918 pMiniTabArea
->AddTab( pClassView
, "ClassView", "class_icon.bmp", wxBITMAP_TYPE_BMP
);
919 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView","res_icon.bmp" );
920 pMiniTabArea
->AddTab( new wxPanel(), "FileView", "file_icon.bmp" );
921 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", "help_icon.bmp" );
922 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
923 pMiniTabArea
), "HelloWorld", "help_icon.bmp" );
925 // now create "output" window
927 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
929 pTabbedArea
->Create( pParent
, -1 );
931 wxPanel
* pSheet3
= new wxPanel();
932 pSheet3
->Create( pTabbedArea
, -1 );
933 pSheet3
->Show(FALSE
);
935 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
936 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
937 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap("file_icon") );
938 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
940 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
941 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
942 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
947 void MyFrame::DropInSomeBars( int layoutNo
)
949 /* create once... and forget! */
951 // setup dimension infos for various bar shapes
956 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
958 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
960 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
961 cbWidth
,cbHeight
, // when docked vertically
962 cbWidth
,cbHeight
, // when floated
963 TRUE
// true - bar is fixed-size
968 cbDimInfo
sizes1( cbWidth
,cbHeight
,
970 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
976 cbDimInfo
sizes3( cbWidth
,cbHeight
,
978 cbWidth
,cbHeight
, TRUE
); // -/-
983 cbDimInfo
sizes4( cbWidth
,cbHeight
,
985 cbWidth
,cbHeight
, FALSE
); // -/-
990 cbDimInfo
sizes5( cbWidth
,cbHeight
,
992 cbWidth
,cbHeight
, TRUE
,
993 3, // vertical gap (bar border)
994 3 // horizontal gap (bar border)
998 if ( layoutNo
== FIRST_LAYOUT
)
1000 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
1002 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
1004 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
1006 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
1007 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
1008 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
1009 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
1010 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
1013 if ( layoutNo
== SECOND_LAYOUT
)
1015 // show off various wx-controls in the second layout
1017 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
1018 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
1019 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
1020 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
1021 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1022 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1023 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
1024 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
1025 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
1028 if ( layoutNo
== THIRD_LAYOUT
)
1032 cbCommonPaneProperties props
;
1033 layout
.GetPaneProperties( props
);
1034 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
1035 layout
.SetPaneProperties( props
, wxALL_PANES
);
1039 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
1040 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
1041 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
1042 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
1043 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
1044 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
1045 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
1047 cbDimInfo
sizes10(175,35, // when docked horizontally
1048 175,38, // when docked vertically
1049 170,35, // when floated
1050 TRUE
, // the bar is not fixed-size
1051 4, // vertical gap (bar border)
1052 4, // horizontal gap (bar border)
1053 new cbDynToolBarDimHandler()
1056 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
1058 pToolBar
->Create( mpInternalFrm
, -1 );
1060 // 1001-1006 ids of command events fired by added tool-buttons
1062 pToolBar
->AddTool( 1001, wxBitmap("new_icon") );
1063 pToolBar
->AddTool( 1002, wxBitmap("open_icon") );
1064 pToolBar
->AddTool( 1003, wxBitmap("save_icon") );
1066 pToolBar
->AddTool( 1004, wxBitmap("cut_icon") );
1067 pToolBar
->AddTool( 1005, wxBitmap("copy_icon") );
1068 pToolBar
->AddTool( 1006, wxBitmap("paste_icon") );
1070 pToolBar
->AddTool( 1001, "new.bmp" );
1071 pToolBar
->AddTool( 1002, "open.bmp" );
1072 pToolBar
->AddTool( 1003, "save.bmp" );
1074 pToolBar
->AddTool( 1004, "cut.bmp" );
1075 pToolBar
->AddTool( 1005, "copy.bmp" );
1076 pToolBar
->AddTool( 1006, "paste.bmp" );
1078 layout
.AddBar( pToolBar
, // bar window (can be NULL)
1079 sizes10
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
1080 0, // insert into 0th row (vert. position)
1081 0, // offset from the start of row (in pixels)
1082 "Real-Toolbar", // name to refere in customization pop-ups
1088 // create first "developement" layout
1090 AddSearchToolbars( layout
, mpInternalFrm
);
1092 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
1094 // create another ***secreat developement*** layout inside
1095 // the third sheet of the outter one's output bar
1099 new wxFrameLayout( pSheet3
,
1100 CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3
), FALSE
);
1102 CreateDevLayout( *mpNestedLayout
, pSheet3
);
1104 mpNestedLayout
->Activate();
1108 void MyFrame::CreateLayout( int layoutNo
)
1110 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
1112 if ( layoutNo
== THIRD_LAYOUT
)
1114 pLayout
->PushDefaultPlugins();
1115 pLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
1117 pLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
1119 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
1122 mLayouts
[layoutNo
] = pLayout
;
1124 DropInSomeBars( layoutNo
);
1127 void MyFrame::RemoveLayout( int layoutNo
)
1129 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
1131 if ( !pLayout
) return;
1133 pLayout
->HideBarWindows();
1135 // destroy nested layout first
1137 if ( layoutNo
== THIRD_LAYOUT
)
1139 if ( mpNestedLayout
) delete mpNestedLayout
;
1140 mpNestedLayout
= NULL
;
1143 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
1145 pLayout
->DestroyBarWindows();
1149 mLayouts
[layoutNo
] = NULL
;
1154 void MyFrame::DestroyEverything()
1156 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1162 mpClntWindow
->Destroy();
1164 mpClntWindow
= NULL
;
1168 void MyFrame::SyncMenuBarItems()
1170 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1172 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
1174 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
1177 void MyFrame::ActivateLayout( int layoutNo
)
1179 if ( layoutNo
== mActiveLayoutNo
) return;
1181 if ( mLayouts
[mActiveLayoutNo
] )
1183 mLayouts
[mActiveLayoutNo
]->Deactivate();
1185 mActiveLayoutNo
= layoutNo
;
1187 if ( mLayouts
[mActiveLayoutNo
] )
1189 mLayouts
[mActiveLayoutNo
]->Activate();
1196 void MyFrame::SerializeMe( wxObjectStorage
& store
)
1198 store
.AddInitialRef( this );
1199 store
.AddInitialRef( mpInternalFrm
);
1200 store
.AddInitialRef( &mAboutBox
);
1201 store
.AddInitialRef( &mImageList
);
1203 store
.XchgInt ( mActiveLayoutNo
);
1204 store
.XchgBool( mAutoSave
);
1206 store
.XchgObjPtr( (wxObject
**) &mpClntWindow
);
1208 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1210 if ( i
== THIRD_LAYOUT
)
1212 store
.XchgObjPtr( (wxObject
**) &(mpNestedLayout
) );
1214 store
.XchgObjPtr( (wxObject
**) &(mLayouts
[i
]) );
1217 store
.XchgObjPtr( (wxObject
**) &(mpAboutBoxLayout
) );
1219 store
.Finalize(); // finish serialization
1222 #ifdef __HACK_MY_MSDEV40__
1224 ////////////// new 2.0-magic (linker errors...) ////////////////
1226 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1228 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1229 "recreating toolbar in wxFrame" );
1231 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1234 SetToolBar(toolBar
);
1244 void foo( double& d
)
1249 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1253 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);