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