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:
@@ -654,7 +654,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# Top-level sizer? return window's sizer
|
# Top-level sizer? return window's sizer
|
||||||
if xxx.isSizer and isinstance(parentWin, wxWindow):
|
if xxx.isSizer and isinstance(parentWin, wxWindow):
|
||||||
return parentWin.GetSizer()
|
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]:
|
elif xxx.__class__ in [xxxToolBar, xxxMenuBar]:
|
||||||
# If it's the main toolbar or menubar, we can't really select it
|
# If it's the main toolbar or menubar, we can't really select it
|
||||||
if xxx.parent.__class__ == xxxFrame: return None
|
if xxx.parent.__class__ == xxxFrame: return None
|
||||||
@@ -671,7 +671,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# First window is controld
|
# First window is controld
|
||||||
return parentWin.GetChildren()[self.ItemIndex(item)+1]
|
return parentWin.GetChildren()[self.ItemIndex(item)+1]
|
||||||
# Otherwise get parent's object and it's child
|
# 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
|
# Return window or sizer for sizer items
|
||||||
if child.GetClassName() == 'wxSizerItem':
|
if child.GetClassName() == 'wxSizerItem':
|
||||||
if child.IsWindow(): child = child.GetWindow()
|
if child.IsWindow(): child = child.GetWindow()
|
||||||
@@ -738,7 +738,9 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
return
|
return
|
||||||
# Get window/sizer object
|
# Get window/sizer object
|
||||||
obj = self.FindNodeObject(item)
|
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)
|
pos = self.FindNodePos(item, obj)
|
||||||
size = obj.GetSize()
|
size = obj.GetSize()
|
||||||
# Highlight
|
# Highlight
|
||||||
@@ -979,6 +981,17 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
def OnCloseTestWin(self, evt):
|
def OnCloseTestWin(self, evt):
|
||||||
self.CloseTestWindow()
|
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
|
# Return item index in parent
|
||||||
def ItemIndex(self, item):
|
def ItemIndex(self, item):
|
||||||
n = 0 # index of sibling
|
n = 0 # index of sibling
|
||||||
|
Reference in New Issue
Block a user