wx.lib.mixins.listctrl: Patches from Toni Brkic:
* Bugfix for TextEditMixin when the view can't be scrolled * Enhancement for ListCtrlAutoWidthMixin, allowing it to manage the width of any column. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33131 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,11 +20,20 @@ available.
|
|||||||
Added GetCount, GetCountRGB, and GetCountColour methods to
|
Added GetCount, GetCountRGB, and GetCountColour methods to
|
||||||
wx.ImageHistogram.
|
wx.ImageHistogram.
|
||||||
|
|
||||||
wxMSW: wx.Window.Refresh changed to explicitly refresh all children
|
wxMSW: wx.Window.Refresh changed to explicitly refresh all children as
|
||||||
as well. Previously it was implicitly done because parents did not
|
well as the parent. Previously it was implicitly done because parents
|
||||||
clip thier children by default. Now that they always clip then
|
did not clip their children by default. Now that they always clip
|
||||||
Refresh needed to do a recursive refresh. This also fixes the
|
children then Refresh needed to be fixed to do a recursive refresh.
|
||||||
Freeze/Thaw problems that some people had with 2.5.4.1.
|
This also fixes the Freeze/Thaw problems that some people had with
|
||||||
|
2.5.4.1.
|
||||||
|
|
||||||
|
wx.SplitterWindow: Send EVT_SPLITTER_SASH_POS_CHANGED only once after
|
||||||
|
end of dragging and not after each CHANGING event (modified patch
|
||||||
|
#1076226)
|
||||||
|
|
||||||
|
wx.glcanvas.GLCanvas: applied patch fixing problems with X server
|
||||||
|
crash when using nVidia cards (patch 1155132)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -176,12 +176,25 @@ class ListCtrlAutoWidthMixin:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
""" Standard initialiser.
|
""" Standard initialiser.
|
||||||
"""
|
"""
|
||||||
self._lastColMinWidth = None
|
self._resizeColMinWidth = None
|
||||||
|
self._resizeColStyle = "LAST"
|
||||||
|
self._resizeCol = 0
|
||||||
self.Bind(wx.EVT_SIZE, self._onResize)
|
self.Bind(wx.EVT_SIZE, self._onResize)
|
||||||
self.Bind(wx.EVT_LIST_COL_END_DRAG, self._onResize, self)
|
self.Bind(wx.EVT_LIST_COL_END_DRAG, self._onResize, self)
|
||||||
|
|
||||||
|
|
||||||
|
def setResizeColumn(self, col):
|
||||||
|
"""
|
||||||
|
Specify which column that should be autosized. Pass either
|
||||||
|
'LAST' or the column number. Default is 'LAST'.
|
||||||
|
"""
|
||||||
|
if col == "LAST":
|
||||||
|
self._resizeColStyle = "LAST"
|
||||||
|
else:
|
||||||
|
self._resizeColStyle = "COL"
|
||||||
|
self._resizeCol = col
|
||||||
|
|
||||||
|
|
||||||
def resizeLastColumn(self, minWidth):
|
def resizeLastColumn(self, minWidth):
|
||||||
""" Resize the last column appropriately.
|
""" Resize the last column appropriately.
|
||||||
|
|
||||||
@@ -196,8 +209,13 @@ class ListCtrlAutoWidthMixin:
|
|||||||
|
|
||||||
'minWidth' is the preferred minimum width for the last column.
|
'minWidth' is the preferred minimum width for the last column.
|
||||||
"""
|
"""
|
||||||
self._lastColMinWidth = minWidth
|
self.resizeCloumn(self, minWidth)
|
||||||
|
|
||||||
|
|
||||||
|
def resizeColumn(self, minWidth):
|
||||||
|
self._resizeColMinWidth = minWidth
|
||||||
self._doResize()
|
self._doResize()
|
||||||
|
|
||||||
|
|
||||||
# =====================
|
# =====================
|
||||||
# == Private Methods ==
|
# == Private Methods ==
|
||||||
@@ -231,8 +249,13 @@ class ListCtrlAutoWidthMixin:
|
|||||||
numCols = self.GetColumnCount()
|
numCols = self.GetColumnCount()
|
||||||
if numCols == 0: return # Nothing to resize.
|
if numCols == 0: return # Nothing to resize.
|
||||||
|
|
||||||
if self._lastColMinWidth == None:
|
if(self._resizeColStyle == "LAST"):
|
||||||
self._lastColMinWidth = self.GetColumnWidth(numCols - 1)
|
resizeCol = self.GetColumnCount()
|
||||||
|
else:
|
||||||
|
resizeCol = self._resizeCol
|
||||||
|
|
||||||
|
if self._resizeColMinWidth == None:
|
||||||
|
self._resizeColMinWidth = self.GetColumnWidth(resizeCol - 1)
|
||||||
|
|
||||||
# We're showing the vertical scrollbar -> allow for scrollbar width
|
# We're showing the vertical scrollbar -> allow for scrollbar width
|
||||||
# NOTE: on GTK, the scrollbar is included in the client size, but on
|
# NOTE: on GTK, the scrollbar is included in the client size, but on
|
||||||
@@ -244,21 +267,23 @@ class ListCtrlAutoWidthMixin:
|
|||||||
listWidth = listWidth - scrollWidth
|
listWidth = listWidth - scrollWidth
|
||||||
|
|
||||||
totColWidth = 0 # Width of all columns except last one.
|
totColWidth = 0 # Width of all columns except last one.
|
||||||
for col in range(numCols-1):
|
for col in range(numCols):
|
||||||
totColWidth = totColWidth + self.GetColumnWidth(col)
|
if col != (resizeCol-1):
|
||||||
|
totColWidth = totColWidth + self.GetColumnWidth(col)
|
||||||
|
|
||||||
lastColWidth = self.GetColumnWidth(numCols - 1)
|
resizeColWidth = self.GetColumnWidth(resizeCol - 1)
|
||||||
|
|
||||||
if totColWidth + self._lastColMinWidth > listWidth:
|
if totColWidth + self._resizeColMinWidth > listWidth:
|
||||||
# We haven't got the width to show the last column at its minimum
|
# We haven't got the width to show the last column at its minimum
|
||||||
# width -> set it to its minimum width and allow the horizontal
|
# width -> set it to its minimum width and allow the horizontal
|
||||||
# scrollbar to show.
|
# scrollbar to show.
|
||||||
self.SetColumnWidth(numCols-1, self._lastColMinWidth)
|
self.SetColumnWidth(resizeCol-1, self._resizeColMinWidth)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Resize the last column to take up the remaining available space.
|
# Resize the last column to take up the remaining available space.
|
||||||
|
|
||||||
self.SetColumnWidth(numCols-1, listWidth - totColWidth)
|
self.SetColumnWidth(resizeCol-1, listWidth - totColWidth)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -394,7 +419,10 @@ class TextEditMixin:
|
|||||||
editor = wx.PreTextCtrl()
|
editor = wx.PreTextCtrl()
|
||||||
|
|
||||||
style =wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB|wx.TE_RICH2
|
style =wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB|wx.TE_RICH2
|
||||||
style |= {wx.LIST_FORMAT_LEFT: wx.TE_LEFT, wx.LIST_FORMAT_RIGHT: wx.TE_RIGHT, wx.LIST_FORMAT_CENTRE : wx.TE_CENTRE}[col_style]
|
style |= {wx.LIST_FORMAT_LEFT: wx.TE_LEFT,
|
||||||
|
wx.LIST_FORMAT_RIGHT: wx.TE_RIGHT,
|
||||||
|
wx.LIST_FORMAT_CENTRE : wx.TE_CENTRE
|
||||||
|
}[col_style]
|
||||||
|
|
||||||
editor.Create(self, -1, style=style)
|
editor.Create(self, -1, style=style)
|
||||||
editor.SetBackgroundColour(wx.Colour(red=255,green=255,blue=175)) #Yellow
|
editor.SetBackgroundColour(wx.Colour(red=255,green=255,blue=175)) #Yellow
|
||||||
@@ -493,7 +521,7 @@ class TextEditMixin:
|
|||||||
|
|
||||||
scrolloffset = self.GetScrollPos(wx.HORIZONTAL)
|
scrolloffset = self.GetScrollPos(wx.HORIZONTAL)
|
||||||
|
|
||||||
# scroll foreward
|
# scroll forward
|
||||||
if x0+x1-scrolloffset > self.GetSize()[0]:
|
if x0+x1-scrolloffset > self.GetSize()[0]:
|
||||||
if wx.Platform == "__WXMSW__":
|
if wx.Platform == "__WXMSW__":
|
||||||
# don't start scrolling unless we really need to
|
# don't start scrolling unless we really need to
|
||||||
@@ -512,6 +540,9 @@ class TextEditMixin:
|
|||||||
# Since we can not programmatically scroll the ListCtrl
|
# Since we can not programmatically scroll the ListCtrl
|
||||||
# close the editor so the user can scroll and open the editor
|
# close the editor so the user can scroll and open the editor
|
||||||
# again
|
# again
|
||||||
|
self.editor.SetValue(self.GetItem(row, col).GetText())
|
||||||
|
self.curRow = row
|
||||||
|
self.curCol = col
|
||||||
self.CloseEditor()
|
self.CloseEditor()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user