View Issue Details

IDProjectCategoryView StatusLast Update
0025452LazarusTAChartpublic2014-01-18 00:30
ReporterwpAssigned ToMaxim Ganetsky 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Platformi86OSLinuxOS VersionUbuntu
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version1.2.0 
Summary0025452: Chartlistbox not showing checkboxes
DescriptionLoading the listbox demo that comes with Lazarus (lazarus/components/tachart/demo/listbox) under Linux and OSX, you'll see that the checkboxes in the listbox are not drawn. At runtime, even the listbox item texts are not drawn either (I don't have OSX, but this is reported by a forum user - http://forum.lazarus.freepascal.org/index.php/topic,23012.msg136799.html).

In the attachment, there's another simple project in which I could verify the bug in Ubuntu. Windows is ok.

The attached patch fixes the bug at least for Ubuntu.

In addition the patch fixes also the problem that the checkboxes are too large in Ubuntu. In the patch, the checkbox size is not derived from the font height, no longer from the SystemMetrics of the menu checkboxes.
TagsNo tags attached.
Fixed in Revision43739
LazTarget-
WidgetsetGTK 2
Attached Files
  • tachartlistbox.pas.patch (1,640 bytes)
    Index: tachartlistbox.pas
    ===================================================================
    --- tachartlistbox.pas	(revision 43585)
    +++ tachartlistbox.pas	(working copy)
    @@ -181,7 +181,7 @@
     implementation
     
     uses
    -  Graphics, Math, LCLIntf, LCLType, SysUtils, Themes,
    +  Graphics, Math, Types, LCLType, LCLIntf, SysUtils, Themes,
       TACustomSource, TADrawerCanvas, TADrawUtils, TAEnumerators, TAGeometry;
     
     procedure Register;
    @@ -189,6 +189,8 @@
       RegisterComponents(CHART_COMPONENT_IDE_PAGE, [TChartListbox]);
     end;
     
    +{ TChartListbox }
    +
     constructor TChartListbox.Create(AOwner: TComponent);
     begin
       inherited Create(AOwner);
    @@ -213,11 +215,12 @@
     begin
       ACheckBoxRect := ZeroRect;
       ASeriesIconRect := ZeroRect;
    -  w := GetSystemMetrics(SM_CYMENUCHECK);
    -  x := 2;
    +
    +  w := Canvas.TextHeight('Tg');
    +  x := 4;
       if cloShowCheckboxes in Options then begin
         with AItemRect do
    -      ACheckboxRect := Bounds(Left + 1, (Top + Bottom - w) div 2, w, w);
    +      ACheckboxRect := Bounds(Left + 4, (Top + Bottom - w) div 2, w, w);
         if cloShowIcons in Options then
           x += ACheckboxRect.Right;
       end
    @@ -297,7 +300,7 @@
       id: IChartDrawer;
       rcb, ricon: TRect;
       te: TThemedElementDetails;
    -  x: Integer;
    +  x, w: Integer;
       ch: Boolean;
     begin
       if Assigned(OnDrawItem) then begin
    @@ -304,9 +307,8 @@
         OnDrawItem(Self, AIndex, ARect, AState);
         exit;
       end;
    -  if
    -    (odPainted in AState) or (FChart = nil) or not InRange(AIndex, 0, Count - 1)
    -  then exit;
    +  if (FChart = nil) or not InRange(AIndex, 0, Count - 1) then
    +    exit;
     
       Canvas.FillRect(ARect);
       CalcRects(ARect, rcb, ricon);
    
    tachartlistbox.pas.patch (1,640 bytes)
  • ChartListbox_Linux.zip (2,455 bytes)

Activities

wp

2013-12-23 13:11

developer  

tachartlistbox.pas.patch (1,640 bytes)
Index: tachartlistbox.pas
===================================================================
--- tachartlistbox.pas	(revision 43585)
+++ tachartlistbox.pas	(working copy)
@@ -181,7 +181,7 @@
 implementation
 
 uses
-  Graphics, Math, LCLIntf, LCLType, SysUtils, Themes,
+  Graphics, Math, Types, LCLType, LCLIntf, SysUtils, Themes,
   TACustomSource, TADrawerCanvas, TADrawUtils, TAEnumerators, TAGeometry;
 
 procedure Register;
@@ -189,6 +189,8 @@
   RegisterComponents(CHART_COMPONENT_IDE_PAGE, [TChartListbox]);
 end;
 
+{ TChartListbox }
+
 constructor TChartListbox.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
@@ -213,11 +215,12 @@
 begin
   ACheckBoxRect := ZeroRect;
   ASeriesIconRect := ZeroRect;
-  w := GetSystemMetrics(SM_CYMENUCHECK);
-  x := 2;
+
+  w := Canvas.TextHeight('Tg');
+  x := 4;
   if cloShowCheckboxes in Options then begin
     with AItemRect do
-      ACheckboxRect := Bounds(Left + 1, (Top + Bottom - w) div 2, w, w);
+      ACheckboxRect := Bounds(Left + 4, (Top + Bottom - w) div 2, w, w);
     if cloShowIcons in Options then
       x += ACheckboxRect.Right;
   end
@@ -297,7 +300,7 @@
   id: IChartDrawer;
   rcb, ricon: TRect;
   te: TThemedElementDetails;
-  x: Integer;
+  x, w: Integer;
   ch: Boolean;
 begin
   if Assigned(OnDrawItem) then begin
@@ -304,9 +307,8 @@
     OnDrawItem(Self, AIndex, ARect, AState);
     exit;
   end;
-  if
-    (odPainted in AState) or (FChart = nil) or not InRange(AIndex, 0, Count - 1)
-  then exit;
+  if (FChart = nil) or not InRange(AIndex, 0, Count - 1) then
+    exit;
 
   Canvas.FillRect(ARect);
   CalcRects(ARect, rcb, ricon);
tachartlistbox.pas.patch (1,640 bytes)

wp

2013-12-23 13:12

developer  

ChartListbox_Linux.zip (2,455 bytes)

wp

2013-12-26 11:53

developer   ~0072052

As reported in the forum (http://forum.lazarus.freepascal.org/index.php/topic,23012.msg136996.html#msg136996), this patch fixes the issue also for OSX (Mavericks).

Maxim Ganetsky

2014-01-16 22:25

developer   ~0072497

Applied with some cleanups, thanks.

Scheduled for merging to fixes_1_2.

Please test and close if OK.

wp

2014-01-17 00:39

developer   ~0072503

Thank you

wp

2014-01-17 22:25

developer   ~0072522

I wonder why all this and the other issues are not marked as "closed" after I click on "Close".

Maxim Ganetsky

2014-01-18 00:30

developer   ~0072524

Strange. Please create a bugreport if it will happen again.

Issue History

Date Modified Username Field Change
2013-12-23 13:10 wp New Issue
2013-12-23 13:11 wp File Added: tachartlistbox.pas.patch
2013-12-23 13:12 wp File Added: ChartListbox_Linux.zip
2013-12-26 11:53 wp Note Added: 0072052
2014-01-16 14:45 Vincent Snijders Assigned To => Alexander S. Klenin
2014-01-16 14:45 Vincent Snijders Status new => assigned
2014-01-16 22:25 Maxim Ganetsky Fixed in Revision => 43739
2014-01-16 22:25 Maxim Ganetsky LazTarget => -
2014-01-16 22:25 Maxim Ganetsky Note Added: 0072497
2014-01-16 22:25 Maxim Ganetsky Status assigned => resolved
2014-01-16 22:25 Maxim Ganetsky Fixed in Version => 1.4
2014-01-16 22:25 Maxim Ganetsky Resolution open => fixed
2014-01-16 22:25 Maxim Ganetsky Assigned To Alexander S. Klenin => Maxim Ganetsky
2014-01-16 22:43 Maxim Ganetsky Fixed in Version 1.4 => 1.2.0
2014-01-17 00:39 wp Note Added: 0072503
2014-01-17 22:25 wp Note Added: 0072522
2014-01-18 00:30 Maxim Ganetsky Note Added: 0072524
2014-01-18 00:30 Maxim Ganetsky Status resolved => closed