Cocoa: make MenuItem State Images configurable

This commit is contained in:
rich2014 2024-06-01 20:47:57 +08:00
parent 1ee73b9b31
commit 3f43638383
2 changed files with 12 additions and 4 deletions

View File

@ -6,7 +6,7 @@ unit CocoaConfig;
interface interface
uses uses
CocoaAll, Cocoa_Extra; CocoaAll, Cocoa_Extra, CocoaConst;
var var
// for compatiblity with LCL 1.8 release. The macOS base is 72ppi // for compatiblity with LCL 1.8 release. The macOS base is 72ppi
@ -26,6 +26,10 @@ var
// default NSTableViewStyle // default NSTableViewStyle
CocoaTableViewStyle : NSTableViewStyle = NSTableViewStyleAutomatic; CocoaTableViewStyle : NSTableViewStyle = NSTableViewStyleAutomatic;
// default Image Name for MenuItem
CocoaDefaultCheckMenuImageName : NSString;
CocoaDefaultRadioMenuImageName : NSString;
{$ifdef COCOALOOPHIJACK} {$ifdef COCOALOOPHIJACK}
// The flag is set to true once hi-jacked loop is finished (at the end of app) // The flag is set to true once hi-jacked loop is finished (at the end of app)
// The flag is checked in Menus to avoid "double" Cmd+Q menu // The flag is checked in Menus to avoid "double" Cmd+Q menu
@ -34,5 +38,9 @@ var
implementation implementation
initialization
CocoaDefaultCheckMenuImageName:= NSSTR('NSMenuCheckmark');
CocoaDefaultRadioMenuImageName:= NSSTR('NSDatePickerCalendarHome');
end. end.

View File

@ -33,7 +33,7 @@ uses
// Widgetset // Widgetset
WSMenus, WSMenus,
// LCL Cocoa // LCL Cocoa
CocoaInt, CocoaMenus, CocoaWSCommon, CocoaUtils, CocoaGDIObjects; CocoaConfig, CocoaInt, CocoaMenus, CocoaWSCommon, CocoaUtils, CocoaGDIObjects;
type type
@ -162,12 +162,12 @@ end;
// used from the MenuMadness example // used from the MenuMadness example
class function TCocoaWSMenuItem.NSMenuCheckmark: NSImage; class function TCocoaWSMenuItem.NSMenuCheckmark: NSImage;
begin begin
Result:=NSImage.imageNamed(NSStringUtf8('NSMenuCheckmark')); Result:=NSImage.imageNamed(CocoaConfig.CocoaDefaultCheckMenuImageName);
end; end;
class function TCocoaWSMenuItem.NSMenuRadio: NSImage; class function TCocoaWSMenuItem.NSMenuRadio: NSImage;
begin begin
Result:=NSImage.imageNamed(NSStringUtf8('NSDatePickerCalendarHome')) Result:=NSImage.imageNamed(CocoaConfig.CocoaDefaultRadioMenuImageName)
end; end;
class function TCocoaWSMenuItem.isSeparator(const ACaption: AnsiString): Boolean; class function TCocoaWSMenuItem.isSeparator(const ACaption: AnsiString): Boolean;