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