37 |
37 |
38 class CustomTree(CT.CustomTreeCtrl): |
38 class CustomTree(CT.CustomTreeCtrl): |
39 |
39 |
40 def __init__(self, *args, **kwargs): |
40 def __init__(self, *args, **kwargs): |
41 CT.CustomTreeCtrl.__init__(self, *args, **kwargs) |
41 CT.CustomTreeCtrl.__init__(self, *args, **kwargs) |
42 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) |
42 #self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) |
43 |
43 |
44 self.BackgroundBitmap = None |
44 self.BackgroundBitmap = None |
45 self.BackgroundAlign = wx.ALIGN_LEFT|wx.ALIGN_TOP |
45 self.BackgroundAlign = wx.ALIGN_LEFT|wx.ALIGN_TOP |
46 |
46 |
47 self.AddMenu = None |
47 self.AddMenu = None |
101 item, flags = self.HitTest(pos) |
101 item, flags = self.HitTest(pos) |
102 |
102 |
103 bitmap_rect = self.GetBitmapRect() |
103 bitmap_rect = self.GetBitmapRect() |
104 if (bitmap_rect.InsideXY(pos.x, pos.y) or |
104 if (bitmap_rect.InsideXY(pos.x, pos.y) or |
105 flags & wx.TREE_HITTEST_NOWHERE) and self.AddMenu is not None: |
105 flags & wx.TREE_HITTEST_NOWHERE) and self.AddMenu is not None: |
106 self.PopupMenuXY(self.AddMenu, pos.x, pos.y) |
106 wx.CallAfter(self.PopupMenuXY, self.AddMenu, pos.x, pos.y) |
107 event.Skip() |
107 event.Skip() |
|
108 |
|
109 def OnEraseBackground(self, event): |
|
110 dc = event.GetDC() |
108 |
111 |
|
112 if not dc: |
|
113 dc = wx.ClientDC(self) |
|
114 rect = self.GetUpdateRegion().GetBox() |
|
115 dc.SetClippingRect(rect) |
|
116 |
|
117 dc.Clear() |
|
118 |
|
119 bitmap_rect = self.GetBitmapRect() |
|
120 dc.DrawBitmap(self.BackgroundBitmap, bitmap_rect.x, bitmap_rect.y) |
|
121 |
109 def OnScroll(self, event): |
122 def OnScroll(self, event): |
110 wx.CallAfter(self.Refresh) |
123 wx.CallAfter(self.Refresh) |
111 event.Skip() |
124 event.Skip() |
112 |
125 |
113 def OnSize(self, event): |
126 def OnSize(self, event): |
114 CT.CustomTreeCtrl.OnSize(self, event) |
127 CT.CustomTreeCtrl.OnSize(self, event) |
115 self.Refresh() |
128 self.Refresh() |
116 |
|
117 def OnPaint(self, event): |
|
118 dc = wx.ClientDC(self) |
|
119 dc.Clear() |
|
120 |
|
121 bitmap_rect = self.GetBitmapRect() |
|
122 dc.DrawBitmap(self.BackgroundBitmap, bitmap_rect.x, bitmap_rect.y) |
|
123 |
|
124 CT.CustomTreeCtrl.OnPaint(self, event) |
|