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