2 # Purpose: XRC editor, XML_tree class
3 # Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
7 from xxx
import * # xxx imports globals and params
11 # Constant to define standart window name
12 STD_NAME
= '_XRCED_T_W'
18 def __init__(self
, name
):
21 def write(self
, data
):
23 encoding
= g
.currentEncoding
25 encoding
= wxGetDefaultPyEncoding()
27 self
.buffer += data
.encode(encoding
)
28 except UnicodeEncodeError:
29 self
.buffer += data
.encode(encoding
, 'xmlcharrefreplace')
32 wxMemoryFSHandler_AddFile(self
.name
, self
.buffer)
34 ################################################################################
36 # Redefine writing to include encoding
37 class MyDocument(minidom
.Document
):
39 minidom
.Document
.__init
__(self
)
41 def writexml(self
, writer
, indent
="", addindent
="", newl
="", encoding
=""):
42 if encoding
: encdstr
= 'encoding="%s"' % encoding
44 writer
.write('<?xml version="1.0" %s?>\n' % encdstr
)
45 for node
in self
.childNodes
:
46 node
.writexml(writer
, indent
, addindent
, newl
)
48 ################################################################################
50 # Ids for menu commands
60 STATIC_TEXT
= wxNewId()
64 BITMAP_BUTTON
= wxNewId()
65 RADIO_BUTTON
= wxNewId()
66 SPIN_BUTTON
= wxNewId()
67 TOGGLE_BUTTON
= wxNewId()
69 STATIC_BOX
= wxNewId()
75 STATIC_LINE
= wxNewId()
76 STATIC_BITMAP
= wxNewId()
80 SCROLL_BAR
= wxNewId()
83 CHECK_LIST
= wxNewId()
85 SPLITTER_WINDOW
= wxNewId()
86 SCROLLED_WINDOW
= wxNewId()
87 HTML_WINDOW
= wxNewId()
88 CALENDAR_CTRL
= wxNewId()
89 GENERIC_DIR_CTRL
= wxNewId()
93 WIZARD_PAGE
= wxNewId()
94 WIZARD_PAGE_SIMPLE
= wxNewId()
95 STATUS_BAR
= wxNewId()
98 STATIC_BOX_SIZER
= wxNewId()
99 GRID_SIZER
= wxNewId()
100 FLEX_GRID_SIZER
= wxNewId()
101 GRID_BAG_SIZER
= wxNewId()
102 STD_DIALOG_BUTTON_SIZER
= wxNewId()
108 MENU_ITEM
= wxNewId()
109 SEPARATOR
= wxNewId()
111 OK_BUTTON
= wxNewId()
112 YES_BUTTON
= wxNewId()
113 SAVE_BUTTON
= wxNewId()
114 APPLY_BUTTON
= wxNewId()
115 NO_BUTTON
= wxNewId()
116 CANCEL_BUTTON
= wxNewId()
117 HELP_BUTTON
= wxNewId()
118 CONTEXT_HELP_BUTTON
= wxNewId()
127 ID_EXPAND
= wxNewId()
128 ID_COLLAPSE
= wxNewId()
129 ID_PASTE_SIBLING
= wxNewId()
130 ID_TOOL_PASTE
= wxNewId()
131 ID_SUBCLASS
= wxNewId()
133 def __init__(self
, parent
):
134 self
.ID_DELETE
= parent
.ID_DELETE
135 EVT_MENU_RANGE(parent
, ID_NEW
.PANEL
, ID_NEW
.LAST
, parent
.OnCreate
)
136 EVT_MENU_RANGE(parent
, 1000 + ID_NEW
.PANEL
, 1000 + ID_NEW
.LAST
, parent
.OnReplace
)
137 EVT_MENU(parent
, self
.ID_COLLAPSE
, parent
.OnCollapse
)
138 EVT_MENU(parent
, self
.ID_EXPAND
, parent
.OnExpand
)
139 EVT_MENU(parent
, self
.ID_PASTE_SIBLING
, parent
.OnPaste
)
140 EVT_MENU(parent
, self
.ID_SUBCLASS
, parent
.OnSubclass
)
141 # We connect to tree, but process in frame
142 EVT_MENU_HIGHLIGHT_ALL(g
.tree
, parent
.OnPullDownHighlight
)
144 # Mapping from IDs to element names
146 ID_NEW
.PANEL
: 'wxPanel',
147 ID_NEW
.DIALOG
: 'wxDialog',
148 ID_NEW
.FRAME
: 'wxFrame',
149 ID_NEW
.WIZARD
: 'wxWizard',
150 ID_NEW
.WIZARD_PAGE
: 'wxWizardPage',
151 ID_NEW
.WIZARD_PAGE_SIMPLE
: 'wxWizardPageSimple',
152 ID_NEW
.TOOL_BAR
: 'wxToolBar',
154 ID_NEW
.MENU_BAR
: 'wxMenuBar',
155 ID_NEW
.MENU
: 'wxMenu',
156 ID_NEW
.MENU_ITEM
: 'wxMenuItem',
157 ID_NEW
.SEPARATOR
: 'separator',
159 ID_NEW
.STATIC_TEXT
: 'wxStaticText',
160 ID_NEW
.TEXT_CTRL
: 'wxTextCtrl',
162 ID_NEW
.BUTTON
: 'wxButton',
163 ID_NEW
.BITMAP_BUTTON
: 'wxBitmapButton',
164 ID_NEW
.RADIO_BUTTON
: 'wxRadioButton',
165 ID_NEW
.SPIN_BUTTON
: 'wxSpinButton',
166 ID_NEW
.TOGGLE_BUTTON
: 'wxToggleButton',
168 ID_NEW
.STATIC_BOX
: 'wxStaticBox',
169 ID_NEW
.CHECK_BOX
: 'wxCheckBox',
170 ID_NEW
.RADIO_BOX
: 'wxRadioBox',
171 ID_NEW
.COMBO_BOX
: 'wxComboBox',
172 ID_NEW
.LIST_BOX
: 'wxListBox',
174 ID_NEW
.STATIC_LINE
: 'wxStaticLine',
175 ID_NEW
.STATIC_BITMAP
: 'wxStaticBitmap',
176 ID_NEW
.CHOICE
: 'wxChoice',
177 ID_NEW
.SLIDER
: 'wxSlider',
178 ID_NEW
.GAUGE
: 'wxGauge',
179 ID_NEW
.SCROLL_BAR
: 'wxScrollBar',
180 ID_NEW
.TREE_CTRL
: 'wxTreeCtrl',
181 ID_NEW
.LIST_CTRL
: 'wxListCtrl',
182 ID_NEW
.CHECK_LIST
: 'wxCheckListBox',
183 ID_NEW
.NOTEBOOK
: 'wxNotebook',
184 ID_NEW
.SPLITTER_WINDOW
: 'wxSplitterWindow',
185 ID_NEW
.SCROLLED_WINDOW
: 'wxScrolledWindow',
186 ID_NEW
.HTML_WINDOW
: 'wxHtmlWindow',
187 ID_NEW
.CALENDAR_CTRL
: 'wxCalendarCtrl',
188 ID_NEW
.GENERIC_DIR_CTRL
: 'wxGenericDirCtrl',
189 ID_NEW
.SPIN_CTRL
: 'wxSpinCtrl',
191 ID_NEW
.BOX_SIZER
: 'wxBoxSizer',
192 ID_NEW
.STATIC_BOX_SIZER
: 'wxStaticBoxSizer',
193 ID_NEW
.GRID_SIZER
: 'wxGridSizer',
194 ID_NEW
.FLEX_GRID_SIZER
: 'wxFlexGridSizer',
195 ID_NEW
.GRID_BAG_SIZER
: 'wxGridBagSizer',
196 ID_NEW
.STD_DIALOG_BUTTON_SIZER
: 'wxStdDialogButtonSizer',
197 ID_NEW
.SPACER
: 'spacer',
198 ID_NEW
.UNKNOWN
: 'unknown',
200 ID_NEW
.OK_BUTTON
: 'wxButton',
201 ID_NEW
.YES_BUTTON
: 'wxButton',
202 ID_NEW
.SAVE_BUTTON
: 'wxButton',
203 ID_NEW
.APPLY_BUTTON
: 'wxButton',
204 ID_NEW
.NO_BUTTON
: 'wxButton',
205 ID_NEW
.CANCEL_BUTTON
: 'wxButton',
206 ID_NEW
.HELP_BUTTON
: 'wxButton',
207 ID_NEW
.CONTEXT_HELP_BUTTON
: 'wxButton',
210 (ID_NEW
.PANEL
, 'Panel', 'Create panel'),
211 (ID_NEW
.DIALOG
, 'Dialog', 'Create dialog'),
212 (ID_NEW
.FRAME
, 'Frame', 'Create frame'),
213 (ID_NEW
.WIZARD
, 'Wizard', 'Create wizard'),
215 (ID_NEW
.TOOL_BAR
, 'ToolBar', 'Create toolbar'),
216 (ID_NEW
.MENU_BAR
, 'MenuBar', 'Create menubar'),
217 (ID_NEW
.MENU
, 'Menu', 'Create menu')
220 (ID_NEW
.PANEL
, 'Panel', 'Create panel'),
221 (ID_NEW
.NOTEBOOK
, 'Notebook', 'Create notebook control'),
222 (ID_NEW
.SPLITTER_WINDOW
, 'SplitterWindow', 'Create splitter window'),
223 (ID_NEW
.TOOL_BAR
, 'ToolBar', 'Create toolbar'),
224 # (ID_NEW.WIZARD_PAGE, 'WizardPage', 'Create wizard page'),
225 (ID_NEW
.WIZARD_PAGE_SIMPLE
, 'WizardPageSimple', 'Create simple wizard page'),
228 (ID_NEW
.BOX_SIZER
, 'BoxSizer', 'Create box sizer'),
229 (ID_NEW
.STATIC_BOX_SIZER
, 'StaticBoxSizer',
230 'Create static box sizer'),
231 (ID_NEW
.GRID_SIZER
, 'GridSizer', 'Create grid sizer'),
232 (ID_NEW
.FLEX_GRID_SIZER
, 'FlexGridSizer',
233 'Create flexgrid sizer'),
234 (ID_NEW
.GRID_BAG_SIZER
, 'GridBagSizer',
235 'Create gridbag sizer'),
236 # (ID_NEW.STD_DIALOG_BUTTON_SIZER, 'StdDialogButtonSizer',
237 # 'Create standard button sizer'),
238 (ID_NEW
.SPACER
, 'Spacer', 'Create spacer'),
241 ['control', 'Various controls',
242 (ID_NEW
.STATIC_TEXT
, 'Label', 'Create label'),
243 (ID_NEW
.STATIC_BITMAP
, 'Bitmap', 'Create bitmap'),
244 (ID_NEW
.STATIC_LINE
, 'Line', 'Create line'),
245 (ID_NEW
.TEXT_CTRL
, 'TextBox', 'Create text box'),
246 (ID_NEW
.CHOICE
, 'Choice', 'Create choice'),
247 (ID_NEW
.SLIDER
, 'Slider', 'Create slider'),
248 (ID_NEW
.GAUGE
, 'Gauge', 'Create gauge'),
249 (ID_NEW
.SPIN_CTRL
, 'SpinCtrl', 'Create spin'),
250 (ID_NEW
.SCROLL_BAR
, 'ScrollBar', 'Create scroll bar'),
251 (ID_NEW
.TREE_CTRL
, 'TreeCtrl', 'Create tree'),
252 (ID_NEW
.LIST_CTRL
, 'ListCtrl', 'Create list'),
253 (ID_NEW
.CHECK_LIST
, 'CheckList', 'Create check list'),
254 (ID_NEW
.SCROLLED_WINDOW
, 'ScrolledWindow', 'Create scrolled window'),
255 (ID_NEW
.HTML_WINDOW
, 'HtmlWindow', 'Create HTML window'),
256 (ID_NEW
.CALENDAR_CTRL
, 'CalendarCtrl', 'Create calendar control'),
257 (ID_NEW
.GENERIC_DIR_CTRL
, 'GenericDirCtrl', 'Create generic dir control'),
258 (ID_NEW
.UNKNOWN
, 'Unknown', 'Create custom control placeholder'),
260 ['button', 'Buttons',
261 (ID_NEW
.BUTTON
, 'Button', 'Create button'),
262 (ID_NEW
.BITMAP_BUTTON
, 'BitmapButton', 'Create bitmap button'),
263 (ID_NEW
.RADIO_BUTTON
, 'RadioButton', 'Create radio button'),
264 (ID_NEW
.SPIN_BUTTON
, 'SpinButton', 'Create spin button'),
265 (ID_NEW
.TOGGLE_BUTTON
, 'ToggleButton', 'Create toggle button'),
268 (ID_NEW
.STATIC_BOX
, 'StaticBox', 'Create static box'),
269 (ID_NEW
.CHECK_BOX
, 'CheckBox', 'Create check box'),
270 (ID_NEW
.RADIO_BOX
, 'RadioBox', 'Create radio box'),
271 (ID_NEW
.COMBO_BOX
, 'ComboBox', 'Create combo box'),
272 (ID_NEW
.LIST_BOX
, 'ListBox', 'Create list box'),
274 ['container', 'Containers',
275 (ID_NEW
.PANEL
, 'Panel', 'Create panel'),
276 (ID_NEW
.NOTEBOOK
, 'Notebook', 'Create notebook control'),
277 (ID_NEW
.SPLITTER_WINDOW
, 'SplitterWindow', 'Create splitter window'),
278 (ID_NEW
.TOOL_BAR
, 'ToolBar', 'Create toolbar'),
279 # (ID_NEW.WIZARD_PAGE, 'Wizard Page', 'Create wizard page'),
280 (ID_NEW
.WIZARD_PAGE_SIMPLE
, 'WizardPageSimple', 'Create simple wizard page'),
283 (ID_NEW
.BOX_SIZER
, 'BoxSizer', 'Create box sizer'),
284 (ID_NEW
.STATIC_BOX_SIZER
, 'StaticBoxSizer',
285 'Create static box sizer'),
286 (ID_NEW
.GRID_SIZER
, 'GridSizer', 'Create grid sizer'),
287 (ID_NEW
.FLEX_GRID_SIZER
, 'FlexGridSizer',
288 'Create flexgrid sizer'),
289 (ID_NEW
.GRID_BAG_SIZER
, 'GridBagSizer',
290 'Create gridbag sizer'),
291 (ID_NEW
.SPACER
, 'Spacer', 'Create spacer'),
292 (ID_NEW
.STD_DIALOG_BUTTON_SIZER
, 'StdDialogButtonSizer',
293 'Create standard button sizer'),
296 self
.menuControls
= [
297 (ID_NEW
.MENU
, 'Menu', 'Create menu'),
298 (ID_NEW
.MENU_ITEM
, 'MenuItem', 'Create menu item'),
299 (ID_NEW
.SEPARATOR
, 'Separator', 'Create separator'),
301 self
.toolBarControls
= [
302 (ID_NEW
.TOOL
, 'Tool', 'Create tool'),
303 (ID_NEW
.SEPARATOR
, 'Separator', 'Create separator'),
304 ['control', 'Various controls',
305 (ID_NEW
.STATIC_TEXT
, 'Label', 'Create label'),
306 (ID_NEW
.STATIC_BITMAP
, 'Bitmap', 'Create bitmap'),
307 (ID_NEW
.STATIC_LINE
, 'Line', 'Create line'),
308 (ID_NEW
.TEXT_CTRL
, 'TextBox', 'Create text box'),
309 (ID_NEW
.CHOICE
, 'Choice', 'Create choice'),
310 (ID_NEW
.SLIDER
, 'Slider', 'Create slider'),
311 (ID_NEW
.GAUGE
, 'Gauge', 'Create gauge'),
312 (ID_NEW
.SCROLL_BAR
, 'ScrollBar', 'Create scroll bar'),
313 (ID_NEW
.LIST_CTRL
, 'ListCtrl', 'Create list control'),
314 (ID_NEW
.CHECK_LIST
, 'CheckList', 'Create check list'),
316 ['button', 'Buttons',
317 (ID_NEW
.BUTTON
, 'Button', 'Create button'),
318 (ID_NEW
.BITMAP_BUTTON
, 'BitmapButton', 'Create bitmap button'),
319 (ID_NEW
.RADIO_BUTTON
, 'RadioButton', 'Create radio button'),
320 (ID_NEW
.SPIN_BUTTON
, 'SpinButton', 'Create spin button'),
323 (ID_NEW
.STATIC_BOX
, 'StaticBox', 'Create static box'),
324 (ID_NEW
.CHECK_BOX
, 'CheckBox', 'Create check box'),
325 (ID_NEW
.RADIO_BOX
, 'RadioBox', 'Create radio box'),
326 (ID_NEW
.COMBO_BOX
, 'ComboBox', 'Create combo box'),
327 (ID_NEW
.LIST_BOX
, 'ListBox', 'Create list box'),
331 (ID_NEW
.OK_BUTTON
, 'OK Button', 'Create standard button'),
332 (ID_NEW
.YES_BUTTON
, 'YES Button', 'Create standard button'),
333 (ID_NEW
.SAVE_BUTTON
, 'SAVE Button', 'Create standard button'),
334 (ID_NEW
.APPLY_BUTTON
, 'APPLY Button', 'Create standard button'),
335 (ID_NEW
.NO_BUTTON
, 'NO Button', 'Create standard button'),
336 (ID_NEW
.CANCEL_BUTTON
, 'CANCEL Button', 'Create standard button'),
337 (ID_NEW
.HELP_BUTTON
, 'HELP Button', 'Create standard button'),
338 (ID_NEW
.CONTEXT_HELP_BUTTON
, 'CONTEXT HELP Button', 'Create standard button'),
340 self
.stdButtonIDs
= {
341 ID_NEW
.OK_BUTTON
: ('wxID_OK', '&Ok'),
342 ID_NEW
.YES_BUTTON
: ('wxID_YES', '&Yes'),
343 ID_NEW
.SAVE_BUTTON
: ('wxID_SAVE', '&Save'),
344 ID_NEW
.APPLY_BUTTON
: ('wxID_APPLY', '&Apply'),
345 ID_NEW
.NO_BUTTON
: ('wxID_NO', '&No'),
346 ID_NEW
.CANCEL_BUTTON
: ('wxID_CANCEL', '&Cancel'),
347 ID_NEW
.HELP_BUTTON
: ('wxID_HELP', '&Help'),
348 ID_NEW
.CONTEXT_HELP_BUTTON
: ('wxID_CONTEXT_HELP', '&Help'),
353 ################################################################################
355 # Set menu to list items.
356 # Each menu command is a tuple (id, label, help)
357 # submenus are lists [id, label, help, submenu]
358 # and separators are any other type. Shift is for making
359 # alternative sets of IDs. (+1000).
360 def SetMenu(m
, list, shift
=False):
362 if type(l
) == types
.TupleType
:
364 if shift
: l
= (1000 + l
[0],) + l
[1:]
366 elif type(l
) == types
.ListType
:
368 SetMenu(subMenu
, l
[2:])
369 m
.AppendMenu(wxNewId(), l
[0], subMenu
, l
[1])
373 ################################################################################
376 def __init__(self
, pos
, size
):
377 if size
.width
== -1: size
.width
= 0
378 if size
.height
== -1: size
.height
= 0
380 l1
= wxWindow(w
, -1, pos
, wxSize(size
.width
, 2))
381 l1
.SetBackgroundColour(wxRED
)
382 l2
= wxWindow(w
, -1, pos
, wxSize(2, size
.height
))
383 l2
.SetBackgroundColour(wxRED
)
384 l3
= wxWindow(w
, -1, wxPoint(pos
.x
+ size
.width
- 2, pos
.y
), wxSize(2, size
.height
))
385 l3
.SetBackgroundColour(wxRED
)
386 l4
= wxWindow(w
, -1, wxPoint(pos
.x
, pos
.y
+ size
.height
- 2), wxSize(size
.width
, 2))
387 l4
.SetBackgroundColour(wxRED
)
388 self
.lines
= [l1
, l2
, l3
, l4
]
389 # Move highlight to a new position
390 def Replace(self
, pos
, size
):
391 if size
.width
== -1: size
.width
= 0
392 if size
.height
== -1: size
.height
= 0
393 self
.lines
[0].SetDimensions(pos
.x
, pos
.y
, size
.width
, 2)
394 self
.lines
[1].SetDimensions(pos
.x
, pos
.y
, 2, size
.height
)
395 self
.lines
[2].SetDimensions(pos
.x
+ size
.width
- 2, pos
.y
, 2, size
.height
)
396 self
.lines
[3].SetDimensions(pos
.x
, pos
.y
+ size
.height
- 2, size
.width
, 2)
399 map(wxWindow
.Destroy
, self
.lines
)
400 g
.testWin
.highLight
= None
402 map(wxWindow
.Refresh
, self
.lines
)
404 ################################################################################
406 class XML_Tree(wxTreeCtrl
):
407 def __init__(self
, parent
, id):
408 wxTreeCtrl
.__init
__(self
, parent
, id, style
= wxTR_HAS_BUTTONS | wxTR_MULTIPLE
)
409 self
.SetBackgroundColour(wxColour(224, 248, 224))
411 EVT_TREE_SEL_CHANGED(self
, self
.GetId(), self
.OnSelChanged
)
412 # One works on Linux, another on Windows
413 if wxPlatform
== '__WXGTK__':
414 EVT_TREE_ITEM_ACTIVATED(self
, self
.GetId(), self
.OnItemActivated
)
416 EVT_LEFT_DCLICK(self
, self
.OnDClick
)
417 EVT_RIGHT_DOWN(self
, self
.OnRightDown
)
418 EVT_TREE_ITEM_EXPANDED(self
, self
.GetId(), self
.OnItemExpandedCollapsed
)
419 EVT_TREE_ITEM_COLLAPSED(self
, self
.GetId(), self
.OnItemExpandedCollapsed
)
421 self
.selection
= None
422 self
.selectionChanging
= False
423 self
.needUpdate
= False
424 self
.pendingHighLight
= None
425 self
.ctrl
= self
.shift
= False
428 il
= wxImageList(16, 16, True)
429 self
.rootImage
= il
.Add(images
.getTreeRootImage().Scale(16,16).ConvertToBitmap())
430 xxxObject
.image
= il
.Add(images
.getTreeDefaultImage().Scale(16,16).ConvertToBitmap())
431 xxxPanel
.image
= il
.Add(images
.getTreePanelImage().Scale(16,16).ConvertToBitmap())
432 xxxDialog
.image
= il
.Add(images
.getTreeDialogImage().Scale(16,16).ConvertToBitmap())
433 xxxFrame
.image
= il
.Add(images
.getTreeFrameImage().Scale(16,16).ConvertToBitmap())
434 xxxMenuBar
.image
= il
.Add(images
.getTreeMenuBarImage().Scale(16,16).ConvertToBitmap())
435 xxxMenu
.image
= il
.Add(images
.getTreeMenuImage().Scale(16,16).ConvertToBitmap())
436 xxxMenuItem
.image
= il
.Add(images
.getTreeMenuItemImage().Scale(16,16).ConvertToBitmap())
437 xxxToolBar
.image
= il
.Add(images
.getTreeToolBarImage().Scale(16,16).ConvertToBitmap())
438 xxxTool
.image
= il
.Add(images
.getTreeToolImage().Scale(16,16).ConvertToBitmap())
439 xxxSeparator
.image
= il
.Add(images
.getTreeSeparatorImage().Scale(16,16).ConvertToBitmap())
440 xxxSizer
.imageH
= il
.Add(images
.getTreeSizerHImage().Scale(16,16).ConvertToBitmap())
441 xxxSizer
.imageV
= il
.Add(images
.getTreeSizerVImage().Scale(16,16).ConvertToBitmap())
442 xxxStaticBoxSizer
.imageH
= il
.Add(images
.getTreeStaticBoxSizerHImage().Scale(16,16).ConvertToBitmap())
443 xxxStaticBoxSizer
.imageV
= il
.Add(images
.getTreeStaticBoxSizerVImage().Scale(16,16).ConvertToBitmap())
444 xxxGridSizer
.image
= il
.Add(images
.getTreeSizerGridImage().Scale(16,16).ConvertToBitmap())
445 xxxFlexGridSizer
.image
= il
.Add(images
.getTreeSizerFlexGridImage().Scale(16,16).ConvertToBitmap())
447 self
.SetImageList(il
)
449 def RegisterKeyEvents(self
):
450 EVT_KEY_DOWN(self
, g
.tools
.OnKeyDown
)
451 EVT_KEY_UP(self
, g
.tools
.OnKeyUp
)
452 EVT_ENTER_WINDOW(self
, g
.tools
.OnMouse
)
453 EVT_LEAVE_WINDOW(self
, g
.tools
.OnMouse
)
455 def ExpandAll(self
, item
):
456 if self
.ItemHasChildren(item
):
458 i
, cookie
= self
.GetFirstChild(item
)
462 i
, cookie
= self
.GetNextChild(item
, cookie
)
465 def CollapseAll(self
, item
):
466 if self
.ItemHasChildren(item
):
467 i
, cookie
= self
.GetFirstChild(item
)
471 i
, cookie
= self
.GetNextChild(item
, cookie
)
478 self
.DeleteAllItems()
479 # Add minimal structure
480 if self
.dom
: self
.dom
.unlink()
481 self
.dom
= MyDocument()
482 self
.dummyNode
= self
.dom
.createComment('dummy node')
484 self
.mainNode
= self
.dom
.createElement('resource')
485 self
.dom
.appendChild(self
.mainNode
)
486 self
.rootObj
= xxxMainNode(self
.dom
)
487 self
.root
= self
.AddRoot('XML tree', self
.rootImage
,
488 data
=wxTreeItemData(self
.rootObj
))
489 self
.SetItemHasChildren(self
.root
)
491 self
.Expand(self
.root
)
493 # Clear old data and set new
494 def SetData(self
, dom
):
495 self
.DeleteAllItems()
496 # Add minimal structure
497 if self
.dom
: self
.dom
.unlink()
499 self
.dummyNode
= self
.dom
.createComment('dummy node')
500 # Find 'resource' child, add it's children
501 self
.mainNode
= dom
.documentElement
502 self
.rootObj
= xxxMainNode(self
.dom
)
503 self
.root
= self
.AddRoot('XML tree', self
.rootImage
,
504 data
=wxTreeItemData(self
.rootObj
))
505 self
.SetItemHasChildren(self
.root
)
506 nodes
= self
.mainNode
.childNodes
[:]
509 self
.AddNode(self
.root
, None, node
)
511 self
.mainNode
.removeChild(node
)
513 self
.Expand(self
.root
)
516 # Add tree item for given parent item if node is DOM element node with
517 # object/object_ref tag. xxxParent is parent xxx object
518 def AddNode(self
, itemParent
, xxxParent
, node
):
519 # Set item data to current node
521 xxx
= MakeXXXFromDOM(xxxParent
, node
)
523 print 'ERROR: MakeXXXFromDom(%s, %s)' % (xxxParent
, node
)
525 treeObj
= xxx
.treeObject()
527 item
= self
.AppendItem(itemParent
, treeObj
.treeName(),
528 image
=treeObj
.treeImage(),
529 data
=wxTreeItemData(xxx
))
530 # Different color for references
532 self
.SetItemTextColour(item
, 'DarkGreen')
533 # Try to find children objects
534 if treeObj
.hasChildren
:
535 nodes
= treeObj
.element
.childNodes
[:]
538 self
.AddNode(item
, treeObj
, n
)
539 elif n
.nodeType
!= minidom
.Node
.ELEMENT_NODE
:
540 treeObj
.element
.removeChild(n
)
543 # Insert new item at specific position
544 def InsertNode(self
, itemParent
, parent
, elem
, nextItem
):
545 # Insert in XML tree and wxWin
546 xxx
= MakeXXXFromDOM(parent
, elem
)
547 # If nextItem is None, we append to parent, otherwise insert before it
549 node
= self
.GetPyData(nextItem
).element
550 parent
.element
.insertBefore(elem
, node
)
551 # Inserting before is difficult, se we insert after or first child
552 index
= self
.ItemIndex(nextItem
)
553 newItem
= self
.InsertItemBefore(itemParent
, index
,
554 xxx
.treeName(), image
=xxx
.treeImage())
555 self
.SetPyData(newItem
, xxx
)
557 parent
.element
.appendChild(elem
)
558 newItem
= self
.AppendItem(itemParent
, xxx
.treeName(), image
=xxx
.treeImage(),
559 data
=wxTreeItemData(xxx
))
560 # Different color for references
561 if xxx
.treeObject().ref
: self
.SetItemTextColour(newItem
, 'DarkGreen')
564 treeObj
= xxx
.treeObject()
565 for n
in treeObj
.element
.childNodes
:
567 self
.AddNode(newItem
, treeObj
, n
)
570 # Remove leaf of tree, return it's data object
571 def RemoveLeaf(self
, leaf
):
572 xxx
= self
.GetPyData(leaf
)
574 parent
= node
.parentNode
575 parent
.removeChild(node
)
577 # Reset selection object
578 self
.selection
= None
580 # Find position relative to the top-level window
581 def FindNodePos(self
, item
, obj
=None):
583 if item
== g
.testWin
.item
: return wxPoint(0, 0)
584 itemParent
= self
.GetItemParent(item
)
586 if not obj
: obj
= self
.FindNodeObject(item
)
587 if self
.GetPyData(itemParent
).treeObject().__class
__ == xxxNotebook
:
588 notebook
= self
.FindNodeObject(itemParent
)
590 for i
in range(notebook
.GetPageCount()):
591 if notebook
.GetPage(i
) == obj
:
592 if notebook
.GetSelection() != i
:
593 notebook
.SetSelection(i
)
594 # Remove highlight - otherwise highlight window won't be visible
595 if g
.testWin
.highLight
:
596 g
.testWin
.highLight
.Remove()
598 # Find first ancestor which is a wxWindow (not a sizer)
599 winParent
= itemParent
600 while self
.GetPyData(winParent
).isSizer
:
601 winParent
= self
.GetItemParent(winParent
)
602 # Notebook children are layed out in a little strange way
603 if self
.GetPyData(itemParent
).treeObject().__class
__ == xxxNotebook
:
604 parentPos
= wxPoint(0,0)
606 parentPos
= self
.FindNodePos(winParent
)
607 # Position (-1,-1) is really (0,0)
608 pos
= obj
.GetPosition()
609 if pos
== (-1,-1): pos
= (0,0)
610 return parentPos
+ pos
612 # Find window (or sizer) corresponding to a tree item.
613 def FindNodeObject(self
, item
):
615 # If top-level, return testWin (or panel its panel)
616 if item
== testWin
.item
: return testWin
.panel
617 itemParent
= self
.GetItemParent(item
)
618 xxx
= self
.GetPyData(item
).treeObject()
619 parentWin
= self
.FindNodeObject(itemParent
)
620 # Top-level sizer? return window's sizer
621 if xxx
.isSizer
and isinstance(parentWin
, wxWindow
):
622 return parentWin
.GetSizer()
623 elif isinstance(xxx
.parent
, xxxToolBar
):
624 # How to get tool from toolbar?
626 elif isinstance(xxx
.parent
, xxxStdDialogButtonSizer
):
627 # This sizer returns non-existing children
628 for ch
in parentWin
.GetChildren():
629 if ch
.GetWindow() and ch
.GetWindow().GetName() == xxx
.name
:
630 return ch
.GetWindow()
632 # Otherwise get parent's object and it's child
633 child
= parentWin
.GetChildren()[self
.ItemIndex(item
)]
634 # Return window or sizer for sizer items
635 if child
.GetClassName() == 'wxSizerItem':
636 if child
.IsWindow(): child
= child
.GetWindow()
637 elif child
.IsSizer():
638 child
= child
.GetSizer()
639 # Test for notebook sizers
640 if isinstance(child
, wxNotebookSizer
):
641 child
= child
.GetNotebook()
644 def OnSelChanged(self
, evt
):
645 if self
.selectionChanging
: return
646 self
.selectionChanging
= True
648 self
.SelectItem(evt
.GetItem())
649 self
.selectionChanging
= False
651 def ChangeSelection(self
, item
):
653 # !!! problem with wxGTK - GetOldItem is Ok if nothing selected
654 #oldItem = evt.GetOldItem()
656 oldItem
= self
.selection
658 xxx
= self
.GetPyData(oldItem
)
659 # If some data was modified, apply changes
660 if g
.panel
.IsModified():
661 self
.Apply(xxx
, oldItem
)
662 #if conf.autoRefresh:
664 if g
.testWin
.highLight
:
665 g
.testWin
.highLight
.Remove()
666 self
.needUpdate
= True
667 status
= 'Changes were applied'
668 g
.frame
.SetStatusText(status
)
670 self
.selection
= item
671 if not self
.selection
.IsOk():
672 self
.selection
= None
674 xxx
= self
.GetPyData(self
.selection
)
679 # Highlighting is done in OnIdle
680 self
.pendingHighLight
= self
.selection
682 # Check if item is in testWin subtree
683 def IsHighlatable(self
, item
):
684 if item
== g
.testWin
.item
: return False
685 while item
!= self
.root
:
686 item
= self
.GetItemParent(item
)
687 if item
== g
.testWin
.item
: return True
690 # Highlight selected item
691 def HighLight(self
, item
):
692 self
.pendingHighLight
= None
693 # Can highlight only with some top-level windows
694 if not g
.testWin
or self
.GetPyData(g
.testWin
.item
).treeObject().__class
__ \
695 not in [xxxDialog
, xxxPanel
, xxxFrame
]:
697 # If a control from another window is selected, remove highlight
698 if not self
.IsHighlatable(item
):
699 if g
.testWin
.highLight
: g
.testWin
.highLight
.Remove()
701 # Get window/sizer object
702 obj
= self
.FindNodeObject(item
)
704 pos
= self
.FindNodePos(item
, obj
)
707 # Negative positions are not working quite well
708 if g
.testWin
.highLight
:
709 g
.testWin
.highLight
.Replace(pos
, size
)
711 g
.testWin
.highLight
= HighLightBox(pos
, size
)
712 g
.testWin
.highLight
.Refresh()
713 g
.testWin
.highLight
.item
= item
715 def ShowTestWindow(self
, item
):
716 xxx
= self
.GetPyData(item
)
717 if g
.panel
.IsModified():
718 self
.Apply(xxx
, item
) # apply changes
719 treeObj
= xxx
.treeObject()
720 if treeObj
.className
not in ['wxFrame', 'wxPanel', 'wxDialog',
721 'wxMenuBar', 'wxToolBar', 'wxWizard',
722 'wxWizardPageSimple']:
723 wxLogMessage('No view for this element (yet)')
726 if g
.testWin
: # Reset old
727 self
.SetItemBold(g
.testWin
.item
, False)
728 self
.CreateTestWin(item
)
729 # Maybe an error occurred, so we need to test
730 if g
.testWin
: self
.SetItemBold(g
.testWin
.item
)
732 # Double-click on Linux
733 def OnItemActivated(self
, evt
):
734 if evt
.GetItem() != self
.root
:
735 self
.ShowTestWindow(evt
.GetItem())
737 # Double-click on Windows
738 def OnDClick(self
, evt
):
739 item
, flags
= self
.HitTest(evt
.GetPosition())
740 if flags
in [wxTREE_HITTEST_ONITEMBUTTON
, wxTREE_HITTEST_ONITEMLABEL
]:
741 if item
!= self
.root
: self
.ShowTestWindow(item
)
745 def OnItemExpandedCollapsed(self
, evt
):
746 # Update tool palette
750 # (re)create test window
751 def CreateTestWin(self
, item
):
753 # Create a window with this resource
754 xxx
= self
.GetPyData(item
).treeObject()
757 # if xxx.__class__ == xxxFrame:
758 # Frame can't have many children,
759 # but it's first child possibly can...
760 # child = self.GetFirstChild(item)[0]
761 # if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
762 # # Clean-up before recursive call or error
763 # wxMemoryFSHandler_RemoveFile('xxx.xrc')
765 # self.CreateTestWin(child)
770 # Close old window, remember where it was
773 pos
= testWin
.GetPosition()
774 if item
== testWin
.item
:
775 # Remember highlight if same top-level window
776 if testWin
.highLight
:
777 highLight
= testWin
.highLight
.item
778 if xxx
.className
== 'wxPanel':
779 if testWin
.highLight
:
780 testWin
.pendingHighLight
= highLight
781 testWin
.highLight
.Remove()
782 testWin
.panel
.Destroy()
786 testWin
= g
.testWin
= None
789 testWin
= g
.testWin
= None
793 memFile
= MemoryFile('xxx.xrc')
794 # Create memory XML file
796 # Change window id to _XRCED_T_W. This gives some name for
797 # unnamed windows, and for named gives the possibility to
798 # write sawfish scripts.
803 elem
.setAttribute('name', STD_NAME
)
804 # Replace wizard page class temporarily
805 if xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
806 oldCl
= elem
.getAttribute('class')
807 elem
.setAttribute('class', 'wxPanel')
808 parent
= elem
.parentNode
809 next
= elem
.nextSibling
810 encd
= self
.rootObj
.params
['encoding'].value()
811 if not encd
: encd
= None
812 self
.dom
.writexml(open('ttt.xrc','w'), encoding
=encd
)
813 self
.dom
.writexml(memFile
, encoding
=encd
)
815 # Remove temporary name or restore changed
817 elem
.removeAttribute('name')
819 elem
.setAttribute('name', xxx
.name
)
820 if xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
821 elem
.setAttribute('class', oldCl
)
822 memFile
.close() # write to wxMemoryFS
823 xmlFlags
= wxXRC_NO_SUBCLASSING
824 # Use translations if encoding is not specified
825 if not g
.currentEncoding
:
826 xmlFlags
!= wxXRC_USE_LOCALE
827 res
= wxXmlResource('', xmlFlags
)
828 res
.Load('memory:xxx.xrc')
830 if xxx
.__class
__ == xxxFrame
:
831 # Frame can't have many children,
832 # but it's first child possibly can...
833 # child = self.GetFirstChild(item)[0]
834 # if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
835 # # Clean-up before recursive call or error
836 # wxMemoryFSHandler_RemoveFile('xxx.xrc')
838 # self.CreateTestWin(child)
840 # This currently works under GTK, but not under MSW
841 testWin
= g
.testWin
= wxPreFrame()
842 res
.LoadOnFrame(testWin
, g
.frame
, STD_NAME
)
844 testWin
.panel
= testWin
845 testWin
.CreateStatusBar()
846 testWin
.SetClientSize(testWin
.GetBestSize())
847 testWin
.SetPosition(pos
)
849 elif xxx
.__class
__ == xxxPanel
:
852 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'Panel: ' + name
,
853 pos
=pos
, name
=STD_NAME
)
854 testWin
.panel
= res
.LoadPanel(testWin
, STD_NAME
)
855 testWin
.SetClientSize(testWin
.GetBestSize())
857 elif xxx
.__class
__ == xxxDialog
:
858 testWin
= g
.testWin
= res
.LoadDialog(None, STD_NAME
)
859 testWin
.panel
= testWin
861 testWin
.SetPosition(pos
)
863 # Dialog's default code does not produce EVT_CLOSE
864 EVT_BUTTON(testWin
, wxID_OK
, self
.OnCloseTestWin
)
865 EVT_BUTTON(testWin
, wxID_CANCEL
, self
.OnCloseTestWin
)
866 elif xxx
.__class
__ == xxxWizard
:
868 res
.LoadOnObject(wiz
, None, STD_NAME
, 'wxWizard')
869 # Find first page (don't know better way)
871 for w
in wiz
.GetChildren():
872 if isinstance(w
, wxWizardPage
):
876 wxLogError('Wizard is empty')
878 # Wizard should be modal
879 self
.SetItemBold(item
)
881 self
.SetItemBold(item
, False)
883 elif xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
886 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'Wizard page: ' + name
,
887 pos
=pos
, name
=STD_NAME
)
888 testWin
.panel
= wxPrePanel()
889 res
.LoadOnObject(testWin
.panel
, testWin
, STD_NAME
, 'wxPanel')
890 testWin
.SetClientSize(testWin
.GetBestSize())
892 elif xxx
.__class
__ == xxxMenuBar
:
893 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'MenuBar: ' + name
,
894 pos
=pos
, name
=STD_NAME
)
896 # Set status bar to display help
897 testWin
.CreateStatusBar()
898 testWin
.menuBar
= res
.LoadMenuBar(STD_NAME
)
899 testWin
.SetMenuBar(testWin
.menuBar
)
901 elif xxx
.__class
__ == xxxToolBar
:
902 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'ToolBar: ' + name
,
903 pos
=pos
, name
=STD_NAME
)
905 # Set status bar to display help
906 testWin
.CreateStatusBar()
907 testWin
.toolBar
= res
.LoadToolBar(testWin
, STD_NAME
)
908 testWin
.SetToolBar(testWin
.toolBar
)
912 EVT_CLOSE(testWin
, self
.OnCloseTestWin
)
913 testWin
.highLight
= None
914 if highLight
and not self
.pendingHighLight
:
915 self
.HighLight(highLight
)
918 self
.SetItemBold(item
, False)
919 g
.testWinPos
= g
.testWin
.GetPosition()
923 wxLogError(traceback
.format_exception(inf
[0], inf
[1], None)[-1])
924 wxLogError('Error loading resource')
925 wxMemoryFSHandler_RemoveFile('xxx.xrc')
928 def CloseTestWindow(self
):
929 if not g
.testWin
: return
930 self
.SetItemBold(g
.testWin
.item
, False)
931 g
.frame
.tb
.ToggleTool(g
.frame
.ID_TOOL_LOCATE
, False)
932 g
.testWinPos
= g
.testWin
.GetPosition()
936 def OnCloseTestWin(self
, evt
):
937 self
.CloseTestWindow()
939 # Return item index in parent
940 def ItemIndex(self
, item
):
941 n
= 0 # index of sibling
942 prev
= self
.GetPrevSibling(item
)
944 prev
= self
.GetPrevSibling(prev
)
948 # Full tree index of an item - list of positions
949 def ItemFullIndex(self
, item
):
950 if not item
.IsOk(): return None
952 while item
!= self
.root
:
953 l
.insert(0, self
.ItemIndex(item
))
954 item
= self
.GetItemParent(item
)
956 # Get item position from full index
957 def ItemAtFullIndex(self
, index
):
958 if index
is None: return wxTreeItemId()
961 item
= self
.GetFirstChild(item
)[0]
962 for k
in range(i
): item
= self
.GetNextSibling(item
)
965 # True if next item should be inserted after current (vs. appended to it)
966 def NeedInsert(self
, item
):
967 xxx
= self
.GetPyData(item
)
968 if item
== self
.root
: return False # root item
969 if xxx
.hasChildren
and not self
.GetChildrenCount(item
, False):
971 return not (self
.IsExpanded(item
) and self
.GetChildrenCount(item
, False))
973 # Override to use like single-selection tree
974 def GetSelection(self
):
975 self
.GetSelections(self
)[:1]
976 def SelectItem(self
, item
):
978 self
.ChangeSelection(item
)
979 wxTreeCtrl
.SelectItem(self
, item
)
982 def OnRightDown(self
, evt
):
983 pullDownMenu
= g
.pullDownMenu
985 pt
= evt
.GetPosition();
986 item
, flags
= self
.HitTest(pt
)
987 if item
.Ok() and flags
& wxTREE_HITTEST_ONITEM
:
988 self
.SelectItem(item
)
993 item
= self
.selection
995 menu
.Append(g
.pullDownMenu
.ID_EXPAND
, 'Expand', 'Expand tree')
996 menu
.Append(g
.pullDownMenu
.ID_COLLAPSE
, 'Collapse', 'Collapse tree')
998 # self.ctrl = evt.ControlDown() # save Ctrl state
999 # self.shift = evt.ShiftDown() # and Shift too
1000 m
= wxMenu() # create menu
1004 needInsert
= self
.NeedInsert(item
)
1005 if item
== self
.root
or needInsert
and self
.GetItemParent(item
) == self
.root
:
1006 SetMenu(m
, pullDownMenu
.topLevel
)
1008 m
.Append(ID_NEW
.REF
, 'reference...', 'Create object_ref node')
1010 xxx
= self
.GetPyData(item
).treeObject()
1011 # Check parent for possible child nodes if inserting sibling
1012 if needInsert
: xxx
= xxx
.parent
1013 if xxx
.__class
__ == xxxMenuBar
:
1014 m
.Append(ID_NEW
.MENU
, 'Menu', 'Create menu')
1015 elif xxx
.__class
__ in [xxxToolBar
, xxxTool
] or \
1016 xxx
.__class
__ == xxxSeparator
and xxx
.parent
.__class
__ == xxxToolBar
:
1017 SetMenu(m
, pullDownMenu
.toolBarControls
)
1018 elif xxx
.__class
__ in [xxxMenu
, xxxMenuItem
]:
1019 SetMenu(m
, pullDownMenu
.menuControls
)
1020 elif xxx
.__class
__ == xxxStdDialogButtonSizer
:
1021 SetMenu(m
, pullDownMenu
.stdButtons
)
1023 SetMenu(m
, pullDownMenu
.controls
)
1024 if xxx
.__class
__ == xxxNotebook
:
1025 m
.Enable(m
.FindItem('sizer'), False)
1026 elif not (xxx
.isSizer
or xxx
.parent
and xxx
.parent
.isSizer
):
1027 m
.Enable(ID_NEW
.SPACER
, False)
1029 m
.Append(ID_NEW
.REF
, 'reference...', 'Create object_ref node')
1030 # Select correct label for create menu
1033 menu
.AppendMenu(wxNewId(), 'Insert Child', m
,
1034 'Create child object as the first child')
1036 menu
.AppendMenu(wxNewId(), 'Append Child', m
,
1037 'Create child object as the last child')
1040 menu
.AppendMenu(wxNewId(), 'Create Sibling', m
,
1041 'Create sibling before selected object')
1043 menu
.AppendMenu(wxNewId(), 'Create Sibling', m
,
1044 'Create sibling after selected object')
1045 # Build replace menu
1046 if item
!= self
.root
:
1047 xxx
= self
.GetPyData(item
).treeObject()
1048 m
= wxMenu() # create replace menu
1049 if xxx
.__class
__ == xxxMenuBar
:
1050 m
.Append(1000 + ID_NEW
.MENU
, 'Menu', 'Create menu')
1051 elif xxx
.__class
__ in [xxxMenu
, xxxMenuItem
]:
1052 SetMenu(m
, pullDownMenu
.menuControls
, shift
=True)
1053 elif xxx
.__class
__ == xxxToolBar
and \
1054 self
.GetItemParent(item
) == self
.root
:
1055 SetMenu(m
, [], shift
=True)
1056 elif xxx
.__class
__ in [xxxFrame
, xxxDialog
, xxxPanel
]:
1058 (ID_NEW
.PANEL
, 'Panel', 'Create panel'),
1059 (ID_NEW
.DIALOG
, 'Dialog', 'Create dialog'),
1060 (ID_NEW
.FRAME
, 'Frame', 'Create frame')], shift
=True)
1062 SetMenu(m
, pullDownMenu
.sizers
, shift
=True)
1064 SetMenu(m
, pullDownMenu
.controls
, shift
=True)
1066 menu
.AppendMenu(id, 'Replace With', m
)
1067 if not m
.GetMenuItemCount(): menu
.Enable(id, False)
1068 menu
.Append(pullDownMenu
.ID_SUBCLASS
, 'Subclass...',
1069 'Set "subclass" property')
1070 menu
.AppendSeparator()
1071 # Not using standart IDs because we don't want to show shortcuts
1072 menu
.Append(wxID_CUT
, 'Cut', 'Cut to the clipboard')
1073 menu
.Append(wxID_COPY
, 'Copy', 'Copy to the clipboard')
1074 if self
.ctrl
and item
!= self
.root
:
1075 menu
.Append(pullDownMenu
.ID_PASTE_SIBLING
, 'Paste Sibling',
1076 'Paste from the clipboard as a sibling')
1078 menu
.Append(wxID_PASTE
, 'Paste', 'Paste from the clipboard')
1079 menu
.Append(pullDownMenu
.ID_DELETE
,
1080 'Delete', 'Delete object')
1081 if self
.ItemHasChildren(item
):
1082 menu
.AppendSeparator()
1083 menu
.Append(pullDownMenu
.ID_EXPAND
, 'Expand', 'Expand subtree')
1084 menu
.Append(pullDownMenu
.ID_COLLAPSE
, 'Collapse', 'Collapse subtree')
1085 self
.PopupMenu(menu
, evt
.GetPosition())
1089 def Apply(self
, xxx
, item
):
1092 xxx
= xxx
.treeObject()
1093 if xxx
.hasName
and self
.GetItemText(item
) != xxx
.name
:
1094 self
.SetItemText(item
, xxx
.treeName())
1095 # Item width may have changed
1096 # !!! Tric to update tree width (wxGTK, ??)
1097 self
.SetIndent(self
.GetIndent())
1098 # Change tree icon for sizers
1099 if isinstance(xxx
, xxxBoxSizer
):
1100 self
.SetItemImage(item
, xxx
.treeImage())
1101 # Set global modified state
1102 g
.frame
.SetModified()