mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-02 00:29:25 +02:00
Qt: implemented TQtWidgetSet.GetTextExtentExPoint()
git-svn-id: trunk@27398 -
This commit is contained in:
parent
a09babf360
commit
a67a2dce83
@ -3473,6 +3473,52 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetTextExtentExPoint
|
||||
Params: http://msdn.microsoft.com/en-us/library/dd144935%28VS.85%29.aspx
|
||||
Returns: True on success
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.GetTextExtentExPoint(DC: HDC; Str: PChar; Count,
|
||||
MaxWidth: Integer; MaxCount, PartialWidths: PInteger; var Size: TSize
|
||||
): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
w: Integer;
|
||||
Accumulator: Integer;
|
||||
AStr: WideString;
|
||||
begin
|
||||
Result := False;
|
||||
if not IsValidDC(DC) then Exit;
|
||||
with TQtDeviceContext(DC) do
|
||||
begin
|
||||
AStr := GetUtf8String(Str);
|
||||
Size.cX := Font.Metrics.Width(@AStr, Count);
|
||||
Size.cY := Font.Metrics.Height;
|
||||
if PartialWidths <> nil then
|
||||
begin
|
||||
if MaxCount <> nil then
|
||||
MaxCount^ := 0;
|
||||
Accumulator := 0;
|
||||
for i := 0 to Count - 1 do
|
||||
begin
|
||||
w := QFontMetrics_charWidth(Font.Metrics.Widget, @AStr, i);
|
||||
Inc(Accumulator, w);
|
||||
if MaxCount <> nil then
|
||||
begin
|
||||
if Accumulator <= MaxWidth then
|
||||
begin
|
||||
inc(MaxCount^);
|
||||
PartialWidths[i] := Accumulator;
|
||||
end else
|
||||
break;
|
||||
end else
|
||||
PartialWidths[i] := Accumulator;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetTextExtentPoint
|
||||
Params: none
|
||||
|
@ -127,6 +127,7 @@ function GetSysColor(nIndex: Integer): DWORD; override;
|
||||
function GetSysColorBrush(nIndex: Integer): HBrush; override;
|
||||
function GetSystemMetrics(nIndex: Integer): Integer; override;
|
||||
function GetTextColor(DC: HDC) : TColorRef; Override;
|
||||
function GetTextExtentExPoint(DC: HDC; Str: PChar; Count, MaxWidth: Integer; MaxCount, PartialWidths: PInteger; var Size: TSize): Boolean; override;
|
||||
function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override;
|
||||
function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; override;
|
||||
function GetViewPortExtEx(DC: HDC; Size: PSize): Integer; override;
|
||||
|
Loading…
Reference in New Issue
Block a user