Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: cocoa_extra.pas
- ===================================================================
- --- cocoa_extra.pas (revision 61033)
- +++ cocoa_extra.pas (working copy)
- @@ -56,10 +56,17 @@
- procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
- end;
- + NSAppearance = objcclass external(NSObject)
- + function name: NSString; message 'name';
- + class function currentAppearance: NSAppearance; message 'currentAppearance';
- + end;
- +
- NSApplicationFix = objccategory external (NSApplication)
- procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
- function nextEventMatchingMask_untilDate_inMode_dequeue_(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: ObjCBool): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
- procedure postEvent_atStart_(event: NSEvent; flag: ObjCBool); message 'postEvent:atStart:';
- +
- + function appearance: NSAppearance; message 'appearance'; // 10.14 (10.13)
- end;
- NSButtonFix = objccategory external(NSButton)
- @@ -198,6 +205,8 @@
- NSAppKitVersionNumber10_10 = 1343;
- NSAppKitVersionNumber10_11 = 1404;
- NSAppKitVersionNumber10_12 = 1504;
- + NSAppKitVersionNumber10_13 = 1561;
- + NSAppKitVersionNumber10_14 = 1641.10;
- const
- Index: cocoathemes.pas
- ===================================================================
- --- cocoathemes.pas (revision 61033)
- +++ cocoathemes.pas (working copy)
- @@ -22,7 +22,7 @@
- LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
- customdrawndrawers,
- // widgetset
- - CocoaUtils, CocoaGDIObjects;
- + CocoaUtils, CocoaGDIObjects, Cocoa_Extra;
- type
- { TCocoaThemeServices }
- @@ -60,8 +60,35 @@
- function GetOption(AOption: TThemeOption): Integer; override;
- end;
- +// "dark" is not a good reference, as Apple might add more and more themes
- +function IsDarkPossible: Boolean; inline;
- +function IsAppDark: Boolean;
- +
- implementation
- +function IsDarkPossible: Boolean; inline;
- +begin
- + Result := NSAppKitVersionNumber > NSAppKitVersionNumber10_12;
- +end;
- +
- +function IsAppDark: Boolean;
- +var
- + Appear: NSAppearance;
- +begin
- + if not isDarkPossible then
- + begin
- + Result := false;
- + Exit;
- + end;
- + if (not NSApplication(NSApp).respondsToSelector(ObjCSelector('appearance:'))) then begin
- + Result := false;
- + Exit;
- + end;
- + Appear:=NSApplication(NSApp).appearance;
- + Result := Assigned(Appear)
- + and Appear.name.isEqualToString(NSSTR('NSAppearanceNameVibrantDark'));
- +end;
- +
- { TCocoaThemeServices }
- {------------------------------------------------------------------------------
- dmitrys-MBP:cocoa dmitry$ svn diff > appeartest.diff
- dmitrys-MBP:cocoa dmitry$ cat appeartest.diff
- Index: cocoa_extra.pas
- ===================================================================
- --- cocoa_extra.pas (revision 61033)
- +++ cocoa_extra.pas (working copy)
- @@ -56,10 +56,17 @@
- procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
- end;
- + NSAppearance = objcclass external(NSObject)
- + function name: NSString; message 'name';
- + class function currentAppearance: NSAppearance; message 'currentAppearance';
- + end;
- +
- NSApplicationFix = objccategory external (NSApplication)
- procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
- function nextEventMatchingMask_untilDate_inMode_dequeue_(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: ObjCBool): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
- procedure postEvent_atStart_(event: NSEvent; flag: ObjCBool); message 'postEvent:atStart:';
- +
- + function appearance: NSAppearance; message 'appearance'; // 10.14 (10.13)
- end;
- NSButtonFix = objccategory external(NSButton)
- @@ -198,6 +205,8 @@
- NSAppKitVersionNumber10_10 = 1343;
- NSAppKitVersionNumber10_11 = 1404;
- NSAppKitVersionNumber10_12 = 1504;
- + NSAppKitVersionNumber10_13 = 1561;
- + NSAppKitVersionNumber10_14 = 1641.10;
- const
- Index: cocoathemes.pas
- ===================================================================
- --- cocoathemes.pas (revision 61033)
- +++ cocoathemes.pas (working copy)
- @@ -22,7 +22,7 @@
- LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
- customdrawndrawers,
- // widgetset
- - CocoaUtils, CocoaGDIObjects;
- + CocoaUtils, CocoaGDIObjects, Cocoa_Extra;
- type
- { TCocoaThemeServices }
- @@ -60,8 +60,35 @@
- function GetOption(AOption: TThemeOption): Integer; override;
- end;
- +// "dark" is not a good reference, as Apple might add more and more themes
- +function IsDarkPossible: Boolean; inline;
- +function IsAppDark: Boolean;
- +
- implementation
- +function IsDarkPossible: Boolean; inline;
- +begin
- + Result := NSAppKitVersionNumber > NSAppKitVersionNumber10_12;
- +end;
- +
- +function IsAppDark: Boolean;
- +var
- + Appear: NSAppearance;
- +begin
- + if not isDarkPossible then
- + begin
- + Result := false;
- + Exit;
- + end;
- + if (not NSApplication(NSApp).respondsToSelector(ObjCSelector('appearance:'))) then begin
- + Result := false;
- + Exit;
- + end;
- + Appear:=NSApplication(NSApp).appearance;
- + Result := Assigned(Appear)
- + and Appear.name.isEqualToString(NSSTR('NSAppearanceNameVibrantDark'));
- +end;
- +
- { TCocoaThemeServices }
- {------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement