mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-09 17:38:12 +02:00
Qt: TQtBrush added Style property, implemented TQtWidgetSet.GetObject() returning TLogBrush.
git-svn-id: trunk@33040 -
This commit is contained in:
parent
1923bcff9e
commit
38a2f4a30d
@ -233,15 +233,18 @@ type
|
|||||||
|
|
||||||
TQtBrush = class(TQtResource)
|
TQtBrush = class(TQtResource)
|
||||||
private
|
private
|
||||||
|
function getStyle: QtBrushStyle;
|
||||||
|
procedure setStyle(style: QtBrushStyle);
|
||||||
public
|
public
|
||||||
Widget: QBrushH;
|
Widget: QBrushH;
|
||||||
constructor Create(CreateHandle: Boolean); virtual;
|
constructor Create(CreateHandle: Boolean); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function getColor: PQColor;
|
function getColor: PQColor;
|
||||||
|
function GetLBStyle(out AStyle: LongWord; out AHatch: PtrUInt): Boolean;
|
||||||
procedure setColor(AColor: PQColor);
|
procedure setColor(AColor: PQColor);
|
||||||
procedure setStyle(style: QtBrushStyle);
|
|
||||||
procedure setTexture(pixmap: QPixmapH);
|
procedure setTexture(pixmap: QPixmapH);
|
||||||
procedure setTextureImage(image: QImageH);
|
procedure setTextureImage(image: QImageH);
|
||||||
|
property Style: QtBrushStyle read getStyle write setStyle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtPen }
|
{ TQtPen }
|
||||||
@ -1601,11 +1604,39 @@ begin
|
|||||||
Result := QBrush_Color(Widget);
|
Result := QBrush_Color(Widget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtBrush.GetLBStyle(out AStyle: LongWord; out AHatch: PtrUInt
|
||||||
|
): Boolean;
|
||||||
|
var
|
||||||
|
BrushStyle: QtBrushStyle;
|
||||||
|
begin
|
||||||
|
AStyle := BS_SOLID;
|
||||||
|
if BrushStyle in [QtHorPattern, QtVerPattern, QtCrossPattern,
|
||||||
|
QtBDiagPattern, QtFDiagPattern, QtDiagCrossPattern] then
|
||||||
|
AStyle := BS_HATCHED
|
||||||
|
else
|
||||||
|
AHatch := 0;
|
||||||
|
case BrushStyle of
|
||||||
|
QtNoBrush: AStyle := BS_NULL;
|
||||||
|
QtHorPattern: AHatch := HS_HORIZONTAL;
|
||||||
|
QtVerPattern: AHatch := HS_VERTICAL;
|
||||||
|
QtCrossPattern: AHatch := HS_CROSS;
|
||||||
|
QtBDiagPattern: AHatch := HS_BDIAGONAL;
|
||||||
|
QtFDiagPattern: AHatch := HS_FDIAGONAL;
|
||||||
|
QtDiagCrossPattern: AHatch := HS_DIAGCROSS;
|
||||||
|
QtTexturePattern: AStyle := BS_PATTERN;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQtBrush.setColor(AColor: PQColor);
|
procedure TQtBrush.setColor(AColor: PQColor);
|
||||||
begin
|
begin
|
||||||
QBrush_setColor(Widget, AColor);
|
QBrush_setColor(Widget, AColor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtBrush.getStyle: QtBrushStyle;
|
||||||
|
begin
|
||||||
|
Result := QBrush_style(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtBrush.setStyle
|
Function: TQtBrush.setStyle
|
||||||
Params: None
|
Params: None
|
||||||
|
@ -415,25 +415,25 @@ begin
|
|||||||
// BS_HOLLOW, // Hollow brush.
|
// BS_HOLLOW, // Hollow brush.
|
||||||
BS_NULL: // Same as BS_HOLLOW.
|
BS_NULL: // Same as BS_HOLLOW.
|
||||||
begin
|
begin
|
||||||
QtBrush.setStyle(QtNoBrush);
|
QtBrush.Style := QtNoBrush;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
BS_SOLID: // Solid brush.
|
BS_SOLID: // Solid brush.
|
||||||
begin
|
begin
|
||||||
QtBrush.setStyle(QtSolidPattern);
|
QtBrush.Style := QtSolidPattern;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
BS_HATCHED: // Hatched brush.
|
BS_HATCHED: // Hatched brush.
|
||||||
begin
|
begin
|
||||||
case LogBrush.lbHatch of
|
case LogBrush.lbHatch of
|
||||||
HS_BDIAGONAL: QtBrush.setStyle(QtBDiagPattern);
|
HS_BDIAGONAL: QtBrush.Style := QtBDiagPattern;
|
||||||
HS_CROSS: QtBrush.setStyle(QtCrossPattern);
|
HS_CROSS: QtBrush.Style := QtCrossPattern;
|
||||||
HS_DIAGCROSS: QtBrush.setStyle(QtDiagCrossPattern);
|
HS_DIAGCROSS: QtBrush.Style := QtDiagCrossPattern;
|
||||||
HS_FDIAGONAL: QtBrush.setStyle(QtFDiagPattern);
|
HS_FDIAGONAL: QtBrush.Style := QtFDiagPattern;
|
||||||
HS_HORIZONTAL: QtBrush.setStyle(QtHorPattern);
|
HS_HORIZONTAL: QtBrush.Style := QtHorPattern;
|
||||||
HS_VERTICAL: QtBrush.setStyle(QtVerPattern);
|
HS_VERTICAL: QtBrush.Style := QtVerPattern;
|
||||||
else
|
else
|
||||||
QtBrush.setStyle(QtSolidPattern);
|
QtBrush.Style := QtSolidPattern;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -451,6 +451,7 @@ begin
|
|||||||
BS_PATTERN8X8: // Same as BS_PATTERN.
|
BS_PATTERN8X8: // Same as BS_PATTERN.
|
||||||
begin
|
begin
|
||||||
QtBrush.setTextureImage(TQtImage(LogBrush.lbHatch).Handle);
|
QtBrush.setTextureImage(TQtImage(LogBrush.lbHatch).Handle);
|
||||||
|
QtBrush.Style := QtTexturePattern;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
DebugLn(Format('Unsupported Style %d',[LogBrush.lbStyle]));
|
DebugLn(Format('Unsupported Style %d',[LogBrush.lbStyle]));
|
||||||
@ -473,7 +474,7 @@ begin
|
|||||||
// set brush color
|
// set brush color
|
||||||
Color := QBrush_Color(QtBrush.Widget)^;
|
Color := QBrush_Color(QtBrush.Widget)^;
|
||||||
ColorRefToTQColor(ColorToRGB(TColor(logBrush.lbColor)), Color);
|
ColorRefToTQColor(ColorToRGB(TColor(logBrush.lbColor)), Color);
|
||||||
QBrush_setColor(QtBrush.Widget, @Color);
|
QtBrush.setColor(@Color);
|
||||||
except
|
except
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI CreateBrushIndirect] Failed');
|
WriteLn('[WinAPI CreateBrushIndirect] Failed');
|
||||||
@ -3011,10 +3012,12 @@ var
|
|||||||
aObject: TObject;
|
aObject: TObject;
|
||||||
AFont: TQtFont absolute aObject;
|
AFont: TQtFont absolute aObject;
|
||||||
APen: TQtPen absolute aObject;
|
APen: TQtPen absolute aObject;
|
||||||
|
ABrush: TQtBrush absolute aObject;
|
||||||
BitmapSection : TDIBSECTION;
|
BitmapSection : TDIBSECTION;
|
||||||
ALogFont: PLogFont absolute Buf;
|
ALogFont: PLogFont absolute Buf;
|
||||||
ALogPen: PLogPen absolute Buf;
|
ALogPen: PLogPen absolute Buf;
|
||||||
AExtLogPen: PExtLogPen absolute Buf;
|
AExtLogPen: PExtLogPen absolute Buf;
|
||||||
|
ALogBrush: PLogBrush absolute Buf;
|
||||||
Dashes: TQRealArray;
|
Dashes: TQRealArray;
|
||||||
i: integer;
|
i: integer;
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
@ -3158,7 +3161,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Brush
|
Region
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
else
|
else
|
||||||
if aObject is TQtRegion then
|
if aObject is TQtRegion then
|
||||||
@ -3168,12 +3171,20 @@ begin
|
|||||||
ObjType := 'Region';
|
ObjType := 'Region';
|
||||||
{$endif}
|
{$endif}
|
||||||
end else
|
end else
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Brush
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
if aObject is TQtBrush then
|
if aObject is TQtBrush then
|
||||||
begin
|
begin
|
||||||
{TODO: implement Brush}
|
if Buf = nil then
|
||||||
{$ifdef VerboseQtWinAPI}
|
Result := SizeOf(TLogBrush)
|
||||||
ObjType := 'Brush';
|
else
|
||||||
{$endif}
|
if BufSize >= SizeOf(TLogBrush) then
|
||||||
|
begin
|
||||||
|
Result := SizeOf(TLogBrush);
|
||||||
|
TQColorToColorRef(ABrush.getColor^, ALogBrush^.lbColor);
|
||||||
|
ABrush.GetLbStyle(ALogBrush^.lbStyle, ALogBrush^.lbHatch);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Image
|
Image
|
||||||
|
Loading…
Reference in New Issue
Block a user