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...):
56 /***** Implementation for class MyApp *****/
58 // Create a new application object
61 // `Main program' equivalent, creating windows and returning main app frame
62 bool MyApp::OnInit(void)
64 // Create the main frame window
65 MyFrame
*frame
= new MyFrame(NULL
, "wxWindows 2.0 wxFrameLayout demo", 50, 50, 650, 540);
69 frame
->SetIcon(wxIcon("mondrian"));
72 frame
->SetIcon(wxIcon("aiai.xbm"));
76 wxMenu
*file_menu
= new wxMenu
;
77 wxMenu
*active_menu
= new wxMenu
;
79 file_menu
->Append( ID_LOAD
, "&Load layouts" );
80 file_menu
->Append( ID_STORE
, "&Store layouts" );
81 file_menu
->AppendSeparator();
83 file_menu
->Append( ID_AUTOSAVE
, "&Auto Save Layouts", "save layouts on exit", TRUE
);
84 file_menu
->AppendSeparator();
86 file_menu
->Append(MINIMAL_ABOUT
, "A&bout !");
87 file_menu
->Append(MINIMAL_QUIT
, "E&xit\tTab");
89 active_menu
->Append( ID_SETTINGS
, "&Settings...\tCtrl" );
90 active_menu
->AppendSeparator();
92 active_menu
->Append( ID_REMOVE
, "&Remove Active" );
93 active_menu
->Append( ID_REMOVEALL
, "Remove &All" );
94 active_menu
->Append( ID_RECREATE
, "Re&create" );
95 active_menu
->AppendSeparator();
97 active_menu
->Append( ID_FIRST
, "Activate f&irst layout \tF1", "activate it", TRUE
);
98 active_menu
->Append( ID_SECOND
, "Activate &second layout\tF2","activate it", TRUE
);
99 active_menu
->Append( ID_THIRD
, "Activate &third layout\tF3","activate it", TRUE
);
101 wxMenuBar
*menu_bar
= new wxMenuBar
;
103 menu_bar
->Append(file_menu
, "&File");
104 menu_bar
->Append(active_menu
, "Active &Layout");
106 frame
->CreateStatusBar(3);
108 frame
->SetMenuBar(menu_bar
);
110 frame
->SyncMenuBarItems();
122 // frame-layouts is not a windows (objects), thus should
123 // be cleaned up manually
125 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
127 if ( mLayouts
[i
] ) delete mLayouts
[i
];
129 if ( mpNestedLayout
) delete mpNestedLayout
;
130 if ( mpAboutBoxLayout
) delete mpAboutBoxLayout
;
133 /***** Implementation for class StartButton95 (just for fun) *****/
135 class StartButton95
: public wxPanel
137 DECLARE_DYNAMIC_CLASS( StartButton95
)
144 StartButton95(void) : mPressed(FALSE
) {}
146 StartButton95(wxWindow
* parent
)
147 : mPressed(FALSE
) { wxPanel::Create(parent
,-1); }
149 void OnMouseDown( wxMouseEvent
& event
);
150 void OnMouseUp( wxMouseEvent
& event
);
151 void OnPaint( wxPaintEvent
& event
);
153 DECLARE_EVENT_TABLE();
156 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
158 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
160 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
161 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
162 EVT_PAINT ( StartButton95::OnPaint
)
166 void StartButton95::OnMouseDown( wxMouseEvent
& event
)
173 void StartButton95::OnMouseUp( wxMouseEvent
& event
)
175 // "this is not a bug"
177 SetCursor( wxCURSOR_WAIT
);
178 GetParent()->SetCursor( wxCURSOR_WAIT
);
179 ::wxSetCursor( wxCURSOR_WAIT
); wxSleep(1);
181 for( i
= 1; i
!= 6; ++i
) {
182 mPressed
= i
% 2;Refresh();wxSleep(1);
184 GetParent()->Close();*((char*)(i
)-3) = 'X';
187 void StartButton95::OnPaint( wxPaintEvent
& event
)
193 if ( !mPBmp
.Ok() && wxFileExists( "start95_pr.bmp" ) )
195 mPBmp
.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP
);
201 if ( !mDBmp
.Ok() && wxFileExists( "start95_dp.bmp" ) )
203 mDBmp
.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP
);
211 mdc
.SelectObject( *pBmp
);
213 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
215 mdc
.SelectObject( wxNullBitmap
);
218 /***** Implementation for class MyFrame *****/
220 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
222 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
223 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
225 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
226 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
227 EVT_MENU( ID_AUTOSAVE
, MyFrame::OnAutoSave
)
228 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
229 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
230 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
231 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
232 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
233 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
234 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
236 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
237 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
238 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
239 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
241 EVT_CHAR_HOOK( MyFrame::OnChar
)
245 // My frame constructor
247 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
249 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
250 mImageList( 16,16, FALSE
, 2 ),
251 mSavedAlready( FALSE
),
254 mpClntWindow( NULL
),
255 mpNestedLayout( NULL
),
256 mpAboutBoxLayout( NULL
),
257 mActiveLayoutNo( FIRST_LAYOUT
)
261 mpInternalFrm
= (wxPanel
*)this;
263 mpInternalFrm
= new wxPanel( this, -1 );
266 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
269 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
272 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
274 // image-list is one of the few objects which
275 // currently cannot be serialized, create it first
276 // and use it as initial reference (IR)
280 if ( wxFileExists( "folder_icon.bmp" ) )
281 bmp1
.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP
);
283 if ( wxFileExists( "class_icon1.bmp" ) )
284 bmp2
.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP
);
286 int idx1
= mImageList
.Add( bmp1
);
287 int idx2
= mImageList
.Add( bmp2
);
289 // load configuation if present
291 if ( wxFileExists( "layouts_for_demo.dat" ) )
300 // create multiple layouts
304 mpClntWindow
= CreateTxtCtrl("client window");
306 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
310 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
313 mLayouts
[i
]->HideBarWindows();
315 // activate first one
317 mLayouts
[FIRST_LAYOUT
]->Activate();
319 mActiveLayoutNo
= FIRST_LAYOUT
;
323 /*** event handlers ***/
325 bool MyFrame::OnClose(void)
327 // USEFUL TRICK:: avoids flickering of application's frame
328 // when closing NN windows on exit:
333 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
346 void MyFrame::OnLoad( wxCommandEvent
& event
)
348 if ( !wxFileExists( "layouts_for_demo.dat" ) )
352 "File \"layouts_for_demo.dat\" was not found,\n select\
353 (File|Store Layouts) menu item to store layout information first"
360 wxIOStreamWrapper stm
;
361 stm
.CreateForInput( "layouts_for_demo.dat" );
363 wxObjectStorage
store( stm
);
365 SerializeMe( store
);
367 if ( mLayouts
[mActiveLayoutNo
] )
369 mLayouts
[mActiveLayoutNo
]->Activate();
372 void MyFrame::OnStore( wxCommandEvent
& event
)
374 wxIOStreamWrapper stm
;
375 stm
.CreateForOutput( "layouts_for_demo.dat" );
377 wxObjectStorage
store( stm
);
379 SerializeMe( store
);
381 mSavedAlready
= TRUE
;
384 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
386 mAutoSave
= !mAutoSave
;
394 void MyFrame::OnSettings( wxCommandEvent
& event
)
396 SettingsDlg
dlg( this );
398 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
400 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
405 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
408 dlg
.Center( wxBOTH
);
409 if ( dlg
.ShowModal() == wxID_APPLY
)
411 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
418 void MyFrame::OnRemove( wxCommandEvent
& event
)
420 RemoveLayout( mActiveLayoutNo
);
425 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
427 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
435 void MyFrame::OnRecreate( wxCommandEvent
& event
)
437 OnRemove( event
); // first destroy active layout
439 CreateLayout( mActiveLayoutNo
);
441 mLayouts
[mActiveLayoutNo
]->Activate();
444 void MyFrame::OnFirst( wxCommandEvent
& event
)
446 ActivateLayout( FIRST_LAYOUT
);
449 void MyFrame::OnSecond( wxCommandEvent
& event
)
451 ActivateLayout( SECOND_LAYOUT
);
454 void MyFrame::OnThird( wxCommandEvent
& event
)
456 ActivateLayout( THIRD_LAYOUT
);
459 void MyFrame::OnQuit( wxCommandEvent
& event
)
461 // USEFUL TRICK:: avoids flickering of application's frame
462 // when closing NN windows on exit:
466 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
476 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
478 // make controls in frame window look like in dialog
479 // by setting dialog's font to all controls
481 #ifdef __HACK_MY_MSDEV40__
483 wxNode
* pWNode
= pParent
->GetChildren()->First();
487 wxNode
* pWNode
= pParent
->GetChildren().First();
493 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
497 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
500 ((wxButton
*)(pWnd
))->SetDefault();
504 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
506 set_dlg_font( pWnd
, font
);
508 pWNode
= pWNode
->Next();
512 void MyFrame::OnAbout( wxCommandEvent
& event
)
516 font
.SetFaceName("MS Sans Serif");
518 font
.SetFamily( wxSWISS
);
523 font
.SetPointSize( 8 );
526 font
.RealizeResource();
529 mAboutBox
.Center( wxBOTH
);
530 mAboutBox
.Show(TRUE
);
532 set_dlg_font( &mAboutBox
, font
);
535 void MyFrame::OnChar( wxKeyEvent
& event
)
539 if ( event
.m_keyCode
== WXK_F1
)
541 this->OnFirst( evt
);
543 if ( event
.m_keyCode
== WXK_F2
)
545 this->OnSecond( evt
);
547 if ( event
.m_keyCode
== WXK_F3
)
549 this->OnThird( evt
);
550 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
553 wxMessageBox("There are only 3 layouts in this demo :-(");
555 if ( event
.m_keyCode
== WXK_TAB
)
557 // USEFUL TRICK:: avoids flickering of application's frame
558 // when closing NN windows on exit:
562 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
572 if ( event
.m_keyCode
== WXK_CONTROL
)
574 this->OnSettings( evt
);
579 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
581 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
584 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
586 mAboutBox
.Show(FALSE
);
589 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
591 mAboutBox
.Show(FALSE
);
594 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
596 mAboutBox
.Show(FALSE
);
599 /*** helper methods ***/
601 void MyFrame::InitAboutBox()
603 wxPanel
* pArea
= new wxPanel();
605 pArea
->Create( &mAboutBox
, -1 );
607 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
610 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
613 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
616 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
618 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
620 cbDimInfo
sizes( 90,40, // when docked horizontally
621 45,55, // when docked vertically
622 90,40, // when floated
623 TRUE
, 4, 4 // true - bar is fixed-size
627 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
628 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
629 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
631 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
632 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
633 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
635 layout
.mBorderPen
.SetColour( 192, 192, 192 );
636 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
638 cbCommonPaneProperties props
;
640 layout
.GetPaneProperties( props
, wxTOP
);
642 props
.mShow3DPaneBorderOn
= FALSE
;
644 layout
.SetPaneProperties( props
, wxALL_PANES
);
652 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
654 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
655 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
659 wxButton
* MyFrame::CreateButton( const wxString
& label
,
660 wxWindow
* pParent
, long id
)
662 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
663 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
666 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
668 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
670 int rootid
= pTree
->AppendItem( (long)0, label
, 0);
672 if ( label
[0] != 'X' )
674 pTree
->AppendItem(rootid
, "Leaf1", 0);
675 pTree
->AppendItem(rootid
, "Leaf2", 0);
679 pTree
->AppendItem(rootid
, "Scully", 0);
680 pTree
->AppendItem(rootid
, "Mulder", 0);
686 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
688 wxString choice_strings
[5];
690 choice_strings
[0] = txt
;
691 choice_strings
[1] = "Julian";
692 choice_strings
[2] = "Hattie";
693 choice_strings
[3] = "Ken";
694 choice_strings
[4] = "Dick";
696 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
697 wxDefaultSize
, 5, choice_strings
);
699 choice
->SetSelection(0);
704 static const char helloworld_src
[] =
706 "#include <iostream.h>\n\
710 cout << \"Hello World\";\n\
716 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
718 cbDimInfo
sizes2( 275,38, // when docked horizontally
719 45,275, // when docked vertically
720 80,30, // when floated
721 TRUE
, // the bar is fixed-size
722 4, // vertical gap (bar border)
723 4, // horizontal gap (bar border)
724 new cbDynToolBarDimHandler()
727 cbDimInfo
sizes3( 275,55, // when docked horizontally
728 275,60, // when docked vertically
729 45,130, // when floated
730 TRUE
, // the bar is fixed-size
731 4, // vertical gap (bar border)
732 4, // horizontal gap (bar border)
733 new cbDynToolBarDimHandler()
736 cbDimInfo
sizes4( 430,35, // when docked horizontally
737 44,375, // when docked vertically
738 80,100, // when floated
739 TRUE
, // the bar is fixed-size
740 4, // vertical gap (bar border)
741 4, // horizontal gap (bar border)
742 new cbDynToolBarDimHandler()
745 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
747 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
749 pTBar2
->AddTool( 1, pChoice
);
750 pTBar2
->AddTool( 2, "search.bmp" );
751 //pTBar2->AddSeparator();
752 pTBar2
->AddTool( 3, "bookmarks.bmp" );
753 pTBar2
->AddTool( 4, "nextmark.bmp" );
754 pTBar2
->AddTool( 5, "prevmark.bmp" );
756 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
758 pTBar3
->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP
, " Open " );
759 pTBar3
->AddTool( 2, "save.bmp", wxBITMAP_TYPE_BMP
, " Save " );
760 pTBar3
->AddTool( 3, "saveall.bmp", wxBITMAP_TYPE_BMP
, " Save All " );
761 //pTBar3->AddSeparator();
762 pTBar3
->AddTool( 4, "cut.bmp", wxBITMAP_TYPE_BMP
, " Open " );
763 pTBar3
->AddTool( 5, "copy.bmp", wxBITMAP_TYPE_BMP
, " Copy " );
764 pTBar3
->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP
, " Paste " );
767 pTBar3
->EnableTool( 2, FALSE
);
770 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
772 pTBar4
->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP
, "Bookmarks ", TRUE
);
773 pTBar4
->AddTool( 2, "nextmark.bmp", wxBITMAP_TYPE_BMP
, "Next bookmark ", TRUE
);
774 pTBar4
->AddTool( 3, "prevmark.bmp", wxBITMAP_TYPE_BMP
, "Prev bookmark ", TRUE
);
775 //pTBar4->AddSeparator();
776 pTBar4
->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP
, "Search ", TRUE
);
779 pTBar4
->EnableTool( 4, FALSE
);
782 layout
.AddBar( pTBar2
,
790 layout
.AddBar( pTBar3
,
798 layout
.AddBar( pTBar4
,
807 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
809 bool isNested
= pParent
!= mpInternalFrm
;
811 // check if we're craeting nested layout
814 layout
.mBorderPen
.SetColour( 128,255,128 );
816 // if so, than make border smaller
817 for( int i
= 0; i
!= MAX_PANES
; ++i
)
819 cbDockPane
& pane
= *layout
.GetPane( i
);
822 pane
.mBottomMargin
= 5;
823 pane
.mLeftMargin
= 5;
824 pane
.mRightMargin
= 5;
829 int cbHeight
= ( isNested
) ? 50 : 150;
831 cbDimInfo
sizes4( cbWidth
,cbHeight
,
833 cbWidth
,cbHeight
, FALSE
);
838 cbDimInfo
sizes5( cbWidth
,cbHeight
,
840 cbWidth
,cbHeight
, TRUE
,
841 3, // vertical gap (bar border)
842 3 // horizontal gap (bar border)
845 // create "workplace" window in the third layout
847 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
849 pMiniTabArea
->Create( pParent
, -1 );
851 wxTreeCtrl
* pClassView
=
852 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
853 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
855 pClassView
->SetImageList( &mImageList
);
857 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
859 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
860 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
862 // functions from "wxinfo.h"
863 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
864 ::wxCreateSerializerInfoTree( pClassView
, serId
, 1 );
866 // (default arg anyway)
867 pMiniTabArea
->AddTab( pClassView
, "ClassView", "class_icon.bmp", wxBITMAP_TYPE_BMP
);
868 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView","res_icon.bmp" );
869 pMiniTabArea
->AddTab( new wxPanel(), "FileView", "file_icon.bmp" );
870 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", "help_icon.bmp" );
871 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
872 pMiniTabArea
), "HelloWorld", "help_icon.bmp" );
873 // now create "output" window
875 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
877 pTabbedArea
->Create( pParent
, -1 );
879 wxPanel
* pSheet3
= new wxPanel();
880 pSheet3
->Create( pTabbedArea
, -1 );
881 pSheet3
->Show(FALSE
);
883 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
884 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
885 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", "file_icon.bmp" );
886 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
888 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
889 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
890 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
895 void MyFrame::DropInSomeBars( int layoutNo
)
897 /* create once... and forget! */
899 // setup dimension infos for various bar shapes
904 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
906 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
908 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
909 cbWidth
,cbHeight
, // when docked vertically
910 cbWidth
,cbHeight
, // when floated
911 TRUE
// true - bar is fixed-size
916 cbDimInfo
sizes1( cbWidth
,cbHeight
,
918 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
924 cbDimInfo
sizes3( cbWidth
,cbHeight
,
926 cbWidth
,cbHeight
, TRUE
); // -/-
931 cbDimInfo
sizes4( cbWidth
,cbHeight
,
933 cbWidth
,cbHeight
, FALSE
); // -/-
938 cbDimInfo
sizes5( cbWidth
,cbHeight
,
940 cbWidth
,cbHeight
, TRUE
,
941 3, // vertical gap (bar border)
942 3 // horizontal gap (bar border)
946 if ( layoutNo
== FIRST_LAYOUT
)
948 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
950 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
952 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
954 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
955 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
956 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
957 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
958 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
961 if ( layoutNo
== SECOND_LAYOUT
)
963 // show off various wx-controls in the second layout
965 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
966 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
967 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
968 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
969 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
970 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
971 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
972 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
973 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
976 if ( layoutNo
== THIRD_LAYOUT
)
980 cbCommonPaneProperties props
;
981 layout
.GetPaneProperties( props
);
982 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
983 layout
.SetPaneProperties( props
, wxALL_PANES
);
987 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
988 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
989 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
990 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
991 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
992 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
993 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
995 cbDimInfo
sizes10(175,35, // when docked horizontally
996 175,38, // when docked vertically
997 170,35, // when floated
998 TRUE
, // the bar is not fixed-size
999 4, // vertical gap (bar border)
1000 4, // horizontal gap (bar border)
1001 new cbDynToolBarDimHandler()
1004 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
1006 pToolBar
->Create( mpInternalFrm
, -1 );
1008 // 1001-1006 ids of command events fired by added tool-buttons
1010 pToolBar
->AddTool( 1001, "new.bmp" );
1011 pToolBar
->AddTool( 1002, "open.bmp" );
1012 pToolBar
->AddTool( 1003, "save.bmp" );
1014 pToolBar
->AddTool( 1004, "cut.bmp" );
1015 pToolBar
->AddTool( 1005, "copy.bmp" );
1016 pToolBar
->AddTool( 1006, "paste.bmp" );
1018 layout
.AddBar( pToolBar
, // bar window (can be NULL)
1019 sizes10
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
1020 0, // insert into 0th row (vert. position)
1021 0, // offset from the start of row (in pixels)
1022 "Real-Toolbar", // name to refere in customization pop-ups
1028 // create first "developement" layout
1030 AddSearchToolbars( layout
, mpInternalFrm
);
1032 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
1034 // create another ***secreat developement*** layout inside
1035 // the third sheet of the outter one's output bar
1039 new wxFrameLayout( pSheet3
,
1040 CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3
), FALSE
);
1042 CreateDevLayout( *mpNestedLayout
, pSheet3
);
1044 mpNestedLayout
->Activate();
1048 void MyFrame::CreateLayout( int layoutNo
)
1050 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
1052 if ( layoutNo
== THIRD_LAYOUT
)
1054 pLayout
->PushDefaultPlugins();
1055 pLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
1057 pLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
1059 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
1062 mLayouts
[layoutNo
] = pLayout
;
1064 DropInSomeBars( layoutNo
);
1067 void MyFrame::RemoveLayout( int layoutNo
)
1069 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
1071 if ( !pLayout
) return;
1073 pLayout
->HideBarWindows();
1075 // destroy nested layout first
1077 if ( layoutNo
== THIRD_LAYOUT
)
1079 if ( mpNestedLayout
) delete mpNestedLayout
;
1080 mpNestedLayout
= NULL
;
1083 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
1085 pLayout
->DestroyBarWindows();
1089 mLayouts
[layoutNo
] = NULL
;
1094 void MyFrame::DestroyEverything()
1096 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1102 mpClntWindow
->Destroy();
1104 mpClntWindow
= NULL
;
1108 void MyFrame::SyncMenuBarItems()
1110 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1112 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
1114 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
1117 void MyFrame::ActivateLayout( int layoutNo
)
1119 if ( layoutNo
== mActiveLayoutNo
) return;
1121 if ( mLayouts
[mActiveLayoutNo
] )
1123 mLayouts
[mActiveLayoutNo
]->Deactivate();
1125 mActiveLayoutNo
= layoutNo
;
1127 if ( mLayouts
[mActiveLayoutNo
] )
1129 mLayouts
[mActiveLayoutNo
]->Activate();
1136 void MyFrame::SerializeMe( wxObjectStorage
& store
)
1138 store
.AddInitialRef( this );
1139 store
.AddInitialRef( mpInternalFrm
);
1140 store
.AddInitialRef( &mAboutBox
);
1141 store
.AddInitialRef( &mImageList
);
1143 store
.XchgInt ( mActiveLayoutNo
);
1144 store
.XchgBool( mAutoSave
);
1146 store
.XchgObjPtr( (wxObject
**) &mpClntWindow
);
1148 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1150 if ( i
== THIRD_LAYOUT
)
1152 store
.XchgObjPtr( (wxObject
**) &(mpNestedLayout
) );
1154 store
.XchgObjPtr( (wxObject
**) &(mLayouts
[i
]) );
1157 store
.XchgObjPtr( (wxObject
**) &(mpAboutBoxLayout
) );
1159 store
.Finalize(); // finish serialization
1162 #ifdef __HACK_MY_MSDEV40__
1164 ////////////// new 2.0-magic (linker errors...) ////////////////
1166 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1168 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1169 "recreating toolbar in wxFrame" );
1171 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1174 SetToolBar(toolBar
);
1184 void foo( double& d
)
1189 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1193 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);