himselfv / wakan

Japanese and Chinese learning tool with dictionary
39 stars 7 forks source link

Problems with focus painting in dict. results grid when drag-selecting and moving mouse around #155

Closed himselfv closed 11 years ago

himselfv commented 11 years ago

Original report by me.

Originally reported on Google Code with ID 155

Start drag-selecting and move mouse around crossing cells while holding left button.
Focused rows are not completely colored and defocused cells are not always uncolored.

Reported by himselfv on 2013-04-18 10:47:42

himselfv commented 11 years ago
Apparently this bug emerges when DoubleBuffering is disabled for a grid control. With
double buffering enabled everything is okay.

Reported by himselfv on 2013-04-23 07:13:42

himselfv commented 11 years ago
Problems were caused by PaintSelectionRect. When given a clip rect, it messed with Windows
HREGIONS to only draw inside that region -- this was needed because PaintSelectionRect
is called on each DrawCell, and we'd repaint selection times after times otherwise.

This somehow didn't work as expected. I didn't investigate, but either the code was
wrong, or TStringGrid relied on HREGION not being updated (even though I changed it
back before returning), anyway, when you click on a cell and move moves to the cell
above it, this is what should happen:

Cells[0,i-1]: Draw(selected)
Cells[1,i-1]: Draw(selected)
Cells[2,i-1]: Draw(selected)
Cells[0,i]: Draw() //normal
Cells[1,i]: Draw()
Cells[2,i]: Draw()

But somehow messing with HREGIONS resulted in just:

Cells[0,i-1]: Draw(selected)

De-selection for Cells[...,i] never got called, neither did selection for Cells[1+,i-1].

Fixed by not relying on HREGIONS for a puny task of clipping the rectangle to invert
color in. I'm just clipping it manually now; it should even be slightly faster.

Fixed @r511 (along with some drawing optimizations for grids).

Reported by himselfv on 2013-04-23 11:41:20