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
);
246 mdc
.SelectObject( *pBmp
);
248 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
250 mdc
.SelectObject( wxNullBitmap
);
253 /***** Implementation for class MyFrame *****/
255 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
257 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
258 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
260 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
261 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
262 EVT_MENU( ID_AUTOSAVE
, MyFrame::OnAutoSave
)
263 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
264 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
265 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
266 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
267 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
268 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
269 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
271 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
272 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
273 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
274 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
276 EVT_CHAR_HOOK( MyFrame::OnChar
)
280 // My frame constructor
282 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
284 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
285 mImageList( 16,16, FALSE
, 2 ),
286 mSavedAlready( FALSE
),
289 mpClntWindow( NULL
),
290 mpNestedLayout( NULL
),
291 mpAboutBoxLayout( NULL
),
292 mActiveLayoutNo( FIRST_LAYOUT
)
296 mpInternalFrm
= (wxPanel
*)this;
298 mpInternalFrm
= new wxPanel( this, -1 );
301 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
304 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
307 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
309 // image-list is one of the few objects which
310 // currently cannot be serialized, create it first
311 // and use it as initial reference (IR)
315 bmp1
.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
316 bmp2
.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE
);
318 bmp1
= wxBitmap( folder_icon_xpm
);
319 bmp2
= wxBitmap( class_icon1_xpm
);
321 int idx1
= mImageList
.Add( bmp1
);
322 int idx2
= mImageList
.Add( bmp2
);
324 // load configuation if present
326 if ( wxFileExists( "layouts_for_demo.dat" ) )
335 // create multiple layouts
339 mpClntWindow
= CreateTxtCtrl("client window");
341 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
345 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
348 mLayouts
[i
]->HideBarWindows();
350 // activate first one
352 mLayouts
[FIRST_LAYOUT
]->Activate();
354 mActiveLayoutNo
= FIRST_LAYOUT
;
358 /*** event handlers ***/
360 bool MyFrame::OnClose(void)
362 // USEFUL TRICK:: avoids flickering of application's frame
363 // when closing NN windows on exit:
368 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
381 void MyFrame::OnLoad( wxCommandEvent
& event
)
383 if ( !wxFileExists( "layouts_for_demo.dat" ) )
387 "File \"layouts_for_demo.dat\" was not found,\n select\
388 (File|Store Layouts) menu item to store layout information first"
395 wxIOStreamWrapper stm
;
396 stm
.CreateForInput( "layouts_for_demo.dat" );
398 wxObjectStorage
store( stm
);
400 SerializeMe( store
);
402 if ( mLayouts
[mActiveLayoutNo
] )
404 mLayouts
[mActiveLayoutNo
]->Activate();
407 void MyFrame::OnStore( wxCommandEvent
& event
)
409 wxIOStreamWrapper stm
;
410 stm
.CreateForOutput( "layouts_for_demo.dat" );
412 wxObjectStorage
store( stm
);
414 SerializeMe( store
);
416 mSavedAlready
= TRUE
;
419 void MyFrame::OnAutoSave( wxCommandEvent
& event
)
421 mAutoSave
= !mAutoSave
;
429 void MyFrame::OnSettings( wxCommandEvent
& event
)
431 SettingsDlg
dlg( this );
433 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
435 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
440 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
443 dlg
.Center( wxBOTH
);
444 if ( dlg
.ShowModal() == wxID_APPLY
)
446 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
453 void MyFrame::OnRemove( wxCommandEvent
& event
)
455 RemoveLayout( mActiveLayoutNo
);
460 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
462 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
470 void MyFrame::OnRecreate( wxCommandEvent
& event
)
472 OnRemove( event
); // first destroy active layout
474 CreateLayout( mActiveLayoutNo
);
476 mLayouts
[mActiveLayoutNo
]->Activate();
479 void MyFrame::OnFirst( wxCommandEvent
& event
)
481 ActivateLayout( FIRST_LAYOUT
);
484 void MyFrame::OnSecond( wxCommandEvent
& event
)
486 ActivateLayout( SECOND_LAYOUT
);
489 void MyFrame::OnThird( wxCommandEvent
& event
)
491 ActivateLayout( THIRD_LAYOUT
);
494 void MyFrame::OnQuit( wxCommandEvent
& event
)
496 // USEFUL TRICK:: avoids flickering of application's frame
497 // when closing NN windows on exit:
501 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
511 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
513 // make controls in frame window look like in dialog
514 // by setting dialog's font to all controls
516 #ifdef __HACK_MY_MSDEV40__
518 wxNode
* pWNode
= pParent
->GetChildren()->First();
522 wxNode
* pWNode
= pParent
->GetChildren().First();
528 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
532 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
535 ((wxButton
*)(pWnd
))->SetDefault();
539 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
541 set_dlg_font( pWnd
, font
);
543 pWNode
= pWNode
->Next();
547 void MyFrame::OnAbout( wxCommandEvent
& event
)
551 font
.SetFaceName("MS Sans Serif");
553 font
.SetFamily( wxSWISS
);
558 font
.SetPointSize( 8 );
561 font
.RealizeResource();
564 mAboutBox
.Center( wxBOTH
);
565 mAboutBox
.Show(TRUE
);
567 set_dlg_font( &mAboutBox
, font
);
570 void MyFrame::OnChar( wxKeyEvent
& event
)
574 if ( event
.m_keyCode
== WXK_F1
)
576 this->OnFirst( evt
);
578 if ( event
.m_keyCode
== WXK_F2
)
580 this->OnSecond( evt
);
582 if ( event
.m_keyCode
== WXK_F3
)
584 this->OnThird( evt
);
585 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
588 wxMessageBox("There are only 3 layouts in this demo :-(");
590 if ( event
.m_keyCode
== WXK_TAB
)
592 // USEFUL TRICK:: avoids flickering of application's frame
593 // when closing NN windows on exit:
597 if ( (mAutoSave
&& mSavedAlready
) || !mAutoSave
);
607 if ( event
.m_keyCode
== WXK_CONTROL
)
609 this->OnSettings( evt
);
614 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
616 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
619 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
621 mAboutBox
.Show(FALSE
);
624 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
626 mAboutBox
.Show(FALSE
);
629 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
631 mAboutBox
.Show(FALSE
);
634 /*** helper methods ***/
636 void MyFrame::InitAboutBox()
638 wxPanel
* pArea
= new wxPanel();
640 pArea
->Create( &mAboutBox
, -1 );
642 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
645 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
648 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
651 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
653 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
655 cbDimInfo
sizes( 90,40, // when docked horizontally
656 45,55, // when docked vertically
657 90,40, // when floated
658 TRUE
, 4, 4 // true - bar is fixed-size
662 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
663 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
664 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
666 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
667 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
668 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
670 layout
.mBorderPen
.SetColour( 192, 192, 192 );
671 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
673 cbCommonPaneProperties props
;
675 layout
.GetPaneProperties( props
, wxTOP
);
677 props
.mShow3DPaneBorderOn
= FALSE
;
679 layout
.SetPaneProperties( props
, wxALL_PANES
);
687 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
689 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
690 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
694 wxButton
* MyFrame::CreateButton( const wxString
& label
,
695 wxWindow
* pParent
, long id
)
697 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
698 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
701 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
703 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
705 int rootid
= pTree
->AppendItem( (long)0, label
, -1);
707 if ( label
[0] != 'X' )
709 pTree
->AppendItem(rootid
, "Leaf1", -1);
710 pTree
->AppendItem(rootid
, "Leaf2", -1);
714 pTree
->AppendItem(rootid
, "Scully", -1);
715 pTree
->AppendItem(rootid
, "Mulder", -1);
721 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
723 wxString choice_strings
[5];
725 choice_strings
[0] = txt
;
726 choice_strings
[1] = "Julian";
727 choice_strings
[2] = "Hattie";
728 choice_strings
[3] = "Ken";
729 choice_strings
[4] = "Dick";
731 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
732 wxDefaultSize
, 5, choice_strings
);
734 choice
->SetSelection(0);
739 static const char helloworld_src
[] =
741 "#include <iostream.h>\n\
745 cout << \"Hello World\";\n\
751 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
753 cbDimInfo
sizes2( 275,38, // when docked horizontally
754 45,275, // when docked vertically
755 80,30, // 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 cbDimInfo
sizes3( 275,55, // when docked horizontally
763 275,60, // when docked vertically
764 45,130, // when floated
765 TRUE
, // the bar is fixed-size
766 4, // vertical gap (bar border)
767 4, // horizontal gap (bar border)
768 new cbDynToolBarDimHandler()
771 cbDimInfo
sizes4( 430,35, // when docked horizontally
772 44,375, // when docked vertically
773 80,100, // when floated
774 TRUE
, // the bar is fixed-size
775 4, // vertical gap (bar border)
776 4, // horizontal gap (bar border)
777 new cbDynToolBarDimHandler()
780 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
782 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
784 pTBar2
->AddTool( 1, pChoice
);
786 pTBar2
->AddTool( 2, wxBitmap("search_icon") );
787 //pTBar2->AddSeparator();
788 pTBar2
->AddTool( 3, wxBitmap("bookmarks_icon") );
789 pTBar2
->AddTool( 4, wxBitmap("nextmark_icon") );
790 pTBar2
->AddTool( 5, wxBitmap("prevmark_icon") );
794 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
796 pTBar3
->AddTool( 1, wxBitmap("open_icon"), " Open " );
797 pTBar3
->AddTool( 2, wxBitmap("save_icon"), " Save " );
798 pTBar3
->AddTool( 3, wxBitmap("saveall_icon"), " Save All " );
799 //pTBar3->AddSeparator();
800 pTBar3
->AddTool( 4, wxBitmap("cut_icon"), " Open " );
801 pTBar3
->AddTool( 5, wxBitmap("copy_icon"), " Copy " );
802 pTBar3
->AddTool( 6, wxBitmap("paste_icon")," Paste " );
804 pTBar3
->EnableTool( 2, FALSE
);
806 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
808 pTBar4
->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE
);
809 pTBar4
->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE
);
810 pTBar4
->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE
);
811 //pTBar4->AddSeparator();
812 pTBar4
->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE
);
814 pTBar4
->EnableTool( 4, FALSE
);
817 pTBar2
->AddTool( 2, search_xpm
);
818 //pTBar2->AddSeparator();
819 pTBar2
->AddTool( 3, bookmarks_xpm
);
820 pTBar2
->AddTool( 4, nextmark_xpm
);
821 pTBar2
->AddTool( 5, prevmark_xpm
);
824 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
826 pTBar3
->AddTool( 1, wxBitmap(open_xpm
), " Open " );
827 pTBar3
->AddTool( 2, wxBitmap(save_xpm
), " Save " );
828 pTBar3
->AddTool( 3, wxBitmap(saveall_xpm
), " Save All " );
829 //pTBar3->AddSeparator();
830 pTBar3
->AddTool( 4, wxBitmap(cut_xpm
), " Open " );
831 pTBar3
->AddTool( 5, wxBitmap(copy_xpm
), " Copy " );
832 pTBar3
->AddTool( 6, wxBitmap(paste_xpm
), " Paste " );
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
);
843 layout
.AddBar( pTBar2
,
851 layout
.AddBar( pTBar3
,
859 layout
.AddBar( pTBar4
,
868 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
870 bool isNested
= pParent
!= mpInternalFrm
;
872 // check if we're craeting nested layout
875 layout
.mBorderPen
.SetColour( 128,255,128 );
877 // if so, than make border smaller
878 for( int i
= 0; i
!= MAX_PANES
; ++i
)
880 cbDockPane
& pane
= *layout
.GetPane( i
);
883 pane
.mBottomMargin
= 5;
884 pane
.mLeftMargin
= 5;
885 pane
.mRightMargin
= 5;
890 int cbHeight
= ( isNested
) ? 50 : 150;
892 cbDimInfo
sizes4( cbWidth
,cbHeight
,
894 cbWidth
,cbHeight
, FALSE
);
899 cbDimInfo
sizes5( cbWidth
,cbHeight
,
901 cbWidth
,cbHeight
, TRUE
,
902 3, // vertical gap (bar border)
903 3 // horizontal gap (bar border)
906 // create "workplace" window in the third layout
908 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
910 pMiniTabArea
->Create( pParent
, -1 );
912 wxTreeCtrl
* pClassView
=
913 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
914 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
916 pClassView
->SetImageList( &mImageList
);
918 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
920 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
921 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
923 // functions from "wxinfo.h"
924 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
925 ::wxCreateSerializerInfoTree( pClassView
, serId
, 1 );
928 // (default arg anyway)
929 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap("class_icon"));
930 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") );
931 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap("file_icon") );
932 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap("help_icon") );
933 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
934 pMiniTabArea
), "HelloWorld", &wxBitmap("help_icon") );
936 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap(class_icon_xpm
));
937 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap(res_icon_xpm
) );
938 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap(file_icon_xpm
) );
939 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap(help_icon_xpm
) );
940 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
941 pMiniTabArea
), "HelloWorld", &wxBitmap(help_icon_xpm
) );
943 // now create "output" window
945 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
947 pTabbedArea
->Create( pParent
, -1 );
949 wxPanel
* pSheet3
= new wxPanel();
950 pSheet3
->Create( pTabbedArea
, -1 );
951 pSheet3
->Show(FALSE
);
953 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
954 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
956 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap("file_icon") );
958 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap(file_icon_xpm
) );
960 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
962 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
963 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
964 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
969 void MyFrame::DropInSomeBars( int layoutNo
)
971 /* create once... and forget! */
973 // setup dimension infos for various bar shapes
978 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
980 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
982 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
983 cbWidth
,cbHeight
, // when docked vertically
984 cbWidth
,cbHeight
, // when floated
985 TRUE
// true - bar is fixed-size
990 cbDimInfo
sizes1( cbWidth
,cbHeight
,
992 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
998 cbDimInfo
sizes3( cbWidth
,cbHeight
,
1000 cbWidth
,cbHeight
, TRUE
); // -/-
1005 cbDimInfo
sizes4( cbWidth
,cbHeight
,
1007 cbWidth
,cbHeight
, FALSE
); // -/-
1012 cbDimInfo
sizes5( cbWidth
,cbHeight
,
1014 cbWidth
,cbHeight
, TRUE
,
1015 3, // vertical gap (bar border)
1016 3 // horizontal gap (bar border)
1020 if ( layoutNo
== FIRST_LAYOUT
)
1022 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
1024 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
1026 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
1028 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
1029 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
1030 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
1031 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
1032 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
1035 if ( layoutNo
== SECOND_LAYOUT
)
1037 // show off various wx-controls in the second layout
1039 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
1040 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
1041 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
1042 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
1043 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1044 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
1045 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
1046 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
1047 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
1050 if ( layoutNo
== THIRD_LAYOUT
)
1054 cbCommonPaneProperties props
;
1055 layout
.GetPaneProperties( props
);
1056 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
1057 layout
.SetPaneProperties( props
, wxALL_PANES
);
1061 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
1062 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
1063 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
1064 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
1065 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
1066 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
1067 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
1069 cbDimInfo
sizes10(175,35, // when docked horizontally
1070 175,38, // when docked vertically
1071 170,35, // when floated
1072 TRUE
, // the bar is not fixed-size
1073 4, // vertical gap (bar border)
1074 4, // horizontal gap (bar border)
1075 new cbDynToolBarDimHandler()
1078 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
1080 pToolBar
->Create( mpInternalFrm
, -1 );
1082 // 1001-1006 ids of command events fired by added tool-buttons
1084 pToolBar
->AddTool( 1001, wxBitmap("new_icon") );
1085 pToolBar
->AddTool( 1002, wxBitmap("open_icon") );
1086 pToolBar
->AddTool( 1003, wxBitmap("save_icon") );
1088 pToolBar
->AddTool( 1004, wxBitmap("cut_icon") );
1089 pToolBar
->AddTool( 1005, wxBitmap("copy_icon") );
1090 pToolBar
->AddTool( 1006, wxBitmap("paste_icon") );
1092 pToolBar
->AddTool( 1001, wxBitmap(new_xpm
) );
1093 pToolBar
->AddTool( 1002, wxBitmap(open_xpm
) );
1094 pToolBar
->AddTool( 1003, wxBitmap(save_xpm
) );
1096 pToolBar
->AddTool( 1004, wxBitmap(cut_xpm
) );
1097 pToolBar
->AddTool( 1005, wxBitmap(copy_xpm
) );
1098 pToolBar
->AddTool( 1006, wxBitmap(paste_xpm
) );
1100 layout
.AddBar( pToolBar
, // bar window (can be NULL)
1101 sizes10
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
1102 0, // insert into 0th row (vert. position)
1103 0, // offset from the start of row (in pixels)
1104 "Real-Toolbar", // name to refere in customization pop-ups
1110 // create first "developement" layout
1112 AddSearchToolbars( layout
, mpInternalFrm
);
1114 wxWindow
* pSheet3
= CreateDevLayout( layout
, mpInternalFrm
);
1116 // create another ***secreat developement*** layout inside
1117 // the third sheet of the outter one's output bar
1121 new wxFrameLayout( pSheet3
,
1122 CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3
), FALSE
);
1124 CreateDevLayout( *mpNestedLayout
, pSheet3
);
1126 mpNestedLayout
->Activate();
1130 void MyFrame::CreateLayout( int layoutNo
)
1132 wxFrameLayout
* pLayout
= new wxFrameLayout( mpInternalFrm
, mpClntWindow
, FALSE
);
1134 if ( layoutNo
== THIRD_LAYOUT
)
1136 pLayout
->PushDefaultPlugins();
1137 pLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
1139 pLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
1141 pLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
1144 mLayouts
[layoutNo
] = pLayout
;
1146 DropInSomeBars( layoutNo
);
1149 void MyFrame::RemoveLayout( int layoutNo
)
1151 wxFrameLayout
* pLayout
= mLayouts
[layoutNo
];
1153 if ( !pLayout
) return;
1155 pLayout
->HideBarWindows();
1157 // destroy nested layout first
1159 if ( layoutNo
== THIRD_LAYOUT
)
1161 if ( mpNestedLayout
) delete mpNestedLayout
;
1162 mpNestedLayout
= NULL
;
1165 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
1167 pLayout
->DestroyBarWindows();
1171 mLayouts
[layoutNo
] = NULL
;
1176 void MyFrame::DestroyEverything()
1178 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1184 mpClntWindow
->Destroy();
1186 mpClntWindow
= NULL
;
1190 void MyFrame::SyncMenuBarItems()
1192 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1194 GetMenuBar()->Check( ID_FIRST
+i
, mActiveLayoutNo
== FIRST_LAYOUT
+i
);
1196 GetMenuBar()->Check( ID_AUTOSAVE
, mAutoSave
);
1199 void MyFrame::ActivateLayout( int layoutNo
)
1201 if ( layoutNo
== mActiveLayoutNo
) return;
1203 if ( mLayouts
[mActiveLayoutNo
] )
1205 mLayouts
[mActiveLayoutNo
]->Deactivate();
1207 mActiveLayoutNo
= layoutNo
;
1209 if ( mLayouts
[mActiveLayoutNo
] )
1211 mLayouts
[mActiveLayoutNo
]->Activate();
1218 void MyFrame::SerializeMe( wxObjectStorage
& store
)
1220 store
.AddInitialRef( this );
1221 store
.AddInitialRef( mpInternalFrm
);
1222 store
.AddInitialRef( &mAboutBox
);
1223 store
.AddInitialRef( &mImageList
);
1225 store
.XchgInt ( mActiveLayoutNo
);
1226 store
.XchgBool( mAutoSave
);
1228 store
.XchgObjPtr( (wxObject
**) &mpClntWindow
);
1230 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
1232 if ( i
== THIRD_LAYOUT
)
1234 store
.XchgObjPtr( (wxObject
**) &(mpNestedLayout
) );
1236 store
.XchgObjPtr( (wxObject
**) &(mLayouts
[i
]) );
1239 store
.XchgObjPtr( (wxObject
**) &(mpAboutBoxLayout
) );
1241 store
.Finalize(); // finish serialization
1244 #ifdef __HACK_MY_MSDEV40__
1246 ////////////// new 2.0-magic (linker errors...) ////////////////
1248 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1250 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1251 "recreating toolbar in wxFrame" );
1253 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1256 SetToolBar(toolBar
);
1266 void foo( double& d
)
1271 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1275 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);