- fix DrawEdge (was wrong colors and wrong rectangle)
- fix DrawText for cases where string is not utf8 coded

git-svn-id: trunk@12045 -
This commit is contained in:
paul 2007-09-16 15:35:38 +00:00
parent 3b6250d969
commit d712502a4c
2 changed files with 101 additions and 85 deletions

View File

@ -277,7 +277,7 @@ type
procedure setBrush(ABrush: TQtBrush); procedure setBrush(ABrush: TQtBrush);
function BackgroundBrush: TQtBrush; function BackgroundBrush: TQtBrush;
function pen: TQtPen; function pen: TQtPen;
procedure setPen(APen: TQtPen); function setPen(APen: TQtPen): TQtPen;
function SetBkColor(Color: TcolorRef): TColorRef; function SetBkColor(Color: TcolorRef): TColorRef;
function SetBkMode(BkMode: Integer): Integer; function SetBkMode(BkMode: Integer): Integer;
function getDeviceSize: TPoint; function getDeviceSize: TPoint;
@ -1113,11 +1113,8 @@ end;
Setting pen color. Setting pen color.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TQtPen.setColor(p1: TQColor); procedure TQtPen.setColor(p1: TQColor);
var
p2: TQColor;
begin begin
QColor_fromRGB(@p2,p1.r,p1.g,p1.b,p1.Alpha); QPen_setColor(Widget, @p1);
QPen_setColor(Widget, @p2);
end; end;
@ -1746,13 +1743,14 @@ end;
Params: None Params: None
Returns: Nothing Returns: Nothing
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TQtDeviceContext.setPen(APen: TQtPen); function TQtDeviceContext.setPen(APen: TQtPen): TQtPen;
begin begin
{$ifdef VerboseQt} {$ifdef VerboseQt}
Write('TQtDeviceContext.setPen() '); Write('TQtDeviceContext.setPen() ');
{$endif} {$endif}
Result := pen;
SelPen := APen; SelPen := APen;
if (APen.Widget <> nil) and (Widget <> nil) then if (APen <> nil) and (APen.Widget <> nil) and (Widget <> nil) then
QPainter_setPen(Widget, APen.Widget); QPainter_setPen(Widget, APen.Widget);
end; end;

View File

@ -924,12 +924,13 @@ var
QtDC: TQtDeviceContext; QtDC: TQtDeviceContext;
Pen: QPenH; Pen: QPenH;
procedure InternalDrawEdge(Outer: Boolean; const R: TRect); procedure InternalDrawEdge(Outer: Boolean; const R: TRect);
var var
X1, Y1, X2, Y2: Integer; X1, Y1, X2, Y2: Integer;
ColorLeftTop, ColorRightBottom: TColor; ColorLeftTop, ColorRightBottom: TColor;
EdgeQtColor: TQColor; EdgeQtColor: TQColor;
begin APen, OldPen: TQtPen;
begin
X1 := R.Left; X1 := R.Left;
Y1 := R.Top; Y1 := R.Top;
X2 := R.Right; X2 := R.Right;
@ -937,6 +938,9 @@ begin
ColorLeftTop := clNone; ColorLeftTop := clNone;
ColorRightBottom := clNone; ColorRightBottom := clNone;
EdgeQtColor.ColorSpec := 1; // rgb
EdgeQtColor.Alpha := $FFFF;
EdgeQtColor.Pad := 0;
if Outer then if Outer then
begin begin
@ -970,40 +974,53 @@ begin
if grfFlags and BF_MONO = 0 then if grfFlags and BF_MONO = 0 then
ColorLeftTop := ColorToRgb(ColorLeftTop); ColorLeftTop := ColorToRgb(ColorLeftTop);
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorLeftTop),Green(ColorLeftTop),Blue(ColorLeftTop)); APen := TQtPen.Create(True);
Pen := QPainter_pen(QtDC.Widget); ColorRefToTQColor(ColorLeftTop, EdgeQtColor);
QPen_setColor(Pen, @EdgeQtColor); APen.setColor(EdgeQtColor);
OldPen := QtDC.setPen(APen);
if grfFlags and BF_LEFT <> 0 then if grfFlags and BF_LEFT <> 0 then
QtDC.DrawLine(X1, Y1, X1, Y2); QtDC.DrawLine(X1, Y1, X1, Y2);
if grfFlags and BF_TOP <> 0 then if grfFlags and BF_TOP <> 0 then
QtDC.DrawLine(X1, Y1, X2, Y1); QtDC.DrawLine(X1, Y1, X2, Y1);
QtDC.setPen(OldPen);
APen.Free;
APen := TQtPen.Create(True);
if grfFlags and BF_MONO = 0 then if grfFlags and BF_MONO = 0 then
ColorRightBottom := ColorToRgb(ColorRightBottom); ColorRightBottom := ColorToRgb(ColorRightBottom);
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorRightBottom),Green(ColorRightBottom),Blue(ColorRightBottom)); ColorRefToTQColor(ColorRightBottom, EdgeQtColor);
Pen := QPainter_pen(QtDC.Widget); APen.setColor(EdgeQtColor);
QPen_setColor(Pen, @EdgeQtColor); OldPen := QtDC.SetPen(APen);
if grfFlags and BF_RIGHT <> 0 then if grfFlags and BF_RIGHT <> 0 then
QtDC.DrawLine(X2, Y1, X2, Y2); QtDC.DrawLine(X2, Y1, X2, Y2);
if grfFlags and BF_BOTTOM <> 0 then if grfFlags and BF_BOTTOM <> 0 then
QtDC.DrawLine(X1, Y2, X2, Y2); QtDC.DrawLine(X1, Y2, X2, Y2);
QtDC.SetPen(OldPen);
APen.Free;
end end
else else
begin begin
if grfFlags and BF_MONO = 0 then if grfFlags and BF_MONO = 0 then
ColorLeftTop := ColorToRgb(ColorRightBottom); ColorRightBottom := ColorToRgb(ColorRightBottom);
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorLeftTop),Green(ColorLeftTop),Blue(ColorLeftTop));
Pen := QPainter_pen(QtDC.Widget); APen := TQtPen.Create(True);
QPen_setColor(Pen, @EdgeQtColor); ColorRefToTQColor(ColorLeftTop, EdgeQtColor);
APen.setColor(EdgeQtColor);
OldPen := QtDC.setPen(APen);
if (grfFlags and BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL_ENDTOPLEFT) or if (grfFlags and BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL_ENDTOPLEFT) or
(grfFlags and BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL_ENDBOTTOMRIGHT) then (grfFlags and BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL_ENDBOTTOMRIGHT) then
QtDC.DrawLine(X1, Y1, X2, Y2) QtDC.DrawLine(X1, Y1, X2, Y2)
else else
QtDC.DrawLine(X1, Y2, X2, Y1); QtDC.DrawLine(X1, Y2, X2, Y1);
QtDC.setPen(OldPen);
APen.Free;
end;
end; end;
end;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
@ -1015,6 +1032,8 @@ begin
QtDC := TQtDeviceContext(DC); QtDC := TQtDeviceContext(DC);
Dec(Rect.Right, 1);
Dec(Rect.Bottom, 1);
ClientRect := Rect; ClientRect := Rect;
QPainter_save(QtDC.Widget); QPainter_save(QtDC.Widget);
@ -1040,7 +1059,6 @@ begin
InflateRect(ClientRect, -1, -1); InflateRect(ClientRect, -1, -1);
end; end;
finally finally
end; end;
if grfFlags and BF_MIDDLE <> 0 then if grfFlags and BF_MIDDLE <> 0 then
@ -1148,7 +1166,7 @@ begin
QtDC :=TQtDeviceContext(DC); QtDC :=TQtDeviceContext(DC);
WideStr := UTF8Decode(Str); WideStr := GetUtf8String(Str);
QtFontMetrics := TQtFontMetrics.Create(QtDC.font.Widget); QtFontMetrics := TQtFontMetrics.Create(QtDC.font.Widget);
try try