1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxaui: wx advanced user interface - sample/test program
4 // Author: Benjamin I. Williams
8 // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
9 // Licence: wxWindows Library Licence, Version 3.1
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/treectrl.h"
22 #include "wx/spinctrl.h"
23 #include "wx/artprov.h"
24 #include "wx/clipbrd.h"
26 #include "wx/colordlg.h"
27 #include "wx/wxhtml.h"
28 #include "wx/imaglist.h"
29 #include "wx/dataobj.h"
30 #include "wx/dcclient.h"
31 #include "wx/bmpbuttn.h"
33 #include "wx/toolbar.h"
34 #include "wx/statusbr.h"
35 #include "wx/msgdlg.h"
36 #include "wx/textdlg.h"
38 #include "wx/aui/aui.h"
39 #include "../sample.xpm"
43 class MyApp
: public wxApp
53 class wxSizeReportCtrl
;
57 class MyFrame
: public wxFrame
61 ID_CreateTree
= wxID_HIGHEST
+1,
73 ID_CopyPerspectiveCode
,
77 ID_TransparentHintFade
,
79 ID_DisableVenetianFade
,
83 ID_HorizontalGradient
,
85 ID_FirstPerspective
= ID_CreatePerspective
+1000
89 MyFrame(wxWindow
* parent
,
91 const wxString
& title
,
92 const wxPoint
& pos
= wxDefaultPosition
,
93 const wxSize
& size
= wxDefaultSize
,
94 long style
= wxDEFAULT_FRAME_STYLE
| wxSUNKEN_BORDER
);
98 wxDockArt
* GetDockArt();
102 wxTextCtrl
* CreateTextCtrl(const wxString
& text
= wxEmptyString
);
103 wxGrid
* CreateGrid();
104 wxTreeCtrl
* CreateTreeCtrl();
105 wxSizeReportCtrl
* CreateSizeReportCtrl(int width
= 80, int height
= 80);
106 wxPoint
GetStartPosition();
107 wxHtmlWindow
* CreateHTMLCtrl();
108 wxAuiMultiNotebook
* CreateNotebook();
110 wxString
GetIntroText();
114 void OnEraseBackground(wxEraseEvent
& evt
);
115 void OnSize(wxSizeEvent
& evt
);
117 void OnCreateTree(wxCommandEvent
& evt
);
118 void OnCreateGrid(wxCommandEvent
& evt
);
119 void OnCreateHTML(wxCommandEvent
& evt
);
120 void OnCreateNotebook(wxCommandEvent
& evt
);
121 void OnCreateText(wxCommandEvent
& evt
);
122 void OnCreateSizeReport(wxCommandEvent
& evt
);
123 void OnChangeContentPane(wxCommandEvent
& evt
);
124 void OnCreatePerspective(wxCommandEvent
& evt
);
125 void OnCopyPerspectiveCode(wxCommandEvent
& evt
);
126 void OnRestorePerspective(wxCommandEvent
& evt
);
127 void OnSettings(wxCommandEvent
& evt
);
128 void OnExit(wxCommandEvent
& evt
);
129 void OnAbout(wxCommandEvent
& evt
);
131 void OnGradient(wxCommandEvent
& evt
);
132 void OnManagerFlag(wxCommandEvent
& evt
);
133 void OnUpdateUI(wxUpdateUIEvent
& evt
);
135 void OnPaneClose(wxFrameManagerEvent
& evt
);
139 wxFrameManager m_mgr
;
140 wxArrayString m_perspectives
;
141 wxMenu
* m_perspectives_menu
;
143 DECLARE_EVENT_TABLE()
147 // -- wxSizeReportCtrl --
148 // (a utility control that always reports it's client size)
150 class wxSizeReportCtrl
: public wxControl
154 wxSizeReportCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
155 const wxPoint
& pos
= wxDefaultPosition
,
156 const wxSize
& size
= wxDefaultSize
,
157 wxFrameManager
* mgr
= NULL
)
158 : wxControl(parent
, id
, pos
, size
, wxNO_BORDER
)
165 void OnPaint(wxPaintEvent
& WXUNUSED(evt
))
168 wxSize size
= GetClientSize();
172 s
.Printf(wxT("Size: %d x %d"), size
.x
, size
.y
);
174 dc
.SetFont(*wxNORMAL_FONT
);
175 dc
.GetTextExtent(s
, &w
, &height
);
177 dc
.SetBrush(*wxWHITE_BRUSH
);
178 dc
.SetPen(*wxWHITE_PEN
);
179 dc
.DrawRectangle(0, 0, size
.x
, size
.y
);
180 dc
.SetPen(*wxLIGHT_GREY_PEN
);
181 dc
.DrawLine(0, 0, size
.x
, size
.y
);
182 dc
.DrawLine(0, size
.y
, size
.x
, 0);
183 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2));
187 wxPaneInfo pi
= m_mgr
->GetPane(this);
189 s
.Printf(wxT("Layer: %d"), pi
.dock_layer
);
190 dc
.GetTextExtent(s
, &w
, &h
);
191 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*1));
193 s
.Printf(wxT("Dock: %d Row: %d"), pi
.dock_direction
, pi
.dock_row
);
194 dc
.GetTextExtent(s
, &w
, &h
);
195 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*2));
197 s
.Printf(wxT("Position: %d"), pi
.dock_pos
);
198 dc
.GetTextExtent(s
, &w
, &h
);
199 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*3));
201 s
.Printf(wxT("Proportion: %d"), pi
.dock_proportion
);
202 dc
.GetTextExtent(s
, &w
, &h
);
203 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*4));
207 void OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
209 // intentionally empty
212 void OnSize(wxSizeEvent
& WXUNUSED(evt
))
218 wxFrameManager
* m_mgr
;
220 DECLARE_EVENT_TABLE()
223 BEGIN_EVENT_TABLE(wxSizeReportCtrl
, wxControl
)
224 EVT_PAINT(wxSizeReportCtrl::OnPaint
)
225 EVT_SIZE(wxSizeReportCtrl::OnSize
)
226 EVT_ERASE_BACKGROUND(wxSizeReportCtrl::OnEraseBackground
)
230 class SettingsPanel
: public wxPanel
234 ID_PaneBorderSize
= wxID_HIGHEST
+1,
239 ID_InactiveCaptionColor
,
240 ID_InactiveCaptionGradientColor
,
241 ID_InactiveCaptionTextColor
,
242 ID_ActiveCaptionColor
,
243 ID_ActiveCaptionGradientColor
,
244 ID_ActiveCaptionTextColor
,
251 SettingsPanel(wxWindow
* parent
, MyFrame
* frame
)
252 : wxPanel(parent
, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
)
254 //wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
256 //vert->Add(1, 1, 1, wxEXPAND);
258 wxBoxSizer
* s1
= new wxBoxSizer(wxHORIZONTAL
);
259 m_border_size
= new wxSpinCtrl(this, ID_PaneBorderSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
260 s1
->Add(1, 1, 1, wxEXPAND
);
261 s1
->Add(new wxStaticText(this, wxID_ANY
, wxT("Pane Border Size:")));
262 s1
->Add(m_border_size
);
263 s1
->Add(1, 1, 1, wxEXPAND
);
264 s1
->SetItemMinSize((size_t)1, 180, 20);
265 //vert->Add(s1, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
267 wxBoxSizer
* s2
= new wxBoxSizer(wxHORIZONTAL
);
268 m_sash_size
= new wxSpinCtrl(this, ID_SashSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
269 s2
->Add(1, 1, 1, wxEXPAND
);
270 s2
->Add(new wxStaticText(this, wxID_ANY
, wxT("Sash Size:")));
271 s2
->Add(m_sash_size
);
272 s2
->Add(1, 1, 1, wxEXPAND
);
273 s2
->SetItemMinSize((size_t)1, 180, 20);
274 //vert->Add(s2, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
276 wxBoxSizer
* s3
= new wxBoxSizer(wxHORIZONTAL
);
277 m_caption_size
= new wxSpinCtrl(this, ID_CaptionSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
278 s3
->Add(1, 1, 1, wxEXPAND
);
279 s3
->Add(new wxStaticText(this, wxID_ANY
, wxT("Caption Size:")));
280 s3
->Add(m_caption_size
);
281 s3
->Add(1, 1, 1, wxEXPAND
);
282 s3
->SetItemMinSize((size_t)1, 180, 20);
283 //vert->Add(s3, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
285 //vert->Add(1, 1, 1, wxEXPAND);
288 wxBitmap b
= CreateColorBitmap(*wxBLACK
);
290 wxBoxSizer
* s4
= new wxBoxSizer(wxHORIZONTAL
);
291 m_background_color
= new wxBitmapButton(this, ID_BackgroundColor
, b
, wxDefaultPosition
, wxSize(50,25));
292 s4
->Add(1, 1, 1, wxEXPAND
);
293 s4
->Add(new wxStaticText(this, wxID_ANY
, wxT("Background Color:")));
294 s4
->Add(m_background_color
);
295 s4
->Add(1, 1, 1, wxEXPAND
);
296 s4
->SetItemMinSize((size_t)1, 180, 20);
298 wxBoxSizer
* s5
= new wxBoxSizer(wxHORIZONTAL
);
299 m_sash_color
= new wxBitmapButton(this, ID_SashColor
, b
, wxDefaultPosition
, wxSize(50,25));
300 s5
->Add(1, 1, 1, wxEXPAND
);
301 s5
->Add(new wxStaticText(this, wxID_ANY
, wxT("Sash Color:")));
302 s5
->Add(m_sash_color
);
303 s5
->Add(1, 1, 1, wxEXPAND
);
304 s5
->SetItemMinSize((size_t)1, 180, 20);
306 wxBoxSizer
* s6
= new wxBoxSizer(wxHORIZONTAL
);
307 m_inactive_caption_color
= new wxBitmapButton(this, ID_InactiveCaptionColor
, b
, wxDefaultPosition
, wxSize(50,25));
308 s6
->Add(1, 1, 1, wxEXPAND
);
309 s6
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption:")));
310 s6
->Add(m_inactive_caption_color
);
311 s6
->Add(1, 1, 1, wxEXPAND
);
312 s6
->SetItemMinSize((size_t)1, 180, 20);
314 wxBoxSizer
* s7
= new wxBoxSizer(wxHORIZONTAL
);
315 m_inactive_caption_gradient_color
= new wxBitmapButton(this, ID_InactiveCaptionGradientColor
, b
, wxDefaultPosition
, wxSize(50,25));
316 s7
->Add(1, 1, 1, wxEXPAND
);
317 s7
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption Gradient:")));
318 s7
->Add(m_inactive_caption_gradient_color
);
319 s7
->Add(1, 1, 1, wxEXPAND
);
320 s7
->SetItemMinSize((size_t)1, 180, 20);
322 wxBoxSizer
* s8
= new wxBoxSizer(wxHORIZONTAL
);
323 m_inactive_caption_text_color
= new wxBitmapButton(this, ID_InactiveCaptionTextColor
, b
, wxDefaultPosition
, wxSize(50,25));
324 s8
->Add(1, 1, 1, wxEXPAND
);
325 s8
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption Text:")));
326 s8
->Add(m_inactive_caption_text_color
);
327 s8
->Add(1, 1, 1, wxEXPAND
);
328 s8
->SetItemMinSize((size_t)1, 180, 20);
330 wxBoxSizer
* s9
= new wxBoxSizer(wxHORIZONTAL
);
331 m_active_caption_color
= new wxBitmapButton(this, ID_ActiveCaptionColor
, b
, wxDefaultPosition
, wxSize(50,25));
332 s9
->Add(1, 1, 1, wxEXPAND
);
333 s9
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption:")));
334 s9
->Add(m_active_caption_color
);
335 s9
->Add(1, 1, 1, wxEXPAND
);
336 s9
->SetItemMinSize((size_t)1, 180, 20);
338 wxBoxSizer
* s10
= new wxBoxSizer(wxHORIZONTAL
);
339 m_active_caption_gradient_color
= new wxBitmapButton(this, ID_ActiveCaptionGradientColor
, b
, wxDefaultPosition
, wxSize(50,25));
340 s10
->Add(1, 1, 1, wxEXPAND
);
341 s10
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption Gradient:")));
342 s10
->Add(m_active_caption_gradient_color
);
343 s10
->Add(1, 1, 1, wxEXPAND
);
344 s10
->SetItemMinSize((size_t)1, 180, 20);
346 wxBoxSizer
* s11
= new wxBoxSizer(wxHORIZONTAL
);
347 m_active_caption_text_color
= new wxBitmapButton(this, ID_ActiveCaptionTextColor
, b
, wxDefaultPosition
, wxSize(50,25));
348 s11
->Add(1, 1, 1, wxEXPAND
);
349 s11
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption Text:")));
350 s11
->Add(m_active_caption_text_color
);
351 s11
->Add(1, 1, 1, wxEXPAND
);
352 s11
->SetItemMinSize((size_t)1, 180, 20);
354 wxBoxSizer
* s12
= new wxBoxSizer(wxHORIZONTAL
);
355 m_border_color
= new wxBitmapButton(this, ID_BorderColor
, b
, wxDefaultPosition
, wxSize(50,25));
356 s12
->Add(1, 1, 1, wxEXPAND
);
357 s12
->Add(new wxStaticText(this, wxID_ANY
, wxT("Border Color:")));
358 s12
->Add(m_border_color
);
359 s12
->Add(1, 1, 1, wxEXPAND
);
360 s12
->SetItemMinSize((size_t)1, 180, 20);
362 wxBoxSizer
* s13
= new wxBoxSizer(wxHORIZONTAL
);
363 m_gripper_color
= new wxBitmapButton(this, ID_GripperColor
, b
, wxDefaultPosition
, wxSize(50,25));
364 s13
->Add(1, 1, 1, wxEXPAND
);
365 s13
->Add(new wxStaticText(this, wxID_ANY
, wxT("Gripper Color:")));
366 s13
->Add(m_gripper_color
);
367 s13
->Add(1, 1, 1, wxEXPAND
);
368 s13
->SetItemMinSize((size_t)1, 180, 20);
370 wxGridSizer
* grid_sizer
= new wxGridSizer(2);
371 grid_sizer
->SetHGap(5);
372 grid_sizer
->Add(s1
); grid_sizer
->Add(s4
);
373 grid_sizer
->Add(s2
); grid_sizer
->Add(s5
);
374 grid_sizer
->Add(s3
); grid_sizer
->Add(s13
);
375 grid_sizer
->Add(1,1); grid_sizer
->Add(s12
);
376 grid_sizer
->Add(s6
); grid_sizer
->Add(s9
);
377 grid_sizer
->Add(s7
); grid_sizer
->Add(s10
);
378 grid_sizer
->Add(s8
); grid_sizer
->Add(s11
);
380 wxBoxSizer
* cont_sizer
= new wxBoxSizer(wxVERTICAL
);
381 cont_sizer
->Add(grid_sizer
, 1, wxEXPAND
| wxALL
, 5);
382 SetSizer(cont_sizer
);
383 GetSizer()->SetSizeHints(this);
386 m_border_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
));
387 m_sash_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_SASH_SIZE
));
388 m_caption_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_CAPTION_SIZE
));
395 wxBitmap
CreateColorBitmap(const wxColour
& c
)
399 for (int x
= 0; x
< 25; ++x
)
400 for (int y
= 0; y
< 14; ++y
)
403 if (x
== 0 || x
== 24 || y
== 0 || y
== 13)
405 image
.SetRGB(x
, y
, pixcol
.Red(), pixcol
.Green(), pixcol
.Blue());
407 return wxBitmap(image
);
412 wxColour bk
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_BACKGROUND_COLOUR
);
413 m_background_color
->SetBitmapLabel(CreateColorBitmap(bk
));
415 wxColour cap
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_COLOUR
);
416 m_inactive_caption_color
->SetBitmapLabel(CreateColorBitmap(cap
));
418 wxColour capgrad
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
);
419 m_inactive_caption_gradient_color
->SetBitmapLabel(CreateColorBitmap(capgrad
));
421 wxColour captxt
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
);
422 m_inactive_caption_text_color
->SetBitmapLabel(CreateColorBitmap(captxt
));
424 wxColour acap
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_COLOUR
);
425 m_active_caption_color
->SetBitmapLabel(CreateColorBitmap(acap
));
427 wxColour acapgrad
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
);
428 m_active_caption_gradient_color
->SetBitmapLabel(CreateColorBitmap(acapgrad
));
430 wxColour acaptxt
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
);
431 m_active_caption_text_color
->SetBitmapLabel(CreateColorBitmap(acaptxt
));
433 wxColour sash
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_SASH_COLOUR
);
434 m_sash_color
->SetBitmapLabel(CreateColorBitmap(sash
));
436 wxColour border
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_BORDER_COLOUR
);
437 m_border_color
->SetBitmapLabel(CreateColorBitmap(border
));
439 wxColour gripper
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_GRIPPER_COLOUR
);
440 m_gripper_color
->SetBitmapLabel(CreateColorBitmap(gripper
));
443 void OnPaneBorderSize(wxSpinEvent
& event
)
445 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_PANE_BORDER_SIZE
,
446 event
.GetPosition());
450 void OnSashSize(wxSpinEvent
& event
)
452 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_SASH_SIZE
,
453 event
.GetPosition());
457 void OnCaptionSize(wxSpinEvent
& event
)
459 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_CAPTION_SIZE
,
460 event
.GetPosition());
464 void OnSetColor(wxCommandEvent
& event
)
466 wxColourDialog
dlg(m_frame
);
467 dlg
.SetTitle(_("Color Picker"));
468 if (dlg
.ShowModal() != wxID_OK
)
472 switch (event
.GetId())
474 case ID_BackgroundColor
: var
= wxAUI_ART_BACKGROUND_COLOUR
; break;
475 case ID_SashColor
: var
= wxAUI_ART_SASH_COLOUR
; break;
476 case ID_InactiveCaptionColor
: var
= wxAUI_ART_INACTIVE_CAPTION_COLOUR
; break;
477 case ID_InactiveCaptionGradientColor
: var
= wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
; break;
478 case ID_InactiveCaptionTextColor
: var
= wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
; break;
479 case ID_ActiveCaptionColor
: var
= wxAUI_ART_ACTIVE_CAPTION_COLOUR
; break;
480 case ID_ActiveCaptionGradientColor
: var
= wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
; break;
481 case ID_ActiveCaptionTextColor
: var
= wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
; break;
482 case ID_BorderColor
: var
= wxAUI_ART_BORDER_COLOUR
; break;
483 case ID_GripperColor
: var
= wxAUI_ART_GRIPPER_COLOUR
; break;
487 m_frame
->GetDockArt()->SetColor(var
, dlg
.GetColourData().GetColour());
495 wxSpinCtrl
* m_border_size
;
496 wxSpinCtrl
* m_sash_size
;
497 wxSpinCtrl
* m_caption_size
;
498 wxBitmapButton
* m_inactive_caption_text_color
;
499 wxBitmapButton
* m_inactive_caption_gradient_color
;
500 wxBitmapButton
* m_inactive_caption_color
;
501 wxBitmapButton
* m_active_caption_text_color
;
502 wxBitmapButton
* m_active_caption_gradient_color
;
503 wxBitmapButton
* m_active_caption_color
;
504 wxBitmapButton
* m_sash_color
;
505 wxBitmapButton
* m_background_color
;
506 wxBitmapButton
* m_border_color
;
507 wxBitmapButton
* m_gripper_color
;
509 DECLARE_EVENT_TABLE()
512 BEGIN_EVENT_TABLE(SettingsPanel
, wxPanel
)
513 EVT_SPINCTRL(ID_PaneBorderSize
, SettingsPanel::OnPaneBorderSize
)
514 EVT_SPINCTRL(ID_SashSize
, SettingsPanel::OnSashSize
)
515 EVT_SPINCTRL(ID_CaptionSize
, SettingsPanel::OnCaptionSize
)
516 EVT_BUTTON(ID_BackgroundColor
, SettingsPanel::OnSetColor
)
517 EVT_BUTTON(ID_SashColor
, SettingsPanel::OnSetColor
)
518 EVT_BUTTON(ID_InactiveCaptionColor
, SettingsPanel::OnSetColor
)
519 EVT_BUTTON(ID_InactiveCaptionGradientColor
, SettingsPanel::OnSetColor
)
520 EVT_BUTTON(ID_InactiveCaptionTextColor
, SettingsPanel::OnSetColor
)
521 EVT_BUTTON(ID_ActiveCaptionColor
, SettingsPanel::OnSetColor
)
522 EVT_BUTTON(ID_ActiveCaptionGradientColor
, SettingsPanel::OnSetColor
)
523 EVT_BUTTON(ID_ActiveCaptionTextColor
, SettingsPanel::OnSetColor
)
524 EVT_BUTTON(ID_BorderColor
, SettingsPanel::OnSetColor
)
525 EVT_BUTTON(ID_GripperColor
, SettingsPanel::OnSetColor
)
531 wxFrame
* frame
= new MyFrame(NULL
,
533 wxT("wxAUI Sample Application"),
542 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
543 EVT_ERASE_BACKGROUND(MyFrame::OnEraseBackground
)
544 EVT_SIZE(MyFrame::OnSize
)
545 EVT_MENU(MyFrame::ID_CreateTree
, MyFrame::OnCreateTree
)
546 EVT_MENU(MyFrame::ID_CreateGrid
, MyFrame::OnCreateGrid
)
547 EVT_MENU(MyFrame::ID_CreateText
, MyFrame::OnCreateText
)
548 EVT_MENU(MyFrame::ID_CreateHTML
, MyFrame::OnCreateHTML
)
549 EVT_MENU(MyFrame::ID_CreateSizeReport
, MyFrame::OnCreateSizeReport
)
550 EVT_MENU(MyFrame::ID_CreatePerspective
, MyFrame::OnCreatePerspective
)
551 EVT_MENU(MyFrame::ID_CopyPerspectiveCode
, MyFrame::OnCopyPerspectiveCode
)
552 EVT_MENU(ID_AllowFloating
, MyFrame::OnManagerFlag
)
553 EVT_MENU(ID_TransparentHint
, MyFrame::OnManagerFlag
)
554 EVT_MENU(ID_TransparentHintFade
, MyFrame::OnManagerFlag
)
555 EVT_MENU(ID_DisableVenetian
, MyFrame::OnManagerFlag
)
556 EVT_MENU(ID_DisableVenetianFade
, MyFrame::OnManagerFlag
)
557 EVT_MENU(ID_TransparentDrag
, MyFrame::OnManagerFlag
)
558 EVT_MENU(ID_AllowActivePane
, MyFrame::OnManagerFlag
)
559 EVT_MENU(ID_NoGradient
, MyFrame::OnGradient
)
560 EVT_MENU(ID_VerticalGradient
, MyFrame::OnGradient
)
561 EVT_MENU(ID_HorizontalGradient
, MyFrame::OnGradient
)
562 EVT_MENU(ID_Settings
, MyFrame::OnSettings
)
563 EVT_MENU(ID_GridContent
, MyFrame::OnChangeContentPane
)
564 EVT_MENU(ID_TreeContent
, MyFrame::OnChangeContentPane
)
565 EVT_MENU(ID_TextContent
, MyFrame::OnChangeContentPane
)
566 EVT_MENU(ID_SizeReportContent
, MyFrame::OnChangeContentPane
)
567 EVT_MENU(ID_HTMLContent
, MyFrame::OnChangeContentPane
)
568 EVT_MENU(ID_NotebookContent
, MyFrame::OnChangeContentPane
)
569 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
570 EVT_MENU(wxID_ABOUT
, MyFrame::OnAbout
)
571 EVT_UPDATE_UI(ID_AllowFloating
, MyFrame::OnUpdateUI
)
572 EVT_UPDATE_UI(ID_TransparentHint
, MyFrame::OnUpdateUI
)
573 EVT_UPDATE_UI(ID_TransparentHintFade
, MyFrame::OnUpdateUI
)
574 EVT_UPDATE_UI(ID_DisableVenetian
, MyFrame::OnUpdateUI
)
575 EVT_UPDATE_UI(ID_DisableVenetianFade
, MyFrame::OnUpdateUI
)
576 EVT_UPDATE_UI(ID_TransparentDrag
, MyFrame::OnUpdateUI
)
577 EVT_UPDATE_UI(ID_NoGradient
, MyFrame::OnUpdateUI
)
578 EVT_UPDATE_UI(ID_VerticalGradient
, MyFrame::OnUpdateUI
)
579 EVT_UPDATE_UI(ID_HorizontalGradient
, MyFrame::OnUpdateUI
)
580 EVT_MENU_RANGE(MyFrame::ID_FirstPerspective
, MyFrame::ID_FirstPerspective
+1000,
581 MyFrame::OnRestorePerspective
)
582 EVT_AUI_PANECLOSE(MyFrame::OnPaneClose
)
586 MyFrame::MyFrame(wxWindow
* parent
,
588 const wxString
& title
,
592 : wxFrame(parent
, id
, title
, pos
, size
, style
)
594 // tell wxFrameManager to manage this frame
595 m_mgr
.SetManagedWindow(this);
598 SetIcon(wxIcon(sample_xpm
));
601 wxMenuBar
* mb
= new wxMenuBar
;
603 wxMenu
* file_menu
= new wxMenu
;
604 file_menu
->Append(wxID_EXIT
, _("Exit"));
606 wxMenu
* view_menu
= new wxMenu
;
607 view_menu
->Append(ID_CreateText
, _("Create Text Control"));
608 view_menu
->Append(ID_CreateHTML
, _("Create HTML Control"));
609 view_menu
->Append(ID_CreateTree
, _("Create Tree"));
610 view_menu
->Append(ID_CreateGrid
, _("Create Grid"));
611 view_menu
->Append(ID_CreateSizeReport
, _("Create Size Reporter"));
612 view_menu
->AppendSeparator();
613 view_menu
->Append(ID_GridContent
, _("Use a Grid for the Content Pane"));
614 view_menu
->Append(ID_TextContent
, _("Use a Text Control for the Content Pane"));
615 view_menu
->Append(ID_HTMLContent
, _("Use an HTML Control for the Content Pane"));
616 view_menu
->Append(ID_TreeContent
, _("Use a Tree Control for the Content Pane"));
617 view_menu
->Append(ID_NotebookContent
, _("Use a AUI wxMultiNotebook control for the Content Pane"));
618 view_menu
->Append(ID_SizeReportContent
, _("Use a Size Reporter for the Content Pane"));
620 wxMenu
* options_menu
= new wxMenu
;
621 options_menu
->AppendCheckItem(ID_AllowFloating
, _("Allow Floating"));
622 options_menu
->AppendCheckItem(ID_TransparentHint
, _("Transparent Hint"));
623 options_menu
->AppendCheckItem(ID_TransparentHintFade
, _("Transparent Hint Fade-in"));
624 options_menu
->AppendCheckItem(ID_DisableVenetian
, _("Disable Venetian Blinds Hint"));
625 options_menu
->AppendCheckItem(ID_DisableVenetianFade
, _("Disable Venetian Blinds Hint Fade-in"));
626 options_menu
->AppendCheckItem(ID_TransparentDrag
, _("Transparent Drag"));
627 options_menu
->AppendCheckItem(ID_AllowActivePane
, _("Allow Active Pane"));
628 options_menu
->AppendSeparator();
629 options_menu
->AppendRadioItem(ID_NoGradient
, _("No Caption Gradient"));
630 options_menu
->AppendRadioItem(ID_VerticalGradient
, _("Vertical Caption Gradient"));
631 options_menu
->AppendRadioItem(ID_HorizontalGradient
, _("Horizontal Caption Gradient"));
632 options_menu
->AppendSeparator();
633 options_menu
->Append(ID_Settings
, _("Settings Pane"));
635 m_perspectives_menu
= new wxMenu
;
636 m_perspectives_menu
->Append(ID_CreatePerspective
, _("Create Perspective"));
637 m_perspectives_menu
->Append(ID_CopyPerspectiveCode
, _("Copy Perspective Data To Clipboard"));
638 m_perspectives_menu
->AppendSeparator();
639 m_perspectives_menu
->Append(ID_FirstPerspective
+0, _("Default Startup"));
640 m_perspectives_menu
->Append(ID_FirstPerspective
+1, _("All Panes"));
642 wxMenu
* help_menu
= new wxMenu
;
643 help_menu
->Append(wxID_ABOUT
, _("About..."));
645 mb
->Append(file_menu
, _("File"));
646 mb
->Append(view_menu
, _("View"));
647 mb
->Append(m_perspectives_menu
, _("Perspectives"));
648 mb
->Append(options_menu
, _("Options"));
649 mb
->Append(help_menu
, _("Help"));
654 GetStatusBar()->SetStatusText(_("Ready"));
657 // min size for the frame itself isn't completely done.
658 // see the end up wxFrameManager::Update() for the test
659 // code. For now, just hard code a frame minimum size
660 SetMinSize(wxSize(400,300));
662 // create some toolbars
663 wxToolBar
* tb1
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
664 wxTB_FLAT
| wxTB_NODIVIDER
);
665 tb1
->SetToolBitmapSize(wxSize(48,48));
666 tb1
->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR
));
668 tb1
->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION
));
669 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION
));
670 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING
));
671 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE
));
675 wxToolBar
* tb2
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
676 wxTB_FLAT
| wxTB_NODIVIDER
);
677 tb2
->SetToolBitmapSize(wxSize(16,16));
679 wxBitmap tb2_bmp1
= wxArtProvider::GetBitmap(wxART_QUESTION
, wxART_OTHER
, wxSize(16,16));
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
);
685 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
686 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
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
);
695 wxToolBar
* tb3
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
696 wxTB_FLAT
| wxTB_NODIVIDER
);
697 tb3
->SetToolBitmapSize(wxSize(16,16));
698 wxBitmap tb3_bmp1
= wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_OTHER
, wxSize(16,16));
699 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
700 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
701 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
702 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
704 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
705 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
709 wxToolBar
* tb4
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
710 wxTB_FLAT
| wxTB_NODIVIDER
| wxTB_HORZ_TEXT
);
711 tb4
->SetToolBitmapSize(wxSize(16,16));
712 wxBitmap tb4_bmp1
= wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_OTHER
, wxSize(16,16));
713 tb4
->AddTool(101, wxT("Item 1"), tb4_bmp1
);
714 tb4
->AddTool(101, wxT("Item 2"), tb4_bmp1
);
715 tb4
->AddTool(101, wxT("Item 3"), tb4_bmp1
);
716 tb4
->AddTool(101, wxT("Item 4"), tb4_bmp1
);
718 tb4
->AddTool(101, wxT("Item 5"), tb4_bmp1
);
719 tb4
->AddTool(101, wxT("Item 6"), tb4_bmp1
);
720 tb4
->AddTool(101, wxT("Item 7"), tb4_bmp1
);
721 tb4
->AddTool(101, wxT("Item 8"), tb4_bmp1
);
724 // create some toolbars
725 wxToolBar
* tb5
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
726 wxTB_FLAT
| wxTB_NODIVIDER
| wxTB_VERTICAL
);
727 tb5
->SetToolBitmapSize(wxSize(48,48));
728 tb5
->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR
));
730 tb5
->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION
));
731 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION
));
732 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING
));
733 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE
));
737 // add a bunch of panes
738 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
739 Name(wxT("test1")).Caption(wxT("Pane Caption")).
742 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
743 Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
744 Bottom().Position(1));
746 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
747 Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
750 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
751 Name(wxT("test4")).Caption(wxT("Pane Caption")).
754 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
755 Name(wxT("test5")).Caption(wxT("No Close Button")).
756 Right().CloseButton(false));
758 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
759 Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
762 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
763 Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
766 m_mgr
.AddPane(CreateTreeCtrl(), wxPaneInfo().
767 Name(wxT("test8")).Caption(wxT("Tree Pane")).
768 Left().Layer(1).Position(1));
770 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
771 Name(wxT("test9")).Caption(wxT("Min Size 200x100")).
772 BestSize(wxSize(200,100)).MinSize(wxSize(200,100)).
775 wxWindow
* wnd10
= CreateTextCtrl(wxT("This pane will prompt the user before hiding."));
776 m_mgr
.AddPane(wnd10
, wxPaneInfo().
777 Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")).
778 Bottom().Layer(1).Position(1));
780 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
781 Name(wxT("test11")).Caption(wxT("Fixed Pane")).
782 Bottom().Layer(1).Position(2).Fixed());
785 m_mgr
.AddPane(new SettingsPanel(this,this), wxPaneInfo().
786 Name(wxT("settings")).Caption(wxT("Dock Manager Settings")).
787 Dockable(false).Float().Hide());
789 // create some center panes
791 m_mgr
.AddPane(CreateGrid(), wxPaneInfo().Name(wxT("grid_content")).
792 CenterPane().Hide());
794 m_mgr
.AddPane(CreateTreeCtrl(), wxPaneInfo().Name(wxT("tree_content")).
795 CenterPane().Hide());
797 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().Name(wxT("sizereport_content")).
798 CenterPane().Hide());
800 m_mgr
.AddPane(CreateTextCtrl(), wxPaneInfo().Name(wxT("text_content")).
801 CenterPane().Hide());
803 m_mgr
.AddPane(CreateHTMLCtrl(), wxPaneInfo().Name(wxT("html_content")).
806 m_mgr
.AddPane(CreateNotebook(), wxPaneInfo().Name(wxT("notebook_content")).
807 CenterPane().PaneBorder(false));
809 // add the toolbars to the manager
811 m_mgr
.AddPane(tb1
, wxPaneInfo().
812 Name(wxT("tb1")).Caption(wxT("Big Toolbar")).
814 LeftDockable(false).RightDockable(false));
816 m_mgr
.AddPane(tb2
, wxPaneInfo().
817 Name(wxT("tb2")).Caption(wxT("Toolbar 2")).
818 ToolbarPane().Top().Row(1).
819 LeftDockable(false).RightDockable(false));
821 m_mgr
.AddPane(tb3
, wxPaneInfo().
822 Name(wxT("tb3")).Caption(wxT("Toolbar 3")).
823 ToolbarPane().Top().Row(1).Position(1).
824 LeftDockable(false).RightDockable(false));
826 m_mgr
.AddPane(tb4
, wxPaneInfo().
827 Name(wxT("tb4")).Caption(wxT("Sample Bookmark Toolbar")).
828 ToolbarPane().Top().Row(2).
829 LeftDockable(false).RightDockable(false));
831 m_mgr
.AddPane(tb5
, wxPaneInfo().
832 Name(wxT("tb5")).Caption(wxT("Sample Vertical Toolbar")).
833 ToolbarPane().Left().
835 TopDockable(false).BottomDockable(false));
837 m_mgr
.AddPane(new wxButton(this, wxID_ANY
, _("Test Button")),
838 wxPaneInfo().Name(wxT("tb6")).
839 ToolbarPane().Top().Row(2).Position(1).
840 LeftDockable(false).RightDockable(false));
843 // make some default perspectives
845 wxString perspective_all
= m_mgr
.SavePerspective();
848 wxPaneInfoArray
& all_panes
= m_mgr
.GetAllPanes();
849 for (i
= 0, count
= all_panes
.GetCount(); i
< count
; ++i
)
850 if (!all_panes
.Item(i
).IsToolbar())
851 all_panes
.Item(i
).Hide();
852 m_mgr
.GetPane(wxT("tb1")).Hide();
853 m_mgr
.GetPane(wxT("tb6")).Hide();
854 m_mgr
.GetPane(wxT("test8")).Show().Left().Layer(0).Row(0).Position(0);
855 m_mgr
.GetPane(wxT("test10")).Show().Bottom().Layer(0).Row(0).Position(0);
856 m_mgr
.GetPane(wxT("html_content")).Show();
857 wxString perspective_default
= m_mgr
.SavePerspective();
859 m_perspectives
.Add(perspective_default
);
860 m_perspectives
.Add(perspective_all
);
862 // "commit" all changes made to wxFrameManager
871 wxDockArt
* MyFrame::GetDockArt()
873 return m_mgr
.GetArtProvider();
876 void MyFrame::DoUpdate()
881 void MyFrame::OnEraseBackground(wxEraseEvent
& event
)
886 void MyFrame::OnSize(wxSizeEvent
& event
)
891 void MyFrame::OnSettings(wxCommandEvent
& WXUNUSED(event
))
893 // show the settings pane, and float it
894 wxPaneInfo
& floating_pane
= m_mgr
.GetPane(wxT("settings")).Float().Show();
896 if (floating_pane
.floating_pos
== wxDefaultPosition
)
897 floating_pane
.FloatingPosition(GetStartPosition());
902 void MyFrame::OnGradient(wxCommandEvent
& event
)
906 switch (event
.GetId())
908 case ID_NoGradient
: gradient
= wxAUI_GRADIENT_NONE
; break;
909 case ID_VerticalGradient
: gradient
= wxAUI_GRADIENT_VERTICAL
; break;
910 case ID_HorizontalGradient
: gradient
= wxAUI_GRADIENT_HORIZONTAL
; break;
913 m_mgr
.GetArtProvider()->SetMetric(wxAUI_ART_GRADIENT_TYPE
, gradient
);
917 void MyFrame::OnManagerFlag(wxCommandEvent
& event
)
919 unsigned int flag
= 0;
921 #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__)
922 if (event
.GetId() == ID_TransparentDrag
||
923 event
.GetId() == ID_TransparentHint
||
924 event
.GetId() == ID_TransparentHintFade
)
926 wxMessageBox(wxT("This option is presently only available on wxGTK, wxMSW and wxMac"));
931 switch (event
.GetId())
933 case ID_AllowFloating
: flag
= wxAUI_MGR_ALLOW_FLOATING
; break;
934 case ID_TransparentDrag
: flag
= wxAUI_MGR_TRANSPARENT_DRAG
; break;
935 case ID_TransparentHint
: flag
= wxAUI_MGR_TRANSPARENT_HINT
; break;
936 case ID_TransparentHintFade
: flag
= wxAUI_MGR_TRANSPARENT_HINT_FADE
; break;
937 case ID_DisableVenetian
: flag
= wxAUI_MGR_DISABLE_VENETIAN_BLINDS
; break;
938 case ID_DisableVenetianFade
: flag
= wxAUI_MGR_DISABLE_VENETIAN_BLINDS_FADE
; break;
939 case ID_AllowActivePane
: flag
= wxAUI_MGR_ALLOW_ACTIVE_PANE
; break;
941 m_mgr
.SetFlags(m_mgr
.GetFlags() ^ flag
);
945 void MyFrame::OnUpdateUI(wxUpdateUIEvent
& event
)
947 unsigned int flags
= m_mgr
.GetFlags();
949 switch (event
.GetId())
952 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_NONE
);
954 case ID_VerticalGradient
:
955 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_VERTICAL
);
957 case ID_HorizontalGradient
:
958 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_HORIZONTAL
);
960 case ID_AllowFloating
:
961 event
.Check((flags
& wxAUI_MGR_ALLOW_FLOATING
) != 0);
963 case ID_TransparentDrag
:
964 event
.Check((flags
& wxAUI_MGR_TRANSPARENT_DRAG
) != 0);
966 case ID_TransparentHint
:
967 event
.Check((flags
& wxAUI_MGR_TRANSPARENT_HINT
) != 0);
969 case ID_TransparentHintFade
:
970 event
.Check((flags
& wxAUI_MGR_TRANSPARENT_HINT_FADE
) != 0);
972 case ID_DisableVenetian
:
973 event
.Check((flags
& wxAUI_MGR_DISABLE_VENETIAN_BLINDS
) != 0);
975 case ID_DisableVenetianFade
:
976 event
.Check((flags
& wxAUI_MGR_DISABLE_VENETIAN_BLINDS_FADE
) != 0);
981 void MyFrame::OnPaneClose(wxFrameManagerEvent
& evt
)
983 if (evt
.pane
->name
== wxT("test10"))
985 int res
= wxMessageBox(wxT("Are you sure you want to close/hide this pane?"),
994 void MyFrame::OnCreatePerspective(wxCommandEvent
& WXUNUSED(event
))
996 wxTextEntryDialog
dlg(this, wxT("Enter a name for the new perspective:"),
999 dlg
.SetValue(wxString::Format(wxT("Perspective %u"), unsigned(m_perspectives
.GetCount() + 1)));
1000 if (dlg
.ShowModal() != wxID_OK
)
1003 if (m_perspectives
.GetCount() == 0)
1005 m_perspectives_menu
->AppendSeparator();
1008 m_perspectives_menu
->Append(ID_FirstPerspective
+ m_perspectives
.GetCount(), dlg
.GetValue());
1009 m_perspectives
.Add(m_mgr
.SavePerspective());
1012 void MyFrame::OnCopyPerspectiveCode(wxCommandEvent
& WXUNUSED(event
))
1014 wxString s
= m_mgr
.SavePerspective();
1017 if (wxTheClipboard
->Open())
1019 wxTheClipboard
->SetData(new wxTextDataObject(s
));
1020 wxTheClipboard
->Close();
1025 void MyFrame::OnRestorePerspective(wxCommandEvent
& event
)
1027 m_mgr
.LoadPerspective(m_perspectives
.Item(event
.GetId() - ID_FirstPerspective
));
1031 wxPoint
MyFrame::GetStartPosition()
1035 wxPoint pt
= ClientToScreen(wxPoint(0,0));
1036 return wxPoint(pt
.x
+ x
, pt
.y
+ x
);
1039 void MyFrame::OnCreateTree(wxCommandEvent
& WXUNUSED(event
))
1041 m_mgr
.AddPane(CreateTreeCtrl(), wxPaneInfo().
1042 Name(wxT("Test")).Caption(wxT("Tree Control")).
1043 Float().FloatingPosition(GetStartPosition()).
1044 FloatingSize(wxSize(150,300)));
1048 void MyFrame::OnCreateGrid(wxCommandEvent
& WXUNUSED(event
))
1050 m_mgr
.AddPane(CreateGrid(), wxPaneInfo().
1051 Name(wxT("Test")).Caption(wxT("Grid")).
1052 Float().FloatingPosition(GetStartPosition()).
1053 FloatingSize(wxSize(300,200)));
1057 void MyFrame::OnCreateHTML(wxCommandEvent
& WXUNUSED(event
))
1059 m_mgr
.AddPane(CreateHTMLCtrl(), wxPaneInfo().
1060 Name(wxT("Test")).Caption(wxT("HTML Control")).
1061 Float().FloatingPosition(GetStartPosition()).
1062 FloatingSize(wxSize(300,200)));
1066 void MyFrame::OnCreateNotebook(wxCommandEvent
& WXUNUSED(event
))
1068 m_mgr
.AddPane(CreateNotebook(), wxPaneInfo().
1069 Name(wxT("Test")).Caption(wxT("Notebook")).
1070 Float().FloatingPosition(GetStartPosition()).
1071 FloatingSize(wxSize(300,200)));
1075 void MyFrame::OnCreateText(wxCommandEvent
& WXUNUSED(event
))
1077 m_mgr
.AddPane(CreateTextCtrl(), wxPaneInfo().
1078 Name(wxT("Test")).Caption(wxT("Text Control")).
1079 Float().FloatingPosition(GetStartPosition()));
1083 void MyFrame::OnCreateSizeReport(wxCommandEvent
& WXUNUSED(event
))
1085 m_mgr
.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
1086 Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
1087 Float().FloatingPosition(GetStartPosition()));
1091 void MyFrame::OnChangeContentPane(wxCommandEvent
& event
)
1093 m_mgr
.GetPane(wxT("grid_content")).Show(event
.GetId() == ID_GridContent
);
1094 m_mgr
.GetPane(wxT("text_content")).Show(event
.GetId() == ID_TextContent
);
1095 m_mgr
.GetPane(wxT("tree_content")).Show(event
.GetId() == ID_TreeContent
);
1096 m_mgr
.GetPane(wxT("sizereport_content")).Show(event
.GetId() == ID_SizeReportContent
);
1097 m_mgr
.GetPane(wxT("html_content")).Show(event
.GetId() == ID_HTMLContent
);
1098 m_mgr
.GetPane(wxT("notebook_content")).Show(event
.GetId() == ID_NotebookContent
);
1102 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
1107 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
1109 wxMessageBox(_("wxAUI Demo\nAn advanced window management library for wxWidgets\n(c) Copyright 2005-2006, Kirix Corporation"), _("About wxAUI Demo"), wxOK
, this);
1112 wxTextCtrl
* MyFrame::CreateTextCtrl(const wxString
& ctrl_text
)
1117 if (ctrl_text
.Length() > 0)
1120 text
.Printf(wxT("This is text box %d"), ++n
);
1122 return new wxTextCtrl(this,wxID_ANY
, text
,
1123 wxPoint(0,0), wxSize(150,90),
1124 wxNO_BORDER
| wxTE_MULTILINE
);
1128 wxGrid
* MyFrame::CreateGrid()
1130 wxGrid
* grid
= new wxGrid(this, wxID_ANY
,
1133 wxNO_BORDER
| wxWANTS_CHARS
);
1134 grid
->CreateGrid(50, 20);
1138 wxTreeCtrl
* MyFrame::CreateTreeCtrl()
1140 wxTreeCtrl
* tree
= new wxTreeCtrl(this, wxID_ANY
,
1141 wxPoint(0,0), wxSize(160,250),
1142 wxTR_DEFAULT_STYLE
| wxNO_BORDER
);
1144 wxTreeItemId root
= tree
->AddRoot(wxT("wxAUI Project"));
1145 wxArrayTreeItemIds items
;
1148 wxImageList
* imglist
= new wxImageList(16, 16, true, 2);
1149 imglist
->Add(wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_OTHER
, wxSize(16,16)));
1150 imglist
->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_OTHER
, wxSize(16,16)));
1151 tree
->AssignImageList(imglist
);
1153 items
.Add(tree
->AppendItem(root
, wxT("Item 1"), 0));
1154 items
.Add(tree
->AppendItem(root
, wxT("Item 2"), 0));
1155 items
.Add(tree
->AppendItem(root
, wxT("Item 3"), 0));
1156 items
.Add(tree
->AppendItem(root
, wxT("Item 4"), 0));
1157 items
.Add(tree
->AppendItem(root
, wxT("Item 5"), 0));
1161 for (i
= 0, count
= items
.Count(); i
< count
; ++i
)
1163 wxTreeItemId id
= items
.Item(i
);
1164 tree
->AppendItem(id
, wxT("Subitem 1"), 1);
1165 tree
->AppendItem(id
, wxT("Subitem 2"), 1);
1166 tree
->AppendItem(id
, wxT("Subitem 3"), 1);
1167 tree
->AppendItem(id
, wxT("Subitem 4"), 1);
1168 tree
->AppendItem(id
, wxT("Subitem 5"), 1);
1177 wxSizeReportCtrl
* MyFrame::CreateSizeReportCtrl(int width
, int height
)
1179 wxSizeReportCtrl
* ctrl
= new wxSizeReportCtrl(this, wxID_ANY
,
1181 wxSize(width
, height
), &m_mgr
);
1185 wxHtmlWindow
* MyFrame::CreateHTMLCtrl()
1187 wxHtmlWindow
* ctrl
= new wxHtmlWindow(this, wxID_ANY
,
1190 ctrl
->SetPage(GetIntroText());
1194 wxAuiMultiNotebook
* MyFrame::CreateNotebook()
1196 wxAuiMultiNotebook
* ctrl
= new wxAuiMultiNotebook( this, wxID_ANY
,
1197 wxDefaultPosition
, wxSize(400,300), wxNO_BORDER
);
1199 wxPanel
*panel
= new wxPanel( ctrl
, wxID_ANY
);
1200 wxFlexGridSizer
*flex
= new wxFlexGridSizer( 2 );
1201 flex
->AddGrowableRow( 0 );
1202 flex
->AddGrowableRow( 3 );
1203 flex
->AddGrowableCol( 1 );
1204 flex
->Add( 5,5 ); flex
->Add( 5,5 );
1205 flex
->Add( new wxStaticText( panel
, -1, wxT("wxTextCtrl:") ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1206 flex
->Add( new wxTextCtrl( panel
, -1, wxT(""), wxDefaultPosition
, wxSize(100,-1)),
1207 1, wxALL
|wxALIGN_CENTRE
, 5 );
1208 flex
->Add( new wxStaticText( panel
, -1, wxT("wxSpinCtrl:") ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1209 flex
->Add( new wxSpinCtrl( panel
, -1, wxT("5"), wxDefaultPosition
, wxSize(100,-1),
1210 wxSP_ARROW_KEYS
, 5, 50, 5 ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1211 flex
->Add( 5,5 ); flex
->Add( 5,5 );
1212 panel
->SetSizer( flex
);
1213 ctrl
->AddPage( panel
, wxT("wxPanel") );
1215 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some text"),
1216 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl I") );
1218 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1219 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl II") );
1224 wxString
MyFrame::GetIntroText()
1228 "<h3>Welcome to wxAUI</h3>"
1229 "<br/><b>Overview</b><br/>"
1230 "<p>wxAUI is an Advanced User Interface library for the wxWidgets toolkit "
1231 "that allows developers to create high-quality, cross-platform user "
1232 "interfaces quickly and easily.</p>"
1233 "<p><b>Features</b></p>"
1234 "<p>With wxAUI, developers can create application frameworks with:</p>"
1236 "<li>Native, dockable floating frames</li>"
1237 "<li>Perspective saving and loading</li>"
1238 "<li>Native toolbars incorporating real-time, "spring-loaded" dragging</li>"
1239 "<li>Customizable floating/docking behavior</li>"
1240 "<li>Completely customizable look-and-feel</li>"
1241 "<li>Optional transparent window effects (while dragging or docking)</li>"
1243 "<p><b>What's new in 0.9.2?</b></p>"
1244 "<p>The following features/fixes have been added since the last version of wxAUI:</p>"
1246 "<li>Support for wxMac</li>"
1247 "<li>Updates for wxWidgets 2.6.3</li>"
1248 "<li>Fix to pass more unused events through</li>"
1249 "<li>Fix to allow floating windows to receive idle events</li>"
1250 "<li>Fix for minimizing/maximizing problem with transparent hint pane</li>"
1251 "<li>Fix to not paint empty hint rectangles</li>"
1252 "<li>Fix for 64-bit compilation</li>"
1254 "<p><b>What changed in 0.9.1?</b></p>"
1255 "<p>The following features/fixes were added in wxAUI 0.9.1:</p>"
1257 "<li>Support for MDI frames</li>"
1258 "<li>Gradient captions option</li>"
1259 "<li>Active/Inactive panes option</li>"
1260 "<li>Fix for screen artifacts/paint problems</li>"
1261 "<li>Fix for hiding/showing floated window problem</li>"
1262 "<li>Fix for floating pane sizing problem</li>"
1263 "<li>Fix for drop position problem when dragging around center pane margins</li>"
1264 "<li>LF-only text file formatting for source code</li>"
1266 "<p>See README.txt for more information.</p>"
1269 return wxString::FromAscii(text
);