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