cocoa: support for dynamic tooltip color. #34260

git-svn-id: trunk@58965 -
This commit is contained in:
dmitry 2018-09-12 15:10:05 +00:00
parent 8e92c0d649
commit 28dc96b03e
3 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;