Qt: fixed drawing of text when have DT_MODIFYSTRING and DT_END_ELLIPSIS flags using TrimLeft(), so it's same like under win32.

git-svn-id: trunk@31354 -
This commit is contained in:
zeljko 2011-06-24 08:38:17 +00:00
parent 762aef652a
commit a8b4881fc6
2 changed files with 12 additions and 7 deletions

View File

@ -225,7 +225,8 @@ type
function charWidth(str: WideString; pos: Integer): Integer;
function averageCharWidth: Integer;
function elidedText(const AText: WideString;
const AMode: QtTextElideMode; const AWidth: Integer): WideString;
const AMode: QtTextElideMode; const AWidth: Integer;
const AFlags: Integer = 0): WideString;
end;
{ TQtBrush }
@ -1537,9 +1538,10 @@ begin
end;
function TQtFontMetrics.elidedText(const AText: WideString;
const AMode: QtTextElideMode; const AWidth: Integer): WideString;
const AMode: QtTextElideMode; const AWidth: Integer;
const AFlags: Integer = 0): WideString;
begin
QFontMetrics_elidedText(Widget, @Result, @AText, AMode, AWidth, 0);
QFontMetrics_elidedText(Widget, @Result, @AText, AMode, AWidth, AFlags);
end;
{ TQtBrush }

View File

@ -1202,7 +1202,6 @@ var
S: String;
i: Integer;
procedure CalculateOffsetWithAngle(const AFontAngle: Integer;
var TextLeft,TextTop: Integer);
var
@ -1339,8 +1338,9 @@ begin
Save
project (in two lines, so Ctrl+S is invisible. See issue #18631.
But does not trigger with qt-4.6.XX and maybe with 4.7.0.
Opened nokia issue: http://bugreports.qt.nokia.com/browse/QTBUG-17020}
if (QtVersionMajor = 4) and (QtVersionMinor = 7) and (QtVersionMicro = 1) and
Opened nokia issue: http://bugreports.qt.nokia.com/browse/QTBUG-17020
UPDATE: it's fixed in qt-4.7.4 git and qt-4.8}
if (QtVersionMajor = 4) and (QtVersionMinor = 7) and (QtVersionMicro < 4) and
(Flags and DT_WORDBREAK = DT_WORDBREAK) and
((Flags and DT_VCENTER = DT_VCENTER) or (Flags and DT_CENTER = DT_CENTER))
and not (Flags and DT_NOCLIP = DT_NOCLIP) and
@ -1363,8 +1363,11 @@ begin
if (Flags and DT_MODIFYSTRING = DT_MODIFYSTRING) and
(Flags and DT_END_ELLIPSIS = DT_END_ELLIPSIS) then
begin
// windows are removing trailing spaces in this case
// and we are doing same thing too.
WideStr := TrimLeft(WideStr);
with ARect do
WideStr := QtDC.Metrics.elidedText(WideStr, QtElideRight, Right - Left);
WideStr := QtDC.Metrics.elidedText(WideStr, QtElideRight, Right - Left, 0);
end;
with ARect do