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