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
)
195 if ( !mPBmp
.Ok() && wxFileExists( "start95_pr.bmp" ) )
197 mPBmp
.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP
);
203 if ( !mDBmp
.Ok() && wxFileExists( "start95_dp.bmp" ) )
205 mDBmp
.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP
);
213 mdc
.SelectObject( *pBmp
);
215 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
217 mdc
.SelectObject( wxNullBitmap
);
220 /***** Implementation for class MyFrame *****/
222 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
224 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
225 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
227 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
228 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
229 EVT_MENU( ID_AUTOSAVE
, MyFrame::OnAutoSave
)
230 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
231 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
232 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
233 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
234 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
235 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
236 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
238 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
239 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
240 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
241 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
243 EVT_CHAR_HOOK( MyFrame::OnChar
)
247 // My frame constructor
249 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
251 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
252 mImageList( 16,16, FALSE
, 2 ),
253 mSavedAlready( FALSE
),
256 mpClntWindow( NULL
),
257 mpNestedLayout( NULL
),
258 mpAboutBoxLayout( NULL
),
259 mActiveLayoutNo( FIRST_LAYOUT
)
263 mpInternalFrm
= (wxPanel
*)this;
265 mpInternalFrm
= new wxPanel( this, -1 );
268 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
271 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
274 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
276 // image-list is one of the few objects which
277 // currently cannot be serialized, create it first
278 // and use it as initial reference (IR)
282 if ( wxFileExists( "folder_icon.bmp" ) )
283 bmp1
.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP
);
285 if ( wxFileExists( "class_icon1.bmp" ) )
286 bmp2
.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP
);
288 int idx1
= mImageList
.Add( bmp1
);
289 int idx2
= mImageList
.Add( bmp2
);
291 // load configuation if present
293 if ( wxFileExists( "layouts_for_demo.dat" ) )
302 // create multiple layouts
306 mpClntWindow
= CreateTxtCtrl("client window");
308 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
312 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
315 mLayouts
[i
]->HideBarWindows();
317 // activate first one
319 mLayouts
[FIRST_LAYOUT
]->Activate();
321 mActiveLayoutNo
= FIRST_LAYOUT
;
325 /*** event handlers ***/
327 bool MyFrame::OnClose(void)
329 // USEFUL TRICK:: avoids flickering of application's frame
330 // when closing NN windows on exit:
335 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
348 void MyFrame::OnLoad( wxCommandEvent
& event
)
350 if ( !wxFileExists( "layouts_for_demo.dat" ) )
354 "File \"layouts_for_demo.dat\" was not found,\n select\
355 (File|Store Layouts) menu item to store layout information first"
362 wxIOStreamWrapper stm
;
363 stm
.CreateForInput( "layouts_for_demo.dat" );
365 wxObjectStorage
store( stm
);
367 SerializeMe( store
);
369 if ( mLayouts
[mActiveLayoutNo
] )
371 mLayouts
[mActiveLayoutNo
]->Activate();
374 void MyFrame::OnStore( wxCommandEvent
& event
)
376 wxIOStreamWrapper stm
;
377 stm
.CreateForOutput( "layouts_for_demo.dat" );
379 wxObjectStorage
store( stm
);
381 SerializeMe( store
);
383 mSavedAlready
= TRUE
;
386 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
388 mAutoSave
= !mAutoSave
;
396 void MyFrame::OnSettings( wxCommandEvent
& event
)
398 SettingsDlg
dlg( this );
400 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
402 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
407 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
410 dlg
.Center( wxBOTH
);
411 if ( dlg
.ShowModal() == wxID_APPLY
)
413 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
420 void MyFrame::OnRemove( wxCommandEvent
& event
)
422 RemoveLayout( mActiveLayoutNo
);
427 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
429 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
437 void MyFrame::OnRecreate( wxCommandEvent
& event
)
439 OnRemove( event
); // first destroy active layout
441 CreateLayout( mActiveLayoutNo
);
443 mLayouts
[mActiveLayoutNo
]->Activate();
446 void MyFrame::OnFirst( wxCommandEvent
& event
)
448 ActivateLayout( FIRST_LAYOUT
);
451 void MyFrame::OnSecond( wxCommandEvent
& event
)
453 ActivateLayout( SECOND_LAYOUT
);
456 void MyFrame::OnThird( wxCommandEvent
& event
)
458 ActivateLayout( THIRD_LAYOUT
);
461 void MyFrame::OnQuit( wxCommandEvent
& event
)
463 // USEFUL TRICK:: avoids flickering of application's frame
464 // when closing NN windows on exit:
468 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
478 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
480 // make controls in frame window look like in dialog
481 // by setting dialog's font to all controls
483 #ifdef __HACK_MY_MSDEV40__
485 wxNode
* pWNode
= pParent
->GetChildren()->First();
489 wxNode
* pWNode
= pParent
->GetChildren().First();
495 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
499 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
502 ((wxButton
*)(pWnd
))->SetDefault();
506 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
508 set_dlg_font( pWnd
, font
);
510 pWNode
= pWNode
->Next();
514 void MyFrame::OnAbout( wxCommandEvent
& event
)
518 font
.SetFaceName("MS Sans Serif");
520 font
.SetFamily( wxSWISS
);
525 font
.SetPointSize( 8 );
528 font
.RealizeResource();
531 mAboutBox
.Center( wxBOTH
);
532 mAboutBox
.Show(TRUE
);
534 set_dlg_font( &mAboutBox
, font
);
537 void MyFrame::OnChar( wxKeyEvent
& event
)
541 if ( event
.m_keyCode
== WXK_F1
)
543 this->OnFirst( evt
);
545 if ( event
.m_keyCode
== WXK_F2
)
547 this->OnSecond( evt
);
549 if ( event
.m_keyCode
== WXK_F3
)
551 this->OnThird( evt
);
552 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
555 wxMessageBox("There are only 3 layouts in this demo :-(");
557 if ( event
.m_keyCode
== WXK_TAB
)
559 // USEFUL TRICK:: avoids flickering of application's frame
560 // when closing NN windows on exit:
564 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
574 if ( event
.m_keyCode
== WXK_CONTROL
)
576 this->OnSettings( evt
);
581 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
583 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
586 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
588 mAboutBox
.Show(FALSE
);
591 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
593 mAboutBox
.Show(FALSE
);
596 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
598 mAboutBox
.Show(FALSE
);
601 /*** helper methods ***/
603 void MyFrame::InitAboutBox()
605 wxPanel
* pArea
= new wxPanel();
607 pArea
->Create( &mAboutBox
, -1 );
609 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
612 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
615 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
618 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
620 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
622 cbDimInfo
sizes( 90,40, // when docked horizontally
623 45,55, // when docked vertically
624 90,40, // when floated
625 TRUE
, 4, 4 // true - bar is fixed-size
629 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
630 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
631 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
633 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
634 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
635 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
637 layout
.mBorderPen
.SetColour( 192, 192, 192 );
638 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
640 cbCommonPaneProperties props
;
642 layout
.GetPaneProperties( props
, wxTOP
);
644 props
.mShow3DPaneBorderOn
= FALSE
;
646 layout
.SetPaneProperties( props
, wxALL_PANES
);
654 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
656 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
657 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
661 wxButton
* MyFrame::CreateButton( const wxString
& label
,
662 wxWindow
* pParent
, long id
)
664 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
665 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
668 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
670 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
672 int rootid
= pTree
->AppendItem( (long)0, label
, -1);
674 if ( label
[0] != 'X' )
676 pTree
->AppendItem(rootid
, "Leaf1", -1);
677 pTree
->AppendItem(rootid
, "Leaf2", -1);
681 pTree
->AppendItem(rootid
, "Scully", -1);
682 pTree
->AppendItem(rootid
, "Mulder", -1);
688 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
690 wxString choice_strings
[5];
692 choice_strings
[0] = txt
;
693 choice_strings
[1] = "Julian";
694 choice_strings
[2] = "Hattie";
695 choice_strings
[3] = "Ken";
696 choice_strings
[4] = "Dick";
698 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
699 wxDefaultSize
, 5, choice_strings
);
701 choice
->SetSelection(0);
706 static const char helloworld_src
[] =
708 "#include <iostream.h>\n\
712 cout << \"Hello World\";\n\
718 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
720 cbDimInfo
sizes2( 275,38, // when docked horizontally
721 45,275, // when docked vertically
722 80,30, // when floated
723 TRUE
, // the bar is fixed-size
724 4, // vertical gap (bar border)
725 4, // horizontal gap (bar border)
726 new cbDynToolBarDimHandler()
729 cbDimInfo
sizes3( 275,55, // when docked horizontally
730 275,60, // when docked vertically
731 45,130, // when floated
732 TRUE
, // the bar is fixed-size
733 4, // vertical gap (bar border)
734 4, // horizontal gap (bar border)
735 new cbDynToolBarDimHandler()
738 cbDimInfo
sizes4( 430,35, // when docked horizontally
739 44,375, // when docked vertically
740 80,100, // when floated
741 TRUE
, // the bar is fixed-size
742 4, // vertical gap (bar border)
743 4, // horizontal gap (bar border)
744 new cbDynToolBarDimHandler()
747 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
749 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
751 pTBar2
->AddTool( 1, pChoice
);
752 pTBar2
->AddTool( 2, "search.bmp" );
753 //pTBar2->AddSeparator();
754 pTBar2
->AddTool( 3, "bookmarks.bmp" );
755 pTBar2
->AddTool( 4, "nextmark.bmp" );
756 pTBar2
->AddTool( 5, "prevmark.bmp" );
758 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
760 pTBar3
->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP
, " Open " );
761 pTBar3
->AddTool( 2, "save.bmp", wxBITMAP_TYPE_BMP
, " Save " );
762 pTBar3
->AddTool( 3, "saveall.bmp", wxBITMAP_TYPE_BMP
, " Save All " );
763 //pTBar3->AddSeparator();
764 pTBar3
->AddTool( 4, "cut.bmp", wxBITMAP_TYPE_BMP
, " Open " );
765 pTBar3
->AddTool( 5, "copy.bmp", wxBITMAP_TYPE_BMP
, " Copy " );
766 pTBar3
->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP
, " Paste " );
769 pTBar3
->EnableTool( 2, FALSE
);
772 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
774 pTBar4
->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP
, "Bookmarks ", TRUE
);
775 pTBar4
->AddTool( 2, "nextmark.bmp", wxBITMAP_TYPE_BMP
, "Next bookmark ", TRUE
);
776 pTBar4
->AddTool( 3, "prevmark.bmp", wxBITMAP_TYPE_BMP
, "Prev bookmark ", TRUE
);
777 //pTBar4->AddSeparator();
778 pTBar4
->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP
, "Search ", TRUE
);
781 pTBar4
->EnableTool( 4, FALSE
);
784 layout
.AddBar( pTBar2
,
792 layout
.AddBar( pTBar3
,
800 layout
.AddBar( pTBar4
,
809 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
811 bool isNested
= pParent
!= mpInternalFrm
;
813 // check if we're craeting nested layout
816 layout
.mBorderPen
.SetColour( 128,255,128 );
818 // if so, than make border smaller
819 for( int i
= 0; i
!= MAX_PANES
; ++i
)
821 cbDockPane
& pane
= *layout
.GetPane( i
);
824 pane
.mBottomMargin
= 5;
825 pane
.mLeftMargin
= 5;
826 pane
.mRightMargin
= 5;
831 int cbHeight
= ( isNested
) ? 50 : 150;
833 cbDimInfo
sizes4( cbWidth
,cbHeight
,
835 cbWidth
,cbHeight
, FALSE
);
840 cbDimInfo
sizes5( cbWidth
,cbHeight
,
842 cbWidth
,cbHeight
, TRUE
,
843 3, // vertical gap (bar border)
844 3 // horizontal gap (bar border)
847 // create "workplace" window in the third layout
849 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
851 pMiniTabArea
->Create( pParent
, -1 );
853 wxTreeCtrl
* pClassView
=
854 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
855 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
857 pClassView
->SetImageList( &mImageList
);
859 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
861 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
862 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
864 // functions from "wxinfo.h"
865 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
866 ::wxCreateSerializerInfoTree( pClassView
, serId
, 1 );
868 // (default arg anyway)
869 pMiniTabArea
->AddTab( pClassView
, "ClassView", "class_icon.bmp", wxBITMAP_TYPE_BMP
);
870 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView","res_icon.bmp" );
871 pMiniTabArea
->AddTab( new wxPanel(), "FileView", "file_icon.bmp" );
872 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", "help_icon.bmp" );
873 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
874 pMiniTabArea
), "HelloWorld", "help_icon.bmp" );
875 // now create "output" window
877 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
879 pTabbedArea
->Create( pParent
, -1 );
881 wxPanel
* pSheet3
= new wxPanel();
882 pSheet3
->Create( pTabbedArea
, -1 );
883 pSheet3
->Show(FALSE
);
885 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
886 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
887 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", "file_icon.bmp" );
888 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
890 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
891 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
892 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
897 void MyFrame::DropInSomeBars( int layoutNo
)
899 /* create once... and forget! */
901 // setup dimension infos for various bar shapes
906 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
908 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
910 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
911 cbWidth
,cbHeight
, // when docked vertically
912 cbWidth
,cbHeight
, // when floated
913 TRUE
// true - bar is fixed-size
918 cbDimInfo
sizes1( cbWidth
,cbHeight
,
920 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
926 cbDimInfo
sizes3( cbWidth
,cbHeight
,
928 cbWidth
,cbHeight
, TRUE
); // -/-
933 cbDimInfo
sizes4( cbWidth
,cbHeight
,
935 cbWidth
,cbHeight
, FALSE
); // -/-
940 cbDimInfo
sizes5( cbWidth
,cbHeight
,
942 cbWidth
,cbHeight
, TRUE
,
943 3, // vertical gap (bar border)
944 3 // horizontal gap (bar border)
948 if ( layoutNo
== FIRST_LAYOUT
)
950 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
952 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
954 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
956 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
957 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
958 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
959 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
960 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
963 if ( layoutNo
== SECOND_LAYOUT
)
965 // show off various wx-controls in the second layout
967 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
968 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
969 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
970 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
971 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
972 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
973 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
974 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
975 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
978 if ( layoutNo
== THIRD_LAYOUT
)
982 cbCommonPaneProperties props
;
983 layout
.GetPaneProperties( props
);
984 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
985 layout
.SetPaneProperties( props
, wxALL_PANES
);
989 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
990 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
991 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
992 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
993 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
994 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
995 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
997 cbDimInfo
sizes10(175,35, // when docked horizontally
998 175,38, // when docked vertically
999 170,35, // when floated
1000 TRUE
, // the bar is not fixed-size
1001 4, // vertical gap (bar border)
1002 4, // horizontal gap (bar border)
1003 new cbDynToolBarDimHandler()
1006 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
1008 pToolBar
->Create( mpInternalFrm
, -1 );
1010 // 1001-1006 ids of command events fired by added tool-buttons
1012 pToolBar
->AddTool( 1001, "new.bmp" );
1013 pToolBar
->AddTool( 1002, "open.bmp" );
1014 pToolBar
->AddTool( 1003, "save.bmp" );
1016 pToolBar
->AddTool( 1004, "cut.bmp" );
1017 pToolBar
->AddTool( 1005, "copy.bmp" );
1018 pToolBar
->AddTool( 1006, "paste.bmp" );
1020 layout
.AddBar( pToolBar
, // bar window (can be NULL)
1021 sizes10
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
1022 0, // insert into 0th row (vert. position)
1023 0, // offset from the start of row (in pixels)
1024 "Real-Toolbar", // name to refere in customization pop-ups
1030 // create first "developement" layout
1032 AddSearchToolbars( layout
, mpInternalFrm
);
1034 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
1036 // create another ***secreat developement*** layout inside
1037 // the third sheet of the outter one's output bar
1041 new wxFrameLayout( pSheet3
,
1042 CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3
), FALSE
);
1044 CreateDevLayout( *mpNestedLayout
, pSheet3
);
1046 mpNestedLayout
->Activate();
1050 void MyFrame::CreateLayout( int layoutNo
)
1052 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
1054 if ( layoutNo
== THIRD_LAYOUT
)
1056 pLayout
->PushDefaultPlugins();
1057 pLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
1059 pLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
1061 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
1064 mLayouts
[layoutNo
] = pLayout
;
1066 DropInSomeBars( layoutNo
);
1069 void MyFrame::RemoveLayout( int layoutNo
)
1071 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
1073 if ( !pLayout
) return;
1075 pLayout
->HideBarWindows();
1077 // destroy nested layout first
1079 if ( layoutNo
== THIRD_LAYOUT
)
1081 if ( mpNestedLayout
) delete mpNestedLayout
;
1082 mpNestedLayout
= NULL
;
1085 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
1087 pLayout
->DestroyBarWindows();
1091 mLayouts
[layoutNo
] = NULL
;
1096 void MyFrame::DestroyEverything()
1098 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1104 mpClntWindow
->Destroy();
1106 mpClntWindow
= NULL
;
1110 void MyFrame::SyncMenuBarItems()
1112 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1114 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
1116 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
1119 void MyFrame::ActivateLayout( int layoutNo
)
1121 if ( layoutNo
== mActiveLayoutNo
) return;
1123 if ( mLayouts
[mActiveLayoutNo
] )
1125 mLayouts
[mActiveLayoutNo
]->Deactivate();
1127 mActiveLayoutNo
= layoutNo
;
1129 if ( mLayouts
[mActiveLayoutNo
] )
1131 mLayouts
[mActiveLayoutNo
]->Activate();
1138 void MyFrame::SerializeMe( wxObjectStorage
& store
)
1140 store
.AddInitialRef( this );
1141 store
.AddInitialRef( mpInternalFrm
);
1142 store
.AddInitialRef( &mAboutBox
);
1143 store
.AddInitialRef( &mImageList
);
1145 store
.XchgInt ( mActiveLayoutNo
);
1146 store
.XchgBool( mAutoSave
);
1148 store
.XchgObjPtr( (wxObject
**) &mpClntWindow
);
1150 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1152 if ( i
== THIRD_LAYOUT
)
1154 store
.XchgObjPtr( (wxObject
**) &(mpNestedLayout
) );
1156 store
.XchgObjPtr( (wxObject
**) &(mLayouts
[i
]) );
1159 store
.XchgObjPtr( (wxObject
**) &(mpAboutBoxLayout
) );
1161 store
.Finalize(); // finish serialization
1164 #ifdef __HACK_MY_MSDEV40__
1166 ////////////// new 2.0-magic (linker errors...) ////////////////
1168 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1170 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1171 "recreating toolbar in wxFrame" );
1173 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1176 SetToolBar(toolBar
);
1186 void foo( double& d
)
1191 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1195 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);