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