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