mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 04:19:12 +02:00
Qt:
- use cosmetic pens for GetStockObject - better handling of passed Pen.Width (0 = cosmetic, > 0 = geometric) - implement GetObject for HPEN git-svn-id: trunk@16803 -
This commit is contained in:
parent
c6336bf30d
commit
ab9944c497
@ -622,7 +622,7 @@ begin
|
|||||||
TQtBrush(FStockWhiteBrush).FShared := True;
|
TQtBrush(FStockWhiteBrush).FShared := True;
|
||||||
|
|
||||||
LogPen.lopnStyle := PS_NULL;
|
LogPen.lopnStyle := PS_NULL;
|
||||||
LogPen.lopnWidth.X := 1;
|
LogPen.lopnWidth := Point(0, 0); // create cosmetic pens
|
||||||
LogPen.lopnColor := $FFFFFF;
|
LogPen.lopnColor := $FFFFFF;
|
||||||
FStockNullPen := CreatePenIndirect(LogPen);
|
FStockNullPen := CreatePenIndirect(LogPen);
|
||||||
TQtPen(FStockNullPen).FShared := True;
|
TQtPen(FStockNullPen).FShared := True;
|
||||||
@ -635,7 +635,7 @@ begin
|
|||||||
FStockBlackPen := CreatePenIndirect(LogPen);
|
FStockBlackPen := CreatePenIndirect(LogPen);
|
||||||
TQtPen(FStockBlackPen).FShared := True;
|
TQtPen(FStockBlackPen).FShared := True;
|
||||||
|
|
||||||
FStockSystemFont := 0;//Styles aren't initialized yet
|
FStockSystemFont := 0; // styles aren't initialized yet
|
||||||
|
|
||||||
FStockDefaultDC := 0; // app must be initialized
|
FStockDefaultDC := 0; // app must be initialized
|
||||||
end;
|
end;
|
||||||
|
@ -212,13 +212,15 @@ type
|
|||||||
constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual;
|
constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
public
|
public
|
||||||
function Width: Integer;
|
function getWidth: Integer;
|
||||||
function Style: QtPenStyle;
|
function getStyle: QtPenStyle;
|
||||||
function getColor: TQColor;
|
function getColor: TQColor;
|
||||||
|
function getCosmetic: Boolean;
|
||||||
procedure setStyle(AStyle: QtPenStyle);
|
procedure setStyle(AStyle: QtPenStyle);
|
||||||
procedure setBrush(brush: QBrushH);
|
procedure setBrush(brush: QBrushH);
|
||||||
procedure setWidth(p1: Integer);
|
procedure setWidth(p1: Integer);
|
||||||
procedure setColor(p1: TQColor);
|
procedure setColor(p1: TQColor);
|
||||||
|
procedure setCosmetic(b: Boolean);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1417,6 +1419,16 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtPen.getWidth: Integer;
|
||||||
|
begin
|
||||||
|
Result := QPen_width(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtPen.getStyle: QtPenStyle;
|
||||||
|
begin
|
||||||
|
Result := QPen_style(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtPen.setBrush
|
Function: TQtPen.setBrush
|
||||||
Params: None
|
Params: None
|
||||||
@ -1448,34 +1460,17 @@ begin
|
|||||||
QPen_setWidth(Widget, p1);
|
QPen_setWidth(Widget, p1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: TQtPen.Style
|
|
||||||
Params: None
|
|
||||||
Returns: QPenStyle
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TQtPen.Style: QtPenStyle;
|
|
||||||
begin
|
|
||||||
Result := QPen_Style(Widget);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TQtPen.getColor: TQColor;
|
function TQtPen.getColor: TQColor;
|
||||||
begin
|
begin
|
||||||
QPen_color(Widget, @Result);
|
QPen_color(Widget, @Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtPen.getCosmetic: Boolean;
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: TQtPen.Width
|
|
||||||
Params: None
|
|
||||||
Returns: integer , width of current pen
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TQtPen.Width: Integer;
|
|
||||||
begin
|
begin
|
||||||
Result := QPen_Width(Widget);
|
Result := QPen_isCosmetic(Widget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtPen.setColor
|
Function: TQtPen.setColor
|
||||||
Params: p1: TQColor
|
Params: p1: TQColor
|
||||||
@ -1487,6 +1482,11 @@ begin
|
|||||||
QPen_setColor(Widget, @p1);
|
QPen_setColor(Widget, @p1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtPen.setCosmetic(b: Boolean);
|
||||||
|
begin
|
||||||
|
QPen_setCosmetic(Widget, b);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TQtRegion }
|
{ TQtRegion }
|
||||||
|
|
||||||
@ -2267,9 +2267,9 @@ end;
|
|||||||
|
|
||||||
procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef);
|
procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef);
|
||||||
begin
|
begin
|
||||||
AColorRef:=(( AColor.r shr 8) and $FF)
|
AColorRef := ((AColor.r shr 8) and $FF) or
|
||||||
or (AColor.g and $ff00)
|
(AColor.g and $FF00) or
|
||||||
or ((AColor.b shl 8) and $ff0000);
|
((AColor.b shl 8) and $FF0000);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor);
|
procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor);
|
||||||
|
@ -633,7 +633,13 @@ begin
|
|||||||
QtPen.setStyle(QtSolidLine);
|
QtPen.setStyle(QtSolidLine);
|
||||||
end;
|
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);
|
QPen_Color(QtPen.Widget, @Color);
|
||||||
ColorRefToTQColor(ColorToRGB(lopnColor), Color);
|
ColorRefToTQColor(ColorToRGB(lopnColor), Color);
|
||||||
@ -2163,11 +2169,24 @@ end;
|
|||||||
Necessary for TBitmap support
|
Necessary for TBitmap support
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidgetSet.GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer;
|
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
|
var
|
||||||
aObject: TObject;
|
aObject: TObject;
|
||||||
AFont: TQtFont absolute aObject;
|
AFont: TQtFont absolute aObject;
|
||||||
|
APen: TQtPen absolute aObject;
|
||||||
BitmapSection : TDIBSECTION;
|
BitmapSection : TDIBSECTION;
|
||||||
ALogFont: PLogFont absolute Buf;
|
ALogFont: PLogFont absolute Buf;
|
||||||
|
ALogPen: PLogPen absolute Buf;
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
ObjType: string;
|
ObjType: string;
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -2221,6 +2240,22 @@ begin
|
|||||||
ALogFont^.lfFaceName := UTF8Encode(AFont.getFamily);
|
ALogFont^.lfFaceName := UTF8Encode(AFont.getFamily);
|
||||||
end;
|
end;
|
||||||
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
|
Brush
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
Loading…
Reference in New Issue
Block a user