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