Corrected close button bitmap in wxAUIMultiNotebook.
[wxWidgets.git] / samples / aui / auidemo.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: auidemo.cpp
3 // Purpose: wxaui: wx advanced user interface - sample/test program
4 // Author: Benjamin I. Williams
5 // Modified by:
6 // Created: 2005-10-03
7 // RCS-ID: $Id$
8 // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
9 // Licence: wxWindows Library Licence, Version 3.1
10 ///////////////////////////////////////////////////////////////////////////////
11
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 #include "wx/wx.h"
20
21 #include "wx/grid.h"
22 #include "wx/treectrl.h"
23 #include "wx/spinctrl.h"
24 #include "wx/artprov.h"
25 #include "wx/clipbrd.h"
26 #include "wx/image.h"
27 #include "wx/colordlg.h"
28 #include "wx/wxhtml.h"
29 #include "wx/imaglist.h"
30 #include "wx/dataobj.h"
31
32 #include "wx/aui/aui.h"
33 #include "../sample.xpm"
34
35 // -- application --
36
37 class MyApp : public wxApp
38 {
39 public:
40 bool OnInit();
41 };
42
43 DECLARE_APP(MyApp)
44 IMPLEMENT_APP(MyApp)
45
46
47 class wxSizeReportCtrl;
48
49 // -- frame --
50
51 class MyFrame : public wxFrame
52 {
53 enum
54 {
55 ID_CreateTree = wxID_HIGHEST+1,
56 ID_CreateGrid,
57 ID_CreateText,
58 ID_CreateHTML,
59 ID_CreateSizeReport,
60 ID_GridContent,
61 ID_TextContent,
62 ID_TreeContent,
63 ID_HTMLContent,
64 ID_NotebookContent,
65 ID_SizeReportContent,
66 ID_CreatePerspective,
67 ID_CopyPerspectiveCode,
68 ID_AllowFloating,
69 ID_AllowActivePane,
70 ID_TransparentHint,
71 ID_TransparentHintFade,
72 ID_TransparentDrag,
73 ID_NoGradient,
74 ID_VerticalGradient,
75 ID_HorizontalGradient,
76 ID_Settings,
77 ID_FirstPerspective = ID_CreatePerspective+1000
78 };
79
80 public:
81 MyFrame(wxWindow* parent,
82 wxWindowID id,
83 const wxString& title,
84 const wxPoint& pos = wxDefaultPosition,
85 const wxSize& size = wxDefaultSize,
86 long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
87
88 ~MyFrame();
89
90 wxDockArt* GetDockArt();
91 void DoUpdate();
92
93 private:
94 wxTextCtrl* CreateTextCtrl(const wxString& text = wxEmptyString);
95 wxGrid* CreateGrid();
96 wxTreeCtrl* CreateTreeCtrl();
97 wxSizeReportCtrl* CreateSizeReportCtrl(int width = 80, int height = 80);
98 wxPoint GetStartPosition();
99 wxHtmlWindow* CreateHTMLCtrl();
100 wxAuiMultiNotebook* CreateNotebook();
101
102 wxString GetIntroText();
103
104 private:
105
106 void OnEraseBackground(wxEraseEvent& evt);
107 void OnSize(wxSizeEvent& evt);
108
109 void OnCreateTree(wxCommandEvent& evt);
110 void OnCreateGrid(wxCommandEvent& evt);
111 void OnCreateHTML(wxCommandEvent& evt);
112 void OnCreateNotebook(wxCommandEvent& evt);
113 void OnCreateText(wxCommandEvent& evt);
114 void OnCreateSizeReport(wxCommandEvent& evt);
115 void OnChangeContentPane(wxCommandEvent& evt);
116 void OnCreatePerspective(wxCommandEvent& evt);
117 void OnCopyPerspectiveCode(wxCommandEvent& evt);
118 void OnRestorePerspective(wxCommandEvent& evt);
119 void OnSettings(wxCommandEvent& evt);
120 void OnExit(wxCommandEvent& evt);
121 void OnAbout(wxCommandEvent& evt);
122
123 void OnGradient(wxCommandEvent& evt);
124 void OnManagerFlag(wxCommandEvent& evt);
125 void OnUpdateUI(wxUpdateUIEvent& evt);
126
127 void OnPaneClose(wxFrameManagerEvent& evt);
128
129 private:
130
131 wxFrameManager m_mgr;
132 wxArrayString m_perspectives;
133 wxMenu* m_perspectives_menu;
134
135 DECLARE_EVENT_TABLE()
136 };
137
138
139
140 // -- wxSizeReportCtrl --
141 // (a utility control that always reports it's client size)
142
143 class wxSizeReportCtrl : public wxControl
144 {
145 public:
146
147 wxSizeReportCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
148 const wxPoint& pos = wxDefaultPosition,
149 const wxSize& size = wxDefaultSize,
150 wxFrameManager* mgr = NULL)
151 : wxControl(parent, id, pos, size, wxNO_BORDER)
152 {
153 m_mgr = mgr;
154 }
155
156 private:
157
158 void OnPaint(wxPaintEvent& WXUNUSED(evt))
159 {
160 wxPaintDC dc(this);
161 wxSize size = GetClientSize();
162 wxString s;
163 int h, w, height;
164
165 s.Printf(wxT("Size: %d x %d"), size.x, size.y);
166
167 dc.SetFont(*wxNORMAL_FONT);
168 dc.GetTextExtent(s, &w, &height);
169 height += 3;
170 dc.SetBrush(*wxWHITE_BRUSH);
171 dc.SetPen(*wxWHITE_PEN);
172 dc.DrawRectangle(0, 0, size.x, size.y);
173 dc.SetPen(*wxLIGHT_GREY_PEN);
174 dc.DrawLine(0, 0, size.x, size.y);
175 dc.DrawLine(0, size.y, size.x, 0);
176 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2));
177
178 if (m_mgr)
179 {
180 wxPaneInfo pi = m_mgr->GetPane(this);
181
182 s.Printf(wxT("Layer: %d"), pi.dock_layer);
183 dc.GetTextExtent(s, &w, &h);
184 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*1));
185
186 s.Printf(wxT("Dock: %d Row: %d"), pi.dock_direction, pi.dock_row);
187 dc.GetTextExtent(s, &w, &h);
188 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*2));
189
190 s.Printf(wxT("Position: %d"), pi.dock_pos);
191 dc.GetTextExtent(s, &w, &h);
192 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*3));
193
194 s.Printf(wxT("Proportion: %d"), pi.dock_proportion);
195 dc.GetTextExtent(s, &w, &h);
196 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*4));
197 }
198 }
199
200 void OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
201 {
202 // intentionally empty
203 }
204
205 void OnSize(wxSizeEvent& WXUNUSED(evt))
206 {
207 Refresh();
208 }
209 private:
210
211 wxFrameManager* m_mgr;
212
213 DECLARE_EVENT_TABLE()
214 };
215
216 BEGIN_EVENT_TABLE(wxSizeReportCtrl, wxControl)
217 EVT_PAINT(wxSizeReportCtrl::OnPaint)
218 EVT_SIZE(wxSizeReportCtrl::OnSize)
219 EVT_ERASE_BACKGROUND(wxSizeReportCtrl::OnEraseBackground)
220 END_EVENT_TABLE()
221
222
223
224
225
226
227 class SettingsPanel : public wxPanel
228 {
229 enum
230 {
231 ID_PaneBorderSize = wxID_HIGHEST+1,
232 ID_SashSize,
233 ID_CaptionSize,
234 ID_BackgroundColor,
235 ID_SashColor,
236 ID_InactiveCaptionColor,
237 ID_InactiveCaptionGradientColor,
238 ID_InactiveCaptionTextColor,
239 ID_ActiveCaptionColor,
240 ID_ActiveCaptionGradientColor,
241 ID_ActiveCaptionTextColor,
242 ID_BorderColor,
243 ID_GripperColor
244 };
245
246 public:
247
248 SettingsPanel(wxWindow* parent, MyFrame* frame)
249 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
250 {
251 //wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
252
253 //vert->Add(1, 1, 1, wxEXPAND);
254
255 wxBoxSizer* s1 = new wxBoxSizer(wxHORIZONTAL);
256 m_border_size = new wxSpinCtrl(this, ID_PaneBorderSize, wxEmptyString, wxDefaultPosition, wxSize(50,20));
257 s1->Add(1, 1, 1, wxEXPAND);
258 s1->Add(new wxStaticText(this, wxID_ANY, wxT("Pane Border Size:")));
259 s1->Add(m_border_size);
260 s1->Add(1, 1, 1, wxEXPAND);
261 s1->SetItemMinSize((size_t)1, 180, 20);
262 //vert->Add(s1, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
263
264 wxBoxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
265 m_sash_size = new wxSpinCtrl(this, ID_SashSize, wxEmptyString, wxDefaultPosition, wxSize(50,20));
266 s2->Add(1, 1, 1, wxEXPAND);
267 s2->Add(new wxStaticText(this, wxID_ANY, wxT("Sash Size:")));
268 s2->Add(m_sash_size);
269 s2->Add(1, 1, 1, wxEXPAND);
270 s2->SetItemMinSize((size_t)1, 180, 20);
271 //vert->Add(s2, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
272
273 wxBoxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
274 m_caption_size = new wxSpinCtrl(this, ID_CaptionSize, wxEmptyString, wxDefaultPosition, wxSize(50,20));
275 s3->Add(1, 1, 1, wxEXPAND);
276 s3->Add(new wxStaticText(this, wxID_ANY, wxT("Caption Size:")));
277 s3->Add(m_caption_size);
278 s3->Add(1, 1, 1, wxEXPAND);
279 s3->SetItemMinSize((size_t)1, 180, 20);
280 //vert->Add(s3, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
281
282 //vert->Add(1, 1, 1, wxEXPAND);
283
284
285 wxBitmap b = CreateColorBitmap(*wxBLACK);
286
287 wxBoxSizer* s4 = new wxBoxSizer(wxHORIZONTAL);
288 m_background_color = new wxBitmapButton(this, ID_BackgroundColor, b, wxDefaultPosition, wxSize(50,25));
289 s4->Add(1, 1, 1, wxEXPAND);
290 s4->Add(new wxStaticText(this, wxID_ANY, wxT("Background Color:")));
291 s4->Add(m_background_color);
292 s4->Add(1, 1, 1, wxEXPAND);
293 s4->SetItemMinSize((size_t)1, 180, 20);
294
295 wxBoxSizer* s5 = new wxBoxSizer(wxHORIZONTAL);
296 m_sash_color = new wxBitmapButton(this, ID_SashColor, b, wxDefaultPosition, wxSize(50,25));
297 s5->Add(1, 1, 1, wxEXPAND);
298 s5->Add(new wxStaticText(this, wxID_ANY, wxT("Sash Color:")));
299 s5->Add(m_sash_color);
300 s5->Add(1, 1, 1, wxEXPAND);
301 s5->SetItemMinSize((size_t)1, 180, 20);
302
303 wxBoxSizer* s6 = new wxBoxSizer(wxHORIZONTAL);
304 m_inactive_caption_color = new wxBitmapButton(this, ID_InactiveCaptionColor, b, wxDefaultPosition, wxSize(50,25));
305 s6->Add(1, 1, 1, wxEXPAND);
306 s6->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption:")));
307 s6->Add(m_inactive_caption_color);
308 s6->Add(1, 1, 1, wxEXPAND);
309 s6->SetItemMinSize((size_t)1, 180, 20);
310
311 wxBoxSizer* s7 = new wxBoxSizer(wxHORIZONTAL);
312 m_inactive_caption_gradient_color = new wxBitmapButton(this, ID_InactiveCaptionGradientColor, b, wxDefaultPosition, wxSize(50,25));
313 s7->Add(1, 1, 1, wxEXPAND);
314 s7->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption Gradient:")));
315 s7->Add(m_inactive_caption_gradient_color);
316 s7->Add(1, 1, 1, wxEXPAND);
317 s7->SetItemMinSize((size_t)1, 180, 20);
318
319 wxBoxSizer* s8 = new wxBoxSizer(wxHORIZONTAL);
320 m_inactive_caption_text_color = new wxBitmapButton(this, ID_InactiveCaptionTextColor, b, wxDefaultPosition, wxSize(50,25));
321 s8->Add(1, 1, 1, wxEXPAND);
322 s8->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption Text:")));
323 s8->Add(m_inactive_caption_text_color);
324 s8->Add(1, 1, 1, wxEXPAND);
325 s8->SetItemMinSize((size_t)1, 180, 20);
326
327 wxBoxSizer* s9 = new wxBoxSizer(wxHORIZONTAL);
328 m_active_caption_color = new wxBitmapButton(this, ID_ActiveCaptionColor, b, wxDefaultPosition, wxSize(50,25));
329 s9->Add(1, 1, 1, wxEXPAND);
330 s9->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption:")));
331 s9->Add(m_active_caption_color);
332 s9->Add(1, 1, 1, wxEXPAND);
333 s9->SetItemMinSize((size_t)1, 180, 20);
334
335 wxBoxSizer* s10 = new wxBoxSizer(wxHORIZONTAL);
336 m_active_caption_gradient_color = new wxBitmapButton(this, ID_ActiveCaptionGradientColor, b, wxDefaultPosition, wxSize(50,25));
337 s10->Add(1, 1, 1, wxEXPAND);
338 s10->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption Gradient:")));
339 s10->Add(m_active_caption_gradient_color);
340 s10->Add(1, 1, 1, wxEXPAND);
341 s10->SetItemMinSize((size_t)1, 180, 20);
342
343 wxBoxSizer* s11 = new wxBoxSizer(wxHORIZONTAL);
344 m_active_caption_text_color = new wxBitmapButton(this, ID_ActiveCaptionTextColor, b, wxDefaultPosition, wxSize(50,25));
345 s11->Add(1, 1, 1, wxEXPAND);
346 s11->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption Text:")));
347 s11->Add(m_active_caption_text_color);
348 s11->Add(1, 1, 1, wxEXPAND);
349 s11->SetItemMinSize((size_t)1, 180, 20);
350
351 wxBoxSizer* s12 = new wxBoxSizer(wxHORIZONTAL);
352 m_border_color = new wxBitmapButton(this, ID_BorderColor, b, wxDefaultPosition, wxSize(50,25));
353 s12->Add(1, 1, 1, wxEXPAND);
354 s12->Add(new wxStaticText(this, wxID_ANY, wxT("Border Color:")));
355 s12->Add(m_border_color);
356 s12->Add(1, 1, 1, wxEXPAND);
357 s12->SetItemMinSize((size_t)1, 180, 20);
358
359 wxBoxSizer* s13 = new wxBoxSizer(wxHORIZONTAL);
360 m_gripper_color = new wxBitmapButton(this, ID_GripperColor, b, wxDefaultPosition, wxSize(50,25));
361 s13->Add(1, 1, 1, wxEXPAND);
362 s13->Add(new wxStaticText(this, wxID_ANY, wxT("Gripper Color:")));
363 s13->Add(m_gripper_color);
364 s13->Add(1, 1, 1, wxEXPAND);
365 s13->SetItemMinSize((size_t)1, 180, 20);
366
367 wxGridSizer* grid_sizer = new wxGridSizer(2);
368 grid_sizer->SetHGap(5);
369 grid_sizer->Add(s1); grid_sizer->Add(s4);
370 grid_sizer->Add(s2); grid_sizer->Add(s5);
371 grid_sizer->Add(s3); grid_sizer->Add(s13);
372 grid_sizer->Add(1,1); grid_sizer->Add(s12);
373 grid_sizer->Add(s6); grid_sizer->Add(s9);
374 grid_sizer->Add(s7); grid_sizer->Add(s10);
375 grid_sizer->Add(s8); grid_sizer->Add(s11);
376
377 wxBoxSizer* cont_sizer = new wxBoxSizer(wxVERTICAL);
378 cont_sizer->Add(grid_sizer, 1, wxEXPAND | wxALL, 5);
379 SetSizer(cont_sizer);
380 GetSizer()->SetSizeHints(this);
381
382 m_frame = frame;
383 m_border_size->SetValue(frame->GetDockArt()->GetMetric(wxAUI_ART_PANE_BORDER_SIZE));
384 m_sash_size->SetValue(frame->GetDockArt()->GetMetric(wxAUI_ART_SASH_SIZE));
385 m_caption_size->SetValue(frame->GetDockArt()->GetMetric(wxAUI_ART_CAPTION_SIZE));
386
387 UpdateColors();
388 }
389
390 private:
391
392 wxBitmap CreateColorBitmap(const wxColour& c)
393 {
394 wxImage image;
395 image.Create(25,14);
396 for (int x = 0; x < 25; ++x)
397 for (int y = 0; y < 14; ++y)
398 {
399 wxColour pixcol = c;
400 if (x == 0 || x == 24 || y == 0 || y == 13)
401 pixcol = *wxBLACK;
402 image.SetRGB(x, y, pixcol.Red(), pixcol.Green(), pixcol.Blue());
403 }
404 return wxBitmap(image);
405 }
406
407 void UpdateColors()
408 {
409 wxColour bk = m_frame->GetDockArt()->GetColor(wxAUI_ART_BACKGROUND_COLOUR);
410 m_background_color->SetBitmapLabel(CreateColorBitmap(bk));
411
412 wxColour cap = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_COLOUR);
413 m_inactive_caption_color->SetBitmapLabel(CreateColorBitmap(cap));
414
415 wxColour capgrad = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR);
416 m_inactive_caption_gradient_color->SetBitmapLabel(CreateColorBitmap(capgrad));
417
418 wxColour captxt = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR);
419 m_inactive_caption_text_color->SetBitmapLabel(CreateColorBitmap(captxt));
420
421 wxColour acap = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_COLOUR);
422 m_active_caption_color->SetBitmapLabel(CreateColorBitmap(acap));
423
424 wxColour acapgrad = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR);
425 m_active_caption_gradient_color->SetBitmapLabel(CreateColorBitmap(acapgrad));
426
427 wxColour acaptxt = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR);
428 m_active_caption_text_color->SetBitmapLabel(CreateColorBitmap(acaptxt));
429
430 wxColour sash = m_frame->GetDockArt()->GetColor(wxAUI_ART_SASH_COLOUR);
431 m_sash_color->SetBitmapLabel(CreateColorBitmap(sash));
432
433 wxColour border = m_frame->GetDockArt()->GetColor(wxAUI_ART_BORDER_COLOUR);
434 m_border_color->SetBitmapLabel(CreateColorBitmap(border));
435
436 wxColour gripper = m_frame->GetDockArt()->GetColor(wxAUI_ART_GRIPPER_COLOUR);
437 m_gripper_color->SetBitmapLabel(CreateColorBitmap(gripper));
438 }
439
440 void OnPaneBorderSize(wxSpinEvent& event)
441 {
442 m_frame->GetDockArt()->SetMetric(wxAUI_ART_PANE_BORDER_SIZE,
443 event.GetPosition());
444 m_frame->DoUpdate();
445 }
446
447 void OnSashSize(wxSpinEvent& event)
448 {
449 m_frame->GetDockArt()->SetMetric(wxAUI_ART_SASH_SIZE,
450 event.GetPosition());
451 m_frame->DoUpdate();
452 }
453
454 void OnCaptionSize(wxSpinEvent& event)
455 {
456 m_frame->GetDockArt()->SetMetric(wxAUI_ART_CAPTION_SIZE,
457 event.GetPosition());
458 m_frame->DoUpdate();
459 }
460
461 void OnSetColor(wxCommandEvent& event)
462 {
463 wxColourDialog dlg(m_frame);
464 dlg.SetTitle(_("Color Picker"));
465 if (dlg.ShowModal() != wxID_OK)
466 return;
467
468 int var = 0;
469 switch (event.GetId())
470 {
471 case ID_BackgroundColor: var = wxAUI_ART_BACKGROUND_COLOUR; break;
472 case ID_SashColor: var = wxAUI_ART_SASH_COLOUR; break;
473 case ID_InactiveCaptionColor: var = wxAUI_ART_INACTIVE_CAPTION_COLOUR; break;
474 case ID_InactiveCaptionGradientColor: var = wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR; break;
475 case ID_InactiveCaptionTextColor: var = wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR; break;
476 case ID_ActiveCaptionColor: var = wxAUI_ART_ACTIVE_CAPTION_COLOUR; break;
477 case ID_ActiveCaptionGradientColor: var = wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR; break;
478 case ID_ActiveCaptionTextColor: var = wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR; break;
479 case ID_BorderColor: var = wxAUI_ART_BORDER_COLOUR; break;
480 case ID_GripperColor: var = wxAUI_ART_GRIPPER_COLOUR; break;
481 default: return;
482 }
483
484 m_frame->GetDockArt()->SetColor(var, dlg.GetColourData().GetColour());
485 m_frame->DoUpdate();
486 UpdateColors();
487 }
488
489 private:
490
491 MyFrame* m_frame;
492 wxSpinCtrl* m_border_size;
493 wxSpinCtrl* m_sash_size;
494 wxSpinCtrl* m_caption_size;
495 wxBitmapButton* m_inactive_caption_text_color;
496 wxBitmapButton* m_inactive_caption_gradient_color;
497 wxBitmapButton* m_inactive_caption_color;
498 wxBitmapButton* m_active_caption_text_color;
499 wxBitmapButton* m_active_caption_gradient_color;
500 wxBitmapButton* m_active_caption_color;
501 wxBitmapButton* m_sash_color;
502 wxBitmapButton* m_background_color;
503 wxBitmapButton* m_border_color;
504 wxBitmapButton* m_gripper_color;
505
506 DECLARE_EVENT_TABLE()
507 };
508
509 BEGIN_EVENT_TABLE(SettingsPanel, wxPanel)
510 EVT_SPINCTRL(ID_PaneBorderSize, SettingsPanel::OnPaneBorderSize)
511 EVT_SPINCTRL(ID_SashSize, SettingsPanel::OnSashSize)
512 EVT_SPINCTRL(ID_CaptionSize, SettingsPanel::OnCaptionSize)
513 EVT_BUTTON(ID_BackgroundColor, SettingsPanel::OnSetColor)
514 EVT_BUTTON(ID_SashColor, SettingsPanel::OnSetColor)
515 EVT_BUTTON(ID_InactiveCaptionColor, SettingsPanel::OnSetColor)
516 EVT_BUTTON(ID_InactiveCaptionGradientColor, SettingsPanel::OnSetColor)
517 EVT_BUTTON(ID_InactiveCaptionTextColor, SettingsPanel::OnSetColor)
518 EVT_BUTTON(ID_ActiveCaptionColor, SettingsPanel::OnSetColor)
519 EVT_BUTTON(ID_ActiveCaptionGradientColor, SettingsPanel::OnSetColor)
520 EVT_BUTTON(ID_ActiveCaptionTextColor, SettingsPanel::OnSetColor)
521 EVT_BUTTON(ID_BorderColor, SettingsPanel::OnSetColor)
522 EVT_BUTTON(ID_GripperColor, SettingsPanel::OnSetColor)
523 END_EVENT_TABLE()
524
525
526
527
528
529
530
531 bool MyApp::OnInit()
532 {
533 wxFrame* frame = new MyFrame(NULL,
534 wxID_ANY,
535 wxT("wxAUI 0.9.2 Test Application"),
536 wxDefaultPosition,
537 wxSize(800, 600));
538 SetTopWindow(frame);
539 frame->Show();
540
541 return true;
542 }
543
544
545
546 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
547 EVT_ERASE_BACKGROUND(MyFrame::OnEraseBackground)
548 EVT_SIZE(MyFrame::OnSize)
549 EVT_MENU(MyFrame::ID_CreateTree, MyFrame::OnCreateTree)
550 EVT_MENU(MyFrame::ID_CreateGrid, MyFrame::OnCreateGrid)
551 EVT_MENU(MyFrame::ID_CreateText, MyFrame::OnCreateText)
552 EVT_MENU(MyFrame::ID_CreateHTML, MyFrame::OnCreateHTML)
553 EVT_MENU(MyFrame::ID_CreateSizeReport, MyFrame::OnCreateSizeReport)
554 EVT_MENU(MyFrame::ID_CreatePerspective, MyFrame::OnCreatePerspective)
555 EVT_MENU(MyFrame::ID_CopyPerspectiveCode, MyFrame::OnCopyPerspectiveCode)
556 EVT_MENU(ID_AllowFloating, MyFrame::OnManagerFlag)
557 EVT_MENU(ID_TransparentHint, MyFrame::OnManagerFlag)
558 EVT_MENU(ID_TransparentHintFade, MyFrame::OnManagerFlag)
559 EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag)
560 EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag)
561 EVT_MENU(ID_NoGradient, MyFrame::OnGradient)
562 EVT_MENU(ID_VerticalGradient, MyFrame::OnGradient)
563 EVT_MENU(ID_HorizontalGradient, MyFrame::OnGradient)
564 EVT_MENU(ID_Settings, MyFrame::OnSettings)
565 EVT_MENU(ID_GridContent, MyFrame::OnChangeContentPane)
566 EVT_MENU(ID_TreeContent, MyFrame::OnChangeContentPane)
567 EVT_MENU(ID_TextContent, MyFrame::OnChangeContentPane)
568 EVT_MENU(ID_SizeReportContent, MyFrame::OnChangeContentPane)
569 EVT_MENU(ID_HTMLContent, MyFrame::OnChangeContentPane)
570 EVT_MENU(ID_NotebookContent, MyFrame::OnChangeContentPane)
571 EVT_MENU(wxID_EXIT, MyFrame::OnExit)
572 EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
573 EVT_UPDATE_UI(ID_AllowFloating, MyFrame::OnUpdateUI)
574 EVT_UPDATE_UI(ID_TransparentHint, MyFrame::OnUpdateUI)
575 EVT_UPDATE_UI(ID_TransparentHintFade, MyFrame::OnUpdateUI)
576 EVT_UPDATE_UI(ID_TransparentDrag, MyFrame::OnUpdateUI)
577 EVT_UPDATE_UI(ID_NoGradient, MyFrame::OnUpdateUI)
578 EVT_UPDATE_UI(ID_VerticalGradient, MyFrame::OnUpdateUI)
579 EVT_UPDATE_UI(ID_HorizontalGradient, MyFrame::OnUpdateUI)
580 EVT_MENU_RANGE(MyFrame::ID_FirstPerspective, MyFrame::ID_FirstPerspective+1000,
581 MyFrame::OnRestorePerspective)
582 EVT_AUI_PANECLOSE(MyFrame::OnPaneClose)
583 END_EVENT_TABLE()
584
585
586
587 MyFrame::MyFrame(wxWindow* parent,
588 wxWindowID id,
589 const wxString& title,
590 const wxPoint& pos,
591 const wxSize& size,
592 long style)
593 : wxFrame(parent, id, title, pos, size, style)
594 {
595 // tell wxFrameManager to manage this frame
596 m_mgr.SetManagedWindow(this);
597
598 // set frame icon
599 SetIcon(wxIcon(sample_xpm));
600
601 // create menu
602 wxMenuBar* mb = new wxMenuBar;
603
604 wxMenu* file_menu = new wxMenu;
605 file_menu->Append(wxID_EXIT, _("Exit"));
606
607 wxMenu* view_menu = new wxMenu;
608 view_menu->Append(ID_CreateText, _("Create Text Control"));
609 view_menu->Append(ID_CreateHTML, _("Create HTML Control"));
610 view_menu->Append(ID_CreateTree, _("Create Tree"));
611 view_menu->Append(ID_CreateGrid, _("Create Grid"));
612 view_menu->Append(ID_CreateSizeReport, _("Create Size Reporter"));
613 view_menu->AppendSeparator();
614 view_menu->Append(ID_GridContent, _("Use a Grid for the Content Pane"));
615 view_menu->Append(ID_TextContent, _("Use a Text Control for the Content Pane"));
616 view_menu->Append(ID_HTMLContent, _("Use an HTML Control for the Content Pane"));
617 view_menu->Append(ID_TreeContent, _("Use a Tree Control for the Content Pane"));
618 view_menu->Append(ID_NotebookContent, _("Use a AUI wxMultiNotebook control for the Content Pane"));
619 view_menu->Append(ID_SizeReportContent, _("Use a Size Reporter for the Content Pane"));
620
621 wxMenu* options_menu = new wxMenu;
622 options_menu->AppendCheckItem(ID_AllowFloating, _("Allow Floating"));
623 options_menu->AppendCheckItem(ID_TransparentHint, _("Transparent Hint"));
624 options_menu->AppendCheckItem(ID_TransparentHintFade, _("Transparent Hint Fade-in"));
625 options_menu->AppendCheckItem(ID_TransparentDrag, _("Transparent Drag"));
626 options_menu->AppendCheckItem(ID_AllowActivePane, _("Allow Active Pane"));
627 options_menu->AppendSeparator();
628 options_menu->AppendRadioItem(ID_NoGradient, _("No Caption Gradient"));
629 options_menu->AppendRadioItem(ID_VerticalGradient, _("Vertical Caption Gradient"));
630 options_menu->AppendRadioItem(ID_HorizontalGradient, _("Horizontal Caption Gradient"));
631 options_menu->AppendSeparator();
632 options_menu->Append(ID_Settings, _("Settings Pane"));
633
634 m_perspectives_menu = new wxMenu;
635 m_perspectives_menu->Append(ID_CreatePerspective, _("Create Perspective"));
636 m_perspectives_menu->Append(ID_CopyPerspectiveCode, _("Copy Perspective Data To Clipboard"));
637 m_perspectives_menu->AppendSeparator();
638 m_perspectives_menu->Append(ID_FirstPerspective+0, _("Default Startup"));
639 m_perspectives_menu->Append(ID_FirstPerspective+1, _("All Panes"));
640
641 wxMenu* help_menu = new wxMenu;
642 help_menu->Append(wxID_ABOUT, _("About..."));
643
644 mb->Append(file_menu, _("File"));
645 mb->Append(view_menu, _("View"));
646 mb->Append(m_perspectives_menu, _("Perspectives"));
647 mb->Append(options_menu, _("Options"));
648 mb->Append(help_menu, _("Help"));
649
650 SetMenuBar(mb);
651
652 CreateStatusBar();
653 GetStatusBar()->SetStatusText(_("Ready"));
654
655
656 // min size for the frame itself isn't completely done.
657 // see the end up wxFrameManager::Update() for the test
658 // code. For now, just hard code a frame minimum size
659 SetMinSize(wxSize(400,300));
660
661 // create some toolbars
662 wxToolBar* tb1 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
663 wxTB_FLAT | wxTB_NODIVIDER);
664 tb1->SetToolBitmapSize(wxSize(48,48));
665 tb1->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR));
666 tb1->AddSeparator();
667 tb1->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION));
668 tb1->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION));
669 tb1->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING));
670 tb1->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE));
671 tb1->Realize();
672
673
674
675 wxToolBar* tb2 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
676 wxTB_FLAT | wxTB_NODIVIDER);
677 tb2->SetToolBitmapSize(wxSize(16,16));
678
679 wxBitmap tb2_bmp1 = wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(16,16));
680 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
681 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
682 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
683 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
684 tb2->AddSeparator();
685 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
686 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
687 tb2->AddSeparator();
688 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
689 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
690 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
691 tb2->AddTool(101, wxT("Test"), tb2_bmp1);
692 tb2->Realize();
693
694
695 wxToolBar* tb3 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
696 wxTB_FLAT | wxTB_NODIVIDER);
697 tb3->SetToolBitmapSize(wxSize(16,16));
698 wxBitmap tb3_bmp1 = wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(16,16));
699 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
700 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
701 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
702 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
703 tb3->AddSeparator();
704 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
705 tb3->AddTool(101, wxT("Test"), tb3_bmp1);
706 tb3->Realize();
707
708
709
710 wxToolBar* tb4 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
711 wxTB_FLAT | wxTB_NODIVIDER | wxTB_HORZ_TEXT);
712 tb4->SetToolBitmapSize(wxSize(16,16));
713 wxBitmap tb4_bmp1 = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
714 tb4->AddTool(101, wxT("Item 1"), tb4_bmp1);
715 tb4->AddTool(101, wxT("Item 2"), tb4_bmp1);
716 tb4->AddTool(101, wxT("Item 3"), tb4_bmp1);
717 tb4->AddTool(101, wxT("Item 4"), tb4_bmp1);
718 tb4->AddSeparator();
719 tb4->AddTool(101, wxT("Item 5"), tb4_bmp1);
720 tb4->AddTool(101, wxT("Item 6"), tb4_bmp1);
721 tb4->AddTool(101, wxT("Item 7"), tb4_bmp1);
722 tb4->AddTool(101, wxT("Item 8"), tb4_bmp1);
723 tb4->Realize();
724
725 // create some toolbars
726 wxToolBar* tb5 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
727 wxTB_FLAT | wxTB_NODIVIDER | wxTB_VERTICAL);
728 tb5->SetToolBitmapSize(wxSize(48,48));
729 tb5->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR));
730 tb5->AddSeparator();
731 tb5->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION));
732 tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION));
733 tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING));
734 tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE));
735 tb5->Realize();
736
737
738 // add a bunch of panes
739 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
740 Name(wxT("test1")).Caption(wxT("Pane Caption")).
741 Top());
742
743 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
744 Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
745 Bottom().Position(1));
746
747 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
748 Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
749 Bottom());
750
751 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
752 Name(wxT("test4")).Caption(wxT("Pane Caption")).
753 Left());
754
755 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
756 Name(wxT("test5")).Caption(wxT("No Close Button")).
757 Right().CloseButton(false));
758
759 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
760 Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
761 Right().Row(1));
762
763 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
764 Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
765 Left().Layer(1));
766
767 m_mgr.AddPane(CreateTreeCtrl(), wxPaneInfo().
768 Name(wxT("test8")).Caption(wxT("Tree Pane")).
769 Left().Layer(1).Position(1));
770
771 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
772 Name(wxT("test9")).Caption(wxT("Min Size 200x100")).
773 BestSize(wxSize(200,100)).MinSize(wxSize(200,100)).
774 Bottom().Layer(1));
775
776 wxWindow* wnd10 = CreateTextCtrl(wxT("This pane will prompt the user before hiding."));
777 m_mgr.AddPane(wnd10, wxPaneInfo().
778 Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")).
779 Bottom().Layer(1).Position(1));
780
781 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
782 Name(wxT("test11")).Caption(wxT("Fixed Pane")).
783 Bottom().Layer(1).Position(2).Fixed());
784
785
786 m_mgr.AddPane(new SettingsPanel(this,this), wxPaneInfo().
787 Name(wxT("settings")).Caption(wxT("Dock Manager Settings")).
788 Dockable(false).Float().Hide());
789
790 // create some center panes
791
792 m_mgr.AddPane(CreateGrid(), wxPaneInfo().Name(wxT("grid_content")).
793 CenterPane().Hide());
794
795 m_mgr.AddPane(CreateTreeCtrl(), wxPaneInfo().Name(wxT("tree_content")).
796 CenterPane().Hide());
797
798 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().Name(wxT("sizereport_content")).
799 CenterPane().Hide());
800
801 m_mgr.AddPane(CreateTextCtrl(), wxPaneInfo().Name(wxT("text_content")).
802 CenterPane().Hide());
803
804 m_mgr.AddPane(CreateHTMLCtrl(), wxPaneInfo().Name(wxT("html_content")).
805 CenterPane());
806
807 m_mgr.AddPane(CreateNotebook(), wxPaneInfo().Name(wxT("notebook_content")).
808 CenterPane());
809
810 // add the toolbars to the manager
811
812 m_mgr.AddPane(tb1, wxPaneInfo().
813 Name(wxT("tb1")).Caption(wxT("Big Toolbar")).
814 ToolbarPane().Top().
815 LeftDockable(false).RightDockable(false));
816
817 m_mgr.AddPane(tb2, wxPaneInfo().
818 Name(wxT("tb2")).Caption(wxT("Toolbar 2")).
819 ToolbarPane().Top().Row(1).
820 LeftDockable(false).RightDockable(false));
821
822 m_mgr.AddPane(tb3, wxPaneInfo().
823 Name(wxT("tb3")).Caption(wxT("Toolbar 3")).
824 ToolbarPane().Top().Row(1).Position(1).
825 LeftDockable(false).RightDockable(false));
826
827 m_mgr.AddPane(tb4, wxPaneInfo().
828 Name(wxT("tb4")).Caption(wxT("Sample Bookmark Toolbar")).
829 ToolbarPane().Top().Row(2).
830 LeftDockable(false).RightDockable(false));
831
832 m_mgr.AddPane(tb5, wxPaneInfo().
833 Name(wxT("tb5")).Caption(wxT("Sample Vertical Toolbar")).
834 ToolbarPane().Left().
835 GripperTop().
836 TopDockable(false).BottomDockable(false));
837
838 m_mgr.AddPane(new wxButton(this, wxID_ANY, _("Test Button")),
839 wxPaneInfo().Name(wxT("tb6")).
840 ToolbarPane().Top().Row(2).Position(1).
841 LeftDockable(false).RightDockable(false));
842
843
844 // make some default perspectives
845
846 wxString perspective_all = m_mgr.SavePerspective();
847
848 int i, count;
849 wxPaneInfoArray& all_panes = m_mgr.GetAllPanes();
850 for (i = 0, count = all_panes.GetCount(); i < count; ++i)
851 if (!all_panes.Item(i).IsToolbar())
852 all_panes.Item(i).Hide();
853 m_mgr.GetPane(wxT("tb1")).Hide();
854 m_mgr.GetPane(wxT("tb6")).Hide();
855 m_mgr.GetPane(wxT("test8")).Show().Left().Layer(0).Row(0).Position(0);
856 m_mgr.GetPane(wxT("test10")).Show().Bottom().Layer(0).Row(0).Position(0);
857 m_mgr.GetPane(wxT("html_content")).Show();
858 wxString perspective_default = m_mgr.SavePerspective();
859
860 m_perspectives.Add(perspective_default);
861 m_perspectives.Add(perspective_all);
862
863 // "commit" all changes made to wxFrameManager
864 m_mgr.Update();
865 }
866
867 MyFrame::~MyFrame()
868 {
869 m_mgr.UnInit();
870 }
871
872 wxDockArt* MyFrame::GetDockArt()
873 {
874 return m_mgr.GetArtProvider();
875 }
876
877 void MyFrame::DoUpdate()
878 {
879 m_mgr.Update();
880 }
881
882
883 void MyFrame::OnEraseBackground(wxEraseEvent& event)
884 {
885 event.Skip();
886 }
887
888 void MyFrame::OnSize(wxSizeEvent& event)
889 {
890 event.Skip();
891 }
892
893 void MyFrame::OnSettings(wxCommandEvent& WXUNUSED(event))
894 {
895 // show the settings pane, and float it
896 wxPaneInfo& floating_pane = m_mgr.GetPane(wxT("settings")).Float().Show();
897
898 if (floating_pane.floating_pos == wxDefaultPosition)
899 floating_pane.FloatingPosition(GetStartPosition());
900
901 m_mgr.Update();
902 }
903
904
905 void MyFrame::OnGradient(wxCommandEvent& event)
906 {
907 int gradient = 0;
908
909 switch (event.GetId())
910 {
911 case ID_NoGradient: gradient = wxAUI_GRADIENT_NONE; break;
912 case ID_VerticalGradient: gradient = wxAUI_GRADIENT_VERTICAL; break;
913 case ID_HorizontalGradient: gradient = wxAUI_GRADIENT_HORIZONTAL; break;
914 }
915
916 m_mgr.GetArtProvider()->SetMetric(wxAUI_ART_GRADIENT_TYPE, gradient);
917 m_mgr.Update();
918 }
919
920 void MyFrame::OnManagerFlag(wxCommandEvent& event)
921 {
922 unsigned int flag = 0;
923
924 #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__)
925 if (event.GetId() == ID_TransparentDrag ||
926 event.GetId() == ID_TransparentHint ||
927 event.GetId() == ID_TransparentHintFade)
928 {
929 wxMessageBox(wxT("This option is presently only available on wxGTK, wxMSW and wxMac"));
930 return;
931 }
932 #endif
933
934 switch (event.GetId())
935 {
936 case ID_AllowFloating: flag = wxAUI_MGR_ALLOW_FLOATING; break;
937 case ID_TransparentDrag: flag = wxAUI_MGR_TRANSPARENT_DRAG; break;
938 case ID_TransparentHint: flag = wxAUI_MGR_TRANSPARENT_HINT; break;
939 case ID_TransparentHintFade: flag = wxAUI_MGR_TRANSPARENT_HINT_FADE; break;
940 case ID_AllowActivePane: flag = wxAUI_MGR_ALLOW_ACTIVE_PANE; break;
941 }
942 m_mgr.SetFlags(m_mgr.GetFlags() ^ flag);
943 m_mgr.Update();
944 }
945
946 void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
947 {
948 unsigned int flags = m_mgr.GetFlags();
949
950 switch (event.GetId())
951 {
952 case ID_NoGradient:
953 event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_NONE ? true : false);
954 break;
955 case ID_VerticalGradient:
956 event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_VERTICAL ? true : false);
957 break;
958 case ID_HorizontalGradient:
959 event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_HORIZONTAL ? true : false);
960 break;
961 case ID_AllowFloating:
962 event.Check(flags & wxAUI_MGR_ALLOW_FLOATING ? true : false);
963 break;
964 case ID_TransparentDrag:
965 event.Check(flags & wxAUI_MGR_TRANSPARENT_DRAG ? true : false);
966 break;
967 case ID_TransparentHint:
968 event.Check(flags & wxAUI_MGR_TRANSPARENT_HINT ? true : false);
969 break;
970 case ID_TransparentHintFade:
971 event.Check(flags & wxAUI_MGR_TRANSPARENT_HINT_FADE ? true : false);
972 break;
973 }
974 }
975
976 void MyFrame::OnPaneClose(wxFrameManagerEvent& evt)
977 {
978 if (evt.pane->name == wxT("test10"))
979 {
980 int res = wxMessageBox(wxT("Are you sure you want to close/hide this pane?"),
981 wxT("wxAUI"),
982 wxYES_NO,
983 this);
984 if (res != wxYES)
985 evt.Veto();
986 }
987 }
988
989
990
991 void MyFrame::OnCreatePerspective(wxCommandEvent& WXUNUSED(event))
992 {
993 wxTextEntryDialog dlg(this, wxT("Enter a name for the new perspective:"),
994 wxT("wxAUI Test"));
995
996 dlg.SetValue(wxString::Format(wxT("Perspective %d"), m_perspectives.GetCount()+1));
997 if (dlg.ShowModal() != wxID_OK)
998 return;
999
1000 if (m_perspectives.GetCount() == 0)
1001 {
1002 m_perspectives_menu->AppendSeparator();
1003 }
1004
1005 m_perspectives_menu->Append(ID_FirstPerspective + m_perspectives.GetCount(), dlg.GetValue());
1006 m_perspectives.Add(m_mgr.SavePerspective());
1007 }
1008
1009 void MyFrame::OnCopyPerspectiveCode(wxCommandEvent& WXUNUSED(event))
1010 {
1011 wxString s = m_mgr.SavePerspective();
1012
1013 #if wxUSE_CLIPBOARD
1014 if (wxTheClipboard->Open())
1015 {
1016 wxTheClipboard->SetData(new wxTextDataObject(s));
1017 wxTheClipboard->Close();
1018 }
1019 #endif
1020 }
1021
1022 void MyFrame::OnRestorePerspective(wxCommandEvent& event)
1023 {
1024 m_mgr.LoadPerspective(m_perspectives.Item(event.GetId() - ID_FirstPerspective));
1025 }
1026
1027
1028 wxPoint MyFrame::GetStartPosition()
1029 {
1030 static int x = 0;
1031 x += 20;
1032 wxPoint pt = ClientToScreen(wxPoint(0,0));
1033 return wxPoint(pt.x + x, pt.y + x);
1034 }
1035
1036 void MyFrame::OnCreateTree(wxCommandEvent& WXUNUSED(event))
1037 {
1038 m_mgr.AddPane(CreateTreeCtrl(), wxPaneInfo().
1039 Name(wxT("Test")).Caption(wxT("Tree Control")).
1040 Float().FloatingPosition(GetStartPosition()).
1041 FloatingSize(wxSize(150,300)));
1042 m_mgr.Update();
1043 }
1044
1045 void MyFrame::OnCreateGrid(wxCommandEvent& WXUNUSED(event))
1046 {
1047 m_mgr.AddPane(CreateGrid(), wxPaneInfo().
1048 Name(wxT("Test")).Caption(wxT("Grid")).
1049 Float().FloatingPosition(GetStartPosition()).
1050 FloatingSize(wxSize(300,200)));
1051 m_mgr.Update();
1052 }
1053
1054 void MyFrame::OnCreateHTML(wxCommandEvent& WXUNUSED(event))
1055 {
1056 m_mgr.AddPane(CreateHTMLCtrl(), wxPaneInfo().
1057 Name(wxT("Test")).Caption(wxT("Grid")).
1058 Float().FloatingPosition(GetStartPosition()).
1059 FloatingSize(wxSize(300,200)));
1060 m_mgr.Update();
1061 }
1062
1063 void MyFrame::OnCreateNotebook(wxCommandEvent& WXUNUSED(event))
1064 {
1065 m_mgr.AddPane(CreateNotebook(), wxPaneInfo().
1066 Name(wxT("Test")).Caption(wxT("Notebook")).
1067 Float().FloatingPosition(GetStartPosition()).
1068 FloatingSize(wxSize(300,200)));
1069 m_mgr.Update();
1070 }
1071
1072 void MyFrame::OnCreateText(wxCommandEvent& WXUNUSED(event))
1073 {
1074 m_mgr.AddPane(CreateTextCtrl(), wxPaneInfo().
1075 Name(wxT("Test")).Caption(wxT("Text Control")).
1076 Float().FloatingPosition(GetStartPosition()));
1077 m_mgr.Update();
1078 }
1079
1080 void MyFrame::OnCreateSizeReport(wxCommandEvent& WXUNUSED(event))
1081 {
1082 m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
1083 Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
1084 Float().FloatingPosition(GetStartPosition()));
1085 m_mgr.Update();
1086 }
1087
1088 void MyFrame::OnChangeContentPane(wxCommandEvent& event)
1089 {
1090 m_mgr.GetPane(wxT("grid_content")).Show(event.GetId() == ID_GridContent ? true:false);
1091 m_mgr.GetPane(wxT("text_content")).Show(event.GetId() == ID_TextContent ? true:false);
1092 m_mgr.GetPane(wxT("tree_content")).Show(event.GetId() == ID_TreeContent ? true:false);
1093 m_mgr.GetPane(wxT("sizereport_content")).Show(event.GetId() == ID_SizeReportContent ? true:false);
1094 m_mgr.GetPane(wxT("html_content")).Show(event.GetId() == ID_HTMLContent ? true:false);
1095 m_mgr.GetPane(wxT("notebook_content")).Show(event.GetId() == ID_NotebookContent ? true:false);
1096 m_mgr.Update();
1097 }
1098
1099 void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
1100 {
1101 Close(true);
1102 }
1103
1104 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
1105 {
1106 wxMessageBox(_("wxAUI Demo\nAn advanced window management library for wxWidgets\n(c) Copyright 2005-2006, Kirix Corporation"), _("About wxAUI Demo"), wxOK, this);
1107 }
1108
1109 wxTextCtrl* MyFrame::CreateTextCtrl(const wxString& ctrl_text)
1110 {
1111 static int n = 0;
1112
1113 wxString text;
1114 if (ctrl_text.Length() > 0)
1115 text = ctrl_text;
1116 else
1117 text.Printf(wxT("This is text box %d"), ++n);
1118
1119 return new wxTextCtrl(this,wxID_ANY, text,
1120 wxPoint(0,0), wxSize(150,90),
1121 wxNO_BORDER | wxTE_MULTILINE);
1122 }
1123
1124
1125 wxGrid* MyFrame::CreateGrid()
1126 {
1127 wxGrid* grid = new wxGrid(this, wxID_ANY,
1128 wxPoint(0,0),
1129 wxSize(150,250),
1130 wxNO_BORDER | wxWANTS_CHARS);
1131 grid->CreateGrid(50, 20);
1132 return grid;
1133 }
1134
1135 wxTreeCtrl* MyFrame::CreateTreeCtrl()
1136 {
1137 wxTreeCtrl* tree = new wxTreeCtrl(this, wxID_ANY,
1138 wxPoint(0,0), wxSize(160,250),
1139 wxTR_DEFAULT_STYLE | wxNO_BORDER);
1140
1141 wxTreeItemId root = tree->AddRoot(wxT("wxAUI Project"));
1142 wxArrayTreeItemIds items;
1143
1144
1145 wxImageList* imglist = new wxImageList(16, 16, true, 2);
1146 imglist->Add(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(16,16)));
1147 imglist->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)));
1148 tree->AssignImageList(imglist);
1149
1150 items.Add(tree->AppendItem(root, wxT("Item 1"), 0));
1151 items.Add(tree->AppendItem(root, wxT("Item 2"), 0));
1152 items.Add(tree->AppendItem(root, wxT("Item 3"), 0));
1153 items.Add(tree->AppendItem(root, wxT("Item 4"), 0));
1154 items.Add(tree->AppendItem(root, wxT("Item 5"), 0));
1155
1156
1157 int i, count;
1158 for (i = 0, count = items.Count(); i < count; ++i)
1159 {
1160 wxTreeItemId id = items.Item(i);
1161 tree->AppendItem(id, wxT("Subitem 1"), 1);
1162 tree->AppendItem(id, wxT("Subitem 2"), 1);
1163 tree->AppendItem(id, wxT("Subitem 3"), 1);
1164 tree->AppendItem(id, wxT("Subitem 4"), 1);
1165 tree->AppendItem(id, wxT("Subitem 5"), 1);
1166 }
1167
1168
1169 tree->Expand(root);
1170
1171 return tree;
1172 }
1173
1174 wxSizeReportCtrl* MyFrame::CreateSizeReportCtrl(int width, int height)
1175 {
1176 wxSizeReportCtrl* ctrl = new wxSizeReportCtrl(this, wxID_ANY,
1177 wxDefaultPosition,
1178 wxSize(width, height), &m_mgr);
1179 return ctrl;
1180 }
1181
1182 wxHtmlWindow* MyFrame::CreateHTMLCtrl()
1183 {
1184 wxHtmlWindow* ctrl = new wxHtmlWindow(this, wxID_ANY,
1185 wxDefaultPosition,
1186 wxSize(400,300));
1187 ctrl->SetPage(GetIntroText());
1188 return ctrl;
1189 }
1190
1191 wxAuiMultiNotebook* MyFrame::CreateNotebook()
1192 {
1193 wxAuiMultiNotebook* ctrl = new wxAuiMultiNotebook( this, wxID_ANY,
1194 wxDefaultPosition, wxSize(400,300) );
1195
1196 wxPanel *panel = new wxPanel( ctrl, wxID_ANY );
1197 wxFlexGridSizer *flex = new wxFlexGridSizer( 2 );
1198 flex->AddGrowableRow( 0 );
1199 flex->AddGrowableRow( 3 );
1200 flex->AddGrowableCol( 1 );
1201 flex->Add( 5,5 ); flex->Add( 5,5 );
1202 flex->Add( new wxStaticText( panel, -1, wxT("wxTextCtrl:") ), 0, wxALL|wxALIGN_CENTRE, 5 );
1203 flex->Add( new wxTextCtrl( panel, -1, wxT(""), wxDefaultPosition, wxSize(100,-1) ),
1204 1, wxALL|wxALIGN_CENTRE, 5 );
1205 flex->Add( new wxStaticText( panel, -1, wxT("wxSpinCtrl:") ), 0, wxALL|wxALIGN_CENTRE, 5 );
1206 flex->Add( new wxSpinCtrl( panel, -1, wxT("5"), wxDefaultPosition, wxSize(100,-1),
1207 wxSP_ARROW_KEYS, 5, 50, 5 ), 0, wxALL|wxALIGN_CENTRE, 5 );
1208 flex->Add( 5,5 ); flex->Add( 5,5 );
1209 panel->SetSizer( flex );
1210 ctrl->AddPage( panel, wxT("wxPanel") );
1211
1212 ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some text"),
1213 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE) , wxT("wxTextCtrl I") );
1214
1215 ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"),
1216 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE) , wxT("wxTextCtrl II") );
1217
1218 return ctrl;
1219 }
1220
1221 wxString MyFrame::GetIntroText()
1222 {
1223 const char* text =
1224 "<html><body>"
1225 "<h3>Welcome to wxAUI 0.9.2</h3>"
1226 "<br/><b>Overview</b><br/>"
1227 "<p>wxAUI is an Advanced User Interface library for the wxWidgets toolkit "
1228 "that allows developers to create high-quality, cross-platform user "
1229 "interfaces quickly and easily.</p>"
1230 "<p><b>Features</b></p>"
1231 "<p>With wxAUI version 0.9.2, developers can create application frameworks with:</p>"
1232 "<ul>"
1233 "<li>Native, dockable floating frames</li>"
1234 "<li>Perspective saving and loading</li>"
1235 "<li>Native toolbars incorporating real-time, &quot;spring-loaded&quot; dragging</li>"
1236 "<li>Customizable floating/docking behavior</li>"
1237 "<li>Completely customizable look-and-feel</li>"
1238 "<li>Optional transparent window effects (while dragging or docking)</li>"
1239 "</ul>"
1240 "<p><b>What's new in 0.9.2?</b></p>"
1241 "<p>The following features/fixes have been added since the last version of wxAUI:</p>"
1242 "<ul>"
1243 "<li>Support for wxMac</li>"
1244 "<li>Updates for wxWidgets 2.6.3</li>"
1245 "<li>Fix to pass more unused events through</li>"
1246 "<li>Fix to allow floating windows to receive idle events</li>"
1247 "<li>Fix for minimizing/maximizing problem with transparent hint pane</li>"
1248 "<li>Fix to not paint empty hint rectangles</li>"
1249 "<li>Fix for 64-bit compilation</li>"
1250 "</ul>"
1251 "<p><b>What changed in 0.9.1?</b></p>"
1252 "<p>The following features/fixes were added in wxAUI 0.9.1:</p>"
1253 "<ul>"
1254 "<li>Support for MDI frames</li>"
1255 "<li>Gradient captions option</li>"
1256 "<li>Active/Inactive panes option</li>"
1257 "<li>Fix for screen artifacts/paint problems</li>"
1258 "<li>Fix for hiding/showing floated window problem</li>"
1259 "<li>Fix for floating pane sizing problem</li>"
1260 "<li>Fix for drop position problem when dragging around center pane margins</li>"
1261 "<li>LF-only text file formatting for source code</li>"
1262 "</ul>"
1263 "<p>See README.txt for more information.</p>"
1264 "</body></html>";
1265
1266 return wxString::FromAscii(text);
1267 }