]> git.saurik.com Git - wxWidgets.git/blob - utils/framelayout/samples/test/fl_test.cpp
8e32d9677e2cad105e5d2ccb8df8f36fd7de07d7
[wxWidgets.git] / utils / framelayout / samples / test / fl_test.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: minimal.cpp
3 // Purpose: Minimal wxWindows sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12
13 #ifdef __GNUG__
14 #pragma implementation "minimal.cpp"
15 #pragma interface "minimal.cpp"
16 #endif
17
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include "wx/wxprec.h"
20
21 /*
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25 */
26
27 #ifndef WX_PRECOMP
28 #include "wx/wx.h"
29 #endif
30
31 #include "wx/textctrl.h"
32
33 #include "controlbar.h" // core API
34 #include "fl_test.h"
35
36 // extra plugins
37 #include "barhintspl.h" // beveal for bars with "X"s and grooves
38 #include "rowdragpl.h" // NC-look with dragable rows
39 #include "cbcustom.h" // customization plugin
40 #include "hintanimpl.h"
41
42 // beuty-care
43 #include "gcupdatesmgr.h" // smooth d&d
44 #include "antiflickpl.h" // double-buffered repaint of decorations
45
46 #include "dyntbar.h" // auto-layouting toolbar
47 #include "dyntbarhnd.h" // control-bar dimension handler for it
48
49 // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
50
51 #ifndef wxDUMMY_OBJ_INCLUDED
52 char wxDummyChar;
53 #endif
54
55
56 IMPLEMENT_APP (MyApp)
57
58 bool MyApp::OnInit(void)
59 {
60 MyFrame *frame = new MyFrame(NULL);
61
62 frame->SetBackgroundColour( wxColour(192,192,192) );
63
64 wxMenu *file_menu = new wxMenu;
65
66 file_menu->Append( NEW_TEST_EXIT, "E&xit" );
67
68 wxMenuBar *menu_bar = new wxMenuBar;
69
70 menu_bar->Append(file_menu, "&File");
71
72 frame->SetMenuBar(menu_bar);
73
74 frame->CreateStatusBar(3);
75
76 frame->Show(TRUE);
77
78 frame->mpClientWnd->Refresh();
79
80 SetTopWindow(frame);
81
82 return TRUE;
83
84 /*
85 wxMessageBox("Hello, this demo has a bunch of yet-not-fixed-bugs and misssing functionality\n\
86 The ONLY purpose is to demostrate self-layouting toolbars,\n flat-bitmapped-buttons and 2-new FL-plugins\
87 (cbRowDragPlugin & cbBarHintsPlugin)\n\n\
88 BTW, disabled images and label-text are rendered at run-time" );
89 */
90
91
92 return TRUE;
93 }
94
95 /***** Implementation for class MyFrame *****/
96
97 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
98
99 // EVT_CHAR_HOOK(MyFrame::OnKeyDown)
100 // EVT_PAINT( MyFrame::OnPaint )
101 EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit )
102
103 END_EVENT_TABLE()
104
105 void MyFrame::OnExit( wxCommandEvent& event )
106 {
107 Destroy();
108 }
109
110 wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
111 {
112 wxTextCtrl* pCtrl =
113
114 new wxTextCtrl( mpInternalFrm, -1, value,
115 wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE );
116
117 pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
118
119 return pCtrl;
120 }
121
122 MyFrame::MyFrame(wxFrame *frame)
123
124 : wxFrame( frame, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
125 wxSize( 700, 500 ),
126 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
127 wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
128 "freimas" )
129 {
130 #ifdef __WXMSW__
131 mpInternalFrm = (wxPanel*)this;
132 #else
133 mpInternalFrm = new wxPanel( this, -1 );
134 #endif
135
136
137 mpClientWnd = CreateTextCtrl( "Client window" );
138
139
140 mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd );
141
142
143 #ifdef __WXGTK__
144
145 cbCommonPaneProperties props;
146 mpLayout->GetPaneProperties( props );
147
148 props.mRealTimeUpdatesOn = FALSE; // real-time OFF!!!
149
150 mpLayout->SetPaneProperties( props, wxALL_PANES );
151
152 #endif
153
154 mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() );
155
156 // this is now default...
157 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
158
159 // setup plugins for testing
160
161 mpLayout->PushDefaultPlugins();
162
163 mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
164
165 mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
166 mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
167 mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
168 mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
169
170 // drop in some bars
171
172 cbDimInfo sizes0(200,45, // when docked horizontally
173 200,85, // when docked vertically
174 175,35, // when floated
175 FALSE, // the bar is not fixed-size
176 4, // vertical gap (bar border)
177 4 // horizontal gap (bar border)
178 );
179
180 cbDimInfo sizes1(150,35, // when docked horizontally
181 150,85, // when docked vertically
182 175,35, // when floated
183 TRUE, // the bar is not fixed-size
184 4, // vertical gap (bar border)
185 4 // horizontal gap (bar border)
186 );
187
188 cbDimInfo sizes2(175,45, // when docked horizontally
189 175,37, // when docked vertically
190 170,35, // when floated
191 TRUE, // the bar is not fixed-size
192 4, // vertical gap (bar border)
193 4, // horizontal gap (bar border)
194 new cbDynToolBarDimHandler()
195 );
196
197 mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window
198 sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
199 0, // insert into 0th row (vert. position)
200 0, // offset from the start of row (in pixels)
201 "InfoViewer1", // name to refere in customization pop-ups
202 TRUE
203 );
204
205 mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window
206 sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
207 1, // insert into 0th row (vert. position)
208 0, // offset from the start of row (in pixels)
209 "InfoViewer2", // name to refere in customization pop-ups
210 TRUE
211 );
212
213 mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window
214 sizes1, wxTOP, // alignment ( 0-top,1-bottom, etc)
215 0, // insert into 0th row (vert. position)
216 0, // offset from the start of row (in pixels)
217 "ToolBar1", // name to refere in customization pop-ups
218 TRUE
219 );
220
221 wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
222
223 pToolBar->Create( mpInternalFrm, -1 );
224
225 // 1001-1006 ids of command events fired by added tool-buttons
226
227 pToolBar->AddTool( 1001, "new.bmp" );
228 pToolBar->AddTool( 1002, "open.bmp" );
229 pToolBar->AddTool( 1003, "save.bmp" );
230
231 pToolBar->AddTool( 1004, "cut.bmp" );
232 pToolBar->AddTool( 1005, "copy.bmp" );
233 pToolBar->AddTool( 1006, "paste.bmp" );
234
235
236 mpLayout->AddBar( pToolBar, // bar window (can be NULL)
237 sizes2, wxTOP, // alignment ( 0-top,1-bottom, etc)
238 0, // insert into 0th row (vert. position)
239 0, // offset from the start of row (in pixels)
240 "ToolBar2", // name to refere in customization pop-ups
241 FALSE
242 );
243
244 mpLayout->EnableFloating( TRUE ); // off, thinking bout wxGtk...
245 }
246
247 MyFrame::~MyFrame()
248 {
249 if ( mpLayout) delete mpLayout; // should be destroyed manually
250 }
251
252 #ifdef __HACK_MY_MSDEV40__
253
254 ////////////// new 2.0-magic (linker errors...) ////////////////
255
256 wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
257 {
258 wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
259 "recreating toolbar in wxFrame" );
260
261 wxToolBar* toolBar = OnCreateToolBar(style, id, name);
262 if (toolBar)
263 {
264 SetToolBar(toolBar);
265 PositionToolBar();
266 return toolBar;
267 }
268 else
269 {
270 return NULL;
271 }
272 }
273
274 wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
275 {
276 return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
277 }
278
279 #endif