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