diff --git a/lcl/interfaces/qt/qtobject.inc b/lcl/interfaces/qt/qtobject.inc index e6661e2dc4..0cd436e70f 100644 --- a/lcl/interfaces/qt/qtobject.inc +++ b/lcl/interfaces/qt/qtobject.inc @@ -622,7 +622,7 @@ begin TQtBrush(FStockWhiteBrush).FShared := True; LogPen.lopnStyle := PS_NULL; - LogPen.lopnWidth.X := 1; + LogPen.lopnWidth := Point(0, 0); // create cosmetic pens LogPen.lopnColor := $FFFFFF; FStockNullPen := CreatePenIndirect(LogPen); TQtPen(FStockNullPen).FShared := True; @@ -635,7 +635,7 @@ begin FStockBlackPen := CreatePenIndirect(LogPen); TQtPen(FStockBlackPen).FShared := True; - FStockSystemFont := 0;//Styles aren't initialized yet + FStockSystemFont := 0; // styles aren't initialized yet FStockDefaultDC := 0; // app must be initialized end; diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 0d9a5d1db7..e6c563bff6 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -212,13 +212,15 @@ type constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual; destructor Destroy; override; public - function Width: Integer; - function Style: QtPenStyle; + function getWidth: Integer; + function getStyle: QtPenStyle; function getColor: TQColor; + function getCosmetic: Boolean; procedure setStyle(AStyle: QtPenStyle); procedure setBrush(brush: QBrushH); procedure setWidth(p1: Integer); procedure setColor(p1: TQColor); + procedure setCosmetic(b: Boolean); end; @@ -1417,6 +1419,16 @@ begin inherited Destroy; end; +function TQtPen.getWidth: Integer; +begin + Result := QPen_width(Widget); +end; + +function TQtPen.getStyle: QtPenStyle; +begin + Result := QPen_style(Widget); +end; + {------------------------------------------------------------------------------ Function: TQtPen.setBrush Params: None @@ -1448,34 +1460,17 @@ begin QPen_setWidth(Widget, p1); end; - -{------------------------------------------------------------------------------ - Function: TQtPen.Style - Params: None - Returns: QPenStyle - ------------------------------------------------------------------------------} -function TQtPen.Style: QtPenStyle; -begin - Result := QPen_Style(Widget); -end; - function TQtPen.getColor: TQColor; begin QPen_color(Widget, @Result); end; - -{------------------------------------------------------------------------------ - Function: TQtPen.Width - Params: None - Returns: integer , width of current pen - - ------------------------------------------------------------------------------} -function TQtPen.Width: Integer; +function TQtPen.getCosmetic: Boolean; begin - Result := QPen_Width(Widget); + Result := QPen_isCosmetic(Widget); end; + {------------------------------------------------------------------------------ Function: TQtPen.setColor Params: p1: TQColor @@ -1487,6 +1482,11 @@ begin QPen_setColor(Widget, @p1); end; +procedure TQtPen.setCosmetic(b: Boolean); +begin + QPen_setCosmetic(Widget, b); +end; + { TQtRegion } @@ -2267,9 +2267,9 @@ end; procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef); begin - AColorRef:=(( AColor.r shr 8) and $FF) - or (AColor.g and $ff00) - or ((AColor.b shl 8) and $ff0000); + AColorRef := ((AColor.r shr 8) and $FF) or + (AColor.g and $FF00) or + ((AColor.b shl 8) and $FF0000); end; procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor); diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index a8872811c9..13c106b4ee 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -633,7 +633,13 @@ begin QtPen.setStyle(QtSolidLine); end; - QtPen.setWidth(lopnWidth.X); + if lopnWidth.X <= 0 then + QtPen.setCosmetic(True) + else + begin + QtPen.setCosmetic(False); + QtPen.setWidth(lopnWidth.X); + end; QPen_Color(QtPen.Widget, @Color); ColorRefToTQColor(ColorToRGB(lopnColor), Color); @@ -2163,11 +2169,24 @@ end; Necessary for TBitmap support ------------------------------------------------------------------------------} function TQtWidgetSet.GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; +const + QtPenStyleToWinStyleMap: array[QtPenStyle] of UINT = + ( + { QtNoPen } PS_NULL, + { QtSolidLine } PS_SOLID, + { QtDashLine } PS_DASH, + { QtDotLine } PS_DOT, + { QtDashDotLine } PS_DASHDOT, + { QtDashDotDotLine } PS_DASHDOTDOT, + { QtCustomDashLine } PS_USERSTYLE + ); var aObject: TObject; AFont: TQtFont absolute aObject; + APen: TQtPen absolute aObject; BitmapSection : TDIBSECTION; ALogFont: PLogFont absolute Buf; + ALogPen: PLogPen absolute Buf; {$ifdef VerboseQtWinAPI} ObjType: string; {$endif} @@ -2221,6 +2240,22 @@ begin ALogFont^.lfFaceName := UTF8Encode(AFont.getFamily); end; end + {------------------------------------------------------------------------------ + Pen + ------------------------------------------------------------------------------} + else + if aObject is TQtPen then + begin + if BufSize = SizeOf(TLogPen) then + begin + TQColorToColorRef(APen.getColor, ALogPen^.lopnColor); + if APen.getCosmetic then + ALogPen^.lopnWidth := Point(0, 0) + else + ALogPen^.lopnWidth := Point(APen.getWidth, 0); + ALogPen^.lopnStyle := QtPenStyleToWinStyleMap[APen.getStyle]; + end; + end {------------------------------------------------------------------------------ Brush ------------------------------------------------------------------------------}