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