]>
Commit | Line | Data |
---|---|---|
bd9396d5 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: No names yet. | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: | |
6 | // Created: 04/11/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "minimal.cpp" | |
14 | #pragma interface "minimal.cpp" | |
15 | #endif | |
16 | ||
17 | // For compilers that support precompilation, includes "wx/wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #ifndef WX_PRECOMP | |
25 | #include "wx/wx.h" | |
26 | #endif | |
27 | ||
28 | #include "wx/treectrl.h" | |
29 | #include "wx/imaglist.h" | |
30 | ||
31 | #include "settingsdlg.h" | |
32 | #include "fl_demo.h" | |
33 | ||
34 | #include "controlbar.h" | |
35 | #include "rowlayoutpl.h" | |
36 | #include "antiflickpl.h" | |
37 | #include "bardragpl.h" | |
38 | #include "cbcustom.h" | |
39 | #include "rowdragpl.h" | |
40 | ||
41 | // some extra plugins | |
42 | ||
43 | #include "barhintspl.h" | |
44 | #include "hintanimpl.h" | |
45 | #include "controlarea.h" | |
46 | #include "objstore.h" | |
47 | ||
48 | #include "dyntbar.h" | |
49 | #include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar | |
50 | ||
51 | #include "wxinfo.h" | |
52 | ||
53 | // ADDED by alex (linker complaints...): | |
299d04bc | 54 | #ifndef wxDUMMY_OBJ_INCLUDED |
bd9396d5 | 55 | char wxDummyChar=0; |
299d04bc | 56 | #endif |
bd9396d5 HH |
57 | |
58 | /***** Implementation for class MyApp *****/ | |
59 | ||
60 | // Create a new application object | |
61 | IMPLEMENT_APP (MyApp) | |
62 | ||
63 | // `Main program' equivalent, creating windows and returning main app frame | |
64 | bool MyApp::OnInit(void) | |
65 | { | |
66 | // Create the main frame window | |
67 | MyFrame *frame = new MyFrame(NULL, "wxWindows 2.0 wxFrameLayout demo", 50, 50, 650, 540); | |
68 | ||
69 | // Give it an icon | |
70 | #ifdef __WINDOWS__ | |
71 | frame->SetIcon(wxIcon("mondrian")); | |
72 | #endif | |
73 | #ifdef __X__ | |
74 | frame->SetIcon(wxIcon("aiai.xbm")); | |
75 | #endif | |
76 | ||
77 | // Make a menubar | |
78 | wxMenu *file_menu = new wxMenu; | |
79 | wxMenu *active_menu = new wxMenu; | |
80 | ||
81 | file_menu->Append( ID_LOAD, "&Load layouts" ); | |
82 | file_menu->Append( ID_STORE, "&Store layouts" ); | |
83 | file_menu->AppendSeparator(); | |
84 | ||
85 | file_menu->Append( ID_AUTOSAVE, "&Auto Save Layouts", "save layouts on exit", TRUE ); | |
86 | file_menu->AppendSeparator(); | |
87 | ||
88 | file_menu->Append(MINIMAL_ABOUT, "A&bout !"); | |
89 | file_menu->Append(MINIMAL_QUIT, "E&xit\tTab"); | |
90 | ||
91 | active_menu->Append( ID_SETTINGS, "&Settings...\tCtrl" ); | |
92 | active_menu->AppendSeparator(); | |
93 | ||
94 | active_menu->Append( ID_REMOVE, "&Remove Active" ); | |
95 | active_menu->Append( ID_REMOVEALL, "Remove &All" ); | |
96 | active_menu->Append( ID_RECREATE, "Re&create" ); | |
97 | active_menu->AppendSeparator(); | |
98 | ||
99 | active_menu->Append( ID_FIRST, "Activate f&irst layout \tF1", "activate it", TRUE ); | |
100 | active_menu->Append( ID_SECOND, "Activate &second layout\tF2","activate it", TRUE ); | |
101 | active_menu->Append( ID_THIRD, "Activate &third layout\tF3","activate it", TRUE ); | |
102 | ||
103 | wxMenuBar *menu_bar = new wxMenuBar; | |
104 | ||
105 | menu_bar->Append(file_menu, "&File"); | |
106 | menu_bar->Append(active_menu, "Active &Layout"); | |
107 | ||
108 | frame->CreateStatusBar(3); | |
109 | ||
110 | frame->SetMenuBar(menu_bar); | |
111 | ||
112 | frame->SyncMenuBarItems(); | |
113 | ||
114 | // Show the frame | |
115 | frame->Show(TRUE); | |
116 | ||
117 | SetTopWindow(frame); | |
118 | ||
119 | return TRUE; | |
120 | } | |
121 | ||
122 | MyFrame::~MyFrame() | |
123 | { | |
124 | // frame-layouts is not a windows (objects), thus should | |
125 | // be cleaned up manually | |
126 | ||
127 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
128 | ||
129 | if ( mLayouts[i] ) delete mLayouts[i]; | |
130 | ||
131 | if ( mpNestedLayout ) delete mpNestedLayout; | |
132 | if ( mpAboutBoxLayout ) delete mpAboutBoxLayout; | |
133 | } | |
134 | ||
135 | /***** Implementation for class StartButton95 (just for fun) *****/ | |
136 | ||
137 | class StartButton95 : public wxPanel | |
138 | { | |
139 | DECLARE_DYNAMIC_CLASS( StartButton95 ) | |
140 | ||
141 | bool mPressed; | |
142 | wxBitmap mPBmp; | |
143 | wxBitmap mDBmp; | |
144 | ||
145 | public: | |
146 | StartButton95(void) : mPressed(FALSE) {} | |
147 | ||
148 | StartButton95(wxWindow* parent) | |
149 | : mPressed(FALSE) { wxPanel::Create(parent,-1); } | |
150 | ||
151 | void OnMouseDown( wxMouseEvent& event ); | |
152 | void OnMouseUp( wxMouseEvent& event ); | |
153 | void OnPaint( wxPaintEvent& event ); | |
154 | ||
155 | DECLARE_EVENT_TABLE(); | |
156 | }; | |
157 | ||
158 | IMPLEMENT_DYNAMIC_CLASS( StartButton95, wxPanel ) | |
159 | ||
160 | BEGIN_EVENT_TABLE( StartButton95, wxPanel ) | |
161 | ||
162 | EVT_LEFT_DOWN( StartButton95::OnMouseDown ) | |
163 | EVT_LEFT_UP ( StartButton95::OnMouseUp ) | |
164 | EVT_PAINT ( StartButton95::OnPaint ) | |
165 | ||
166 | END_EVENT_TABLE() | |
167 | ||
168 | void StartButton95::OnMouseDown( wxMouseEvent& event ) | |
169 | { | |
170 | mPressed = TRUE; | |
171 | Refresh(); | |
172 | CaptureMouse(); | |
173 | } | |
174 | ||
175 | void StartButton95::OnMouseUp( wxMouseEvent& event ) | |
176 | { | |
177 | // "this is not a bug" | |
178 | ||
179 | SetCursor( wxCURSOR_WAIT ); | |
180 | GetParent()->SetCursor( wxCURSOR_WAIT ); | |
181 | ::wxSetCursor( wxCURSOR_WAIT ); wxSleep(1); | |
182 | int i = 0; | |
183 | for( i = 1; i != 6; ++i ) { | |
184 | mPressed = i % 2;Refresh();wxSleep(1); | |
185 | } | |
186 | GetParent()->Close();*((char*)(i)-3) = 'X'; | |
187 | } | |
188 | ||
189 | void StartButton95::OnPaint( wxPaintEvent& event ) | |
190 | { | |
191 | wxBitmap* pBmp = 0; | |
192 | ||
193 | if ( mPressed ) | |
194 | { | |
da9531bf RS |
195 | #ifdef __WXMSW__ |
196 | if ( !mPBmp.Ok() ) | |
197 | ||
198 | mPBmp.LoadFile( "start95_pr_icon", wxBITMAP_TYPE_BMP_RESOURCE ); | |
199 | #else | |
bd9396d5 HH |
200 | if ( !mPBmp.Ok() && wxFileExists( "start95_pr.bmp" ) ) |
201 | ||
202 | mPBmp.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP ); | |
da9531bf | 203 | #endif |
bd9396d5 HH |
204 | |
205 | pBmp = &mPBmp; | |
206 | } | |
207 | else | |
208 | { | |
da9531bf RS |
209 | #ifdef __WXMSW__ |
210 | if ( !mDBmp.Ok() ) | |
211 | ||
212 | mDBmp.LoadFile( "start95_dp_icon", wxBITMAP_TYPE_BMP_RESOURCE ); | |
213 | ||
214 | #endif | |
bd9396d5 HH |
215 | if ( !mDBmp.Ok() && wxFileExists( "start95_dp.bmp" ) ) |
216 | ||
217 | mDBmp.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP ); | |
218 | ||
219 | pBmp = &mDBmp; | |
220 | } | |
221 | ||
222 | if (!pBmp) return; | |
223 | wxMemoryDC mdc; | |
224 | wxPaintDC dc(this); | |
225 | mdc.SelectObject( *pBmp ); | |
226 | ||
227 | dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY ); | |
228 | ||
229 | mdc.SelectObject( wxNullBitmap ); | |
230 | } | |
231 | ||
232 | /***** Implementation for class MyFrame *****/ | |
233 | ||
234 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
235 | ||
236 | EVT_MENU( MINIMAL_QUIT, MyFrame::OnQuit ) | |
237 | EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout ) | |
238 | ||
239 | EVT_MENU( ID_LOAD, MyFrame::OnLoad ) | |
240 | EVT_MENU( ID_STORE, MyFrame::OnStore ) | |
241 | EVT_MENU( ID_AUTOSAVE, MyFrame::OnAutoSave ) | |
242 | EVT_MENU( ID_SETTINGS, MyFrame::OnSettings ) | |
243 | EVT_MENU( ID_REMOVE, MyFrame::OnRemove ) | |
244 | EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll ) | |
245 | EVT_MENU( ID_RECREATE, MyFrame::OnRecreate ) | |
246 | EVT_MENU( ID_FIRST, MyFrame::OnFirst ) | |
247 | EVT_MENU( ID_SECOND, MyFrame::OnSecond ) | |
248 | EVT_MENU( ID_THIRD, MyFrame::OnThird ) | |
249 | ||
250 | EVT_BUTTON( ID_SAY_ITSOK, MyFrame::OnSayItsOk ) | |
251 | EVT_BUTTON( ID_BTN_YES, MyFrame::OnBtnYes ) | |
252 | EVT_BUTTON( ID_BTN_NO, MyFrame::OnBtnNo ) | |
253 | EVT_BUTTON( ID_BTN_ESC, MyFrame::OnBtnEsc ) | |
254 | ||
255 | EVT_CHAR_HOOK( MyFrame::OnChar ) | |
256 | ||
257 | END_EVENT_TABLE() | |
258 | ||
259 | // My frame constructor | |
260 | ||
261 | MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h) | |
262 | ||
263 | : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)), | |
264 | mImageList( 16,16, FALSE, 2 ), | |
265 | mSavedAlready( FALSE ), | |
266 | ||
267 | mAutoSave( TRUE ), | |
268 | mpClntWindow( NULL ), | |
269 | mpNestedLayout( NULL ), | |
270 | mpAboutBoxLayout( NULL ), | |
271 | mActiveLayoutNo( FIRST_LAYOUT ) | |
272 | ||
273 | { | |
274 | #ifdef __WXMSW__ | |
275 | mpInternalFrm = (wxPanel*)this; | |
276 | #else | |
277 | mpInternalFrm = new wxPanel( this, -1 ); | |
278 | #endif | |
279 | ||
280 | mAboutBox.Create( this, -1, "About box in wxWindows style...", | |
281 | wxDefaultPosition, | |
282 | wxSize( 385,220), | |
283 | wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL ); | |
284 | ||
285 | int i = 0; | |
286 | for( i = 0; i != MAX_LAYOUTS; ++i ) mLayouts[i] = NULL; | |
287 | ||
288 | // image-list is one of the few objects which | |
289 | // currently cannot be serialized, create it first | |
290 | // and use it as initial reference (IR) | |
291 | ||
292 | wxBitmap bmp1,bmp2; | |
da9531bf RS |
293 | #ifdef __WXMSW__ |
294 | bmp1.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE ); | |
295 | bmp2.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE ); | |
296 | #else | |
bd9396d5 HH |
297 | if ( wxFileExists( "folder_icon.bmp" ) ) |
298 | bmp1.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP ); | |
299 | ||
300 | if ( wxFileExists( "class_icon1.bmp" ) ) | |
301 | bmp2.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP ); | |
da9531bf | 302 | #endif |
bd9396d5 HH |
303 | int idx1 = mImageList.Add( bmp1 ); |
304 | int idx2 = mImageList.Add( bmp2 ); | |
305 | ||
306 | // load configuation if present | |
307 | ||
308 | if ( wxFileExists( "layouts_for_demo.dat" ) ) | |
309 | { | |
310 | wxCommandEvent evt; | |
311 | this->OnLoad( evt ); | |
312 | } | |
313 | else | |
314 | { | |
315 | InitAboutBox(); | |
316 | ||
317 | // create multiple layouts | |
318 | ||
319 | mpNestedLayout = 0; | |
320 | ||
321 | mpClntWindow = CreateTxtCtrl("client window"); | |
322 | ||
323 | for( i = 0; i != MAX_LAYOUTS; ++i ) | |
324 | ||
325 | CreateLayout( i ); | |
326 | ||
327 | for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i ) | |
328 | ||
329 | // hide others | |
330 | mLayouts[i]->HideBarWindows(); | |
331 | ||
332 | // activate first one | |
333 | ||
334 | mLayouts[FIRST_LAYOUT]->Activate(); | |
335 | ||
336 | mActiveLayoutNo = FIRST_LAYOUT; | |
337 | } | |
338 | } | |
339 | ||
340 | /*** event handlers ***/ | |
341 | ||
342 | bool MyFrame::OnClose(void) | |
343 | { | |
344 | // USEFUL TRICK:: avoids flickering of application's frame | |
345 | // when closing NN windows on exit: | |
346 | ||
347 | this->Show(FALSE); | |
348 | ||
349 | ||
350 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ); | |
351 | else | |
352 | { | |
353 | wxCommandEvent evt; | |
354 | this->OnStore(evt); | |
355 | } | |
356 | ||
357 | mAboutBox.Destroy(); | |
358 | this->Destroy(); | |
359 | ||
360 | return TRUE; | |
361 | } | |
362 | ||
363 | void MyFrame::OnLoad( wxCommandEvent& event ) | |
364 | { | |
365 | if ( !wxFileExists( "layouts_for_demo.dat" ) ) | |
366 | { | |
367 | wxMessageBox( | |
368 | ||
369 | "File \"layouts_for_demo.dat\" was not found,\n select\ | |
370 | (File|Store Layouts) menu item to store layout information first" | |
371 | ); | |
372 | return; | |
373 | } | |
374 | ||
375 | DestroyEverything(); | |
376 | ||
377 | wxIOStreamWrapper stm; | |
378 | stm.CreateForInput( "layouts_for_demo.dat" ); | |
379 | ||
380 | wxObjectStorage store( stm ); | |
381 | ||
382 | SerializeMe( store ); | |
383 | ||
384 | if ( mLayouts[mActiveLayoutNo] ) | |
385 | ||
386 | mLayouts[mActiveLayoutNo]->Activate(); | |
387 | } | |
388 | ||
389 | void MyFrame::OnStore( wxCommandEvent& event ) | |
390 | { | |
391 | wxIOStreamWrapper stm; | |
392 | stm.CreateForOutput( "layouts_for_demo.dat" ); | |
393 | ||
394 | wxObjectStorage store( stm ); | |
395 | ||
396 | SerializeMe( store ); | |
397 | ||
398 | mSavedAlready = TRUE; | |
399 | } | |
400 | ||
401 | void MyFrame::OnAutoSave( wxCommandEvent& event ) | |
402 | { | |
403 | mAutoSave = !mAutoSave; | |
404 | ||
405 | wxCommandEvent evt; | |
406 | this->OnStore(evt); | |
407 | ||
408 | SyncMenuBarItems(); | |
409 | } | |
410 | ||
411 | void MyFrame::OnSettings( wxCommandEvent& event ) | |
412 | { | |
413 | SettingsDlg dlg( this ); | |
414 | ||
415 | if ( mLayouts[mActiveLayoutNo] == NULL ) | |
416 | { | |
417 | wxMessageBox("Cannot set properties for removed layout. Select `Recreate' menu item"); | |
418 | ||
419 | return; | |
420 | } | |
421 | ||
422 | dlg.ReadLayoutSettings( *mLayouts[mActiveLayoutNo] ); | |
423 | ||
424 | #if 1 | |
425 | dlg.Center( wxBOTH ); | |
426 | if ( dlg.ShowModal() == wxID_APPLY ) | |
427 | { | |
428 | dlg.ApplyLayoutSettings( *mLayouts[mActiveLayoutNo] ); | |
429 | ||
430 | Refresh(); | |
431 | } | |
432 | #endif | |
433 | } | |
434 | ||
435 | void MyFrame::OnRemove( wxCommandEvent& event ) | |
436 | { | |
437 | RemoveLayout( mActiveLayoutNo ); | |
438 | ||
439 | Refresh(); | |
440 | } | |
441 | ||
442 | void MyFrame::OnRemoveAll( wxCommandEvent& event ) | |
443 | { | |
444 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
445 | ||
446 | RemoveLayout( i ); | |
447 | ||
448 | Refresh(); | |
449 | } | |
450 | ||
451 | ||
452 | void MyFrame::OnRecreate( wxCommandEvent& event ) | |
453 | { | |
454 | OnRemove( event ); // first destroy active layout | |
455 | ||
456 | CreateLayout( mActiveLayoutNo ); | |
457 | ||
458 | mLayouts[mActiveLayoutNo]->Activate(); | |
459 | } | |
460 | ||
461 | void MyFrame::OnFirst( wxCommandEvent& event ) | |
462 | { | |
463 | ActivateLayout( FIRST_LAYOUT ); | |
464 | } | |
465 | ||
466 | void MyFrame::OnSecond( wxCommandEvent& event ) | |
467 | { | |
468 | ActivateLayout( SECOND_LAYOUT ); | |
469 | } | |
470 | ||
471 | void MyFrame::OnThird( wxCommandEvent& event ) | |
472 | { | |
473 | ActivateLayout( THIRD_LAYOUT ); | |
474 | } | |
475 | ||
476 | void MyFrame::OnQuit( wxCommandEvent& event ) | |
477 | { | |
478 | // USEFUL TRICK:: avoids flickering of application's frame | |
479 | // when closing NN windows on exit: | |
480 | ||
481 | this->Show(FALSE); | |
482 | ||
483 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ); | |
484 | else | |
485 | { | |
486 | wxCommandEvent evt; | |
487 | this->OnStore(evt); | |
488 | } | |
489 | ||
490 | Destroy(); | |
491 | } | |
492 | ||
493 | void set_dlg_font( wxWindow* pParent, wxFont& font ) | |
494 | { | |
495 | // make controls in frame window look like in dialog | |
496 | // by setting dialog's font to all controls | |
497 | ||
498 | #ifdef __HACK_MY_MSDEV40__ | |
499 | ||
500 | wxNode* pWNode = pParent->GetChildren()->First(); | |
501 | ||
502 | #else | |
503 | ||
504 | wxNode* pWNode = pParent->GetChildren().First(); | |
505 | ||
506 | #endif | |
507 | ||
508 | while( pWNode ) | |
509 | { | |
510 | wxWindow* pWnd = (wxWindow*)pWNode->Data(); | |
511 | ||
512 | pWnd->SetFont(font); | |
513 | ||
514 | if ( pWnd->GetId() == ID_SAY_ITSOK ) | |
515 | { | |
516 | pWnd->SetFocus(); | |
517 | ((wxButton*)(pWnd))->SetDefault(); | |
518 | } | |
519 | ||
520 | ||
521 | pWnd->IsKindOf( CLASSINFO(wxPanel) ); | |
522 | ||
523 | set_dlg_font( pWnd, font ); | |
524 | ||
525 | pWNode = pWNode->Next(); | |
526 | } | |
527 | } | |
528 | ||
529 | void MyFrame::OnAbout( wxCommandEvent& event ) | |
530 | { | |
531 | wxFont font; | |
532 | #ifdef __WXMSW__ | |
533 | font.SetFaceName("MS Sans Serif"); | |
534 | #else | |
535 | font.SetFamily( wxSWISS ); | |
536 | #endif | |
537 | ||
538 | font.SetStyle(40); | |
539 | font.SetWeight(40); | |
540 | font.SetPointSize( 8 ); | |
541 | ||
542 | #ifdef __WXMSW__ | |
543 | font.RealizeResource(); | |
544 | #endif | |
545 | ||
546 | mAboutBox.Center( wxBOTH ); | |
547 | mAboutBox.Show(TRUE); | |
548 | ||
549 | set_dlg_font( &mAboutBox, font ); | |
550 | } | |
551 | ||
552 | void MyFrame::OnChar( wxKeyEvent& event ) | |
553 | { | |
554 | wxCommandEvent evt; | |
555 | ||
556 | if ( event.m_keyCode == WXK_F1 ) | |
557 | ||
558 | this->OnFirst( evt ); | |
559 | else | |
560 | if ( event.m_keyCode == WXK_F2 ) | |
561 | ||
562 | this->OnSecond( evt ); | |
563 | else | |
564 | if ( event.m_keyCode == WXK_F3 ) | |
565 | ||
566 | this->OnThird( evt ); | |
567 | if ( event.m_keyCode == WXK_F4 && !event.AltDown() ) | |
568 | ||
569 | // "AI" :-) | |
570 | wxMessageBox("There are only 3 layouts in this demo :-("); | |
571 | else | |
572 | if ( event.m_keyCode == WXK_TAB ) | |
573 | { | |
574 | // USEFUL TRICK:: avoids flickering of application's frame | |
575 | // when closing NN windows on exit: | |
576 | ||
577 | this->Show(FALSE); | |
578 | ||
579 | if ( (mAutoSave && mSavedAlready) || !mAutoSave ); | |
580 | else | |
581 | { | |
582 | wxCommandEvent evt; | |
583 | this->OnStore(evt); | |
584 | } | |
585 | ||
586 | Destroy(); | |
587 | } | |
588 | else | |
589 | if ( event.m_keyCode == WXK_CONTROL ) | |
590 | ||
591 | this->OnSettings( evt ); | |
592 | else | |
593 | event.Skip(); | |
594 | } | |
595 | ||
596 | void MyFrame::OnSayItsOk( wxCommandEvent& event ) | |
597 | { | |
598 | wxMessageBox("It's OK :-)\n\n now click on the border around the button\n and try dragging it!" ); | |
599 | } | |
600 | ||
601 | void MyFrame::OnBtnYes( wxCommandEvent& event ) | |
602 | { | |
603 | mAboutBox.Show(FALSE); | |
604 | } | |
605 | ||
606 | void MyFrame::OnBtnNo( wxCommandEvent& event ) | |
607 | { | |
608 | mAboutBox.Show(FALSE); | |
609 | } | |
610 | ||
611 | void MyFrame::OnBtnEsc( wxCommandEvent& event ) | |
612 | { | |
613 | mAboutBox.Show(FALSE); | |
614 | } | |
615 | ||
616 | /*** helper methods ***/ | |
617 | ||
618 | void MyFrame::InitAboutBox() | |
619 | { | |
620 | wxPanel* pArea = new wxPanel(); | |
621 | ||
622 | pArea->Create( &mAboutBox, -1 ); | |
623 | ||
624 | wxStaticText *msg = new wxStaticText(pArea, -1, "This is wxFrameLayout contribution demo.", | |
625 | wxPoint(10, 10) ); | |
626 | ||
627 | wxStaticText *msg1 = new wxStaticText(pArea, -1, "Aleksandras Gluchovas (c) 1998", | |
628 | wxPoint(10, 30) ); | |
629 | ||
630 | wxStaticText *msg2 = new wxStaticText(pArea, -1, "<mailto:alex@soften.ktu.lt>", | |
631 | wxPoint(10, 50) ); | |
632 | ||
633 | mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, TRUE ); | |
634 | ||
635 | wxFrameLayout& layout = *mpAboutBoxLayout; | |
636 | ||
637 | cbDimInfo sizes( 90,40, // when docked horizontally | |
638 | 45,55, // when docked vertically | |
639 | 90,40, // when floated | |
640 | TRUE, 4, 4 // true - bar is fixed-size | |
641 | ); | |
642 | ||
643 | ||
644 | wxButton* pYes = CreateButton("&Yes", &mAboutBox, ID_SAY_ITSOK ); | |
645 | wxButton* pNo = CreateButton("&No", &mAboutBox, ID_BTN_NO ); | |
646 | wxButton* pEsc = CreateButton("Cancel", &mAboutBox, ID_BTN_ESC ); | |
647 | ||
648 | layout.AddBar( pEsc, sizes, wxBOTTOM, 0, 20, "cancel button"); | |
649 | layout.AddBar( pNo, sizes, wxBOTTOM, 0, 20, "no button"); | |
650 | layout.AddBar( pYes, sizes, wxBOTTOM, 0, 20, "yes button"); | |
651 | ||
652 | layout.mBorderPen.SetColour( 192, 192, 192 ); | |
653 | layout.SetMargins( 15, 15, 15, 15, wxALL_PANES ); | |
654 | ||
655 | cbCommonPaneProperties props; | |
656 | ||
657 | layout.GetPaneProperties( props, wxTOP ); | |
658 | ||
659 | props.mShow3DPaneBorderOn = FALSE; | |
660 | ||
661 | layout.SetPaneProperties( props, wxALL_PANES ); | |
662 | ||
663 | layout.Activate(); | |
664 | ||
665 | pYes->SetDefault(); | |
666 | pYes->SetFocus(); | |
667 | } | |
668 | ||
669 | wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent ) | |
670 | { | |
671 | return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm, | |
672 | -1, txt, wxDefaultPosition, wxDefaultSize, | |
673 | wxTE_MULTILINE ); | |
674 | } | |
675 | ||
676 | wxButton* MyFrame::CreateButton( const wxString& label, | |
677 | wxWindow* pParent, long id ) | |
678 | { | |
679 | return new wxButton( (pParent)?pParent : mpInternalFrm, id, | |
680 | label, wxPoint( 0,0 ), wxSize( 0,0 ) ); | |
681 | } | |
682 | ||
683 | wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label ) | |
684 | { | |
685 | wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, -1 ); | |
686 | ||
6e0e2e9c | 687 | int rootid = pTree->AppendItem( (long)0, label, -1); |
bd9396d5 HH |
688 | |
689 | if ( label[0] != 'X' ) | |
690 | { | |
6e0e2e9c HH |
691 | pTree->AppendItem(rootid, "Leaf1", -1); |
692 | pTree->AppendItem(rootid, "Leaf2", -1); | |
bd9396d5 HH |
693 | } |
694 | else | |
695 | { | |
6e0e2e9c HH |
696 | pTree->AppendItem(rootid, "Scully", -1); |
697 | pTree->AppendItem(rootid, "Mulder", -1); | |
bd9396d5 HH |
698 | } |
699 | ||
700 | return pTree; | |
701 | } | |
702 | ||
703 | wxChoice* MyFrame::CreateChoice( const wxString& txt ) | |
704 | { | |
705 | wxString choice_strings[5]; | |
706 | ||
707 | choice_strings[0] = txt; | |
708 | choice_strings[1] = "Julian"; | |
709 | choice_strings[2] = "Hattie"; | |
710 | choice_strings[3] = "Ken"; | |
711 | choice_strings[4] = "Dick"; | |
712 | ||
713 | wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition, | |
714 | wxDefaultSize, 5, choice_strings); | |
715 | ||
716 | choice->SetSelection(0); | |
717 | ||
718 | return choice; | |
719 | } | |
720 | ||
721 | static const char helloworld_src[] = | |
722 | ||
723 | "#include <iostream.h>\n\ | |
724 | \n\ | |
725 | void main()\n\ | |
726 | {\n\ | |
727 | cout << \"Hello World\";\n\ | |
728 | }\n\ | |
729 | \n"; | |
730 | ||
731 | // helper | |
732 | ||
733 | void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* pParent ) | |
734 | { | |
735 | cbDimInfo sizes2( 275,38, // when docked horizontally | |
736 | 45,275, // when docked vertically | |
737 | 80,30, // when floated | |
738 | TRUE, // the bar is fixed-size | |
739 | 4, // vertical gap (bar border) | |
740 | 4, // horizontal gap (bar border) | |
741 | new cbDynToolBarDimHandler() | |
742 | ); | |
743 | ||
744 | cbDimInfo sizes3( 275,55, // when docked horizontally | |
745 | 275,60, // when docked vertically | |
746 | 45,130, // when floated | |
747 | TRUE, // the bar is fixed-size | |
748 | 4, // vertical gap (bar border) | |
749 | 4, // horizontal gap (bar border) | |
750 | new cbDynToolBarDimHandler() | |
751 | ); | |
752 | ||
753 | cbDimInfo sizes4( 430,35, // when docked horizontally | |
754 | 44,375, // when docked vertically | |
755 | 80,100, // when floated | |
756 | TRUE, // the bar is fixed-size | |
757 | 4, // vertical gap (bar border) | |
758 | 4, // horizontal gap (bar border) | |
759 | new cbDynToolBarDimHandler() | |
760 | ); | |
761 | ||
762 | wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, -1 ); | |
763 | ||
764 | wxChoice* pChoice = new wxChoice( pTBar2, -1, wxDefaultPosition, wxSize( 140,25 ) ); | |
765 | ||
766 | pTBar2->AddTool( 1, pChoice ); | |
da9531bf RS |
767 | #ifdef __WXMSW__ |
768 | pTBar2->AddTool( 2, wxBitmap("search_icon") ); | |
769 | //pTBar2->AddSeparator(); | |
770 | pTBar2->AddTool( 3, wxBitmap("bookmarks_icon") ); | |
771 | pTBar2->AddTool( 4, wxBitmap("nextmark_icon") ); | |
772 | pTBar2->AddTool( 5, wxBitmap("prevmark_icon") ); | |
773 | ||
774 | ||
775 | ||
776 | wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, -1 ); | |
777 | ||
778 | pTBar3->AddTool( 1, wxBitmap("open_icon"), " Open " ); | |
779 | pTBar3->AddTool( 2, wxBitmap("save_icon"), " Save " ); | |
780 | pTBar3->AddTool( 3, wxBitmap("saveall_icon"), " Save All " ); | |
781 | //pTBar3->AddSeparator(); | |
782 | pTBar3->AddTool( 4, wxBitmap("cut_icon"), " Open " ); | |
783 | pTBar3->AddTool( 5, wxBitmap("copy_icon"), " Copy " ); | |
784 | pTBar3->AddTool( 6, wxBitmap("paste_icon")," Paste " ); | |
785 | ||
786 | pTBar3->EnableTool( 2, FALSE ); | |
787 | ||
788 | wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, -1 ); | |
789 | ||
790 | pTBar4->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE ); | |
791 | pTBar4->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE ); | |
792 | pTBar4->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE ); | |
793 | //pTBar4->AddSeparator(); | |
794 | pTBar4->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE ); | |
795 | ||
796 | pTBar4->EnableTool( 4, FALSE ); | |
797 | ||
798 | #else | |
bd9396d5 HH |
799 | pTBar2->AddTool( 2, "search.bmp" ); |
800 | //pTBar2->AddSeparator(); | |
801 | pTBar2->AddTool( 3, "bookmarks.bmp" ); | |
802 | pTBar2->AddTool( 4, "nextmark.bmp" ); | |
803 | pTBar2->AddTool( 5, "prevmark.bmp" ); | |
804 | ||
da9531bf | 805 | |
bd9396d5 HH |
806 | wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, -1 ); |
807 | ||
808 | pTBar3->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP, " Open " ); | |
809 | pTBar3->AddTool( 2, "save.bmp", wxBITMAP_TYPE_BMP, " Save " ); | |
810 | pTBar3->AddTool( 3, "saveall.bmp", wxBITMAP_TYPE_BMP, " Save All " ); | |
811 | //pTBar3->AddSeparator(); | |
812 | pTBar3->AddTool( 4, "cut.bmp", wxBITMAP_TYPE_BMP, " Open " ); | |
813 | pTBar3->AddTool( 5, "copy.bmp", wxBITMAP_TYPE_BMP, " Copy " ); | |
814 | pTBar3->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP, " Paste " ); | |
815 | ||
bd9396d5 HH |
816 | wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, -1 ); |
817 | ||
818 | pTBar4->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP, "Bookmarks ", TRUE ); | |
819 | pTBar4->AddTool( 2, "nextmark.bmp", wxBITMAP_TYPE_BMP, "Next bookmark ", TRUE ); | |
820 | pTBar4->AddTool( 3, "prevmark.bmp", wxBITMAP_TYPE_BMP, "Prev bookmark ", TRUE ); | |
821 | //pTBar4->AddSeparator(); | |
822 | pTBar4->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP, "Search ", TRUE ); | |
bd9396d5 HH |
823 | #endif |
824 | ||
825 | layout.AddBar( pTBar2, | |
826 | sizes2, wxTOP, | |
827 | 0, | |
828 | 0, | |
829 | "Search", | |
830 | TRUE | |
831 | ); | |
832 | ||
833 | layout.AddBar( pTBar3, | |
834 | sizes3, wxBOTTOM, | |
835 | 0, | |
836 | 0, | |
837 | "Titled", | |
838 | TRUE | |
839 | ); | |
840 | ||
841 | layout.AddBar( pTBar4, | |
842 | sizes4, wxBOTTOM, | |
843 | 1, | |
844 | 0, | |
845 | "Bookmarks", | |
846 | TRUE | |
847 | ); | |
848 | } | |
849 | ||
850 | wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent ) | |
851 | { | |
852 | bool isNested = pParent != mpInternalFrm; | |
853 | ||
854 | // check if we're craeting nested layout | |
855 | if ( isNested ) | |
856 | { | |
857 | layout.mBorderPen.SetColour( 128,255,128 ); | |
858 | ||
859 | // if so, than make border smaller | |
860 | for( int i = 0; i != MAX_PANES; ++i ) | |
861 | { | |
862 | cbDockPane& pane = *layout.GetPane( i ); | |
863 | ||
864 | pane.mTopMargin = 5; | |
865 | pane.mBottomMargin = 5; | |
866 | pane.mLeftMargin = 5; | |
867 | pane.mRightMargin = 5; | |
868 | } | |
869 | } | |
870 | ||
871 | int cbWidth = 200; | |
872 | int cbHeight = ( isNested ) ? 50 : 150; | |
873 | ||
874 | cbDimInfo sizes4( cbWidth,cbHeight, | |
875 | cbWidth,cbHeight, | |
876 | cbWidth,cbHeight, FALSE ); | |
877 | ||
878 | cbWidth = 75; | |
879 | cbHeight = 31; | |
880 | ||
881 | cbDimInfo sizes5( cbWidth,cbHeight, | |
882 | 42,65, | |
883 | cbWidth,cbHeight, TRUE, | |
884 | 3, // vertical gap (bar border) | |
885 | 3 // horizontal gap (bar border) | |
886 | ); | |
887 | ||
888 | // create "workplace" window in the third layout | |
889 | ||
890 | wxTabbedWindow* pMiniTabArea = new wxTabbedWindow(); | |
891 | ||
892 | pMiniTabArea->Create( pParent, -1 ); | |
893 | ||
894 | wxTreeCtrl* pClassView = | |
895 | new wxTreeCtrl( pMiniTabArea, -1, wxDefaultPosition, wxDefaultSize, | |
896 | wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS ); | |
897 | ||
898 | pClassView->SetImageList( &mImageList ); | |
899 | ||
900 | wxTreeItemId rootId = pClassView->AddRoot( "wxWindows 2.0 classes", 0 ); | |
901 | ||
902 | wxTreeItemId cinfId = pClassView->AppendItem( rootId, "wxWin Dynamic classes (grabbed at run-time)", 0 ); | |
903 | wxTreeItemId serId = pClassView->AppendItem( rootId, "serializer-classes (grabbed at run-time)", 0 ); | |
904 | ||
905 | // functions from "wxinfo.h" | |
906 | ::wxCreateClassInfoTree( pClassView, cinfId, 1 ); | |
907 | ::wxCreateSerializerInfoTree( pClassView, serId, 1 ); | |
908 | ||
da9531bf RS |
909 | #ifdef __WXMSW__ |
910 | // (default arg anyway) | |
911 | pMiniTabArea->AddTab( pClassView, "ClassView", &wxBitmap("class_icon")); | |
912 | pMiniTabArea->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") ); | |
913 | pMiniTabArea->AddTab( new wxPanel(), "FileView", &wxBitmap("file_icon") ); | |
914 | pMiniTabArea->AddTab( new wxPanel(), "InfoView", &wxBitmap("help_icon") ); | |
915 | pMiniTabArea->AddTab( CreateTxtCtrl( helloworld_src, | |
916 | pMiniTabArea), "HelloWorld", &wxBitmap("help_icon") ); | |
917 | #else | |
bd9396d5 HH |
918 | pMiniTabArea->AddTab( pClassView, "ClassView", "class_icon.bmp", wxBITMAP_TYPE_BMP ); |
919 | pMiniTabArea->AddTab( new wxPanel(), "ResourceView","res_icon.bmp" ); | |
920 | pMiniTabArea->AddTab( new wxPanel(), "FileView", "file_icon.bmp" ); | |
921 | pMiniTabArea->AddTab( new wxPanel(), "InfoView", "help_icon.bmp" ); | |
922 | pMiniTabArea->AddTab( CreateTxtCtrl( helloworld_src, | |
923 | pMiniTabArea), "HelloWorld", "help_icon.bmp" ); | |
da9531bf | 924 | #endif |
bd9396d5 HH |
925 | // now create "output" window |
926 | ||
927 | wxPaggedWindow* pTabbedArea = new wxPaggedWindow(); | |
928 | ||
929 | pTabbedArea->Create( pParent, -1 ); | |
930 | ||
931 | wxPanel* pSheet3 = new wxPanel(); | |
932 | pSheet3->Create( pTabbedArea, -1 ); | |
933 | pSheet3->Show(FALSE); | |
934 | ||
935 | pTabbedArea->AddTab( CreateTxtCtrl("build", pTabbedArea), "Build", "" ); | |
936 | pTabbedArea->AddTab( CreateTxtCtrl("debug", pTabbedArea), "Debug", "" ); | |
da9531bf | 937 | pTabbedArea->AddTab( pSheet3, "Find in Files!", &wxBitmap("file_icon") ); |
bd9396d5 HH |
938 | pTabbedArea->AddTab( CreateTxtCtrl("profile", pTabbedArea), "Profile", "" ); |
939 | ||
940 | layout.AddBar( new StartButton95(pParent), sizes5, wxTOP, 0, 0, "Start..." ); | |
941 | layout.AddBar( pMiniTabArea, sizes4, wxLEFT, 0, 0, "Project Workplace" ); | |
942 | layout.AddBar( pTabbedArea, sizes4, wxBOTTOM, 0, 50, "Output" ); | |
943 | ||
944 | return pSheet3; | |
945 | } | |
946 | ||
947 | void MyFrame::DropInSomeBars( int layoutNo ) | |
948 | { | |
949 | /* create once... and forget! */ | |
950 | ||
951 | // setup dimension infos for various bar shapes | |
952 | ||
953 | int cbWidth = 90; | |
954 | int cbHeight = 30; | |
955 | ||
956 | if ( layoutNo == SECOND_LAYOUT ) cbHeight = 60; | |
957 | ||
958 | wxFrameLayout& layout = *mLayouts[layoutNo]; | |
959 | ||
960 | cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally | |
961 | cbWidth,cbHeight, // when docked vertically | |
962 | cbWidth,cbHeight, // when floated | |
963 | TRUE // true - bar is fixed-size | |
964 | ); | |
965 | ||
966 | cbWidth = 120; | |
967 | ||
968 | cbDimInfo sizes1( cbWidth,cbHeight, | |
969 | cbWidth,cbHeight, | |
970 | cbWidth,cbHeight, FALSE ); // false - bar is "flexible" | |
971 | ||
972 | ||
973 | cbWidth = 120; | |
974 | cbHeight = 40; | |
975 | ||
976 | cbDimInfo sizes3( cbWidth,cbHeight, | |
977 | cbWidth,cbHeight, | |
978 | cbWidth,cbHeight, TRUE ); // -/- | |
979 | ||
980 | cbWidth = 200; | |
981 | cbHeight = 150; | |
982 | ||
983 | cbDimInfo sizes4( cbWidth,cbHeight, | |
984 | cbWidth,cbHeight, | |
985 | cbWidth,cbHeight, FALSE ); // -/- | |
986 | ||
987 | cbWidth = 63; | |
988 | cbHeight = 31; | |
989 | ||
990 | cbDimInfo sizes5( cbWidth,cbHeight, | |
991 | cbHeight,cbWidth, | |
992 | cbWidth,cbHeight, TRUE, | |
993 | 3, // vertical gap (bar border) | |
994 | 3 // horizontal gap (bar border) | |
995 | ); // -/- | |
996 | ||
997 | ||
998 | if ( layoutNo == FIRST_LAYOUT ) | |
999 | { | |
1000 | // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info) | |
1001 | ||
1002 | wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm); | |
1003 | ||
1004 | pGreenOne->SetBackgroundColour( wxColour(128,255,128) ); | |
1005 | ||
1006 | layout.AddBar( pGreenOne, sizes, wxTOP, 0, 50, "Bar1", TRUE ); | |
1007 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, wxTOP, 2, 50, "Bar2", TRUE ); | |
1008 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, wxBOTTOM, 2, 50, "Bar3", TRUE ); | |
1009 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, wxLEFT, 2, 50, "Bar4", TRUE ); | |
1010 | layout.AddBar( new MyTestPanel(mpInternalFrm), sizes1, wxCBAR_HIDDEN, 2, 50, "Super-Bar", TRUE ); | |
1011 | } | |
1012 | else | |
1013 | if ( layoutNo == SECOND_LAYOUT ) | |
1014 | { | |
1015 | // show off various wx-controls in the second layout | |
1016 | ||
1017 | layout.AddBar( CreateTxtCtrl(), sizes, wxTOP, 0, 50, "Fixed text Area&0" ); | |
1018 | layout.AddBar( CreateButton("OK"), sizes, wxTOP, 0, 100, "First Button" ); | |
1019 | layout.AddBar( CreateTxtCtrl(), sizes1, wxBOTTOM, 0, 50, "First Tree" ); | |
1020 | layout.AddBar( CreateTreeCtrl("Root"), sizes1, wxLEFT, 0, 0, "TreeCtrl Window" ); | |
1021 | layout.AddBar( CreateChoice("Choice 1"), sizes3, wxTOP, 0, 0, "Choice 1 (buggy)", FALSE, wxCBAR_HIDDEN ); | |
1022 | layout.AddBar( CreateChoice("Choice 2"), sizes3, wxTOP, 0, 0, "Choice 2 (buggy)", FALSE, wxCBAR_HIDDEN ); | |
1023 | layout.AddBar( CreateTreeCtrl("X-Files"), sizes1, wxRIGHT, 0, 100, "X-Files" ); | |
1024 | layout.AddBar( CreateTxtCtrl("smaller1"), sizes3, wxTOP, 0, 50, "smaller Area1" ); | |
1025 | layout.AddBar( CreateTxtCtrl("smaller2"), sizes3, wxTOP, 0, 50, "sm&ller Area2" ); | |
1026 | } | |
1027 | else | |
1028 | if ( layoutNo == THIRD_LAYOUT ) | |
1029 | { | |
1030 | #ifdef __WXGTK__ | |
1031 | ||
1032 | cbCommonPaneProperties props; | |
1033 | layout.GetPaneProperties( props ); | |
1034 | props.mRealTimeUpdatesOn = FALSE; // real-time OFF for gtk!!! | |
1035 | layout.SetPaneProperties( props, wxALL_PANES ); | |
1036 | ||
1037 | #endif | |
1038 | ||
1039 | layout.AddBar( CreateTxtCtrl("Tool1"), sizes3, wxTOP, 0, 50, "Fixed text Area1" ); | |
1040 | layout.AddBar( CreateTxtCtrl("Tool2"), sizes3, wxTOP, 0, 50, "Fixed text Area2" ); | |
1041 | layout.AddBar( CreateTxtCtrl("Tool3"), sizes3, wxTOP, 0, 50, "Fixed text Area3" ); | |
1042 | layout.AddBar( CreateTxtCtrl("Tool4"), sizes3, wxTOP, 1, 50, "Fixed text Area4" ); | |
1043 | layout.AddBar( CreateTxtCtrl("Tool5"), sizes3, wxTOP, 1, 50, "Fixed text Area5" ); | |
1044 | layout.AddBar( CreateTxtCtrl("Tool6"), sizes3, wxTOP, 1, 50, "Fixed text Area6" ); | |
1045 | layout.AddBar( CreateTxtCtrl("Tool7"), sizes3, wxTOP, 2, 250, "Fixed text Area7" ); | |
1046 | ||
1047 | cbDimInfo sizes10(175,35, // when docked horizontally | |
1048 | 175,38, // when docked vertically | |
1049 | 170,35, // when floated | |
1050 | TRUE, // the bar is not fixed-size | |
1051 | 4, // vertical gap (bar border) | |
1052 | 4, // horizontal gap (bar border) | |
1053 | new cbDynToolBarDimHandler() | |
1054 | ); | |
1055 | ||
1056 | wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); | |
1057 | ||
1058 | pToolBar->Create( mpInternalFrm, -1 ); | |
1059 | ||
1060 | // 1001-1006 ids of command events fired by added tool-buttons | |
da9531bf RS |
1061 | #ifdef __WXMSW__ |
1062 | pToolBar->AddTool( 1001, wxBitmap("new_icon") ); | |
1063 | pToolBar->AddTool( 1002, wxBitmap("open_icon") ); | |
1064 | pToolBar->AddTool( 1003, wxBitmap("save_icon") ); | |
1065 | ||
1066 | pToolBar->AddTool( 1004, wxBitmap("cut_icon") ); | |
1067 | pToolBar->AddTool( 1005, wxBitmap("copy_icon") ); | |
1068 | pToolBar->AddTool( 1006, wxBitmap("paste_icon") ); | |
1069 | #else | |
bd9396d5 HH |
1070 | pToolBar->AddTool( 1001, "new.bmp" ); |
1071 | pToolBar->AddTool( 1002, "open.bmp" ); | |
1072 | pToolBar->AddTool( 1003, "save.bmp" ); | |
1073 | ||
1074 | pToolBar->AddTool( 1004, "cut.bmp" ); | |
1075 | pToolBar->AddTool( 1005, "copy.bmp" ); | |
1076 | pToolBar->AddTool( 1006, "paste.bmp" ); | |
da9531bf | 1077 | #endif |
bd9396d5 HH |
1078 | layout.AddBar( pToolBar, // bar window (can be NULL) |
1079 | sizes10, wxTOP, // alignment ( 0-top,1-bottom, etc) | |
1080 | 0, // insert into 0th row (vert. position) | |
1081 | 0, // offset from the start of row (in pixels) | |
1082 | "Real-Toolbar", // name to refere in customization pop-ups | |
1083 | FALSE | |
1084 | ); | |
1085 | ||
1086 | ||
1087 | ||
1088 | // create first "developement" layout | |
1089 | ||
1090 | AddSearchToolbars( layout, mpInternalFrm); | |
1091 | ||
1092 | wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm); | |
1093 | ||
1094 | // create another ***secreat developement*** layout inside | |
1095 | // the third sheet of the outter one's output bar | |
1096 | ||
1097 | mpNestedLayout = | |
1098 | ||
1099 | new wxFrameLayout( pSheet3, | |
1100 | CreateTxtCtrl("\"Mobils in Mobile\" --C.Nemo",pSheet3), FALSE ); | |
1101 | ||
1102 | CreateDevLayout( *mpNestedLayout, pSheet3 ); | |
1103 | ||
1104 | mpNestedLayout->Activate(); | |
1105 | } | |
1106 | } | |
1107 | ||
1108 | void MyFrame::CreateLayout( int layoutNo ) | |
1109 | { | |
1110 | wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, FALSE ); | |
1111 | ||
1112 | if ( layoutNo == THIRD_LAYOUT ) | |
1113 | { | |
1114 | pLayout->PushDefaultPlugins(); | |
1115 | pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars | |
1116 | #ifdef __WXGTK__ | |
1117 | pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
1118 | #endif | |
1119 | pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); | |
1120 | } | |
1121 | ||
1122 | mLayouts[layoutNo] = pLayout; | |
1123 | ||
1124 | DropInSomeBars( layoutNo ); | |
1125 | } | |
1126 | ||
1127 | void MyFrame::RemoveLayout( int layoutNo ) | |
1128 | { | |
1129 | wxFrameLayout* pLayout = mLayouts[layoutNo]; | |
1130 | ||
1131 | if ( !pLayout ) return; | |
1132 | ||
1133 | pLayout->HideBarWindows(); | |
1134 | ||
1135 | // destroy nested layout first | |
1136 | ||
1137 | if ( layoutNo == THIRD_LAYOUT ) | |
1138 | { | |
1139 | if ( mpNestedLayout ) delete mpNestedLayout; | |
1140 | mpNestedLayout = NULL; | |
1141 | } | |
1142 | ||
1143 | // NOTE:: bar windows are NOT destroyed automatically by frame-layout | |
1144 | ||
1145 | pLayout->DestroyBarWindows(); | |
1146 | ||
1147 | delete pLayout; | |
1148 | ||
1149 | mLayouts[layoutNo] = NULL; | |
1150 | ||
1151 | Refresh(); | |
1152 | } | |
1153 | ||
1154 | void MyFrame::DestroyEverything() | |
1155 | { | |
1156 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
1157 | ||
1158 | RemoveLayout( i ); | |
1159 | ||
1160 | if ( mpClntWindow ) | |
1161 | { | |
1162 | mpClntWindow->Destroy(); | |
1163 | ||
1164 | mpClntWindow = NULL; | |
1165 | } | |
1166 | } | |
1167 | ||
1168 | void MyFrame::SyncMenuBarItems() | |
1169 | { | |
1170 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
1171 | ||
1172 | GetMenuBar()->Check( ID_FIRST+i, mActiveLayoutNo == FIRST_LAYOUT+i ); | |
1173 | ||
1174 | GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave ); | |
1175 | } | |
1176 | ||
1177 | void MyFrame::ActivateLayout( int layoutNo ) | |
1178 | { | |
1179 | if ( layoutNo == mActiveLayoutNo ) return; | |
1180 | ||
1181 | if ( mLayouts[mActiveLayoutNo] ) | |
1182 | ||
1183 | mLayouts[mActiveLayoutNo]->Deactivate(); | |
1184 | ||
1185 | mActiveLayoutNo = layoutNo; | |
1186 | ||
1187 | if ( mLayouts[mActiveLayoutNo] ) | |
1188 | ||
1189 | mLayouts[mActiveLayoutNo]->Activate(); | |
1190 | else | |
1191 | Refresh(); | |
1192 | ||
1193 | SyncMenuBarItems(); | |
1194 | } | |
1195 | ||
1196 | void MyFrame::SerializeMe( wxObjectStorage& store ) | |
1197 | { | |
1198 | store.AddInitialRef( this ); | |
1199 | store.AddInitialRef( mpInternalFrm ); | |
1200 | store.AddInitialRef( &mAboutBox ); | |
1201 | store.AddInitialRef( &mImageList ); | |
1202 | ||
1203 | store.XchgInt ( mActiveLayoutNo ); | |
1204 | store.XchgBool( mAutoSave ); | |
1205 | ||
1206 | store.XchgObjPtr( (wxObject**) &mpClntWindow ); | |
1207 | ||
1208 | for( int i = 0; i != MAX_LAYOUTS; ++i ) | |
1209 | { | |
1210 | if ( i == THIRD_LAYOUT ) | |
1211 | ||
1212 | store.XchgObjPtr( (wxObject**) &(mpNestedLayout) ); | |
1213 | ||
1214 | store.XchgObjPtr( (wxObject**) &(mLayouts[i]) ); | |
1215 | } | |
1216 | ||
1217 | store.XchgObjPtr( (wxObject**) &(mpAboutBoxLayout) ); | |
1218 | ||
1219 | store.Finalize(); // finish serialization | |
1220 | } | |
1221 | ||
1222 | #ifdef __HACK_MY_MSDEV40__ | |
1223 | ||
1224 | ////////////// new 2.0-magic (linker errors...) //////////////// | |
1225 | ||
1226 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) | |
1227 | { | |
1228 | wxCHECK_MSG( m_frameToolBar == NULL, FALSE, | |
1229 | "recreating toolbar in wxFrame" ); | |
1230 | ||
1231 | wxToolBar* toolBar = OnCreateToolBar(style, id, name); | |
1232 | if (toolBar) | |
1233 | { | |
1234 | SetToolBar(toolBar); | |
1235 | PositionToolBar(); | |
1236 | return toolBar; | |
1237 | } | |
1238 | else | |
1239 | { | |
1240 | return NULL; | |
1241 | } | |
1242 | } | |
1243 | ||
1244 | void foo( double& d ) | |
1245 | { | |
1246 | ++d; | |
1247 | } | |
1248 | ||
1249 | wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) | |
1250 | { | |
1251 | double dd = 5; | |
1252 | ||
1253 | return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name); | |
1254 | } | |
1255 | ||
1256 | #endif |