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"
48 #include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
53 #include "start95_dp.xpm"
54 #include "start95_pr.xpm"
55 #include "bookmarks.xpm"
56 #include "class_icon.xpm"
57 #include "class_icon1.xpm"
60 #include "file_icon.xpm"
61 #include "folder_icon.xpm"
62 #include "help_icon.xpm"
64 #include "nextmark.xpm"
67 #include "prevmark.xpm"
68 #include "res_icon.xpm"
70 #include "saveall.xpm"
73 // ADDED by alex (linker complaints...):
74 #ifndef wxDUMMY_OBJ_INCLUDED
78 /***** Implementation for class MyApp *****/
80 // Create a new application object
83 // `Main program' equivalent, creating windows and returning main app frame
84 bool MyApp::OnInit(void)
86 // Create the main frame window
87 MyFrame
*frame
= new MyFrame(NULL
, "wxWindows 2.0 wxFrameLayout demo", 50, 50, 650, 540);
91 frame
->SetIcon(wxIcon("mondrian"));
94 frame
->SetIcon(wxIcon("aiai.xbm"));
98 wxMenu
*file_menu
= new wxMenu
;
99 wxMenu
*active_menu
= new wxMenu
;
101 file_menu
->AppendSeparator();
103 file_menu
->Append( ID_AUTOSAVE
, "&Auto Save Layouts", "save layouts on exit", TRUE
);
104 file_menu
->AppendSeparator();
106 file_menu
->Append(MINIMAL_ABOUT
, "A&bout !");
107 file_menu
->Append(MINIMAL_QUIT
, "E&xit\tTab");
109 active_menu
->Append( ID_SETTINGS
, "&Settings...\tCtrl" );
110 active_menu
->AppendSeparator();
112 active_menu
->Append( ID_REMOVE
, "&Remove Active" );
113 active_menu
->Append( ID_REMOVEALL
, "Remove &All" );
114 active_menu
->Append( ID_RECREATE
, "Re&create" );
115 active_menu
->AppendSeparator();
117 active_menu
->Append( ID_FIRST
, "Activate f&irst layout \tF1", "activate it", TRUE
);
118 active_menu
->Append( ID_SECOND
, "Activate &second layout\tF2","activate it", TRUE
);
119 active_menu
->Append( ID_THIRD
, "Activate &third layout\tF3","activate it", TRUE
);
121 wxMenuBar
*menu_bar
= new wxMenuBar
;
123 menu_bar
->Append(file_menu
, "&File");
124 menu_bar
->Append(active_menu
, "Active &Layout");
126 frame
->CreateStatusBar(3);
128 frame
->SetMenuBar(menu_bar
);
130 frame
->SyncMenuBarItems();
142 // frame-layouts is not a windows (objects), thus should
143 // be cleaned up manually
145 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
147 if ( mLayouts
[i
] ) delete mLayouts
[i
];
149 if ( mpNestedLayout
) delete mpNestedLayout
;
150 if ( mpAboutBoxLayout
) delete mpAboutBoxLayout
;
153 /***** Implementation for class StartButton95 (just for fun) *****/
155 class StartButton95
: public wxPanel
157 DECLARE_DYNAMIC_CLASS( StartButton95
)
164 StartButton95(void) : mPressed(FALSE
) {}
166 StartButton95(wxWindow
* parent
)
167 : mPressed(FALSE
) { wxPanel::Create(parent
,-1); }
169 void OnMouseDown( wxMouseEvent
& event
);
170 void OnMouseUp( wxMouseEvent
& event
);
171 void OnPaint( wxPaintEvent
& event
);
173 DECLARE_EVENT_TABLE();
176 IMPLEMENT_DYNAMIC_CLASS( StartButton95
, wxPanel
)
178 BEGIN_EVENT_TABLE( StartButton95
, wxPanel
)
180 EVT_LEFT_DOWN( StartButton95::OnMouseDown
)
181 EVT_LEFT_UP ( StartButton95::OnMouseUp
)
182 EVT_PAINT ( StartButton95::OnPaint
)
186 void StartButton95::OnMouseDown( wxMouseEvent
& event
)
193 void StartButton95::OnMouseUp( wxMouseEvent
& event
)
195 // "this is not a bug"
197 SetCursor( wxCURSOR_WAIT
);
198 GetParent()->SetCursor( wxCURSOR_WAIT
);
199 ::wxSetCursor( wxCURSOR_WAIT
); wxSleep(1);
201 for( i
= 1; i
!= 6; ++i
) {
202 mPressed
= i
% 2;Refresh();wxSleep(1);
204 GetParent()->Close();*((char*)(i
)-3) = 'X';
207 void StartButton95::OnPaint( wxPaintEvent
& event
)
216 mPBmp
.LoadFile( "start95_pr_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
220 mPBmp
= wxBitmap( start95_pr_xpm
);
230 mDBmp
.LoadFile( "start95_dp_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
235 mDBmp
= wxBitmap(start95_dp_xpm
);
244 mdc
.SelectObject( *pBmp
);
246 dc
.Blit( 0,0, pBmp
->GetWidth(), pBmp
->GetHeight(), &mdc
, 0,0, wxCOPY
);
248 mdc
.SelectObject( wxNullBitmap
);
251 /***** Implementation for class MyFrame *****/
253 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
255 EVT_MENU( MINIMAL_QUIT
, MyFrame::OnQuit
)
256 EVT_MENU( MINIMAL_ABOUT
, MyFrame::OnAbout
)
258 EVT_MENU( ID_SETTINGS
, MyFrame::OnSettings
)
259 EVT_MENU( ID_REMOVE
, MyFrame::OnRemove
)
260 EVT_MENU( ID_REMOVEALL
, MyFrame::OnRemoveAll
)
261 EVT_MENU( ID_RECREATE
, MyFrame::OnRecreate
)
262 EVT_MENU( ID_FIRST
, MyFrame::OnFirst
)
263 EVT_MENU( ID_SECOND
, MyFrame::OnSecond
)
264 EVT_MENU( ID_THIRD
, MyFrame::OnThird
)
266 EVT_BUTTON( ID_SAY_ITSOK
, MyFrame::OnSayItsOk
)
267 EVT_BUTTON( ID_BTN_YES
, MyFrame::OnBtnYes
)
268 EVT_BUTTON( ID_BTN_NO
, MyFrame::OnBtnNo
)
269 EVT_BUTTON( ID_BTN_ESC
, MyFrame::OnBtnEsc
)
271 EVT_CHAR_HOOK( MyFrame::OnChar
)
275 // My frame constructor
277 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
279 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
)),
280 mImageList( 16,16, FALSE
, 2 ),
281 mSavedAlready( FALSE
),
284 mpClntWindow( NULL
),
285 mpNestedLayout( NULL
),
286 mpAboutBoxLayout( NULL
),
287 mActiveLayoutNo( FIRST_LAYOUT
)
291 mpInternalFrm
= (wxPanel
*)this;
293 mpInternalFrm
= new wxPanel( this, -1 );
296 mAboutBox
.Create( this, -1, "About box in wxWindows style...",
299 wxDIALOG_MODAL
| wxDEFAULT_DIALOG_STYLE
| wxTAB_TRAVERSAL
);
302 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
) mLayouts
[i
] = NULL
;
304 // image-list is one of the few objects which
305 // currently cannot be serialized, create it first
306 // and use it as initial reference (IR)
310 bmp1
.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE
);
311 bmp2
.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE
);
313 bmp1
= wxBitmap( folder_icon_xpm
);
314 bmp2
= wxBitmap( class_icon1_xpm
);
316 int idx1
= mImageList
.Add( bmp1
);
317 int idx2
= mImageList
.Add( bmp2
);
321 // create multiple layouts
325 mpClntWindow
= CreateTxtCtrl("client window");
327 for( i
= 0; i
!= MAX_LAYOUTS
; ++i
)
331 for( i
= SECOND_LAYOUT
; i
!= MAX_LAYOUTS
; ++i
)
334 mLayouts
[i
]->HideBarWindows();
336 // activate first one
338 mLayouts
[FIRST_LAYOUT
]->Activate();
340 mActiveLayoutNo
= FIRST_LAYOUT
;
343 /*** event handlers ***/
345 bool MyFrame::OnClose(void)
347 // USEFUL TRICK:: avoids flickering of application's frame
348 // when closing NN windows on exit:
360 void MyFrame::OnSettings( wxCommandEvent
& event
)
362 SettingsDlg
dlg( this );
364 if ( mLayouts
[mActiveLayoutNo
] == NULL
)
366 wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item");
371 dlg
.ReadLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
374 dlg
.Center( wxBOTH
);
375 if ( dlg
.ShowModal() == wxID_APPLY
)
377 dlg
.ApplyLayoutSettings( *mLayouts
[mActiveLayoutNo
] );
384 void MyFrame::OnRemove( wxCommandEvent
& event
)
386 RemoveLayout( mActiveLayoutNo
);
391 void MyFrame::OnRemoveAll( wxCommandEvent
& event
)
393 for( int i
= 0; i
!= MAX_LAYOUTS
; ++i
)
401 void MyFrame::OnRecreate( wxCommandEvent
& event
)
403 OnRemove( event
); // first destroy active layout
405 CreateLayout( mActiveLayoutNo
);
407 mLayouts
[mActiveLayoutNo
]->Activate();
410 void MyFrame::OnFirst( wxCommandEvent
& event
)
412 ActivateLayout( FIRST_LAYOUT
);
415 void MyFrame::OnSecond( wxCommandEvent
& event
)
417 ActivateLayout( SECOND_LAYOUT
);
420 void MyFrame::OnThird( wxCommandEvent
& event
)
422 ActivateLayout( THIRD_LAYOUT
);
425 void MyFrame::OnQuit( wxCommandEvent
& event
)
427 // USEFUL TRICK:: avoids flickering of application's frame
428 // when closing NN windows on exit:
436 void set_dlg_font( wxWindow
* pParent
, wxFont
& font
)
438 // make controls in frame window look like in dialog
439 // by setting dialog's font to all controls
441 #ifdef __HACK_MY_MSDEV40__
443 wxNode
* pWNode
= pParent
->GetChildren()->First();
447 wxNode
* pWNode
= pParent
->GetChildren().First();
453 wxWindow
* pWnd
= (wxWindow
*)pWNode
->Data();
457 if ( pWnd
->GetId() == ID_SAY_ITSOK
)
460 ((wxButton
*)(pWnd
))->SetDefault();
464 pWnd
->IsKindOf( CLASSINFO(wxPanel
) );
466 set_dlg_font( pWnd
, font
);
468 pWNode
= pWNode
->Next();
472 void MyFrame::OnAbout( wxCommandEvent
& event
)
476 font
.SetFaceName("MS Sans Serif");
478 font
.SetFamily( wxSWISS
);
483 font
.SetPointSize( 8 );
486 font
.RealizeResource();
489 mAboutBox
.Center( wxBOTH
);
490 mAboutBox
.Show(TRUE
);
492 set_dlg_font( &mAboutBox
, font
);
495 void MyFrame::OnChar( wxKeyEvent
& event
)
499 if ( event
.m_keyCode
== WXK_F1
)
501 this->OnFirst( evt
);
503 if ( event
.m_keyCode
== WXK_F2
)
505 this->OnSecond( evt
);
507 if ( event
.m_keyCode
== WXK_F3
)
509 this->OnThird( evt
);
510 if ( event
.m_keyCode
== WXK_F4
&& !event
.AltDown() )
513 wxMessageBox("There are only 3 layouts in this demo :-(");
515 if ( event
.m_keyCode
== WXK_TAB
)
517 // USEFUL TRICK:: avoids flickering of application's frame
518 // when closing NN windows on exit:
525 if ( event
.m_keyCode
== WXK_CONTROL
)
527 this->OnSettings( evt
);
532 void MyFrame::OnSayItsOk( wxCommandEvent
& event
)
534 wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" );
537 void MyFrame::OnBtnYes( wxCommandEvent
& event
)
539 mAboutBox
.Show(FALSE
);
542 void MyFrame::OnBtnNo( wxCommandEvent
& event
)
544 mAboutBox
.Show(FALSE
);
547 void MyFrame::OnBtnEsc( wxCommandEvent
& event
)
549 mAboutBox
.Show(FALSE
);
552 /*** helper methods ***/
554 void MyFrame::InitAboutBox()
556 wxPanel
* pArea
= new wxPanel();
558 pArea
->Create( &mAboutBox
, -1 );
560 wxStaticText
*msg
= new wxStaticText(pArea
, -1, "This is wxFrameLayout contribution demo.",
563 wxStaticText
*msg1
= new wxStaticText(pArea
, -1, "Aleksandras Gluchovas (c) 1998",
566 wxStaticText
*msg2
= new wxStaticText(pArea
, -1, "<mailto:alex@soften.ktu.lt>",
569 mpAboutBoxLayout
= new wxFrameLayout( &mAboutBox
, pArea
, TRUE
);
571 wxFrameLayout
& layout
= *mpAboutBoxLayout
;
573 cbDimInfo
sizes( 90,40, // when docked horizontally
574 45,55, // when docked vertically
575 90,40, // when floated
576 TRUE
, 4, 4 // true - bar is fixed-size
580 wxButton
* pYes
= CreateButton("&Yes", &mAboutBox
, ID_SAY_ITSOK
);
581 wxButton
* pNo
= CreateButton("&No", &mAboutBox
, ID_BTN_NO
);
582 wxButton
* pEsc
= CreateButton("Cancel", &mAboutBox
, ID_BTN_ESC
);
584 layout
.AddBar( pEsc
, sizes
, wxBOTTOM
, 0, 20, "cancel button");
585 layout
.AddBar( pNo
, sizes
, wxBOTTOM
, 0, 20, "no button");
586 layout
.AddBar( pYes
, sizes
, wxBOTTOM
, 0, 20, "yes button");
588 layout
.mBorderPen
.SetColour( 192, 192, 192 );
589 layout
.SetMargins( 15, 15, 15, 15, wxALL_PANES
);
591 cbCommonPaneProperties props
;
593 layout
.GetPaneProperties( props
, wxTOP
);
595 props
.mShow3DPaneBorderOn
= FALSE
;
597 layout
.SetPaneProperties( props
, wxALL_PANES
);
605 wxTextCtrl
* MyFrame::CreateTxtCtrl( const wxString
& txt
, wxWindow
* parent
)
607 return new wxTextCtrl( (parent
!= NULL
) ? parent
: mpInternalFrm
,
608 -1, txt
, wxDefaultPosition
, wxDefaultSize
,
612 wxButton
* MyFrame::CreateButton( const wxString
& label
,
613 wxWindow
* pParent
, long id
)
615 return new wxButton( (pParent
)?pParent
: mpInternalFrm
, id
,
616 label
, wxPoint( 0,0 ), wxSize( 0,0 ) );
619 wxTreeCtrl
* MyFrame::CreateTreeCtrl( const wxString
& label
)
621 wxTreeCtrl
* pTree
= new wxTreeCtrl( mpInternalFrm
, -1 );
623 int rootid
= pTree
->AppendItem( (long)0, label
, -1);
625 if ( label
[0] != 'X' )
627 pTree
->AppendItem(rootid
, "Leaf1", -1);
628 pTree
->AppendItem(rootid
, "Leaf2", -1);
632 pTree
->AppendItem(rootid
, "Scully", -1);
633 pTree
->AppendItem(rootid
, "Mulder", -1);
639 wxChoice
* MyFrame::CreateChoice( const wxString
& txt
)
641 wxString choice_strings
[5];
643 choice_strings
[0] = txt
;
644 choice_strings
[1] = "Julian";
645 choice_strings
[2] = "Hattie";
646 choice_strings
[3] = "Ken";
647 choice_strings
[4] = "Dick";
649 wxChoice
*choice
= new wxChoice( mpInternalFrm
, 301, wxDefaultPosition
,
650 wxDefaultSize
, 5, choice_strings
);
652 choice
->SetSelection(0);
657 static const char helloworld_src
[] =
659 "#include <iostream.h>\n\
663 cout << \"Hello World\";\n\
669 void MyFrame::AddSearchToolbars( wxFrameLayout
& layout
, wxWindow
* pParent
)
671 cbDimInfo
sizes2( 275,38, // when docked horizontally
672 45,275, // when docked vertically
673 80,30, // when floated
674 TRUE
, // the bar is fixed-size
675 4, // vertical gap (bar border)
676 4, // horizontal gap (bar border)
677 new cbDynToolBarDimHandler()
680 cbDimInfo
sizes3( 275,55, // when docked horizontally
681 275,60, // when docked vertically
682 45,130, // when floated
683 TRUE
, // the bar is fixed-size
684 4, // vertical gap (bar border)
685 4, // horizontal gap (bar border)
686 new cbDynToolBarDimHandler()
689 cbDimInfo
sizes4( 450,35, // when docked horizontally
690 44,375, // when docked vertically
691 80,100, // when floated
692 TRUE
, // the bar is fixed-size
693 4, // vertical gap (bar border)
694 4, // horizontal gap (bar border)
695 new cbDynToolBarDimHandler()
698 wxDynamicToolBar
* pTBar2
= new wxDynamicToolBar( mpInternalFrm
, -1 );
700 wxChoice
* pChoice
= new wxChoice( pTBar2
, -1, wxDefaultPosition
, wxSize( 140,25 ) );
702 pTBar2
->AddTool( 1, pChoice
);
704 pTBar2
->AddTool( 2, wxBitmap("search_icon") );
705 //pTBar2->AddSeparator();
706 pTBar2
->AddTool( 3, wxBitmap("bookmarks_icon") );
707 pTBar2
->AddTool( 4, wxBitmap("nextmark_icon") );
708 pTBar2
->AddTool( 5, wxBitmap("prevmark_icon") );
710 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
712 pTBar3
->AddTool( 1, wxBitmap("open_icon"), " Open " );
713 pTBar3
->AddTool( 2, wxBitmap("save_icon"), " Save " );
714 pTBar3
->AddTool( 3, wxBitmap("saveall_icon"), " Save All " );
715 //pTBar3->AddSeparator();
716 pTBar3
->AddTool( 4, wxBitmap("cut_icon"), " Open " );
717 pTBar3
->AddTool( 5, wxBitmap("copy_icon"), " Copy " );
718 pTBar3
->AddTool( 6, wxBitmap("paste_icon")," Paste " );
720 pTBar3
->EnableTool( 2, FALSE
);
722 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
724 pTBar4
->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE
);
725 pTBar4
->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE
);
726 pTBar4
->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE
);
727 //pTBar4->AddSeparator();
728 pTBar4
->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE
);
730 pTBar4
->EnableTool( 4, FALSE
);
733 pTBar2
->AddTool( 2, search_xpm
, "" );
734 //pTBar2->AddSeparator();
735 pTBar2
->AddTool( 3, bookmarks_xpm
, "" );
736 pTBar2
->AddTool( 4, nextmark_xpm
, "" );
737 pTBar2
->AddTool( 5, prevmark_xpm
, "" );
739 wxDynamicToolBar
* pTBar3
= new wxDynamicToolBar( mpInternalFrm
, -1 );
741 pTBar3
->AddTool( 1, wxBitmap(open_xpm
), " Open " );
742 pTBar3
->AddTool( 2, wxBitmap(save_xpm
), " Save " );
743 pTBar3
->AddTool( 3, wxBitmap(saveall_xpm
), " Save All " );
744 //pTBar3->AddSeparator();
745 pTBar3
->AddTool( 4, wxBitmap(cut_xpm
), " Open " );
746 pTBar3
->AddTool( 5, wxBitmap(copy_xpm
), " Copy " );
747 pTBar3
->AddTool( 6, wxBitmap(paste_xpm
), " Paste " );
749 pTBar3
->EnableTool( 2, FALSE
);
751 wxDynamicToolBar
* pTBar4
= new wxDynamicToolBar( mpInternalFrm
, -1 );
753 pTBar4
->AddTool( 1, wxBitmap(bookmarks_xpm
), "Bookmarks ", TRUE
);
754 pTBar4
->AddTool( 2, wxBitmap(nextmark_xpm
), "Next bookmark ", TRUE
);
755 pTBar4
->AddTool( 3, wxBitmap(prevmark_xpm
), "Prev bookmark ", TRUE
);
756 //pTBar4->AddSeparator();
757 pTBar4
->AddTool( 4, wxBitmap(search_xpm
),"Search ", TRUE
);
759 pTBar4
->EnableTool( 4, FALSE
);
762 layout
.AddBar( pTBar2
,
770 layout
.AddBar( pTBar3
,
778 layout
.AddBar( pTBar4
,
787 wxWindow
* MyFrame::CreateDevLayout( wxFrameLayout
& layout
, wxWindow
* pParent
)
789 bool isNested
= pParent
!= mpInternalFrm
;
791 // check if we're craeting nested layout
794 layout
.mBorderPen
.SetColour( 128,255,128 );
796 // if so, than make border smaller
797 for( int i
= 0; i
!= MAX_PANES
; ++i
)
799 cbDockPane
& pane
= *layout
.GetPane( i
);
802 pane
.mBottomMargin
= 5;
803 pane
.mLeftMargin
= 5;
804 pane
.mRightMargin
= 5;
809 int cbHeight
= ( isNested
) ? 50 : 150;
811 cbDimInfo
sizes4( cbWidth
,cbHeight
,
813 cbWidth
,cbHeight
, FALSE
);
818 cbDimInfo
sizes5( cbWidth
,cbHeight
,
820 cbWidth
,cbHeight
, TRUE
,
821 3, // vertical gap (bar border)
822 3 // horizontal gap (bar border)
825 // create "workplace" window in the third layout
827 wxTabbedWindow
* pMiniTabArea
= new wxTabbedWindow();
829 pMiniTabArea
->Create( pParent
, -1 );
831 wxTreeCtrl
* pClassView
=
832 new wxTreeCtrl( pMiniTabArea
, -1, wxDefaultPosition
, wxDefaultSize
,
833 wxTR_HAS_BUTTONS
| wxTR_EDIT_LABELS
);
835 pClassView
->SetImageList( &mImageList
);
837 wxTreeItemId rootId
= pClassView
->AddRoot( "wxWindows 2.0 classes", 0 );
839 wxTreeItemId cinfId
= pClassView
->AppendItem( rootId
, "wxWin Dynamic classes (grabbed at run-time)", 0 );
840 wxTreeItemId serId
= pClassView
->AppendItem( rootId
, "serializer-classes (grabbed at run-time)", 0 );
842 // functions from "wxinfo.h"
843 ::wxCreateClassInfoTree( pClassView
, cinfId
, 1 );
846 // (default arg anyway)
847 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap("class_icon"));
848 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") );
849 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap("file_icon") );
850 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap("help_icon") );
851 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
852 pMiniTabArea
), "HelloWorld", &wxBitmap("help_icon") );
854 pMiniTabArea
->AddTab( pClassView
, "ClassView", &wxBitmap(class_icon_xpm
));
855 pMiniTabArea
->AddTab( new wxPanel(), "ResourceView",&wxBitmap(res_icon_xpm
) );
856 pMiniTabArea
->AddTab( new wxPanel(), "FileView", &wxBitmap(file_icon_xpm
) );
857 pMiniTabArea
->AddTab( new wxPanel(), "InfoView", &wxBitmap(help_icon_xpm
) );
858 pMiniTabArea
->AddTab( CreateTxtCtrl( helloworld_src
,
859 pMiniTabArea
), "HelloWorld", &wxBitmap(help_icon_xpm
) );
861 // now create "output" window
863 wxPaggedWindow
* pTabbedArea
= new wxPaggedWindow();
865 pTabbedArea
->Create( pParent
, -1 );
867 wxPanel
* pSheet3
= new wxPanel();
868 pSheet3
->Create( pTabbedArea
, -1 );
869 pSheet3
->Show(FALSE
);
871 pTabbedArea
->AddTab( CreateTxtCtrl("build", pTabbedArea
), "Build", "" );
872 pTabbedArea
->AddTab( CreateTxtCtrl("debug", pTabbedArea
), "Debug", "" );
874 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap("file_icon") );
876 pTabbedArea
->AddTab( pSheet3
, "Find in Files!", &wxBitmap(file_icon_xpm
) );
878 pTabbedArea
->AddTab( CreateTxtCtrl("profile", pTabbedArea
), "Profile", "" );
880 layout
.AddBar( new StartButton95(pParent
), sizes5
, wxTOP
, 0, 0, "Start..." );
881 layout
.AddBar( pMiniTabArea
, sizes4
, wxLEFT
, 0, 0, "Project Workplace" );
882 layout
.AddBar( pTabbedArea
, sizes4
, wxBOTTOM
, 0, 50, "Output" );
887 void MyFrame::DropInSomeBars( int layoutNo
)
889 /* create once... and forget! */
891 // setup dimension infos for various bar shapes
896 if ( layoutNo
== SECOND_LAYOUT
) cbHeight
= 60;
898 wxFrameLayout
& layout
= *mLayouts
[layoutNo
];
900 cbDimInfo
sizes( cbWidth
,cbHeight
, // when docked horizontally
901 cbWidth
,cbHeight
, // when docked vertically
902 cbWidth
,cbHeight
, // when floated
903 TRUE
// true - bar is fixed-size
908 cbDimInfo
sizes1( cbWidth
,cbHeight
,
910 cbWidth
,cbHeight
, FALSE
); // false - bar is "flexible"
916 cbDimInfo
sizes3( cbWidth
,cbHeight
,
918 cbWidth
,cbHeight
, TRUE
); // -/-
923 cbDimInfo
sizes4( cbWidth
,cbHeight
,
925 cbWidth
,cbHeight
, FALSE
); // -/-
930 cbDimInfo
sizes5( cbWidth
,cbHeight
,
932 cbWidth
,cbHeight
, TRUE
,
933 3, // vertical gap (bar border)
934 3 // horizontal gap (bar border)
938 if ( layoutNo
== FIRST_LAYOUT
)
940 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
942 wxWindow
* pGreenOne
= new MyTestPanel(mpInternalFrm
);
944 pGreenOne
->SetBackgroundColour( wxColour(128,255,128) );
946 layout
.AddBar( pGreenOne
, sizes
, wxTOP
, 0, 50, "Bar1", TRUE
);
947 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxTOP
, 2, 50, "Bar2", TRUE
);
948 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxBOTTOM
, 2, 50, "Bar3", TRUE
);
949 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes
, wxLEFT
, 2, 50, "Bar4", TRUE
);
950 layout
.AddBar( new MyTestPanel(mpInternalFrm
), sizes1
, wxCBAR_HIDDEN
, 2, 50, "Super-Bar", TRUE
);
953 if ( layoutNo
== SECOND_LAYOUT
)
955 // show off various wx-controls in the second layout
957 layout
.AddBar( CreateTxtCtrl(), sizes
, wxTOP
, 0, 50, "Fixed text Area&0" );
958 layout
.AddBar( CreateButton("OK"), sizes
, wxTOP
, 0, 100, "First Button" );
959 layout
.AddBar( CreateTxtCtrl(), sizes1
, wxBOTTOM
, 0, 50, "First Tree" );
960 layout
.AddBar( CreateTreeCtrl("Root"), sizes1
, wxLEFT
, 0, 0, "TreeCtrl Window" );
961 layout
.AddBar( CreateChoice("Choice 1"), sizes3
, wxTOP
, 0, 0, "Choice 1 (buggy)", FALSE
, wxCBAR_HIDDEN
);
962 layout
.AddBar( CreateChoice("Choice 2"), sizes3
, wxTOP
, 0, 0, "Choice 2 (buggy)", FALSE
, wxCBAR_HIDDEN
);
963 layout
.AddBar( CreateTreeCtrl("X-Files"), sizes1
, wxRIGHT
, 0, 100, "X-Files" );
964 layout
.AddBar( CreateTxtCtrl("smaller1"), sizes3
, wxTOP
, 0, 50, "smaller Area1" );
965 layout
.AddBar( CreateTxtCtrl("smaller2"), sizes3
, wxTOP
, 0, 50, "sm&ller Area2" );
968 if ( layoutNo
== THIRD_LAYOUT
)
972 cbCommonPaneProperties props
;
973 layout
.GetPaneProperties( props
);
974 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF for gtk!!!
975 layout
.SetPaneProperties( props
, wxALL_PANES
);
979 layout
.AddBar( CreateTxtCtrl("Tool1"), sizes3
, wxTOP
, 0, 50, "Fixed text Area1" );
980 layout
.AddBar( CreateTxtCtrl("Tool2"), sizes3
, wxTOP
, 0, 50, "Fixed text Area2" );
981 layout
.AddBar( CreateTxtCtrl("Tool3"), sizes3
, wxTOP
, 0, 50, "Fixed text Area3" );
982 layout
.AddBar( CreateTxtCtrl("Tool4"), sizes3
, wxTOP
, 1, 50, "Fixed text Area4" );
983 layout
.AddBar( CreateTxtCtrl("Tool5"), sizes3
, wxTOP
, 1, 50, "Fixed text Area5" );
984 layout
.AddBar( CreateTxtCtrl("Tool6"), sizes3
, wxTOP
, 1, 50, "Fixed text Area6" );
985 layout
.AddBar( CreateTxtCtrl("Tool7"), sizes3
, wxTOP
, 2, 250, "Fixed text Area7" );
987 cbDimInfo
sizes10(175,35, // when docked horizontally
988 175,38, // when docked vertically
989 170,35, // when floated
990 TRUE
, // the bar is not fixed-size
991 4, // vertical gap (bar border)
992 4, // horizontal gap (bar border)
993 new cbDynToolBarDimHandler()
996 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
998 pToolBar
->Create( mpInternalFrm
, -1 );
1000 // 1001-1006 ids of command events fired by added tool-buttons
1002 pToolBar
->AddTool( 1001, wxBitmap("new_icon") );
1003 pToolBar
->AddTool( 1002, wxBitmap("open_icon") );
1004 pToolBar
->AddTool( 1003, wxBitmap("save_icon") );
1006 pToolBar
->AddTool( 1004, wxBitmap("cut_icon") );
1007 pToolBar
->AddTool( 1005, wxBitmap("copy_icon") );
1008 pToolBar
->AddTool( 1006, wxBitmap("paste_icon") );
1010 pToolBar
->AddTool( 1001, wxBitmap(new_xpm
), "" );
1011 pToolBar
->AddTool( 1002, wxBitmap(open_xpm
), "" );
1012 pToolBar
->AddTool( 1003, wxBitmap(save_xpm
), "" );
1014 pToolBar
->AddTool( 1004, wxBitmap(cut_xpm
), "" );
1015 pToolBar
->AddTool( 1005, wxBitmap(copy_xpm
), "" );
1016 pToolBar
->AddTool( 1006, wxBitmap(paste_xpm
), "" );
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 #ifdef __HACK_MY_MSDEV40__
1138 ////////////// new 2.0-magic (linker errors...) ////////////////
1140 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1142 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
1143 "recreating toolbar in wxFrame" );
1145 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1148 SetToolBar(toolBar
);
1158 void foo( double& d
)
1163 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1167 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);