mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 22:40:56 +02:00
Carbon intf: implemented Caret
- fixed bug #0010058 Carbon TStatusBar is made transparent by its panels - implemented TextFractional property git-svn-id: trunk@12895 -
This commit is contained in:
parent
9466bf997c
commit
e92a45abb8
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2785,6 +2785,7 @@ lcl/interfaces/carbon/README.txt svneol=native#text/plain
|
|||||||
lcl/interfaces/carbon/carbonbars.pp svneol=native#text/pascal
|
lcl/interfaces/carbon/carbonbars.pp svneol=native#text/pascal
|
||||||
lcl/interfaces/carbon/carbonbuttons.pp svneol=native#text/pascal
|
lcl/interfaces/carbon/carbonbuttons.pp svneol=native#text/pascal
|
||||||
lcl/interfaces/carbon/carboncanvas.pp svneol=native#text/pascal
|
lcl/interfaces/carbon/carboncanvas.pp svneol=native#text/pascal
|
||||||
|
lcl/interfaces/carbon/carboncaret.pas svneol=native#text/pascal
|
||||||
lcl/interfaces/carbon/carbonclipboard.pp svneol=native#text/pascal
|
lcl/interfaces/carbon/carbonclipboard.pp svneol=native#text/pascal
|
||||||
lcl/interfaces/carbon/carbondbgconsts.pp svneol=native#text/pascal
|
lcl/interfaces/carbon/carbondbgconsts.pp svneol=native#text/pascal
|
||||||
lcl/interfaces/carbon/carbondebug.inc svneol=native#text/plain
|
lcl/interfaces/carbon/carbondebug.inc svneol=native#text/plain
|
||||||
|
@ -81,6 +81,7 @@ type
|
|||||||
FClipRegion: TCarbonRegion;
|
FClipRegion: TCarbonRegion;
|
||||||
|
|
||||||
FSavedDCList: TFPObjectList;
|
FSavedDCList: TFPObjectList;
|
||||||
|
FTextFractional: Boolean;
|
||||||
|
|
||||||
procedure SetBkColor(const AValue: TColor);
|
procedure SetBkColor(const AValue: TColor);
|
||||||
procedure SetBkMode(const AValue: Integer);
|
procedure SetBkMode(const AValue: Integer);
|
||||||
@ -116,8 +117,10 @@ type
|
|||||||
function ExtTextOut(X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
|
function ExtTextOut(X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
|
||||||
procedure FillRect(Rect: TRect; Brush: TCarbonBrush);
|
procedure FillRect(Rect: TRect; Brush: TCarbonBrush);
|
||||||
procedure Frame3D(var ARect: TRect; const FrameWidth: integer; const Style: TBevelCut);
|
procedure Frame3D(var ARect: TRect; const FrameWidth: integer; const Style: TBevelCut);
|
||||||
|
function GetClipRect: TRect;
|
||||||
function GetTextExtentPoint(Str: PChar; Count: Integer; var Size: TSize): Boolean;
|
function GetTextExtentPoint(Str: PChar; Count: Integer; var Size: TSize): Boolean;
|
||||||
function GetTextMetrics(var TM: TTextMetric): Boolean;
|
function GetTextMetrics(var TM: TTextMetric): Boolean;
|
||||||
|
procedure InvertRectangle(X1, Y1, X2, Y2: Integer);
|
||||||
procedure LineTo(X, Y: Integer);
|
procedure LineTo(X, Y: Integer);
|
||||||
procedure PolyBezier(Points: PPoint; NumPts: Integer; Filled, Continuous: boolean);
|
procedure PolyBezier(Points: PPoint; NumPts: Integer; Filled, Continuous: boolean);
|
||||||
procedure Polygon(Points: PPoint; NumPts: Integer; Winding: boolean);
|
procedure Polygon(Points: PPoint; NumPts: Integer; Winding: boolean);
|
||||||
@ -144,6 +147,8 @@ type
|
|||||||
|
|
||||||
property ROP2: Integer read FROP2 write SetROP2;
|
property ROP2: Integer read FROP2 write SetROP2;
|
||||||
property PenPos: TPoint read FPenPos write FPenPos;
|
property PenPos: TPoint read FPenPos write FPenPos;
|
||||||
|
|
||||||
|
property TextFractional: Boolean read FTextFractional write FTextFractional;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonScreenContext }
|
{ TCarbonScreenContext }
|
||||||
@ -164,6 +169,7 @@ type
|
|||||||
function GetSize: TPoint; override;
|
function GetSize: TPoint; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TCarbonWidget);
|
constructor Create(AOwner: TCarbonWidget);
|
||||||
|
procedure Reset; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonBitmapContext }
|
{ TCarbonBitmapContext }
|
||||||
@ -389,17 +395,19 @@ begin
|
|||||||
FBkBrush := TCarbonBrush.Create(False);
|
FBkBrush := TCarbonBrush.Create(False);
|
||||||
FTextBrush := TCarbonBrush.Create(False);
|
FTextBrush := TCarbonBrush.Create(False);
|
||||||
|
|
||||||
FCurrentPen := BlackPen;
|
FCurrentPen := DefaultPen;
|
||||||
FCurrentPen.Select;
|
FCurrentPen.Select;
|
||||||
FCurrentBrush := WhiteBrush;
|
FCurrentBrush := DefaultBrush;
|
||||||
FCurrentBrush.Select;
|
FCurrentBrush.Select;
|
||||||
FCurrentFont := StockSystemFont;
|
FCurrentFont := DefaultFont;
|
||||||
FCurrentFont.Select;
|
FCurrentFont.Select;
|
||||||
|
|
||||||
FClipRegion := TCarbonRegion.Create;
|
FClipRegion := TCarbonRegion.Create;
|
||||||
|
|
||||||
FCurrentRegion := FClipRegion;
|
FCurrentRegion := FClipRegion;
|
||||||
FCurrentRegion.Select;
|
FCurrentRegion.Select;
|
||||||
|
|
||||||
|
FTextFractional := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -446,7 +454,7 @@ begin
|
|||||||
// set raster operation to copy
|
// set raster operation to copy
|
||||||
FROP2 := R2_COPYPEN;
|
FROP2 := R2_COPYPEN;
|
||||||
|
|
||||||
CurrentFont := StockSystemFont;
|
CurrentFont := DefaultFont;
|
||||||
|
|
||||||
if CGContext <> nil then
|
if CGContext <> nil then
|
||||||
begin
|
begin
|
||||||
@ -458,8 +466,8 @@ begin
|
|||||||
CGContextSetShouldAntialias(CGContext, 1);
|
CGContextSetShouldAntialias(CGContext, 1);
|
||||||
|
|
||||||
// set initial pen, brush and font
|
// set initial pen, brush and font
|
||||||
CurrentPen := BlackPen;
|
CurrentPen := DefaultPen;
|
||||||
CurrentBrush := WhiteBrush;
|
CurrentBrush := DefaultBrush;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -645,16 +653,18 @@ begin
|
|||||||
if OSError(ATSUSetLayoutControls(ALayout, 1, @Tag, @DataSize, @PValue),
|
if OSError(ATSUSetLayoutControls(ALayout, 1, @Tag, @DataSize, @PValue),
|
||||||
Self, SName, 'ATSUSetLayoutControls', 'LineRotation') then Exit;
|
Self, SName, 'ATSUSetLayoutControls', 'LineRotation') then Exit;
|
||||||
|
|
||||||
// disable fractional positions of glyphs in layout
|
if not TextFractional then
|
||||||
Tag := kATSULineLayoutOptionsTag;
|
begin
|
||||||
DataSize := SizeOf(ATSLineLayoutOptions);
|
// disable fractional positions of glyphs in layout
|
||||||
|
Tag := kATSULineLayoutOptionsTag;
|
||||||
Options := kATSLineFractDisable or kATSLineDisableAutoAdjustDisplayPos or
|
DataSize := SizeOf(ATSLineLayoutOptions);
|
||||||
kATSLineDisableAllLayoutOperations or kATSLineUseDeviceMetrics;
|
|
||||||
PValue := @Options;
|
|
||||||
if OSError(ATSUSetLayoutControls(ALayout, 1, @Tag, @DataSize, @PValue),
|
|
||||||
Self, SName, 'ATSUSetLayoutControls', 'LineLayoutOptions') then Exit;
|
|
||||||
|
|
||||||
|
Options := kATSLineFractDisable or kATSLineDisableAutoAdjustDisplayPos or
|
||||||
|
kATSLineDisableAllLayoutOperations or kATSLineUseDeviceMetrics;
|
||||||
|
PValue := @Options;
|
||||||
|
if OSError(ATSUSetLayoutControls(ALayout, 1, @Tag, @DataSize, @PValue),
|
||||||
|
Self, SName, 'ATSUSetLayoutControls', 'LineLayoutOptions') then Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// set layout context
|
// set layout context
|
||||||
Tag := kATSUCGContextTag;
|
Tag := kATSUCGContextTag;
|
||||||
@ -836,6 +846,8 @@ const
|
|||||||
SName = 'ExtTextOut';
|
SName = 'ExtTextOut';
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
//DebugLn('TCarbonDeviceContext.ExtTextOut ' + DbgS(X) + ', ' + DbgS(Y) + ' R: ' + DbgS(Rect^) +
|
||||||
|
// ' S: ' + Str + ' C: ' + DbgS(Count));
|
||||||
|
|
||||||
if not BeginTextRender(Str, Count, TextLayout) then
|
if not BeginTextRender(Str, Count, TextLayout) then
|
||||||
begin
|
begin
|
||||||
@ -930,8 +942,6 @@ var
|
|||||||
const
|
const
|
||||||
SName = 'Frame3D';
|
SName = 'Frame3D';
|
||||||
begin
|
begin
|
||||||
if CurrentBrush.Solid then FillRect(ARect, CurrentBrush);
|
|
||||||
|
|
||||||
if Style = bvRaised then
|
if Style = bvRaised then
|
||||||
begin
|
begin
|
||||||
D := GetCarbonThemeMetric(kThemeMetricPrimaryGroupBoxContentInset, 1);
|
D := GetCarbonThemeMetric(kThemeMetricPrimaryGroupBoxContentInset, 1);
|
||||||
@ -953,6 +963,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonDeviceContext.GetClipRect
|
||||||
|
Returns: Clipping rectangle
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TCarbonDeviceContext.GetClipRect: TRect;
|
||||||
|
begin
|
||||||
|
Result := CGRectToRect(CGContextGetClipBoundingBox(CGContext));
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonDeviceContext.GetTextExtentPoint
|
Method: TCarbonDeviceContext.GetTextExtentPoint
|
||||||
Params: Str - Text string
|
Params: Str - Text string
|
||||||
@ -1070,6 +1089,29 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonDeviceContext.InvertRectangle
|
||||||
|
Params: X1 - X-coordinate of bounding rectangle's upper-left corner
|
||||||
|
Y1 - Y-coordinate of bounding rectangle's upper-left corner
|
||||||
|
X2 - X-coordinate of bounding rectangle's lower-right corner
|
||||||
|
Y2 - Y-coordinate of bounding rectangle's lower-right corner
|
||||||
|
|
||||||
|
Draws an inverted rectangle.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TCarbonDeviceContext.InvertRectangle(X1, Y1, X2, Y2: Integer);
|
||||||
|
begin
|
||||||
|
// save dest context
|
||||||
|
CGContextSaveGState(CGContext);
|
||||||
|
try
|
||||||
|
WhiteBrush.Apply(Self, False);
|
||||||
|
CGContextSetBlendMode(CGContext, kCGBlendModeDifference);
|
||||||
|
|
||||||
|
CGContextFillRect(CGContext, GetCGRectSorted(X1, Y1, X2, Y2));
|
||||||
|
finally
|
||||||
|
CGContextRestoreGState(CGContext);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonDeviceContext.LineTo
|
Method: TCarbonDeviceContext.LineTo
|
||||||
Params: X - X-coordinate of line's ending point
|
Params: X - X-coordinate of line's ending point
|
||||||
@ -1423,6 +1465,30 @@ begin
|
|||||||
Reset;
|
Reset;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonControlContext.Reset
|
||||||
|
|
||||||
|
Resets the control context properties to defaults (pen, brush, ...)
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TCarbonControlContext.Reset;
|
||||||
|
begin
|
||||||
|
inherited Reset;
|
||||||
|
|
||||||
|
if CGContext <> nil then
|
||||||
|
if CurrentBrush <> nil then // apply control background color
|
||||||
|
begin
|
||||||
|
if FOwner.LCLObject.Color <> clBtnFace then
|
||||||
|
CurrentBrush.SetColor(FOwner.LCLObject.Color, True)
|
||||||
|
else
|
||||||
|
CurrentBrush.SetColor(FOwner.LCLObject.Color, False);
|
||||||
|
|
||||||
|
CurrentBrush.Apply(Self, False);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FOwner.LCLObject.Font.Handle <> 0 then
|
||||||
|
CurrentFont := TCarbonFont(FOwner.LCLObject.Font.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCarbonBitmapContext }
|
{ TCarbonBitmapContext }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
359
lcl/interfaces/carbon/carboncaret.pas
Normal file
359
lcl/interfaces/carbon/carboncaret.pas
Normal file
@ -0,0 +1,359 @@
|
|||||||
|
{
|
||||||
|
/***************************************************************************
|
||||||
|
CarbonCaret.pas - Carbon Caret Emulation
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
copyright (c) Andreas Hausladen
|
||||||
|
|
||||||
|
adopted for Lazarus and Carbon by Lazarus Team
|
||||||
|
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
*****************************************************************************
|
||||||
|
* *
|
||||||
|
* This file is part of the Lazarus Component Library (LCL) *
|
||||||
|
* *
|
||||||
|
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||||
|
* for details about the copyright. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* *
|
||||||
|
*****************************************************************************
|
||||||
|
}
|
||||||
|
|
||||||
|
unit CarbonCaret;
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
// debugging defines
|
||||||
|
{$I carbondebug.inc}
|
||||||
|
|
||||||
|
uses
|
||||||
|
// Bindings
|
||||||
|
FPCMacOSAll,
|
||||||
|
// Free Pascal
|
||||||
|
Classes, SysUtils, Types,
|
||||||
|
// Widgetset
|
||||||
|
CarbonDef, CarbonGDIObjects,
|
||||||
|
// LCL
|
||||||
|
LCLType, LCLIntf, LCLProc, Graphics, ExtCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TEmulatedCaret }
|
||||||
|
|
||||||
|
TEmulatedCaret = class(TComponent)
|
||||||
|
private
|
||||||
|
FTimer: TTimer;
|
||||||
|
FUpdating: Boolean;
|
||||||
|
FOldRect: TRect;
|
||||||
|
FWidget: TCarbonWidget;
|
||||||
|
FBitmap: TCarbonBitmap;
|
||||||
|
FWidth, FHeight: Integer;
|
||||||
|
FPos: TPoint;
|
||||||
|
FVisible: Boolean;
|
||||||
|
FVisibleState: Boolean;
|
||||||
|
FRespondToFocus: Boolean;
|
||||||
|
procedure SetPos(const Value: TPoint);
|
||||||
|
protected
|
||||||
|
procedure DoTimer(Sender: TObject);
|
||||||
|
procedure DrawCaret; virtual;
|
||||||
|
procedure SetWidget(AWidget: TCarbonWidget);
|
||||||
|
procedure UpdateCaret;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function CreateCaret(AWidget: TCarbonWidget; Bitmap: PtrUInt; Width, Height: Integer): Boolean;
|
||||||
|
function DestroyCaret: Boolean;
|
||||||
|
|
||||||
|
function IsValid: Boolean;
|
||||||
|
|
||||||
|
function Show(AWidget: TCarbonWidget): Boolean;
|
||||||
|
function Hide: Boolean;
|
||||||
|
|
||||||
|
property Timer: TTimer read FTimer;
|
||||||
|
property Pos: TPoint read FPos write SetPos;
|
||||||
|
property RespondToFocus: Boolean read FRespondToFocus write FRespondToFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CreateCaret(Widget: TCarbonWidget; Bitmap: PtrUInt; Width, Height: Integer): Boolean; overload;
|
||||||
|
function HideCaret(Widget: TCarbonWidget): Boolean;
|
||||||
|
function ShowCaret(Widget: TCarbonWidget): Boolean;
|
||||||
|
function SetCaretPos(X, Y: Integer): Boolean;
|
||||||
|
function GetCaretPos(var P: TPoint): Boolean;
|
||||||
|
function GetCarbonCaretRespondToFocus: Boolean;
|
||||||
|
procedure SetCarbonCaretRespondToFocus(Value: Boolean);
|
||||||
|
function DestroyCaret: Boolean;
|
||||||
|
procedure DrawCaret;
|
||||||
|
procedure DestroyGlobalCaret;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses CarbonCanvas;
|
||||||
|
|
||||||
|
var
|
||||||
|
GlobalCaret: TEmulatedCaret = nil;
|
||||||
|
|
||||||
|
procedure GlobalCaretNeeded;
|
||||||
|
begin
|
||||||
|
if GlobalCaret = nil then GlobalCaret := TEmulatedCaret.Create(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DrawCaret;
|
||||||
|
begin
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
if Assigned(GlobalCaret) then GlobalCaret.DrawCaret;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DestroyGlobalCaret;
|
||||||
|
begin
|
||||||
|
FreeAndNil(GlobalCaret);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CreateCaret(Widget: TCarbonWidget; Bitmap: PtrUInt; Width, Height: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
|
||||||
|
Result := GlobalCaret.CreateCaret(Widget, Bitmap, Width, Height);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetCaretBlinkTime: Cardinal;
|
||||||
|
begin
|
||||||
|
// TODO: use FPCMacOSAll.GetCaretTime
|
||||||
|
Result := 600; // our default value
|
||||||
|
end;
|
||||||
|
|
||||||
|
function HideCaret(Widget: TCarbonWidget): Boolean;
|
||||||
|
begin
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
if Assigned(GlobalCaret) then
|
||||||
|
Result := GlobalCaret.Hide
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ShowCaret(Widget: TCarbonWidget): Boolean;
|
||||||
|
begin
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
|
||||||
|
Result := GlobalCaret.Show(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SetCaretPos(X, Y: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
|
||||||
|
GlobalCaret.Pos := Classes.Point(X, Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetCaretPos(var P: TPoint): Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
GlobalCaretNeeded;
|
||||||
|
|
||||||
|
with GlobalCaret.Pos do
|
||||||
|
begin
|
||||||
|
P.x := X;
|
||||||
|
P.y := Y;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetCarbonCaretRespondToFocus: Boolean;
|
||||||
|
begin
|
||||||
|
Result := GlobalCaret.RespondToFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetCarbonCaretRespondToFocus(Value: Boolean);
|
||||||
|
begin
|
||||||
|
GlobalCaret.RespondToFocus := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function DestroyCaret: Boolean;
|
||||||
|
begin
|
||||||
|
if Assigned(GlobalCaret) then
|
||||||
|
Result := GlobalCaret.DestroyCaret
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TEmulatedCaret }
|
||||||
|
|
||||||
|
constructor TEmulatedCaret.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
|
||||||
|
FOldRect := Rect(0, 0, 1, 1);
|
||||||
|
|
||||||
|
FUpdating := False;
|
||||||
|
FTimer := TTimer.Create(self);
|
||||||
|
FTimer.Enabled := False;
|
||||||
|
FTimer.Interval := GetCaretBlinkTime;
|
||||||
|
FTimer.OnTimer := @DoTimer;
|
||||||
|
|
||||||
|
FRespondToFocus := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TEmulatedCaret.Destroy;
|
||||||
|
begin
|
||||||
|
DestroyCaret;
|
||||||
|
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmulatedCaret.CreateCaret(AWidget: TCarbonWidget; Bitmap: PtrUInt;
|
||||||
|
Width, Height: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
DestroyCaret;
|
||||||
|
SetWidget(AWidget);
|
||||||
|
|
||||||
|
FWidth := Width;
|
||||||
|
FHeight := Height;
|
||||||
|
if Bitmap > 1 then
|
||||||
|
FBitmap := TCarbonBitmap.Create(TCarbonBitmap(Bitmap))
|
||||||
|
else
|
||||||
|
FBitmap := nil;
|
||||||
|
|
||||||
|
Result := IsValid;
|
||||||
|
FTimer.Enabled := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmulatedCaret.DestroyCaret: Boolean;
|
||||||
|
begin
|
||||||
|
FTimer.Enabled := False;
|
||||||
|
Hide;
|
||||||
|
if Assigned(FBitmap) then FBitmap.Free;
|
||||||
|
FWidget := nil;
|
||||||
|
FBitmap := nil;
|
||||||
|
FWidth := 0;
|
||||||
|
FHeight := 0;
|
||||||
|
Result := not IsValid;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEmulatedCaret.DrawCaret;
|
||||||
|
begin
|
||||||
|
if IsValid and FVisible and FVisibleState and FWidget.Painting then
|
||||||
|
begin
|
||||||
|
if FBitmap = nil then
|
||||||
|
(FWidget.Context as TCarbonDeviceContext).InvertRectangle(FPos.X, FPos.Y,
|
||||||
|
FPos.X + FWidth, FPos.Y + FHeight)
|
||||||
|
else
|
||||||
|
(FWidget.Context as TCarbonDeviceContext).DrawCGImage(FPos.X, FPos.Y,
|
||||||
|
FBitmap.Width, FBitmap.Height, FBitmap.CGImage);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmulatedCaret.Show(AWidget: TCarbonWidget): Boolean;
|
||||||
|
var
|
||||||
|
ShowVisible: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if FUpdating then Exit;
|
||||||
|
|
||||||
|
if FWidget <> AWidget then
|
||||||
|
begin
|
||||||
|
Hide;
|
||||||
|
SetWidget(AWidget);
|
||||||
|
ShowVisible := True;
|
||||||
|
end
|
||||||
|
else ShowVisible := not FVisible;
|
||||||
|
|
||||||
|
Result := IsValid;
|
||||||
|
|
||||||
|
if Result then
|
||||||
|
begin
|
||||||
|
FVisible := True;
|
||||||
|
FVisibleState := ShowVisible;
|
||||||
|
UpdateCaret;
|
||||||
|
FTimer.Enabled := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmulatedCaret.Hide: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if FUpdating then Exit;
|
||||||
|
|
||||||
|
Result := IsValid;
|
||||||
|
if Result and FVisible then
|
||||||
|
begin
|
||||||
|
FVisible := False;
|
||||||
|
UpdateCaret;
|
||||||
|
FTimer.Enabled := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEmulatedCaret.SetPos(const Value: TPoint);
|
||||||
|
begin
|
||||||
|
if FUpdating then Exit;
|
||||||
|
if FWidget = nil then
|
||||||
|
begin
|
||||||
|
FPos.X := 0;
|
||||||
|
FPos.Y := 0;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if ((FPos.x <> Value.x) or (FPos.y <> Value.y)) then
|
||||||
|
begin
|
||||||
|
FPos := Value;
|
||||||
|
FVisibleState := True;
|
||||||
|
UpdateCaret;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEmulatedCaret.DoTimer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FVisibleState := not FVisibleState;
|
||||||
|
if FVisible then UpdateCaret;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmulatedCaret.IsValid: Boolean;
|
||||||
|
begin
|
||||||
|
Result := (FWidth > 0) and (FHeight > 0) and (FWidget <> nil) and FWidget.IsVisible;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEmulatedCaret.SetWidget(AWidget: TCarbonWidget);
|
||||||
|
begin
|
||||||
|
if FUpdating then Exit;
|
||||||
|
if FWidget <> nil then FWidget.HasCaret := False;
|
||||||
|
|
||||||
|
FWidget := AWidget;
|
||||||
|
if FWidget <> nil then FWidget.HasCaret := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEmulatedCaret.UpdateCaret;
|
||||||
|
var
|
||||||
|
R: TRect;
|
||||||
|
begin
|
||||||
|
if FUpdating then Exit;
|
||||||
|
if (FWidget <> nil) and FWidget.Painting then Exit;
|
||||||
|
FUpdating := True;
|
||||||
|
try
|
||||||
|
if FWidget <> nil then
|
||||||
|
begin
|
||||||
|
//DebugLn('TEmulatedCaret.UpdateCaret ' + DbgS(FPos) + ' ' + DbgS(FVisible) + ' ' + DbgS(FVisibleState));
|
||||||
|
R.Left := FPos.x;
|
||||||
|
R.Top := FPos.y;
|
||||||
|
R.Right := R.Left + FWidth + 2;
|
||||||
|
R.Bottom := R.Top + FHeight + 2;
|
||||||
|
|
||||||
|
if not EqualRect(FOldRect, R) then FWidget.Invalidate(@FOldRect);
|
||||||
|
FWidget.Invalidate(@R);
|
||||||
|
FWidget.Update;
|
||||||
|
|
||||||
|
FOldRect := R;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FUpdating := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
finalization
|
||||||
|
|
||||||
|
DestroyGlobalCaret;
|
||||||
|
|
||||||
|
end.
|
@ -95,6 +95,7 @@ const
|
|||||||
SCreateStyle = 'ATSUCreateStyle';
|
SCreateStyle = 'ATSUCreateStyle';
|
||||||
SDisposeStyle = 'ATSUDisposeStyle';
|
SDisposeStyle = 'ATSUDisposeStyle';
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -64,6 +64,8 @@ type
|
|||||||
private
|
private
|
||||||
FProperties: TStringList;
|
FProperties: TStringList;
|
||||||
FCursor: HCURSOR;
|
FCursor: HCURSOR;
|
||||||
|
FHasCaret: Boolean;
|
||||||
|
function GetPainting: Boolean;
|
||||||
function GetProperty(AIndex: String): Pointer;
|
function GetProperty(AIndex: String): Pointer;
|
||||||
procedure SetProperty(AIndex: String; const AValue: Pointer);
|
procedure SetProperty(AIndex: String; const AValue: Pointer);
|
||||||
protected
|
protected
|
||||||
@ -121,6 +123,8 @@ type
|
|||||||
- processes track and draw event }
|
- processes track and draw event }
|
||||||
property Content: ControlRef read GetContent;
|
property Content: ControlRef read GetContent;
|
||||||
property Cursor: HCURSOR read FCursor;
|
property Cursor: HCURSOR read FCursor;
|
||||||
|
property HasCaret: Boolean read FHasCaret write FHasCaret;
|
||||||
|
property Painting: Boolean read GetPainting;
|
||||||
property Properties[AIndex: String]: Pointer read GetProperty write SetProperty;
|
property Properties[AIndex: String]: Pointer read GetProperty write SetProperty;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ function RegisterEventHandler(AHandler: TCarbonEventHandlerProc): EventHandlerUP
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
CarbonProc, CarbonDbgConsts, CarbonUtils;
|
CarbonProc, CarbonDbgConsts, CarbonUtils, CarbonCaret;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Name: CheckHandle
|
Name: CheckHandle
|
||||||
@ -339,6 +343,15 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonWidget.GetPainting
|
||||||
|
Returns: If the widget is being repaint
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TCarbonWidget.GetPainting: Boolean;
|
||||||
|
begin
|
||||||
|
Result := Context <> nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonWidget.SetProperty
|
Method: TCarbonWidget.SetProperty
|
||||||
Params: AIndex - Property name
|
Params: AIndex - Property name
|
||||||
@ -497,6 +510,7 @@ begin
|
|||||||
FProperties := nil;
|
FProperties := nil;
|
||||||
Widget := nil;
|
Widget := nil;
|
||||||
Context := nil;
|
Context := nil;
|
||||||
|
FHasCaret := False;
|
||||||
|
|
||||||
CreateWidget(AParams);
|
CreateWidget(AParams);
|
||||||
|
|
||||||
@ -523,14 +537,16 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
destructor TCarbonWidget.Destroy;
|
destructor TCarbonWidget.Destroy;
|
||||||
begin
|
begin
|
||||||
DestroyWidget;
|
|
||||||
|
|
||||||
FProperties.Free;
|
|
||||||
|
|
||||||
{$IFDEF VerboseWidget}
|
{$IFDEF VerboseWidget}
|
||||||
DebugLn('TCarbonWidget.Destroy ', ClassName, ' ', LCLObject.Name, ': ',
|
DebugLn('TCarbonWidget.Destroy ', ClassName, ' ', LCLObject.Name, ': ',
|
||||||
LCLObject.ClassName);
|
LCLObject.ClassName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
DestroyWidget;
|
||||||
|
|
||||||
|
FProperties.Free;
|
||||||
|
|
||||||
|
if HasCaret then DestroyCaret;
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
@ -713,7 +713,7 @@ end;
|
|||||||
function TCarbonComboBox.SetItemIndex(AIndex: Integer): Boolean;
|
function TCarbonComboBox.SetItemIndex(AIndex: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
DebugLn('TCarbonComboBox.SetItemIndex New: ' + DbgS(AIndex) + ' Prev: ' + DbgS(FItemIndex));
|
//DebugLn('TCarbonComboBox.SetItemIndex New: ' + DbgS(AIndex) + ' Prev: ' + DbgS(FItemIndex));
|
||||||
if AIndex <> FItemIndex then
|
if AIndex <> FItemIndex then
|
||||||
begin
|
begin
|
||||||
if FReadOnly then SetValue(AIndex + 1)
|
if FReadOnly then SetValue(AIndex + 1)
|
||||||
|
@ -167,6 +167,7 @@ type
|
|||||||
TCarbonBitmap = class(TCarbonGDIObject)
|
TCarbonBitmap = class(TCarbonGDIObject)
|
||||||
private
|
private
|
||||||
FData: Pointer;
|
FData: Pointer;
|
||||||
|
FAlignment: TCarbonBitmapAlignment;
|
||||||
FFreeData: Boolean;
|
FFreeData: Boolean;
|
||||||
FDataSize: Integer;
|
FDataSize: Integer;
|
||||||
FBytesPerRow: Integer;
|
FBytesPerRow: Integer;
|
||||||
@ -183,6 +184,7 @@ type
|
|||||||
constructor Create(AWidth, AHeight, ADepth, ABitsPerPixel: Integer;
|
constructor Create(AWidth, AHeight, ADepth, ABitsPerPixel: Integer;
|
||||||
AAlignment: TCarbonBitmapAlignment; AType: TCarbonBitmapType;
|
AAlignment: TCarbonBitmapAlignment; AType: TCarbonBitmapType;
|
||||||
AData: Pointer; ACopyData: Boolean = True);
|
AData: Pointer; ACopyData: Boolean = True);
|
||||||
|
constructor Create(ABitmap: TCarbonBitmap);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Update;
|
procedure Update;
|
||||||
function CreateSubImage(const ARect: TRect): CGImageRef;
|
function CreateSubImage(const ARect: TRect): CGImageRef;
|
||||||
@ -289,6 +291,10 @@ var
|
|||||||
StockNullBrush: TCarbonBrush;
|
StockNullBrush: TCarbonBrush;
|
||||||
WhiteBrush: TCarbonBrush;
|
WhiteBrush: TCarbonBrush;
|
||||||
BlackPen: TCarbonPen;
|
BlackPen: TCarbonPen;
|
||||||
|
|
||||||
|
DefaultFont: TCarbonFont;
|
||||||
|
DefaultBrush: TCarbonBrush;
|
||||||
|
DefaultPen: TCarbonPen;
|
||||||
|
|
||||||
DefaultBitmap: TCarbonBitmap; // 1 x 1 bitmap for default context
|
DefaultBitmap: TCarbonBitmap; // 1 x 1 bitmap for default context
|
||||||
|
|
||||||
@ -636,6 +642,7 @@ end;
|
|||||||
procedure TCarbonRegion.Apply(ADC: TCarbonContext);
|
procedure TCarbonRegion.Apply(ADC: TCarbonContext);
|
||||||
begin
|
begin
|
||||||
if ADC = nil then Exit;
|
if ADC = nil then Exit;
|
||||||
|
if ADC.CGContext = nil then Exit;
|
||||||
|
|
||||||
if OSError(HIShapeReplacePathInCGContext(FShape, ADC.CGContext),
|
if OSError(HIShapeReplacePathInCGContext(FShape, ADC.CGContext),
|
||||||
Self, 'Apply', 'HIShapeReplacePathInCGContext') then Exit;
|
Self, 'Apply', 'HIShapeReplacePathInCGContext') then Exit;
|
||||||
@ -960,6 +967,7 @@ var
|
|||||||
AROP2: Integer;
|
AROP2: Integer;
|
||||||
begin
|
begin
|
||||||
if ADC = nil then Exit;
|
if ADC = nil then Exit;
|
||||||
|
if ADC.CGContext = nil then Exit;
|
||||||
|
|
||||||
if UseROP2 then AROP2 := (ADC as TCarbonDeviceContext).ROP2
|
if UseROP2 then AROP2 := (ADC as TCarbonDeviceContext).ROP2
|
||||||
else AROP2 := R2_COPYPEN;
|
else AROP2 := R2_COPYPEN;
|
||||||
@ -1027,6 +1035,7 @@ var
|
|||||||
AROP2: Integer;
|
AROP2: Integer;
|
||||||
begin
|
begin
|
||||||
if ADC = nil then Exit;
|
if ADC = nil then Exit;
|
||||||
|
if ADC.CGContext = nil then Exit;
|
||||||
|
|
||||||
if UseROP2 then AROP2 := (ADC as TCarbonDeviceContext).ROP2
|
if UseROP2 then AROP2 := (ADC as TCarbonDeviceContext).ROP2
|
||||||
else AROP2 := R2_COPYPEN;
|
else AROP2 := R2_COPYPEN;
|
||||||
@ -1100,7 +1109,7 @@ end;
|
|||||||
Params: AWidth - Bitmap width
|
Params: AWidth - Bitmap width
|
||||||
AHeight - Bitmap height
|
AHeight - Bitmap height
|
||||||
ADepth - Significant bits per pixel
|
ADepth - Significant bits per pixel
|
||||||
ABitsPerPixel - The number of allocated bits per pixel (can be larget that depth)
|
ABitsPerPixel - The number of allocated bits per pixel (can be larger than depth)
|
||||||
AAlignment - Alignment of the data for each row
|
AAlignment - Alignment of the data for each row
|
||||||
ABytesPerRow - The number of bytes between rows
|
ABytesPerRow - The number of bytes between rows
|
||||||
ACopyData - Copy supplied bitmap data (OPTIONAL)
|
ACopyData - Copy supplied bitmap data (OPTIONAL)
|
||||||
@ -1113,8 +1122,7 @@ constructor TCarbonBitmap.Create(AWidth, AHeight, ADepth, ABitsPerPixel: Integer
|
|||||||
const
|
const
|
||||||
ALIGNBITS: array[TCarbonBitmapAlignment] of Integer = (0, 1, 3, 7, $F);
|
ALIGNBITS: array[TCarbonBitmapAlignment] of Integer = (0, 1, 3, 7, $F);
|
||||||
var
|
var
|
||||||
m: Integer;
|
M: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited Create(False);
|
inherited Create(False);
|
||||||
|
|
||||||
@ -1127,11 +1135,11 @@ begin
|
|||||||
FDepth := ADepth;
|
FDepth := ADepth;
|
||||||
FBitsPerPixel := ABitsPerPixel;
|
FBitsPerPixel := ABitsPerPixel;
|
||||||
FType := AType;
|
FType := AType;
|
||||||
|
FAlignment := AAlignment;
|
||||||
|
|
||||||
FBytesPerRow := ((AWidth * ABitsPerPixel) + 7) shr 3;
|
FBytesPerRow := ((AWidth * ABitsPerPixel) + 7) shr 3;
|
||||||
m := FBytesPerRow and ALIGNBITS[AAlignment];
|
M := FBytesPerRow and ALIGNBITS[AAlignment];
|
||||||
if m <> 0
|
if M <> 0 then Inc(FBytesPerRow, ALIGNBITS[AAlignment] + 1 - M);
|
||||||
then Inc(FBytesPerRow, ALIGNBITS[AAlignment] + 1 - m);
|
|
||||||
|
|
||||||
FDataSize := FBytesPerRow * FHeight;
|
FDataSize := FBytesPerRow * FHeight;
|
||||||
|
|
||||||
@ -1157,6 +1165,18 @@ begin
|
|||||||
//DbgDumpImage(FCGImage, 'TCarbonBitmap.Create');
|
//DbgDumpImage(FCGImage, 'TCarbonBitmap.Create');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonBitmap.Create
|
||||||
|
Params: ABitmap - Source bitmap
|
||||||
|
|
||||||
|
Creates Carbon bitmap as a copy of specified bitmap
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
constructor TCarbonBitmap.Create(ABitmap: TCarbonBitmap);
|
||||||
|
begin
|
||||||
|
Create(ABitmap.Width, ABitmap.Height, ABitmap.Depth, ABitmap.FBitsPerPixel,
|
||||||
|
ABitmap.FAlignment, ABitmap.FType, ABitmap.Data);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonBitmap.Destroy
|
Method: TCarbonBitmap.Destroy
|
||||||
|
|
||||||
@ -1577,6 +1597,11 @@ initialization
|
|||||||
WhiteBrush := TCarbonBrush.Create(True);
|
WhiteBrush := TCarbonBrush.Create(True);
|
||||||
BlackPen := TCarbonPen.Create(True);
|
BlackPen := TCarbonPen.Create(True);
|
||||||
|
|
||||||
|
DefaultFont := TCarbonFont.Create(True);
|
||||||
|
|
||||||
|
DefaultBrush := TCarbonBrush.Create(True);
|
||||||
|
DefaultPen := TCarbonPen.Create(True);
|
||||||
|
|
||||||
DefaultContext := TCarbonBitmapContext.Create;
|
DefaultContext := TCarbonBitmapContext.Create;
|
||||||
DefaultBitmap := TCarbonBitmap.Create(1, 1, 32, 32, cbaDQWord, cbtARGB, nil);
|
DefaultBitmap := TCarbonBitmap.Create(1, 1, 32, 32, cbaDQWord, cbtARGB, nil);
|
||||||
DefaultContext.Bitmap := DefaultBitmap;
|
DefaultContext.Bitmap := DefaultBitmap;
|
||||||
@ -1588,6 +1613,11 @@ finalization
|
|||||||
DefaultContext.Free;
|
DefaultContext.Free;
|
||||||
ScreenContext.Free;
|
ScreenContext.Free;
|
||||||
|
|
||||||
|
DefaultBrush.Free;
|
||||||
|
DefaultPen.Free;
|
||||||
|
|
||||||
|
DefaultFont.Free;
|
||||||
|
|
||||||
BlackPen.Free;
|
BlackPen.Free;
|
||||||
WhiteBrush.Free;
|
WhiteBrush.Free;
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ type
|
|||||||
property MainMenu: TMainMenu read FMainMenu;
|
property MainMenu: TMainMenu read FMainMenu;
|
||||||
public
|
public
|
||||||
procedure SetCaptureWidget(const AWidget: HWND);
|
procedure SetCaptureWidget(const AWidget: HWND);
|
||||||
|
procedure SetTextFractional(ACanvas: TCanvas; AEnabled: Boolean);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -162,7 +163,7 @@ uses
|
|||||||
{ these can/should go up }
|
{ these can/should go up }
|
||||||
CarbonDef, CarbonPrivate, CarbonMenus, CarbonButtons, CarbonBars, CarbonEdits,
|
CarbonDef, CarbonPrivate, CarbonMenus, CarbonButtons, CarbonBars, CarbonEdits,
|
||||||
CarbonListViews, CarbonTabs,
|
CarbonListViews, CarbonTabs,
|
||||||
CarbonThemes, CarbonCanvas, CarbonStrings, CarbonClipboard,
|
CarbonThemes, CarbonCanvas, CarbonStrings, CarbonClipboard, CarbonCaret,
|
||||||
CarbonProc, CarbonDbgConsts, CarbonUtils,
|
CarbonProc, CarbonDbgConsts, CarbonUtils,
|
||||||
|
|
||||||
Buttons, StdCtrls, PairSplitter, ComCtrls, CListBox, Calendar, Arrow,
|
Buttons, StdCtrls, PairSplitter, ComCtrls, CListBox, Calendar, Arrow,
|
||||||
|
@ -617,6 +617,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: SetTextFractional
|
||||||
|
Params: ACanvas - LCL Canvas
|
||||||
|
|
||||||
|
Sets canvas text fractional enabled
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TCarbonWidgetSet.SetTextFractional(ACanvas: TCanvas; AEnabled: Boolean);
|
||||||
|
begin
|
||||||
|
{$IFDEF VerboseLCLIntf}
|
||||||
|
DebugLn('TCarbonWidgetSet.SetTextFractional ACanvas: ' + DbgS(ACanvas) + ' AEnabled: ' + DbgS(AEnabled));
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
if not CheckDC(ACanvas.Handle, 'SetTextFractional') then Exit;
|
||||||
|
|
||||||
|
TCarbonDeviceContext(ACanvas.Handle).TextFractional := AEnabled;
|
||||||
|
end;
|
||||||
|
|
||||||
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
||||||
|
|
||||||
// included by carbonint.pas
|
// included by carbonint.pas
|
||||||
|
@ -440,7 +440,6 @@ var
|
|||||||
Event: EventRef;
|
Event: EventRef;
|
||||||
CurEventClass: TEventInt;
|
CurEventClass: TEventInt;
|
||||||
CurEventKind: TEventInt;
|
CurEventKind: TEventInt;
|
||||||
P: TPoint;
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseObject}
|
{$IFDEF VerboseObject}
|
||||||
DebugLn('TCarbonWidgetSet.AppProcessMessages');
|
DebugLn('TCarbonWidgetSet.AppProcessMessages');
|
||||||
@ -474,10 +473,7 @@ begin
|
|||||||
|
|
||||||
if Clipboard <> nil then
|
if Clipboard <> nil then
|
||||||
if Clipboard.OwnerShips > 0 then Clipboard.CheckOwnerShip;
|
if Clipboard.OwnerShips > 0 then Clipboard.CheckOwnerShip;
|
||||||
|
|
||||||
//GetCursorPos(P);
|
|
||||||
//DebugLn('Mouse Pos: ' + DbgS(P));
|
|
||||||
|
|
||||||
until Application.Terminated;
|
until Application.Terminated;
|
||||||
|
|
||||||
{$IFDEF VerboseObject}
|
{$IFDEF VerboseObject}
|
||||||
|
@ -198,12 +198,15 @@ type
|
|||||||
FScrollPageSize: TPoint;
|
FScrollPageSize: TPoint;
|
||||||
FMulX: Single; // multiply x coords to fit real page size
|
FMulX: Single; // multiply x coords to fit real page size
|
||||||
FMulY: Single; // multiply y coords to fit real page size
|
FMulY: Single; // multiply y coords to fit real page size
|
||||||
|
FTextFractional: Boolean;
|
||||||
protected
|
protected
|
||||||
procedure RegisterEvents; override;
|
procedure RegisterEvents; override;
|
||||||
procedure CreateWidget(const AParams: TCreateParams); override;
|
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||||
procedure DestroyWidget; override;
|
procedure DestroyWidget; override;
|
||||||
function GetFrame(Index: Integer): ControlRef; override;
|
function GetFrame(Index: Integer): ControlRef; override;
|
||||||
public
|
public
|
||||||
|
class function GetValidEvents: TCarbonControlEvents; override;
|
||||||
|
procedure Draw; override;
|
||||||
procedure GetInfo(out AImageSize, AViewSize, ALineSize: HISize; out AOrigin: HIPoint); virtual;
|
procedure GetInfo(out AImageSize, AViewSize, ALineSize: HISize; out AOrigin: HIPoint); virtual;
|
||||||
procedure ScrollTo(const ANewOrigin: HIPoint); virtual;
|
procedure ScrollTo(const ANewOrigin: HIPoint); virtual;
|
||||||
public
|
public
|
||||||
@ -211,6 +214,8 @@ type
|
|||||||
procedure SetFont(const AFont: TFont); override;
|
procedure SetFont(const AFont: TFont); override;
|
||||||
procedure GetScrollInfo(SBStyle: Integer; var ScrollInfo: TScrollInfo); override;
|
procedure GetScrollInfo(SBStyle: Integer; var ScrollInfo: TScrollInfo); override;
|
||||||
function SetScrollInfo(SBStyle: Integer; const ScrollInfo: TScrollInfo): Integer; override;
|
function SetScrollInfo(SBStyle: Integer; const ScrollInfo: TScrollInfo): Integer; override;
|
||||||
|
|
||||||
|
property TextFractional: Boolean read FTextFractional write FTextFractional;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonScrollingWinControl }
|
{ TCarbonScrollingWinControl }
|
||||||
@ -271,7 +276,7 @@ function GetCarbonControl(AWidget: ControlRef): TCarbonControl;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses InterfaceBase, CarbonInt, CarbonProc, CarbonDbgConsts, CarbonUtils,
|
uses InterfaceBase, CarbonInt, CarbonProc, CarbonDbgConsts, CarbonUtils,
|
||||||
CarbonWSStdCtrls, CarbonCanvas;
|
CarbonWSStdCtrls, CarbonCanvas, CarbonCaret;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Name: RaiseCreateWidgetError
|
Name: RaiseCreateWidgetError
|
||||||
@ -690,6 +695,11 @@ begin
|
|||||||
FScrollOrigin := GetHIPoint(0, 0);
|
FScrollOrigin := GetHIPoint(0, 0);
|
||||||
FMulX := 1;
|
FMulX := 1;
|
||||||
FMulY := 1;
|
FMulY := 1;
|
||||||
|
|
||||||
|
if LCLObject.ClassType.ClassNameIs('TSynEdit') then
|
||||||
|
FTextFractional := False
|
||||||
|
else
|
||||||
|
FTextFractional := True;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
@ -716,6 +726,30 @@ begin
|
|||||||
Result := FScrollView;
|
Result := FScrollView;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonCustomControl.GetValidEvents
|
||||||
|
Returns: Set of events with installed handlers
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
class function TCarbonCustomControl.GetValidEvents: TCarbonControlEvents;
|
||||||
|
begin
|
||||||
|
Result := [cceDraw];
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TCarbonCustomControl.Draw
|
||||||
|
|
||||||
|
Draw event handler
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TCarbonCustomControl.Draw;
|
||||||
|
begin
|
||||||
|
if Context <> nil then
|
||||||
|
begin
|
||||||
|
(Context as TCarbonDeviceContext).TextFractional := TextFractional;
|
||||||
|
if LCLObject.Color <> clBtnFace then
|
||||||
|
with (Context as TCarbonDeviceContext) do FillRect(GetClipRect, CurrentBrush);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonCustomControl.GetInfo
|
Method: TCarbonCustomControl.GetInfo
|
||||||
Params: AImageSize - Size of entire scrollable area
|
Params: AImageSize - Size of entire scrollable area
|
||||||
|
@ -40,7 +40,6 @@ function CarbonCommon_Draw(ANextHandler: EventHandlerCallRef;
|
|||||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||||
var
|
var
|
||||||
AStruct: PPaintStruct;
|
AStruct: PPaintStruct;
|
||||||
//EraseMsg: TLMEraseBkgnd;
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerbosePaint}
|
{$IFDEF VerbosePaint}
|
||||||
Debugln('CarbonCommon_Draw ', DbgSName(AWidget.LCLObject));
|
Debugln('CarbonCommon_Draw ', DbgSName(AWidget.LCLObject));
|
||||||
@ -55,10 +54,7 @@ begin
|
|||||||
SizeOf(CGContextRef), nil, @(AWidget.Context.CGContext)),
|
SizeOf(CGContextRef), nil, @(AWidget.Context.CGContext)),
|
||||||
'CarbonCommon_Draw', SGetEvent, 'kEventParamCGContextRef') then Exit;
|
'CarbonCommon_Draw', SGetEvent, 'kEventParamCGContextRef') then Exit;
|
||||||
|
|
||||||
// erase background
|
AWidget.Context.Reset;
|
||||||
{EraseMsg.Msg := LM_ERASEBKGND;
|
|
||||||
EraseMsg.DC := HDC(AWidget.Context);
|
|
||||||
DeliverMessage(AWidget.LCLObject, EraseMsg);}
|
|
||||||
|
|
||||||
// let carbon draw/update
|
// let carbon draw/update
|
||||||
Result := CallNextEventHandler(ANextHandler, AEvent);
|
Result := CallNextEventHandler(ANextHandler, AEvent);
|
||||||
@ -78,6 +74,8 @@ begin
|
|||||||
finally
|
finally
|
||||||
Dispose(AStruct);
|
Dispose(AStruct);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if AWidget.HasCaret then DrawCaret;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(AWidget.Context);
|
FreeAndNil(AWidget.Context);
|
||||||
end;
|
end;
|
||||||
|
@ -286,8 +286,7 @@ end;
|
|||||||
Creates new logical brush that has the specified style, color, and pattern
|
Creates new logical brush that has the specified style, color, and pattern
|
||||||
TODO: patterns
|
TODO: patterns
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.CreateBrushIndirect(const LogBrush: TLogBrush
|
function TCarbonWidgetSet.CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH;
|
||||||
): HBRUSH;
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseWinAPI}
|
{$IFDEF VerboseWinAPI}
|
||||||
DebugLn('TCarbonWidgetSet.CreateBrushIndirect');
|
DebugLn('TCarbonWidgetSet.CreateBrushIndirect');
|
||||||
@ -296,10 +295,29 @@ begin
|
|||||||
Result := HBRUSH(TCarbonBrush.Create(LogBrush));
|
Result := HBRUSH(TCarbonBrush.Create(LogBrush));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.CreateCaret(Handle: HWND; Bitmap: hBitmap; width,
|
{------------------------------------------------------------------------------
|
||||||
Height: Integer): Boolean;
|
Method: CreateCaret
|
||||||
|
Params: Handle - handle to owner window
|
||||||
|
Bitmap - handle to bitmap for caret shape
|
||||||
|
Width - caret width
|
||||||
|
Height - caret height
|
||||||
|
Returns: If the function succeeded
|
||||||
|
|
||||||
|
Creates a new shape for the system caret and assigns ownership of the caret
|
||||||
|
to the specified window
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TCarbonWidgetSet.CreateCaret(Handle: HWND; Bitmap: hBitmap; Width, Height: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited CreateCaret(Handle, Bitmap, width, Height);
|
Result := True;
|
||||||
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.CreateCaret Handle: ' + DbgS(Handle) + ' Bitmap: ' + DbgS(Bitmap),
|
||||||
|
' W: ' + DbgS(Width), ' H: ' + DbgS(Height));
|
||||||
|
{$ENDIF}
|
||||||
|
if not CheckWidget(Handle, 'CreateCaret') then Exit;
|
||||||
|
if Bitmap > 1 then
|
||||||
|
if not CheckBitmap(Bitmap, 'CreateCaret') then Exit;
|
||||||
|
|
||||||
|
Result := CarbonCaret.CreateCaret(TCarbonWidget(Handle), Bitmap, Width, Height);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -538,9 +556,22 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: DestroyCaret
|
||||||
|
Params: Handle - handle to the window with a caret (IGNORED)
|
||||||
|
Returns: If the function succeeds
|
||||||
|
|
||||||
|
Destroys the caret but doesn't free the bitmap.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.DestroyCaret(Handle: HWND): Boolean;
|
function TCarbonWidgetSet.DestroyCaret(Handle: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited DestroyCaret(Handle);
|
Result := False;
|
||||||
|
|
||||||
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.DestroyCaret Handle: ' + DbgS(Handle));
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
Result := CarbonCaret.DestroyCaret;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -990,9 +1021,20 @@ begin
|
|||||||
Result := FCaptureWidget;
|
Result := FCaptureWidget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: GetCaretPos
|
||||||
|
Params: LPPoint - record to receive coordinates
|
||||||
|
Returns: If the function succeeds
|
||||||
|
|
||||||
|
Gets the caret's position, in client coordinates.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
|
function TCarbonWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited GetCaretPos(lpPoint);
|
Result := CarbonCaret.GetCaretPos(lpPoint);
|
||||||
|
|
||||||
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.GetCaretPos Point: ' + DbgS(lpPoint), ' Result: ' + DbgS(Result));
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.GetCaretRespondToFocus(handle: HWND;
|
function TCarbonWidgetSet.GetCaretRespondToFocus(handle: HWND;
|
||||||
@ -1079,8 +1121,7 @@ begin
|
|||||||
if not CheckDC(DC, 'GetClipBox') then Exit;
|
if not CheckDC(DC, 'GetClipBox') then Exit;
|
||||||
|
|
||||||
if lpRect <> nil then
|
if lpRect <> nil then
|
||||||
lpRect^ := CGRectToRect(
|
lpRect^ := TCarbonDeviceContext(DC).GetClipRect;
|
||||||
CGContextGetClipBoundingBox(TCarbonDeviceContext(DC).CGContext));
|
|
||||||
|
|
||||||
Result := COMPLEXREGION;
|
Result := COMPLEXREGION;
|
||||||
|
|
||||||
@ -1848,9 +1889,22 @@ begin
|
|||||||
Mode);
|
Mode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: HideCaret
|
||||||
|
Params: HWnd - handle to the window with the caret
|
||||||
|
Returns: Whether the window owns the caret
|
||||||
|
|
||||||
|
Removes the caret from the screen.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.HideCaret(hWnd: HWND): Boolean;
|
function TCarbonWidgetSet.HideCaret(hWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited HideCaret(hWnd);
|
Result := False;
|
||||||
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.HideCaret Handle: ' + DbgS(hWnd));
|
||||||
|
{$ENDIF}
|
||||||
|
if not CheckWidget(hWnd, 'HideCaret') then Exit;
|
||||||
|
|
||||||
|
Result := CarbonCaret.HideCaret(TCarbonWidget(hWnd));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -2623,14 +2677,38 @@ begin
|
|||||||
Result:=inherited SetCapture(AHandle);
|
Result:=inherited SetCapture(AHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: SetCaretPos
|
||||||
|
Params: X, Y - Caret pos
|
||||||
|
Returns: If the function succeeds
|
||||||
|
|
||||||
|
Moves the caret to the specified coordinates.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.SetCaretPos(X, Y: Integer): Boolean;
|
function TCarbonWidgetSet.SetCaretPos(X, Y: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited SetCaretPos(X, Y);
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.SetCaretPos X: ' + DbgS(X) + ' Y: ' + DbgS(Y));
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
Result := CarbonCaret.SetCaretPos(X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: SetCaretPosEx
|
||||||
|
Params: Handle - handle of window
|
||||||
|
X - Horizontal caret coordinate
|
||||||
|
Y - Vertical caret coordinate
|
||||||
|
Returns: If the function succeeds
|
||||||
|
|
||||||
|
Moves the caret to the specified coordinates in the specified window.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean;
|
function TCarbonWidgetSet.SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited SetCaretPosEx(Handle, X, Y);
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.SetCaretPosEx X: ' + DbgS(X) + ' Y: ' + DbgS(Y));
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
Result := CarbonCaret.SetCaretPos(X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.SetCaretRespondToFocus(handle: HWND;
|
function TCarbonWidgetSet.SetCaretRespondToFocus(handle: HWND;
|
||||||
@ -2908,9 +2986,22 @@ begin
|
|||||||
Result:=inherited SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
Result:=inherited SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: ShowCaret
|
||||||
|
Params: HWnd - Handle of window with caret
|
||||||
|
Returns: if the function succeeds
|
||||||
|
|
||||||
|
Makes the caret visible on the screen at the caret's current position.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
function TCarbonWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=inherited ShowCaret(hWnd);
|
Result := False;
|
||||||
|
{$IFDEF VerboseWinAPI}
|
||||||
|
DebugLn('TCarbonWidgetSet.ShowCaret Handle: ' + DbgS(hWnd));
|
||||||
|
{$ENDIF}
|
||||||
|
if not CheckWidget(hWnd, 'ShowCaret') then Exit;
|
||||||
|
|
||||||
|
Result := CarbonCaret.ShowCaret(TCarbonWidget(hWnd));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.ShowScrollBar(Handle: HWND; wBar: Integer;
|
function TCarbonWidgetSet.ShowScrollBar(Handle: HWND; wBar: Integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user