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:], shift
)
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
.selection
= None
480 self
.DeleteAllItems()
481 # Add minimal structure
482 if self
.dom
: self
.dom
.unlink()
483 self
.dom
= MyDocument()
484 self
.dummyNode
= self
.dom
.createComment('dummy node')
486 self
.mainNode
= self
.dom
.createElement('resource')
487 self
.dom
.appendChild(self
.mainNode
)
488 self
.rootObj
= xxxMainNode(self
.dom
)
489 self
.root
= self
.AddRoot('XML tree', self
.rootImage
,
490 data
=wxTreeItemData(self
.rootObj
))
491 self
.SetItemHasChildren(self
.root
)
492 self
.Expand(self
.root
)
494 # Clear old data and set new
495 def SetData(self
, dom
):
496 self
.selection
= None
498 self
.DeleteAllItems()
499 # Add minimal structure
500 if self
.dom
: self
.dom
.unlink()
502 self
.dummyNode
= self
.dom
.createComment('dummy node')
503 # Find 'resource' child, add it's children
504 self
.mainNode
= dom
.documentElement
505 self
.rootObj
= xxxMainNode(self
.dom
)
506 self
.root
= self
.AddRoot('XML tree', self
.rootImage
,
507 data
=wxTreeItemData(self
.rootObj
))
508 self
.SetItemHasChildren(self
.root
)
509 nodes
= self
.mainNode
.childNodes
[:]
512 self
.AddNode(self
.root
, None, node
)
514 self
.mainNode
.removeChild(node
)
516 self
.Expand(self
.root
)
518 # Add tree item for given parent item if node is DOM element node with
519 # object/object_ref tag. xxxParent is parent xxx object
520 def AddNode(self
, itemParent
, xxxParent
, node
):
521 # Set item data to current node
523 xxx
= MakeXXXFromDOM(xxxParent
, node
)
525 print 'ERROR: MakeXXXFromDom(%s, %s)' % (xxxParent
, node
)
527 treeObj
= xxx
.treeObject()
529 item
= self
.AppendItem(itemParent
, treeObj
.treeName(),
530 image
=treeObj
.treeImage(),
531 data
=wxTreeItemData(xxx
))
532 # Different color for references
534 self
.SetItemTextColour(item
, 'DarkGreen')
535 # Try to find children objects
536 if treeObj
.hasChildren
:
537 nodes
= treeObj
.element
.childNodes
[:]
540 self
.AddNode(item
, treeObj
, n
)
541 elif n
.nodeType
!= minidom
.Node
.ELEMENT_NODE
:
542 treeObj
.element
.removeChild(n
)
545 # Insert new item at specific position
546 def InsertNode(self
, itemParent
, parent
, elem
, nextItem
):
547 # Insert in XML tree and wxWin
548 xxx
= MakeXXXFromDOM(parent
, elem
)
549 # If nextItem is None, we append to parent, otherwise insert before it
551 node
= self
.GetPyData(nextItem
).element
552 parent
.element
.insertBefore(elem
, node
)
553 # Inserting before is difficult, se we insert after or first child
554 index
= self
.ItemIndex(nextItem
)
555 newItem
= self
.InsertItemBefore(itemParent
, index
,
556 xxx
.treeName(), image
=xxx
.treeImage())
557 self
.SetPyData(newItem
, xxx
)
559 parent
.element
.appendChild(elem
)
560 newItem
= self
.AppendItem(itemParent
, xxx
.treeName(), image
=xxx
.treeImage(),
561 data
=wxTreeItemData(xxx
))
562 # Different color for references
563 if xxx
.treeObject().ref
: self
.SetItemTextColour(newItem
, 'DarkGreen')
566 treeObj
= xxx
.treeObject()
567 for n
in treeObj
.element
.childNodes
:
569 self
.AddNode(newItem
, treeObj
, n
)
572 # Remove leaf of tree, return it's data object
573 def RemoveLeaf(self
, leaf
):
574 xxx
= self
.GetPyData(leaf
)
576 parent
= node
.parentNode
577 parent
.removeChild(node
)
579 # Reset selection object
580 self
.selection
= None
582 # Find position relative to the top-level window
583 def FindNodePos(self
, item
, obj
=None):
585 if item
== g
.testWin
.item
: return wxPoint(0, 0)
586 itemParent
= self
.GetItemParent(item
)
588 if not obj
: obj
= self
.FindNodeObject(item
)
589 if self
.GetPyData(itemParent
).treeObject().__class
__ == xxxNotebook
:
590 notebook
= self
.FindNodeObject(itemParent
)
592 for i
in range(notebook
.GetPageCount()):
593 if notebook
.GetPage(i
) == obj
:
594 if notebook
.GetSelection() != i
:
595 notebook
.SetSelection(i
)
596 # Remove highlight - otherwise highlight window won't be visible
597 if g
.testWin
.highLight
:
598 g
.testWin
.highLight
.Remove()
600 # Find first ancestor which is a wxWindow (not a sizer)
601 winParent
= itemParent
602 while self
.GetPyData(winParent
).isSizer
:
603 winParent
= self
.GetItemParent(winParent
)
604 # Notebook children are layed out in a little strange way
605 if self
.GetPyData(itemParent
).treeObject().__class
__ == xxxNotebook
:
606 parentPos
= wxPoint(0,0)
608 parentPos
= self
.FindNodePos(winParent
)
609 # Position (-1,-1) is really (0,0)
610 pos
= obj
.GetPosition()
611 if pos
== (-1,-1): pos
= (0,0)
612 return parentPos
+ pos
614 # Find window (or sizer) corresponding to a tree item.
615 def FindNodeObject(self
, item
):
617 # If top-level, return testWin (or panel its panel)
618 if item
== testWin
.item
: return testWin
.panel
619 itemParent
= self
.GetItemParent(item
)
620 xxx
= self
.GetPyData(item
).treeObject()
621 parentWin
= self
.FindNodeObject(itemParent
)
622 # Top-level sizer? return window's sizer
623 if xxx
.isSizer
and isinstance(parentWin
, wxWindow
):
624 return parentWin
.GetSizer()
625 elif isinstance(xxx
.parent
, xxxToolBar
):
626 # How to get tool from toolbar?
628 elif isinstance(xxx
.parent
, xxxStdDialogButtonSizer
):
629 # This sizer returns non-existing children
630 for ch
in parentWin
.GetChildren():
631 if ch
.GetWindow() and ch
.GetWindow().GetName() == xxx
.name
:
632 return ch
.GetWindow()
634 # Otherwise get parent's object and it's child
635 child
= parentWin
.GetChildren()[self
.ItemIndex(item
)]
636 # Return window or sizer for sizer items
637 if child
.GetClassName() == 'wxSizerItem':
638 if child
.IsWindow(): child
= child
.GetWindow()
639 elif child
.IsSizer():
640 child
= child
.GetSizer()
641 # Test for notebook sizers
642 if isinstance(child
, wxNotebookSizer
):
643 child
= child
.GetNotebook()
646 def OnSelChanged(self
, evt
):
647 if self
.selectionChanging
: return
648 self
.selectionChanging
= True
650 self
.SelectItem(evt
.GetItem())
651 self
.selectionChanging
= False
653 def ChangeSelection(self
, item
):
655 # !!! problem with wxGTK - GetOldItem is Ok if nothing selected
656 #oldItem = evt.GetOldItem()
658 oldItem
= self
.selection
660 xxx
= self
.GetPyData(oldItem
)
661 # If some data was modified, apply changes
662 if g
.panel
.IsModified():
663 self
.Apply(xxx
, oldItem
)
664 #if conf.autoRefresh:
666 if g
.testWin
.highLight
:
667 g
.testWin
.highLight
.Remove()
668 self
.needUpdate
= True
669 status
= 'Changes were applied'
670 g
.frame
.SetStatusText(status
)
672 self
.selection
= item
673 if not self
.selection
.IsOk():
674 self
.selection
= None
676 xxx
= self
.GetPyData(self
.selection
)
681 # Highlighting is done in OnIdle
682 self
.pendingHighLight
= self
.selection
684 # Check if item is in testWin subtree
685 def IsHighlatable(self
, item
):
686 if item
== g
.testWin
.item
: return False
687 while item
!= self
.root
:
688 item
= self
.GetItemParent(item
)
689 if item
== g
.testWin
.item
: return True
692 # Highlight selected item
693 def HighLight(self
, item
):
694 self
.pendingHighLight
= None
695 # Can highlight only with some top-level windows
696 if not g
.testWin
or self
.GetPyData(g
.testWin
.item
).treeObject().__class
__ \
697 not in [xxxDialog
, xxxPanel
, xxxFrame
]:
699 # If a control from another window is selected, remove highlight
700 if not self
.IsHighlatable(item
):
701 if g
.testWin
.highLight
: g
.testWin
.highLight
.Remove()
703 # Get window/sizer object
704 obj
= self
.FindNodeObject(item
)
706 pos
= self
.FindNodePos(item
, obj
)
709 # Negative positions are not working quite well
710 if g
.testWin
.highLight
:
711 g
.testWin
.highLight
.Replace(pos
, size
)
713 g
.testWin
.highLight
= HighLightBox(pos
, size
)
714 g
.testWin
.highLight
.Refresh()
715 g
.testWin
.highLight
.item
= item
717 def ShowTestWindow(self
, item
):
718 xxx
= self
.GetPyData(item
)
719 if g
.panel
.IsModified():
720 self
.Apply(xxx
, item
) # apply changes
721 treeObj
= xxx
.treeObject()
722 if treeObj
.className
not in ['wxFrame', 'wxPanel', 'wxDialog',
723 'wxMenuBar', 'wxToolBar', 'wxWizard',
724 'wxWizardPageSimple']:
725 wxLogMessage('No view for this element (yet)')
728 if g
.testWin
: # Reset old
729 self
.SetItemBold(g
.testWin
.item
, False)
730 self
.CreateTestWin(item
)
731 # Maybe an error occurred, so we need to test
732 if g
.testWin
: self
.SetItemBold(g
.testWin
.item
)
734 # Double-click on Linux
735 def OnItemActivated(self
, evt
):
736 if evt
.GetItem() != self
.root
:
737 self
.ShowTestWindow(evt
.GetItem())
739 # Double-click on Windows
740 def OnDClick(self
, evt
):
741 item
, flags
= self
.HitTest(evt
.GetPosition())
742 if flags
in [wxTREE_HITTEST_ONITEMBUTTON
, wxTREE_HITTEST_ONITEMLABEL
]:
743 if item
!= self
.root
: self
.ShowTestWindow(item
)
747 def OnItemExpandedCollapsed(self
, evt
):
748 # Update tool palette
752 # (re)create test window
753 def CreateTestWin(self
, item
):
755 # Create a window with this resource
756 xxx
= self
.GetPyData(item
).treeObject()
759 # if xxx.__class__ == xxxFrame:
760 # Frame can't have many children,
761 # but it's first child possibly can...
762 # child = self.GetFirstChild(item)[0]
763 # if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
764 # # Clean-up before recursive call or error
765 # wxMemoryFSHandler_RemoveFile('xxx.xrc')
767 # self.CreateTestWin(child)
771 # Close old window, remember where it was
774 pos
= testWin
.GetPosition()
775 if item
== testWin
.item
:
776 # Remember highlight if same top-level window
777 if testWin
.highLight
:
778 highLight
= testWin
.highLight
.item
779 if xxx
.className
== 'wxPanel':
780 if testWin
.highLight
:
781 testWin
.pendingHighLight
= highLight
782 testWin
.highLight
.Remove()
783 testWin
.panel
.Destroy()
787 testWin
= g
.testWin
= None
790 testWin
= g
.testWin
= None
794 memFile
= MemoryFile('xxx.xrc')
795 # Create memory XML file
797 # Change window id to _XRCED_T_W. This gives some name for
798 # unnamed windows, and for named gives the possibility to
799 # write sawfish scripts.
804 elem
.setAttribute('name', STD_NAME
)
805 # Replace wizard page class temporarily
806 if xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
807 oldCl
= elem
.getAttribute('class')
808 elem
.setAttribute('class', 'wxPanel')
809 parent
= elem
.parentNode
810 next
= elem
.nextSibling
811 encd
= self
.rootObj
.params
['encoding'].value()
812 if not encd
: encd
= None
813 self
.dom
.writexml(open('ttt.xrc','w'), encoding
=encd
)
814 self
.dom
.writexml(memFile
, encoding
=encd
)
816 # Remove temporary name or restore changed
818 elem
.removeAttribute('name')
820 elem
.setAttribute('name', xxx
.name
)
821 if xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
822 elem
.setAttribute('class', oldCl
)
823 memFile
.close() # write to wxMemoryFS
824 xmlFlags
= wxXRC_NO_SUBCLASSING
825 # Use translations if encoding is not specified
826 if not g
.currentEncoding
:
827 xmlFlags
!= wxXRC_USE_LOCALE
828 res
= wxXmlResource('', xmlFlags
)
829 res
.Load('memory:xxx.xrc')
831 if xxx
.__class
__ == xxxFrame
:
832 # Frame can't have many children,
833 # but it's first child possibly can...
834 # child = self.GetFirstChild(item)[0]
835 # if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
836 # # Clean-up before recursive call or error
837 # wxMemoryFSHandler_RemoveFile('xxx.xrc')
839 # self.CreateTestWin(child)
841 # This currently works under GTK, but not under MSW
842 testWin
= g
.testWin
= wxPreFrame()
843 res
.LoadOnFrame(testWin
, g
.frame
, STD_NAME
)
845 testWin
.panel
= testWin
846 testWin
.CreateStatusBar()
847 testWin
.SetClientSize(testWin
.GetBestSize())
848 testWin
.SetPosition(pos
)
850 elif xxx
.__class
__ == xxxPanel
:
853 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'Panel: ' + name
,
854 pos
=pos
, name
=STD_NAME
)
855 testWin
.panel
= res
.LoadPanel(testWin
, STD_NAME
)
856 testWin
.SetClientSize(testWin
.GetBestSize())
858 elif xxx
.__class
__ == xxxDialog
:
859 testWin
= g
.testWin
= res
.LoadDialog(None, STD_NAME
)
860 testWin
.panel
= testWin
862 testWin
.SetPosition(pos
)
864 # Dialog's default code does not produce EVT_CLOSE
865 EVT_BUTTON(testWin
, wxID_OK
, self
.OnCloseTestWin
)
866 EVT_BUTTON(testWin
, wxID_CANCEL
, self
.OnCloseTestWin
)
867 elif xxx
.__class
__ == xxxWizard
:
869 res
.LoadOnObject(wiz
, None, STD_NAME
, 'wxWizard')
870 # Find first page (don't know better way)
872 for w
in wiz
.GetChildren():
873 if isinstance(w
, wxWizardPage
):
877 wxLogError('Wizard is empty')
879 # Wizard should be modal
880 self
.SetItemBold(item
)
882 self
.SetItemBold(item
, False)
884 elif xxx
.__class
__ in [xxxWizardPage
, xxxWizardPageSimple
]:
887 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'Wizard page: ' + name
,
888 pos
=pos
, name
=STD_NAME
)
889 testWin
.panel
= wxPrePanel()
890 res
.LoadOnObject(testWin
.panel
, testWin
, STD_NAME
, 'wxPanel')
891 testWin
.SetClientSize(testWin
.GetBestSize())
893 elif xxx
.__class
__ == xxxMenuBar
:
894 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'MenuBar: ' + name
,
895 pos
=pos
, name
=STD_NAME
)
897 # Set status bar to display help
898 testWin
.CreateStatusBar()
899 testWin
.menuBar
= res
.LoadMenuBar(STD_NAME
)
900 testWin
.SetMenuBar(testWin
.menuBar
)
902 elif xxx
.__class
__ == xxxToolBar
:
903 testWin
= g
.testWin
= wxFrame(g
.frame
, -1, 'ToolBar: ' + name
,
904 pos
=pos
, name
=STD_NAME
)
906 # Set status bar to display help
907 testWin
.CreateStatusBar()
908 testWin
.toolBar
= res
.LoadToolBar(testWin
, STD_NAME
)
909 testWin
.SetToolBar(testWin
.toolBar
)
913 EVT_CLOSE(testWin
, self
.OnCloseTestWin
)
914 testWin
.highLight
= None
915 if highLight
and not self
.pendingHighLight
:
916 self
.HighLight(highLight
)
919 self
.SetItemBold(item
, False)
920 g
.testWinPos
= g
.testWin
.GetPosition()
924 wxLogError(traceback
.format_exception(inf
[0], inf
[1], None)[-1])
925 wxLogError('Error loading resource')
926 wxMemoryFSHandler_RemoveFile('xxx.xrc')
929 def CloseTestWindow(self
):
930 if not g
.testWin
: return
931 self
.SetItemBold(g
.testWin
.item
, False)
932 g
.frame
.tb
.ToggleTool(g
.frame
.ID_TOOL_LOCATE
, False)
933 g
.testWinPos
= g
.testWin
.GetPosition()
937 def OnCloseTestWin(self
, evt
):
938 self
.CloseTestWindow()
940 # Return item index in parent
941 def ItemIndex(self
, item
):
942 n
= 0 # index of sibling
943 prev
= self
.GetPrevSibling(item
)
945 prev
= self
.GetPrevSibling(prev
)
949 # Full tree index of an item - list of positions
950 def ItemFullIndex(self
, item
):
951 if not item
.IsOk(): return None
953 while item
!= self
.root
:
954 l
.insert(0, self
.ItemIndex(item
))
955 item
= self
.GetItemParent(item
)
957 # Get item position from full index
958 def ItemAtFullIndex(self
, index
):
959 if index
is None: return wxTreeItemId()
962 item
= self
.GetFirstChild(item
)[0]
963 for k
in range(i
): item
= self
.GetNextSibling(item
)
966 # True if next item should be inserted after current (vs. appended to it)
967 def NeedInsert(self
, item
):
968 xxx
= self
.GetPyData(item
)
969 if item
== self
.root
: return False # root item
970 if xxx
.hasChildren
and not self
.GetChildrenCount(item
, False):
972 return not (self
.IsExpanded(item
) and self
.GetChildrenCount(item
, False))
974 # Override to use like single-selection tree
975 def GetSelection(self
):
976 return self
.selection
977 def SelectItem(self
, item
):
979 self
.ChangeSelection(item
)
980 wxTreeCtrl
.SelectItem(self
, item
)
983 def OnRightDown(self
, evt
):
984 pullDownMenu
= g
.pullDownMenu
986 pt
= evt
.GetPosition();
987 item
, flags
= self
.HitTest(pt
)
988 if item
.Ok() and flags
& wxTREE_HITTEST_ONITEM
:
989 self
.SelectItem(item
)
994 item
= self
.selection
996 menu
.Append(g
.pullDownMenu
.ID_EXPAND
, 'Expand', 'Expand tree')
997 menu
.Append(g
.pullDownMenu
.ID_COLLAPSE
, 'Collapse', 'Collapse tree')
999 # self.ctrl = evt.ControlDown() # save Ctrl state
1000 # self.shift = evt.ShiftDown() # and Shift too
1001 m
= wxMenu() # create menu
1005 needInsert
= self
.NeedInsert(item
)
1006 if item
== self
.root
or needInsert
and self
.GetItemParent(item
) == self
.root
:
1007 SetMenu(m
, pullDownMenu
.topLevel
)
1009 m
.Append(ID_NEW
.REF
, 'reference...', 'Create object_ref node')
1011 xxx
= self
.GetPyData(item
).treeObject()
1012 # Check parent for possible child nodes if inserting sibling
1013 if needInsert
: xxx
= xxx
.parent
1014 if xxx
.__class
__ == xxxMenuBar
:
1015 m
.Append(ID_NEW
.MENU
, 'Menu', 'Create menu')
1016 elif xxx
.__class
__ in [xxxToolBar
, xxxTool
] or \
1017 xxx
.__class
__ == xxxSeparator
and xxx
.parent
.__class
__ == xxxToolBar
:
1018 SetMenu(m
, pullDownMenu
.toolBarControls
)
1019 elif xxx
.__class
__ in [xxxMenu
, xxxMenuItem
]:
1020 SetMenu(m
, pullDownMenu
.menuControls
)
1021 elif xxx
.__class
__ == xxxStdDialogButtonSizer
:
1022 SetMenu(m
, pullDownMenu
.stdButtons
)
1024 SetMenu(m
, pullDownMenu
.controls
)
1025 if xxx
.__class
__ == xxxNotebook
:
1026 m
.Enable(m
.FindItem('sizer'), False)
1027 elif not (xxx
.isSizer
or xxx
.parent
and xxx
.parent
.isSizer
):
1028 m
.Enable(ID_NEW
.SPACER
, False)
1030 m
.Append(ID_NEW
.REF
, 'reference...', 'Create object_ref node')
1031 # Select correct label for create menu
1034 menu
.AppendMenu(wxNewId(), 'Insert Child', m
,
1035 'Create child object as the first child')
1037 menu
.AppendMenu(wxNewId(), 'Append Child', m
,
1038 'Create child object as the last child')
1041 menu
.AppendMenu(wxNewId(), 'Create Sibling', m
,
1042 'Create sibling before selected object')
1044 menu
.AppendMenu(wxNewId(), 'Create Sibling', m
,
1045 'Create sibling after selected object')
1046 # Build replace menu
1047 if item
!= self
.root
:
1048 xxx
= self
.GetPyData(item
).treeObject()
1049 m
= wxMenu() # create replace menu
1050 if xxx
.__class
__ == xxxMenuBar
:
1051 m
.Append(1000 + ID_NEW
.MENU
, 'Menu', 'Create menu')
1052 elif xxx
.__class
__ in [xxxMenu
, xxxMenuItem
]:
1053 SetMenu(m
, pullDownMenu
.menuControls
, shift
=True)
1054 elif xxx
.__class
__ == xxxToolBar
and \
1055 self
.GetItemParent(item
) == self
.root
:
1056 SetMenu(m
, [], shift
=True)
1057 elif xxx
.__class
__ in [xxxFrame
, xxxDialog
, xxxPanel
]:
1059 (ID_NEW
.PANEL
, 'Panel', 'Create panel'),
1060 (ID_NEW
.DIALOG
, 'Dialog', 'Create dialog'),
1061 (ID_NEW
.FRAME
, 'Frame', 'Create frame')], shift
=True)
1063 SetMenu(m
, pullDownMenu
.sizers
, shift
=True)
1065 SetMenu(m
, pullDownMenu
.controls
, shift
=True)
1067 menu
.AppendMenu(id, 'Replace With', m
)
1068 if not m
.GetMenuItemCount(): menu
.Enable(id, False)
1069 menu
.Append(pullDownMenu
.ID_SUBCLASS
, 'Subclass...',
1070 'Set "subclass" property')
1071 menu
.AppendSeparator()
1072 # Not using standart IDs because we don't want to show shortcuts
1073 menu
.Append(wxID_CUT
, 'Cut', 'Cut to the clipboard')
1074 menu
.Append(wxID_COPY
, 'Copy', 'Copy to the clipboard')
1075 if self
.ctrl
and item
!= self
.root
:
1076 menu
.Append(pullDownMenu
.ID_PASTE_SIBLING
, 'Paste Sibling',
1077 'Paste from the clipboard as a sibling')
1079 menu
.Append(wxID_PASTE
, 'Paste', 'Paste from the clipboard')
1080 menu
.Append(pullDownMenu
.ID_DELETE
,
1081 'Delete', 'Delete object')
1082 if self
.ItemHasChildren(item
):
1083 menu
.AppendSeparator()
1084 menu
.Append(pullDownMenu
.ID_EXPAND
, 'Expand', 'Expand subtree')
1085 menu
.Append(pullDownMenu
.ID_COLLAPSE
, 'Collapse', 'Collapse subtree')
1086 self
.PopupMenu(menu
, evt
.GetPosition())
1090 def Apply(self
, xxx
, item
):
1093 xxx
= xxx
.treeObject()
1094 if xxx
.hasName
and self
.GetItemText(item
) != xxx
.name
:
1095 self
.SetItemText(item
, xxx
.treeName())
1096 # Item width may have changed
1097 # !!! Tric to update tree width (wxGTK, ??)
1098 self
.SetIndent(self
.GetIndent())
1099 # Change tree icon for sizers
1100 if isinstance(xxx
, xxxBoxSizer
):
1101 self
.SetItemImage(item
, xxx
.treeImage())
1102 # Set global modified state
1103 g
.frame
.SetModified()