Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. Index: cocoa_extra.pas
  2. ===================================================================
  3. --- cocoa_extra.pas (revision 61033)
  4. +++ cocoa_extra.pas (working copy)
  5. @@ -56,10 +56,17 @@
  6. procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
  7. end;
  8.  
  9. + NSAppearance = objcclass external(NSObject)
  10. + function name: NSString; message 'name';
  11. + class function currentAppearance: NSAppearance; message 'currentAppearance';
  12. + end;
  13. +
  14. NSApplicationFix = objccategory external (NSApplication)
  15. procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
  16. function nextEventMatchingMask_untilDate_inMode_dequeue_(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: ObjCBool): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
  17. procedure postEvent_atStart_(event: NSEvent; flag: ObjCBool); message 'postEvent:atStart:';
  18. +
  19. + function appearance: NSAppearance; message 'appearance'; // 10.14 (10.13)
  20. end;
  21.  
  22. NSButtonFix = objccategory external(NSButton)
  23. @@ -198,6 +205,8 @@
  24. NSAppKitVersionNumber10_10 = 1343;
  25. NSAppKitVersionNumber10_11 = 1404;
  26. NSAppKitVersionNumber10_12 = 1504;
  27. + NSAppKitVersionNumber10_13 = 1561;
  28. + NSAppKitVersionNumber10_14 = 1641.10;
  29.  
  30.  
  31. const
  32. Index: cocoathemes.pas
  33. ===================================================================
  34. --- cocoathemes.pas (revision 61033)
  35. +++ cocoathemes.pas (working copy)
  36. @@ -22,7 +22,7 @@
  37. LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
  38. customdrawndrawers,
  39. // widgetset
  40. - CocoaUtils, CocoaGDIObjects;
  41. + CocoaUtils, CocoaGDIObjects, Cocoa_Extra;
  42.  
  43. type
  44. { TCocoaThemeServices }
  45. @@ -60,8 +60,35 @@
  46. function GetOption(AOption: TThemeOption): Integer; override;
  47. end;
  48.  
  49. +// "dark" is not a good reference, as Apple might add more and more themes
  50. +function IsDarkPossible: Boolean; inline;
  51. +function IsAppDark: Boolean;
  52. +
  53. implementation
  54.  
  55. +function IsDarkPossible: Boolean; inline;
  56. +begin
  57. + Result := NSAppKitVersionNumber > NSAppKitVersionNumber10_12;
  58. +end;
  59. +
  60. +function IsAppDark: Boolean;
  61. +var
  62. + Appear: NSAppearance;
  63. +begin
  64. + if not isDarkPossible then
  65. + begin
  66. + Result := false;
  67. + Exit;
  68. + end;
  69. + if (not NSApplication(NSApp).respondsToSelector(ObjCSelector('appearance:'))) then begin
  70. + Result := false;
  71. + Exit;
  72. + end;
  73. + Appear:=NSApplication(NSApp).appearance;
  74. + Result := Assigned(Appear)
  75. + and Appear.name.isEqualToString(NSSTR('NSAppearanceNameVibrantDark'));
  76. +end;
  77. +
  78. { TCocoaThemeServices }
  79.  
  80. {------------------------------------------------------------------------------
  81. dmitrys-MBP:cocoa dmitry$ svn diff > appeartest.diff
  82. dmitrys-MBP:cocoa dmitry$ cat appeartest.diff
  83. Index: cocoa_extra.pas
  84. ===================================================================
  85. --- cocoa_extra.pas (revision 61033)
  86. +++ cocoa_extra.pas (working copy)
  87. @@ -56,10 +56,17 @@
  88. procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
  89. end;
  90.  
  91. + NSAppearance = objcclass external(NSObject)
  92. + function name: NSString; message 'name';
  93. + class function currentAppearance: NSAppearance; message 'currentAppearance';
  94. + end;
  95. +
  96. NSApplicationFix = objccategory external (NSApplication)
  97. procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
  98. function nextEventMatchingMask_untilDate_inMode_dequeue_(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: ObjCBool): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
  99. procedure postEvent_atStart_(event: NSEvent; flag: ObjCBool); message 'postEvent:atStart:';
  100. +
  101. + function appearance: NSAppearance; message 'appearance'; // 10.14 (10.13)
  102. end;
  103.  
  104. NSButtonFix = objccategory external(NSButton)
  105. @@ -198,6 +205,8 @@
  106. NSAppKitVersionNumber10_10 = 1343;
  107. NSAppKitVersionNumber10_11 = 1404;
  108. NSAppKitVersionNumber10_12 = 1504;
  109. + NSAppKitVersionNumber10_13 = 1561;
  110. + NSAppKitVersionNumber10_14 = 1641.10;
  111.  
  112.  
  113. const
  114. Index: cocoathemes.pas
  115. ===================================================================
  116. --- cocoathemes.pas (revision 61033)
  117. +++ cocoathemes.pas (working copy)
  118. @@ -22,7 +22,7 @@
  119. LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
  120. customdrawndrawers,
  121. // widgetset
  122. - CocoaUtils, CocoaGDIObjects;
  123. + CocoaUtils, CocoaGDIObjects, Cocoa_Extra;
  124.  
  125. type
  126. { TCocoaThemeServices }
  127. @@ -60,8 +60,35 @@
  128. function GetOption(AOption: TThemeOption): Integer; override;
  129. end;
  130.  
  131. +// "dark" is not a good reference, as Apple might add more and more themes
  132. +function IsDarkPossible: Boolean; inline;
  133. +function IsAppDark: Boolean;
  134. +
  135. implementation
  136.  
  137. +function IsDarkPossible: Boolean; inline;
  138. +begin
  139. + Result := NSAppKitVersionNumber > NSAppKitVersionNumber10_12;
  140. +end;
  141. +
  142. +function IsAppDark: Boolean;
  143. +var
  144. + Appear: NSAppearance;
  145. +begin
  146. + if not isDarkPossible then
  147. + begin
  148. + Result := false;
  149. + Exit;
  150. + end;
  151. + if (not NSApplication(NSApp).respondsToSelector(ObjCSelector('appearance:'))) then begin
  152. + Result := false;
  153. + Exit;
  154. + end;
  155. + Appear:=NSApplication(NSApp).appearance;
  156. + Result := Assigned(Appear)
  157. + and Appear.name.isEqualToString(NSSTR('NSAppearanceNameVibrantDark'));
  158. +end;
  159. +
  160. { TCocoaThemeServices }
  161.  
  162. {------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement