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