]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/fl/fl_demo2.cpp
Restored the accidentally deleted "return true;" at the end of the Show method from...
[wxWidgets.git] / contrib / samples / fl / fl_demo2.cpp
CommitLineData
03206f17
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by: Sebastian Haase (June 21, 2001)
6// Created: 04/11/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
03206f17
VS
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20#include "wx/wx.h"
21#endif
22
be5a51fb 23// wxWidgets headers.
03206f17
VS
24#include "wx/treectrl.h"
25#include "wx/imaglist.h"
2a21ac15 26#include "wx/notebook.h"
03206f17
VS
27
28// fl headers.
29#include "wx/fl/controlbar.h"
30#include "wx/fl/rowlayoutpl.h"
31#include "wx/fl/antiflickpl.h"
32#include "wx/fl/bardragpl.h"
33#include "wx/fl/cbcustom.h"
34#include "wx/fl/rowdragpl.h"
35
36// some extra fl plugins.
37#include "wx/fl/barhintspl.h"
38#include "wx/fl/hintanimpl.h"
39
40#include "wx/fl/dyntbar.h"
41#include "wx/fl/dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
42
43#include "fl_demo2.h"
44
45/***** Implementation for class MyApp *****/
46
47// Create a new application object
48IMPLEMENT_APP (MyApp)
49
50// `Main program' equivalent, creating windows and returning main app frame
51bool MyApp::OnInit(void)
52{
53 // Create the main frame window
be5a51fb 54 MyFrame *frame = new MyFrame(NULL, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540);
2a21ac15 55
03206f17
VS
56 // Give it an icon
57#ifdef __WINDOWS__
05aa1fc7 58 frame->SetIcon(wxIcon(wxT("mondrian")));
03206f17
VS
59#endif
60#ifdef __X__
05aa1fc7 61 frame->SetIcon(wxIcon(wxT("aiai.xbm")));
03206f17 62#endif
2a21ac15 63
03206f17
VS
64 // Make a menubar
65 wxMenu *file_menu = new wxMenu;
66 wxMenu *active_menu = new wxMenu;
2a21ac15 67
05aa1fc7
JS
68 file_menu->Append( ID_LOAD, _("&Load layouts") );
69 file_menu->Append( ID_STORE, _("&Store layouts") );
03206f17 70 file_menu->AppendSeparator();
2a21ac15
DS
71
72 file_menu->Append( ID_AUTOSAVE, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK );
03206f17 73 file_menu->AppendSeparator();
2a21ac15 74
05aa1fc7
JS
75 file_menu->Append(MINIMAL_ABOUT, _("A&bout !"));
76 file_menu->Append(MINIMAL_QUIT, _("E&xit\tTab"));
2a21ac15 77
05aa1fc7 78 //active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") );
03206f17 79 //active_menu->AppendSeparator();
2a21ac15 80
05aa1fc7
JS
81 active_menu->Append( ID_REMOVE, _("&Remove Active") );
82 active_menu->Append( ID_REMOVEALL, _("Remove &All") );
83 active_menu->Append( ID_RECREATE, _("Re&create") );
03206f17 84 active_menu->AppendSeparator();
2a21ac15
DS
85
86 active_menu->Append( ID_FIRST, _("Activate f&irst layout \tF1"), _("activate it"), wxITEM_CHECK );
87 active_menu->Append( ID_SECOND, _("Activate &second layout\tF2"), _("activate it"), wxITEM_CHECK );
88 active_menu->Append( ID_THIRD, _("Activate &third layout\tF3"), _("activate it"), wxITEM_CHECK );
89
03206f17 90 wxMenuBar *menu_bar = new wxMenuBar;
2a21ac15 91
05aa1fc7
JS
92 menu_bar->Append(file_menu, _("&File"));
93 menu_bar->Append(active_menu, _("Active &Layout"));
2a21ac15 94
d96cdd4a 95#if wxUSE_STATUSBAR
03206f17 96 frame->CreateStatusBar(3);
d96cdd4a 97#endif // wxUSE_STATUSBAR
2a21ac15 98
03206f17 99 frame->SetMenuBar(menu_bar);
2a21ac15 100
03206f17 101 frame->SyncMenuBarItems();
2a21ac15 102
03206f17 103 // Show the frame
2a21ac15
DS
104 frame->Show(true);
105
03206f17 106 SetTopWindow(frame);
2a21ac15
DS
107
108 return true;
03206f17
VS
109}
110
111MyFrame::~MyFrame()
112{
113 // frame-layouts is not a windows (objects), thus should
114 // be cleaned up manually
2a21ac15 115
03206f17
VS
116 for( int i = 0; i != MAX_LAYOUTS; ++i )
117 {
2a21ac15 118 if ( mLayouts[i] )
03206f17
VS
119 delete mLayouts[i];
120 }
2a21ac15
DS
121
122 if ( mpNestedLayout )
03206f17 123 delete mpNestedLayout;
2a21ac15 124 if ( mpAboutBoxLayout )
03206f17
VS
125 delete mpAboutBoxLayout;
126}
127
128/***** Implementation for class MyFrame *****/
129
130BEGIN_EVENT_TABLE(MyFrame, wxFrame)
131 EVT_MENU( MINIMAL_QUIT, MyFrame::OnQuit )
132 EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout )
133
134 EVT_MENU( ID_LOAD, MyFrame::OnLoad )
135 EVT_MENU( ID_STORE, MyFrame::OnStore )
136 EVT_MENU( ID_AUTOSAVE, MyFrame::OnAutoSave )
137 //EVT_MENU( ID_SETTINGS, MyFrame::OnSettings )
138 EVT_MENU( ID_REMOVE, MyFrame::OnRemove )
139 EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll )
140 EVT_MENU( ID_RECREATE, MyFrame::OnRecreate )
141 EVT_MENU( ID_FIRST, MyFrame::OnFirst )
142 EVT_MENU( ID_SECOND, MyFrame::OnSecond )
143 EVT_MENU( ID_THIRD, MyFrame::OnThird )
144
145 EVT_BUTTON( ID_SAY_ITSOK, MyFrame::OnSayItsOk )
146 EVT_BUTTON( ID_BTN_YES, MyFrame::OnBtnYes )
147 EVT_BUTTON( ID_BTN_NO, MyFrame::OnBtnNo )
148 EVT_BUTTON( ID_BTN_ESC, MyFrame::OnBtnEsc )
149
150 EVT_CHAR_HOOK( MyFrame::OnChar )
151END_EVENT_TABLE()
152
153// My frame constructor
154
05aa1fc7 155MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h)
2a21ac15 156 : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
03206f17
VS
157 mpNestedLayout( NULL ),
158 mpAboutBoxLayout( NULL ),
159
160 mActiveLayoutNo( FIRST_LAYOUT ),
2a21ac15
DS
161 mAutoSave( true ),
162 mSavedAlready( false ),
03206f17
VS
163 mpClntWindow( NULL ),
164
2a21ac15 165 mImageList( 16,16, false, 2 )
03206f17 166{
8552e6f0
MB
167 int i;
168
03206f17 169 mpInternalFrm = (wxPanel*)this;
2a21ac15
DS
170
171 mAboutBox.Create( this, wxID_ANY, _T("About box in wxWidgets style..."),
03206f17
VS
172 wxDefaultPosition,
173 wxSize( 385,220),
2a21ac15
DS
174 wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL );
175
176 for( i = 0; i != MAX_LAYOUTS; ++i )
03206f17 177 mLayouts[i] = NULL;
2a21ac15 178
03206f17 179 // image-list is one of the few objects which
2a21ac15 180 // currently cannot be serialized, create it first
03206f17 181 // and use it as initial reference (IR)
2a21ac15 182
03206f17 183 wxBitmap bmp1,bmp2;
2a21ac15 184
05aa1fc7
JS
185 if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp") ) )
186 bmp1.LoadFile( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp"), wxBITMAP_TYPE_BMP );
2a21ac15 187
05aa1fc7
JS
188 if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp") ) )
189 bmp2.LoadFile( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp"), wxBITMAP_TYPE_BMP );
2a21ac15 190
03206f17
VS
191 mImageList.Add( bmp1 );
192 mImageList.Add( bmp2 );
2a21ac15 193
03206f17 194 InitAboutBox();
2a21ac15 195
03206f17 196 // create multiple layouts
2a21ac15 197
03206f17 198 mpNestedLayout = 0;
2a21ac15 199
05aa1fc7 200 mpClntWindow = CreateTxtCtrl(wxT("client window"));
2a21ac15 201
03206f17
VS
202 // Create all layouts
203 for( i = 0; i != MAX_LAYOUTS; ++i )
c82c42d4 204 {
03206f17
VS
205 CreateLayout( i );
206 }
207 // hide others
208 for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i )
209 {
210 mLayouts[i]->HideBarWindows();
211 }
2a21ac15
DS
212
213 // activate first one
03206f17
VS
214 mLayouts[FIRST_LAYOUT]->Activate();
215 mActiveLayoutNo = FIRST_LAYOUT;
216}
217
218/*** event handlers ***/
219
220bool MyFrame::OnClose(void)
221{
2a21ac15 222 // USEFUL TRICK:: avoids flickering of application's frame
03206f17 223 // when closing NN windows on exit:
2a21ac15
DS
224
225 Show(false);
226
03206f17
VS
227 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
228 {
229 }
230 else
231 {
232 wxCommandEvent evt;
2a21ac15 233 OnStore(evt);
03206f17 234 }
2a21ac15 235
03206f17 236 mAboutBox.Destroy();
2a21ac15
DS
237 Destroy();
238
239 return true;
03206f17
VS
240}
241
8552e6f0 242void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) )
03206f17 243{
05aa1fc7 244 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
03206f17
VS
245}
246
8552e6f0 247void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) )
03206f17 248{
05aa1fc7 249 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
03206f17
VS
250}
251
8552e6f0 252void MyFrame::OnAutoSave( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
253{
254 mAutoSave = !mAutoSave;
2a21ac15 255
03206f17 256 wxCommandEvent evt;
2a21ac15
DS
257 OnStore(evt);
258
03206f17
VS
259 SyncMenuBarItems();
260}
261
8552e6f0 262void MyFrame::OnRemove( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
263{
264 RemoveLayout( mActiveLayoutNo );
2a21ac15 265
03206f17
VS
266 Refresh();
267}
268
8552e6f0 269void MyFrame::OnRemoveAll( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
270{
271 for( int i = 0; i != MAX_LAYOUTS; ++i )
2a21ac15 272 {
03206f17
VS
273 RemoveLayout( i );
274 }
275
276 Refresh();
277}
278
279
280void MyFrame::OnRecreate( wxCommandEvent& event )
281{
282 OnRemove( event ); // first destroy active layout
2a21ac15 283
03206f17 284 CreateLayout( mActiveLayoutNo );
2a21ac15 285
03206f17
VS
286 mLayouts[mActiveLayoutNo]->Activate();
287}
288
8552e6f0 289void MyFrame::OnFirst( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
290{
291 ActivateLayout( FIRST_LAYOUT );
292}
293
8552e6f0 294void MyFrame::OnSecond( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
295{
296 ActivateLayout( SECOND_LAYOUT );
297}
298
8552e6f0 299void MyFrame::OnThird( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
300{
301 ActivateLayout( THIRD_LAYOUT );
302}
303
8552e6f0 304void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
03206f17 305{
2a21ac15 306 // USEFUL TRICK:: avoids flickering of application's frame
03206f17 307 // when closing NN windows on exit:
2a21ac15
DS
308
309 Show(false);
310
03206f17
VS
311 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
312 {
313 }
314 else
315 {
316 wxCommandEvent evt;
2a21ac15 317 OnStore(evt);
03206f17 318 }
2a21ac15 319
03206f17
VS
320 Destroy();
321}
322
8552e6f0 323void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
03206f17
VS
324{
325 wxFont font;
326#ifdef __WXMSW__
05aa1fc7 327 font.SetFaceName(wxT("MS Sans Serif"));
03206f17
VS
328#else
329 font.SetFamily( wxSWISS );
330#endif
2a21ac15 331
03206f17
VS
332 font.SetStyle( wxSLANT );
333 font.SetWeight( wxNORMAL );
334 font.SetPointSize( 8 );
2a21ac15 335
03206f17
VS
336#ifdef __WXMSW__
337 font.RealizeResource();
338#endif
2a21ac15 339
03206f17 340 mAboutBox.Center( wxBOTH );
2a21ac15
DS
341 mAboutBox.Show(true);
342
03206f17
VS
343}
344
345void MyFrame::OnChar( wxKeyEvent& event )
346{
347 wxCommandEvent evt;
2a21ac15 348
03206f17
VS
349 if ( event.m_keyCode == WXK_F1 )
350 {
2a21ac15 351 OnFirst( evt );
03206f17
VS
352 }
353 else
354 {
355 if ( event.m_keyCode == WXK_F2 )
356 {
2a21ac15 357 OnSecond( evt );
03206f17
VS
358 }
359 else
360 {
361 if ( event.m_keyCode == WXK_F3 )
2a21ac15
DS
362 {
363 OnThird( evt );
03206f17
VS
364 }
365 if ( event.m_keyCode == WXK_F4 && !event.AltDown() )
2a21ac15 366 {
03206f17 367 // "AI" :-)
05aa1fc7 368 wxMessageBox(_("There are only 3 layouts in this demo :-("));
03206f17
VS
369 }
370 else
371 {
372 if ( event.m_keyCode == WXK_TAB )
373 {
2a21ac15 374 // USEFUL TRICK:: avoids flickering of application's frame
03206f17 375 // when closing NN windows on exit:
2a21ac15
DS
376
377 Show(false);
378
03206f17
VS
379 if ( (mAutoSave && mSavedAlready) || !mAutoSave )
380 {
381 }
382 else
383 {
384 wxCommandEvent evt;
2a21ac15 385 OnStore(evt);
03206f17 386 }
2a21ac15 387
03206f17
VS
388 Destroy();
389 }
390 else
391 {
392 event.Skip();
393 }
394 }
395 }
396 }
397}
398
8552e6f0 399void MyFrame::OnSayItsOk( wxCommandEvent& WXUNUSED(event) )
03206f17 400{
05aa1fc7 401 wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
03206f17
VS
402}
403
8552e6f0 404void MyFrame::OnBtnYes( wxCommandEvent& WXUNUSED(event) )
03206f17 405{
2a21ac15 406 mAboutBox.Show(false);
03206f17
VS
407}
408
8552e6f0 409void MyFrame::OnBtnNo( wxCommandEvent& WXUNUSED(event) )
03206f17 410{
2a21ac15 411 mAboutBox.Show(false);
03206f17
VS
412}
413
8552e6f0 414void MyFrame::OnBtnEsc( wxCommandEvent& WXUNUSED(event) )
03206f17 415{
2a21ac15 416 mAboutBox.Show(false);
03206f17
VS
417}
418
419/*** helper methods ***/
420
421void MyFrame::InitAboutBox()
422{
423 wxPanel* pArea = new wxPanel();
2a21ac15
DS
424
425 pArea->Create( &mAboutBox, wxID_ANY );
426
427 new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."),
03206f17 428 wxPoint(10, 10) );
2a21ac15
DS
429
430 new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"),
03206f17 431 wxPoint(10, 30) );
2a21ac15
DS
432
433 new wxStaticText(pArea, wxID_ANY, _("<mailto:alex@soften.ktu.lt>"),
03206f17 434 wxPoint(10, 50) );
2a21ac15
DS
435
436 mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true );
437
03206f17 438 wxFrameLayout& layout = *mpAboutBoxLayout;
2a21ac15 439
03206f17
VS
440 cbDimInfo sizes( 90,40, // when docked horizontally
441 45,55, // when docked vertically
442 90,40, // when floated
2a21ac15
DS
443 true, 4, 4 // true - bar is fixed-size
444 );
445
446
05aa1fc7
JS
447 wxButton* pYes = CreateButton(_("&Yes"), &mAboutBox, ID_SAY_ITSOK );
448 wxButton* pNo = CreateButton(_("&No"), &mAboutBox, ID_BTN_NO );
449 wxButton* pEsc = CreateButton(_("Cancel"), &mAboutBox, ID_BTN_ESC );
2a21ac15 450
05aa1fc7
JS
451 layout.AddBar( pEsc, sizes, FL_ALIGN_BOTTOM, 0, 20, _("cancel button"));
452 layout.AddBar( pNo, sizes, FL_ALIGN_BOTTOM, 0, 20, _("no button"));
453 layout.AddBar( pYes, sizes, FL_ALIGN_BOTTOM, 0, 20, _("yes button"));
2a21ac15 454
03206f17
VS
455 layout.mBorderPen.SetColour( 192, 192, 192 );
456 layout.SetMargins( 15, 15, 15, 15, wxALL_PANES );
2a21ac15 457
03206f17 458 cbCommonPaneProperties props;
2a21ac15 459
03206f17 460 layout.GetPaneProperties( props, FL_ALIGN_TOP );
2a21ac15
DS
461
462 props.mShow3DPaneBorderOn = false;
463
03206f17 464 layout.SetPaneProperties( props, wxALL_PANES );
2a21ac15 465
03206f17 466 layout.Activate();
2a21ac15 467
03206f17
VS
468 pYes->SetDefault();
469 pYes->SetFocus();
470}
471
2a21ac15 472wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent )
03206f17
VS
473{
474 return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm,
2a21ac15 475 wxID_ANY, txt, wxDefaultPosition, wxDefaultSize,
03206f17
VS
476 wxTE_MULTILINE );
477}
478
479wxButton* MyFrame::CreateButton( const wxString& label,
480 wxWindow* pParent, long id )
481{
2a21ac15 482 return new wxButton( (pParent)?pParent : mpInternalFrm, id,
03206f17
VS
483 label, wxPoint( 0,0 ), wxSize( 0,0 ) );
484}
485
486wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label )
487{
2a21ac15
DS
488 wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, wxID_ANY );
489
63a24a91 490 const wxTreeItemId rootid = pTree->AddRoot(label);
2a21ac15 491
63a24a91 492 if ( label.StartsWith(_T("X")) )
03206f17 493 {
63a24a91
WS
494 pTree->AppendItem(rootid, _("Scully"));
495 pTree->AppendItem(rootid, _("Mulder"));
03206f17
VS
496 }
497 else
498 {
63a24a91
WS
499 pTree->AppendItem(rootid, _("Leaf1"));
500 pTree->AppendItem(rootid, _("Leaf2"));
03206f17 501 }
2a21ac15 502
03206f17
VS
503 return pTree;
504}
505
506wxChoice* MyFrame::CreateChoice( const wxString& txt )
507{
508 wxString choice_strings[5];
2a21ac15 509
03206f17 510 choice_strings[0] = txt;
05aa1fc7
JS
511 choice_strings[1] = _("Julian");
512 choice_strings[2] = _("Hattie");
513 choice_strings[3] = _("Ken");
514 choice_strings[4] = _("Dick");
2a21ac15
DS
515
516 wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition,
03206f17 517 wxDefaultSize, 5, choice_strings);
2a21ac15 518
03206f17 519 choice->SetSelection(0);
2a21ac15 520
03206f17
VS
521 return choice;
522}
523
524// helper
525
8552e6f0 526void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* WXUNUSED(pParent) )
03206f17 527{
2a21ac15
DS
528 cbDimInfo sizes2( 275,38, // when docked horizontally
529 45,275, // when docked vertically
530 80,30, // when floated
531 true, // the bar is fixed-size
03206f17
VS
532 4, // vertical gap (bar border)
533 4, // horizontal gap (bar border)
534 new cbDynToolBarDimHandler()
2a21ac15
DS
535 );
536
537 cbDimInfo sizes3( 275,55, // when docked horizontally
538 275,60, // when docked vertically
539 45,130, // when floated
540 true, // the bar is fixed-size
03206f17
VS
541 4, // vertical gap (bar border)
542 4, // horizontal gap (bar border)
543 new cbDynToolBarDimHandler()
2a21ac15
DS
544 );
545
546 cbDimInfo sizes4( 430,35, // when docked horizontally
547 44,375, // when docked vertically
548 80,100, // when floated
549 true, // the bar is fixed-size
03206f17
VS
550 4, // vertical gap (bar border)
551 4, // horizontal gap (bar border)
552 new cbDynToolBarDimHandler()
2a21ac15
DS
553 );
554
555 wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
556
557 wxChoice* pChoice = new wxChoice( pTBar2, wxID_ANY, wxDefaultPosition, wxSize( 140,25 ) );
558
03206f17 559 pTBar2->AddTool( 1, pChoice );
05aa1fc7 560 pTBar2->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("search.bmp") );
03206f17 561 //pTBar2->AddSeparator();
05aa1fc7
JS
562 pTBar2->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp") );
563 pTBar2->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp") );
564 pTBar2->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp") );
2a21ac15
DS
565
566 wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
567
05aa1fc7
JS
568 pTBar3->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("open.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
569 pTBar3->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("save.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save ")) );
570 pTBar3->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("saveall.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save All ")) );
03206f17 571 //pTBar3->AddSeparator();
05aa1fc7
JS
572 pTBar3->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("cut.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
573 pTBar3->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("copy.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Copy ")) );
574 pTBar3->AddTool( 6, wxString(wxT(BMP_DIR)) + wxT("paste.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Paste ")) );
2a21ac15 575
03206f17 576#ifdef __WXMSW__
2a21ac15 577 pTBar3->EnableTool( 2, false );
03206f17 578#endif
2a21ac15
DS
579
580 wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
581
582 pTBar4->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Bookmarks ")), true );
583 pTBar4->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Next bookmark ")), true );
584 pTBar4->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Prev bookmark ")), true );
03206f17 585 //pTBar4->AddSeparator();
2a21ac15
DS
586 pTBar4->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Search ")), true );
587
03206f17 588#ifdef __WXMSW__
2a21ac15 589 pTBar4->EnableTool( 4, false );
03206f17 590#endif
2a21ac15
DS
591
592 layout.AddBar( pTBar2,
593 sizes2, FL_ALIGN_TOP,
594 0,
595 0,
596 wxT("Search"),
597 true
03206f17 598 );
2a21ac15
DS
599
600 layout.AddBar( pTBar3,
601 sizes3, FL_ALIGN_BOTTOM,
602 0,
603 0,
604 wxT("Titled"),
605 true
03206f17 606 );
2a21ac15
DS
607
608 layout.AddBar( pTBar4,
609 sizes4, FL_ALIGN_BOTTOM,
610 1,
611 0,
612 wxT("Bookmarks"),
613 true
03206f17
VS
614 );
615}
616
617wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
618{
619 bool isNested = (pParent != mpInternalFrm);
2a21ac15 620
0423ae97 621 // check if we're creating nested layout
03206f17
VS
622 if ( isNested )
623 {
624 layout.mBorderPen.SetColour( 128,255,128 );
2a21ac15 625
03206f17
VS
626 // if so, than make border smaller
627 for( int i = 0; i != MAX_PANES; ++i )
628 {
629 cbDockPane& pane = *layout.GetPane( i );
2a21ac15 630
03206f17
VS
631 pane.mTopMargin = 5;
632 pane.mBottomMargin = 5;
633 pane.mLeftMargin = 5;
634 pane.mRightMargin = 5;
635 }
636 }
2a21ac15 637
03206f17
VS
638 int cbWidth = 200;
639 int cbHeight = ( isNested ) ? 50 : 150;
2a21ac15 640
03206f17
VS
641 cbDimInfo sizes4( cbWidth,cbHeight,
642 cbWidth,cbHeight,
2a21ac15
DS
643 cbWidth,cbHeight, false );
644
03206f17
VS
645 cbWidth = 75;
646 cbHeight = 31;
2a21ac15 647
03206f17
VS
648 cbDimInfo sizes5( cbWidth,cbHeight,
649 42,65,
2a21ac15 650 cbWidth,cbHeight, true,
03206f17
VS
651 3, // vertical gap (bar border)
652 3 // horizontal gap (bar border)
2a21ac15
DS
653 );
654
03206f17
VS
655 // create "workplace" window in the third layout
656 // SEB: originally here was a wxpp (wxWorkshop) class demotrated
657 // wxTabbedWindow* pMiniTabArea = new wxTabbedWindow();
2a21ac15
DS
658 // pMiniTabArea->Create( pParent, wxID_ANY );
659
660
661 wxTreeCtrl* pClassView = new wxTreeCtrl( pParent, wxID_ANY,
03206f17 662 wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS );
2a21ac15 663
03206f17 664 pClassView->SetImageList( &mImageList );
2a21ac15 665
be5a51fb 666 wxTreeItemId rootId = pClassView->AddRoot( wxT("wxWidgets 2.0 classes"), 0 );
2a21ac15 667
05aa1fc7
JS
668 pClassView->AppendItem( rootId, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
669 pClassView->AppendItem( rootId, _("serializer-classes (grabbed at run-time)"), 0 );
2a21ac15 670
03206f17 671 // now create "output" window
c82c42d4 672 wxNotebook* pTabbedArea = new wxNotebook(pParent, wxID_ANY);
03206f17
VS
673 // SEB: originally here was a wxpp (wxWorkshop) class used
674 // wxPaggedWindow* pTabbedArea = new wxPaggedWindow();
2a21ac15
DS
675 // pTabbedArea->Create( pParent, wxID_ANY );
676
03206f17 677 wxPanel* pSheet3 = new wxPanel();
2a21ac15
DS
678 pSheet3->Create( pTabbedArea, wxID_ANY );
679 pSheet3->Show(false);
680
05aa1fc7
JS
681 pTabbedArea->AddPage( CreateTxtCtrl(wxT("build"), pTabbedArea), wxT("Build"));
682 pTabbedArea->AddPage( CreateTxtCtrl(wxT("debug"), pTabbedArea), wxT("Debug"));
683 pTabbedArea->AddPage( pSheet3, wxT("is THIS recursive - or what !?"));
684 pTabbedArea->AddPage( CreateTxtCtrl(wxT("profile"), pTabbedArea), wxT("Profile"));
2a21ac15 685
05aa1fc7
JS
686 layout.AddBar( new StartButton95(pParent), sizes5, FL_ALIGN_TOP, 0, 0, wxT("Start...") );
687 layout.AddBar( pClassView, sizes4, FL_ALIGN_LEFT, 0, 0, wxT("Project Workplace") );
688 layout.AddBar( pTabbedArea, sizes4, FL_ALIGN_BOTTOM, 0, 50, wxT("Output") );
2a21ac15 689
03206f17
VS
690 return pSheet3;
691}
692
693void MyFrame::DropInSomeBars( int layoutNo )
694{
695 /* create once... and forget! */
2a21ac15 696
03206f17 697 // setup dimension infos for various bar shapes
2a21ac15 698
03206f17
VS
699 int cbWidth = 90;
700 int cbHeight = 30;
2a21ac15
DS
701
702 if ( layoutNo == SECOND_LAYOUT )
03206f17 703 cbHeight = 60;
2a21ac15 704
03206f17 705 wxFrameLayout& layout = *mLayouts[layoutNo];
2a21ac15 706
03206f17
VS
707 cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally
708 cbWidth,cbHeight, // when docked vertically
709 cbWidth,cbHeight, // when floated
2a21ac15
DS
710 true // true - bar is fixed-size
711 );
712
03206f17 713 cbWidth = 120;
2a21ac15 714
03206f17
VS
715 cbDimInfo sizes1( cbWidth,cbHeight,
716 cbWidth,cbHeight,
2a21ac15 717 cbWidth,cbHeight, false ); // false - bar is "flexible"
03206f17
VS
718
719 cbWidth = 120;
720 cbHeight = 40;
2a21ac15 721
03206f17
VS
722 cbDimInfo sizes3( cbWidth,cbHeight,
723 cbWidth,cbHeight,
2a21ac15
DS
724 cbWidth,cbHeight, true ); // -/-
725
03206f17
VS
726 cbWidth = 200;
727 cbHeight = 150;
2a21ac15 728
03206f17
VS
729 cbDimInfo sizes4( cbWidth,cbHeight,
730 cbWidth,cbHeight,
2a21ac15
DS
731 cbWidth,cbHeight, false ); // -/-
732
03206f17
VS
733 cbWidth = 63;
734 cbHeight = 31;
2a21ac15 735
03206f17
VS
736 cbDimInfo sizes5( cbWidth,cbHeight,
737 cbHeight,cbWidth,
2a21ac15 738 cbWidth,cbHeight, true,
03206f17
VS
739 3, // vertical gap (bar border)
740 3 // horizontal gap (bar border)
741 ); // -/-
2a21ac15
DS
742
743
03206f17
VS
744 if ( layoutNo == FIRST_LAYOUT )
745 {
746 // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
2a21ac15 747
03206f17 748 wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm);
2a21ac15 749
03206f17 750 pGreenOne->SetBackgroundColour( wxColour(128,255,128) );
2a21ac15
DS
751
752 layout.AddBar( pGreenOne, sizes, FL_ALIGN_TOP, 0, 50, wxT("Bar1"), true );
753 layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_TOP, 2, 50, wxT("Bar2"), true );
754 layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_BOTTOM, 2, 50, wxT("Bar3"), true );
755 layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_LEFT, 2, 50, wxT("Bar4"), true );
756 layout.AddBar( new MyTestPanel(mpInternalFrm), sizes1, wxCBAR_HIDDEN, 2, 50, wxT("Super-Bar"), true );
03206f17
VS
757 }
758 else
759 {
760 if ( layoutNo == SECOND_LAYOUT )
761 {
762 // show off various wx-controls in the second layout
2a21ac15 763
05aa1fc7
JS
764 layout.AddBar( CreateTxtCtrl(), sizes, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area&0") );
765 layout.AddBar( CreateButton(wxT("OK")), sizes, FL_ALIGN_TOP, 0, 100, wxT("First Button") );
766 layout.AddBar( CreateTxtCtrl(), sizes1, FL_ALIGN_BOTTOM, 0, 50, wxT("First Tree") );
767 layout.AddBar( CreateTreeCtrl(wxT("Root")), sizes1, FL_ALIGN_LEFT, 0, 0, wxT("TreeCtrl Window") );
2a21ac15
DS
768 layout.AddBar( CreateChoice(wxT("Choice 1")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 1 (buggy)"), false, wxCBAR_HIDDEN );
769 layout.AddBar( CreateChoice(wxT("Choice 2")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 2 (buggy)"), false, wxCBAR_HIDDEN );
05aa1fc7
JS
770 layout.AddBar( CreateTreeCtrl(wxT("X-Files")), sizes1, FL_ALIGN_RIGHT, 0, 100, wxT("X-Files") );
771 layout.AddBar( CreateTxtCtrl(wxT("smaller1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("smaller Area1") );
772 layout.AddBar( CreateTxtCtrl(wxT("smaller2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("sm&ller Area2") );
03206f17
VS
773 }
774 else
775 {
776 if ( layoutNo == THIRD_LAYOUT )
777 {
778#if defined(__WXGTK__) || defined(__WXX11__)
779 cbCommonPaneProperties props;
780 layout.GetPaneProperties( props );
2a21ac15 781 props.mRealTimeUpdatesOn = false; // real-time OFF for gtk!!!
03206f17
VS
782 layout.SetPaneProperties( props, wxALL_PANES );
783#endif
2a21ac15 784
05aa1fc7
JS
785 layout.AddBar( CreateTxtCtrl(wxT("Tool1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area1") );
786 layout.AddBar( CreateTxtCtrl(wxT("Tool2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area2") );
787 layout.AddBar( CreateTxtCtrl(wxT("Tool3")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area3") );
788 layout.AddBar( CreateTxtCtrl(wxT("Tool4")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area4") );
789 layout.AddBar( CreateTxtCtrl(wxT("Tool5")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area5") );
790 layout.AddBar( CreateTxtCtrl(wxT("Tool6")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area6") );
791 layout.AddBar( CreateTxtCtrl(wxT("Tool7")), sizes3, FL_ALIGN_TOP, 2,250, wxT("Fixed text Area7") );
2a21ac15
DS
792
793 cbDimInfo sizes10( 175,35, // when docked horizontally
794 175,38, // when docked vertically
795 170,35, // when floated
796 true, // the bar is not fixed-size
03206f17
VS
797 4, // vertical gap (bar border)
798 4, // horizontal gap (bar border)
799 new cbDynToolBarDimHandler()
2a21ac15
DS
800 );
801
03206f17 802 wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
2a21ac15
DS
803
804 pToolBar->Create( mpInternalFrm, wxID_ANY );
805
03206f17 806 // 1001-1006 ids of command events fired by added tool-buttons
2a21ac15 807
05aa1fc7
JS
808 pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") );
809 pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") );
810 pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") );
2a21ac15 811
05aa1fc7
JS
812 pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") );
813 pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") );
814 pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") );
2a21ac15 815
03206f17
VS
816 layout.AddBar( pToolBar, // bar window (can be NULL)
817 sizes10, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
818 0, // insert into 0th row (vert. position)
819 0, // offset from the start of row (in pixels)
05aa1fc7 820 wxT("Real-Toolbar"), // name to refere in customization pop-ups
2a21ac15 821 false
03206f17 822 );
2a21ac15 823
03206f17
VS
824 // create first "developement" layout
825 AddSearchToolbars( layout, mpInternalFrm);
2a21ac15 826
03206f17 827 wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm);
2a21ac15 828
03206f17
VS
829 // create another ***secreat developement*** layout inside
830 // the third sheet of the outter one's output bar
2a21ac15
DS
831
832 mpNestedLayout = new wxFrameLayout( pSheet3,
833 CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3), false );
834
03206f17 835 CreateDevLayout( *mpNestedLayout, pSheet3 );
2a21ac15 836
03206f17
VS
837 mpNestedLayout->Activate();
838 }
839 }
840 }
2a21ac15 841}
03206f17
VS
842
843void MyFrame::CreateLayout( int layoutNo )
844{
2a21ac15
DS
845 wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, false );
846
03206f17
VS
847 if ( layoutNo == THIRD_LAYOUT )
848 {
849 pLayout->PushDefaultPlugins();
850 pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
2a21ac15 851#if defined(__WXGTK__) || defined(__WXX11__)
03206f17
VS
852 pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
853#endif
2a21ac15 854 pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
03206f17 855 }
2a21ac15 856
03206f17 857 mLayouts[layoutNo] = pLayout;
2a21ac15 858
03206f17
VS
859 DropInSomeBars( layoutNo );
860}
861
862void MyFrame::RemoveLayout( int layoutNo )
863{
864 wxFrameLayout* pLayout = mLayouts[layoutNo];
2a21ac15
DS
865
866 if ( !pLayout )
03206f17 867 return;
2a21ac15 868
03206f17 869 pLayout->HideBarWindows();
2a21ac15 870
03206f17 871 // destroy nested layout first
2a21ac15 872
03206f17
VS
873 if ( layoutNo == THIRD_LAYOUT )
874 {
2a21ac15 875 if ( mpNestedLayout )
03206f17
VS
876 delete mpNestedLayout;
877 mpNestedLayout = NULL;
878 }
2a21ac15
DS
879
880 // NOTE:: bar windows are NOT destroyed automatically by frame-layout
881
03206f17 882 pLayout->DestroyBarWindows();
2a21ac15 883
03206f17 884 delete pLayout;
2a21ac15 885
03206f17 886 mLayouts[layoutNo] = NULL;
2a21ac15 887
03206f17
VS
888 Refresh();
889}
890
891void MyFrame::SyncMenuBarItems()
892{
893 for( int i = 0; i != MAX_LAYOUTS; ++i )
894 {
895 GetMenuBar()->Check( ID_FIRST+i, mActiveLayoutNo == FIRST_LAYOUT+i );
896 }
2a21ac15 897
03206f17
VS
898 GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave );
899}
900
901void MyFrame::ActivateLayout( int layoutNo )
902{
2a21ac15 903 if ( layoutNo == mActiveLayoutNo )
03206f17 904 return;
2a21ac15 905
03206f17
VS
906 if ( mLayouts[mActiveLayoutNo] )
907 mLayouts[mActiveLayoutNo]->Deactivate();
2a21ac15 908
03206f17 909 mActiveLayoutNo = layoutNo;
2a21ac15
DS
910
911 if ( mLayouts[mActiveLayoutNo] )
03206f17
VS
912 mLayouts[mActiveLayoutNo]->Activate();
913 else
914 Refresh();
2a21ac15 915
03206f17
VS
916 SyncMenuBarItems();
917}
918
919/***** Implementation for class StartButton95 (just for fun) *****/
920
921IMPLEMENT_DYNAMIC_CLASS( StartButton95, wxPanel )
922
923BEGIN_EVENT_TABLE( StartButton95, wxPanel )
924 EVT_LEFT_DOWN( StartButton95::OnMouseDown )
925 EVT_LEFT_UP ( StartButton95::OnMouseUp )
926 EVT_PAINT ( StartButton95::OnPaint )
927END_EVENT_TABLE()
928
8552e6f0 929void StartButton95::OnMouseDown( wxMouseEvent& WXUNUSED(event) )
03206f17 930{
2a21ac15 931 m_bPressed = true;
03206f17
VS
932 Refresh();
933 CaptureMouse();
934}
935
8552e6f0 936void StartButton95::OnMouseUp( wxMouseEvent& WXUNUSED(event) )
03206f17
VS
937{
938 // "this is not a bug"
2a21ac15 939
03206f17
VS
940 SetCursor( wxCURSOR_WAIT );
941 GetParent()->SetCursor( wxCURSOR_WAIT );
2a21ac15 942 ::wxSetCursor( wxCURSOR_WAIT );
03206f17 943 wxSleep(1);
2a21ac15
DS
944
945 for( int i = 1; i != 6; ++i )
946 {
03206f17
VS
947 m_bPressed = (i % 2) != 0;
948 Refresh();
949 wxSleep(1);
950 }
951 GetParent()->Close();
952 //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???
953}
954
8552e6f0 955void StartButton95::OnPaint( wxPaintEvent& WXUNUSED(event) )
03206f17 956{
8552e6f0 957 wxBitmap* pBmp;
2a21ac15 958
03206f17
VS
959 if ( m_bPressed )
960 {
05aa1fc7 961 if ( !m_PBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp") ) )
2a21ac15 962
05aa1fc7 963 m_PBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP );
2a21ac15 964
03206f17
VS
965 pBmp = &m_PBmp;
966 }
967 else
968 {
05aa1fc7 969 if ( !m_DBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp") ) )
2a21ac15 970
05aa1fc7 971 m_DBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP );
2a21ac15 972
03206f17
VS
973 pBmp = &m_DBmp;
974 }
2a21ac15 975
03206f17
VS
976 if (!pBmp) return;
977 wxMemoryDC mdc;
978 wxPaintDC dc(this);
979 mdc.SelectObject( *pBmp );
2a21ac15 980
03206f17 981 dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY );
2a21ac15 982
03206f17
VS
983 mdc.SelectObject( wxNullBitmap );
984}