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
54 #include "start95_dp.xpm"
55 #include "start95_pr.xpm"
56 #include "bookmarks.xpm"
57 #include "class_icon.xpm"
58 #include "class_icon1.xpm"
61 #include "file_icon.xpm"
62 #include "folder_icon.xpm"
63 #include "help_icon.xpm"
65 #include "nextmark.xpm"
68 #include "prevmark.xpm"
69 #include "res_icon.xpm"
71 #include "saveall.xpm"
74 // ADDED by alex (linker complaints...):
75 #ifndef wxDUMMY_OBJ_INCLUDED
79 /***** Implementation for class MyApp *****/
81 // Create a new application object
84 // `Main program' equivalent, creating windows and returning main app frame
85 bool MyApp::OnInit(void)
87 // Create the main frame window
88 MyFrame
*frame
= new MyFrame(NULL
, "wxWindows 2.0 wxFrameLayout demo", 50, 50, 650, 540);
92 frame
->SetIcon(wxIcon("mondrian"));
95 frame
->SetIcon(wxIcon("aiai.xbm"));
99 wxMenu
*file_menu
= new wxMenu
;
100 wxMenu
*active_menu
= new wxMenu
;
102 file_menu
->Append( ID_LOAD
, "&Load layouts" );
103 file_menu
->Append( ID_STORE
, "&Store layouts" );
104 file_menu
->AppendSeparator();
106 file_menu
->Append( ID_AUTOSAVE
, "&Auto Save Layouts", "save layouts on exit", TRUE
);
107 file_menu
->AppendSeparator();
109 file_menu
->Append(MINIMAL_ABOUT
, "A&bout !");
110 file_menu
->Append(MINIMAL_QUIT
, "E&xit\tTab");
112 active_menu
->Append( ID_SETTINGS
, "&Settings...\tCtrl" );
113 active_menu
->AppendSeparator();
115 active_menu
->Append( ID_REMOVE
, "&Remove Active" );
116 active_menu
->Append( ID_REMOVEALL
, "Remove &All" );
117 active_menu
->Append( ID_RECREATE
, "Re&create" );
118 active_menu
->AppendSeparator();
120 active_menu
->Append( ID_FIRST
, "Activate f&irst layout \tF1", "activate it", TRUE
);
121 active_menu
->Append( ID_SECOND
, "Activate &second layout\tF2","activate it", TRUE
);
122 active_menu
->Append( ID_THIRD
, "Activate &third layout\tF3","activate it", TRUE
);
124 wxMenuBar
*menu_bar
= new wxMenuBar
;
126 menu_bar
->Append(file_menu
, "&File");
127 menu_bar
->Append(active_menu
, "Active &Layout");
129 frame
->CreateStatusBar(3);
131 frame
->SetMenuBar(menu_bar
);
133 frame
->SyncMenuBarItems();
145 // frame-layouts is not a windows (objects), thus should
146 // be cleaned up manually
148 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
150 if ( mLayouts
[i
] ) delete mLayouts
[i
];
152 if ( mpNestedLayout
) delete mpNestedLayout
;
153 if ( mpAboutBoxLayout
) delete mpAboutBoxLayout
;
156 /***** Implementation for class StartButton95 (just for fun) *****/
158 class StartButton95
: public wxPanel
160 DECLARE_DYNAMIC_CLASS( StartButton95
)
167 StartButton95(void) : mPressed(FALSE
) {}
169 StartButton95(wxWindow
* parent
)
170 : mPressed(FALSE
) { wxPanel::Create(parent
,-1); }
172 void OnMouseDown( wxMouseEvent
& event
);
173 void OnMouseUp( wxMouseEvent
& event
);
174 void OnPaint( wxPaintEvent
& event
);
176 DECLARE_EVENT_TABLE();
179 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
181 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
183 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
184 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
185 EVT_PAINT ( StartButton95::OnPaint
)
189 void StartButton95::OnMouseDown( wxMouseEvent
& event
)
196 void StartButton95::OnMouseUp( wxMouseEvent
& event
)
198 // "this is not a bug"
200 SetCursor( wxCURSOR_WAIT
);
201 GetParent()->SetCursor( wxCURSOR_WAIT
);
202 ::wxSetCursor( wxCURSOR_WAIT
); wxSleep(1);
204 for( i
= 1; i
!= 6; ++i
) {
205 mPressed
= i
% 2;Refresh();wxSleep(1);
207 GetParent()->Close();*((char*)(i
)-3) = 'X';
210 void StartButton95::OnPaint( wxPaintEvent
& event
)
219 mPBmp
.LoadFile( "start95_pr_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
223 mPBmp
= wxBitmap( start95_pr_xpm
);
233 mDBmp
.LoadFile( "start95_dp_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
238 mDBmp
= wxBitmap(start95_dp_xpm
);
247 mdc
.SelectObject( *pBmp
);
249 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
251 mdc
.SelectObject( wxNullBitmap
);
254 /***** Implementation for class MyFrame *****/
256 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
258 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
259 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
261 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
262 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
263 EVT_MENU( ID_AUTOSAVE
, MyFrame::OnAutoSave
)
264 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
265 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
266 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
267 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
268 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
269 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
270 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
272 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
273 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
274 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
275 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
277 EVT_CHAR_HOOK( MyFrame::OnChar
)
281 // My frame constructor
283 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
285 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
286 mImageList( 16,16, FALSE
, 2 ),
287 mSavedAlready( FALSE
),
290 mpClntWindow( NULL
),
291 mpNestedLayout( NULL
),
292 mpAboutBoxLayout( NULL
),
293 mActiveLayoutNo( FIRST_LAYOUT
)
297 mpInternalFrm
= (wxPanel
*)this;
299 mpInternalFrm
= new wxPanel( this, -1 );
302 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
305 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
308 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
310 // image-list is one of the few objects which
311 // currently cannot be serialized, create it first
312 // and use it as initial reference (IR)
316 bmp1
.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
317 bmp2
.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE
);
319 bmp1
= wxBitmap( folder_icon_xpm
);
320 bmp2
= wxBitmap( class_icon1_xpm
);
322 int idx1
= mImageList
.Add( bmp1
);
323 int idx2
= mImageList
.Add( bmp2
);
325 // load configuation if present
327 if ( wxFileExists( "layouts_for_demo.dat" ) )
336 // create multiple layouts
340 mpClntWindow
= CreateTxtCtrl("client window");
342 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
346 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
349 mLayouts
[i
]->HideBarWindows();
351 // activate first one
353 mLayouts
[FIRST_LAYOUT
]->Activate();
355 mActiveLayoutNo
= FIRST_LAYOUT
;
359 /*** event handlers ***/
361 bool MyFrame::OnClose(void)
363 // USEFUL TRICK:: avoids flickering of application's frame
364 // when closing NN windows on exit:
369 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
382 void MyFrame::OnLoad( wxCommandEvent
& event
)
384 if ( !wxFileExists( "layouts_for_demo.dat" ) )
388 "File \"layouts_for_demo.dat\" was not found,\n select\
389 (File|Store Layouts) menu item to store layout information first"
396 wxIOStreamWrapper stm
;
397 stm
.CreateForInput( "layouts_for_demo.dat" );
399 wxObjectStorage
store( stm
);
401 SerializeMe( store
);
403 if ( mLayouts
[mActiveLayoutNo
] )
405 mLayouts
[mActiveLayoutNo
]->Activate();
408 void MyFrame::OnStore( wxCommandEvent
& event
)
410 wxIOStreamWrapper stm
;
411 stm
.CreateForOutput( "layouts_for_demo.dat" );
413 wxObjectStorage
store( stm
);
415 SerializeMe( store
);
417 mSavedAlready
= TRUE
;
420 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
422 mAutoSave
= !mAutoSave
;
430 void MyFrame::OnSettings( wxCommandEvent
& event
)
432 SettingsDlg
dlg( this );
434 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
436 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
441 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
444 dlg
.Center( wxBOTH
);
445 if ( dlg
.ShowModal() == wxID_APPLY
)
447 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
454 void MyFrame::OnRemove( wxCommandEvent
& event
)
456 RemoveLayout( mActiveLayoutNo
);
461 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
463 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
471 void MyFrame::OnRecreate( wxCommandEvent
& event
)
473 OnRemove( event
); // first destroy active layout
475 CreateLayout( mActiveLayoutNo
);
477 mLayouts
[mActiveLayoutNo
]->Activate();
480 void MyFrame::OnFirst( wxCommandEvent
& event
)
482 ActivateLayout( FIRST_LAYOUT
);
485 void MyFrame::OnSecond( wxCommandEvent
& event
)
487 ActivateLayout( SECOND_LAYOUT
);
490 void MyFrame::OnThird( wxCommandEvent
& event
)
492 ActivateLayout( THIRD_LAYOUT
);
495 void MyFrame::OnQuit( wxCommandEvent
& event
)
497 // USEFUL TRICK:: avoids flickering of application's frame
498 // when closing NN windows on exit:
502 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
512 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
514 // make controls in frame window look like in dialog
515 // by setting dialog's font to all controls
517 #ifdef __HACK_MY_MSDEV40__
519 wxNode
* pWNode
= pParent
->GetChildren()->First();
523 wxNode
* pWNode
= pParent
->GetChildren().First();
529 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
533 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
536 ((wxButton
*)(pWnd
))->SetDefault();
540 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
542 set_dlg_font( pWnd
, font
);
544 pWNode
= pWNode
->Next();
548 void MyFrame::OnAbout( wxCommandEvent
& event
)
552 font
.SetFaceName("MS Sans Serif");
554 font
.SetFamily( wxSWISS
);
559 font
.SetPointSize( 8 );
562 font
.RealizeResource();
565 mAboutBox
.Center( wxBOTH
);
566 mAboutBox
.Show(TRUE
);
568 set_dlg_font( &mAboutBox
, font
);
571 void MyFrame::OnChar( wxKeyEvent
& event
)
575 if ( event
.m_keyCode
== WXK_F1
)
577 this->OnFirst( evt
);
579 if ( event
.m_keyCode
== WXK_F2
)
581 this->OnSecond( evt
);
583 if ( event
.m_keyCode
== WXK_F3
)
585 this->OnThird( evt
);
586 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
589 wxMessageBox("There are only 3 layouts in this demo :-(");
591 if ( event
.m_keyCode
== WXK_TAB
)
593 // USEFUL TRICK:: avoids flickering of application's frame
594 // when closing NN windows on exit:
598 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
608 if ( event
.m_keyCode
== WXK_CONTROL
)
610 this->OnSettings( evt
);
615 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
617 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
620 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
622 mAboutBox
.Show(FALSE
);
625 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
627 mAboutBox
.Show(FALSE
);
630 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
632 mAboutBox
.Show(FALSE
);
635 /*** helper methods ***/
637 void MyFrame::InitAboutBox()
639 wxPanel
* pArea
= new wxPanel();
641 pArea
->Create( &mAboutBox
, -1 );
643 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
646 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
649 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
652 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
654 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
656 cbDimInfo
sizes( 90,40, // when docked horizontally
657 45,55, // when docked vertically
658 90,40, // when floated
659 TRUE
, 4, 4 // true - bar is fixed-size
663 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
664 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
665 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
667 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
668 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
669 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
671 layout
.mBorderPen
.SetColour( 192, 192, 192 );
672 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
674 cbCommonPaneProperties props
;
676 layout
.GetPaneProperties( props
, wxTOP
);
678 props
.mShow3DPaneBorderOn
= FALSE
;
680 layout
.SetPaneProperties( props
, wxALL_PANES
);
688 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
690 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
691 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
695 wxButton
* MyFrame::CreateButton( const wxString
& label
,
696 wxWindow
* pParent
, long id
)
698 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
699 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
702 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
704 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
706 int rootid
= pTree
->AppendItem( (long)0, label
, -1);
708 if ( label
[0] != 'X' )
710 pTree
->AppendItem(rootid
, "Leaf1", -1);
711 pTree
->AppendItem(rootid
, "Leaf2", -1);
715 pTree
->AppendItem(rootid
, "Scully", -1);
716 pTree
->AppendItem(rootid
, "Mulder", -1);
722 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
724 wxString choice_strings
[5];
726 choice_strings
[0] = txt
;
727 choice_strings
[1] = "Julian";
728 choice_strings
[2] = "Hattie";
729 choice_strings
[3] = "Ken";
730 choice_strings
[4] = "Dick";
732 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
733 wxDefaultSize
, 5, choice_strings
);
735 choice
->SetSelection(0);
740 static const char helloworld_src
[] =
742 "#include <iostream.h>\n\
746 cout << \"Hello World\";\n\
752 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
754 cbDimInfo
sizes2( 275,38, // when docked horizontally
755 45,275, // when docked vertically
756 80,30, // when floated
757 TRUE
, // the bar is fixed-size
758 4, // vertical gap (bar border)
759 4, // horizontal gap (bar border)
760 new cbDynToolBarDimHandler()
763 cbDimInfo
sizes3( 275,55, // when docked horizontally
764 275,60, // when docked vertically
765 45,130, // when floated
766 TRUE
, // the bar is fixed-size
767 4, // vertical gap (bar border)
768 4, // horizontal gap (bar border)
769 new cbDynToolBarDimHandler()
772 cbDimInfo
sizes4( 450,35, // when docked horizontally
773 44,375, // when docked vertically
774 80,100, // when floated
775 TRUE
, // the bar is fixed-size
776 4, // vertical gap (bar border)
777 4, // horizontal gap (bar border)
778 new cbDynToolBarDimHandler()
781 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
783 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
785 pTBar2
->AddTool( 1, pChoice
);
787 pTBar2
->AddTool( 2, wxBitmap("search_icon") );
788 //pTBar2->AddSeparator();
789 pTBar2
->AddTool( 3, wxBitmap("bookmarks_icon") );
790 pTBar2
->AddTool( 4, wxBitmap("nextmark_icon") );
791 pTBar2
->AddTool( 5, wxBitmap("prevmark_icon") );
793 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
795 pTBar3
->AddTool( 1, wxBitmap("open_icon"), " Open " );
796 pTBar3
->AddTool( 2, wxBitmap("save_icon"), " Save " );
797 pTBar3
->AddTool( 3, wxBitmap("saveall_icon"), " Save All " );
798 //pTBar3->AddSeparator();
799 pTBar3
->AddTool( 4, wxBitmap("cut_icon"), " Open " );
800 pTBar3
->AddTool( 5, wxBitmap("copy_icon"), " Copy " );
801 pTBar3
->AddTool( 6, wxBitmap("paste_icon")," Paste " );
803 pTBar3
->EnableTool( 2, FALSE
);
805 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
807 pTBar4
->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE
);
808 pTBar4
->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE
);
809 pTBar4
->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE
);
810 //pTBar4->AddSeparator();
811 pTBar4
->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE
);
813 pTBar4
->EnableTool( 4, FALSE
);
816 pTBar2
->AddTool( 2, search_xpm
);
817 //pTBar2->AddSeparator();
818 pTBar2
->AddTool( 3, bookmarks_xpm
);
819 pTBar2
->AddTool( 4, nextmark_xpm
);
820 pTBar2
->AddTool( 5, prevmark_xpm
);
822 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
824 pTBar3
->AddTool( 1, wxBitmap(open_xpm
), " Open " );
825 pTBar3
->AddTool( 2, wxBitmap(save_xpm
), " Save " );
826 pTBar3
->AddTool( 3, wxBitmap(saveall_xpm
), " Save All " );
827 //pTBar3->AddSeparator();
828 pTBar3
->AddTool( 4, wxBitmap(cut_xpm
), " Open " );
829 pTBar3
->AddTool( 5, wxBitmap(copy_xpm
), " Copy " );
830 pTBar3
->AddTool( 6, wxBitmap(paste_xpm
), " Paste " );
832 pTBar3
->EnableTool( 2, FALSE
);
834 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
836 pTBar4
->AddTool( 1, wxBitmap(bookmarks_xpm
), "Bookmarks ", TRUE
);
837 pTBar4
->AddTool( 2, wxBitmap(nextmark_xpm
), "Next bookmark ", TRUE
);
838 pTBar4
->AddTool( 3, wxBitmap(prevmark_xpm
), "Prev bookmark ", TRUE
);
839 //pTBar4->AddSeparator();
840 pTBar4
->AddTool( 4, wxBitmap(search_xpm
),"Search ", TRUE
);
842 pTBar4
->EnableTool( 4, FALSE
);
845 layout
.AddBar( pTBar2
,
853 layout
.AddBar( pTBar3
,
861 layout
.AddBar( pTBar4
,
870 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
872 bool isNested
= pParent
!= mpInternalFrm
;
874 // check if we're craeting nested layout
877 layout
.mBorderPen
.SetColour( 128,255,128 );
879 // if so, than make border smaller
880 for( int i
= 0; i
!= MAX_PANES
; ++i
)
882 cbDockPane
& pane
= *layout
.GetPane( i
);
885 pane
.mBottomMargin
= 5;
886 pane
.mLeftMargin
= 5;
887 pane
.mRightMargin
= 5;
892 int cbHeight
= ( isNested
) ? 50 : 150;
894 cbDimInfo
sizes4( cbWidth
,cbHeight
,
896 cbWidth
,cbHeight
, FALSE
);
901 cbDimInfo
sizes5( cbWidth
,cbHeight
,
903 cbWidth
,cbHeight
, TRUE
,
904 3, // vertical gap (bar border)
905 3 // horizontal gap (bar border)
908 // create "workplace" window in the third layout
910 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
912 pMiniTabArea
->Create( pParent
, -1 );
914 wxTreeCtrl
* pClassView
=
915 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
916 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
918 pClassView
->SetImageList( &mImageList
);
920 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
922 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
923 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
925 // functions from "wxinfo.h"
926 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
927 ::wxCreateSerializerInfoTree( pClassView
, serId
, 1 );
930 // (default arg anyway)
931 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap("class_icon"));
932 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") );
933 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap("file_icon") );
934 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap("help_icon") );
935 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
936 pMiniTabArea
), "HelloWorld", &wxBitmap("help_icon") );
938 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap(class_icon_xpm
));
939 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap(res_icon_xpm
) );
940 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap(file_icon_xpm
) );
941 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap(help_icon_xpm
) );
942 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
943 pMiniTabArea
), "HelloWorld", &wxBitmap(help_icon_xpm
) );
945 // now create "output" window
947 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
949 pTabbedArea
->Create( pParent
, -1 );
951 wxPanel
* pSheet3
= new wxPanel();
952 pSheet3
->Create( pTabbedArea
, -1 );
953 pSheet3
->Show(FALSE
);
955 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
956 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
958 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap("file_icon") );
960 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap(file_icon_xpm
) );
962 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
964 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
965 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
966 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
971 void MyFrame::DropInSomeBars( int layoutNo
)
973 /* create once... and forget! */
975 // setup dimension infos for various bar shapes
980 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
982 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
984 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
985 cbWidth
,cbHeight
, // when docked vertically
986 cbWidth
,cbHeight
, // when floated
987 TRUE
// true - bar is fixed-size
992 cbDimInfo
sizes1( cbWidth
,cbHeight
,
994 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
1000 cbDimInfo
sizes3( cbWidth
,cbHeight
,
1002 cbWidth
,cbHeight
, TRUE
); // -/-
1007 cbDimInfo
sizes4( cbWidth
,cbHeight
,
1009 cbWidth
,cbHeight
, FALSE
); // -/-
1014 cbDimInfo
sizes5( cbWidth
,cbHeight
,
1016 cbWidth
,cbHeight
, TRUE
,
1017 3, // vertical gap (bar border)
1018 3 // horizontal gap (bar border)
1022 if ( layoutNo
== FIRST_LAYOUT
)
1024 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
1026 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
1028 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
1030 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
1031 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
1032 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
1033 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
1034 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
1037 if ( layoutNo
== SECOND_LAYOUT
)
1039 // show off various wx-controls in the second layout
1041 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
1042 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
1043 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
1044 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
1045 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1046 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1047 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
1048 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
1049 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
1052 if ( layoutNo
== THIRD_LAYOUT
)
1056 cbCommonPaneProperties props
;
1057 layout
.GetPaneProperties( props
);
1058 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
1059 layout
.SetPaneProperties( props
, wxALL_PANES
);
1063 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
1064 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
1065 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
1066 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
1067 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
1068 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
1069 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
1071 cbDimInfo
sizes10(175,35, // when docked horizontally
1072 175,38, // when docked vertically
1073 170,35, // when floated
1074 TRUE
, // the bar is not fixed-size
1075 4, // vertical gap (bar border)
1076 4, // horizontal gap (bar border)
1077 new cbDynToolBarDimHandler()
1080 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
1082 pToolBar
->Create( mpInternalFrm
, -1 );
1084 // 1001-1006 ids of command events fired by added tool-buttons
1086 pToolBar
->AddTool( 1001, wxBitmap("new_icon") );
1087 pToolBar
->AddTool( 1002, wxBitmap("open_icon") );
1088 pToolBar
->AddTool( 1003, wxBitmap("save_icon") );
1090 pToolBar
->AddTool( 1004, wxBitmap("cut_icon") );
1091 pToolBar
->AddTool( 1005, wxBitmap("copy_icon") );
1092 pToolBar
->AddTool( 1006, wxBitmap("paste_icon") );
1094 pToolBar
->AddTool( 1001, wxBitmap(new_xpm
) );
1095 pToolBar
->AddTool( 1002, wxBitmap(open_xpm
) );
1096 pToolBar
->AddTool( 1003, wxBitmap(save_xpm
) );
1098 pToolBar
->AddTool( 1004, wxBitmap(cut_xpm
) );
1099 pToolBar
->AddTool( 1005, wxBitmap(copy_xpm
) );
1100 pToolBar
->AddTool( 1006, wxBitmap(paste_xpm
) );
1102 layout
.AddBar( pToolBar
, // bar window (can be NULL)
1103 sizes10
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
1104 0, // insert into 0th row (vert. position)
1105 0, // offset from the start of row (in pixels)
1106 "Real-Toolbar", // name to refere in customization pop-ups
1112 // create first "developement" layout
1114 AddSearchToolbars( layout
, mpInternalFrm
);
1116 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
1118 // create another ***secreat developement*** layout inside
1119 // the third sheet of the outter one's output bar
1123 new wxFrameLayout( pSheet3
,
1124 CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3
), FALSE
);
1126 CreateDevLayout( *mpNestedLayout
, pSheet3
);
1128 mpNestedLayout
->Activate();
1132 void MyFrame::CreateLayout( int layoutNo
)
1134 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
1136 if ( layoutNo
== THIRD_LAYOUT
)
1138 pLayout
->PushDefaultPlugins();
1139 pLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
1141 pLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
1143 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
1146 mLayouts
[layoutNo
] = pLayout
;
1148 DropInSomeBars( layoutNo
);
1151 void MyFrame::RemoveLayout( int layoutNo
)
1153 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
1155 if ( !pLayout
) return;
1157 pLayout
->HideBarWindows();
1159 // destroy nested layout first
1161 if ( layoutNo
== THIRD_LAYOUT
)
1163 if ( mpNestedLayout
) delete mpNestedLayout
;
1164 mpNestedLayout
= NULL
;
1167 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
1169 pLayout
->DestroyBarWindows();
1173 mLayouts
[layoutNo
] = NULL
;
1178 void MyFrame::DestroyEverything()
1180 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1186 mpClntWindow
->Destroy();
1188 mpClntWindow
= NULL
;
1192 void MyFrame::SyncMenuBarItems()
1194 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1196 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
1198 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
1201 void MyFrame::ActivateLayout( int layoutNo
)
1203 if ( layoutNo
== mActiveLayoutNo
) return;
1205 if ( mLayouts
[mActiveLayoutNo
] )
1207 mLayouts
[mActiveLayoutNo
]->Deactivate();
1209 mActiveLayoutNo
= layoutNo
;
1211 if ( mLayouts
[mActiveLayoutNo
] )
1213 mLayouts
[mActiveLayoutNo
]->Activate();
1220 void MyFrame::SerializeMe( wxObjectStorage
& store
)
1222 store
.AddInitialRef( this );
1223 store
.AddInitialRef( mpInternalFrm
);
1224 store
.AddInitialRef( &mAboutBox
);
1225 store
.AddInitialRef( &mImageList
);
1227 store
.XchgInt ( mActiveLayoutNo
);
1228 store
.XchgBool( mAutoSave
);
1230 store
.XchgObjPtr( (wxObject
**) &mpClntWindow
);
1232 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1234 if ( i
== THIRD_LAYOUT
)
1236 store
.XchgObjPtr( (wxObject
**) &(mpNestedLayout
) );
1238 store
.XchgObjPtr( (wxObject
**) &(mLayouts
[i
]) );
1241 store
.XchgObjPtr( (wxObject
**) &(mpAboutBoxLayout
) );
1243 store
.Finalize(); // finish serialization
1246 #ifdef __HACK_MY_MSDEV40__
1248 ////////////// new 2.0-magic (linker errors...) ////////////////
1250 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1252 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1253 "recreating toolbar in wxFrame" );
1255 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1258 SetToolBar(toolBar
);
1268 void foo( double& d
)
1273 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1277 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);