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