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