From 81f2d6d659680412be1e9d0dabb6f2ed0545efff Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 20 Dec 2011 07:07:02 +0000 Subject: [PATCH] cocoa: intial implementation for GetDeviceCaps git-svn-id: trunk@34314 - --- lcl/interfaces/cocoa/cocoawinapi.inc | 35 +++++++++++++++++++++++++++ lcl/interfaces/cocoa/cocoawinapih.inc | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index b20f97b476..477325a050 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -1191,6 +1191,41 @@ begin {$ENDIF} end; +function TCocoaWidgetSet.GetDeviceCaps(DC: HDC; Index: Integer): Integer; +var + ctx: TCocoaContext; +begin + ctx := CheckDC(DC); + if not Assigned(ctx) then + Exit(0); + + // todo: change implementation for printers + case Index of + HORZSIZE: + Result := Round(NSScreen.mainScreen.frame.size.width / 72 * 25.4); + VERTSIZE: + Result := Round(NSScreen.mainScreen.frame.size.height / 72 * 25.4); + HORZRES: + Result := Round(NSScreen.mainScreen.frame.size.width); + BITSPIXEL: + Result := CGDisplayBitsPerPixel(CGMainDisplayID); + PLANES: + Result := 1; + SIZEPALETTE: + Result := 0; + LOGPIXELSX: + Result := 72; + LOGPIXELSY: + Result := 72; + VERTRES: + Result := Round(NSScreen.mainScreen.frame.size.height); + NUMRESERVED: + Result := 0; + else + DebugLn('TCocoaWidgetSet.GetDeviceCaps TODO Index: ' + DbgS(Index)); + end; +end; + function TCocoaWidgetSet.GetDeviceSize(DC: HDC; var P: TPoint): Boolean; var ctx: TCocoaContext; diff --git a/lcl/interfaces/cocoa/cocoawinapih.inc b/lcl/interfaces/cocoa/cocoawinapih.inc index 6c9e0a977c..d0a4150544 100644 --- a/lcl/interfaces/cocoa/cocoawinapih.inc +++ b/lcl/interfaces/cocoa/cocoawinapih.inc @@ -101,8 +101,8 @@ function GetClipBox(DC : hDC; lpRect : PRect) : Longint; override; function GetClipRGN(DC: hDC; RGN: hRGN): Longint; override; function GetCursorPos(var lpPoint: TPoint ): Boolean; override; function GetDC(hWnd: HWND): HDC; override; -{function GetDCOriginRelativeToWindow(PaintDC: HDC; WindowHandle: HWND; var OriginDiff: TPoint): boolean; override; -function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override; } +{function GetDCOriginRelativeToWindow(PaintDC: HDC; WindowHandle: HWND; var OriginDiff: TPoint): boolean; override;} +function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override; function GetDeviceSize(DC: HDC; var P: TPoint): Boolean; override; {function GetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT): Integer; override;} function GetFocus: HWND; override;