diff --git a/lcl/include/canvas.inc b/lcl/include/canvas.inc index af7679ef6f..ec27bd80e1 100644 --- a/lcl/include/canvas.inc +++ b/lcl/include/canvas.inc @@ -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; diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 482b1053a0..d8bc506442 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -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; diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 1d270ad48a..c0358d257d 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -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); diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 2790793c14..5f64af4de4 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -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);