1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "fl_sample.cpp"
14 #pragma interface "fl_sample.cpp"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 #include "controlbar.h"
31 #include "barhintspl.h"
32 #include "hintanimpl.h"
34 #include "wx/textctrl.h"
36 // ADDED by alex (linker complaints...):
37 #ifndef wxDUMMY_OBJ_INCLUDED
45 #define LAYOUT_FILE "layouts.dat"
47 class MyApp
: public wxApp
53 class MyFrame
: public wxFrame
56 wxFrameLayout
* mpLayout
;
57 wxWindow
* mpClientWnd
;
58 wxPanel
* mpInternalFrm
;
61 wxTextCtrl
* CreateTextCtrl( const wxString
& value
);
65 MyFrame( wxWindow
* parent
, char *title
);
68 void OnQuit( wxCommandEvent
& event
);
70 bool OnClose(void) { return TRUE
; }
75 /***** Implementation for class MyApp *****/
79 bool MyApp::OnInit(void)
81 // wxWindows boiler-plate:
83 MyFrame
*frame
= new MyFrame(NULL
, "wxFrameLayout sample");
85 wxMenu
*file_menu
= new wxMenu
;
87 file_menu
->Append( ID_LOAD
, "&Load layout" );
88 file_menu
->Append( ID_STORE
, "&Store layout" );
89 file_menu
->AppendSeparator();
91 file_menu
->Append( ID_QUIT
, "E&xit" );
93 wxMenuBar
*menu_bar
= new wxMenuBar
;
95 menu_bar
->Append(file_menu
, "&File");
97 frame
->CreateStatusBar(3);
98 frame
->SetMenuBar(menu_bar
);
107 /***** Immlementation for class MyFrame *****/
109 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
111 EVT_MENU( ID_QUIT
, MyFrame::OnQuit
)
115 MyFrame::MyFrame( wxWindow
* parent
, char *title
)
117 : wxFrame( parent
, -1, "NewTest-II", wxDefaultPosition
,
119 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
120 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
124 mpInternalFrm
= (wxPanel
*)this;
126 mpInternalFrm
= new wxPanel( this, -1 );
129 mpClientWnd
= CreateTextCtrl( "Client window" );
131 // btw, creation of internal frame is needed for wxGtk version
132 // to act correctly (since menu-bar is a separate window there..)
134 mpLayout
= new wxFrameLayout( mpInternalFrm
, mpClientWnd
);
138 // real-time dosn't work well under wxGtk yet
139 cbCommonPaneProperties props
;
140 mpLayout
->GetPaneProperties( props
);
142 props
.mRealTimeUpdatesOn
= FALSE
; // off
144 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
148 mpLayout
->PushDefaultPlugins();
149 mpLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for barso
150 //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
152 cbDimInfo
sizes( 80,65, // when docked horizontally
153 80,65, // when docked vertically
154 80,30, // when floated
155 TRUE
, // the bar is fixed-size
156 5, // vertical gap (bar border)
157 5 // horizontal gap (bar border)
162 for( int i
= 1; i
<= 10; ++i
)
165 sprintf( buf
, "%d", i
);
166 wxString name
= wxString("Bar-");
169 sizes
.mIsFixed
= i
% 5 > 0; // every fifth bar is not fixed-size
171 if ( !sizes
.mIsFixed
) name
+= " (flexible)";
173 mpLayout
->AddBar( CreateTextCtrl(name
),// bar window
174 sizes
, i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
175 0, // insert into 0th row (vert. position)
176 0, // offset from the start of row (in pixels)
177 name
// name to refere in customization pop-ups
184 // layout is not a window, should be released manually
186 if ( mpLayout
) delete mpLayout
;
189 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
193 new wxTextCtrl( mpInternalFrm
, -1, value
,
194 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE
);
196 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
201 void MyFrame::OnQuit( wxCommandEvent
& event
)
203 Show( FALSE
); // TRICK:: hide it, to avoid flickered destruction
208 #ifdef __HACK_MY_MSDEV40__
210 ////////////// new 2.0-magic (linker errors...) ////////////////
212 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
214 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
215 "recreating toolbar in wxFrame" );
217 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
230 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
232 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);