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