mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:59:16 +02:00
cocoa: moved backingScaleFactor to cocoa_extra unit into NSWindowFix category. Removed conflicting (and hacky) NSWindow redeclaration
git-svn-id: trunk@57677 -
This commit is contained in:
parent
055d910ecd
commit
fc6c0627a4
@ -60,8 +60,11 @@ type
|
||||
end;
|
||||
|
||||
NSWindowFix = objccategory external (NSWindow)
|
||||
// 10.4-10.7
|
||||
function userSpaceScaleFactor: CGFloat; message 'userSpaceScaleFactor'; //deprecated
|
||||
// 10.7+
|
||||
procedure toggleFullScreen(sender: id); message 'toggleFullScreen:';
|
||||
function backingScaleFactor: CGFloat; message 'backingScaleFactor';
|
||||
end;
|
||||
|
||||
{// private since 10.5, doesn't seam to do anything in 10.10
|
||||
|
@ -406,10 +406,6 @@ type
|
||||
procedure mouseMoved(event: NSEvent); override;
|
||||
end;
|
||||
|
||||
NSWindow = objcclass external(CocoaAll.NSWindow)
|
||||
function backingScaleFactor: CGFloat; message 'backingScaleFactor';
|
||||
end;
|
||||
|
||||
{ TCocoaWindow }
|
||||
|
||||
TCocoaWindowContent = objcclass;
|
||||
|
@ -8,7 +8,7 @@ interface
|
||||
|
||||
uses
|
||||
Types,
|
||||
CGGeometry, CocoaAll,
|
||||
CGGeometry, CocoaAll, cocoa_extra,
|
||||
Classes, Controls, SysUtils,
|
||||
//
|
||||
WSControls, LCLType, LMessages, LCLProc, Graphics, Forms,
|
||||
@ -1372,11 +1372,29 @@ end;
|
||||
|
||||
class function TCocoaWSWinControl.GetCanvasScaleFactor(const AControl: TControl
|
||||
): Double;
|
||||
var
|
||||
obj: NSObject;
|
||||
win: NSWindow;
|
||||
begin
|
||||
if TWinControl(AControl).HandleAllocated then
|
||||
Result := TCocoaWindow(TWinControl(AControl).Handle).backingScaleFactor // ToDo: use userSpaceScaleFactor for Mac OSX 10.6
|
||||
else
|
||||
win := nil;
|
||||
Result := 1;
|
||||
|
||||
if TWinControl(AControl).HandleAllocated then
|
||||
begin
|
||||
obj := NSObject(TWinControl(AControl).Handle);
|
||||
if obj.isKindOfClass_(NSView) then
|
||||
win := NSView(obj).window
|
||||
else if obj.isKindOfClass_(NSWindow) then
|
||||
win := NSWindow(obj);
|
||||
end;
|
||||
|
||||
if Assigned(win) then
|
||||
begin
|
||||
if win.respondsToSelector( NSSelectorFromString(NSSTR('backingScaleFactor'))) then
|
||||
Result := win.backingScaleFactor
|
||||
else if win.respondsToSelector( NSSelectorFromString(NSSTR('userSpaceScaleFactor'))) then // for older OSX
|
||||
Result := win.userSpaceScaleFactor;
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
||||
|
Loading…
Reference in New Issue
Block a user