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