Skip to content

Commit

Permalink
themed border color, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextp committed Sep 20, 2020
1 parent 9dbcefa commit 65e0d2a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions win32menustyler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface
TWin32MenuStylerTheme = record
ColorBk: TColor;
ColorBkSelected: TColor;
ColorBorder: TColor; //used only if <>clNone
ColorFont: TColor;
ColorFontDisabled: TColor;
ColorFontShortcut: TColor;
Expand All @@ -25,11 +26,12 @@ TWin32MenuStylerTheme = record
CharSubmenu: WideChar;
FontName: string;
FontSize: integer;
IndentMinPercents: integer;
IndentBigPercents: integer;
IndentIconPercents: integer;
IndentRightPercents: integer;
IndentSubmenuArrowPercents: integer;
//indents in percents of avarage char width
IndentMinPercents: integer; //indent from edges to separator line
IndentBigPercents: integer; //indent from left edge to caption
IndentIconPercents: integer; //indents around the icon
IndentRightPercents: integer; //indent from right edge to end of shortcut text
IndentSubmenuArrowPercents: integer; //indent from right edge to submenu '>' char
end;

type
Expand Down Expand Up @@ -156,10 +158,19 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
IconW:= 0;

if odSelected in AState then
ACanvas.Brush.Color:= MenuStylerTheme.ColorBkSelected
begin
ACanvas.Brush.Color:= MenuStylerTheme.ColorBkSelected;
if MenuStylerTheme.ColorBorder<>clNone then
ACanvas.Pen.Color:= MenuStylerTheme.ColorBorder
else
ACanvas.Pen.Color:= MenuStylerTheme.ColorBkSelected;
ACanvas.Rectangle(ARect);
end
else
begin
ACanvas.Brush.Color:= MenuStylerTheme.ColorBk;
ACanvas.FillRect(ARect);
ACanvas.FillRect(ARect);
end;

Windows.GetTextExtentPoint(ACanvas.Handle, PChar(cSampleShort), Length(cSampleShort), ExtCell);
dxCell:= ExtCell.cx;
Expand Down Expand Up @@ -262,7 +273,7 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
ACanvas.Font.Color:= MenuStylerTheme.ColorFont;

Windows.TextOutW(ACanvas.Handle,
ARect.Right - dxCell*MenuStylerTheme.IndentSubmenuArrowPercents div 100,
ARect.Right - dxCell*MenuStylerTheme.IndentSubmenuArrowPercents div 100 - 2,
Y,
@MenuStylerTheme.CharSubmenu,
1);
Expand Down Expand Up @@ -294,6 +305,7 @@ initialization
begin
ColorBk:= clDkGray;
ColorBkSelected:= clNavy;
ColorBorder:= clNone;
ColorFont:= clWhite;
ColorFontDisabled:= clMedGray;
ColorFontShortcut:= clYellow;
Expand Down

0 comments on commit 65e0d2a

Please sign in to comment.