cocoa: partialy implemented EnumFontFamiliesEx

git-svn-id: trunk@27258 -
This commit is contained in:
dmitry 2010-09-03 09:56:48 +00:00
parent 404ca55078
commit dfad230000
5 changed files with 54 additions and 11 deletions

View File

@ -133,7 +133,7 @@ type
end;
var
TextLayoutClass : TCocoaTextLayoutClass = nil;
TextLayoutClass : TCocoaTextLayoutClass = nil;
implementation

View File

@ -106,6 +106,9 @@ var
implementation
var
ScreenContext : TCocoaContext = nil;
//todo: a better check!
function CheckDC(dc: HDC): TCocoaContext;
@ -382,7 +385,7 @@ end;
procedure InternalFinal;
begin
if Assigned(ScreenContext) then ScreenContext.Free;
end;

View File

@ -6,10 +6,6 @@
methods defined in the
lcl/include/winapi.inc
!! Keep alphabetical !!
******************************************************************************
Implementation
******************************************************************************
@ -36,6 +32,7 @@
nCmdShow:
SW_SHOWNORMAL, SW_MINIMIZE, SW_SHOWMAXIMIZED
------------------------------------------------------------------------------}
function TCocoaWidgetSet.ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean;
begin
{$ifdef VerboseCocoaWinAPI}
@ -246,6 +243,16 @@ end;
{------------------------------- 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;
var
gdi: TCocoaGDIObject;
@ -357,7 +364,6 @@ begin
ctx:=CheckDC(DC);
Result:=Assigned(ctx);
if not Assigned(ctx) then Exit;
ctx.TextOut(X,Y, Str, Count, Dx);
end;
@ -366,4 +372,37 @@ begin
Result:=ExtTextOut(DC, X, Y, 0, nil, Str, Count, nil);
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

View File

@ -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 EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; 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 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 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 GetClipBox(DC : hDC; lpRect : PRect) : 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 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 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;

View File

@ -121,6 +121,7 @@ begin
if Context.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then begin
FillChar(struct, SizeOf(TPaintStruct), 0);
struct.hdc := HDC(Context);
writeln('target = ', Integer(Target),' ', Target.ClassName);
LCLSendPaintMsg(Target, HDC(Context), @struct);
end;
end;