mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 04:20:07 +01:00
Merge pull request #380 from RobinD42/fix-issue355
Fix the missing checkboxes in CheckListCtrlMixin
This commit is contained in:
@@ -698,7 +698,7 @@ HISTORY:
|
||||
1.1 - Initial version
|
||||
"""
|
||||
|
||||
class CheckListCtrlMixin:
|
||||
class CheckListCtrlMixin(object):
|
||||
"""
|
||||
This is a mixin for ListCtrl which add a checkbox in the first
|
||||
column of each row. It is inspired by limodou's CheckList.py(which
|
||||
@@ -738,8 +738,16 @@ class CheckListCtrlMixin:
|
||||
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.__OnLeftDown_)
|
||||
|
||||
# override the default methods of ListCtrl/ListView
|
||||
self.InsertStringItem = self.__InsertStringItem_
|
||||
# Monkey-patch in a new InsertItem so we can also set the image ID for the item
|
||||
self._origInsertItem = self.InsertItem
|
||||
self.InsertItem = self.__InsertItem_
|
||||
|
||||
|
||||
def __InsertItem_(self, *args, **kw):
|
||||
index = self._origInsertItem(*args, **kw)
|
||||
self.SetItemImage(index, self.uncheck_image)
|
||||
return index
|
||||
|
||||
|
||||
def __CreateBitmap(self, flag=0, size=(16, 16)):
|
||||
"""Create a bitmap of the platforms native checkbox. The flag
|
||||
@@ -748,15 +756,13 @@ class CheckListCtrlMixin:
|
||||
"""
|
||||
bmp = wx.Bitmap(*size)
|
||||
dc = wx.MemoryDC(bmp)
|
||||
dc.SetBackground(wx.WHITE_BRUSH)
|
||||
dc.Clear()
|
||||
wx.RendererNative.Get().DrawCheckBox(self, dc,
|
||||
(0, 0, size[0], size[1]), flag)
|
||||
dc.SelectObject(wx.NullBitmap)
|
||||
return bmp
|
||||
|
||||
def __InsertStringItem_(self, index, label):
|
||||
index = self.InsertItem(index, label, 0)
|
||||
return index
|
||||
|
||||
def __OnLeftDown_(self, evt):
|
||||
(index, flags) = self.HitTest(evt.GetPosition())
|
||||
|
||||
Reference in New Issue
Block a user