diff --git a/CHANGES.rst b/CHANGES.rst index 729df9c4..949088f5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -70,6 +70,9 @@ Changes in this release include the following: * Fix type error that would occur using pycolourchooser. (#957) +* Optimize line drawing in HyperTreeList. (#973) + + 4.0.3 "The show must go on. (Die show-stoppers! Die!)" diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index 5cffc7da..ee64d12c 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -251,7 +251,7 @@ def GetSmilesImage(): def opj(path): """Convert paths to the platform-specific separator""" - str = apply(os.path.join, tuple(path.split('/'))) + str = os.path.join(*tuple(path.split('/'))) # HACK: on Linux, a leading / gets lost... if path.startswith('/'): str = '/' + str @@ -417,14 +417,11 @@ class PenDialog(wx.Dialog): else: self.parent.SetBorderPen(pen) - self.Destroy() - event.Skip() + self.EndModal(wx.ID_OK) def OnCancel(self, event): - - self.Destroy() - event.Skip() + self.EndModal(wx.ID_CANCEL) #--------------------------------------------------------------------------- @@ -532,18 +529,15 @@ class TreeDialog(wx.Dialog): selection = self.listicons.GetSelection() self.parent.SetTreeButtons(selection) - self.Destroy() - event.Skip() + self.EndModal(wx.ID_OK) def OnCancel(self, event): - - self.Destroy() - event.Skip() + self.EndModal(wx.ID_CANCEL) #--------------------------------------------------------------------------- -# Just A Dialog To Select Tree Cehck/Radio Item Icons +# Just A Dialog To Select Tree Check/Radio Item Icons #--------------------------------------------------------------------------- class CheckDialog(wx.Dialog): @@ -669,14 +663,11 @@ class CheckDialog(wx.Dialog): selection = self.listicons.GetSelection() self.parent.SetCheckRadio(selection) - self.Destroy() - event.Skip() + self.EndModal(wx.ID_OK) def OnCancel(self, event): - - self.Destroy() - event.Skip() + self.EndModal(wx.ID_CANCEL) #--------------------------------------------------------------------------- @@ -818,14 +809,11 @@ class TreeIcons(wx.Dialog): self.parent.SetNewIcons(newbitmaps) - self.Destroy() - event.Skip() + self.EndModal(wx.ID_OK) def OnCancel(self, event): - - self.Destroy() - event.Skip() + self.EndModal(wx.ID_CANCEL) def GetBitmap(self, input, which): @@ -1067,6 +1055,8 @@ class HyperTreeListDemo(wx.Frame): self.leftpanel.SetBackgroundColour(wx.WHITE) self.leftpanel.SetScrollRate(20, 20) + self.Fit() + def CreateMenuBar(self): @@ -1392,8 +1382,7 @@ class HyperTreeListDemo(wx.Frame): dlg = PenDialog(self, -1, oldpen=pen, pentype=0) dlg.ShowModal() - - event.Skip() + dlg.Destroy() def OnColumnFont(self, event): @@ -1490,7 +1479,7 @@ class HyperTreeListDemo(wx.Frame): dlg = PenDialog(self, -1, oldpen=pen, pentype=1) dlg.ShowModal() - event.Skip() + dlg.Destroy() def SetBorderPen(self, pen): @@ -1502,16 +1491,14 @@ class HyperTreeListDemo(wx.Frame): dlg = TreeDialog(self, -1, oldicons=self.oldicons) dlg.ShowModal() - - event.Skip() + dlg.Destroy() def OnButtonCheckRadio(self, event): dlg = CheckDialog(self, -1) dlg.ShowModal() - - event.Skip() + dlg.Destroy() def SetTreeButtons(self, selection): @@ -1547,6 +1534,7 @@ class HyperTreeListDemo(wx.Frame): il.Add(wx.Bitmap(bitmap_check, wx.BITMAP_TYPE_ICO)) il.Add(wx.Bitmap(bitmap_uncheck, wx.BITMAP_TYPE_ICO)) + il.Add(wx.Bitmap(bitmap_uncheck, wx.BITMAP_TYPE_ICO)) # TODO: we need an "undetermined check" icon... il.Add(wx.Bitmap(bitmap_flag, wx.BITMAP_TYPE_ICO)) il.Add(wx.Bitmap(bitmap_unflag, wx.BITMAP_TYPE_ICO)) self.tree.SetImageListCheck(16, 16, il) @@ -2166,7 +2154,7 @@ class HyperTreeList(HTL.HyperTreeList): dlg = TreeIcons(self, -1, bitmaps=bitmaps) wx.EndBusyCursor() dlg.ShowModal() - event.Skip() + dlg.Destroy() def SetNewIcons(self, bitmaps): diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 7136d6bf..2c3bd0b2 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3202,14 +3202,15 @@ class TreeListMainWindow(CustomTreeCtrl): else: oldY = y_mid + h//2 - for child in item.GetChildren(): - + children = item.GetChildren() + for child in children: y, x_maincol = self.PaintLevel(child, dc, level+1, y, x_maincol) - # draw vertical line - if not self.HasAGWFlag(wx.TR_NO_LINES): - Y1 = child.GetY() + child.GetHeight()//2 - dc.DrawLine(x, oldY, x, Y1) + + if not self.HasAGWFlag(wx.TR_NO_LINES) and children: + last_child = children[-1] + Y1 = last_child.GetY() + last_child.GetHeight() / 2 + dc.DrawLine(x, oldY, x, Y1) return y, x_maincol @@ -3833,7 +3834,7 @@ class TreeListMainWindow(CustomTreeCtrl): checkimage = item.GetCurrentCheckedImage() if checkimage is not None: - wcheck, hcheck = self._imageListCheck.GetSize(checkimage) + wcheck, hcheck = self._imageListCheck.GetSize(0) wcheck += 2*_MARGIN else: wcheck = 0