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_VenetianBlindsHint
,
85 ID_HorizontalGradient
,
87 ID_NotebookCloseButton
,
88 ID_NotebookCloseButtonAll
,
89 ID_NotebookCloseButtonActive
,
90 ID_FirstPerspective
= ID_CreatePerspective
+1000
94 MyFrame(wxWindow
* parent
,
96 const wxString
& title
,
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
99 long style
= wxDEFAULT_FRAME_STYLE
| wxSUNKEN_BORDER
);
103 wxAuiDockArt
* GetDockArt();
107 wxTextCtrl
* CreateTextCtrl(const wxString
& text
= wxEmptyString
);
108 wxGrid
* CreateGrid();
109 wxTreeCtrl
* CreateTreeCtrl();
110 wxSizeReportCtrl
* CreateSizeReportCtrl(int width
= 80, int height
= 80);
111 wxPoint
GetStartPosition();
112 wxHtmlWindow
* CreateHTMLCtrl(wxWindow
* parent
= NULL
);
113 wxAuiNotebook
* CreateNotebook();
115 wxString
GetIntroText();
119 void OnEraseBackground(wxEraseEvent
& evt
);
120 void OnSize(wxSizeEvent
& evt
);
122 void OnCreateTree(wxCommandEvent
& evt
);
123 void OnCreateGrid(wxCommandEvent
& evt
);
124 void OnCreateHTML(wxCommandEvent
& evt
);
125 void OnCreateNotebook(wxCommandEvent
& evt
);
126 void OnCreateText(wxCommandEvent
& evt
);
127 void OnCreateSizeReport(wxCommandEvent
& evt
);
128 void OnChangeContentPane(wxCommandEvent
& evt
);
129 void OnCreatePerspective(wxCommandEvent
& evt
);
130 void OnCopyPerspectiveCode(wxCommandEvent
& evt
);
131 void OnRestorePerspective(wxCommandEvent
& evt
);
132 void OnSettings(wxCommandEvent
& evt
);
133 void OnExit(wxCommandEvent
& evt
);
134 void OnAbout(wxCommandEvent
& evt
);
136 void OnGradient(wxCommandEvent
& evt
);
137 void OnManagerFlag(wxCommandEvent
& evt
);
138 void OnNotebookFlag(wxCommandEvent
& evt
);
139 void OnUpdateUI(wxUpdateUIEvent
& evt
);
141 void OnPaneClose(wxAuiManagerEvent
& evt
);
146 wxArrayString m_perspectives
;
147 wxMenu
* m_perspectives_menu
;
148 long m_notebook_style
;
150 DECLARE_EVENT_TABLE()
154 // -- wxSizeReportCtrl --
155 // (a utility control that always reports it's client size)
157 class wxSizeReportCtrl
: public wxControl
161 wxSizeReportCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
162 const wxPoint
& pos
= wxDefaultPosition
,
163 const wxSize
& size
= wxDefaultSize
,
164 wxAuiManager
* mgr
= NULL
)
165 : wxControl(parent
, id
, pos
, size
, wxNO_BORDER
)
172 void OnPaint(wxPaintEvent
& WXUNUSED(evt
))
175 wxSize size
= GetClientSize();
179 s
.Printf(wxT("Size: %d x %d"), size
.x
, size
.y
);
181 dc
.SetFont(*wxNORMAL_FONT
);
182 dc
.GetTextExtent(s
, &w
, &height
);
184 dc
.SetBrush(*wxWHITE_BRUSH
);
185 dc
.SetPen(*wxWHITE_PEN
);
186 dc
.DrawRectangle(0, 0, size
.x
, size
.y
);
187 dc
.SetPen(*wxLIGHT_GREY_PEN
);
188 dc
.DrawLine(0, 0, size
.x
, size
.y
);
189 dc
.DrawLine(0, size
.y
, size
.x
, 0);
190 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2));
194 wxAuiPaneInfo pi
= m_mgr
->GetPane(this);
196 s
.Printf(wxT("Layer: %d"), pi
.dock_layer
);
197 dc
.GetTextExtent(s
, &w
, &h
);
198 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*1));
200 s
.Printf(wxT("Dock: %d Row: %d"), pi
.dock_direction
, pi
.dock_row
);
201 dc
.GetTextExtent(s
, &w
, &h
);
202 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*2));
204 s
.Printf(wxT("Position: %d"), pi
.dock_pos
);
205 dc
.GetTextExtent(s
, &w
, &h
);
206 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*3));
208 s
.Printf(wxT("Proportion: %d"), pi
.dock_proportion
);
209 dc
.GetTextExtent(s
, &w
, &h
);
210 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*4));
214 void OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
216 // intentionally empty
219 void OnSize(wxSizeEvent
& WXUNUSED(evt
))
227 DECLARE_EVENT_TABLE()
230 BEGIN_EVENT_TABLE(wxSizeReportCtrl
, wxControl
)
231 EVT_PAINT(wxSizeReportCtrl::OnPaint
)
232 EVT_SIZE(wxSizeReportCtrl::OnSize
)
233 EVT_ERASE_BACKGROUND(wxSizeReportCtrl::OnEraseBackground
)
237 class SettingsPanel
: public wxPanel
241 ID_PaneBorderSize
= wxID_HIGHEST
+1,
246 ID_InactiveCaptionColor
,
247 ID_InactiveCaptionGradientColor
,
248 ID_InactiveCaptionTextColor
,
249 ID_ActiveCaptionColor
,
250 ID_ActiveCaptionGradientColor
,
251 ID_ActiveCaptionTextColor
,
258 SettingsPanel(wxWindow
* parent
, MyFrame
* frame
)
259 : wxPanel(parent
, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
)
261 //wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
263 //vert->Add(1, 1, 1, wxEXPAND);
265 wxBoxSizer
* s1
= new wxBoxSizer(wxHORIZONTAL
);
266 m_border_size
= new wxSpinCtrl(this, ID_PaneBorderSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
267 s1
->Add(1, 1, 1, wxEXPAND
);
268 s1
->Add(new wxStaticText(this, wxID_ANY
, wxT("Pane Border Size:")));
269 s1
->Add(m_border_size
);
270 s1
->Add(1, 1, 1, wxEXPAND
);
271 s1
->SetItemMinSize((size_t)1, 180, 20);
272 //vert->Add(s1, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
274 wxBoxSizer
* s2
= new wxBoxSizer(wxHORIZONTAL
);
275 m_sash_size
= new wxSpinCtrl(this, ID_SashSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
276 s2
->Add(1, 1, 1, wxEXPAND
);
277 s2
->Add(new wxStaticText(this, wxID_ANY
, wxT("Sash Size:")));
278 s2
->Add(m_sash_size
);
279 s2
->Add(1, 1, 1, wxEXPAND
);
280 s2
->SetItemMinSize((size_t)1, 180, 20);
281 //vert->Add(s2, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
283 wxBoxSizer
* s3
= new wxBoxSizer(wxHORIZONTAL
);
284 m_caption_size
= new wxSpinCtrl(this, ID_CaptionSize
, wxEmptyString
, wxDefaultPosition
, wxSize(50,20));
285 s3
->Add(1, 1, 1, wxEXPAND
);
286 s3
->Add(new wxStaticText(this, wxID_ANY
, wxT("Caption Size:")));
287 s3
->Add(m_caption_size
);
288 s3
->Add(1, 1, 1, wxEXPAND
);
289 s3
->SetItemMinSize((size_t)1, 180, 20);
290 //vert->Add(s3, 0, wxEXPAND | wxLEFT | wxBOTTOM, 5);
292 //vert->Add(1, 1, 1, wxEXPAND);
295 wxBitmap b
= CreateColorBitmap(*wxBLACK
);
297 wxBoxSizer
* s4
= new wxBoxSizer(wxHORIZONTAL
);
298 m_background_color
= new wxBitmapButton(this, ID_BackgroundColor
, b
, wxDefaultPosition
, wxSize(50,25));
299 s4
->Add(1, 1, 1, wxEXPAND
);
300 s4
->Add(new wxStaticText(this, wxID_ANY
, wxT("Background Color:")));
301 s4
->Add(m_background_color
);
302 s4
->Add(1, 1, 1, wxEXPAND
);
303 s4
->SetItemMinSize((size_t)1, 180, 20);
305 wxBoxSizer
* s5
= new wxBoxSizer(wxHORIZONTAL
);
306 m_sash_color
= new wxBitmapButton(this, ID_SashColor
, b
, wxDefaultPosition
, wxSize(50,25));
307 s5
->Add(1, 1, 1, wxEXPAND
);
308 s5
->Add(new wxStaticText(this, wxID_ANY
, wxT("Sash Color:")));
309 s5
->Add(m_sash_color
);
310 s5
->Add(1, 1, 1, wxEXPAND
);
311 s5
->SetItemMinSize((size_t)1, 180, 20);
313 wxBoxSizer
* s6
= new wxBoxSizer(wxHORIZONTAL
);
314 m_inactive_caption_color
= new wxBitmapButton(this, ID_InactiveCaptionColor
, b
, wxDefaultPosition
, wxSize(50,25));
315 s6
->Add(1, 1, 1, wxEXPAND
);
316 s6
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption:")));
317 s6
->Add(m_inactive_caption_color
);
318 s6
->Add(1, 1, 1, wxEXPAND
);
319 s6
->SetItemMinSize((size_t)1, 180, 20);
321 wxBoxSizer
* s7
= new wxBoxSizer(wxHORIZONTAL
);
322 m_inactive_caption_gradient_color
= new wxBitmapButton(this, ID_InactiveCaptionGradientColor
, b
, wxDefaultPosition
, wxSize(50,25));
323 s7
->Add(1, 1, 1, wxEXPAND
);
324 s7
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption Gradient:")));
325 s7
->Add(m_inactive_caption_gradient_color
);
326 s7
->Add(1, 1, 1, wxEXPAND
);
327 s7
->SetItemMinSize((size_t)1, 180, 20);
329 wxBoxSizer
* s8
= new wxBoxSizer(wxHORIZONTAL
);
330 m_inactive_caption_text_color
= new wxBitmapButton(this, ID_InactiveCaptionTextColor
, b
, wxDefaultPosition
, wxSize(50,25));
331 s8
->Add(1, 1, 1, wxEXPAND
);
332 s8
->Add(new wxStaticText(this, wxID_ANY
, wxT("Normal Caption Text:")));
333 s8
->Add(m_inactive_caption_text_color
);
334 s8
->Add(1, 1, 1, wxEXPAND
);
335 s8
->SetItemMinSize((size_t)1, 180, 20);
337 wxBoxSizer
* s9
= new wxBoxSizer(wxHORIZONTAL
);
338 m_active_caption_color
= new wxBitmapButton(this, ID_ActiveCaptionColor
, b
, wxDefaultPosition
, wxSize(50,25));
339 s9
->Add(1, 1, 1, wxEXPAND
);
340 s9
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption:")));
341 s9
->Add(m_active_caption_color
);
342 s9
->Add(1, 1, 1, wxEXPAND
);
343 s9
->SetItemMinSize((size_t)1, 180, 20);
345 wxBoxSizer
* s10
= new wxBoxSizer(wxHORIZONTAL
);
346 m_active_caption_gradient_color
= new wxBitmapButton(this, ID_ActiveCaptionGradientColor
, b
, wxDefaultPosition
, wxSize(50,25));
347 s10
->Add(1, 1, 1, wxEXPAND
);
348 s10
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption Gradient:")));
349 s10
->Add(m_active_caption_gradient_color
);
350 s10
->Add(1, 1, 1, wxEXPAND
);
351 s10
->SetItemMinSize((size_t)1, 180, 20);
353 wxBoxSizer
* s11
= new wxBoxSizer(wxHORIZONTAL
);
354 m_active_caption_text_color
= new wxBitmapButton(this, ID_ActiveCaptionTextColor
, b
, wxDefaultPosition
, wxSize(50,25));
355 s11
->Add(1, 1, 1, wxEXPAND
);
356 s11
->Add(new wxStaticText(this, wxID_ANY
, wxT("Active Caption Text:")));
357 s11
->Add(m_active_caption_text_color
);
358 s11
->Add(1, 1, 1, wxEXPAND
);
359 s11
->SetItemMinSize((size_t)1, 180, 20);
361 wxBoxSizer
* s12
= new wxBoxSizer(wxHORIZONTAL
);
362 m_border_color
= new wxBitmapButton(this, ID_BorderColor
, b
, wxDefaultPosition
, wxSize(50,25));
363 s12
->Add(1, 1, 1, wxEXPAND
);
364 s12
->Add(new wxStaticText(this, wxID_ANY
, wxT("Border Color:")));
365 s12
->Add(m_border_color
);
366 s12
->Add(1, 1, 1, wxEXPAND
);
367 s12
->SetItemMinSize((size_t)1, 180, 20);
369 wxBoxSizer
* s13
= new wxBoxSizer(wxHORIZONTAL
);
370 m_gripper_color
= new wxBitmapButton(this, ID_GripperColor
, b
, wxDefaultPosition
, wxSize(50,25));
371 s13
->Add(1, 1, 1, wxEXPAND
);
372 s13
->Add(new wxStaticText(this, wxID_ANY
, wxT("Gripper Color:")));
373 s13
->Add(m_gripper_color
);
374 s13
->Add(1, 1, 1, wxEXPAND
);
375 s13
->SetItemMinSize((size_t)1, 180, 20);
377 wxGridSizer
* grid_sizer
= new wxGridSizer(2);
378 grid_sizer
->SetHGap(5);
379 grid_sizer
->Add(s1
); grid_sizer
->Add(s4
);
380 grid_sizer
->Add(s2
); grid_sizer
->Add(s5
);
381 grid_sizer
->Add(s3
); grid_sizer
->Add(s13
);
382 grid_sizer
->Add(1,1); grid_sizer
->Add(s12
);
383 grid_sizer
->Add(s6
); grid_sizer
->Add(s9
);
384 grid_sizer
->Add(s7
); grid_sizer
->Add(s10
);
385 grid_sizer
->Add(s8
); grid_sizer
->Add(s11
);
387 wxBoxSizer
* cont_sizer
= new wxBoxSizer(wxVERTICAL
);
388 cont_sizer
->Add(grid_sizer
, 1, wxEXPAND
| wxALL
, 5);
389 SetSizer(cont_sizer
);
390 GetSizer()->SetSizeHints(this);
393 m_border_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_PANE_BORDER_SIZE
));
394 m_sash_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_SASH_SIZE
));
395 m_caption_size
->SetValue(frame
->GetDockArt()->GetMetric(wxAUI_ART_CAPTION_SIZE
));
402 wxBitmap
CreateColorBitmap(const wxColour
& c
)
406 for (int x
= 0; x
< 25; ++x
)
407 for (int y
= 0; y
< 14; ++y
)
410 if (x
== 0 || x
== 24 || y
== 0 || y
== 13)
412 image
.SetRGB(x
, y
, pixcol
.Red(), pixcol
.Green(), pixcol
.Blue());
414 return wxBitmap(image
);
419 wxColour bk
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_BACKGROUND_COLOUR
);
420 m_background_color
->SetBitmapLabel(CreateColorBitmap(bk
));
422 wxColour cap
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_COLOUR
);
423 m_inactive_caption_color
->SetBitmapLabel(CreateColorBitmap(cap
));
425 wxColour capgrad
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
);
426 m_inactive_caption_gradient_color
->SetBitmapLabel(CreateColorBitmap(capgrad
));
428 wxColour captxt
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
);
429 m_inactive_caption_text_color
->SetBitmapLabel(CreateColorBitmap(captxt
));
431 wxColour acap
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_COLOUR
);
432 m_active_caption_color
->SetBitmapLabel(CreateColorBitmap(acap
));
434 wxColour acapgrad
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
);
435 m_active_caption_gradient_color
->SetBitmapLabel(CreateColorBitmap(acapgrad
));
437 wxColour acaptxt
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
);
438 m_active_caption_text_color
->SetBitmapLabel(CreateColorBitmap(acaptxt
));
440 wxColour sash
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_SASH_COLOUR
);
441 m_sash_color
->SetBitmapLabel(CreateColorBitmap(sash
));
443 wxColour border
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_BORDER_COLOUR
);
444 m_border_color
->SetBitmapLabel(CreateColorBitmap(border
));
446 wxColour gripper
= m_frame
->GetDockArt()->GetColor(wxAUI_ART_GRIPPER_COLOUR
);
447 m_gripper_color
->SetBitmapLabel(CreateColorBitmap(gripper
));
450 void OnPaneBorderSize(wxSpinEvent
& event
)
452 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_PANE_BORDER_SIZE
,
453 event
.GetPosition());
457 void OnSashSize(wxSpinEvent
& event
)
459 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_SASH_SIZE
,
460 event
.GetPosition());
464 void OnCaptionSize(wxSpinEvent
& event
)
466 m_frame
->GetDockArt()->SetMetric(wxAUI_ART_CAPTION_SIZE
,
467 event
.GetPosition());
471 void OnSetColor(wxCommandEvent
& event
)
473 wxColourDialog
dlg(m_frame
);
474 dlg
.SetTitle(_("Color Picker"));
475 if (dlg
.ShowModal() != wxID_OK
)
479 switch (event
.GetId())
481 case ID_BackgroundColor
: var
= wxAUI_ART_BACKGROUND_COLOUR
; break;
482 case ID_SashColor
: var
= wxAUI_ART_SASH_COLOUR
; break;
483 case ID_InactiveCaptionColor
: var
= wxAUI_ART_INACTIVE_CAPTION_COLOUR
; break;
484 case ID_InactiveCaptionGradientColor
: var
= wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
; break;
485 case ID_InactiveCaptionTextColor
: var
= wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
; break;
486 case ID_ActiveCaptionColor
: var
= wxAUI_ART_ACTIVE_CAPTION_COLOUR
; break;
487 case ID_ActiveCaptionGradientColor
: var
= wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
; break;
488 case ID_ActiveCaptionTextColor
: var
= wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
; break;
489 case ID_BorderColor
: var
= wxAUI_ART_BORDER_COLOUR
; break;
490 case ID_GripperColor
: var
= wxAUI_ART_GRIPPER_COLOUR
; break;
494 m_frame
->GetDockArt()->SetColor(var
, dlg
.GetColourData().GetColour());
502 wxSpinCtrl
* m_border_size
;
503 wxSpinCtrl
* m_sash_size
;
504 wxSpinCtrl
* m_caption_size
;
505 wxBitmapButton
* m_inactive_caption_text_color
;
506 wxBitmapButton
* m_inactive_caption_gradient_color
;
507 wxBitmapButton
* m_inactive_caption_color
;
508 wxBitmapButton
* m_active_caption_text_color
;
509 wxBitmapButton
* m_active_caption_gradient_color
;
510 wxBitmapButton
* m_active_caption_color
;
511 wxBitmapButton
* m_sash_color
;
512 wxBitmapButton
* m_background_color
;
513 wxBitmapButton
* m_border_color
;
514 wxBitmapButton
* m_gripper_color
;
516 DECLARE_EVENT_TABLE()
519 BEGIN_EVENT_TABLE(SettingsPanel
, wxPanel
)
520 EVT_SPINCTRL(ID_PaneBorderSize
, SettingsPanel::OnPaneBorderSize
)
521 EVT_SPINCTRL(ID_SashSize
, SettingsPanel::OnSashSize
)
522 EVT_SPINCTRL(ID_CaptionSize
, SettingsPanel::OnCaptionSize
)
523 EVT_BUTTON(ID_BackgroundColor
, SettingsPanel::OnSetColor
)
524 EVT_BUTTON(ID_SashColor
, SettingsPanel::OnSetColor
)
525 EVT_BUTTON(ID_InactiveCaptionColor
, SettingsPanel::OnSetColor
)
526 EVT_BUTTON(ID_InactiveCaptionGradientColor
, SettingsPanel::OnSetColor
)
527 EVT_BUTTON(ID_InactiveCaptionTextColor
, SettingsPanel::OnSetColor
)
528 EVT_BUTTON(ID_ActiveCaptionColor
, SettingsPanel::OnSetColor
)
529 EVT_BUTTON(ID_ActiveCaptionGradientColor
, SettingsPanel::OnSetColor
)
530 EVT_BUTTON(ID_ActiveCaptionTextColor
, SettingsPanel::OnSetColor
)
531 EVT_BUTTON(ID_BorderColor
, SettingsPanel::OnSetColor
)
532 EVT_BUTTON(ID_GripperColor
, SettingsPanel::OnSetColor
)
538 wxFrame
* frame
= new MyFrame(NULL
,
540 wxT("wxAUI Sample Application"),
549 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
550 EVT_ERASE_BACKGROUND(MyFrame::OnEraseBackground
)
551 EVT_SIZE(MyFrame::OnSize
)
552 EVT_MENU(MyFrame::ID_CreateTree
, MyFrame::OnCreateTree
)
553 EVT_MENU(MyFrame::ID_CreateGrid
, MyFrame::OnCreateGrid
)
554 EVT_MENU(MyFrame::ID_CreateText
, MyFrame::OnCreateText
)
555 EVT_MENU(MyFrame::ID_CreateHTML
, MyFrame::OnCreateHTML
)
556 EVT_MENU(MyFrame::ID_CreateSizeReport
, MyFrame::OnCreateSizeReport
)
557 EVT_MENU(MyFrame::ID_CreatePerspective
, MyFrame::OnCreatePerspective
)
558 EVT_MENU(MyFrame::ID_CopyPerspectiveCode
, MyFrame::OnCopyPerspectiveCode
)
559 EVT_MENU(ID_AllowFloating
, MyFrame::OnManagerFlag
)
560 EVT_MENU(ID_TransparentHint
, MyFrame::OnManagerFlag
)
561 EVT_MENU(ID_VenetianBlindsHint
, MyFrame::OnManagerFlag
)
562 EVT_MENU(ID_RectangleHint
, MyFrame::OnManagerFlag
)
563 EVT_MENU(ID_NoHint
, MyFrame::OnManagerFlag
)
564 EVT_MENU(ID_HintFade
, MyFrame::OnManagerFlag
)
565 EVT_MENU(ID_NoVenetianFade
, MyFrame::OnManagerFlag
)
566 EVT_MENU(ID_TransparentDrag
, MyFrame::OnManagerFlag
)
567 EVT_MENU(ID_AllowActivePane
, MyFrame::OnManagerFlag
)
568 EVT_MENU(ID_NotebookCloseButton
, MyFrame::OnNotebookFlag
)
569 EVT_MENU(ID_NotebookCloseButtonAll
, MyFrame::OnNotebookFlag
)
570 EVT_MENU(ID_NotebookCloseButtonActive
, MyFrame::OnNotebookFlag
)
571 EVT_MENU(ID_NoGradient
, MyFrame::OnGradient
)
572 EVT_MENU(ID_VerticalGradient
, MyFrame::OnGradient
)
573 EVT_MENU(ID_HorizontalGradient
, MyFrame::OnGradient
)
574 EVT_MENU(ID_Settings
, MyFrame::OnSettings
)
575 EVT_MENU(ID_GridContent
, MyFrame::OnChangeContentPane
)
576 EVT_MENU(ID_TreeContent
, MyFrame::OnChangeContentPane
)
577 EVT_MENU(ID_TextContent
, MyFrame::OnChangeContentPane
)
578 EVT_MENU(ID_SizeReportContent
, MyFrame::OnChangeContentPane
)
579 EVT_MENU(ID_HTMLContent
, MyFrame::OnChangeContentPane
)
580 EVT_MENU(ID_NotebookContent
, MyFrame::OnChangeContentPane
)
581 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
582 EVT_MENU(wxID_ABOUT
, MyFrame::OnAbout
)
583 EVT_UPDATE_UI(ID_NotebookCloseButton
, MyFrame::OnUpdateUI
)
584 EVT_UPDATE_UI(ID_NotebookCloseButtonAll
, MyFrame::OnUpdateUI
)
585 EVT_UPDATE_UI(ID_NotebookCloseButtonActive
, MyFrame::OnUpdateUI
)
586 EVT_UPDATE_UI(ID_AllowFloating
, MyFrame::OnUpdateUI
)
587 EVT_UPDATE_UI(ID_TransparentHint
, MyFrame::OnUpdateUI
)
588 EVT_UPDATE_UI(ID_VenetianBlindsHint
, MyFrame::OnUpdateUI
)
589 EVT_UPDATE_UI(ID_RectangleHint
, MyFrame::OnUpdateUI
)
590 EVT_UPDATE_UI(ID_NoHint
, MyFrame::OnUpdateUI
)
591 EVT_UPDATE_UI(ID_HintFade
, MyFrame::OnUpdateUI
)
592 EVT_UPDATE_UI(ID_NoVenetianFade
, MyFrame::OnUpdateUI
)
593 EVT_UPDATE_UI(ID_TransparentDrag
, MyFrame::OnUpdateUI
)
594 EVT_UPDATE_UI(ID_NoGradient
, MyFrame::OnUpdateUI
)
595 EVT_UPDATE_UI(ID_VerticalGradient
, MyFrame::OnUpdateUI
)
596 EVT_UPDATE_UI(ID_HorizontalGradient
, MyFrame::OnUpdateUI
)
597 EVT_MENU_RANGE(MyFrame::ID_FirstPerspective
, MyFrame::ID_FirstPerspective
+1000,
598 MyFrame::OnRestorePerspective
)
599 EVT_AUI_PANECLOSE(MyFrame::OnPaneClose
)
603 MyFrame::MyFrame(wxWindow
* parent
,
605 const wxString
& title
,
609 : wxFrame(parent
, id
, title
, pos
, size
, style
)
611 // tell wxAuiManager to manage this frame
612 m_mgr
.SetManagedWindow(this);
615 SetIcon(wxIcon(sample_xpm
));
617 // set up default notebook style
618 m_notebook_style
= wxAUI_NB_DEFAULT_STYLE
| wxNO_BORDER
;
621 wxMenuBar
* mb
= new wxMenuBar
;
623 wxMenu
* file_menu
= new wxMenu
;
624 file_menu
->Append(wxID_EXIT
, _("Exit"));
626 wxMenu
* view_menu
= new wxMenu
;
627 view_menu
->Append(ID_CreateText
, _("Create Text Control"));
628 view_menu
->Append(ID_CreateHTML
, _("Create HTML Control"));
629 view_menu
->Append(ID_CreateTree
, _("Create Tree"));
630 view_menu
->Append(ID_CreateGrid
, _("Create Grid"));
631 view_menu
->Append(ID_CreateSizeReport
, _("Create Size Reporter"));
632 view_menu
->AppendSeparator();
633 view_menu
->Append(ID_GridContent
, _("Use a Grid for the Content Pane"));
634 view_menu
->Append(ID_TextContent
, _("Use a Text Control for the Content Pane"));
635 view_menu
->Append(ID_HTMLContent
, _("Use an HTML Control for the Content Pane"));
636 view_menu
->Append(ID_TreeContent
, _("Use a Tree Control for the Content Pane"));
637 view_menu
->Append(ID_NotebookContent
, _("Use a AUI wxMultiNotebook control for the Content Pane"));
638 view_menu
->Append(ID_SizeReportContent
, _("Use a Size Reporter for the Content Pane"));
640 wxMenu
* options_menu
= new wxMenu
;
641 options_menu
->AppendRadioItem(ID_TransparentHint
, _("Transparent Hint"));
642 options_menu
->AppendRadioItem(ID_VenetianBlindsHint
, _("Venetian Blinds Hint"));
643 options_menu
->AppendRadioItem(ID_RectangleHint
, _("Rectangle Hint"));
644 options_menu
->AppendRadioItem(ID_NoHint
, _("No Hint"));
645 options_menu
->AppendSeparator();
646 options_menu
->AppendCheckItem(ID_HintFade
, _("Hint Fade-in"));
647 options_menu
->AppendCheckItem(ID_AllowFloating
, _("Allow Floating"));
648 options_menu
->AppendCheckItem(ID_NoVenetianFade
, _("Disable Venetian Blinds Hint Fade-in"));
649 options_menu
->AppendCheckItem(ID_TransparentDrag
, _("Transparent Drag"));
650 options_menu
->AppendCheckItem(ID_AllowActivePane
, _("Allow Active Pane"));
651 options_menu
->AppendSeparator();
652 options_menu
->AppendRadioItem(ID_NoGradient
, _("No Caption Gradient"));
653 options_menu
->AppendRadioItem(ID_VerticalGradient
, _("Vertical Caption Gradient"));
654 options_menu
->AppendRadioItem(ID_HorizontalGradient
, _("Horizontal Caption Gradient"));
655 options_menu
->AppendSeparator();
656 options_menu
->Append(ID_Settings
, _("Settings Pane"));
658 wxMenu
* notebook_menu
= new wxMenu
;
659 notebook_menu
->AppendRadioItem(ID_NotebookCloseButton
, _("Close Button at Right"));
660 notebook_menu
->AppendRadioItem(ID_NotebookCloseButtonAll
, _("Close Button on All Tabs"));
661 notebook_menu
->AppendRadioItem(ID_NotebookCloseButtonActive
, _("Close Button on Active Tab"));
663 m_perspectives_menu
= new wxMenu
;
664 m_perspectives_menu
->Append(ID_CreatePerspective
, _("Create Perspective"));
665 m_perspectives_menu
->Append(ID_CopyPerspectiveCode
, _("Copy Perspective Data To Clipboard"));
666 m_perspectives_menu
->AppendSeparator();
667 m_perspectives_menu
->Append(ID_FirstPerspective
+0, _("Default Startup"));
668 m_perspectives_menu
->Append(ID_FirstPerspective
+1, _("All Panes"));
670 wxMenu
* help_menu
= new wxMenu
;
671 help_menu
->Append(wxID_ABOUT
, _("About..."));
673 mb
->Append(file_menu
, _("File"));
674 mb
->Append(view_menu
, _("View"));
675 mb
->Append(m_perspectives_menu
, _("Perspectives"));
676 mb
->Append(options_menu
, _("Options"));
677 mb
->Append(notebook_menu
, _("Notebook"));
678 mb
->Append(help_menu
, _("Help"));
683 GetStatusBar()->SetStatusText(_("Ready"));
686 // min size for the frame itself isn't completely done.
687 // see the end up wxAuiManager::Update() for the test
688 // code. For now, just hard code a frame minimum size
689 SetMinSize(wxSize(400,300));
691 // create some toolbars
692 wxToolBar
* tb1
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
693 wxTB_FLAT
| wxTB_NODIVIDER
);
694 tb1
->SetToolBitmapSize(wxSize(48,48));
695 tb1
->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR
));
697 tb1
->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION
));
698 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION
));
699 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING
));
700 tb1
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE
));
704 wxToolBar
* tb2
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
705 wxTB_FLAT
| wxTB_NODIVIDER
);
706 tb2
->SetToolBitmapSize(wxSize(16,16));
708 wxBitmap tb2_bmp1
= wxArtProvider::GetBitmap(wxART_QUESTION
, wxART_OTHER
, wxSize(16,16));
709 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
710 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
711 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
712 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
714 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
715 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
717 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
718 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
719 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
720 tb2
->AddTool(101, wxT("Test"), tb2_bmp1
);
724 wxToolBar
* tb3
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
725 wxTB_FLAT
| wxTB_NODIVIDER
);
726 tb3
->SetToolBitmapSize(wxSize(16,16));
727 wxBitmap tb3_bmp1
= wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_OTHER
, wxSize(16,16));
728 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
729 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
730 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
731 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
733 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
734 tb3
->AddTool(101, wxT("Test"), tb3_bmp1
);
738 wxToolBar
* tb4
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
739 wxTB_FLAT
| wxTB_NODIVIDER
| wxTB_HORZ_TEXT
);
740 tb4
->SetToolBitmapSize(wxSize(16,16));
741 wxBitmap tb4_bmp1
= wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_OTHER
, wxSize(16,16));
742 tb4
->AddTool(101, wxT("Item 1"), tb4_bmp1
);
743 tb4
->AddTool(101, wxT("Item 2"), tb4_bmp1
);
744 tb4
->AddTool(101, wxT("Item 3"), tb4_bmp1
);
745 tb4
->AddTool(101, wxT("Item 4"), tb4_bmp1
);
747 tb4
->AddTool(101, wxT("Item 5"), tb4_bmp1
);
748 tb4
->AddTool(101, wxT("Item 6"), tb4_bmp1
);
749 tb4
->AddTool(101, wxT("Item 7"), tb4_bmp1
);
750 tb4
->AddTool(101, wxT("Item 8"), tb4_bmp1
);
753 // create some toolbars
754 wxToolBar
* tb5
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
755 wxTB_FLAT
| wxTB_NODIVIDER
| wxTB_VERTICAL
);
756 tb5
->SetToolBitmapSize(wxSize(48,48));
757 tb5
->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR
));
759 tb5
->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION
));
760 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION
));
761 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING
));
762 tb5
->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE
));
765 // add a bunch of panes
766 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
767 Name(wxT("test1")).Caption(wxT("Pane Caption")).
770 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
771 Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
772 Bottom().Position(1).
773 PinButton(true).CloseButton(true).MaximizeButton(true));
775 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
776 Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
778 PinButton(true).CloseButton(true).MaximizeButton(true));
780 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
781 Name(wxT("test4")).Caption(wxT("Pane Caption")).
784 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
785 Name(wxT("test5")).Caption(wxT("No Close Button")).
786 Right().CloseButton(false));
788 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
789 Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
791 PinButton(true).CloseButton(true).MaximizeButton(true));
793 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
794 Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
796 PinButton(true).CloseButton(true).MaximizeButton(true));
798 m_mgr
.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().
799 Name(wxT("test8")).Caption(wxT("Tree Pane")).
800 Left().Layer(1).Position(1).
801 CloseButton(true).MaximizeButton(true));
803 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
804 Name(wxT("test9")).Caption(wxT("Min Size 200x100")).
805 BestSize(wxSize(200,100)).MinSize(wxSize(200,100)).
807 CloseButton(true).MaximizeButton(true));
809 wxWindow
* wnd10
= CreateTextCtrl(wxT("This pane will prompt the user before hiding."));
810 m_mgr
.AddPane(wnd10
, wxAuiPaneInfo().
811 Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")).
812 Bottom().Layer(1).Position(1));
814 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
815 Name(wxT("test11")).Caption(wxT("Fixed Pane")).
816 Bottom().Layer(1).Position(2).Fixed());
819 m_mgr
.AddPane(new SettingsPanel(this,this), wxAuiPaneInfo().
820 Name(wxT("settings")).Caption(wxT("Dock Manager Settings")).
821 Dockable(false).Float().Hide());
823 // create some center panes
825 m_mgr
.AddPane(CreateGrid(), wxAuiPaneInfo().Name(wxT("grid_content")).
826 CenterPane().Hide());
828 m_mgr
.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().Name(wxT("tree_content")).
829 CenterPane().Hide());
831 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().Name(wxT("sizereport_content")).
832 CenterPane().Hide());
834 m_mgr
.AddPane(CreateTextCtrl(), wxAuiPaneInfo().Name(wxT("text_content")).
835 CenterPane().Hide());
837 m_mgr
.AddPane(CreateHTMLCtrl(), wxAuiPaneInfo().Name(wxT("html_content")).
840 m_mgr
.AddPane(CreateNotebook(), wxAuiPaneInfo().Name(wxT("notebook_content")).
841 CenterPane().PaneBorder(false));
843 // add the toolbars to the manager
844 m_mgr
.AddPane(tb1
, wxAuiPaneInfo().
845 Name(wxT("tb1")).Caption(wxT("Big Toolbar")).
847 LeftDockable(false).RightDockable(false));
849 m_mgr
.AddPane(tb2
, wxAuiPaneInfo().
850 Name(wxT("tb2")).Caption(wxT("Toolbar 2")).
851 ToolbarPane().Top().Row(1).
852 LeftDockable(false).RightDockable(false));
854 m_mgr
.AddPane(tb3
, wxAuiPaneInfo().
855 Name(wxT("tb3")).Caption(wxT("Toolbar 3")).
856 ToolbarPane().Top().Row(1).Position(1).
857 LeftDockable(false).RightDockable(false));
859 m_mgr
.AddPane(tb4
, wxAuiPaneInfo().
860 Name(wxT("tb4")).Caption(wxT("Sample Bookmark Toolbar")).
861 ToolbarPane().Top().Row(2).
862 LeftDockable(false).RightDockable(false));
864 m_mgr
.AddPane(tb5
, wxAuiPaneInfo().
865 Name(wxT("tb5")).Caption(wxT("Sample Vertical Toolbar")).
866 ToolbarPane().Left().
868 TopDockable(false).BottomDockable(false));
870 m_mgr
.AddPane(new wxButton(this, wxID_ANY
, _("Test Button")),
871 wxAuiPaneInfo().Name(wxT("tb6")).
872 ToolbarPane().Top().Row(2).Position(1).
873 LeftDockable(false).RightDockable(false));
875 // make some default perspectives
877 wxString perspective_all
= m_mgr
.SavePerspective();
880 wxAuiPaneInfoArray
& all_panes
= m_mgr
.GetAllPanes();
881 for (i
= 0, count
= all_panes
.GetCount(); i
< count
; ++i
)
882 if (!all_panes
.Item(i
).IsToolbar())
883 all_panes
.Item(i
).Hide();
884 m_mgr
.GetPane(wxT("tb1")).Hide();
885 m_mgr
.GetPane(wxT("tb6")).Hide();
886 m_mgr
.GetPane(wxT("test8")).Show().Left().Layer(0).Row(0).Position(0);
887 m_mgr
.GetPane(wxT("test10")).Show().Bottom().Layer(0).Row(0).Position(0);
888 m_mgr
.GetPane(wxT("notebook_content")).Show();
889 wxString perspective_default
= m_mgr
.SavePerspective();
891 m_perspectives
.Add(perspective_default
);
892 m_perspectives
.Add(perspective_all
);
894 // "commit" all changes made to wxAuiManager
903 wxAuiDockArt
* MyFrame::GetDockArt()
905 return m_mgr
.GetArtProvider();
908 void MyFrame::DoUpdate()
913 void MyFrame::OnEraseBackground(wxEraseEvent
& event
)
918 void MyFrame::OnSize(wxSizeEvent
& event
)
923 void MyFrame::OnSettings(wxCommandEvent
& WXUNUSED(event
))
925 // show the settings pane, and float it
926 wxAuiPaneInfo
& floating_pane
= m_mgr
.GetPane(wxT("settings")).Float().Show();
928 if (floating_pane
.floating_pos
== wxDefaultPosition
)
929 floating_pane
.FloatingPosition(GetStartPosition());
934 void MyFrame::OnGradient(wxCommandEvent
& event
)
938 switch (event
.GetId())
940 case ID_NoGradient
: gradient
= wxAUI_GRADIENT_NONE
; break;
941 case ID_VerticalGradient
: gradient
= wxAUI_GRADIENT_VERTICAL
; break;
942 case ID_HorizontalGradient
: gradient
= wxAUI_GRADIENT_HORIZONTAL
; break;
945 m_mgr
.GetArtProvider()->SetMetric(wxAUI_ART_GRADIENT_TYPE
, gradient
);
949 void MyFrame::OnManagerFlag(wxCommandEvent
& event
)
951 unsigned int flag
= 0;
953 #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__)
954 if (event
.GetId() == ID_TransparentDrag
||
955 event
.GetId() == ID_TransparentHint
||
956 event
.GetId() == ID_HintFade
)
958 wxMessageBox(wxT("This option is presently only available on wxGTK, wxMSW and wxMac"));
963 int id
= event
.GetId();
965 if (id
== ID_TransparentHint
||
966 id
== ID_VenetianBlindsHint
||
967 id
== ID_RectangleHint
||
970 unsigned int flags
= m_mgr
.GetFlags();
971 flags
&= ~wxAUI_MGR_TRANSPARENT_HINT
;
972 flags
&= ~wxAUI_MGR_VENETIAN_BLINDS_HINT
;
973 flags
&= ~wxAUI_MGR_RECTANGLE_HINT
;
974 m_mgr
.SetFlags(flags
);
979 case ID_AllowFloating
: flag
= wxAUI_MGR_ALLOW_FLOATING
; break;
980 case ID_TransparentDrag
: flag
= wxAUI_MGR_TRANSPARENT_DRAG
; break;
981 case ID_HintFade
: flag
= wxAUI_MGR_HINT_FADE
; break;
982 case ID_NoVenetianFade
: flag
= wxAUI_MGR_NO_VENETIAN_BLINDS_FADE
; break;
983 case ID_AllowActivePane
: flag
= wxAUI_MGR_ALLOW_ACTIVE_PANE
; break;
984 case ID_TransparentHint
: flag
= wxAUI_MGR_TRANSPARENT_HINT
; break;
985 case ID_VenetianBlindsHint
: flag
= wxAUI_MGR_VENETIAN_BLINDS_HINT
; break;
986 case ID_RectangleHint
: flag
= wxAUI_MGR_RECTANGLE_HINT
; break;
991 m_mgr
.SetFlags(m_mgr
.GetFlags() ^ flag
);
998 void MyFrame::OnNotebookFlag(wxCommandEvent
& event
)
1000 int id
= event
.GetId();
1002 if (id
== ID_NotebookCloseButton
||
1003 id
== ID_NotebookCloseButtonAll
||
1004 id
== ID_NotebookCloseButtonActive
)
1006 m_notebook_style
&= ~(wxAUI_NB_CLOSE_BUTTON
|
1007 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
|
1008 wxAUI_NB_CLOSE_ON_ALL_TABS
);
1012 case ID_NotebookCloseButton
: m_notebook_style
|= wxAUI_NB_CLOSE_BUTTON
; break;
1013 case ID_NotebookCloseButtonAll
: m_notebook_style
|= wxAUI_NB_CLOSE_ON_ALL_TABS
; break;
1014 case ID_NotebookCloseButtonActive
: m_notebook_style
|= wxAUI_NB_CLOSE_ON_ACTIVE_TAB
; break;
1021 wxAuiPaneInfoArray
& all_panes
= m_mgr
.GetAllPanes();
1022 for (i
= 0, count
= all_panes
.GetCount(); i
< count
; ++i
)
1024 wxAuiPaneInfo
& pane
= all_panes
.Item(i
);
1026 if (pane
.window
->IsKindOf(CLASSINFO(wxAuiNotebook
)))
1028 pane
.window
->SetWindowStyleFlag(m_notebook_style
);
1029 pane
.window
->Refresh();
1037 void MyFrame::OnUpdateUI(wxUpdateUIEvent
& event
)
1039 unsigned int flags
= m_mgr
.GetFlags();
1041 switch (event
.GetId())
1044 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_NONE
);
1046 case ID_VerticalGradient
:
1047 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_VERTICAL
);
1049 case ID_HorizontalGradient
:
1050 event
.Check(m_mgr
.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE
) == wxAUI_GRADIENT_HORIZONTAL
);
1052 case ID_AllowFloating
:
1053 event
.Check((flags
& wxAUI_MGR_ALLOW_FLOATING
) != 0);
1055 case ID_TransparentDrag
:
1056 event
.Check((flags
& wxAUI_MGR_TRANSPARENT_DRAG
) != 0);
1058 case ID_TransparentHint
:
1059 event
.Check((flags
& wxAUI_MGR_TRANSPARENT_HINT
) != 0);
1061 case ID_VenetianBlindsHint
:
1062 event
.Check((flags
& wxAUI_MGR_VENETIAN_BLINDS_HINT
) != 0);
1064 case ID_RectangleHint
:
1065 event
.Check((flags
& wxAUI_MGR_RECTANGLE_HINT
) != 0);
1068 event
.Check(((wxAUI_MGR_TRANSPARENT_HINT
|
1069 wxAUI_MGR_VENETIAN_BLINDS_HINT
|
1070 wxAUI_MGR_RECTANGLE_HINT
) & flags
) == 0);
1073 event
.Check((flags
& wxAUI_MGR_HINT_FADE
) != 0);
1075 case ID_NoVenetianFade
:
1076 event
.Check((flags
& wxAUI_MGR_NO_VENETIAN_BLINDS_FADE
) != 0);
1079 case ID_NotebookCloseButton
:
1080 event
.Check((m_notebook_style
& wxAUI_NB_CLOSE_BUTTON
) != 0);
1082 case ID_NotebookCloseButtonAll
:
1083 event
.Check((m_notebook_style
& wxAUI_NB_CLOSE_ON_ALL_TABS
) != 0);
1085 case ID_NotebookCloseButtonActive
:
1086 event
.Check((m_notebook_style
& wxAUI_NB_CLOSE_ON_ACTIVE_TAB
) != 0);
1091 void MyFrame::OnPaneClose(wxAuiManagerEvent
& evt
)
1093 if (evt
.pane
->name
== wxT("test10"))
1095 int res
= wxMessageBox(wxT("Are you sure you want to close/hide this pane?"),
1104 void MyFrame::OnCreatePerspective(wxCommandEvent
& WXUNUSED(event
))
1106 wxTextEntryDialog
dlg(this, wxT("Enter a name for the new perspective:"),
1109 dlg
.SetValue(wxString::Format(wxT("Perspective %u"), unsigned(m_perspectives
.GetCount() + 1)));
1110 if (dlg
.ShowModal() != wxID_OK
)
1113 if (m_perspectives
.GetCount() == 0)
1115 m_perspectives_menu
->AppendSeparator();
1118 m_perspectives_menu
->Append(ID_FirstPerspective
+ m_perspectives
.GetCount(), dlg
.GetValue());
1119 m_perspectives
.Add(m_mgr
.SavePerspective());
1122 void MyFrame::OnCopyPerspectiveCode(wxCommandEvent
& WXUNUSED(event
))
1124 wxString s
= m_mgr
.SavePerspective();
1127 if (wxTheClipboard
->Open())
1129 wxTheClipboard
->SetData(new wxTextDataObject(s
));
1130 wxTheClipboard
->Close();
1135 void MyFrame::OnRestorePerspective(wxCommandEvent
& event
)
1137 m_mgr
.LoadPerspective(m_perspectives
.Item(event
.GetId() - ID_FirstPerspective
));
1141 wxPoint
MyFrame::GetStartPosition()
1145 wxPoint pt
= ClientToScreen(wxPoint(0,0));
1146 return wxPoint(pt
.x
+ x
, pt
.y
+ x
);
1149 void MyFrame::OnCreateTree(wxCommandEvent
& WXUNUSED(event
))
1151 m_mgr
.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().
1152 Name(wxT("Test")).Caption(wxT("Tree Control")).
1153 Float().FloatingPosition(GetStartPosition()).
1154 FloatingSize(wxSize(150,300)));
1158 void MyFrame::OnCreateGrid(wxCommandEvent
& WXUNUSED(event
))
1160 m_mgr
.AddPane(CreateGrid(), wxAuiPaneInfo().
1161 Name(wxT("Test")).Caption(wxT("Grid")).
1162 Float().FloatingPosition(GetStartPosition()).
1163 FloatingSize(wxSize(300,200)));
1167 void MyFrame::OnCreateHTML(wxCommandEvent
& WXUNUSED(event
))
1169 m_mgr
.AddPane(CreateHTMLCtrl(), wxAuiPaneInfo().
1170 Name(wxT("Test")).Caption(wxT("HTML Control")).
1171 Float().FloatingPosition(GetStartPosition()).
1172 FloatingSize(wxSize(300,200)));
1176 void MyFrame::OnCreateNotebook(wxCommandEvent
& WXUNUSED(event
))
1178 m_mgr
.AddPane(CreateNotebook(), wxAuiPaneInfo().
1179 Name(wxT("Test")).Caption(wxT("Notebook")).
1180 Float().FloatingPosition(GetStartPosition()).
1181 FloatingSize(wxSize(300,200)));
1185 void MyFrame::OnCreateText(wxCommandEvent
& WXUNUSED(event
))
1187 m_mgr
.AddPane(CreateTextCtrl(), wxAuiPaneInfo().
1188 Name(wxT("Test")).Caption(wxT("Text Control")).
1189 Float().FloatingPosition(GetStartPosition()));
1193 void MyFrame::OnCreateSizeReport(wxCommandEvent
& WXUNUSED(event
))
1195 m_mgr
.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
1196 Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
1197 Float().FloatingPosition(GetStartPosition()).
1198 PinButton(true).CloseButton(true).MaximizeButton(true));
1202 void MyFrame::OnChangeContentPane(wxCommandEvent
& event
)
1204 m_mgr
.GetPane(wxT("grid_content")).Show(event
.GetId() == ID_GridContent
);
1205 m_mgr
.GetPane(wxT("text_content")).Show(event
.GetId() == ID_TextContent
);
1206 m_mgr
.GetPane(wxT("tree_content")).Show(event
.GetId() == ID_TreeContent
);
1207 m_mgr
.GetPane(wxT("sizereport_content")).Show(event
.GetId() == ID_SizeReportContent
);
1208 m_mgr
.GetPane(wxT("html_content")).Show(event
.GetId() == ID_HTMLContent
);
1209 m_mgr
.GetPane(wxT("notebook_content")).Show(event
.GetId() == ID_NotebookContent
);
1213 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
1218 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
1220 wxMessageBox(_("wxAUI Demo\nAn advanced window management library for wxWidgets\n(c) Copyright 2005-2006, Kirix Corporation"), _("About wxAUI Demo"), wxOK
, this);
1223 wxTextCtrl
* MyFrame::CreateTextCtrl(const wxString
& ctrl_text
)
1228 if (ctrl_text
.Length() > 0)
1231 text
.Printf(wxT("This is text box %d"), ++n
);
1233 return new wxTextCtrl(this,wxID_ANY
, text
,
1234 wxPoint(0,0), wxSize(150,90),
1235 wxNO_BORDER
| wxTE_MULTILINE
);
1239 wxGrid
* MyFrame::CreateGrid()
1241 wxGrid
* grid
= new wxGrid(this, wxID_ANY
,
1244 wxNO_BORDER
| wxWANTS_CHARS
);
1245 grid
->CreateGrid(50, 20);
1249 wxTreeCtrl
* MyFrame::CreateTreeCtrl()
1251 wxTreeCtrl
* tree
= new wxTreeCtrl(this, wxID_ANY
,
1252 wxPoint(0,0), wxSize(160,250),
1253 wxTR_DEFAULT_STYLE
| wxNO_BORDER
);
1255 wxTreeItemId root
= tree
->AddRoot(wxT("wxAUI Project"));
1256 wxArrayTreeItemIds items
;
1259 wxImageList
* imglist
= new wxImageList(16, 16, true, 2);
1260 imglist
->Add(wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_OTHER
, wxSize(16,16)));
1261 imglist
->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_OTHER
, wxSize(16,16)));
1262 tree
->AssignImageList(imglist
);
1264 items
.Add(tree
->AppendItem(root
, wxT("Item 1"), 0));
1265 items
.Add(tree
->AppendItem(root
, wxT("Item 2"), 0));
1266 items
.Add(tree
->AppendItem(root
, wxT("Item 3"), 0));
1267 items
.Add(tree
->AppendItem(root
, wxT("Item 4"), 0));
1268 items
.Add(tree
->AppendItem(root
, wxT("Item 5"), 0));
1272 for (i
= 0, count
= items
.Count(); i
< count
; ++i
)
1274 wxTreeItemId id
= items
.Item(i
);
1275 tree
->AppendItem(id
, wxT("Subitem 1"), 1);
1276 tree
->AppendItem(id
, wxT("Subitem 2"), 1);
1277 tree
->AppendItem(id
, wxT("Subitem 3"), 1);
1278 tree
->AppendItem(id
, wxT("Subitem 4"), 1);
1279 tree
->AppendItem(id
, wxT("Subitem 5"), 1);
1288 wxSizeReportCtrl
* MyFrame::CreateSizeReportCtrl(int width
, int height
)
1290 wxSizeReportCtrl
* ctrl
= new wxSizeReportCtrl(this, wxID_ANY
,
1292 wxSize(width
, height
), &m_mgr
);
1296 wxHtmlWindow
* MyFrame::CreateHTMLCtrl(wxWindow
* parent
)
1301 wxHtmlWindow
* ctrl
= new wxHtmlWindow(parent
, wxID_ANY
,
1304 ctrl
->SetPage(GetIntroText());
1308 wxAuiNotebook
* MyFrame::CreateNotebook()
1310 wxAuiNotebook
* ctrl
= new wxAuiNotebook( this, wxID_ANY
,
1311 wxDefaultPosition
, wxSize(400,300),
1314 ctrl
->AddPage(CreateHTMLCtrl(ctrl
), wxT("Welcome"));
1316 wxPanel
*panel
= new wxPanel( ctrl
, wxID_ANY
);
1317 wxFlexGridSizer
*flex
= new wxFlexGridSizer( 2 );
1318 flex
->AddGrowableRow( 0 );
1319 flex
->AddGrowableRow( 3 );
1320 flex
->AddGrowableCol( 1 );
1321 flex
->Add( 5,5 ); flex
->Add( 5,5 );
1322 flex
->Add( new wxStaticText( panel
, -1, wxT("wxTextCtrl:") ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1323 flex
->Add( new wxTextCtrl( panel
, -1, wxT(""), wxDefaultPosition
, wxSize(100,-1)),
1324 1, wxALL
|wxALIGN_CENTRE
, 5 );
1325 flex
->Add( new wxStaticText( panel
, -1, wxT("wxSpinCtrl:") ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1326 flex
->Add( new wxSpinCtrl( panel
, -1, wxT("5"), wxDefaultPosition
, wxSize(100,-1),
1327 wxSP_ARROW_KEYS
, 5, 50, 5 ), 0, wxALL
|wxALIGN_CENTRE
, 5 );
1328 flex
->Add( 5,5 ); flex
->Add( 5,5 );
1329 panel
->SetSizer( flex
);
1330 ctrl
->AddPage( panel
, wxT("wxPanel") );
1332 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some text"),
1333 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 1") );
1335 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1336 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 2") );
1338 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1339 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 3") );
1341 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1342 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 4") );
1344 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1345 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 5") );
1347 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1348 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 6") );
1350 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1351 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 7") );
1353 ctrl
->AddPage( new wxTextCtrl( ctrl
, wxID_ANY
, wxT("Some more text"),
1354 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
|wxNO_BORDER
) , wxT("wxTextCtrl 8") );
1361 wxString
MyFrame::GetIntroText()
1365 "<h3>Welcome to wxAUI</h3>"
1366 "<br/><b>Overview</b><br/>"
1367 "<p>wxAUI is an Advanced User Interface library for the wxWidgets toolkit "
1368 "that allows developers to create high-quality, cross-platform user "
1369 "interfaces quickly and easily.</p>"
1370 "<p><b>Features</b></p>"
1371 "<p>With wxAUI, developers can create application frameworks with:</p>"
1373 "<li>Native, dockable floating frames</li>"
1374 "<li>Perspective saving and loading</li>"
1375 "<li>Native toolbars incorporating real-time, "spring-loaded" dragging</li>"
1376 "<li>Customizable floating/docking behavior</li>"
1377 "<li>Completely customizable look-and-feel</li>"
1378 "<li>Optional transparent window effects (while dragging or docking)</li>"
1380 "<p><b>What's new in 0.9.2?</b></p>"
1381 "<p>The following features/fixes have been added since the last version of wxAUI:</p>"
1383 "<li>Support for wxMac</li>"
1384 "<li>Updates for wxWidgets 2.6.3</li>"
1385 "<li>Fix to pass more unused events through</li>"
1386 "<li>Fix to allow floating windows to receive idle events</li>"
1387 "<li>Fix for minimizing/maximizing problem with transparent hint pane</li>"
1388 "<li>Fix to not paint empty hint rectangles</li>"
1389 "<li>Fix for 64-bit compilation</li>"
1391 "<p><b>What changed in 0.9.1?</b></p>"
1392 "<p>The following features/fixes were added in wxAUI 0.9.1:</p>"
1394 "<li>Support for MDI frames</li>"
1395 "<li>Gradient captions option</li>"
1396 "<li>Active/Inactive panes option</li>"
1397 "<li>Fix for screen artifacts/paint problems</li>"
1398 "<li>Fix for hiding/showing floated window problem</li>"
1399 "<li>Fix for floating pane sizing problem</li>"
1400 "<li>Fix for drop position problem when dragging around center pane margins</li>"
1401 "<li>LF-only text file formatting for source code</li>"
1403 "<p>See README.txt for more information.</p>"
1406 return wxString::FromAscii(text
);