LCL: Toolbar with menu, use MenuItem.Bitmap

This commit is contained in:
Martin 2025-01-04 13:07:06 +01:00
parent ed082bc3ec
commit 99e2074a2d

View File

@ -338,12 +338,18 @@ begin
tmpMenuButton.FMenuItemIndex:= i; tmpMenuButton.FMenuItemIndex:= i;
wglyph := 0; wglyph := 0;
tmpMenuButton.Images := nil; tmpMenuButton.Images := nil;
if Assigned(FMenu.Images) and (FMenu.Items[i].ImageIndex >= 0) then if Assigned(FMenu.Images) and (FMenu.Items[i].ImageIndex >= 0) then begin
if FMenu.Items[i].ImageIndex < FMenu.Images.Count then if FMenu.Items[i].ImageIndex < FMenu.Images.Count then
begin begin
FMenu.Images.GetBitmap(FMenu.Items[i].ImageIndex, tmpMenuButton.Glyph); FMenu.Images.GetBitmap(FMenu.Items[i].ImageIndex, tmpMenuButton.Glyph);
wglyph := tmpMenuButton.Glyph.Width + 5; wglyph := tmpMenuButton.Glyph.Width + 5;
end; end;
end
else
if Assigned(FMenu.Items[i].Bitmap) then begin
tmpMenuButton.Glyph := FMenu.Items[i].Bitmap;
wglyph := tmpMenuButton.Glyph.Width + 5;
end;
tmpMenuButton.OnClick := @MenuButtonClick; tmpMenuButton.OnClick := @MenuButtonClick;
tmpMenuButton.Parent := Self; tmpMenuButton.Parent := Self;
if FMenu.Items[i].Default then tmpMenuButton.Font.Style := [fsBold]; if FMenu.Items[i].Default then tmpMenuButton.Font.Style := [fsBold];
@ -401,6 +407,7 @@ var
SubMenuItemOut.Items[i].GlyphShowMode := SubMenuItemIn.Items[i].GlyphShowMode; SubMenuItemOut.Items[i].GlyphShowMode := SubMenuItemIn.Items[i].GlyphShowMode;
SubMenuItemOut.Items[i].GroupIndex := SubMenuItemIn.Items[i].GroupIndex; SubMenuItemOut.Items[i].GroupIndex := SubMenuItemIn.Items[i].GroupIndex;
SubMenuItemOut.Items[i].Hint := SubMenuItemIn.Items[i].Hint; SubMenuItemOut.Items[i].Hint := SubMenuItemIn.Items[i].Hint;
SubMenuItemOut.Items[i].Bitmap := SubMenuItemIn.Items[i].Bitmap;
SubMenuItemOut.Items[i].ImageIndex := SubMenuItemIn.Items[i].ImageIndex; SubMenuItemOut.Items[i].ImageIndex := SubMenuItemIn.Items[i].ImageIndex;
SubMenuItemOut.Items[i].RadioItem := SubMenuItemIn.Items[i].RadioItem; SubMenuItemOut.Items[i].RadioItem := SubMenuItemIn.Items[i].RadioItem;
SubMenuItemOut.Items[i].RightJustify := SubMenuItemIn.Items[i].RightJustify; SubMenuItemOut.Items[i].RightJustify := SubMenuItemIn.Items[i].RightJustify;