The attached patch fixes 2 issues for TSpeedButton:

1) With no Caption, the glyph is centered if Layout is Glyph Left or Glyph right, somewhere up or down with Glyph Top or Glyph Bottom. Reason: in speedbutton.inc, if Caption is empty, Result.CX is set twice to zero while Result.CY is left undetermined.

2) With a Caption, the glyph disappears if the layout is Glyph Bottom or Glyph Right. Reason: the calculation increases Left (or Top) of the destination rectangle of the offset amount, and decreases Right (or Bottom) of the same quantity, determining a negative width (or height)

Regards,

Giuliano Colla
Index: lcl/include/speedbutton.inc
===================================================================
--- lcl/include/speedbutton.inc (revisione 11469)
+++ lcl/include/speedbutton.inc (copia locale)
@@ -871,8 +871,8 @@
   end
   else
   begin
+    Result.CY:= 0;
     Result.CX:= 0;
-    Result.CX:= 0;
   end;
 end;
 
Index: lcl/include/buttonglyph.inc
===================================================================
--- lcl/include/buttonglyph.inc (revisione 11469)
+++ lcl/include/buttonglyph.inc (copia locale)
@@ -102,26 +102,29 @@
   SrcRect := Rect((ImgID*gWidth), 0, ((ImgID+1)*gWidth), gHeight);
   DestRect:=Client;
   
-  if (Offset.X>=0) then begin
+
+  Inc(DestRect.Left, Offset.X);
+  {if (Offset.X>=0) then begin
     Inc(DestRect.Left, Offset.X);
     Dec(DestRect.Right, Offset.X); // image couldn't overlap rigth window edge
   end else begin
     Dec(SrcRect.Left, Offset.X);
     Inc(SrcRect.Right, Offset.X);
-  end;
+  end;}
   src_wh:=SrcRect.Right-SrcRect.Left; dst_wh:=DestRect.Right-DestRect.Left;
   if (dst_wh>src_wh) then
     DestRect.Right:=DestRect.Left+src_wh // if window for image is wider
   else if (dst_wh<src_wh) then
       SrcRect.Right:=SrcRect.Left+dst_wh; // if image not fits in their window 
width
 
-  if (Offset.Y>=0) then begin
+  Inc(DestRect.Top, Offset.Y);
+  {if (Offset.Y>=0) then begin
     Inc(DestRect.Top, Offset.Y);
     Dec(DestRect.Bottom, Offset.Y); // image couldn't overlap bottom window 
edge
   end else begin
     Dec(SrcRect.Top, Offset.Y);
     Inc(SrcRect.Bottom, Offset.Y);
-  end;
+  end;}
   src_wh:=SrcRect.Bottom-SrcRect.Top; dst_wh:=DestRect.Bottom-DestRect.Top;
   if (dst_wh>src_wh) then
     DestRect.Bottom:=DestRect.Top+src_wh // if window for image is higher

Reply via email to