mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 20:36:09 +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;
|
||||
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 = class(TObject)
|
||||
@ -361,6 +376,35 @@ begin
|
||||
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 }
|
||||
|
||||
function TCocoaContext.CGContext:CGContextRef;
|
||||
|
@ -41,6 +41,7 @@ uses
|
||||
CocoaProc,
|
||||
// LCL
|
||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||
Controls,
|
||||
IntfGraphics, Graphics, CocoaWSFactory;
|
||||
|
||||
type
|
||||
|
@ -26,34 +26,32 @@
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
(*
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: CreateStandardCursor
|
||||
Params: ACursor - Cursor type
|
||||
Returns: Cursor object in Carbon for the specified cursor type
|
||||
------------------------------------------------------------------------------}
|
||||
function TCarbonWidgetSet.CreateStandardCursor(ACursor: SmallInt): hCursor;
|
||||
var
|
||||
AThemeCursor: ThemeCursor;
|
||||
function TCocoaWidgetSet.CreateStandardCursor(ACursor: SmallInt): HCursor;
|
||||
begin
|
||||
{$IFDEF VerboseLCLIntf}
|
||||
DebugLn('TCarbonWidgetSet.CreateStandardCursor ACursor: ' + DbgS(ACursor));
|
||||
{$ENDIF}
|
||||
|
||||
Result := 0;
|
||||
if (ACursor >= crLow) and (ACursor <= crHigh) then
|
||||
begin
|
||||
AThemeCursor := CursorToThemeCursor[TCursor(ACursor)];
|
||||
if AThemeCursor <> kThemeUndefCursor then
|
||||
Result := hCursor(TCarbonCursor.CreateThemed(AThemeCursor,
|
||||
TCursor(ACursor) = crDefault));
|
||||
case ACursor of
|
||||
crDefault : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.currentSystemCursor));
|
||||
crArrow : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.arrowCursor));
|
||||
crCross : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.crosshairCursor));
|
||||
crIBeam : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.IBeamCursor));
|
||||
crSizeNS : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeUpDownCursor));
|
||||
crSizeWE : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeLeftRightCursor));
|
||||
crSizeN : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeUpCursor));
|
||||
crSizeW : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeLeftCursor));
|
||||
crSizeE : Result := HCursor(TCocoaCursor.CreateStandard(NSCursor.resizeRightCursor));
|
||||
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;
|
||||
|
||||
{$IFDEF VerboseLCLIntf}
|
||||
DebugLn('TCarbonWidgetSet.CreateStandardCursor Result: ' + DbgS(Result));
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
(*
|
||||
{------------------------------------------------------------------------------
|
||||
Method: DrawGrid
|
||||
Params: DC - Handle to device context
|
||||
|
@ -25,8 +25,8 @@
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
{function CreateStandardCursor(ACursor: SmallInt): hCursor; override;
|
||||
procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer); override;
|
||||
function CreateStandardCursor(ACursor: SmallInt): hCursor; override;
|
||||
{procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer); override;
|
||||
|
||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||
|
@ -223,19 +223,11 @@ begin
|
||||
if IconInfo^.hbmColor = 0 then Exit;
|
||||
|
||||
ABitmap := Create32BitAlphaBitmap(TCocoaBitmap(IconInfo^.hbmColor), TCocoaBitmap(IconInfo^.hbmMask));
|
||||
// For now just ignore the mask
|
||||
Result := HICON(IconInfo^.hbmColor);
|
||||
|
||||
if IconInfo^.fIcon then
|
||||
begin
|
||||
Result := HICON(ABitmap)
|
||||
end;
|
||||
{ else
|
||||
begin
|
||||
IconInfo^.hbmColor := HBITMAP(ABitmap);
|
||||
IconInfo^.hbmMask := 0;
|
||||
Result := HICON(TCarbonCursor.CreateFromInfo(IconInfo));
|
||||
end;}
|
||||
else
|
||||
Result := HICON(TCocoaCursor.CreateFromBitmap(ABitmap, GetNSPoint(IconInfo^.xHotSpot, IconInfo^.yHotSpot)));
|
||||
end;
|
||||
|
||||
function TCocoaWidgetSet.CreatePenIndirect(const LogPen: TLogPen): HPEN;
|
||||
@ -294,6 +286,19 @@ begin
|
||||
if Assigned(gdi) then gdi.Release;
|
||||
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;
|
||||
var
|
||||
ctx : TCocoaContext;
|
||||
@ -796,6 +801,23 @@ begin
|
||||
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 --------------------------------}
|
||||
|
||||
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;
|
||||
{function DeleteDC(hDC: HDC): 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 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 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;
|
||||
@ -167,10 +167,10 @@ function SetBkMode(DC: HDC; bkMode : Integer) : Integer; override;
|
||||
function SetCapture(AHandle: HWND): HWND; override;
|
||||
function SetCaretPos(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 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 SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
|
||||
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
|
||||
|
Loading…
Reference in New Issue
Block a user