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