# Copyright: (c) 2001 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------------
# Copyright: (c) 2001 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------------
+# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o 2.5 compatability update.
+# o ListCtrlSelectionManagerMix untested.
+#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxColumnSorterMixin -> ColumnSorterMixin
+# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin
+#
the column header is clicked on.
There are a few requirments needed in order for this to work genericly:
1. The combined class must have a GetListCtrl method that
the column header is clicked on.
There are a few requirments needed in order for this to work genericly:
1. The combined class must have a GetListCtrl method that
- returns the wxListCtrl to be sorted, and the list control
- must exist at the time the wxColumnSorterMixin.__init__
+ returns the wx.ListCtrl to be sorted, and the list control
+ must exist at the time the wx.ColumnSorterMixin.__init__
method is called because it uses GetListCtrl.
2. Items in the list control must have a unique data value set
method is called because it uses GetListCtrl.
2. Items in the list control must have a unique data value set
- raise ValueError, "No wxListCtrl available"
- EVT_LIST_COL_CLICK(list, list.GetId(), self.__OnColClick)
+ raise ValueError, "No wx.ListCtrl available"
+ self.Bind(wx.EVT_LIST_COL_CLICK, self.__OnColClick, list)
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
the list, without either a horizontal scroll bar (unless absolutely
necessary) or empty space to the right of the last column.
NOTE: This only works for report-style lists.
the list, without either a horizontal scroll bar (unless absolutely
necessary) or empty space to the right of the last column.
NOTE: This only works for report-style lists.
- EVT_SIZE(self, self._onResize)
- EVT_LIST_COL_END_DRAG(self, self.GetId(), self._onResize)
+ self.Bind(wx.EVT_SIZE, self._onResize)
+ self.Bind(wx.EVT_LIST_COL_END_DRAG, self._onResize, self)
a horizontal scrollbar. Otherwise, we expand the right-most column
to take up the remaining free space in the list.
a horizontal scrollbar. Otherwise, we expand the right-most column
to take up the remaining free space in the list.
you can also call it yourself whenever you want the last column to
be resized appropriately (eg, when adding, removing or resizing
columns).
you can also call it yourself whenever you want the last column to
be resized appropriately (eg, when adding, removing or resizing
columns).
# NOTE: on GTK, the scrollbar is included in the client size, but on
# Windows it is not included
listWidth = self.GetClientSize().width
# NOTE: on GTK, the scrollbar is included in the client size, but on
# Windows it is not included
listWidth = self.GetClientSize().width
def selectBeforePopup(event):
"""Ensures the item the mouse is pointing at is selected before a popup.
def selectBeforePopup(event):
"""Ensures the item the mouse is pointing at is selected before a popup.
if isinstance(ctrl, wxListCtrl):
n, flags = ctrl.HitTest(event.GetPosition())
if n >= 0:
if isinstance(ctrl, wxListCtrl):
n, flags = ctrl.HitTest(event.GetPosition())
if n >= 0:
for i in range(ctrl.GetItemCount()):
ctrl.SetItemState(i, 0, SEL_FOC)
#for i in getListCtrlSelection(ctrl, SEL_FOC):
# ctrl.SetItemState(i, 0, SEL_FOC)
ctrl.SetItemState(n, SEL_FOC, SEL_FOC)
for i in range(ctrl.GetItemCount()):
ctrl.SetItemState(i, 0, SEL_FOC)
#for i in getListCtrlSelection(ctrl, SEL_FOC):
# ctrl.SetItemState(i, 0, SEL_FOC)
ctrl.SetItemState(n, SEL_FOC, SEL_FOC)
class ListCtrlSelectionManagerMix:
"""Mixin that defines a platform independent selection policy
As selection single and multi-select list return the item index or a
list of item indexes respectively.
"""
class ListCtrlSelectionManagerMix:
"""Mixin that defines a platform independent selection policy
As selection single and multi-select list return the item index or a
list of item indexes respectively.
"""
- EVT_RIGHT_DOWN(self, self.OnLCSMRightDown)
- self.Connect(-1, -1, self.wxEVT_DOPOPUPMENU, self.OnLCSMDoPopup)
+ self.Bind(wx.EVT_RIGHT_DOWN, self.OnLCSMRightDown)
+ self.Bind(EVT_DOPOPUPMENU, self.OnLCSMDoPopup)
+# self.Connect(-1, -1, self.wxEVT_DOPOPUPMENU, self.OnLCSMDoPopup)
def OnLCSMDoPopup(self, event):
self.PopupMenu(event.menu, event.pos)
def OnLCSMDoPopup(self, event):
self.PopupMenu(event.menu, event.pos)