When changing the attributes of cells (font, bg Color, etc) in an
custom wxGrid-derived class, the cell's "Overflow" flag keeps getting
reset
to
'True'. However, calls to SetCellOverflow() are not doing anything
and seem to be ignored. Do I have to override the function, since I'm
using a call inherited from wxGrid and not a wxGrid itself? If so,
how do I do that when the functionality is buried in the precompiled
gridc.pyd? I've been banging my head against this thing for hours....
Please create a small sample of this problem...
Ok, here is the smallest sample I could pull out. From playing around with
the code, it looks like the error only shows up when I use the AVVirtualTable
class, which is a replacement for the wxPyGridTableBase class. Is there
a call I'm missing somewhere in the implementation? I'm sorry to have included
so much code, but this is part of a much larger system and I wanted to recreate
the system as closely as I could.
If you run the code as-is everything should work fine. Uncommenting lines
213 and 214 causes the overflow problem on the center cell by changing the
font.
When changing the attributes of cells (font, bg Color, etc) in an
custom wxGrid-derived class, the cell's "Overflow" flag keeps getting
reset
to
'True'. However, calls to SetCellOverflow() are not doing anything
and seem to be ignored. Do I have to override the function, since I'm
using a call inherited from wxGrid and not a wxGrid itself? If so,
how do I do that when the functionality is buried in the precompiled
gridc.pyd? I've been banging my head against this thing for hours....
Please create a small sample of this problem...
Ok, here is the smallest sample I could pull out. From playing around with
the code, it looks like the error only shows up when I use the AVVirtualTable
class, which is a replacement for the wxPyGridTableBase class. Is there
a call I'm missing somewhere in the implementation? I'm sorry to have included
so much code, but this is part of a much larger system and I wanted to recreate
the system as closely as I could.
If you run the code as-is everything should work fine. Uncommenting lines
213 and 214 causes the overflow problem on the center cell by changing the
font.
Okay, here's the deal. When you set the font for that cell you are also giving it a cell-specific wxGridCellAttr. Since there is also an attr object for the row the two are merged whenever the attributes for the cell are needed. There is a bug in the merge function in that it doesn't do anything about the overflow flag and so it is always set to the default of True.
I can check in a fix but it won't be totally correct because to do it the right way would require a change in the binary layout of a class, and that is a no-no in 2.4. The only binary compatible change I can think of would have the wrong precedence order, IOW, col and row attrs would have higher precedence than cell attrs...
A workaround that you can do in your sample is to have the table also provide the attributes for cells on demand. You can override GetAttr(self, row, col, kind) in your table class and return instances of wxGridCellAttr that have been IncRef()'d. Then you can handle merging attributes (or not) however you wish. If you still want to be able to set attributes from the grid API then you need to override SetAttr too.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I can check in a fix but it won't be totally correct because to do it the right way would require a change in the binary layout of a class, and that is a no-no in 2.4. The only binary compatible change I can think of would have the wrong precedence order, IOW, col and row attrs would have higher precedence than cell attrs...
I've found a way to fix this in a binary compatible way, so the next release will do the merge (almost) properly. You'll still need to set the overflow on the individual cell attribute though.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!