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