mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 00:19:22 +02:00
cocoa: start HCursor implementation
git-svn-id: trunk@33586 -
This commit is contained in:
parent
6493c83448
commit
a920ff2cd0
@ -139,6 +139,21 @@ type
|
|||||||
property Height: Integer read FHeight;
|
property Height: Integer read FHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCocoaCursor }
|
||||||
|
|
||||||
|
TCocoaCursor = class(TObject)
|
||||||
|
private
|
||||||
|
FStandard: Boolean;
|
||||||
|
FBitmap: TCocoaBitmap;
|
||||||
|
FCursor: NSCursor;
|
||||||
|
public
|
||||||
|
constructor CreateStandard(const ACursor: NSCursor);
|
||||||
|
constructor CreateFromBitmap(const ABitmap: TCocoaBitmap; const hotSpot: NSPoint);
|
||||||
|
destructor Destroy; override;
|
||||||
|
function Install: TCocoaCursor;
|
||||||
|
property Standard: Boolean read FStandard;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaTextLayout }
|
{ TCocoaTextLayout }
|
||||||
|
|
||||||
TCocoaTextLayout = class(TObject)
|
TCocoaTextLayout = class(TObject)
|
||||||
@ -361,6 +376,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCocoaCursor }
|
||||||
|
constructor TCocoaCursor.CreateStandard(const ACursor: NSCursor);
|
||||||
|
begin
|
||||||
|
FBitmap := nil;
|
||||||
|
FCursor := ACursor;
|
||||||
|
FStandard := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCocoaCursor.CreateFromBitmap(const ABitmap: TCocoaBitmap; const hotSpot: NSPoint);
|
||||||
|
begin
|
||||||
|
FBitmap := ABitmap;
|
||||||
|
FCursor := NSCursor.alloc.initWithImage_hotSpot(ABitmap.Image, hotSpot);
|
||||||
|
FStandard := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCocoaCursor.Destroy;
|
||||||
|
begin
|
||||||
|
FBitmap.Free;
|
||||||
|
if not Standard then
|
||||||
|
FCursor.release;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCocoaCursor.Install: TCocoaCursor;
|
||||||
|
begin
|
||||||
|
FCursor.set_;
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaContext }
|
{ TCocoaContext }
|
||||||
|
|
||||||
function TCocoaContext.CGContext:CGContextRef;
|
function TCocoaContext.CGContext:CGContextRef;
|
||||||
|
@ -41,6 +41,7 @@ uses
|
|||||||
CocoaProc,
|
CocoaProc,
|
||||||
// LCL
|
// LCL
|
||||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||||
|
Controls,
|
||||||
IntfGraphics, Graphics, CocoaWSFactory;
|
IntfGraphics, Graphics, CocoaWSFactory;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -26,34 +26,32 @@
|
|||||||
* *
|
* *
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
(*
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: CreateStandardCursor
|
Method: CreateStandardCursor
|
||||||
Params: ACursor - Cursor type
|
Params: ACursor - Cursor type
|
||||||
Returns: Cursor object in Carbon for the specified cursor type
|
Returns: Cursor object in Carbon for the specified cursor type
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.CreateStandardCursor(ACursor: SmallInt): hCursor;
|
function TCocoaWidgetSet.CreateStandardCursor(ACursor: SmallInt): HCursor;
|
||||||
var
|
|
||||||
AThemeCursor: ThemeCursor;
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseLCLIntf}
|
case ACursor of
|
||||||
DebugLn('TCarbonWidgetSet.CreateStandardCursor ACursor: ' + DbgS(ACursor));
|
crDefault : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.currentSystemCursor));
|
||||||
{$ENDIF}
|
crArrow : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.arrowCursor));
|
||||||
|
crCross : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.crosshairCursor));
|
||||||
Result := 0;
|
crIBeam : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.IBeamCursor));
|
||||||
if (ACursor >= crLow) and (ACursor <= crHigh) then
|
crSizeNS : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeUpDownCursor));
|
||||||
begin
|
crSizeWE : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeLeftRightCursor));
|
||||||
AThemeCursor := CursorToThemeCursor[TCursor(ACursor)];
|
crSizeN : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeUpCursor));
|
||||||
if AThemeCursor <> kThemeUndefCursor then
|
crSizeW : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeLeftCursor));
|
||||||
Result := hCursor(TCarbonCursor.CreateThemed(AThemeCursor,
|
crSizeE : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeRightCursor));
|
||||||
TCursor(ACursor) = crDefault));
|
crSizeS : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeDownCursor));
|
||||||
|
crNo : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.operationNotAllowedCursor));
|
||||||
|
crHandPoint : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.pointingHandCursor));
|
||||||
|
else
|
||||||
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF VerboseLCLIntf}
|
|
||||||
DebugLn('TCarbonWidgetSet.CreateStandardCursor Result: ' + DbgS(Result));
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: DrawGrid
|
Method: DrawGrid
|
||||||
Params: DC - Handle to device context
|
Params: DC - Handle to device context
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
{function CreateStandardCursor(ACursor: SmallInt): hCursor; override;
|
function CreateStandardCursor(ACursor: SmallInt): hCursor; override;
|
||||||
procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer); override;
|
{procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer); override;
|
||||||
|
|
||||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||||
|
@ -223,19 +223,11 @@ begin
|
|||||||
if IconInfo^.hbmColor = 0 then Exit;
|
if IconInfo^.hbmColor = 0 then Exit;
|
||||||
|
|
||||||
ABitmap := Create32BitAlphaBitmap(TCocoaBitmap(IconInfo^.hbmColor), TCocoaBitmap(IconInfo^.hbmMask));
|
ABitmap := Create32BitAlphaBitmap(TCocoaBitmap(IconInfo^.hbmColor), TCocoaBitmap(IconInfo^.hbmMask));
|
||||||
// For now just ignore the mask
|
|
||||||
Result := HICON(IconInfo^.hbmColor);
|
|
||||||
|
|
||||||
if IconInfo^.fIcon then
|
if IconInfo^.fIcon then
|
||||||
begin
|
|
||||||
Result := HICON(ABitmap)
|
Result := HICON(ABitmap)
|
||||||
end;
|
else
|
||||||
{ else
|
Result := HICON(TCocoaCursor.CreateFromBitmap(ABitmap, GetNSPoint(IconInfo^.xHotSpot, IconInfo^.yHotSpot)));
|
||||||
begin
|
|
||||||
IconInfo^.hbmColor := HBITMAP(ABitmap);
|
|
||||||
IconInfo^.hbmMask := 0;
|
|
||||||
Result := HICON(TCarbonCursor.CreateFromInfo(IconInfo));
|
|
||||||
end;}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaWidgetSet.CreatePenIndirect(const LogPen: TLogPen): HPEN;
|
function TCocoaWidgetSet.CreatePenIndirect(const LogPen: TLogPen): HPEN;
|
||||||
@ -294,6 +286,19 @@ begin
|
|||||||
if Assigned(gdi) then gdi.Release;
|
if Assigned(gdi) then gdi.Release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaWidgetSet.DestroyIcon(Handle: HICON): Boolean;
|
||||||
|
var
|
||||||
|
Ico: TObject;
|
||||||
|
begin
|
||||||
|
Result := Handle <> 0;
|
||||||
|
if not Result then
|
||||||
|
Exit;
|
||||||
|
Ico := TObject(Handle);
|
||||||
|
Result := (Ico is TCocoaBitmap) or (Ico is TCocoaCursor);
|
||||||
|
if Result then
|
||||||
|
Ico.Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCocoaWidgetSet.Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean;
|
function TCocoaWidgetSet.Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean;
|
||||||
var
|
var
|
||||||
ctx : TCocoaContext;
|
ctx : TCocoaContext;
|
||||||
@ -796,6 +801,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaWidgetSet.SetCursor(ACursor: HCURSOR): HCURSOR;
|
||||||
|
begin
|
||||||
|
Result := HCURSOR(TCocoaCursor(ACursor).Install);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCocoaWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
|
||||||
|
var
|
||||||
|
CursorPos: CGPoint;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
CursorPos.X := X;
|
||||||
|
CursorPos.Y := Y;
|
||||||
|
if CGWarpMouseCursorPosition(CursorPos) <> noErr then Exit;
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------- FONT AND TEXT --------------------------------}
|
{------------------------------- FONT AND TEXT --------------------------------}
|
||||||
|
|
||||||
function TCocoaWidgetSet.SetTextColor(DC: HDC; Color: TColorRef): TColorRef;
|
function TCocoaWidgetSet.SetTextColor(DC: HDC; Color: TColorRef): TColorRef;
|
||||||
|
@ -64,9 +64,9 @@ function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; override;
|
|||||||
procedure DeleteCriticalSection(var CritSection: TCriticalSection); override;
|
procedure DeleteCriticalSection(var CritSection: TCriticalSection); override;
|
||||||
{function DeleteDC(hDC: HDC): Boolean; override;}
|
{function DeleteDC(hDC: HDC): Boolean; override;}
|
||||||
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
|
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
|
||||||
{function DestroyCaret(Handle : HWND): Boolean; override;
|
{function DestroyCaret(Handle : HWND): Boolean; override;}
|
||||||
function DestroyIcon(Handle: HICON): Boolean; override;
|
function DestroyIcon(Handle: HICON): Boolean; override;
|
||||||
function DPtoLP(DC: HDC; var Points; Count: Integer): BOOL; override;
|
{function DPtoLP(DC: HDC; var Points; Count: Integer): BOOL; override;
|
||||||
function DrawFocusRect(DC: HDC; const Rect: TRect): boolean; override;
|
function DrawFocusRect(DC: HDC; const Rect: TRect): boolean; override;
|
||||||
function DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean; override;}
|
function DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean; override;}
|
||||||
//function DrawText(DC: HDC; Str: PChar; Count: Integer; var ARect: TRect; Flags: Cardinal): Integer; override;
|
//function DrawText(DC: HDC; Str: PChar; Count: Integer; var ARect: TRect; Flags: Cardinal): Integer; override;
|
||||||
@ -167,10 +167,10 @@ function SetBkMode(DC: HDC; bkMode : Integer) : Integer; override;
|
|||||||
function SetCapture(AHandle: HWND): HWND; override;
|
function SetCapture(AHandle: HWND): HWND; override;
|
||||||
function SetCaretPos(X, Y: Integer): Boolean; override;
|
function SetCaretPos(X, Y: Integer): Boolean; override;
|
||||||
function SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean; override;
|
function SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean; override;
|
||||||
function SetCaretRespondToFocus(handle: HWND; ShowHideOnFocus: boolean): Boolean; override;
|
function SetCaretRespondToFocus(handle: HWND; ShowHideOnFocus: boolean): Boolean; override;}
|
||||||
function SetCursor(ACursor: HCURSOR): HCURSOR; override;
|
function SetCursor(ACursor: HCURSOR): HCURSOR; override;
|
||||||
function SetCursorPos(X, Y: Integer): Boolean; override;
|
function SetCursorPos(X, Y: Integer): Boolean; override;
|
||||||
function SetFocus(hWnd: HWND): HWND; override;
|
{function SetFocus(hWnd: HWND): HWND; override;
|
||||||
function SetForegroundWindow(HWnd: HWND): boolean; override;}
|
function SetForegroundWindow(HWnd: HWND): boolean; override;}
|
||||||
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
|
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
|
||||||
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
|
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user