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