View Issue Details

IDProjectCategoryView StatusLast Update
0014799LazarusLCLpublic2009-11-13 06:53
Reportercobines Assigned ToJesus Reyes  
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0014799: Automatic scrollbars in TCustomGrid not always correctly invalidated when hidden
DescriptionWhen scrollbars are set to show automatically they are not correctly cleared when they are hidden. See attached pictures. First is the at start of application, second after adding some items so that horizontal scrollbar is displayed, third is when those items are removed and scrollbar is hidden, but not redrawn correctly.

I attached this example application. Reproduce with:
1. Start application
2. Check "More items" box.
3. Uncheck "More items" box.

This happens for horizontal and for vertical scrollbar, but I'll describe more using horizontal scrollbar as reference. It seems to happen only with ssAutoBoth and only because horizontal scrollbar is shown because of vertical scrollbar. I tried adding/removing items both horizontally and vertically at the same time, but then the scrollbars are redrawn correctly. So I think it happens only when one scrollbar is shown/hidden in response to the other scrollbar being shown/hidden (and not because the cells themselves won't fit). In the example app the width of the grid without vertical scrollbar is just enough so that horizontal scrollbar doesn't need to be shown, so maybe this is also the cause why it is not cleared.

I tested with TDrawGrid and TStringGrid. Tried on Linux/GTK2 and Linux/QT4 and Win32. On Win32 you might have to check "Double buffering" box to see this, because after scrollbar is hidden it is still completely visible, but it is a "ghost" control (only picture).

Lazarus SVN 22174
TagsNo tags attached.
Fixed in Revision22436, 22535
WidgetsetGTK 2, Win32/Win64, QT
Attached Files


2009-10-14 18:19


2009-10-14 18:20


shot1.png (8,049 bytes)   
shot1.png (8,049 bytes)   

2009-10-14 18:20


shot2.png (8,712 bytes)   
shot2.png (8,712 bytes)   

2009-10-14 18:20


shot3.png (8,088 bytes)   
shot3.png (8,088 bytes)   


2009-11-05 15:56

reporter   ~0031908

I'm reopening the issue because it is not completely fixed.

On QT and Win32 the bug is fixed.
On GTK1 and GTK2 it is almost fixed, but there is still possiblity that the scrollbars will not be cleared (the attached example still doesn't work correctly for me) - when there is less than 3 pixels between last column and edge of the control.

In TCustomGrid.GetSBVisibility function ClientW is calculated by adding current client width to width of the scrollbar. On GTK1/GTK2 however, the client width without scrollbar is not the same as client width with scrollbar plus size of the scrollbar. At least it is not being reported as such on my system.

I checked how the numbers go on different widgetsets (I did the checking inside GetSBVisibility function). In the following text first number is client width with scrollbar, second is scrollbar width, third is client width without scrollbar.

307 + 15 <> 325 (off by 3)

303 + 15 <> 321 (off by 3)

309 + 16 = 325 (ok)

309 + 12 = 321 (ok)

If the width/height reported by GTK is considered correct, then maybe there could be a workaround made for this widgetset. Maybe there's some additional space/border around the scrollbar on GTK that is not accounted for.

Jesus Reyes

2009-11-06 01:33

developer   ~0031926

I think the gtk/gtk2 theme may be playing a role. Here your sample works in gtk1,gtk2,qt and windows. What gtk2 theme are you using?

using scrollbar metrics seems not reliable in all widgetsets (at least not in gtk1/gtk2), for gtk1 the missing 3 pixel gap was known, but I'm not sure if it-s so for every possible theme. For gtk2 I have not investigated.

I will try to find a solution without scrollbar metrics.


2009-11-06 12:17

reporter   ~0031936

Last edited: 2009-11-06 12:22

You're right, it is dependent on gtk theme. I tried other themes and the number "3" in above calculations was different for other themes. You probably tested on a theme where this additional number is zero.

I poked around the gtkrc file and found out that this additional number is a value of "GtkScrolledWindow::scrollbar-spacing", which is "Number of pixels between the scrollbars and the scrolled window.".

So the width of the window without scrollbar would be:
  width of the window with scrollbar
+ width of scrollbar
+ value of "scrollbar-spacing" property of the window.

GtkScrolledWindow ::scrollbar-spacing = 3 by default for all widgets. I was using CleanIce-Dark theme for testing which doesn't have this value defined, so it was taken as default value - hence window size was off by 3.

Jesus Reyes

2009-11-11 22:04

developer   ~0032063

The metrics for scrollbar spacing was missing anyway so I implemented that for gtk/gtk2.


2009-11-13 06:53

reporter   ~0032103

I have retested and confirm that the issue is now fixed on GTK and GTK2.

Issue History

Date Modified Username Field Change
2009-10-14 18:18 cobines New Issue
2009-10-14 18:18 cobines Widgetset => GTK 2, Win32/Win64, QT
2009-10-14 18:19 cobines File Added: customgridscroll.tar.gz
2009-10-14 18:20 cobines File Added: shot1.png
2009-10-14 18:20 cobines File Added: shot2.png
2009-10-14 18:20 cobines File Added: shot3.png
2009-10-14 20:49 Jesus Reyes Status new => assigned
2009-10-14 20:49 Jesus Reyes Assigned To => Jesus Reyes
2009-11-04 21:23 Jesus Reyes Fixed in Revision => 14799
2009-11-04 21:23 Jesus Reyes LazTarget => 0.9.30
2009-11-04 21:23 Jesus Reyes Status assigned => resolved
2009-11-04 21:23 Jesus Reyes Fixed in Version => 0.9.29 (SVN)
2009-11-04 21:23 Jesus Reyes Resolution open => fixed
2009-11-04 21:24 Jesus Reyes Target Version => 0.9.30
2009-11-05 15:56 cobines Status resolved => assigned
2009-11-05 15:56 cobines Resolution fixed => reopened
2009-11-05 15:56 cobines Note Added: 0031908
2009-11-06 01:33 Jesus Reyes Note Added: 0031926
2009-11-06 01:33 Jesus Reyes Status assigned => feedback
2009-11-06 12:17 cobines Note Added: 0031936
2009-11-06 12:22 cobines Note Edited: 0031936
2009-11-11 22:04 Jesus Reyes Fixed in Revision 14799 => 22436, 22535
2009-11-11 22:04 Jesus Reyes Status feedback => resolved
2009-11-11 22:04 Jesus Reyes Resolution reopened => fixed
2009-11-11 22:04 Jesus Reyes Note Added: 0032063
2009-11-13 06:53 cobines Status resolved => closed
2009-11-13 06:53 cobines Note Added: 0032103