]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AUI.py
remove WXDLLEXPORT modifiers since this isn't in the wx DLL
[wxWidgets.git] / wxPython / demo / AUI.py
1 import wx
2 import wx.grid
3 import wx.html
4 import wx.aui
5
6 import cStringIO
7
8 ID_CreateTree = wx.ID_HIGHEST+1
9 ID_CreateGrid = ID_CreateTree+2
10 ID_CreateText = ID_CreateTree+3
11 ID_CreateHTML = ID_CreateTree+4
12 ID_CreateSizeReport = ID_CreateTree+5
13 ID_GridContent = ID_CreateTree+6
14 ID_TextContent = ID_CreateTree+7
15 ID_TreeContent = ID_CreateTree+8
16 ID_HTMLContent = ID_CreateTree+9
17 ID_SizeReportContent = ID_CreateTree+10
18 ID_CreatePerspective = ID_CreateTree+11
19 ID_CopyPerspective = ID_CreateTree+12
20 ID_AllowFloating = ID_CreateTree+13
21 ID_AllowActivePane = ID_CreateTree+14
22 ID_TransparentHint = ID_CreateTree+15
23 ID_TransparentHintFade = ID_CreateTree+16
24 ID_TransparentDrag = ID_CreateTree+17
25 ID_NoGradient = ID_CreateTree+18
26 ID_VerticalGradient = ID_CreateTree+19
27 ID_HorizontalGradient = ID_CreateTree+20
28 ID_Settings = ID_CreateTree+21
29 ID_About = ID_CreateTree+22
30 ID_FirstPerspective = ID_CreatePerspective+1000
31
32 #----------------------------------------------------------------------
33 def GetMondrianData():
34 return \
35 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
36 \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
37 ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
38 o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
39 \xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
40 \x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
41 \x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82'
42
43
44 def GetMondrianBitmap():
45 return wx.BitmapFromImage(GetMondrianImage())
46
47
48 def GetMondrianImage():
49 stream = cStringIO.StringIO(GetMondrianData())
50 return wx.ImageFromStream(stream)
51
52
53 def GetMondrianIcon():
54 icon = wx.EmptyIcon()
55 icon.CopyFromBitmap(GetMondrianBitmap())
56 return icon
57
58
59 class PyAUIFrame(wx.Frame):
60
61 def __init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
62 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
63 wx.SUNKEN_BORDER |
64 wx.CLIP_CHILDREN):
65
66 wx.Frame.__init__(self, parent, id, title, pos, size, style)
67
68 # tell FrameManager to manage this frame
69 self._mgr = wx.aui.FrameManager()
70 self._mgr.SetFrame(self)
71
72 self._perspectives = []
73 self.n = 0
74 self.x = 0
75
76 self.SetIcon(GetMondrianIcon())
77
78 # create menu
79 mb = wx.MenuBar()
80
81 file_menu = wx.Menu()
82 file_menu.Append(wx.ID_EXIT, "Exit")
83
84 view_menu = wx.Menu()
85 view_menu.Append(ID_CreateText, "Create Text Control")
86 view_menu.Append(ID_CreateHTML, "Create HTML Control")
87 view_menu.Append(ID_CreateTree, "Create Tree")
88 view_menu.Append(ID_CreateGrid, "Create Grid")
89 view_menu.Append(ID_CreateSizeReport, "Create Size Reporter")
90 view_menu.AppendSeparator()
91 view_menu.Append(ID_GridContent, "Use a Grid for the Content Pane")
92 view_menu.Append(ID_TextContent, "Use a Text Control for the Content Pane")
93 view_menu.Append(ID_HTMLContent, "Use an HTML Control for the Content Pane")
94 view_menu.Append(ID_TreeContent, "Use a Tree Control for the Content Pane")
95 view_menu.Append(ID_SizeReportContent, "Use a Size Reporter for the Content Pane")
96
97 options_menu = wx.Menu()
98 options_menu.AppendCheckItem(ID_AllowFloating, "Allow Floating")
99 options_menu.AppendCheckItem(ID_TransparentHint, "Transparent Hint")
100 options_menu.AppendCheckItem(ID_TransparentHintFade, "Transparent Hint Fade-in")
101 options_menu.AppendCheckItem(ID_TransparentDrag, "Transparent Drag")
102 options_menu.AppendCheckItem(ID_AllowActivePane, "Allow Active Pane")
103 options_menu.AppendSeparator()
104 options_menu.AppendRadioItem(ID_NoGradient, "No Caption Gradient")
105 options_menu.AppendRadioItem(ID_VerticalGradient, "Vertical Caption Gradient")
106 options_menu.AppendRadioItem(ID_HorizontalGradient, "Horizontal Caption Gradient")
107 options_menu.AppendSeparator()
108 options_menu.Append(ID_Settings, "Settings Pane")
109
110 self._perspectives_menu = wx.Menu()
111 self._perspectives_menu.Append(ID_CreatePerspective, "Create Perspective")
112 self._perspectives_menu.Append(ID_CopyPerspective, "Copy Perspective Data To Clipboard")
113 self._perspectives_menu.AppendSeparator()
114 self._perspectives_menu.Append(ID_FirstPerspective+0, "Default Startup")
115 self._perspectives_menu.Append(ID_FirstPerspective+1, "All Panes")
116 self._perspectives_menu.Append(ID_FirstPerspective+2, "Vertical Toolbar")
117
118 help_menu = wx.Menu()
119 help_menu.Append(ID_About, "About...")
120
121 mb.Append(file_menu, "File")
122 mb.Append(view_menu, "View")
123 mb.Append(self._perspectives_menu, "Perspectives")
124 mb.Append(options_menu, "Options")
125 mb.Append(help_menu, "Help")
126
127 self.SetMenuBar(mb)
128
129 self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
130 self.statusbar.SetStatusWidths([-2, -3])
131 self.statusbar.SetStatusText("Ready", 0)
132 self.statusbar.SetStatusText("Welcome To wxPython!", 1)
133
134 # min size for the frame itself isn't completely done.
135 # see the end up FrameManager::Update() for the test
136 # code. For now, just hard code a frame minimum size
137 self.SetMinSize(wx.Size(400, 300))
138
139 # create some toolbars
140 tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
141 wx.TB_FLAT | wx.TB_NODIVIDER)
142 tb1.SetToolBitmapSize(wx.Size(48,48))
143 tb1.AddLabelTool(101, "Test", wx.ArtProvider_GetBitmap(wx.ART_ERROR))
144 tb1.AddSeparator()
145 tb1.AddLabelTool(102, "Test", wx.ArtProvider_GetBitmap(wx.ART_QUESTION))
146 tb1.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_INFORMATION))
147 tb1.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_WARNING))
148 tb1.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_MISSING_IMAGE))
149 tb1.Realize()
150
151 tb2 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
152 wx.TB_FLAT | wx.TB_NODIVIDER)
153 tb2.SetToolBitmapSize(wx.Size(16,16))
154 tb2_bmp1 = wx.ArtProvider_GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16))
155 tb2.AddLabelTool(101, "Test", tb2_bmp1)
156 tb2.AddLabelTool(101, "Test", tb2_bmp1)
157 tb2.AddLabelTool(101, "Test", tb2_bmp1)
158 tb2.AddLabelTool(101, "Test", tb2_bmp1)
159 tb2.AddSeparator()
160 tb2.AddLabelTool(101, "Test", tb2_bmp1)
161 tb2.AddLabelTool(101, "Test", tb2_bmp1)
162 tb2.AddSeparator()
163 tb2.AddLabelTool(101, "Test", tb2_bmp1)
164 tb2.AddLabelTool(101, "Test", tb2_bmp1)
165 tb2.AddLabelTool(101, "Test", tb2_bmp1)
166 tb2.AddLabelTool(101, "Test", tb2_bmp1)
167 tb2.Realize()
168
169 tb3 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
170 wx.TB_FLAT | wx.TB_NODIVIDER)
171 tb3.SetToolBitmapSize(wx.Size(16,16))
172 tb3_bmp1 = wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16))
173 tb3.AddLabelTool(101, "Test", tb3_bmp1)
174 tb3.AddLabelTool(101, "Test", tb3_bmp1)
175 tb3.AddLabelTool(101, "Test", tb3_bmp1)
176 tb3.AddLabelTool(101, "Test", tb3_bmp1)
177 tb3.AddSeparator()
178 tb3.AddLabelTool(101, "Test", tb3_bmp1)
179 tb3.AddLabelTool(101, "Test", tb3_bmp1)
180 tb3.Realize()
181
182 tb4 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
183 wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_HORZ_TEXT)
184 tb4.SetToolBitmapSize(wx.Size(16,16))
185 tb4_bmp1 = wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))
186 tb4.AddLabelTool(101, "Item 1", tb4_bmp1)
187 tb4.AddLabelTool(101, "Item 2", tb4_bmp1)
188 tb4.AddLabelTool(101, "Item 3", tb4_bmp1)
189 tb4.AddLabelTool(101, "Item 4", tb4_bmp1)
190 tb4.AddSeparator()
191 tb4.AddLabelTool(101, "Item 5", tb4_bmp1)
192 tb4.AddLabelTool(101, "Item 6", tb4_bmp1)
193 tb4.AddLabelTool(101, "Item 7", tb4_bmp1)
194 tb4.AddLabelTool(101, "Item 8", tb4_bmp1)
195 tb4.Realize()
196
197 tb5 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
198 wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_VERTICAL)
199 tb5.SetToolBitmapSize(wx.Size(48, 48))
200 tb5.AddLabelTool(101, "Test", wx.ArtProvider_GetBitmap(wx.ART_ERROR))
201 tb5.AddSeparator()
202 tb5.AddLabelTool(102, "Test", wx.ArtProvider_GetBitmap(wx.ART_QUESTION))
203 tb5.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_INFORMATION))
204 tb5.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_WARNING))
205 tb5.AddLabelTool(103, "Test", wx.ArtProvider_GetBitmap(wx.ART_MISSING_IMAGE))
206 tb5.Realize()
207
208 # add a bunch of panes
209 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
210 Name("test1").Caption("Pane Caption").Top())
211
212 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
213 Name("test2").Caption("Client Size Reporter").
214 Bottom().Position(1))
215
216 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
217 Name("test3").Caption("Client Size Reporter").
218 Bottom())
219
220 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
221 Name("test4").Caption("Pane Caption").
222 Left())
223
224 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
225 Name("test5").Caption("Pane Caption").
226 Right())
227
228 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
229 Name("test6").Caption("Client Size Reporter").
230 Right().Row(1))
231
232 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
233 Name("test7").Caption("Client Size Reporter").
234 Left().Layer(1))
235
236 self._mgr.AddPane(self.CreateTreeCtrl(), wx.aui.PaneInfo().
237 Name("test8").Caption("Tree Pane").
238 Left().Layer(1).Position(1))
239
240 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
241 Name("test9").Caption("Min Size 200x100").
242 BestSize(wx.Size(200,100)).MinSize(wx.Size(200,100)).
243 Bottom().Layer(1))
244
245 self._mgr.AddPane(self.CreateTextCtrl(), wx.aui.PaneInfo().
246 Name("test10").Caption("Text Pane").
247 Bottom().Layer(1).Position(1))
248
249 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
250 Name("test11").Caption("Fixed Pane").
251 Bottom().Layer(1).Position(2).Fixed())
252
253 self._mgr.AddPane(SettingsPanel(self, self), wx.aui.PaneInfo().
254 Name("settings").Caption("Dock Manager Settings").
255 Dockable(False).Float().Hide())
256
257 # create some center panes
258
259 self._mgr.AddPane(self.CreateGrid(), wx.aui.PaneInfo().Name("grid_content").
260 CenterPane().Hide())
261
262 self._mgr.AddPane(self.CreateTreeCtrl(), wx.aui.PaneInfo().Name("tree_content").
263 CenterPane().Hide())
264
265 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().Name("sizereport_content").
266 CenterPane().Hide())
267
268 self._mgr.AddPane(self.CreateTextCtrl(), wx.aui.PaneInfo().Name("text_content").
269 CenterPane().Hide())
270
271 self._mgr.AddPane(self.CreateHTMLCtrl(), wx.aui.PaneInfo().Name("html_content").
272 CenterPane())
273
274 # add the toolbars to the manager
275
276 self._mgr.AddPane(tb1, wx.aui.PaneInfo().
277 Name("tb1").Caption("Big Toolbar").
278 ToolbarPane().Top().
279 LeftDockable(False).RightDockable(False))
280
281 self._mgr.AddPane(tb2, wx.aui.PaneInfo().
282 Name("tb2").Caption("Toolbar 2").
283 ToolbarPane().Top().Row(1).
284 LeftDockable(False).RightDockable(False))
285
286 self._mgr.AddPane(tb3, wx.aui.PaneInfo().
287 Name("tb3").Caption("Toolbar 3").
288 ToolbarPane().Top().Row(1).Position(1).
289 LeftDockable(False).RightDockable(False))
290
291 self._mgr.AddPane(tb4, wx.aui.PaneInfo().
292 Name("tb4").Caption("Sample Bookmark Toolbar").
293 ToolbarPane().Top().Row(2).
294 LeftDockable(False).RightDockable(False))
295
296 self._mgr.AddPane(tb5, wx.aui.PaneInfo().
297 Name("tbvert").Caption("Sample Vertical Toolbar").
298 ToolbarPane().Left().GripperTop().
299 TopDockable(False).BottomDockable(False))
300
301 self._mgr.AddPane(wx.Button(self, -1, "Test Button"),
302 wx.aui.PaneInfo().Name("tb5").
303 ToolbarPane().Top().Row(2).Position(1).
304 LeftDockable(False).RightDockable(False))
305
306 # make some default perspectives
307
308 self._mgr.GetPane("tbvert").Hide()
309
310 perspective_all = self._mgr.SavePerspective()
311
312 all_panes = self._mgr.GetAllPanes()
313
314 for ii in xrange(len(all_panes)):
315 if not all_panes[ii].IsToolbar():
316 all_panes[ii].Hide()
317
318 self._mgr.GetPane("tb1").Hide()
319 self._mgr.GetPane("tb5").Hide()
320 self._mgr.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
321 self._mgr.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
322 self._mgr.GetPane("html_content").Show()
323
324 perspective_default = self._mgr.SavePerspective()
325
326 for ii in xrange(len(all_panes)):
327 if not all_panes[ii].IsToolbar():
328 all_panes[ii].Hide()
329
330 self._mgr.GetPane("tb1").Hide()
331 self._mgr.GetPane("tb5").Hide()
332 self._mgr.GetPane("tbvert").Show()
333 self._mgr.GetPane("grid_content").Show()
334 self._mgr.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
335 self._mgr.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
336 self._mgr.GetPane("html_content").Show()
337
338 perspective_vert = self._mgr.SavePerspective()
339
340 self._perspectives.append(perspective_default)
341 self._perspectives.append(perspective_all)
342 self._perspectives.append(perspective_vert)
343
344 self._mgr.GetPane("tbvert").Hide()
345 self._mgr.GetPane("grid_content").Hide()
346
347 # "commit" all changes made to FrameManager
348 self._mgr.Update()
349
350 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
351 self.Bind(wx.EVT_SIZE, self.OnSize)
352 self.Bind(wx.EVT_CLOSE, self.OnClose)
353
354 # Show How To Use The Closing Panes Event
355 self.Bind(wx.aui.EVT_AUI_PANEBUTTON, self.OnPaneButton)
356
357 self.Bind(wx.EVT_MENU, self.OnCreateTree, id=ID_CreateTree)
358 self.Bind(wx.EVT_MENU, self.OnCreateGrid, id=ID_CreateGrid)
359 self.Bind(wx.EVT_MENU, self.OnCreateText, id=ID_CreateText)
360 self.Bind(wx.EVT_MENU, self.OnCreateHTML, id=ID_CreateHTML)
361 self.Bind(wx.EVT_MENU, self.OnCreateSizeReport, id=ID_CreateSizeReport)
362 self.Bind(wx.EVT_MENU, self.OnCreatePerspective, id=ID_CreatePerspective)
363 self.Bind(wx.EVT_MENU, self.OnCopyPerspective, id=ID_CopyPerspective)
364 self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_AllowFloating)
365 self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_TransparentHint)
366 self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_TransparentHintFade)
367 self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_TransparentDrag)
368 self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_AllowActivePane)
369 self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_NoGradient)
370 self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_VerticalGradient)
371 self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_HorizontalGradient)
372 self.Bind(wx.EVT_MENU, self.OnSettings, id=ID_Settings)
373 self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_GridContent)
374 self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_TreeContent)
375 self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_TextContent)
376 self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_SizeReportContent)
377 self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_HTMLContent)
378 self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)
379 self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_About)
380
381 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_AllowFloating)
382 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentHint)
383 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentHintFade)
384 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentDrag)
385 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_NoGradient)
386 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_VerticalGradient)
387 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_HorizontalGradient)
388
389 self.Bind(wx.EVT_MENU_RANGE, self.OnRestorePerspective, id=ID_FirstPerspective,
390 id2=ID_FirstPerspective+1000)
391
392
393 def OnPaneButton(self, event):
394
395 caption = event.GetPane().caption
396
397 if caption in ["Tree Pane", "Dock Manager Settings", "Fixed Pane"]:
398 msg = "Are You Sure You Want To Close This Pane?"
399 dlg = wx.MessageDialog(self, msg, "PyAUI Question",
400 wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
401
402 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
403 dlg.Destroy()
404 return
405
406 dlg.Destroy()
407
408 event.Skip()
409
410
411 def OnClose(self, event):
412
413 self._mgr.UnInit()
414 self.Destroy()
415
416 event.Skip()
417
418
419 def OnAbout(self, event):
420
421 msg = "wx.aui Demo\n" + \
422 "An advanced window management library for wxWidgets\n" + \
423 "(c) Copyright 2005-2006, Kirix Corporation"
424 dlg = wx.MessageDialog(self, msg, "About wx.aui Demo",
425 wx.OK | wx.ICON_INFORMATION)
426 dlg.ShowModal()
427 dlg.Destroy()
428
429
430 def GetDockArt(self):
431
432 return self._mgr.GetArtProvider()
433
434
435 def DoUpdate(self):
436
437 self._mgr.Update()
438
439
440 def OnEraseBackground(self, event):
441
442 event.Skip()
443
444
445 def OnSize(self, event):
446
447 event.Skip()
448
449
450 def OnSettings(self, event):
451
452 # show the settings pane, and float it
453 floating_pane = self._mgr.GetPane("settings").Float().Show()
454
455 if floating_pane.floating_pos == wx.DefaultPosition:
456 floating_pane.FloatingPosition(self.GetStartPosition())
457
458 self._mgr.Update()
459
460
461 def OnGradient(self, event):
462
463 gradient = 0
464
465 if event.GetId() == ID_NoGradient:
466 gradient = wx.aui.AUI_GRADIENT_NONE
467 elif event.GetId() == ID_VerticalGradient:
468 gradient = wx.aui.AUI_GRADIENT_VERTICAL
469 elif event.GetId() == ID_HorizontalGradient:
470 gradient = wx.aui.AUI_GRADIENT_HORIZONTAL
471
472 self._mgr.GetArtProvider().SetMetric(wx.aui.AUI_ART_GRADIENT_TYPE, gradient)
473 self._mgr.Update()
474
475
476 def OnManagerFlag(self, event):
477
478 flag = 0
479
480 if wx.Platform != "__WXMSW__":
481 if event.GetId() == ID_TransparentDrag or \
482 event.GetId() == ID_TransparentHint or \
483 event.GetId() == ID_TransparentHintFade:
484
485 wx.MessageBox("This option is presently only available on wxMSW")
486 return
487
488 if event.GetId() == ID_AllowFloating:
489 flag = wx.aui.AUI_MGR_ALLOW_FLOATING
490
491 elif event.GetId() == ID_TransparentDrag:
492 flag = wx.aui.AUI_MGR_TRANSPARENT_DRAG
493
494 elif event.GetId() == ID_TransparentHint:
495 flag = wx.aui.AUI_MGR_TRANSPARENT_HINT
496
497 elif event.GetId() == ID_TransparentHintFade:
498 flag = wx.aui.AUI_MGR_TRANSPARENT_HINT_FADE
499
500 elif event.GetId() == ID_AllowActivePane:
501 flag = wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE
502
503 self._mgr.SetFlags(self._mgr.GetFlags() ^ flag)
504
505
506 def OnUpdateUI(self, event):
507
508 flags = self._mgr.GetFlags()
509
510 if event.GetId() == ID_NoGradient:
511 event.Check(((self._mgr.GetArtProvider().GetMetric(wx.aui.AUI_ART_GRADIENT_TYPE) == wx.aui.AUI_GRADIENT_NONE) and \
512 [True] or [False])[0])
513
514 elif event.GetId() == ID_VerticalGradient:
515 event.Check(((self._mgr.GetArtProvider().GetMetric(wx.aui.AUI_ART_GRADIENT_TYPE) == wx.aui.AUI_GRADIENT_VERTICAL) and \
516 [True] or [False])[0])
517
518 elif event.GetId() == ID_HorizontalGradient:
519 event.Check(((self._mgr.GetArtProvider().GetMetric(wx.aui.AUI_ART_GRADIENT_TYPE) == wx.aui.AUI_GRADIENT_HORIZONTAL) and \
520 [True] or [False])[0])
521
522 elif event.GetId() == ID_AllowFloating:
523 event.Check(((flags & wx.aui.AUI_MGR_ALLOW_FLOATING) and [True] or [False])[0])
524
525 elif event.GetId() == ID_TransparentDrag:
526 event.Check(((flags & wx.aui.AUI_MGR_TRANSPARENT_DRAG) and [True] or [False])[0])
527
528 elif event.GetId() == ID_TransparentHint:
529 event.Check(((flags & wx.aui.AUI_MGR_TRANSPARENT_HINT) and [True] or [False])[0])
530
531 elif event.GetId() == ID_TransparentHintFade:
532 event.Check(((flags & wx.aui.AUI_MGR_TRANSPARENT_HINT_FADE) and [True] or [False])[0])
533
534
535 def OnCreatePerspective(self, event):
536
537 dlg = wx.TextEntryDialog(self, "Enter a name for the new perspective:", "AUI Test")
538
539 dlg.SetValue(("Perspective %d")%(len(self._perspectives)+1))
540 if dlg.ShowModal() != wx.ID_OK:
541 return
542
543 if len(self._perspectives) == 0:
544 self._perspectives_menu.AppendSeparator()
545
546 self._perspectives_menu.Append(ID_FirstPerspective + len(self._perspectives), dlg.GetValue())
547 self._perspectives.append(self._mgr.SavePerspective())
548
549
550 def OnCopyPerspective(self, event):
551
552 s = self._mgr.SavePerspective()
553
554 if wx.TheClipboard.Open():
555
556 wx.TheClipboard.SetData(wx.TextDataObject(s))
557 wx.TheClipboard.Close()
558
559 def OnRestorePerspective(self, event):
560
561 self._mgr.LoadPerspective(self._perspectives[event.GetId() - ID_FirstPerspective])
562
563
564 def GetStartPosition(self):
565
566 self.x = self.x + 20
567 x = self.x
568 pt = self.ClientToScreen(wx.Point(0, 0))
569
570 return wx.Point(pt.x + x, pt.y + x)
571
572
573 def OnCreateTree(self, event):
574
575 self._mgr.AddPane(self.CreateTreeCtrl(), wx.aui.PaneInfo().
576 Name("Test").Caption("Tree Control").
577 Float().FloatingPosition(self.GetStartPosition()).
578 FloatingSize(wx.Size(150, 300)))
579 self._mgr.Update()
580
581
582 def OnCreateGrid(self, event):
583
584 self._mgr.AddPane(self.CreateGrid(), wx.aui.PaneInfo().
585 Name("Test").Caption("Grid").
586 Float().FloatingPosition(self.GetStartPosition()).
587 FloatingSize(wx.Size(300, 200)))
588 self._mgr.Update()
589
590
591 def OnCreateHTML(self, event):
592
593 self._mgr.AddPane(self.CreateHTMLCtrl(), wx.aui.PaneInfo().
594 Name("Test").Caption("HTML Content").
595 Float().FloatingPosition(self.GetStartPosition()).
596 FloatingSize(wx.Size(300, 200)))
597 self._mgr.Update()
598
599
600 def OnCreateText(self, event):
601
602 self._mgr.AddPane(self.CreateTextCtrl(), wx.aui.PaneInfo().
603 Name("Test").Caption("Text Control").
604 Float().FloatingPosition(self.GetStartPosition()))
605 self._mgr.Update()
606
607
608 def OnCreateSizeReport(self, event):
609
610 self._mgr.AddPane(self.CreateSizeReportCtrl(), wx.aui.PaneInfo().
611 Name("Test").Caption("Client Size Reporter").
612 Float().FloatingPosition(self.GetStartPosition()))
613 self._mgr.Update()
614
615
616 def OnChangeContentPane(self, event):
617
618 self._mgr.GetPane("grid_content").Show(event.GetId() == ID_GridContent)
619 self._mgr.GetPane("text_content").Show(event.GetId() == ID_TextContent)
620 self._mgr.GetPane("tree_content").Show(event.GetId() == ID_TreeContent)
621 self._mgr.GetPane("sizereport_content").Show(event.GetId() == ID_SizeReportContent)
622 self._mgr.GetPane("html_content").Show(event.GetId() == ID_HTMLContent)
623 self._mgr.Update()
624
625
626 def CreateTextCtrl(self):
627
628 text = ("This is text box %d")%(self.n + 1)
629
630 return wx.TextCtrl(self,-1, text, wx.Point(0, 0), wx.Size(150, 90),
631 wx.NO_BORDER | wx.TE_MULTILINE)
632
633
634
635 def CreateGrid(self):
636
637 grid = wx.grid.Grid(self, -1, wx.Point(0, 0), wx.Size(150, 250),
638 wx.NO_BORDER | wx.WANTS_CHARS)
639
640 grid.CreateGrid(50, 20)
641
642 return grid
643
644
645 def CreateTreeCtrl(self):
646
647 tree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(160, 250),
648 wx.TR_DEFAULT_STYLE | wx.NO_BORDER)
649
650 root = tree.AddRoot("PyAUI Project")
651 items = []
652
653 imglist = wx.ImageList(16, 16, True, 2)
654 imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16)))
655 imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16,16)))
656 tree.AssignImageList(imglist)
657
658 items.append(tree.AppendItem(root, "Item 1", 0))
659 items.append(tree.AppendItem(root, "Item 2", 0))
660 items.append(tree.AppendItem(root, "Item 3", 0))
661 items.append(tree.AppendItem(root, "Item 4", 0))
662 items.append(tree.AppendItem(root, "Item 5", 0))
663
664 for ii in xrange(len(items)):
665
666 id = items[ii]
667 tree.AppendItem(id, "Subitem 1", 1)
668 tree.AppendItem(id, "Subitem 2", 1)
669 tree.AppendItem(id, "Subitem 3", 1)
670 tree.AppendItem(id, "Subitem 4", 1)
671 tree.AppendItem(id, "Subitem 5", 1)
672
673 tree.Expand(root)
674
675 return tree
676
677
678 def CreateSizeReportCtrl(self, width=80, height=80):
679
680 ctrl = SizeReportCtrl(self, -1, wx.DefaultPosition,
681 wx.Size(width, height), self._mgr)
682 return ctrl
683
684
685 def CreateHTMLCtrl(self):
686 ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
687 if "gtk2" in wx.PlatformInfo:
688 ctrl.SetStandardFonts()
689 ctrl.SetPage(self.GetIntroText())
690 return ctrl
691
692
693 def GetIntroText(self):
694 return overview
695
696
697 # -- wx.SizeReportCtrl --
698 # (a utility control that always reports it's client size)
699
700 class SizeReportCtrl(wx.PyControl):
701
702 def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
703 size=wx.DefaultSize, mgr=None):
704
705 wx.PyControl.__init__(self, parent, id, pos, size, wx.NO_BORDER)
706
707 self._mgr = mgr
708
709 self.Bind(wx.EVT_PAINT, self.OnPaint)
710 self.Bind(wx.EVT_SIZE, self.OnSize)
711 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
712
713
714 def OnPaint(self, event):
715
716 dc = wx.PaintDC(self)
717
718 size = self.GetClientSize()
719 s = ("Size: %d x %d")%(size.x, size.y)
720
721 dc.SetFont(wx.NORMAL_FONT)
722 w, height = dc.GetTextExtent(s)
723 height = height + 3
724 dc.SetBrush(wx.WHITE_BRUSH)
725 dc.SetPen(wx.WHITE_PEN)
726 dc.DrawRectangle(0, 0, size.x, size.y)
727 dc.SetPen(wx.LIGHT_GREY_PEN)
728 dc.DrawLine(0, 0, size.x, size.y)
729 dc.DrawLine(0, size.y, size.x, 0)
730 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2))
731
732 if self._mgr:
733
734 pi = self._mgr.GetPane(self)
735
736 s = ("Layer: %d")%pi.dock_layer
737 w, h = dc.GetTextExtent(s)
738 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*1))
739
740 s = ("Dock: %d Row: %d")%(pi.dock_direction, pi.dock_row)
741 w, h = dc.GetTextExtent(s)
742 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*2))
743
744 s = ("Position: %d")%pi.dock_pos
745 w, h = dc.GetTextExtent(s)
746 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*3))
747
748 s = ("Proportion: %d")%pi.dock_proportion
749 w, h = dc.GetTextExtent(s)
750 dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*4))
751
752
753 def OnEraseBackground(self, event):
754 # intentionally empty
755 pass
756
757
758 def OnSize(self, event):
759
760 self.Refresh()
761 event.Skip()
762
763
764 ID_PaneBorderSize = wx.ID_HIGHEST + 1
765 ID_SashSize = ID_PaneBorderSize + 1
766 ID_CaptionSize = ID_PaneBorderSize + 2
767 ID_BackgroundColor = ID_PaneBorderSize + 3
768 ID_SashColor = ID_PaneBorderSize + 4
769 ID_InactiveCaptionColor = ID_PaneBorderSize + 5
770 ID_InactiveCaptionGradientColor = ID_PaneBorderSize + 6
771 ID_InactiveCaptionTextColor = ID_PaneBorderSize + 7
772 ID_ActiveCaptionColor = ID_PaneBorderSize + 8
773 ID_ActiveCaptionGradientColor = ID_PaneBorderSize + 9
774 ID_ActiveCaptionTextColor = ID_PaneBorderSize + 10
775 ID_BorderColor = ID_PaneBorderSize + 11
776 ID_GripperColor = ID_PaneBorderSize + 12
777
778 class SettingsPanel(wx.Panel):
779
780 def __init__(self, parent, frame):
781
782 wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition,
783 wx.DefaultSize)
784
785 self._frame = frame
786
787 vert = wx.BoxSizer(wx.VERTICAL)
788
789 s1 = wx.BoxSizer(wx.HORIZONTAL)
790 self._border_size = wx.SpinCtrl(self, ID_PaneBorderSize, "", wx.DefaultPosition, wx.Size(50,20))
791 s1.Add((1, 1), 1, wx.EXPAND)
792 s1.Add(wx.StaticText(self, -1, "Pane Border Size:"))
793 s1.Add(self._border_size)
794 s1.Add((1, 1), 1, wx.EXPAND)
795 s1.SetItemMinSize(1, (180, 20))
796 #vert.Add(s1, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
797
798 s2 = wx.BoxSizer(wx.HORIZONTAL)
799 self._sash_size = wx.SpinCtrl(self, ID_SashSize, "", wx.DefaultPosition, wx.Size(50,20))
800 s2.Add((1, 1), 1, wx.EXPAND)
801 s2.Add(wx.StaticText(self, -1, "Sash Size:"))
802 s2.Add(self._sash_size)
803 s2.Add((1, 1), 1, wx.EXPAND)
804 s2.SetItemMinSize(1, (180, 20))
805 #vert.Add(s2, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
806
807 s3 = wx.BoxSizer(wx.HORIZONTAL)
808 self._caption_size = wx.SpinCtrl(self, ID_CaptionSize, "", wx.DefaultPosition, wx.Size(50,20))
809 s3.Add((1, 1), 1, wx.EXPAND)
810 s3.Add(wx.StaticText(self, -1, "Caption Size:"))
811 s3.Add(self._caption_size)
812 s3.Add((1, 1), 1, wx.EXPAND)
813 s3.SetItemMinSize(1, (180, 20))
814 #vert.Add(s3, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
815
816 #vert.Add(1, 1, 1, wx.EXPAND)
817
818 b = self.CreateColorBitmap(wx.BLACK)
819
820 s4 = wx.BoxSizer(wx.HORIZONTAL)
821 self._background_color = wx.BitmapButton(self, ID_BackgroundColor, b, wx.DefaultPosition, wx.Size(50,25))
822 s4.Add((1, 1), 1, wx.EXPAND)
823 s4.Add(wx.StaticText(self, -1, "Background Color:"))
824 s4.Add(self._background_color)
825 s4.Add((1, 1), 1, wx.EXPAND)
826 s4.SetItemMinSize(1, (180, 20))
827
828 s5 = wx.BoxSizer(wx.HORIZONTAL)
829 self._sash_color = wx.BitmapButton(self, ID_SashColor, b, wx.DefaultPosition, wx.Size(50,25))
830 s5.Add((1, 1), 1, wx.EXPAND)
831 s5.Add(wx.StaticText(self, -1, "Sash Color:"))
832 s5.Add(self._sash_color)
833 s5.Add((1, 1), 1, wx.EXPAND)
834 s5.SetItemMinSize(1, (180, 20))
835
836 s6 = wx.BoxSizer(wx.HORIZONTAL)
837 self._inactive_caption_color = wx.BitmapButton(self, ID_InactiveCaptionColor, b,
838 wx.DefaultPosition, wx.Size(50,25))
839 s6.Add((1, 1), 1, wx.EXPAND)
840 s6.Add(wx.StaticText(self, -1, "Normal Caption:"))
841 s6.Add(self._inactive_caption_color)
842 s6.Add((1, 1), 1, wx.EXPAND)
843 s6.SetItemMinSize(1, (180, 20))
844
845 s7 = wx.BoxSizer(wx.HORIZONTAL)
846 self._inactive_caption_gradient_color = wx.BitmapButton(self, ID_InactiveCaptionGradientColor,
847 b, wx.DefaultPosition, wx.Size(50,25))
848 s7.Add((1, 1), 1, wx.EXPAND)
849 s7.Add(wx.StaticText(self, -1, "Normal Caption Gradient:"))
850 s7.Add(self._inactive_caption_gradient_color)
851 s7.Add((1, 1), 1, wx.EXPAND)
852 s7.SetItemMinSize(1, (180, 20))
853
854 s8 = wx.BoxSizer(wx.HORIZONTAL)
855 self._inactive_caption_text_color = wx.BitmapButton(self, ID_InactiveCaptionTextColor, b,
856 wx.DefaultPosition, wx.Size(50,25))
857 s8.Add((1, 1), 1, wx.EXPAND)
858 s8.Add(wx.StaticText(self, -1, "Normal Caption Text:"))
859 s8.Add(self._inactive_caption_text_color)
860 s8.Add((1, 1), 1, wx.EXPAND)
861 s8.SetItemMinSize(1, (180, 20))
862
863 s9 = wx.BoxSizer(wx.HORIZONTAL)
864 self._active_caption_color = wx.BitmapButton(self, ID_ActiveCaptionColor, b,
865 wx.DefaultPosition, wx.Size(50,25))
866 s9.Add((1, 1), 1, wx.EXPAND)
867 s9.Add(wx.StaticText(self, -1, "Active Caption:"))
868 s9.Add(self._active_caption_color)
869 s9.Add((1, 1), 1, wx.EXPAND)
870 s9.SetItemMinSize(1, (180, 20))
871
872 s10 = wx.BoxSizer(wx.HORIZONTAL)
873 self._active_caption_gradient_color = wx.BitmapButton(self, ID_ActiveCaptionGradientColor,
874 b, wx.DefaultPosition, wx.Size(50,25))
875 s10.Add((1, 1), 1, wx.EXPAND)
876 s10.Add(wx.StaticText(self, -1, "Active Caption Gradient:"))
877 s10.Add(self._active_caption_gradient_color)
878 s10.Add((1, 1), 1, wx.EXPAND)
879 s10.SetItemMinSize(1, (180, 20))
880
881 s11 = wx.BoxSizer(wx.HORIZONTAL)
882 self._active_caption_text_color = wx.BitmapButton(self, ID_ActiveCaptionTextColor,
883 b, wx.DefaultPosition, wx.Size(50,25))
884 s11.Add((1, 1), 1, wx.EXPAND)
885 s11.Add(wx.StaticText(self, -1, "Active Caption Text:"))
886 s11.Add(self._active_caption_text_color)
887 s11.Add((1, 1), 1, wx.EXPAND)
888 s11.SetItemMinSize(1, (180, 20))
889
890 s12 = wx.BoxSizer(wx.HORIZONTAL)
891 self._border_color = wx.BitmapButton(self, ID_BorderColor, b, wx.DefaultPosition,
892 wx.Size(50,25))
893 s12.Add((1, 1), 1, wx.EXPAND)
894 s12.Add(wx.StaticText(self, -1, "Border Color:"))
895 s12.Add(self._border_color)
896 s12.Add((1, 1), 1, wx.EXPAND)
897 s12.SetItemMinSize(1, (180, 20))
898
899 s13 = wx.BoxSizer(wx.HORIZONTAL)
900 self._gripper_color = wx.BitmapButton(self, ID_GripperColor, b, wx.DefaultPosition,
901 wx.Size(50,25))
902 s13.Add((1, 1), 1, wx.EXPAND)
903 s13.Add(wx.StaticText(self, -1, "Gripper Color:"))
904 s13.Add(self._gripper_color)
905 s13.Add((1, 1), 1, wx.EXPAND)
906 s13.SetItemMinSize(1, (180, 20))
907
908 grid_sizer = wx.GridSizer(0, 2)
909 grid_sizer.SetHGap(5)
910 grid_sizer.Add(s1)
911 grid_sizer.Add(s4)
912 grid_sizer.Add(s2)
913 grid_sizer.Add(s5)
914 grid_sizer.Add(s3)
915 grid_sizer.Add(s13)
916 grid_sizer.Add((1, 1))
917 grid_sizer.Add(s12)
918 grid_sizer.Add(s6)
919 grid_sizer.Add(s9)
920 grid_sizer.Add(s7)
921 grid_sizer.Add(s10)
922 grid_sizer.Add(s8)
923 grid_sizer.Add(s11)
924
925 cont_sizer = wx.BoxSizer(wx.VERTICAL)
926 cont_sizer.Add(grid_sizer, 1, wx.EXPAND | wx.ALL, 5)
927 self.SetSizer(cont_sizer)
928 self.GetSizer().SetSizeHints(self)
929
930 self._border_size.SetValue(frame.GetDockArt().GetMetric(wx.aui.AUI_ART_PANE_BORDER_SIZE))
931 self._sash_size.SetValue(frame.GetDockArt().GetMetric(wx.aui.AUI_ART_SASH_SIZE))
932 self._caption_size.SetValue(frame.GetDockArt().GetMetric(wx.aui.AUI_ART_CAPTION_SIZE))
933
934 self.UpdateColors()
935
936 self.Bind(wx.EVT_SPINCTRL, self.OnPaneBorderSize, id=ID_PaneBorderSize)
937 self.Bind(wx.EVT_SPINCTRL, self.OnSashSize, id=ID_SashSize)
938 self.Bind(wx.EVT_SPINCTRL, self.OnCaptionSize, id=ID_CaptionSize)
939 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_BackgroundColor)
940 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_SashColor)
941 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_InactiveCaptionColor)
942 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_InactiveCaptionGradientColor)
943 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_InactiveCaptionTextColor)
944 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_ActiveCaptionColor)
945 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_ActiveCaptionGradientColor)
946 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_ActiveCaptionTextColor)
947 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_BorderColor)
948 self.Bind(wx.EVT_BUTTON, self.OnSetColor, id=ID_GripperColor)
949
950
951 def CreateColorBitmap(self, c):
952 image = wx.EmptyImage(25, 14)
953
954 for x in xrange(25):
955 for y in xrange(14):
956 pixcol = c
957 if x == 0 or x == 24 or y == 0 or y == 13:
958 pixcol = wx.BLACK
959
960 image.SetRGB(x, y, pixcol.Red(), pixcol.Green(), pixcol.Blue())
961
962 return image.ConvertToBitmap()
963
964
965 def UpdateColors(self):
966
967 bk = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_BACKGROUND_COLOUR)
968 self._background_color.SetBitmapLabel(self.CreateColorBitmap(bk))
969
970 cap = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_INACTIVE_CAPTION_COLOUR)
971 self._inactive_caption_color.SetBitmapLabel(self.CreateColorBitmap(cap))
972
973 capgrad = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR)
974 self._inactive_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmap(capgrad))
975
976 captxt = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_INACTIVE_CAPTION_TEXT_COLOUR)
977 self._inactive_caption_text_color.SetBitmapLabel(self.CreateColorBitmap(captxt))
978
979 acap = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_ACTIVE_CAPTION_COLOUR)
980 self._active_caption_color.SetBitmapLabel(self.CreateColorBitmap(acap))
981
982 acapgrad = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR)
983 self._active_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmap(acapgrad))
984
985 acaptxt = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_ACTIVE_CAPTION_TEXT_COLOUR)
986 self._active_caption_text_color.SetBitmapLabel(self.CreateColorBitmap(acaptxt))
987
988 sash = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_SASH_COLOUR)
989 self._sash_color.SetBitmapLabel(self.CreateColorBitmap(sash))
990
991 border = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_BORDER_COLOUR)
992 self._border_color.SetBitmapLabel(self.CreateColorBitmap(border))
993
994 gripper = self._frame.GetDockArt().GetColour(wx.aui.AUI_ART_GRIPPER_COLOUR)
995 self._gripper_color.SetBitmapLabel(self.CreateColorBitmap(gripper))
996
997
998 def OnPaneBorderSize(self, event):
999
1000 self._frame.GetDockArt().SetMetric(wx.aui.AUI_ART_PANE_BORDER_SIZE,
1001 event.GetInt())
1002 self._frame.DoUpdate()
1003
1004
1005 def OnSashSize(self, event):
1006
1007 self._frame.GetDockArt().SetMetric(wx.aui.AUI_ART_SASH_SIZE,
1008 event.GetInt())
1009 self._frame.DoUpdate()
1010
1011
1012 def OnCaptionSize(self, event):
1013
1014 self._frame.GetDockArt().SetMetric(wx.aui.AUI_ART_CAPTION_SIZE,
1015 event.GetInt())
1016 self._frame.DoUpdate()
1017
1018
1019 def OnSetColor(self, event):
1020
1021 dlg = wx.ColourDialog(self._frame)
1022
1023 dlg.SetTitle("Color Picker")
1024
1025 if dlg.ShowModal() != wx.ID_OK:
1026 return
1027
1028 var = 0
1029 if event.GetId() == ID_BackgroundColor:
1030 var = wx.aui.AUI_ART_BACKGROUND_COLOUR
1031 elif event.GetId() == ID_SashColor:
1032 var = wx.aui.AUI_ART_SASH_COLOUR
1033 elif event.GetId() == ID_InactiveCaptionColor:
1034 var = wx.aui.AUI_ART_INACTIVE_CAPTION_COLOUR
1035 elif event.GetId() == ID_InactiveCaptionGradientColor:
1036 var = wx.aui.AUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
1037 elif event.GetId() == ID_InactiveCaptionTextColor:
1038 var = wx.aui.AUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
1039 elif event.GetId() == ID_ActiveCaptionColor:
1040 var = wx.aui.AUI_ART_ACTIVE_CAPTION_COLOUR
1041 elif event.GetId() == ID_ActiveCaptionGradientColor:
1042 var = wx.aui.AUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
1043 elif event.GetId() == ID_ActiveCaptionTextColor:
1044 var = wx.aui.AUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
1045 elif event.GetId() == ID_BorderColor:
1046 var = wx.aui.AUI_ART_BORDER_COLOUR
1047 elif event.GetId() == ID_GripperColor:
1048 var = wx.aui.AUI_ART_GRIPPER_COLOUR
1049 else:
1050 return
1051
1052 self._frame.GetDockArt().SetColor(var, dlg.GetColourData().GetColour())
1053 self._frame.DoUpdate()
1054 self.UpdateColors()
1055
1056
1057
1058 #----------------------------------------------------------------------
1059
1060 class TestPanel(wx.Panel):
1061 def __init__(self, parent, log):
1062 self.log = log
1063 wx.Panel.__init__(self, parent, -1)
1064 b = wx.Button(self, -1, "Show the wx.aui Demo Frame", (50,50))
1065 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
1066
1067 def OnButton(self, evt):
1068 frame = PyAUIFrame(self, wx.ID_ANY, "wx.aui wxPython Demo", size=(750, 590))
1069 frame.Show()
1070
1071 #----------------------------------------------------------------------
1072
1073 def runTest(frame, nb, log):
1074 win = TestPanel(nb, log)
1075 return win
1076
1077 #----------------------------------------------------------------------
1078
1079
1080
1081 overview = """\
1082 <html><body>
1083 <h3>wx.aui, the Advanced User Interface module</h3>
1084
1085 <br/><b>Overview</b><br/>
1086
1087 <p>wx.aui is an Advanced User Interface library for the wxWidgets toolkit
1088 that allows developers to create high-quality, cross-platform user
1089 interfaces quickly and easily.</p>
1090
1091 <p><b>Features</b></p>
1092
1093 <p>With wx.aui developers can create application frameworks with:</p>
1094
1095 <ul>
1096 <li>Native, dockable floating frames</li>
1097 <li>Perspective saving and loading</li>
1098 <li>Native toolbars incorporating real-time, &quot;spring-loaded&quot; dragging</li>
1099 <li>Customizable floating/docking behavior</li>
1100 <li>Completely customizable look-and-feel</li>
1101 <li>Optional transparent window effects (while dragging or docking)</li>
1102 </ul>
1103
1104 </body></html>
1105 """
1106
1107
1108
1109
1110 if __name__ == '__main__':
1111 import sys,os
1112 import run
1113 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1114