From 28dc96b03e5f013a655763813a547cf80ca5ba04 Mon Sep 17 00:00:00 2001 From: dmitry Date: Wed, 12 Sep 2018 15:10:05 +0000 Subject: [PATCH] cocoa: support for dynamic tooltip color. #34260 git-svn-id: trunk@58965 - --- lcl/interfaces/cocoa/cocoa_extra.pas | 10 +++++++++- lcl/interfaces/cocoa/cocoaint.pas | 13 +++++++++++++ lcl/interfaces/cocoa/cocoawinapi.inc | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoa_extra.pas b/lcl/interfaces/cocoa/cocoa_extra.pas index c22ec9ee98..2bc604af2d 100644 --- a/lcl/interfaces/cocoa/cocoa_extra.pas +++ b/lcl/interfaces/cocoa/cocoa_extra.pas @@ -126,7 +126,15 @@ type end; const - NSAppKitVersionNumber10_7 = 1138; // defined in NSApplication.h + // defined in NSApplication.h + NSAppKitVersionNumber10_5 = 949; + NSAppKitVersionNumber10_6 = 1038; + NSAppKitVersionNumber10_7 = 1138; + NSAppKitVersionNumber10_8 = 1187; + NSAppKitVersionNumber10_9 = 1265; + NSAppKitVersionNumber10_10 = 1343; + NSAppKitVersionNumber10_11 = 1404; + NSAppKitVersionNumber10_12 = 1504; const diff --git a/lcl/interfaces/cocoa/cocoaint.pas b/lcl/interfaces/cocoa/cocoaint.pas index 2355e65379..3c93e7fefa 100644 --- a/lcl/interfaces/cocoa/cocoaint.pas +++ b/lcl/interfaces/cocoa/cocoaint.pas @@ -173,6 +173,11 @@ var CocoaBasePPI : Integer = 96; // for compatiblity with LCL 1.8 release. The macOS base is 72ppi MainPool : NSAutoreleasePool = nil; + ColorToolTip : TColorRef = $C9FCF9; // default = macosx10.4 yellow color. (See InitInternals below) + // it's likely the tooltip color will change in future. + // Thus the variable is left public, so a user of LCL + // would be able to initialize it properly on start + function CocoaScrollBarSetScrollInfo(bar: TCocoaScrollBar; const ScrollInfo: TScrollInfo): Integer; function CocoaScrollBarGetScrollInfo(bar: TCocoaScrollBar; var ScrollInfo: TScrollInfo): Boolean; procedure NSScrollerGetScrollInfo(docSz, pageSz: CGFloat; rl: NSSCroller; Var ScrollInfo: TScrollInfo); @@ -404,6 +409,14 @@ begin // MacOSX 10.6 reports a lot of warnings during initialization process // adding the autorelease pool for the whole Cocoa widgetset MainPool := NSAutoreleasePool.alloc.init; + + // Apple doesn't provide any reasonable way of aquiring tooltip bk color + // todo: The tooltip color could be different depending on "light" or "dark" + // mode selected in the system. Thus actual Theme Drawing should be used + // and implemeneted. + if NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 then + ColorTooltip := $EDEDED; + end; procedure InternalFinal; diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index 280741258e..e9746502b5 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -1593,7 +1593,7 @@ begin COLOR_3DLIGHT: Result := NSColor.controlHighlightColor;// makes a more consistent result (a very light gray) than controlLightHighlightColor (which is white) COLOR_INFOBK: - Result := NSColor.colorWithCalibratedRed_green_blue_alpha(249 / $FF, 252 / $FF, 201 / $FF, 1); + Result := ColorToNSColor(ColorToolTip); else Result := nil; end;