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