Skip to content

Commit

Permalink
refact
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextp committed Sep 20, 2020
1 parent 32b0cbf commit 89b0b16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions win32menustyler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
var
mi: TMenuItem;
Images: TCustomImageList;
IconW, IconH: integer;
dx, dxCell, dxMin, dxBig, Y: integer;
ExtCell, ExtTall, Ext2: Types.TSize;
NDrawFlags: UINT;
Expand All @@ -164,9 +165,18 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
dxMin:= dxCell * MenuStylerTheme.IndentMinPercents div 100;
dxBig:= dxCell * MenuStylerTheme.IndentBigPercents div 100;

IconW:= 0;
IconH:= 0;
Images:= mi.GetParentMenu.Images;
if Assigned(Images) then
dxBig:= Max(dxBig, Images.Width + dxCell * MenuStylerTheme.IndentIconPercents * 2 div 100);
begin
IconW:= Images.Width;
IconH:= Images.Height;
end;

//todo: support MenuItem.Bitmap
if IconW>0 then
dxBig:= Max(dxBig, IconW + dxCell * MenuStylerTheme.IndentIconPercents * 2 div 100);

if mi.IsLine then
begin
Expand Down Expand Up @@ -210,7 +220,7 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
begin
Images.Draw(ACanvas,
dxCell * MenuStylerTheme.IndentIconPercents div 100,
(ARect.Top+ARect.Bottom-Images.Height) div 2,
(ARect.Top+ARect.Bottom-IconH) div 2,
mi.ImageIndex, not bDisabled);
end
else
Expand Down

0 comments on commit 89b0b16

Please sign in to comment.