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
uses
CocoaAll, Cocoa_Extra;
CocoaAll, Cocoa_Extra, CocoaConst;
var
// for compatiblity with LCL 1.8 release. The macOS base is 72ppi
@ -26,6 +26,10 @@ var
// default NSTableViewStyle
CocoaTableViewStyle : NSTableViewStyle = NSTableViewStyleAutomatic;
// default Image Name for MenuItem
CocoaDefaultCheckMenuImageName : NSString;
CocoaDefaultRadioMenuImageName : NSString;
{$ifdef COCOALOOPHIJACK}
// 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
@ -34,5 +38,9 @@ var
implementation
initialization
CocoaDefaultCheckMenuImageName:= NSSTR('NSMenuCheckmark');
CocoaDefaultRadioMenuImageName:= NSSTR('NSDatePickerCalendarHome');
end.

View File

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