You've already forked lazarus-ccr
TGradButton:
- Added TGradCustomControl - Added DropDown-SplitButton Support git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1455 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
71
components/gradcontrols/src/gradcustomcontrol.pas
Executable file
71
components/gradcontrols/src/gradcustomcontrol.pas
Executable file
@ -0,0 +1,71 @@
|
||||
unit gradcustomcontrol;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, Graphics;
|
||||
|
||||
type
|
||||
|
||||
{ TGradCustomControl }
|
||||
|
||||
TGradCustomControl = class(TCustomControl)
|
||||
protected
|
||||
FBuffer: TBitmap;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer;
|
||||
KeepBase: boolean); override;
|
||||
procedure Paint; override;
|
||||
procedure PaintTo(ACanvas: TCanvas; X, Y: Integer); overload;
|
||||
procedure _Paint(ACanvas: TCanvas); virtual; abstract;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TGradCustomControl }
|
||||
|
||||
constructor TGradCustomControl.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
FBuffer := TBitmap.Create;
|
||||
end;
|
||||
|
||||
destructor TGradCustomControl.Destroy;
|
||||
begin
|
||||
FBuffer.Free;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TGradCustomControl.ChangeBounds(ALeft, ATop, AWidth,
|
||||
AHeight: integer; KeepBase: boolean);
|
||||
begin
|
||||
FBuffer.SetSize(AWidth, AHeight);
|
||||
|
||||
_Paint(FBuffer.Canvas);
|
||||
|
||||
inherited ChangeBounds(ALeft, ATop, AWidth, AHeight, KeepBase);
|
||||
end;
|
||||
|
||||
procedure TGradCustomControl.Paint;
|
||||
begin
|
||||
if not HasParent then
|
||||
Exit;
|
||||
|
||||
Canvas.Draw(0,0, FBuffer);
|
||||
|
||||
inherited Paint;
|
||||
end;
|
||||
|
||||
procedure TGradCustomControl.PaintTo(ACanvas: TCanvas; X, Y: Integer);
|
||||
begin
|
||||
ACanvas.Draw(0,0, FBuffer);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user