Getting cell content to overflow properly in a wx.Grid on both Windows and GTK

Hi

I have a wxPython application that uses a wx.Grid with custom cell
renderers. Cell content should be allowed to overflow into other cells
in each direction.

On GTK this works great: The custom renderer behaves like the stock
cell renderer, i.e. when I do not set a background, I get a white
background that is drawn before the cell renderer is invoked. This is
exactly what I want.

However on Windows, the screen becomes garbled because no background is
drawn at all. Looking at the examples, I should draw a rectangle as the
background. This works great for overflowing into cells that are
lower than or right of an overflowing cell. However, the background of
empty cells that are above or left of an overflowing cell destroy the
overflowing content.

Therefore, I am looking for a method on Windows that allows drawing all
cell backgrounds first and all cell content later.
I googled a bit but did not find anything useful.

Thanks in advance

Martin

Martin Manns wrote:

Hi

I have a wxPython application that uses a wx.Grid with custom cell
renderers. Cell content should be allowed to overflow into other cells
in each direction.

On GTK this works great: The custom renderer behaves like the stock
cell renderer, i.e. when I do not set a background, I get a white
background that is drawn before the cell renderer is invoked. This is
exactly what I want.

However on Windows, the screen becomes garbled because no background is
drawn at all. Looking at the examples, I should draw a rectangle as the
background. This works great for overflowing into cells that are
lower than or right of an overflowing cell. However, the background of
empty cells that are above or left of an overflowing cell destroy the
overflowing content.

Therefore, I am looking for a method on Windows that allows drawing all
cell backgrounds first and all cell content later. I googled a bit but did not find anything useful.

IIRC the Grid class assumes that the cell renderers are drawing their own backgrounds as part of their Draw method.

···

--
Robin Dunn
Software Craftsman

I am using the Draw method. It seems to be called for each cell
starting from bottom-right to top-left. Therefore, drawing the
background with this method erases all overflowing content above and
left of the currently drawn cell.

Can I somehow paint the background, stall the method and resume it
after all backgrounds are drawn? Or should I create a class state
"background_draw_required" and draw the background of all cells only at
the first call of the Draw method?

Martin

···

On Mon, 07 Sep 2009 15:28:44 -0700 Robin Dunn <robin@alldunn.com> wrote:

IIRC the Grid class assumes that the cell renderers are drawing their
own backgrounds as part of their Draw method.

Martin Manns wrote:

···

On Mon, 07 Sep 2009 15:28:44 -0700 > Robin Dunn <robin@alldunn.com> wrote:

IIRC the Grid class assumes that the cell renderers are drawing their own backgrounds as part of their Draw method.

I am using the Draw method. It seems to be called for each cell
starting from bottom-right to top-left. Therefore, drawing the
background with this method erases all overflowing content above and
left of the currently drawn cell.

Can I somehow paint the background, stall the method and resume it
after all backgrounds are drawn? Or should I create a class state
"background_draw_required" and draw the background of all cells only at
the first call of the Draw method?

I think you'll need to look at the neighboring cells to see if they are overflowing into the cell being drawn, and then decide what to do.

--
Robin Dunn
Software Craftsman

I like your idea. Unfortunately, the cell content is user-generated.
I cannot know if content from any cell overlaps the current cell.

I am going to check if the cell that is being drawn is the lowest-right
cell that is visible and if yes draw a big white rectangle over the
whole grid.

Is the first cell for which the Draw method is called always the
lowest-right partly visible cell?

Martin

···

On Tue, 08 Sep 2009 12:11:17 -0700 Robin Dunn <robin@alldunn.com> wrote:

Martin Manns wrote:
> Can I somehow paint the background, stall the method and resume it
> after all backgrounds are drawn? Or should I create a class state
> "background_draw_required" and draw the background of all cells
> only at the first call of the Draw method?

I think you'll need to look at the neighboring cells to see if they
are overflowing into the cell being drawn, and then decide what to do.

Martin Manns wrote:

···

On Tue, 08 Sep 2009 12:11:17 -0700 > Robin Dunn <robin@alldunn.com> wrote:

Martin Manns wrote:

Can I somehow paint the background, stall the method and resume it
after all backgrounds are drawn? Or should I create a class state
"background_draw_required" and draw the background of all cells
only at the first call of the Draw method?

I think you'll need to look at the neighboring cells to see if they
are overflowing into the cell being drawn, and then decide what to do.

I like your idea. Unfortunately, the cell content is user-generated.
I cannot know if content from any cell overlaps the current cell.

I am going to check if the cell that is being drawn is the lowest-right
cell that is visible and if yes draw a big white rectangle over the
whole grid.

Is the first cell for which the Draw method is called always the
lowest-right partly visible cell?

Probably, unless the routine that calculates the cells that intersect the update region is ever changed.

--
Robin Dunn
Software Craftsman