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