mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 06:38:13 +02:00
cocoa: partialy implemented EnumFontFamiliesEx
git-svn-id: trunk@27258 -
This commit is contained in:
parent
404ca55078
commit
dfad230000
@ -106,6 +106,9 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
ScreenContext : TCocoaContext = nil;
|
||||||
|
|
||||||
//todo: a better check!
|
//todo: a better check!
|
||||||
|
|
||||||
function CheckDC(dc: HDC): TCocoaContext;
|
function CheckDC(dc: HDC): TCocoaContext;
|
||||||
@ -382,7 +385,7 @@ end;
|
|||||||
|
|
||||||
procedure InternalFinal;
|
procedure InternalFinal;
|
||||||
begin
|
begin
|
||||||
|
if Assigned(ScreenContext) then ScreenContext.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@
|
|||||||
methods defined in the
|
methods defined in the
|
||||||
lcl/include/winapi.inc
|
lcl/include/winapi.inc
|
||||||
|
|
||||||
|
|
||||||
!! Keep alphabetical !!
|
|
||||||
|
|
||||||
|
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
Implementation
|
Implementation
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
@ -36,6 +32,7 @@
|
|||||||
nCmdShow:
|
nCmdShow:
|
||||||
SW_SHOWNORMAL, SW_MINIMIZE, SW_SHOWMAXIMIZED
|
SW_SHOWNORMAL, SW_MINIMIZE, SW_SHOWMAXIMIZED
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
|
||||||
function TCocoaWidgetSet.ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean;
|
function TCocoaWidgetSet.ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseCocoaWinAPI}
|
{$ifdef VerboseCocoaWinAPI}
|
||||||
@ -246,6 +243,16 @@ end;
|
|||||||
|
|
||||||
{------------------------------- DEVICE CONTEXT -------------------------------}
|
{------------------------------- DEVICE CONTEXT -------------------------------}
|
||||||
|
|
||||||
|
function TCocoaWidgetSet.GetDC(hWnd: HWND): HDC;
|
||||||
|
begin
|
||||||
|
if hWnd=0 then begin
|
||||||
|
if not Assigned(ScreenContext) then ScreenContext:=TCocoaContext.Create;
|
||||||
|
Result:=HDC(ScreenContext);
|
||||||
|
end else
|
||||||
|
//todo:!
|
||||||
|
Result:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCocoaWidgetSet.DeleteObject(GDIObject: HGDIOBJ): Boolean;
|
function TCocoaWidgetSet.DeleteObject(GDIObject: HGDIOBJ): Boolean;
|
||||||
var
|
var
|
||||||
gdi: TCocoaGDIObject;
|
gdi: TCocoaGDIObject;
|
||||||
@ -357,7 +364,6 @@ begin
|
|||||||
ctx:=CheckDC(DC);
|
ctx:=CheckDC(DC);
|
||||||
Result:=Assigned(ctx);
|
Result:=Assigned(ctx);
|
||||||
if not Assigned(ctx) then Exit;
|
if not Assigned(ctx) then Exit;
|
||||||
|
|
||||||
ctx.TextOut(X,Y, Str, Count, Dx);
|
ctx.TextOut(X,Y, Str, Count, Dx);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -366,4 +372,37 @@ begin
|
|||||||
Result:=ExtTextOut(DC, X, Y, 0, nil, Str, Count, nil);
|
Result:=ExtTextOut(DC, X, Y, 0, nil, Str, Count, nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaWidgetSet.EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint;
|
||||||
|
var
|
||||||
|
fontManager : NSFontManager;
|
||||||
|
arr : NSArray;
|
||||||
|
fname : NSString;
|
||||||
|
i : Integer;
|
||||||
|
|
||||||
|
ELogFont : TEnumLogFontEx;
|
||||||
|
Metric : TNewTextMetricEx;
|
||||||
|
FontName : AnsiString;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
if not Assigned(Callback) then Exit;
|
||||||
|
fontManager:=NSFontManager.sharedFontManager;
|
||||||
|
arr:=fontManager.availableFontFamilies;
|
||||||
|
for i:=0 to arr.count-1 do begin
|
||||||
|
fname:=NSString(arr.objectAtIndex(i));
|
||||||
|
try
|
||||||
|
FontName:=NSStringToString(fname);
|
||||||
|
FillChar(ELogFont, SizeOf(ELogFont), #0);
|
||||||
|
FillChar(Metric, SizeOf(Metric), #0);
|
||||||
|
ELogFont.elfLogFont.lfFaceName := FontName;
|
||||||
|
ELogFont.elfFullName := FontName;
|
||||||
|
//todo: read the data from all fonts of the fontfamily
|
||||||
|
Result:=CallBack(ELogFont, Metric, TRUETYPE_FONTTYPE, lparam);
|
||||||
|
if Result=0 then Break;
|
||||||
|
except
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
arr.release;
|
||||||
|
end;
|
||||||
|
|
||||||
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
||||||
|
@ -76,9 +76,9 @@ function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override;
|
|||||||
{function EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean; override;
|
{function EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean; override;
|
||||||
function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
|
function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
|
||||||
function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;
|
function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;
|
||||||
procedure EnterCriticalSection(var CritSection: TCriticalSection); override;
|
procedure EnterCriticalSection(var CritSection: TCriticalSection); override;}
|
||||||
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
|
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
|
||||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
{function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;}
|
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;}
|
||||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||||
|
|
||||||
@ -97,9 +97,9 @@ function GetClientBounds(handle : HWND; var ARect : TRect) : Boolean; override;
|
|||||||
function GetClientRect(handle : HWND; var ARect : TRect) : Boolean; override;
|
function GetClientRect(handle : HWND; var ARect : TRect) : Boolean; override;
|
||||||
function GetClipBox(DC : hDC; lpRect : PRect) : Longint; override;
|
function GetClipBox(DC : hDC; lpRect : PRect) : Longint; override;
|
||||||
function GetClipRGN(DC: hDC; RGN: hRGN): Longint; override;
|
function GetClipRGN(DC: hDC; RGN: hRGN): Longint; override;
|
||||||
function GetCursorPos(var lpPoint: TPoint ): Boolean; override;
|
function GetCursorPos(var lpPoint: TPoint ): Boolean; override;}
|
||||||
function GetDC(hWnd: HWND): HDC; override;
|
function GetDC(hWnd: HWND): HDC; override;
|
||||||
function GetDCOriginRelativeToWindow(PaintDC: HDC; WindowHandle: HWND; var OriginDiff: TPoint): boolean; override;
|
{function GetDCOriginRelativeToWindow(PaintDC: HDC; WindowHandle: HWND; var OriginDiff: TPoint): boolean; override;
|
||||||
function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override;
|
function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override;
|
||||||
function GetDeviceSize(DC: HDC; var P: TPoint): Boolean; 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 GetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT): Integer; Override;
|
||||||
|
@ -121,6 +121,7 @@ begin
|
|||||||
if Context.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then begin
|
if Context.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then begin
|
||||||
FillChar(struct, SizeOf(TPaintStruct), 0);
|
FillChar(struct, SizeOf(TPaintStruct), 0);
|
||||||
struct.hdc := HDC(Context);
|
struct.hdc := HDC(Context);
|
||||||
|
writeln('target = ', Integer(Target),' ', Target.ClassName);
|
||||||
LCLSendPaintMsg(Target, HDC(Context), @struct);
|
LCLSendPaintMsg(Target, HDC(Context), @struct);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user