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