From 13bd9d73780d78ce86bfff40560894ede6ea3c13 Mon Sep 17 00:00:00 2001 From: zeljko Date: Mon, 20 Sep 2010 06:54:25 +0000 Subject: [PATCH] Qt,Gtk2: corrected return of Size.cx, simplified and fixed code in qt implementation about Size.cx returned values. git-svn-id: trunk@27416 - --- lcl/interfaces/gtk2/gtk2winapi.inc | 3 +++ lcl/interfaces/qt/qtwinapi.inc | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index 72516fac96..e6a7ad6392 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -5557,7 +5557,10 @@ begin inc(MaxCount^); PartialWidths[i] := Size.cx; end else + begin + dec(Size.cx, Rect.Width); break; + end; end else PartialWidths[i] := Size.cx; if Size.cy < Rect.Height then diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 54f0eda06b..17042a6913 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -3484,7 +3484,6 @@ function TQtWidgetSet.GetTextExtentExPoint(DC: HDC; Str: PChar; Count, var i: Integer; w: Integer; - Accumulator: Integer; AStr: WideString; begin Result := False; @@ -3492,27 +3491,33 @@ begin with TQtDeviceContext(DC) do begin AStr := GetUtf8String(Str); - Size.cX := Font.Metrics.Width(@AStr, Count); - Size.cY := Font.Metrics.Height; - if PartialWidths <> nil then + if PartialWidths = nil then begin + Size.cX := Font.Metrics.Width(@AStr, Count); + Size.cY := Font.Metrics.Height; + end else + begin + Size.cx := 0; + Size.cY := Font.Metrics.Height; 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); + Inc(Size.cx, w); if MaxCount <> nil then begin - if Accumulator <= MaxWidth then + if Size.cx <= MaxWidth then begin inc(MaxCount^); - PartialWidths[i] := Accumulator; + PartialWidths[i] := Size.cx; end else + begin + Dec(Size.cx, w); break; + end; end else - PartialWidths[i] := Accumulator; + PartialWidths[i] := Size.cx; end; end; end;