(Qt): partial implementation of EnumFontFamiliesEx() by theo, with some changes from me.

git-svn-id: trunk@12067 -
This commit is contained in:
zeljko 2007-09-18 13:59:42 +00:00
parent 367039cc48
commit a3ec3fd317
2 changed files with 102 additions and 0 deletions

View File

@ -1298,6 +1298,107 @@ begin
end;
{------------------------------------------------------------------------------
Function: EnumFontFamiliesEx
Params:
hdc
[in] Handle to the device context.
lpLogfont
[in] Pointer to a LOGFONT structure that contains information about the
fonts to enumerate. The function examines the following members.
Member Description
lfCharset If set to DEFAULT_CHARSET, the function enumerates all fonts
in all character sets. If set to a valid character set value,
the function enumerates only fonts in the specified character
set.
lfFaceName If set to an empty string, the function enumerates one font
in each available typeface name. If set to a valid typeface
name, the function enumerates all fonts with the
specified name.
lfPitchAndFamily Must be set to zero for all language versions of
the operating system.
lpEnumFontFamExProc
[in] Pointer to the application definedcallback function. For more
information, see the EnumFontFamExProc function.
lParam
[in] Specifies an applicationdefined value. The function passes this value
to the callback function along with font information.
dwFlags
This parameter is not used and must be zero.
Returns:
The return value is the last value returned by the callback function.
This value depends on which font families are available for the
specified device.
------------------------------------------------------------------------------}
function TQtWidgetSet.EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint;
var
EnumLogFont: TEnumLogFontEx;
Metric: TNewTextMetricEx;
FontList: TStringList;
FontType: Integer;
i: Integer;
function QtGetFontFamilies(var List:TStringList):integer;
var
FontDB: QFontDatabaseH;
StrLst: QStringlistH;
Str: WideString;
j: integer;
begin
Result := -1;
FontDB := QFontDatabase_create();
StrLst := QStringList_create;
try
QFontDatabase_families(FontDB,StrLst);
Result := QStringList_size(StrLst);
for j := 0 to Result - 1 do
begin
QStringList_at(StrLst, @Str, j);
List.Add(GetUtf8String(Str));
end;
finally
QFontDatabase_destroy(FontDB);
QStringList_destroy(StrLst);
end;
end;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI EnumFontFamiliesEx]');
{$endif}
Result := 0;
if (lpLogFont^.lfCharSet = DEFAULT_CHARSET) and
(lpLogFont^.lfFaceName= '') and
(lpLogFont^.lfPitchAndFamily = 0) then
begin
FontList := TStringList.create;
try
if QtGetFontFamilies(FontList)>0 then
begin
for i := 0 to FontList.Count-1 do
begin
EnumLogFont.elfLogFont.lfFaceName := FontList[i];
Result := Callback(EnumLogFont, Metric, FontType, LParam);
end;
end;
finally
FontList.free;
end;
end else
begin
{$note implement}
Result := 0;
end;
end;
{------------------------------------------------------------------------------
Function: ExcludeClipRect
Params: none

View File

@ -80,6 +80,7 @@ function EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean; overr
function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; 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 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;