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