mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-25 22:30:29 +01:00
qt:
- add missing part of RawImage_FromBitmap - TQtImage new constructor Create and method CopyFrom - improve TQtWSBitBtn.SetGlyph git-svn-id: trunk@13603 -
This commit is contained in:
parent
c13f4b790d
commit
f83c8f994c
@ -373,11 +373,13 @@ begin
|
||||
WorkMask := Mask;
|
||||
end
|
||||
else begin
|
||||
// Create SubImage
|
||||
{$note TODO: Use create subimage when size doesn't match }
|
||||
// for now return image
|
||||
WorkImage := Image;
|
||||
WorkMask := Mask;
|
||||
WorkImage := TQtImage.Create;
|
||||
WorkImage.CopyFrom(Image.Handle, ARect.Left, ARect.Top, Width, Height);
|
||||
if Mask <> nil then
|
||||
begin
|
||||
WorkMask := TQtImage.Create;
|
||||
WorkMask.CopyFrom(Mask.Handle, ARect.Left, ARect.Top, Width, Height);
|
||||
end;
|
||||
end;
|
||||
|
||||
Desc.Width := WorkImage.width;
|
||||
@ -396,6 +398,11 @@ begin
|
||||
if ARawImage.MaskSize > 0 then
|
||||
Move(WorkMask.bits^, ARawImage.Mask^, ARawImage.MaskSize);
|
||||
end;
|
||||
|
||||
if WorkImage <> Image then
|
||||
WorkImage.Free;
|
||||
if WorkMask <> Mask then
|
||||
WorkMask.Free;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
@ -107,11 +107,13 @@ type
|
||||
public
|
||||
Handle: QImageH;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(vHandle: QImageH); overload;
|
||||
constructor Create(Adata: PByte; width: Integer; height: Integer; format: QImageFormat; const ADataOwner: Boolean = False); overload;
|
||||
destructor Destroy; override;
|
||||
function AsIcon(AMode: QIconMode = QIconNormal; AState: QIconState = QIconOff): QIconH;
|
||||
function AsPixmap: QPixmapH;
|
||||
procedure CopyFrom(AImage: QImageH; x, y, w, h: integer);
|
||||
public
|
||||
function height: Integer;
|
||||
function width: Integer;
|
||||
@ -556,7 +558,7 @@ end;
|
||||
function QtScreenContext: TQtDeviceContext;
|
||||
begin
|
||||
if FScreenContext = nil then
|
||||
FScreenContext := TQtDeviceContext.Create(QApplication_desktop(), False);
|
||||
FScreenContext := TQtDeviceContext.Create(QApplication_desktop(), True);
|
||||
Result := FScreenContext;
|
||||
end;
|
||||
|
||||
@ -745,6 +747,13 @@ end;
|
||||
|
||||
{ TQtImage }
|
||||
|
||||
constructor TQtImage.Create;
|
||||
begin
|
||||
Handle := QImage_create();
|
||||
FData := nil;
|
||||
FDataOwner := False;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TQtImage.Create
|
||||
|
||||
@ -817,6 +826,11 @@ begin
|
||||
QPixmap_fromImage(Result, Handle);
|
||||
end;
|
||||
|
||||
procedure TQtImage.CopyFrom(AImage: QImageH; x, y, w, h: integer);
|
||||
begin
|
||||
QImage_copy(AImage, Handle, x, y, w, h);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TQtImage.height
|
||||
Params: None
|
||||
|
||||
@ -73,34 +73,42 @@ uses QtWSControls;
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSBitBtn.SetGlyph(const ABitBtn: TCustomBitBtn; const AValue: TButtonGlyph);
|
||||
const
|
||||
IconModeToButtonState: array[QIconMode] of TButtonState =
|
||||
(
|
||||
{ QIconNormal } bsUp,
|
||||
{ QIconDisabled } bsDisabled,
|
||||
{ QIconActive } bsHot,
|
||||
{ QIconSelected } bsDown
|
||||
);
|
||||
|
||||
var
|
||||
AIcon: QIconH;
|
||||
APixmap: QPixmapH;
|
||||
AGlyph: TBitmap;
|
||||
AIndex: Integer;
|
||||
AEffect: TGraphicsDrawEffect;
|
||||
Mode: QIconMode;
|
||||
begin
|
||||
|
||||
if not Assigned(AValue.Images) then
|
||||
exit;
|
||||
if not WSCheckHandleAllocated(ABitBtn, 'SetGlyph') or
|
||||
not Assigned(AValue.Images) then
|
||||
Exit;
|
||||
|
||||
AIcon := QIcon_create();
|
||||
AGlyph := TBitmap.Create;
|
||||
APixmap := QPixmap_create();
|
||||
|
||||
AGlyph := TBitmap.Create;
|
||||
AValue.GetImageIndexAndEffect(bsUp, AIndex, AEffect);
|
||||
AValue.Images.GetBitmap(AIndex, AGlyph, AEffect);
|
||||
|
||||
QPixmap_fromImage(APixmap, TQtImage(AGlyph.Handle).Handle);
|
||||
try
|
||||
if APixmap <> nil then
|
||||
begin
|
||||
AIcon := QIcon_create(APixmap);
|
||||
TQtAbstractButton(ABitBtn.Handle).setIcon(AIcon);
|
||||
end;
|
||||
finally
|
||||
QPixmap_destroy(APixmap);
|
||||
AGlyph.Free;
|
||||
for Mode := QIconNormal to QIconSelected do
|
||||
begin
|
||||
AValue.GetImageIndexAndEffect(IconModeToButtonState[Mode], AIndex, AEffect);
|
||||
AValue.Images.GetBitmap(AIndex, AGlyph, AEffect);
|
||||
QPixmap_fromImage(APixmap, TQtImage(AGlyph.Handle).Handle);
|
||||
QIcon_addPixmap(AIcon, APixmap, Mode, QIconOn);
|
||||
end;
|
||||
QPixmap_destroy(APixmap);
|
||||
AGlyph.Free;
|
||||
|
||||
TQtAbstractButton(ABitBtn.Handle).setIcon(AIcon);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
@ -246,13 +246,6 @@ type
|
||||
|
||||
implementation
|
||||
const
|
||||
PanelBevelToQtFrameShapeMap: array[TStatusPanelBevel] of Integer =
|
||||
(
|
||||
{pbNone } Integer(QFrameNoFrame),
|
||||
{pbLowered} Integer(QFrameStyledPanel) or Integer(QFrameSunken),
|
||||
{pbRaised } Integer(QFrameStyledPanel) or Integer(QFrameRaised)
|
||||
);
|
||||
|
||||
TickMarkToQtSliderTickPositionMap: array[TTickMark] of QSliderTickPosition =
|
||||
(
|
||||
{tmBoth } QSliderTicksBothSides,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user