mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 22:49:30 +02:00
- add CreatePatternBrush for win32 and qt
- fix qt CreateBitmap (winapi expect word alignment while qt needs dword and supports more formats now) git-svn-id: trunk@12864 -
This commit is contained in:
parent
5de34c204b
commit
de0119b05e
@ -166,6 +166,11 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TWidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TWidgetSet.CreatePenIndirect(const LogPen: TLogPen): HPEN;
|
||||
begin
|
||||
Result := 0;
|
||||
|
@ -136,6 +136,11 @@ begin
|
||||
Result := WidgetSet.CreatePalette(LogPalette);
|
||||
end;
|
||||
|
||||
function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
|
||||
begin
|
||||
Result := WidgetSet.CreatePatternBrush(ABitmap);
|
||||
end;
|
||||
|
||||
function CreatePenIndirect(const LogPen: TLogPen): HPEN;
|
||||
begin
|
||||
Result := WidgetSet.CreatePenIndirect(LogPen);
|
||||
|
@ -66,6 +66,7 @@ function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; {$IFDEF IF_BASE_MEMBE
|
||||
function CreateFontIndirect(const LogFont: TLogFont): HFONT; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreatePalette(const LogPalette: TLogPalette): HPalette; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
//function CreatePen --> independent
|
||||
function CreatePenIndirect(const LogPen: TLogPen): HPEN; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreatePolygonRgn(Points: PPoint; NumPts: Integer; FillMode: integer): HRGN; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
@ -179,6 +179,8 @@ type
|
||||
constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual;
|
||||
destructor Destroy; override;
|
||||
procedure setStyle(style: QtBrushStyle);
|
||||
procedure setTexture(pixmap: QPixmapH);
|
||||
procedure setTextureImage(image: QImageH);
|
||||
end;
|
||||
|
||||
{ TQtPen }
|
||||
@ -1076,6 +1078,16 @@ begin
|
||||
QBrush_setStyle(Widget, style);
|
||||
end;
|
||||
|
||||
procedure TQtBrush.setTexture(pixmap: QPixmapH);
|
||||
begin
|
||||
QBrush_setTexture(Widget, pixmap);
|
||||
end;
|
||||
|
||||
procedure TQtBrush.setTextureImage(image: QImageH);
|
||||
begin
|
||||
QBrush_setTextureImage(Widget, image);
|
||||
end;
|
||||
|
||||
{ TQtPen }
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -328,6 +328,11 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.CreateBitmap(Width, Height: Integer;
|
||||
Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP;
|
||||
var
|
||||
Format: QImageFormat;
|
||||
NewBits: Pointer;
|
||||
NewBitsSize: PtrUInt;
|
||||
ARowStride, RSS: Integer;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('Trace:> [WinAPI CreateBitmap]',
|
||||
@ -338,8 +343,32 @@ begin
|
||||
' BitmapBits: ', dbgs(BitmapBits));
|
||||
{$endif}
|
||||
|
||||
Result := HBitmap(TQtImage.Create(BitmapBits, Width,
|
||||
Height, QImageFormat_ARGB32));
|
||||
// for win32 data is aligned to WORD
|
||||
// for qt we must realign data to DWORD
|
||||
|
||||
case BitCount of
|
||||
1: Format := QImageFormat_Mono;
|
||||
15, 16: Format := QImageFormat_RGB16;
|
||||
24: Format := QImageFormat_RGB32;
|
||||
32: Format := QImageFormat_ARGB32;
|
||||
else
|
||||
Format := QImageFormat_ARGB32;
|
||||
end;
|
||||
|
||||
RSS := GetBytesPerLine(Width, BitCount, rileWordBoundary);
|
||||
if BitmapBits <> nil then
|
||||
begin
|
||||
if not CopyImageData(Width, Height, RSS, BitCount, BitmapBits, Rect(0, 0, Width, Height),
|
||||
riloBottomToTop, riloBottomToTop, rileDWordBoundary, NewBits, NewBitsSize) then
|
||||
begin
|
||||
ARowStride := GetBytesPerLine(Width, BitCount, rileDWordBoundary);
|
||||
NewBits := AllocMem(ARowStride);
|
||||
Move(BitmapBits^, NewBits^, RSS);
|
||||
end;
|
||||
end
|
||||
else
|
||||
NewBits := nil;
|
||||
Result := HBitmap(TQtImage.Create(NewBits, Width, Height, Format, True));
|
||||
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('Trace:< [WinAPI CreateBitmap] Bitmap:', dbghex(Result));
|
||||
@ -572,6 +601,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
|
||||
var
|
||||
QtBrush: TQtBrush;
|
||||
begin
|
||||
Result := 0;
|
||||
QtBrush := TQtBrush.Create(True);
|
||||
QtBrush.setTextureImage(TQtImage(ABitmap).Handle);
|
||||
Result := HBRUSH(QtBrush);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: CreatePenIndirect
|
||||
Params: none
|
||||
|
@ -59,6 +59,7 @@ function CreateCursor(ACursorInfo: PIconInfo): hCursor; override;
|
||||
function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override;
|
||||
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
|
||||
function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override;
|
||||
function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override;
|
||||
function CreatePenIndirect(const LogPen: TLogPen): HBRUSH; override;
|
||||
function CreatePixmapIndirect(const Data: Pointer; const TransColor: Longint): HBITMAP; override;
|
||||
function CreatePolygonRgn(Points: PPoint; NumPts: Integer; FillMode: integer): HRGN; override;
|
||||
|
@ -807,6 +807,11 @@ Begin
|
||||
Result := Windows.CreateFontIndirect(@TempLogFont);
|
||||
End;
|
||||
|
||||
function TWin32WidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
|
||||
begin
|
||||
Result := Windows.CreatePatternBrush(ABitmap);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: CreatePenIndirect
|
||||
Params: LogPen - record that defines the style, width, and color of a pen
|
||||
|
@ -55,6 +55,7 @@ function CreateCursor(ACursorInfo: PIconInfo): hCursor; Override;
|
||||
function CreateDIBSection(DC: HDC; const p2: tagBitmapInfo; p3: UINT;
|
||||
var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; Override;
|
||||
function CreateFontIndirect(Const LogFont: TLogFont): HFONT; Override;
|
||||
function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override;
|
||||
function CreatePenIndirect(Const LogPen: TLogPen): HPEN; Override;
|
||||
{ Creates a bitmap from raw pixmap data }
|
||||
function CreatePixmapIndirect(Const Data: Pointer; Const TransColor: LongInt): HBITMAP; Override;
|
||||
|
Loading…
Reference in New Issue
Block a user