mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 17:00:38 +02:00
lcl: start ExtCreatePen function to allow pen creation with different cap style, join style, and pattern
qt: start implementation of ExtCreatePen git-svn-id: trunk@17119 -
This commit is contained in:
parent
5ca161df3b
commit
3461ad0f49
@ -770,6 +770,18 @@ begin
|
||||
Result:=ERROR;
|
||||
end;
|
||||
|
||||
function TWidgetSet.ExtCreatePen(dwPenStyle, dwWidth: DWord;
|
||||
const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
|
||||
var
|
||||
ALogPen: TLogPen;
|
||||
begin
|
||||
// if there is no widgetset implementation use this best match
|
||||
ALogPen.lopnColor := lplb.lbColor;
|
||||
ALogPen.lopnStyle := dwPenStyle;
|
||||
ALogPen.lopnWidth := Point(dwWidth, 0);
|
||||
Result := CreatePenIndirect(ALogPen);
|
||||
end;
|
||||
|
||||
function TWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
|
@ -258,6 +258,11 @@ begin
|
||||
Result := WidgetSet.ExcludeClipRect(DC,Left,Top,Right,Bottom);
|
||||
end;
|
||||
|
||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
|
||||
begin
|
||||
Result := WidgetSet.ExtCreatePen(dwPenStyle, dwWidth, lplb, dwStyleCount, lpStyle);
|
||||
end;
|
||||
|
||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
|
||||
begin
|
||||
Result := WidgetSet.ExtTextOut(DC, X, Y, Options, Rect, Str, Count, Dx);
|
||||
|
@ -96,6 +96,7 @@ function EnumFontFamiliesEx(DC: HDC; lpLogFont:PLogFont; Callback: FontEnumExPro
|
||||
function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
//function EqualRect --> independent
|
||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
||||
|
@ -209,20 +209,28 @@ type
|
||||
|
||||
TQtPen = class(TQtResource)
|
||||
private
|
||||
FIsExtPen: Boolean;
|
||||
public
|
||||
Widget: QPenH;
|
||||
constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual;
|
||||
constructor Create(CreateHandle: Boolean; const AShared: Boolean = False); virtual;
|
||||
destructor Destroy; override;
|
||||
public
|
||||
function getWidth: Integer;
|
||||
function getStyle: QtPenStyle;
|
||||
function getCapStyle: QtPenCapStyle;
|
||||
function getColor: TQColor;
|
||||
function getCosmetic: Boolean;
|
||||
function getJoinStyle: QtPenJoinStyle;
|
||||
function getWidth: Integer;
|
||||
function getStyle: QtPenStyle;
|
||||
|
||||
procedure setCapStyle(pcs: QtPenCapStyle);
|
||||
procedure setColor(p1: TQColor);
|
||||
procedure setCosmetic(b: Boolean);
|
||||
procedure setJoinStyle(pcs: QtPenJoinStyle);
|
||||
procedure setStyle(AStyle: QtPenStyle);
|
||||
procedure setBrush(brush: QBrushH);
|
||||
procedure setWidth(p1: Integer);
|
||||
procedure setColor(p1: TQColor);
|
||||
procedure setCosmetic(b: Boolean);
|
||||
|
||||
property IsExtPen: Boolean read FIsExtPen write FIsExtPen;
|
||||
end;
|
||||
|
||||
|
||||
@ -1406,7 +1414,7 @@ end;
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
constructor TQtPen.Create(CreateHandle: Boolean; Const AShared: Boolean = False);
|
||||
constructor TQtPen.Create(CreateHandle: Boolean; const AShared: Boolean = False);
|
||||
begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtPen.Create CreateHandle: ', dbgs(CreateHandle));
|
||||
@ -1415,6 +1423,7 @@ begin
|
||||
if CreateHandle then
|
||||
Widget := QPen_create;
|
||||
FShared := AShared;
|
||||
FIsExtPen := False;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1434,6 +1443,11 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TQtPen.getCapStyle: QtPenCapStyle;
|
||||
begin
|
||||
Result := QPen_capStyle(Widget);
|
||||
end;
|
||||
|
||||
function TQtPen.getWidth: Integer;
|
||||
begin
|
||||
Result := QPen_width(Widget);
|
||||
@ -1475,6 +1489,11 @@ begin
|
||||
QPen_setWidth(Widget, p1);
|
||||
end;
|
||||
|
||||
procedure TQtPen.setJoinStyle(pcs: QtPenJoinStyle);
|
||||
begin
|
||||
QPen_setJoinStyle(Widget, pcs);
|
||||
end;
|
||||
|
||||
function TQtPen.getColor: TQColor;
|
||||
begin
|
||||
QPen_color(Widget, @Result);
|
||||
@ -1485,6 +1504,16 @@ begin
|
||||
Result := QPen_isCosmetic(Widget);
|
||||
end;
|
||||
|
||||
function TQtPen.getJoinStyle: QtPenJoinStyle;
|
||||
begin
|
||||
Result := QPen_joinStyle(Widget);
|
||||
end;
|
||||
|
||||
procedure TQtPen.setCapStyle(pcs: QtPenCapStyle);
|
||||
begin
|
||||
QPen_setCapStyle(Widget, pcs);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtPen.setColor
|
||||
|
@ -1470,6 +1470,55 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.ExtCreatePen(dwPenStyle, dwWidth: DWord;
|
||||
const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
|
||||
var
|
||||
QtPen: TQtPen;
|
||||
color: TQColor;
|
||||
begin
|
||||
Result := 0;
|
||||
QtPen := TQtPen.Create(True);
|
||||
QtPen.IsExtPen := True;
|
||||
|
||||
case dwPenStyle and PS_STYLE_MASK of
|
||||
PS_SOLID: QtPen.setStyle(QtSolidLine);
|
||||
PS_DASH: QtPen.setStyle(QtDashLine);
|
||||
PS_DOT: QtPen.setStyle(QtDotLine);
|
||||
PS_DASHDOT: QtPen.setStyle(QtDashDotLine);
|
||||
PS_DASHDOTDOT: QtPen.setStyle(QtDashDotDotLine);
|
||||
PS_USERSTYLE: QtPen.setStyle(QtCustomDashLine);
|
||||
PS_NULL: QtPen.setStyle(QtNoPen);
|
||||
end;
|
||||
|
||||
QtPen.setCosmetic((dwPenStyle and PS_TYPE_MASK) = PS_COSMETIC);
|
||||
if (dwPenStyle and PS_TYPE_MASK) = PS_GEOMETRIC then
|
||||
begin
|
||||
QtPen.setWidth(dwWidth);
|
||||
case dwPenStyle and PS_JOIN_MASK of
|
||||
PS_JOIN_ROUND: QtPen.setJoinStyle(QtRoundJoin);
|
||||
PS_JOIN_BEVEL: QtPen.setJoinStyle(QtBevelJoin);
|
||||
PS_JOIN_MITER: QtPen.setJoinStyle(QtMiterJoin);
|
||||
end;
|
||||
|
||||
case dwPenStyle and PS_ENDCAP_MASK of
|
||||
PS_ENDCAP_ROUND: QtPen.setCapStyle(QtRoundCap);
|
||||
PS_ENDCAP_SQUARE: QtPen.setCapStyle(QtSquareCap);
|
||||
PS_ENDCAP_FLAT: QtPen.setCapStyle(QtFlatCap);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (dwPenStyle and PS_STYLE_MASK) = PS_USERSTYLE then
|
||||
begin
|
||||
// TODO: use QPen_setDashPatten which are available since qt 4.1
|
||||
end;
|
||||
|
||||
QPen_Color(QtPen.Widget, @Color);
|
||||
ColorRefToTQColor(ColorToRGB(lplb.lbColor), Color);
|
||||
QPen_setColor(QtPen.Widget, @Color);
|
||||
|
||||
Result := HPEN(QtPen);
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer;
|
||||
var
|
||||
Clip,
|
||||
|
@ -80,6 +80,7 @@ function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;
|
||||
procedure EnterCriticalSection(var CritSection: TCriticalSection); override;
|
||||
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
|
||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||
|
||||
|
@ -1326,6 +1326,12 @@ begin
|
||||
Result := Windows.ExcludeClipRect(dc, Left, Top, Right, Bottom);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.ExtCreatePen(dwPenStyle, dwWidth: DWord;
|
||||
const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
|
||||
begin
|
||||
Result := Windows.ExtCreatePen(dwPenStyle, dwWidth, Windows.TLOGBRUSH(lplb), dwStyleCount, lpStyle);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: ExtTextOut
|
||||
Params: DC - handle to device context
|
||||
|
@ -78,6 +78,7 @@ function EndPaint(Handle : hwnd; var PS : TPaintStruct): Integer; override;
|
||||
function EnumFontFamilies(DC: HDC; Family:Pchar; EnumFontFamProc: FontEnumProc; LParam:Lparam):longint; override;
|
||||
function EnumFontFamiliesEx(DC:HDC; lpLogFont:PLogFont; Callback: FontEnumExProc; LParam:Lparam; flags:dword):longint; override;
|
||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: LongInt; Rect: PRect; Str: PChar; Count: LongInt; Dx: PInteger): Boolean; override;
|
||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user