]>
Commit | Line | Data |
---|---|---|
50acee04 JS |
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 | |
bfeed34c | 7 | // RCS-ID: $Id$ |
50acee04 JS |
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__ | |
bfeed34c | 16 | #pragma hdrstop |
50acee04 JS |
17 | #endif |
18 | ||
87d658e5 | 19 | #include "wx/app.h" |
50acee04 JS |
20 | #include "wx/grid.h" |
21 | #include "wx/treectrl.h" | |
22 | #include "wx/spinctrl.h" | |
23 | #include "wx/artprov.h" | |
24 | #include "wx/clipbrd.h" | |
25 | #include "wx/image.h" | |
26 | #include "wx/colordlg.h" | |
27 | #include "wx/wxhtml.h" | |
3a745867 | 28 | #include "wx/imaglist.h" |
6c73e20d | 29 | #include "wx/dataobj.h" |
87d658e5 PC |
30 | #include "wx/dcclient.h" |
31 | #include "wx/bmpbuttn.h" | |
32 | #include "wx/menu.h" | |
33 | #include "wx/toolbar.h" | |
34 | #include "wx/statusbr.h" | |
35 | #include "wx/msgdlg.h" | |
36 | #include "wx/textdlg.h" | |
50acee04 JS |
37 | |
38 | #include "wx/aui/aui.h" | |
39 | #include "../sample.xpm" | |
40 | ||
41 | // -- application -- | |
42 | ||
43 | class MyApp : public wxApp | |
44 | { | |
45 | public: | |
46 | bool OnInit(); | |
47 | }; | |
48 | ||
004f4002 VZ |
49 | DECLARE_APP(MyApp) |
50 | IMPLEMENT_APP(MyApp) | |
50acee04 JS |
51 | |
52 | ||
53 | class wxSizeReportCtrl; | |
54 | ||
55 | // -- frame -- | |
56 | ||
57 | class MyFrame : public wxFrame | |
58 | { | |
59 | enum | |
60 | { | |
61 | ID_CreateTree = wxID_HIGHEST+1, | |
62 | ID_CreateGrid, | |
63 | ID_CreateText, | |
64 | ID_CreateHTML, | |
65 | ID_CreateSizeReport, | |
66 | ID_GridContent, | |
67 | ID_TextContent, | |
68 | ID_TreeContent, | |
69 | ID_HTMLContent, | |
df00bdf7 | 70 | ID_NotebookContent, |
50acee04 JS |
71 | ID_SizeReportContent, |
72 | ID_CreatePerspective, | |
73 | ID_CopyPerspectiveCode, | |
74 | ID_AllowFloating, | |
75 | ID_AllowActivePane, | |
76 | ID_TransparentHint, | |
cf6fec73 BW |
77 | ID_VenetianBlindsHint, |
78 | ID_RectangleHint, | |
79 | ID_NoHint, | |
80 | ID_HintFade, | |
81 | ID_NoVenetianFade, | |
50acee04 JS |
82 | ID_TransparentDrag, |
83 | ID_NoGradient, | |
84 | ID_VerticalGradient, | |
85 | ID_HorizontalGradient, | |
86 | ID_Settings, | |
c50fa29f BW |
87 | ID_NotebookCloseButton, |
88 | ID_NotebookCloseButtonAll, | |
89 | ID_NotebookCloseButtonActive, | |
50acee04 JS |
90 | ID_FirstPerspective = ID_CreatePerspective+1000 |
91 | }; | |
92 | ||
93 | public: | |
94 | MyFrame(wxWindow* parent, | |
95 | wxWindowID id, | |
96 | const wxString& title, | |
97 | const wxPoint& pos = wxDefaultPosition, | |
98 | const wxSize& size = wxDefaultSize, | |
99 | long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER); | |
100 | ||
101 | ~MyFrame(); | |
102 | ||
a3a5df9d | 103 | wxAuiDockArt* GetDockArt(); |
50acee04 JS |
104 | void DoUpdate(); |
105 | ||
106 | private: | |
58754643 | 107 | wxTextCtrl* CreateTextCtrl(const wxString& text = wxEmptyString); |
50acee04 JS |
108 | wxGrid* CreateGrid(); |
109 | wxTreeCtrl* CreateTreeCtrl(); | |
110 | wxSizeReportCtrl* CreateSizeReportCtrl(int width = 80, int height = 80); | |
111 | wxPoint GetStartPosition(); | |
dbd2f790 | 112 | wxHtmlWindow* CreateHTMLCtrl(wxWindow* parent = NULL); |
a3a5df9d | 113 | wxAuiNotebook* CreateNotebook(); |
50acee04 JS |
114 | |
115 | wxString GetIntroText(); | |
116 | ||
117 | private: | |
118 | ||
58754643 BW |
119 | void OnEraseBackground(wxEraseEvent& evt); |
120 | void OnSize(wxSizeEvent& evt); | |
121 | ||
122 | void OnCreateTree(wxCommandEvent& evt); | |
123 | void OnCreateGrid(wxCommandEvent& evt); | |
124 | void OnCreateHTML(wxCommandEvent& evt); | |
df00bdf7 | 125 | void OnCreateNotebook(wxCommandEvent& evt); |
58754643 BW |
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); | |
135 | ||
136 | void OnGradient(wxCommandEvent& evt); | |
137 | void OnManagerFlag(wxCommandEvent& evt); | |
c50fa29f | 138 | void OnNotebookFlag(wxCommandEvent& evt); |
58754643 BW |
139 | void OnUpdateUI(wxUpdateUIEvent& evt); |
140 | ||
a3a5df9d | 141 | void OnPaneClose(wxAuiManagerEvent& evt); |
58754643 | 142 | |
50acee04 JS |
143 | private: |
144 | ||
a3a5df9d | 145 | wxAuiManager m_mgr; |
50acee04 JS |
146 | wxArrayString m_perspectives; |
147 | wxMenu* m_perspectives_menu; | |
c50fa29f | 148 | long m_notebook_style; |
bfeed34c | 149 | |
6dcf9888 | 150 | DECLARE_EVENT_TABLE() |
50acee04 JS |
151 | }; |
152 | ||
153 | ||
50acee04 JS |
154 | // -- wxSizeReportCtrl -- |
155 | // (a utility control that always reports it's client size) | |
156 | ||
157 | class wxSizeReportCtrl : public wxControl | |
158 | { | |
159 | public: | |
160 | ||
bfeed34c | 161 | wxSizeReportCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, |
50acee04 JS |
162 | const wxPoint& pos = wxDefaultPosition, |
163 | const wxSize& size = wxDefaultSize, | |
a3a5df9d | 164 | wxAuiManager* mgr = NULL) |
50acee04 JS |
165 | : wxControl(parent, id, pos, size, wxNO_BORDER) |
166 | { | |
167 | m_mgr = mgr; | |
168 | } | |
169 | ||
170 | private: | |
171 | ||
bfeed34c | 172 | void OnPaint(wxPaintEvent& WXUNUSED(evt)) |
50acee04 JS |
173 | { |
174 | wxPaintDC dc(this); | |
175 | wxSize size = GetClientSize(); | |
176 | wxString s; | |
177 | int h, w, height; | |
178 | ||
179 | s.Printf(wxT("Size: %d x %d"), size.x, size.y); | |
180 | ||
181 | dc.SetFont(*wxNORMAL_FONT); | |
182 | dc.GetTextExtent(s, &w, &height); | |
183 | height += 3; | |
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)); | |
bfeed34c | 191 | |
50acee04 JS |
192 | if (m_mgr) |
193 | { | |
a3a5df9d | 194 | wxAuiPaneInfo pi = m_mgr->GetPane(this); |
bfeed34c | 195 | |
50acee04 JS |
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)); | |
bfeed34c | 199 | |
50acee04 JS |
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)); | |
bfeed34c | 203 | |
50acee04 JS |
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)); | |
bfeed34c | 207 | |
50acee04 JS |
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)); | |
211 | } | |
212 | } | |
213 | ||
bfeed34c | 214 | void OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) |
50acee04 JS |
215 | { |
216 | // intentionally empty | |
217 | } | |
218 | ||
bfeed34c | 219 | void OnSize(wxSizeEvent& WXUNUSED(evt)) |
50acee04 JS |
220 | { |
221 | Refresh(); | |
222 | } | |
223 | private: | |
224 | ||
a3a5df9d | 225 | wxAuiManager* m_mgr; |
bfeed34c | 226 | |
6dcf9888 | 227 | DECLARE_EVENT_TABLE() |
50acee04 JS |
228 | }; |
229 | ||
230 | BEGIN_EVENT_TABLE(wxSizeReportCtrl, wxControl) | |
231 | EVT_PAINT(wxSizeReportCtrl::OnPaint) | |
232 | EVT_SIZE(wxSizeReportCtrl::OnSize) | |
233 | EVT_ERASE_BACKGROUND(wxSizeReportCtrl::OnEraseBackground) | |
234 | END_EVENT_TABLE() | |
235 | ||
236 | ||
50acee04 JS |
237 | class SettingsPanel : public wxPanel |
238 | { | |
239 | enum | |
240 | { | |
241 | ID_PaneBorderSize = wxID_HIGHEST+1, | |
242 | ID_SashSize, | |
243 | ID_CaptionSize, | |
244 | ID_BackgroundColor, | |
245 | ID_SashColor, | |
246 | ID_InactiveCaptionColor, | |
247 | ID_InactiveCaptionGradientColor, | |
248 | ID_InactiveCaptionTextColor, | |
249 | ID_ActiveCaptionColor, | |
250 | ID_ActiveCaptionGradientColor, | |
251 | ID_ActiveCaptionTextColor, | |
252 | ID_BorderColor, | |
253 | ID_GripperColor | |
254 | }; | |
255 | ||
256 | public: | |
257 | ||
258 | SettingsPanel(wxWindow* parent, MyFrame* frame) | |
bfeed34c | 259 | : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) |
50acee04 JS |
260 | { |
261 | //wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); | |
262 | ||
263 | //vert->Add(1, 1, 1, wxEXPAND); | |
264 | ||
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); | |
bfeed34c | 268 | s1->Add(new wxStaticText(this, wxID_ANY, wxT("Pane Border Size:"))); |
50acee04 JS |
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); | |
273 | ||
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); | |
bfeed34c | 277 | s2->Add(new wxStaticText(this, wxID_ANY, wxT("Sash Size:"))); |
50acee04 JS |
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); | |
282 | ||
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); | |
bfeed34c | 286 | s3->Add(new wxStaticText(this, wxID_ANY, wxT("Caption Size:"))); |
50acee04 JS |
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); | |
291 | ||
292 | //vert->Add(1, 1, 1, wxEXPAND); | |
293 | ||
294 | ||
295 | wxBitmap b = CreateColorBitmap(*wxBLACK); | |
296 | ||
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); | |
bfeed34c | 300 | s4->Add(new wxStaticText(this, wxID_ANY, wxT("Background Color:"))); |
50acee04 JS |
301 | s4->Add(m_background_color); |
302 | s4->Add(1, 1, 1, wxEXPAND); | |
303 | s4->SetItemMinSize((size_t)1, 180, 20); | |
304 | ||
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); | |
bfeed34c | 308 | s5->Add(new wxStaticText(this, wxID_ANY, wxT("Sash Color:"))); |
50acee04 JS |
309 | s5->Add(m_sash_color); |
310 | s5->Add(1, 1, 1, wxEXPAND); | |
311 | s5->SetItemMinSize((size_t)1, 180, 20); | |
312 | ||
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); | |
bfeed34c | 316 | s6->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption:"))); |
50acee04 JS |
317 | s6->Add(m_inactive_caption_color); |
318 | s6->Add(1, 1, 1, wxEXPAND); | |
319 | s6->SetItemMinSize((size_t)1, 180, 20); | |
320 | ||
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); | |
bfeed34c | 324 | s7->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption Gradient:"))); |
50acee04 JS |
325 | s7->Add(m_inactive_caption_gradient_color); |
326 | s7->Add(1, 1, 1, wxEXPAND); | |
327 | s7->SetItemMinSize((size_t)1, 180, 20); | |
328 | ||
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); | |
bfeed34c | 332 | s8->Add(new wxStaticText(this, wxID_ANY, wxT("Normal Caption Text:"))); |
50acee04 JS |
333 | s8->Add(m_inactive_caption_text_color); |
334 | s8->Add(1, 1, 1, wxEXPAND); | |
335 | s8->SetItemMinSize((size_t)1, 180, 20); | |
336 | ||
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); | |
bfeed34c | 340 | s9->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption:"))); |
50acee04 JS |
341 | s9->Add(m_active_caption_color); |
342 | s9->Add(1, 1, 1, wxEXPAND); | |
343 | s9->SetItemMinSize((size_t)1, 180, 20); | |
344 | ||
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); | |
bfeed34c | 348 | s10->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption Gradient:"))); |
50acee04 JS |
349 | s10->Add(m_active_caption_gradient_color); |
350 | s10->Add(1, 1, 1, wxEXPAND); | |
351 | s10->SetItemMinSize((size_t)1, 180, 20); | |
352 | ||
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); | |
bfeed34c | 356 | s11->Add(new wxStaticText(this, wxID_ANY, wxT("Active Caption Text:"))); |
50acee04 JS |
357 | s11->Add(m_active_caption_text_color); |
358 | s11->Add(1, 1, 1, wxEXPAND); | |
359 | s11->SetItemMinSize((size_t)1, 180, 20); | |
360 | ||
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); | |
bfeed34c | 364 | s12->Add(new wxStaticText(this, wxID_ANY, wxT("Border Color:"))); |
50acee04 JS |
365 | s12->Add(m_border_color); |
366 | s12->Add(1, 1, 1, wxEXPAND); | |
367 | s12->SetItemMinSize((size_t)1, 180, 20); | |
368 | ||
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); | |
bfeed34c | 372 | s13->Add(new wxStaticText(this, wxID_ANY, wxT("Gripper Color:"))); |
50acee04 JS |
373 | s13->Add(m_gripper_color); |
374 | s13->Add(1, 1, 1, wxEXPAND); | |
375 | s13->SetItemMinSize((size_t)1, 180, 20); | |
bfeed34c | 376 | |
50acee04 JS |
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); | |
bfeed34c | 386 | |
50acee04 JS |
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); | |
391 | ||
392 | m_frame = frame; | |
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)); | |
bfeed34c | 396 | |
50acee04 JS |
397 | UpdateColors(); |
398 | } | |
399 | ||
400 | private: | |
401 | ||
402 | wxBitmap CreateColorBitmap(const wxColour& c) | |
403 | { | |
404 | wxImage image; | |
405 | image.Create(25,14); | |
406 | for (int x = 0; x < 25; ++x) | |
407 | for (int y = 0; y < 14; ++y) | |
408 | { | |
409 | wxColour pixcol = c; | |
410 | if (x == 0 || x == 24 || y == 0 || y == 13) | |
411 | pixcol = *wxBLACK; | |
412 | image.SetRGB(x, y, pixcol.Red(), pixcol.Green(), pixcol.Blue()); | |
413 | } | |
414 | return wxBitmap(image); | |
415 | } | |
bfeed34c | 416 | |
50acee04 JS |
417 | void UpdateColors() |
418 | { | |
419 | wxColour bk = m_frame->GetDockArt()->GetColor(wxAUI_ART_BACKGROUND_COLOUR); | |
420 | m_background_color->SetBitmapLabel(CreateColorBitmap(bk)); | |
bfeed34c | 421 | |
50acee04 JS |
422 | wxColour cap = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_COLOUR); |
423 | m_inactive_caption_color->SetBitmapLabel(CreateColorBitmap(cap)); | |
bfeed34c | 424 | |
50acee04 JS |
425 | wxColour capgrad = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR); |
426 | m_inactive_caption_gradient_color->SetBitmapLabel(CreateColorBitmap(capgrad)); | |
bfeed34c | 427 | |
50acee04 JS |
428 | wxColour captxt = m_frame->GetDockArt()->GetColor(wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR); |
429 | m_inactive_caption_text_color->SetBitmapLabel(CreateColorBitmap(captxt)); | |
bfeed34c | 430 | |
50acee04 JS |
431 | wxColour acap = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_COLOUR); |
432 | m_active_caption_color->SetBitmapLabel(CreateColorBitmap(acap)); | |
bfeed34c | 433 | |
50acee04 JS |
434 | wxColour acapgrad = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR); |
435 | m_active_caption_gradient_color->SetBitmapLabel(CreateColorBitmap(acapgrad)); | |
bfeed34c | 436 | |
50acee04 JS |
437 | wxColour acaptxt = m_frame->GetDockArt()->GetColor(wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR); |
438 | m_active_caption_text_color->SetBitmapLabel(CreateColorBitmap(acaptxt)); | |
439 | ||
440 | wxColour sash = m_frame->GetDockArt()->GetColor(wxAUI_ART_SASH_COLOUR); | |
441 | m_sash_color->SetBitmapLabel(CreateColorBitmap(sash)); | |
bfeed34c | 442 | |
50acee04 JS |
443 | wxColour border = m_frame->GetDockArt()->GetColor(wxAUI_ART_BORDER_COLOUR); |
444 | m_border_color->SetBitmapLabel(CreateColorBitmap(border)); | |
bfeed34c | 445 | |
50acee04 JS |
446 | wxColour gripper = m_frame->GetDockArt()->GetColor(wxAUI_ART_GRIPPER_COLOUR); |
447 | m_gripper_color->SetBitmapLabel(CreateColorBitmap(gripper)); | |
448 | } | |
bfeed34c | 449 | |
50acee04 JS |
450 | void OnPaneBorderSize(wxSpinEvent& event) |
451 | { | |
452 | m_frame->GetDockArt()->SetMetric(wxAUI_ART_PANE_BORDER_SIZE, | |
453 | event.GetPosition()); | |
454 | m_frame->DoUpdate(); | |
455 | } | |
456 | ||
457 | void OnSashSize(wxSpinEvent& event) | |
458 | { | |
459 | m_frame->GetDockArt()->SetMetric(wxAUI_ART_SASH_SIZE, | |
460 | event.GetPosition()); | |
461 | m_frame->DoUpdate(); | |
462 | } | |
463 | ||
464 | void OnCaptionSize(wxSpinEvent& event) | |
465 | { | |
466 | m_frame->GetDockArt()->SetMetric(wxAUI_ART_CAPTION_SIZE, | |
467 | event.GetPosition()); | |
468 | m_frame->DoUpdate(); | |
469 | } | |
470 | ||
471 | void OnSetColor(wxCommandEvent& event) | |
472 | { | |
473 | wxColourDialog dlg(m_frame); | |
474 | dlg.SetTitle(_("Color Picker")); | |
475 | if (dlg.ShowModal() != wxID_OK) | |
476 | return; | |
bfeed34c | 477 | |
50acee04 JS |
478 | int var = 0; |
479 | switch (event.GetId()) | |
480 | { | |
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; | |
491 | default: return; | |
492 | } | |
bfeed34c | 493 | |
50acee04 JS |
494 | m_frame->GetDockArt()->SetColor(var, dlg.GetColourData().GetColour()); |
495 | m_frame->DoUpdate(); | |
496 | UpdateColors(); | |
497 | } | |
bfeed34c | 498 | |
50acee04 JS |
499 | private: |
500 | ||
501 | MyFrame* m_frame; | |
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; | |
bfeed34c | 515 | |
50acee04 JS |
516 | DECLARE_EVENT_TABLE() |
517 | }; | |
518 | ||
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) | |
bfeed34c | 532 | EVT_BUTTON(ID_GripperColor, SettingsPanel::OnSetColor) |
50acee04 JS |
533 | END_EVENT_TABLE() |
534 | ||
535 | ||
50acee04 JS |
536 | bool MyApp::OnInit() |
537 | { | |
538 | wxFrame* frame = new MyFrame(NULL, | |
539 | wxID_ANY, | |
70476471 | 540 | wxT("wxAUI Sample Application"), |
50acee04 JS |
541 | wxDefaultPosition, |
542 | wxSize(800, 600)); | |
543 | SetTopWindow(frame); | |
544 | frame->Show(); | |
545 | ||
546 | return true; | |
547 | } | |
548 | ||
50acee04 JS |
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) | |
cf6fec73 BW |
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) | |
50acee04 JS |
566 | EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag) |
567 | EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag) | |
c50fa29f BW |
568 | EVT_MENU(ID_NotebookCloseButton, MyFrame::OnNotebookFlag) |
569 | EVT_MENU(ID_NotebookCloseButtonAll, MyFrame::OnNotebookFlag) | |
570 | EVT_MENU(ID_NotebookCloseButtonActive, MyFrame::OnNotebookFlag) | |
50acee04 JS |
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) | |
df00bdf7 | 580 | EVT_MENU(ID_NotebookContent, MyFrame::OnChangeContentPane) |
50acee04 JS |
581 | EVT_MENU(wxID_EXIT, MyFrame::OnExit) |
582 | EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) | |
c50fa29f BW |
583 | EVT_UPDATE_UI(ID_NotebookCloseButton, MyFrame::OnUpdateUI) |
584 | EVT_UPDATE_UI(ID_NotebookCloseButtonAll, MyFrame::OnUpdateUI) | |
585 | EVT_UPDATE_UI(ID_NotebookCloseButtonActive, MyFrame::OnUpdateUI) | |
50acee04 JS |
586 | EVT_UPDATE_UI(ID_AllowFloating, MyFrame::OnUpdateUI) |
587 | EVT_UPDATE_UI(ID_TransparentHint, MyFrame::OnUpdateUI) | |
cf6fec73 BW |
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) | |
50acee04 JS |
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) | |
58754643 | 599 | EVT_AUI_PANECLOSE(MyFrame::OnPaneClose) |
50acee04 JS |
600 | END_EVENT_TABLE() |
601 | ||
602 | ||
50acee04 JS |
603 | MyFrame::MyFrame(wxWindow* parent, |
604 | wxWindowID id, | |
605 | const wxString& title, | |
606 | const wxPoint& pos, | |
607 | const wxSize& size, | |
608 | long style) | |
609 | : wxFrame(parent, id, title, pos, size, style) | |
610 | { | |
a3a5df9d | 611 | // tell wxAuiManager to manage this frame |
461125ea | 612 | m_mgr.SetManagedWindow(this); |
bfeed34c | 613 | |
50acee04 JS |
614 | // set frame icon |
615 | SetIcon(wxIcon(sample_xpm)); | |
616 | ||
c50fa29f BW |
617 | // set up default notebook style |
618 | m_notebook_style = wxAUI_NB_DEFAULT_STYLE | wxNO_BORDER; | |
619 | ||
50acee04 JS |
620 | // create menu |
621 | wxMenuBar* mb = new wxMenuBar; | |
622 | ||
623 | wxMenu* file_menu = new wxMenu; | |
624 | file_menu->Append(wxID_EXIT, _("Exit")); | |
625 | ||
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")); | |
df00bdf7 | 637 | view_menu->Append(ID_NotebookContent, _("Use a AUI wxMultiNotebook control for the Content Pane")); |
bfeed34c WS |
638 | view_menu->Append(ID_SizeReportContent, _("Use a Size Reporter for the Content Pane")); |
639 | ||
50acee04 | 640 | wxMenu* options_menu = new wxMenu; |
cf6fec73 BW |
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")); | |
50acee04 | 647 | options_menu->AppendCheckItem(ID_AllowFloating, _("Allow Floating")); |
cf6fec73 | 648 | options_menu->AppendCheckItem(ID_NoVenetianFade, _("Disable Venetian Blinds Hint Fade-in")); |
50acee04 JS |
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")); | |
bfeed34c | 657 | |
c50fa29f BW |
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")); | |
662 | ||
50acee04 JS |
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")); | |
669 | ||
670 | wxMenu* help_menu = new wxMenu; | |
671 | help_menu->Append(wxID_ABOUT, _("About...")); | |
bfeed34c | 672 | |
50acee04 JS |
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")); | |
c50fa29f | 677 | mb->Append(notebook_menu, _("Notebook")); |
50acee04 | 678 | mb->Append(help_menu, _("Help")); |
bfeed34c | 679 | |
50acee04 JS |
680 | SetMenuBar(mb); |
681 | ||
682 | CreateStatusBar(); | |
683 | GetStatusBar()->SetStatusText(_("Ready")); | |
684 | ||
685 | ||
686 | // min size for the frame itself isn't completely done. | |
a3a5df9d | 687 | // see the end up wxAuiManager::Update() for the test |
50acee04 JS |
688 | // code. For now, just hard code a frame minimum size |
689 | SetMinSize(wxSize(400,300)); | |
690 | ||
691 | // create some toolbars | |
bfeed34c | 692 | wxToolBar* tb1 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
50acee04 JS |
693 | wxTB_FLAT | wxTB_NODIVIDER); |
694 | tb1->SetToolBitmapSize(wxSize(48,48)); | |
695 | tb1->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR)); | |
696 | tb1->AddSeparator(); | |
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)); | |
701 | tb1->Realize(); | |
702 | ||
703 | ||
bfeed34c | 704 | wxToolBar* tb2 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
50acee04 JS |
705 | wxTB_FLAT | wxTB_NODIVIDER); |
706 | tb2->SetToolBitmapSize(wxSize(16,16)); | |
707 | ||
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); | |
713 | tb2->AddSeparator(); | |
714 | tb2->AddTool(101, wxT("Test"), tb2_bmp1); | |
715 | tb2->AddTool(101, wxT("Test"), tb2_bmp1); | |
716 | tb2->AddSeparator(); | |
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); | |
721 | tb2->Realize(); | |
722 | ||
bfeed34c WS |
723 | |
724 | wxToolBar* tb3 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, | |
50acee04 JS |
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); | |
732 | tb3->AddSeparator(); | |
733 | tb3->AddTool(101, wxT("Test"), tb3_bmp1); | |
734 | tb3->AddTool(101, wxT("Test"), tb3_bmp1); | |
735 | tb3->Realize(); | |
736 | ||
737 | ||
bfeed34c | 738 | wxToolBar* tb4 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
50acee04 JS |
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); | |
746 | tb4->AddSeparator(); | |
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); | |
751 | tb4->Realize(); | |
752 | ||
753 | // create some toolbars | |
bfeed34c | 754 | wxToolBar* tb5 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
50acee04 JS |
755 | wxTB_FLAT | wxTB_NODIVIDER | wxTB_VERTICAL); |
756 | tb5->SetToolBitmapSize(wxSize(48,48)); | |
757 | tb5->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR)); | |
758 | tb5->AddSeparator(); | |
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)); | |
763 | tb5->Realize(); | |
764 | ||
50acee04 | 765 | // add a bunch of panes |
a3a5df9d | 766 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
767 | Name(wxT("test1")).Caption(wxT("Pane Caption")). |
768 | Top()); | |
769 | ||
a3a5df9d | 770 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 | 771 | Name(wxT("test2")).Caption(wxT("Client Size Reporter")). |
37106ab2 BW |
772 | Bottom().Position(1). |
773 | PinButton(true).CloseButton(true).MaximizeButton(true)); | |
50acee04 | 774 | |
a3a5df9d | 775 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 | 776 | Name(wxT("test3")).Caption(wxT("Client Size Reporter")). |
37106ab2 BW |
777 | Bottom(). |
778 | PinButton(true).CloseButton(true).MaximizeButton(true)); | |
bfeed34c | 779 | |
a3a5df9d | 780 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
781 | Name(wxT("test4")).Caption(wxT("Pane Caption")). |
782 | Left()); | |
bfeed34c | 783 | |
a3a5df9d | 784 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
31ec1d03 BW |
785 | Name(wxT("test5")).Caption(wxT("No Close Button")). |
786 | Right().CloseButton(false)); | |
bfeed34c | 787 | |
a3a5df9d | 788 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 | 789 | Name(wxT("test6")).Caption(wxT("Client Size Reporter")). |
37106ab2 BW |
790 | Right().Row(1). |
791 | PinButton(true).CloseButton(true).MaximizeButton(true)); | |
50acee04 | 792 | |
a3a5df9d | 793 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 | 794 | Name(wxT("test7")).Caption(wxT("Client Size Reporter")). |
37106ab2 BW |
795 | Left().Layer(1). |
796 | PinButton(true).CloseButton(true).MaximizeButton(true)); | |
bfeed34c | 797 | |
a3a5df9d | 798 | m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo(). |
50acee04 | 799 | Name(wxT("test8")).Caption(wxT("Tree Pane")). |
37106ab2 BW |
800 | Left().Layer(1).Position(1). |
801 | CloseButton(true).MaximizeButton(true)); | |
50acee04 | 802 | |
a3a5df9d | 803 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
804 | Name(wxT("test9")).Caption(wxT("Min Size 200x100")). |
805 | BestSize(wxSize(200,100)).MinSize(wxSize(200,100)). | |
37106ab2 BW |
806 | Bottom().Layer(1). |
807 | CloseButton(true).MaximizeButton(true)); | |
50acee04 | 808 | |
58754643 | 809 | wxWindow* wnd10 = CreateTextCtrl(wxT("This pane will prompt the user before hiding.")); |
a3a5df9d | 810 | m_mgr.AddPane(wnd10, wxAuiPaneInfo(). |
58754643 | 811 | Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")). |
50acee04 | 812 | Bottom().Layer(1).Position(1)); |
bfeed34c | 813 | |
a3a5df9d | 814 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
815 | Name(wxT("test11")).Caption(wxT("Fixed Pane")). |
816 | Bottom().Layer(1).Position(2).Fixed()); | |
817 | ||
bfeed34c | 818 | |
a3a5df9d | 819 | m_mgr.AddPane(new SettingsPanel(this,this), wxAuiPaneInfo(). |
50acee04 JS |
820 | Name(wxT("settings")).Caption(wxT("Dock Manager Settings")). |
821 | Dockable(false).Float().Hide()); | |
822 | ||
823 | // create some center panes | |
824 | ||
a3a5df9d | 825 | m_mgr.AddPane(CreateGrid(), wxAuiPaneInfo().Name(wxT("grid_content")). |
50acee04 JS |
826 | CenterPane().Hide()); |
827 | ||
a3a5df9d | 828 | m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().Name(wxT("tree_content")). |
50acee04 | 829 | CenterPane().Hide()); |
bfeed34c | 830 | |
a3a5df9d | 831 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().Name(wxT("sizereport_content")). |
50acee04 JS |
832 | CenterPane().Hide()); |
833 | ||
a3a5df9d | 834 | m_mgr.AddPane(CreateTextCtrl(), wxAuiPaneInfo().Name(wxT("text_content")). |
50acee04 JS |
835 | CenterPane().Hide()); |
836 | ||
a3a5df9d | 837 | m_mgr.AddPane(CreateHTMLCtrl(), wxAuiPaneInfo().Name(wxT("html_content")). |
50acee04 | 838 | CenterPane()); |
bfeed34c | 839 | |
a3a5df9d | 840 | m_mgr.AddPane(CreateNotebook(), wxAuiPaneInfo().Name(wxT("notebook_content")). |
2e5c35af | 841 | CenterPane().PaneBorder(false)); |
df00bdf7 | 842 | |
50acee04 | 843 | // add the toolbars to the manager |
a3a5df9d | 844 | m_mgr.AddPane(tb1, wxAuiPaneInfo(). |
50acee04 JS |
845 | Name(wxT("tb1")).Caption(wxT("Big Toolbar")). |
846 | ToolbarPane().Top(). | |
847 | LeftDockable(false).RightDockable(false)); | |
848 | ||
a3a5df9d | 849 | m_mgr.AddPane(tb2, wxAuiPaneInfo(). |
50acee04 JS |
850 | Name(wxT("tb2")).Caption(wxT("Toolbar 2")). |
851 | ToolbarPane().Top().Row(1). | |
852 | LeftDockable(false).RightDockable(false)); | |
bfeed34c | 853 | |
a3a5df9d | 854 | m_mgr.AddPane(tb3, wxAuiPaneInfo(). |
50acee04 JS |
855 | Name(wxT("tb3")).Caption(wxT("Toolbar 3")). |
856 | ToolbarPane().Top().Row(1).Position(1). | |
857 | LeftDockable(false).RightDockable(false)); | |
bfeed34c | 858 | |
a3a5df9d | 859 | m_mgr.AddPane(tb4, wxAuiPaneInfo(). |
50acee04 JS |
860 | Name(wxT("tb4")).Caption(wxT("Sample Bookmark Toolbar")). |
861 | ToolbarPane().Top().Row(2). | |
862 | LeftDockable(false).RightDockable(false)); | |
bfeed34c | 863 | |
a3a5df9d | 864 | m_mgr.AddPane(tb5, wxAuiPaneInfo(). |
2c26bdee | 865 | Name(wxT("tb5")).Caption(wxT("Sample Vertical Toolbar")). |
50acee04 JS |
866 | ToolbarPane().Left(). |
867 | GripperTop(). | |
868 | TopDockable(false).BottomDockable(false)); | |
bfeed34c WS |
869 | |
870 | m_mgr.AddPane(new wxButton(this, wxID_ANY, _("Test Button")), | |
a3a5df9d | 871 | wxAuiPaneInfo().Name(wxT("tb6")). |
50acee04 JS |
872 | ToolbarPane().Top().Row(2).Position(1). |
873 | LeftDockable(false).RightDockable(false)); | |
874 | ||
50acee04 | 875 | // make some default perspectives |
bfeed34c | 876 | |
50acee04 | 877 | wxString perspective_all = m_mgr.SavePerspective(); |
bfeed34c | 878 | |
50acee04 | 879 | int i, count; |
a3a5df9d | 880 | wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); |
50acee04 JS |
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(); | |
60fa553c | 885 | m_mgr.GetPane(wxT("tb6")).Hide(); |
50acee04 JS |
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); | |
dbd2f790 | 888 | m_mgr.GetPane(wxT("notebook_content")).Show(); |
50acee04 | 889 | wxString perspective_default = m_mgr.SavePerspective(); |
bfeed34c | 890 | |
50acee04 JS |
891 | m_perspectives.Add(perspective_default); |
892 | m_perspectives.Add(perspective_all); | |
893 | ||
a3a5df9d | 894 | // "commit" all changes made to wxAuiManager |
50acee04 JS |
895 | m_mgr.Update(); |
896 | } | |
897 | ||
898 | MyFrame::~MyFrame() | |
899 | { | |
900 | m_mgr.UnInit(); | |
901 | } | |
902 | ||
a3a5df9d | 903 | wxAuiDockArt* MyFrame::GetDockArt() |
50acee04 JS |
904 | { |
905 | return m_mgr.GetArtProvider(); | |
906 | } | |
907 | ||
908 | void MyFrame::DoUpdate() | |
909 | { | |
910 | m_mgr.Update(); | |
911 | } | |
912 | ||
50acee04 JS |
913 | void MyFrame::OnEraseBackground(wxEraseEvent& event) |
914 | { | |
915 | event.Skip(); | |
916 | } | |
917 | ||
918 | void MyFrame::OnSize(wxSizeEvent& event) | |
919 | { | |
920 | event.Skip(); | |
921 | } | |
922 | ||
bfeed34c | 923 | void MyFrame::OnSettings(wxCommandEvent& WXUNUSED(event)) |
50acee04 JS |
924 | { |
925 | // show the settings pane, and float it | |
a3a5df9d | 926 | wxAuiPaneInfo& floating_pane = m_mgr.GetPane(wxT("settings")).Float().Show(); |
50acee04 JS |
927 | |
928 | if (floating_pane.floating_pos == wxDefaultPosition) | |
929 | floating_pane.FloatingPosition(GetStartPosition()); | |
930 | ||
931 | m_mgr.Update(); | |
932 | } | |
933 | ||
50acee04 JS |
934 | void MyFrame::OnGradient(wxCommandEvent& event) |
935 | { | |
936 | int gradient = 0; | |
937 | ||
938 | switch (event.GetId()) | |
939 | { | |
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; | |
943 | } | |
944 | ||
945 | m_mgr.GetArtProvider()->SetMetric(wxAUI_ART_GRADIENT_TYPE, gradient); | |
946 | m_mgr.Update(); | |
947 | } | |
948 | ||
949 | void MyFrame::OnManagerFlag(wxCommandEvent& event) | |
950 | { | |
951 | unsigned int flag = 0; | |
bfeed34c | 952 | |
7a5b04a6 | 953 | #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__) |
50acee04 JS |
954 | if (event.GetId() == ID_TransparentDrag || |
955 | event.GetId() == ID_TransparentHint || | |
cf6fec73 | 956 | event.GetId() == ID_HintFade) |
50acee04 | 957 | { |
7a5b04a6 | 958 | wxMessageBox(wxT("This option is presently only available on wxGTK, wxMSW and wxMac")); |
50acee04 JS |
959 | return; |
960 | } | |
bfeed34c WS |
961 | #endif |
962 | ||
cf6fec73 BW |
963 | int id = event.GetId(); |
964 | ||
965 | if (id == ID_TransparentHint || | |
966 | id == ID_VenetianBlindsHint || | |
967 | id == ID_RectangleHint || | |
968 | id == ID_NoHint) | |
969 | { | |
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); | |
975 | } | |
976 | ||
977 | switch (id) | |
50acee04 JS |
978 | { |
979 | case ID_AllowFloating: flag = wxAUI_MGR_ALLOW_FLOATING; break; | |
980 | case ID_TransparentDrag: flag = wxAUI_MGR_TRANSPARENT_DRAG; break; | |
cf6fec73 BW |
981 | case ID_HintFade: flag = wxAUI_MGR_HINT_FADE; break; |
982 | case ID_NoVenetianFade: flag = wxAUI_MGR_NO_VENETIAN_BLINDS_FADE; break; | |
50acee04 | 983 | case ID_AllowActivePane: flag = wxAUI_MGR_ALLOW_ACTIVE_PANE; break; |
cf6fec73 BW |
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; | |
987 | } | |
988 | ||
989 | if (flag) | |
990 | { | |
991 | m_mgr.SetFlags(m_mgr.GetFlags() ^ flag); | |
50acee04 | 992 | } |
cf6fec73 | 993 | |
50acee04 JS |
994 | m_mgr.Update(); |
995 | } | |
996 | ||
c50fa29f BW |
997 | |
998 | void MyFrame::OnNotebookFlag(wxCommandEvent& event) | |
999 | { | |
1000 | int id = event.GetId(); | |
1001 | ||
1002 | if (id == ID_NotebookCloseButton || | |
1003 | id == ID_NotebookCloseButtonAll || | |
1004 | id == ID_NotebookCloseButtonActive) | |
1005 | { | |
1006 | m_notebook_style &= ~(wxAUI_NB_CLOSE_BUTTON | | |
1007 | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | | |
1008 | wxAUI_NB_CLOSE_ON_ALL_TABS); | |
1009 | ||
1010 | switch (id) | |
1011 | { | |
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; | |
1015 | } | |
1016 | ||
1017 | } | |
1018 | ||
1019 | ||
1020 | size_t i, count; | |
1021 | wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); | |
1022 | for (i = 0, count = all_panes.GetCount(); i < count; ++i) | |
1023 | { | |
1024 | wxAuiPaneInfo& pane = all_panes.Item(i); | |
1025 | ||
1026 | if (pane.window->IsKindOf(CLASSINFO(wxAuiNotebook))) | |
1027 | { | |
1028 | pane.window->SetWindowStyleFlag(m_notebook_style); | |
1029 | pane.window->Refresh(); | |
1030 | } | |
1031 | } | |
1032 | ||
1033 | ||
1034 | } | |
1035 | ||
1036 | ||
50acee04 JS |
1037 | void MyFrame::OnUpdateUI(wxUpdateUIEvent& event) |
1038 | { | |
1039 | unsigned int flags = m_mgr.GetFlags(); | |
bfeed34c | 1040 | |
50acee04 JS |
1041 | switch (event.GetId()) |
1042 | { | |
1043 | case ID_NoGradient: | |
87d658e5 | 1044 | event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_NONE); |
50acee04 JS |
1045 | break; |
1046 | case ID_VerticalGradient: | |
87d658e5 | 1047 | event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_VERTICAL); |
50acee04 JS |
1048 | break; |
1049 | case ID_HorizontalGradient: | |
87d658e5 | 1050 | event.Check(m_mgr.GetArtProvider()->GetMetric(wxAUI_ART_GRADIENT_TYPE) == wxAUI_GRADIENT_HORIZONTAL); |
50acee04 JS |
1051 | break; |
1052 | case ID_AllowFloating: | |
87d658e5 | 1053 | event.Check((flags & wxAUI_MGR_ALLOW_FLOATING) != 0); |
50acee04 JS |
1054 | break; |
1055 | case ID_TransparentDrag: | |
87d658e5 | 1056 | event.Check((flags & wxAUI_MGR_TRANSPARENT_DRAG) != 0); |
50acee04 JS |
1057 | break; |
1058 | case ID_TransparentHint: | |
87d658e5 | 1059 | event.Check((flags & wxAUI_MGR_TRANSPARENT_HINT) != 0); |
50acee04 | 1060 | break; |
cf6fec73 BW |
1061 | case ID_VenetianBlindsHint: |
1062 | event.Check((flags & wxAUI_MGR_VENETIAN_BLINDS_HINT) != 0); | |
1063 | break; | |
1064 | case ID_RectangleHint: | |
1065 | event.Check((flags & wxAUI_MGR_RECTANGLE_HINT) != 0); | |
50acee04 | 1066 | break; |
cf6fec73 BW |
1067 | case ID_NoHint: |
1068 | event.Check(((wxAUI_MGR_TRANSPARENT_HINT | | |
1069 | wxAUI_MGR_VENETIAN_BLINDS_HINT | | |
1070 | wxAUI_MGR_RECTANGLE_HINT) & flags) == 0); | |
1071 | break; | |
1072 | case ID_HintFade: | |
1073 | event.Check((flags & wxAUI_MGR_HINT_FADE) != 0); | |
70476471 | 1074 | break; |
cf6fec73 BW |
1075 | case ID_NoVenetianFade: |
1076 | event.Check((flags & wxAUI_MGR_NO_VENETIAN_BLINDS_FADE) != 0); | |
70476471 | 1077 | break; |
c50fa29f BW |
1078 | |
1079 | case ID_NotebookCloseButton: | |
1080 | event.Check((m_notebook_style & wxAUI_NB_CLOSE_BUTTON) != 0); | |
1081 | break; | |
1082 | case ID_NotebookCloseButtonAll: | |
1083 | event.Check((m_notebook_style & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0); | |
1084 | break; | |
1085 | case ID_NotebookCloseButtonActive: | |
1086 | event.Check((m_notebook_style & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0); | |
1087 | break; | |
50acee04 JS |
1088 | } |
1089 | } | |
1090 | ||
a3a5df9d | 1091 | void MyFrame::OnPaneClose(wxAuiManagerEvent& evt) |
58754643 BW |
1092 | { |
1093 | if (evt.pane->name == wxT("test10")) | |
1094 | { | |
1095 | int res = wxMessageBox(wxT("Are you sure you want to close/hide this pane?"), | |
1096 | wxT("wxAUI"), | |
1097 | wxYES_NO, | |
1098 | this); | |
1099 | if (res != wxYES) | |
1100 | evt.Veto(); | |
1101 | } | |
1102 | } | |
1103 | ||
bfeed34c | 1104 | void MyFrame::OnCreatePerspective(wxCommandEvent& WXUNUSED(event)) |
50acee04 JS |
1105 | { |
1106 | wxTextEntryDialog dlg(this, wxT("Enter a name for the new perspective:"), | |
1107 | wxT("wxAUI Test")); | |
bfeed34c | 1108 | |
b143cf70 | 1109 | dlg.SetValue(wxString::Format(wxT("Perspective %u"), unsigned(m_perspectives.GetCount() + 1))); |
50acee04 JS |
1110 | if (dlg.ShowModal() != wxID_OK) |
1111 | return; | |
bfeed34c | 1112 | |
50acee04 JS |
1113 | if (m_perspectives.GetCount() == 0) |
1114 | { | |
1115 | m_perspectives_menu->AppendSeparator(); | |
1116 | } | |
bfeed34c | 1117 | |
50acee04 JS |
1118 | m_perspectives_menu->Append(ID_FirstPerspective + m_perspectives.GetCount(), dlg.GetValue()); |
1119 | m_perspectives.Add(m_mgr.SavePerspective()); | |
1120 | } | |
1121 | ||
bfeed34c | 1122 | void MyFrame::OnCopyPerspectiveCode(wxCommandEvent& WXUNUSED(event)) |
50acee04 JS |
1123 | { |
1124 | wxString s = m_mgr.SavePerspective(); | |
bfeed34c | 1125 | |
b2e17848 | 1126 | #if wxUSE_CLIPBOARD |
50acee04 JS |
1127 | if (wxTheClipboard->Open()) |
1128 | { | |
1129 | wxTheClipboard->SetData(new wxTextDataObject(s)); | |
1130 | wxTheClipboard->Close(); | |
1131 | } | |
b2e17848 | 1132 | #endif |
50acee04 JS |
1133 | } |
1134 | ||
1135 | void MyFrame::OnRestorePerspective(wxCommandEvent& event) | |
1136 | { | |
1137 | m_mgr.LoadPerspective(m_perspectives.Item(event.GetId() - ID_FirstPerspective)); | |
1138 | } | |
1139 | ||
1140 | ||
1141 | wxPoint MyFrame::GetStartPosition() | |
1142 | { | |
1143 | static int x = 0; | |
1144 | x += 20; | |
1145 | wxPoint pt = ClientToScreen(wxPoint(0,0)); | |
1146 | return wxPoint(pt.x + x, pt.y + x); | |
1147 | } | |
1148 | ||
bfeed34c | 1149 | void MyFrame::OnCreateTree(wxCommandEvent& WXUNUSED(event)) |
50acee04 | 1150 | { |
a3a5df9d | 1151 | m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
1152 | Name(wxT("Test")).Caption(wxT("Tree Control")). |
1153 | Float().FloatingPosition(GetStartPosition()). | |
1154 | FloatingSize(wxSize(150,300))); | |
1155 | m_mgr.Update(); | |
1156 | } | |
1157 | ||
bfeed34c | 1158 | void MyFrame::OnCreateGrid(wxCommandEvent& WXUNUSED(event)) |
50acee04 | 1159 | { |
a3a5df9d | 1160 | m_mgr.AddPane(CreateGrid(), wxAuiPaneInfo(). |
50acee04 JS |
1161 | Name(wxT("Test")).Caption(wxT("Grid")). |
1162 | Float().FloatingPosition(GetStartPosition()). | |
1163 | FloatingSize(wxSize(300,200))); | |
1164 | m_mgr.Update(); | |
1165 | } | |
1166 | ||
bfeed34c | 1167 | void MyFrame::OnCreateHTML(wxCommandEvent& WXUNUSED(event)) |
50acee04 | 1168 | { |
a3a5df9d | 1169 | m_mgr.AddPane(CreateHTMLCtrl(), wxAuiPaneInfo(). |
87d658e5 | 1170 | Name(wxT("Test")).Caption(wxT("HTML Control")). |
50acee04 JS |
1171 | Float().FloatingPosition(GetStartPosition()). |
1172 | FloatingSize(wxSize(300,200))); | |
1173 | m_mgr.Update(); | |
1174 | } | |
1175 | ||
df00bdf7 RR |
1176 | void MyFrame::OnCreateNotebook(wxCommandEvent& WXUNUSED(event)) |
1177 | { | |
a3a5df9d | 1178 | m_mgr.AddPane(CreateNotebook(), wxAuiPaneInfo(). |
df00bdf7 RR |
1179 | Name(wxT("Test")).Caption(wxT("Notebook")). |
1180 | Float().FloatingPosition(GetStartPosition()). | |
1181 | FloatingSize(wxSize(300,200))); | |
1182 | m_mgr.Update(); | |
1183 | } | |
1184 | ||
bfeed34c | 1185 | void MyFrame::OnCreateText(wxCommandEvent& WXUNUSED(event)) |
50acee04 | 1186 | { |
a3a5df9d | 1187 | m_mgr.AddPane(CreateTextCtrl(), wxAuiPaneInfo(). |
50acee04 JS |
1188 | Name(wxT("Test")).Caption(wxT("Text Control")). |
1189 | Float().FloatingPosition(GetStartPosition())); | |
1190 | m_mgr.Update(); | |
1191 | } | |
1192 | ||
bfeed34c | 1193 | void MyFrame::OnCreateSizeReport(wxCommandEvent& WXUNUSED(event)) |
50acee04 | 1194 | { |
a3a5df9d | 1195 | m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). |
50acee04 | 1196 | Name(wxT("Test")).Caption(wxT("Client Size Reporter")). |
37106ab2 BW |
1197 | Float().FloatingPosition(GetStartPosition()). |
1198 | PinButton(true).CloseButton(true).MaximizeButton(true)); | |
50acee04 JS |
1199 | m_mgr.Update(); |
1200 | } | |
1201 | ||
1202 | void MyFrame::OnChangeContentPane(wxCommandEvent& event) | |
1203 | { | |
87d658e5 PC |
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); | |
50acee04 JS |
1210 | m_mgr.Update(); |
1211 | } | |
1212 | ||
1213 | void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event)) | |
1214 | { | |
1215 | Close(true); | |
1216 | } | |
1217 | ||
1218 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) | |
1219 | { | |
1220 | wxMessageBox(_("wxAUI Demo\nAn advanced window management library for wxWidgets\n(c) Copyright 2005-2006, Kirix Corporation"), _("About wxAUI Demo"), wxOK, this); | |
1221 | } | |
1222 | ||
58754643 | 1223 | wxTextCtrl* MyFrame::CreateTextCtrl(const wxString& ctrl_text) |
50acee04 | 1224 | { |
50acee04 JS |
1225 | static int n = 0; |
1226 | ||
58754643 BW |
1227 | wxString text; |
1228 | if (ctrl_text.Length() > 0) | |
1229 | text = ctrl_text; | |
87d658e5 | 1230 | else |
58754643 | 1231 | text.Printf(wxT("This is text box %d"), ++n); |
50acee04 | 1232 | |
bfeed34c | 1233 | return new wxTextCtrl(this,wxID_ANY, text, |
50acee04 JS |
1234 | wxPoint(0,0), wxSize(150,90), |
1235 | wxNO_BORDER | wxTE_MULTILINE); | |
1236 | } | |
1237 | ||
1238 | ||
1239 | wxGrid* MyFrame::CreateGrid() | |
1240 | { | |
bfeed34c | 1241 | wxGrid* grid = new wxGrid(this, wxID_ANY, |
50acee04 JS |
1242 | wxPoint(0,0), |
1243 | wxSize(150,250), | |
1244 | wxNO_BORDER | wxWANTS_CHARS); | |
1245 | grid->CreateGrid(50, 20); | |
1246 | return grid; | |
1247 | } | |
1248 | ||
1249 | wxTreeCtrl* MyFrame::CreateTreeCtrl() | |
1250 | { | |
bfeed34c | 1251 | wxTreeCtrl* tree = new wxTreeCtrl(this, wxID_ANY, |
50acee04 JS |
1252 | wxPoint(0,0), wxSize(160,250), |
1253 | wxTR_DEFAULT_STYLE | wxNO_BORDER); | |
bfeed34c | 1254 | |
50acee04 JS |
1255 | wxTreeItemId root = tree->AddRoot(wxT("wxAUI Project")); |
1256 | wxArrayTreeItemIds items; | |
1257 | ||
1258 | ||
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); | |
1263 | ||
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)); | |
1269 | ||
bfeed34c | 1270 | |
50acee04 JS |
1271 | int i, count; |
1272 | for (i = 0, count = items.Count(); i < count; ++i) | |
1273 | { | |
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); | |
1280 | } | |
1281 | ||
1282 | ||
1283 | tree->Expand(root); | |
1284 | ||
1285 | return tree; | |
1286 | } | |
1287 | ||
1288 | wxSizeReportCtrl* MyFrame::CreateSizeReportCtrl(int width, int height) | |
1289 | { | |
bfeed34c | 1290 | wxSizeReportCtrl* ctrl = new wxSizeReportCtrl(this, wxID_ANY, |
50acee04 JS |
1291 | wxDefaultPosition, |
1292 | wxSize(width, height), &m_mgr); | |
1293 | return ctrl; | |
1294 | } | |
1295 | ||
dbd2f790 | 1296 | wxHtmlWindow* MyFrame::CreateHTMLCtrl(wxWindow* parent) |
50acee04 | 1297 | { |
dbd2f790 BW |
1298 | if (!parent) |
1299 | parent = this; | |
1300 | ||
1301 | wxHtmlWindow* ctrl = new wxHtmlWindow(parent, wxID_ANY, | |
50acee04 JS |
1302 | wxDefaultPosition, |
1303 | wxSize(400,300)); | |
1304 | ctrl->SetPage(GetIntroText()); | |
1305 | return ctrl; | |
1306 | } | |
1307 | ||
a3a5df9d | 1308 | wxAuiNotebook* MyFrame::CreateNotebook() |
df00bdf7 | 1309 | { |
a3a5df9d | 1310 | wxAuiNotebook* ctrl = new wxAuiNotebook( this, wxID_ANY, |
702b1c7e | 1311 | wxDefaultPosition, wxSize(400,300), |
c50fa29f | 1312 | m_notebook_style ); |
df00bdf7 | 1313 | |
dbd2f790 BW |
1314 | ctrl->AddPage(CreateHTMLCtrl(ctrl), wxT("Welcome")); |
1315 | ||
df00bdf7 RR |
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 ); | |
2e5c35af | 1323 | flex->Add( new wxTextCtrl( panel, -1, wxT(""), wxDefaultPosition, wxSize(100,-1)), |
df00bdf7 RR |
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") ); | |
1331 | ||
1332 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some text"), | |
4953f8cf | 1333 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 1") ); |
df00bdf7 RR |
1334 | |
1335 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
4953f8cf BW |
1336 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 2") ); |
1337 | ||
1338 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
1339 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 3") ); | |
1340 | ||
1341 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
1342 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 4") ); | |
1343 | ||
1344 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
1345 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 5") ); | |
df00bdf7 | 1346 | |
4953f8cf BW |
1347 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), |
1348 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 6") ); | |
1349 | ||
1350 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
1351 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 7") ); | |
1352 | ||
1353 | ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), | |
1354 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 8") ); | |
1355 | ||
c50fa29f BW |
1356 | |
1357 | ||
df00bdf7 RR |
1358 | return ctrl; |
1359 | } | |
50acee04 JS |
1360 | |
1361 | wxString MyFrame::GetIntroText() | |
1362 | { | |
1363 | const char* text = | |
1364 | "<html><body>" | |
70476471 | 1365 | "<h3>Welcome to wxAUI</h3>" |
50acee04 JS |
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>" | |
70476471 | 1371 | "<p>With wxAUI, developers can create application frameworks with:</p>" |
50acee04 JS |
1372 | "<ul>" |
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>" | |
1379 | "</ul>" | |
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>" | |
1382 | "<ul>" | |
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>" | |
1390 | "</ul>" | |
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>" | |
1393 | "<ul>" | |
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>" | |
1402 | "</ul>" | |
1403 | "<p>See README.txt for more information.</p>" | |
1404 | "</body></html>"; | |
1405 | ||
1406 | return wxString::FromAscii(text); | |
1407 | } |