mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-21 13:02:29 +02:00

- InsertBitmap improved to add multiple bitmaps from one big - GetBitmap extended to get Bitmaps with different effects - add DrawToDC to win32 imagelist to give ability to draw without TCanvas (having only HDC) TButtonGlyph: - use internal imagelist to perform different state drawing of glyph TBitBtn: - send ButtonGlyph to widgetset instead of TBitmap to perform different state drawing git-svn-id: trunk@12779 -
114 lines
3.4 KiB
ObjectPascal
114 lines
3.4 KiB
ObjectPascal
{ $Id$}
|
|
{
|
|
*****************************************************************************
|
|
* QtWSButtons.pp *
|
|
* -------------- *
|
|
* *
|
|
* *
|
|
*****************************************************************************
|
|
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
|
* for details about the copyright. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
* *
|
|
*****************************************************************************
|
|
}
|
|
unit QtWSButtons;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
{$I qtdefines.inc}
|
|
|
|
uses
|
|
// Libs
|
|
{$ifdef USE_QT_4_3}
|
|
qt43,
|
|
{$else}
|
|
qt4,
|
|
{$endif}
|
|
qtwidgets, qtobjects,
|
|
// LCL
|
|
SysUtils, Controls, LCLType, Forms, InterfaceBase, Buttons, LMessages, Graphics, GraphType,
|
|
// Widgetset
|
|
WSProc, WSButtons, WSLCLClasses;
|
|
|
|
type
|
|
|
|
{ TQtWSBitBtn }
|
|
|
|
TQtWSBitBtn = class(TWSBitBtn)
|
|
private
|
|
protected
|
|
public
|
|
class procedure SetGlyph(const ABitBtn: TCustomBitBtn; const AValue: TButtonGlyph); override;
|
|
end;
|
|
|
|
{ TQtWSSpeedButton }
|
|
|
|
TQtWSSpeedButton = class(TWSSpeedButton)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses QtWSControls;
|
|
|
|
{ TQtWSBitBtn }
|
|
|
|
{------------------------------------------------------------------------------
|
|
Function: TQtWSBitBtn.SetGlyph
|
|
Params: None
|
|
Returns: Nothing
|
|
------------------------------------------------------------------------------}
|
|
class procedure TQtWSBitBtn.SetGlyph(const ABitBtn: TCustomBitBtn; const AValue: TButtonGlyph);
|
|
var
|
|
AIcon: QIconH;
|
|
APixmap: QPixmapH;
|
|
AGlyph: TBitmap;
|
|
AIndex: Integer;
|
|
AEffect: TGraphicsDrawEffect;
|
|
begin
|
|
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;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
|
|
////////////////////////////////////////////////////
|
|
// I M P O R T A N T
|
|
////////////////////////////////////////////////////
|
|
// To improve speed, register only classes
|
|
// which actually implement something
|
|
////////////////////////////////////////////////////
|
|
RegisterWSComponent(TCustomBitBtn, TQtWSBitBtn);
|
|
// RegisterWSComponent(TCustomSpeedButton, TQtWSSpeedButton);
|
|
////////////////////////////////////////////////////
|
|
end.
|