View Issue Details

IDProjectCategoryView StatusLast Update
0018126LazarusWidgetsetpublic2011-03-15 10:00
ReporterAnton KavalenkaAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target Version1.0.0Fixed in Version0.9.31 (SVN) 
Summary0018126: LCL: Default widgetset implementation of CreateRoundRectRgn() is wrong
DescriptionCurrent implementation of CreateRoundRectRgn() (intfbasewinapi.inc)
uses wrong ellipse radius
Steps To ReproduceRun the attached application and press the button.
TagsNo tags attached.
Fixed in Revision29850
LazTarget1.0
WidgetsetGTK 2, Win32/Win64
Attached Files
  • laztest74.zip (128,280 bytes)
  • delphi.PNG (5,260 bytes)
    delphi.PNG (5,260 bytes)
  • lazarus.PNG (6,493 bytes)
    lazarus.PNG (6,493 bytes)
  • createroundrectrgn.patch (3,103 bytes)
    Index: intfbasewinapi.inc
    ===================================================================
    --- intfbasewinapi.inc	(revision 28566)
    +++ intfbasewinapi.inc	(working copy)
    @@ -198,19 +198,23 @@
     function TWidgetSet.CreateRoundRectRgn(X1, Y1, X2, Y2, nWidthEllipse, nHeightEllipse: Integer): HRGN;
     var
       RoundRgn, CornerSquareRgn, CornerCutRgn: HRGN;
    +  nHalfX,nHalfY:integer;
     begin
       Result := 0;
     
       // The resulting region
       Result := CreateRectRgn(X1, Y1, X2, Y2);
     
    +  nHalfX := nWidthEllipse div 2;
    +  nHalfY := nHeightEllipse div 2;
    +
       // We create this region with dummy values just because
       // CombineRgn requires an existing region to receive the result
       CornerCutRgn := CreateRectRgn(0, 0, nWidthEllipse, nHeightEllipse);
     
       // Top-left corner
    -  RoundRgn := CreateEllipticRgn(X1, Y1, X1 + nWidthEllipse * 2, Y1 + nHeightEllipse * 2);
    -  CornerSquareRgn := CreateRectRgn(X1, Y1, X1 + nWidthEllipse, Y1 + nHeightEllipse);
    +  RoundRgn := CreateEllipticRgn(X1, Y1, X1 + nWidthEllipse, Y1 + nHeightEllipse);
    +  CornerSquareRgn := CreateRectRgn(X1, Y1, X1 + nHalfX, Y1 + nHalfY);
       CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
       CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
       CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
    @@ -218,8 +222,8 @@
       DeleteObject(CornerSquareRgn);
     
       // Bottom-left corner
    -  RoundRgn := CreateEllipticRgn(X1, Y2 - nHeightEllipse * 2, X1 + nWidthEllipse * 2, Y2);
    -  CornerSquareRgn := CreateRectRgn(X1, Y2 - nHeightEllipse, X1 + nWidthEllipse, Y2);
    +  RoundRgn := CreateEllipticRgn(X1, Y2 - nHeightEllipse, X1 + nWidthEllipse, Y2);
    +  CornerSquareRgn := CreateRectRgn(X1, Y2 - nHalfX, X1 + nHalfY, Y2);
       CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
       CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
       CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
    @@ -227,8 +231,8 @@
       DeleteObject(CornerSquareRgn);
     
       // Top-Right corner
    -  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse * 2 , Y1, X2, Y1 + nHeightEllipse * 2);
    -  CornerSquareRgn := CreateRectRgn(X2 - nWidthEllipse, Y1, X2, Y1 + nHeightEllipse);
    +  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y1, X2, Y1 + nHeightEllipse);
    +  CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y1, X2, Y1 + nHalfY);
       CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
       CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
       CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
    @@ -236,8 +240,8 @@
       DeleteObject(CornerSquareRgn);
     
       // Bottom-Right corner
    -  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse * 2, Y2 - nHeightEllipse * 2, X2, Y2);
    -  CornerSquareRgn := CreateRectRgn(X2 - nWidthEllipse, Y2 - nHeightEllipse, X2, Y2);
    +  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y2 - nHeightEllipse, X2, Y2);
    +  CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y2 - nHalfY, X2, Y2);
       CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
       CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
       CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
    
    createroundrectrgn.patch (3,103 bytes)

Relationships

related to 0018125 closedPaul Ishenin LCL: CreateRoundRgn() calls default widgetset implementation instead of native WINAPI 

Activities

2010-12-01 13:44

 

laztest74.zip (128,280 bytes)

2010-12-01 13:47

 

delphi.PNG (5,260 bytes)
delphi.PNG (5,260 bytes)

2010-12-01 13:47

 

lazarus.PNG (6,493 bytes)
lazarus.PNG (6,493 bytes)

Anton Kavalenka

2010-12-01 13:47

reporter   ~0043849

Compare the attached screenshots

2010-12-02 12:51

 

createroundrectrgn.patch (3,103 bytes)
Index: intfbasewinapi.inc
===================================================================
--- intfbasewinapi.inc	(revision 28566)
+++ intfbasewinapi.inc	(working copy)
@@ -198,19 +198,23 @@
 function TWidgetSet.CreateRoundRectRgn(X1, Y1, X2, Y2, nWidthEllipse, nHeightEllipse: Integer): HRGN;
 var
   RoundRgn, CornerSquareRgn, CornerCutRgn: HRGN;
+  nHalfX,nHalfY:integer;
 begin
   Result := 0;
 
   // The resulting region
   Result := CreateRectRgn(X1, Y1, X2, Y2);
 
+  nHalfX := nWidthEllipse div 2;
+  nHalfY := nHeightEllipse div 2;
+
   // We create this region with dummy values just because
   // CombineRgn requires an existing region to receive the result
   CornerCutRgn := CreateRectRgn(0, 0, nWidthEllipse, nHeightEllipse);
 
   // Top-left corner
-  RoundRgn := CreateEllipticRgn(X1, Y1, X1 + nWidthEllipse * 2, Y1 + nHeightEllipse * 2);
-  CornerSquareRgn := CreateRectRgn(X1, Y1, X1 + nWidthEllipse, Y1 + nHeightEllipse);
+  RoundRgn := CreateEllipticRgn(X1, Y1, X1 + nWidthEllipse, Y1 + nHeightEllipse);
+  CornerSquareRgn := CreateRectRgn(X1, Y1, X1 + nHalfX, Y1 + nHalfY);
   CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
   CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
   CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
@@ -218,8 +222,8 @@
   DeleteObject(CornerSquareRgn);
 
   // Bottom-left corner
-  RoundRgn := CreateEllipticRgn(X1, Y2 - nHeightEllipse * 2, X1 + nWidthEllipse * 2, Y2);
-  CornerSquareRgn := CreateRectRgn(X1, Y2 - nHeightEllipse, X1 + nWidthEllipse, Y2);
+  RoundRgn := CreateEllipticRgn(X1, Y2 - nHeightEllipse, X1 + nWidthEllipse, Y2);
+  CornerSquareRgn := CreateRectRgn(X1, Y2 - nHalfX, X1 + nHalfY, Y2);
   CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
   CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
   CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
@@ -227,8 +231,8 @@
   DeleteObject(CornerSquareRgn);
 
   // Top-Right corner
-  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse * 2 , Y1, X2, Y1 + nHeightEllipse * 2);
-  CornerSquareRgn := CreateRectRgn(X2 - nWidthEllipse, Y1, X2, Y1 + nHeightEllipse);
+  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y1, X2, Y1 + nHeightEllipse);
+  CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y1, X2, Y1 + nHalfY);
   CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
   CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
   CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
@@ -236,8 +240,8 @@
   DeleteObject(CornerSquareRgn);
 
   // Bottom-Right corner
-  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse * 2, Y2 - nHeightEllipse * 2, X2, Y2);
-  CornerSquareRgn := CreateRectRgn(X2 - nWidthEllipse, Y2 - nHeightEllipse, X2, Y2);
+  RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y2 - nHeightEllipse, X2, Y2);
+  CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y2 - nHalfY, X2, Y2);
   CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
   CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
   CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
createroundrectrgn.patch (3,103 bytes)

Anton Kavalenka

2010-12-02 12:51

reporter   ~0043884

Patch provided

Paul Ishenin

2011-03-15 05:39

manager   ~0046616

Thanks, applied. Please close if ok.

Issue History

Date Modified Username Field Change
2010-12-01 13:44 Anton Kavalenka New Issue
2010-12-01 13:44 Anton Kavalenka File Added: laztest74.zip
2010-12-01 13:44 Anton Kavalenka Widgetset => GTK 2, Win32/Win64
2010-12-01 13:47 Anton Kavalenka File Added: delphi.PNG
2010-12-01 13:47 Anton Kavalenka File Added: lazarus.PNG
2010-12-01 13:47 Anton Kavalenka Note Added: 0043849
2010-12-01 13:57 Vincent Snijders LazTarget => 1.0
2010-12-01 13:57 Vincent Snijders Status new => acknowledged
2010-12-01 13:57 Vincent Snijders Target Version => 1.0.0
2010-12-01 13:57 Vincent Snijders Relationship added related to 0018125
2010-12-02 12:51 Anton Kavalenka File Added: createroundrectrgn.patch
2010-12-02 12:51 Anton Kavalenka Note Added: 0043884
2011-03-15 05:39 Paul Ishenin Fixed in Revision => 29850
2011-03-15 05:39 Paul Ishenin Status acknowledged => resolved
2011-03-15 05:39 Paul Ishenin Fixed in Version => 0.9.31 (SVN)
2011-03-15 05:39 Paul Ishenin Resolution open => fixed
2011-03-15 05:39 Paul Ishenin Assigned To => Paul Ishenin
2011-03-15 05:39 Paul Ishenin Note Added: 0046616
2011-03-15 10:00 Anton Kavalenka Status resolved => closed