mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 14:59:15 +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;
|
end;
|
||||||
|
|
||||||
NSWindowFix = objccategory external (NSWindow)
|
NSWindowFix = objccategory external (NSWindow)
|
||||||
|
// 10.4-10.7
|
||||||
|
function userSpaceScaleFactor: CGFloat; message 'userSpaceScaleFactor'; //deprecated
|
||||||
// 10.7+
|
// 10.7+
|
||||||
procedure toggleFullScreen(sender: id); message 'toggleFullScreen:';
|
procedure toggleFullScreen(sender: id); message 'toggleFullScreen:';
|
||||||
|
function backingScaleFactor: CGFloat; message 'backingScaleFactor';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{// private since 10.5, doesn't seam to do anything in 10.10
|
{// private since 10.5, doesn't seam to do anything in 10.10
|
||||||
|
@ -406,10 +406,6 @@ type
|
|||||||
procedure mouseMoved(event: NSEvent); override;
|
procedure mouseMoved(event: NSEvent); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
NSWindow = objcclass external(CocoaAll.NSWindow)
|
|
||||||
function backingScaleFactor: CGFloat; message 'backingScaleFactor';
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCocoaWindow }
|
{ TCocoaWindow }
|
||||||
|
|
||||||
TCocoaWindowContent = objcclass;
|
TCocoaWindowContent = objcclass;
|
||||||
|
@ -8,7 +8,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Types,
|
Types,
|
||||||
CGGeometry, CocoaAll,
|
CGGeometry, CocoaAll, cocoa_extra,
|
||||||
Classes, Controls, SysUtils,
|
Classes, Controls, SysUtils,
|
||||||
//
|
//
|
||||||
WSControls, LCLType, LMessages, LCLProc, Graphics, Forms,
|
WSControls, LCLType, LMessages, LCLProc, Graphics, Forms,
|
||||||
@ -1372,11 +1372,29 @@ end;
|
|||||||
|
|
||||||
class function TCocoaWSWinControl.GetCanvasScaleFactor(const AControl: TControl
|
class function TCocoaWSWinControl.GetCanvasScaleFactor(const AControl: TControl
|
||||||
): Double;
|
): Double;
|
||||||
|
var
|
||||||
|
obj: NSObject;
|
||||||
|
win: NSWindow;
|
||||||
begin
|
begin
|
||||||
|
win := nil;
|
||||||
|
Result := 1;
|
||||||
|
|
||||||
if TWinControl(AControl).HandleAllocated then
|
if TWinControl(AControl).HandleAllocated then
|
||||||
Result := TCocoaWindow(TWinControl(AControl).Handle).backingScaleFactor // ToDo: use userSpaceScaleFactor for Mac OSX 10.6
|
begin
|
||||||
else
|
obj := NSObject(TWinControl(AControl).Handle);
|
||||||
Result := 1;
|
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;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
||||||
|
Loading…
Reference in New Issue
Block a user