added TreeCtrl.WindowIndex method for skipping items like MenuBar
when counting window children git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f3190d1cea
commit
0cbb7d59d4
@ -654,7 +654,7 @@ class XML_Tree(wxTreeCtrl):
|
||||
# Top-level sizer? return window's sizer
|
||||
if xxx.isSizer and isinstance(parentWin, wxWindow):
|
||||
return parentWin.GetSizer()
|
||||
elif xxx.__class__ in [xxxStatusBar, xxxMenu, xxxMenuItem, xxxSeparator]: return None
|
||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem, xxxSeparator]: return None
|
||||
elif xxx.__class__ in [xxxToolBar, xxxMenuBar]:
|
||||
# If it's the main toolbar or menubar, we can't really select it
|
||||
if xxx.parent.__class__ == xxxFrame: return None
|
||||
@ -671,7 +671,7 @@ class XML_Tree(wxTreeCtrl):
|
||||
# First window is controld
|
||||
return parentWin.GetChildren()[self.ItemIndex(item)+1]
|
||||
# Otherwise get parent's object and it's child
|
||||
child = parentWin.GetChildren()[self.ItemIndex(item)]
|
||||
child = parentWin.GetChildren()[self.WindowIndex(item)]
|
||||
# Return window or sizer for sizer items
|
||||
if child.GetClassName() == 'wxSizerItem':
|
||||
if child.IsWindow(): child = child.GetWindow()
|
||||
@ -738,7 +738,9 @@ class XML_Tree(wxTreeCtrl):
|
||||
return
|
||||
# Get window/sizer object
|
||||
obj = self.FindNodeObject(item)
|
||||
if not obj: return
|
||||
if not obj:
|
||||
if g.testWin.highLight: g.testWin.highLight.Remove()
|
||||
return
|
||||
pos = self.FindNodePos(item, obj)
|
||||
size = obj.GetSize()
|
||||
# Highlight
|
||||
@ -979,6 +981,17 @@ class XML_Tree(wxTreeCtrl):
|
||||
def OnCloseTestWin(self, evt):
|
||||
self.CloseTestWindow()
|
||||
|
||||
# Return index in parent, for real window children
|
||||
def WindowIndex(self, item):
|
||||
n = 0 # index of sibling
|
||||
prev = self.GetPrevSibling(item)
|
||||
while prev.IsOk():
|
||||
# MenuBar is not a child
|
||||
if not isinstance(self.GetPyData(prev), xxxMenuBar):
|
||||
n += 1
|
||||
prev = self.GetPrevSibling(prev)
|
||||
return n
|
||||
|
||||
# Return item index in parent
|
||||
def ItemIndex(self, item):
|
||||
n = 0 # index of sibling
|
||||
|
Loading…
Reference in New Issue
Block a user