mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 10:55:55 +02:00
Qt:
- 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:
parent
3b6250d969
commit
d712502a4c
@ -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;
|
||||||
|
|
||||||
|
@ -924,86 +924,103 @@ 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;
|
||||||
X1 := R.Left;
|
|
||||||
Y1 := R.Top;
|
|
||||||
X2 := R.Right;
|
|
||||||
Y2 := R.Bottom;
|
|
||||||
|
|
||||||
ColorLeftTop := clNone;
|
|
||||||
ColorRightBottom := clNone;
|
|
||||||
|
|
||||||
if Outer then
|
|
||||||
begin
|
begin
|
||||||
if Edge and BDR_RAISEDOUTER <> 0 then
|
X1 := R.Left;
|
||||||
|
Y1 := R.Top;
|
||||||
|
X2 := R.Right;
|
||||||
|
Y2 := R.Bottom;
|
||||||
|
|
||||||
|
ColorLeftTop := clNone;
|
||||||
|
ColorRightBottom := clNone;
|
||||||
|
EdgeQtColor.ColorSpec := 1; // rgb
|
||||||
|
EdgeQtColor.Alpha := $FFFF;
|
||||||
|
EdgeQtColor.Pad := 0;
|
||||||
|
|
||||||
|
if Outer then
|
||||||
begin
|
begin
|
||||||
ColorLeftTop := ColorLight;
|
if Edge and BDR_RAISEDOUTER <> 0 then
|
||||||
ColorRightBottom := ColorDark;
|
begin
|
||||||
|
ColorLeftTop := ColorLight;
|
||||||
|
ColorRightBottom := ColorDark;
|
||||||
|
end
|
||||||
|
else if Edge and BDR_SUNKENOUTER <> 0 then
|
||||||
|
begin
|
||||||
|
ColorLeftTop := ColorDark;
|
||||||
|
ColorRightBottom := ColorLight;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else if Edge and BDR_SUNKENOUTER <> 0 then
|
|
||||||
begin
|
|
||||||
ColorLeftTop := ColorDark;
|
|
||||||
ColorRightBottom := ColorLight;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if Edge and BDR_RAISEDINNER <> 0 then
|
|
||||||
begin
|
|
||||||
ColorLeftTop := ColorLight;
|
|
||||||
ColorRightBottom := ColorDark;
|
|
||||||
end
|
|
||||||
else if Edge and BDR_SUNKENINNER <> 0 then
|
|
||||||
begin
|
|
||||||
ColorLeftTop := ColorDark;
|
|
||||||
ColorRightBottom := ColorLight;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if grfFlags and BF_DIAGONAL = 0 then
|
|
||||||
begin
|
|
||||||
if grfFlags and BF_MONO = 0 then
|
|
||||||
ColorLeftTop := ColorToRgb(ColorLeftTop);
|
|
||||||
|
|
||||||
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorLeftTop),Green(ColorLeftTop),Blue(ColorLeftTop));
|
|
||||||
Pen := QPainter_pen(QtDC.Widget);
|
|
||||||
QPen_setColor(Pen, @EdgeQtColor);
|
|
||||||
if grfFlags and BF_LEFT <> 0 then
|
|
||||||
QtDC.DrawLine(X1, Y1, X1, Y2);
|
|
||||||
if grfFlags and BF_TOP <> 0 then
|
|
||||||
QtDC.DrawLine(X1, Y1, X2, Y1);
|
|
||||||
|
|
||||||
if grfFlags and BF_MONO = 0 then
|
|
||||||
ColorRightBottom := ColorToRgb(ColorRightBottom);
|
|
||||||
|
|
||||||
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorRightBottom),Green(ColorRightBottom),Blue(ColorRightBottom));
|
|
||||||
Pen := QPainter_pen(QtDC.Widget);
|
|
||||||
QPen_setColor(Pen, @EdgeQtColor);
|
|
||||||
|
|
||||||
if grfFlags and BF_RIGHT <> 0 then
|
|
||||||
QtDC.DrawLine(X2, Y1, X2, Y2);
|
|
||||||
if grfFlags and BF_BOTTOM <> 0 then
|
|
||||||
QtDC.DrawLine(X1, Y2, X2, Y2);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if grfFlags and BF_MONO = 0 then
|
|
||||||
ColorLeftTop := ColorToRgb(ColorRightBottom);
|
|
||||||
QColor_setRgb(QColorH(@EdgeQtColor),Red(ColorLeftTop),Green(ColorLeftTop),Blue(ColorLeftTop));
|
|
||||||
Pen := QPainter_pen(QtDC.Widget);
|
|
||||||
QPen_setColor(Pen, @EdgeQtColor);
|
|
||||||
if (grfFlags and BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL_ENDTOPLEFT) or
|
|
||||||
(grfFlags and BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL_ENDBOTTOMRIGHT) then
|
|
||||||
QtDC.DrawLine(X1, Y1, X2, Y2)
|
|
||||||
else
|
else
|
||||||
QtDC.DrawLine(X1, Y2, X2, Y1);
|
begin
|
||||||
|
if Edge and BDR_RAISEDINNER <> 0 then
|
||||||
|
begin
|
||||||
|
ColorLeftTop := ColorLight;
|
||||||
|
ColorRightBottom := ColorDark;
|
||||||
|
end
|
||||||
|
else if Edge and BDR_SUNKENINNER <> 0 then
|
||||||
|
begin
|
||||||
|
ColorLeftTop := ColorDark;
|
||||||
|
ColorRightBottom := ColorLight;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if grfFlags and BF_DIAGONAL = 0 then
|
||||||
|
begin
|
||||||
|
if grfFlags and BF_MONO = 0 then
|
||||||
|
ColorLeftTop := ColorToRgb(ColorLeftTop);
|
||||||
|
|
||||||
|
APen := TQtPen.Create(True);
|
||||||
|
ColorRefToTQColor(ColorLeftTop, EdgeQtColor);
|
||||||
|
APen.setColor(EdgeQtColor);
|
||||||
|
OldPen := QtDC.setPen(APen);
|
||||||
|
|
||||||
|
if grfFlags and BF_LEFT <> 0 then
|
||||||
|
QtDC.DrawLine(X1, Y1, X1, Y2);
|
||||||
|
if grfFlags and BF_TOP <> 0 then
|
||||||
|
QtDC.DrawLine(X1, Y1, X2, Y1);
|
||||||
|
|
||||||
|
QtDC.setPen(OldPen);
|
||||||
|
APen.Free;
|
||||||
|
APen := TQtPen.Create(True);
|
||||||
|
|
||||||
|
if grfFlags and BF_MONO = 0 then
|
||||||
|
ColorRightBottom := ColorToRgb(ColorRightBottom);
|
||||||
|
|
||||||
|
ColorRefToTQColor(ColorRightBottom, EdgeQtColor);
|
||||||
|
APen.setColor(EdgeQtColor);
|
||||||
|
OldPen := QtDC.SetPen(APen);
|
||||||
|
|
||||||
|
if grfFlags and BF_RIGHT <> 0 then
|
||||||
|
QtDC.DrawLine(X2, Y1, X2, Y2);
|
||||||
|
if grfFlags and BF_BOTTOM <> 0 then
|
||||||
|
QtDC.DrawLine(X1, Y2, X2, Y2);
|
||||||
|
QtDC.SetPen(OldPen);
|
||||||
|
APen.Free;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if grfFlags and BF_MONO = 0 then
|
||||||
|
ColorRightBottom := ColorToRgb(ColorRightBottom);
|
||||||
|
|
||||||
|
APen := TQtPen.Create(True);
|
||||||
|
ColorRefToTQColor(ColorLeftTop, EdgeQtColor);
|
||||||
|
APen.setColor(EdgeQtColor);
|
||||||
|
OldPen := QtDC.setPen(APen);
|
||||||
|
|
||||||
|
if (grfFlags and BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL_ENDTOPLEFT) or
|
||||||
|
(grfFlags and BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL_ENDBOTTOMRIGHT) then
|
||||||
|
QtDC.DrawLine(X1, Y1, X2, Y2)
|
||||||
|
else
|
||||||
|
QtDC.DrawLine(X1, Y2, X2, Y1);
|
||||||
|
QtDC.setPen(OldPen);
|
||||||
|
APen.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
@ -1015,7 +1032,9 @@ 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);
|
||||||
try
|
try
|
||||||
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user