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