@@ -34,7 +34,7 @@ def __init__(self, default_width, max_width, auto_fit, word_wrap=True):
3434 def Draw (self , grid , attr , dc , rect , row , col , isSelected ):
3535 text = grid .GetCellValue (row , col )
3636 dc .SetFont (attr .GetFont ())
37- text = wordwrap .wordwrap (text , grid .GetColSize (col ), dc , breakLongWords = False )
37+ text = wordwrap .wordwrap (text , grid .GetColSize (col ) + 10 , dc , breakLongWords = False )
3838 hAlign , vAlign = attr .GetAlignment ()
3939 if isSelected :
4040 bg = grid .GetSelectionBackground ()
@@ -61,16 +61,14 @@ def GetBestSize(self, grid, attr, dc, row, col):
6161 if len (text ) == 0 :
6262 return dc .GetTextExtent (" " ) # self.default_width
6363
64- # the margin for wordwrap is two widest characters in text + space (W is wide enough)
65- w , h = dc .GetTextExtent (text + "W W" )
64+ w , h = dc .GetTextExtent (text )
6665
6766 if self .word_wrap :
6867 if self .auto_fit :
6968 col_width = min (w , self .max_width )
70- suggest_width = grid .GetColSize (col )
7169 else :
7270 col_width = min (self .default_width , w )
73- suggest_width = col_width
71+ suggest_width = grid . GetColSize ( col ) + dc . GetTextExtent ( "w" )[ 0 ]
7472 text = wordwrap .wordwrap (text , suggest_width , dc , breakLongWords = False )
7573 w , h = dc .GetMultiLineTextExtent (text )
7674 row_height = h
@@ -79,10 +77,10 @@ def GetBestSize(self, grid, attr, dc, row, col):
7977 if self .auto_fit :
8078 col_width = min (w , self .max_width )
8179 else :
82- col_width = min ( w , grid .GetColSize (col ) )
80+ col_width = grid .GetColSize (col )
8381
8482 # do not shrink col size (subtract col margin which is 10 pixels )
85- col_width = max (grid .GetColSize (col )- 10 , col_width )
83+ col_width = max (grid .GetColSize (col ) - 10 , col_width )
8684 return wx .Size (col_width , row_height )
8785
8886 def Clone (self ): # real signature unknown; restored from __doc__
0 commit comments