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