mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +02:00
Qt:
- restored painting inside groupbox - fix IntersectClipRect - fix DrawText (clipping) git-svn-id: trunk@12188 -
This commit is contained in:
parent
490a35d1a5
commit
13c1fd094c
@ -1051,7 +1051,8 @@ begin
|
||||
if Style.SystemFont or Style.Clipping or (not Style.Opaque) then
|
||||
SaveState;
|
||||
|
||||
if Style.SystemFont then begin
|
||||
if Style.SystemFont then
|
||||
begin
|
||||
Options := Options or DT_INTERNAL;
|
||||
SelectObject(DC, GetStockObject(DEFAULT_GUI_FONT));
|
||||
end;
|
||||
@ -1063,9 +1064,10 @@ begin
|
||||
if Style.Layout = tlTop then
|
||||
fRect.Top := Y;
|
||||
|
||||
if (Style.Alignment in [taRightJustify,taCenter])
|
||||
or (Style.Layout in [tlCenter,tlBottom]) then begin
|
||||
DrawText(DC,pChar(Text),Length(Text),fRect,DT_CALCRECT or Options);
|
||||
if (Style.Alignment in [taRightJustify,taCenter]) or
|
||||
(Style.Layout in [tlCenter,tlBottom]) then
|
||||
begin
|
||||
DrawText(DC, pChar(Text), Length(Text), fRect, DT_CALCRECT or Options);
|
||||
case Style.Alignment of
|
||||
taRightJustify : OffsetRect(fRect, ARect.Right - fRect.Right, 0);
|
||||
taCenter : OffsetRect(fRect, (ARect.Right - fRect.Right) div 2, 0);
|
||||
@ -1077,27 +1079,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if Style.Clipping then begin
|
||||
if Style.Clipping then
|
||||
begin
|
||||
IntersectRect(ARect, ARect, fRect);
|
||||
with ARect do
|
||||
InterSectClipRect(DC, Left, Top, Right, Bottom);
|
||||
Options := Options or DT_NOCLIP; // no clipping as we are handling it here
|
||||
end;
|
||||
|
||||
if Style.Opaque then begin
|
||||
FillRect(fRect);
|
||||
end else begin
|
||||
if Style.Opaque then
|
||||
FillRect(fRect)
|
||||
else
|
||||
SetBkMode(DC, TRANSPARENT);
|
||||
end;
|
||||
|
||||
|
||||
if Style.SystemFont then
|
||||
SetTextColor(DC, Font.Color);
|
||||
//debugln('TCanvas.TextRect DRAW Text="',Text,'" ',dbgs(fRect));
|
||||
DrawText(DC, pChar(Text), Length(Text), fRect, Options);
|
||||
|
||||
if Style.Opaque and (csBrushValid in FState) then begin
|
||||
if Brush.Style=bsSolid then
|
||||
// restore BKMode
|
||||
if Style.Opaque and (csBrushValid in FState) then
|
||||
begin
|
||||
if Brush.Style=bsSolid then // restore BKMode
|
||||
SetBkMode(DC, OPAQUE)
|
||||
end;
|
||||
|
||||
|
@ -279,10 +279,11 @@ type
|
||||
procedure fillRect(x, y, w, h: Integer; ABrush: QBrushH); overload;
|
||||
procedure fillRect(x, y, w, h: Integer); overload;
|
||||
|
||||
procedure setBrushOrigin(x, y: Integer);
|
||||
procedure getBrushOrigin(retval: PPoint);
|
||||
function getClipping: Boolean;
|
||||
procedure getPenPos(retval: PPoint);
|
||||
function getWorldMatrix: QMatrixH;
|
||||
procedure setBrushOrigin(x, y: Integer);
|
||||
procedure setPenPos(x, y: Integer);
|
||||
|
||||
function font: TQtFont;
|
||||
@ -1710,6 +1711,11 @@ begin
|
||||
retval^.y := FPenPos.y;
|
||||
end;
|
||||
|
||||
function TQtDeviceContext.getWorldMatrix: QMatrixH;
|
||||
begin
|
||||
Result := QPainter_worldMatrix(Widget);
|
||||
end;
|
||||
|
||||
procedure TQtDeviceContext.setPenPos(x, y: Integer);
|
||||
begin
|
||||
FPenPos.X := x;
|
||||
|
@ -3552,6 +3552,7 @@ begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtGroupBox.Create ');
|
||||
{$endif}
|
||||
FHasPaint := True;
|
||||
Result := QGroupBox_create();
|
||||
FCentralWidget := QWidget_create(Result, 0);
|
||||
Layout := QVBoxLayout_create(Result);
|
||||
|
@ -1186,6 +1186,9 @@ begin
|
||||
|
||||
if Flags and DT_NOPREFIX = 0 then
|
||||
F := F or $800;{QTTextShowMnemonic;}
|
||||
|
||||
if Flags and DT_NOCLIP = 0 then
|
||||
F := F or $200; {QtTextDontClip}
|
||||
|
||||
QtDC.font.Metrics.BoundingRect(@R, @ARect, F, @WideStr);
|
||||
|
||||
@ -3153,42 +3156,32 @@ end;
|
||||
|
||||
function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
|
||||
var
|
||||
QtDC: TQtDeviceContext absolute dc;
|
||||
IntersectRgn, Rgn: QRegionH;
|
||||
X1,Y1,X2,Y2: Integer;
|
||||
QtDC: TQtDeviceContext;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('***** [WinAPI TQtWidgetSet.IntersectClipRect] ');
|
||||
{$endif}
|
||||
Result := ERROR;
|
||||
if not IsValidDC(DC) then exit;
|
||||
|
||||
QtDC := TQtDeviceContext(DC);
|
||||
|
||||
X1 := Left;
|
||||
Y1 := Top;
|
||||
X2 := Right;
|
||||
Y2 := Bottom;
|
||||
QMatrix_map(QPainter_worldMatrix(QtDC.Widget), X1, Y1, @X1, @Y1);
|
||||
QMatrix_map(QPainter_worldMatrix(QtDC.Widget), X2, Y2, @X2, @Y2);
|
||||
|
||||
IntersectRgn := QRegion_create(X1, Y1, X2 - X1, Y2 - Y1);
|
||||
IntersectRgn := QRegion_create(Left, Top, Right - Left, Bottom - Top);
|
||||
Rgn := QRegion_create;
|
||||
try
|
||||
if QPainter_hasClipping(QtDC.Widget) then
|
||||
if QtDC.getClipping then
|
||||
begin
|
||||
QPainter_clipRegion(QtDC.Widget, Rgn);
|
||||
if QRegion_isEmpty(Rgn) then
|
||||
QRegion_unite(Rgn, Rgn, IntersectRgn)
|
||||
QtDC.setClipRegion(IntersectRgn)
|
||||
else
|
||||
QRegion_intersect(Rgn, Rgn, IntersectRgn);
|
||||
QtDC.setClipRegion(IntersectRgn, QtIntersectClip);
|
||||
end
|
||||
else
|
||||
begin
|
||||
QtDC.setClipRegion(InterSectRgn);
|
||||
QPainter_clipRegion(QtDC.Widget, Rgn);
|
||||
end;
|
||||
QPainter_setClipping(QtDC.Widget, True);
|
||||
QtDC.setClipping(True);
|
||||
Result := QtDC.GetRegionType(Rgn);
|
||||
finally
|
||||
QRegion_destroy(IntersectRgn);
|
||||
|
Loading…
Reference in New Issue
Block a user