Skip to content

Commit

Permalink
add 2 theme colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextp committed Sep 25, 2020
1 parent 65e0d2a commit c0c1b08
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions win32menustyler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ interface
TWin32MenuStylerTheme = record
ColorBk: TColor;
ColorBkSelected: TColor;
ColorBorder: TColor; //used only if <>clNone
ColorBkSelectedDisabled: TColor; //used only if <>clNone
ColorSelBorder: TColor; //used only if <>clNone
ColorFont: TColor;
ColorFontSelected: TColor; //used only if <>clNone
ColorFontDisabled: TColor;
ColorFontShortcut: TColor;
CharCheckmark: WideChar;
CharRadiomark: WideChar;
CharSubmenu: WideChar;
FontName: string;
FontSize: integer;
//indents in percents of avarage char width
//indents in percents of average char width
IndentMinPercents: integer; //indent from edges to separator line
IndentBigPercents: integer; //indent from left edge to caption
IndentIconPercents: integer; //indents around the icon
Expand Down Expand Up @@ -146,24 +148,28 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
dx, dxCell, dxMin, dxBig, Y: integer;
ExtCell, ExtTall, Ext2: Types.TSize;
NDrawFlags: UINT;
bDisabled, bInBar, bHasSubmenu: boolean;
bSel, bDisabled, bInBar, bHasSubmenu: boolean;
BufW: UnicodeString;
mark: WideChar;
R: TRect;
begin
mi:= Sender as TMenuItem;
bSel:= odSelected in AState;
bDisabled:= odDisabled in AState;
bInBar:= mi.IsInMenuBar;
bHasSubmenu:= (not bInBar) and (mi.Count>0);
IconW:= 0;

if odSelected in AState then
if bSel then
begin
ACanvas.Brush.Color:= MenuStylerTheme.ColorBkSelected;
if MenuStylerTheme.ColorBorder<>clNone then
ACanvas.Pen.Color:= MenuStylerTheme.ColorBorder
if bDisabled and (MenuStylerTheme.ColorBkSelectedDisabled<>clNone) then
ACanvas.Brush.Color:= MenuStylerTheme.ColorBkSelectedDisabled
else
ACanvas.Pen.Color:= MenuStylerTheme.ColorBkSelected;
ACanvas.Brush.Color:= MenuStylerTheme.ColorBkSelected;
if MenuStylerTheme.ColorSelBorder<>clNone then
ACanvas.Pen.Color:= MenuStylerTheme.ColorSelBorder
else
ACanvas.Pen.Color:= ACanvas.Brush.Color;
ACanvas.Rectangle(ARect);
end
else
Expand Down Expand Up @@ -197,6 +203,9 @@ procedure TWin32MenuStyler.HandleMenuDrawItem(Sender: TObject; ACanvas: TCanvas;

if bDisabled then
ACanvas.Font.Color:= MenuStylerTheme.ColorFontDisabled
else
if bSel and (MenuStylerTheme.ColorFontSelected<>clNone) then
ACanvas.Font.Color:= MenuStylerTheme.ColorFontSelected
else
ACanvas.Font.Color:= MenuStylerTheme.ColorFont;

Expand Down Expand Up @@ -305,8 +314,10 @@ initialization
begin
ColorBk:= clDkGray;
ColorBkSelected:= clNavy;
ColorBorder:= clNone;
ColorBkSelectedDisabled:= clNone;
ColorSelBorder:= clNone;
ColorFont:= clWhite;
ColorFontSelected:= clNone;
ColorFontDisabled:= clMedGray;
ColorFontShortcut:= clYellow;
CharCheckmark:= #$2713;
Expand Down

0 comments on commit c0c1b08

Please sign in to comment.