|
@@ -82,6 +82,7 @@ type
|
|
|
procedure DoMouseUp; virtual;
|
|
procedure DoMouseUp; virtual;
|
|
|
procedure DoMouseEnter; virtual;
|
|
procedure DoMouseEnter; virtual;
|
|
|
procedure DoMouseLeave; virtual;
|
|
procedure DoMouseLeave; virtual;
|
|
|
|
|
+ procedure DoMouseMove(x, y: integer); virtual;
|
|
|
protected
|
|
protected
|
|
|
procedure Click; override;
|
|
procedure Click; override;
|
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
@@ -89,6 +90,7 @@ type
|
|
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
|
|
procedure MouseEnter; override;
|
|
procedure MouseEnter; override;
|
|
|
procedure MouseLeave; override;
|
|
procedure MouseLeave; override;
|
|
|
|
|
+ procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
|
|
|
public
|
|
public
|
|
|
property ModalResult: TModalResult
|
|
property ModalResult: TModalResult
|
|
|
read FModalResult write FModalResult default mrNone;
|
|
read FModalResult write FModalResult default mrNone;
|
|
@@ -238,6 +240,8 @@ type
|
|
|
TBCCustomImageButton = class(TBCGraphicButton)
|
|
TBCCustomImageButton = class(TBCGraphicButton)
|
|
|
private
|
|
private
|
|
|
{ Private declarations }
|
|
{ Private declarations }
|
|
|
|
|
+ FAlphaTest: boolean;
|
|
|
|
|
+ FAlphaTestValue: byte;
|
|
|
{$IFDEF INDEBUG}
|
|
{$IFDEF INDEBUG}
|
|
|
FDrawCount: integer;
|
|
FDrawCount: integer;
|
|
|
FRenderCount: integer;
|
|
FRenderCount: integer;
|
|
@@ -253,6 +257,9 @@ type
|
|
|
FBitmapFile: string;
|
|
FBitmapFile: string;
|
|
|
FTextVisible: boolean;
|
|
FTextVisible: boolean;
|
|
|
FToggle: boolean;
|
|
FToggle: boolean;
|
|
|
|
|
+ FMouse: TPoint;
|
|
|
|
|
+ procedure SetFAlphaTest(AValue: boolean);
|
|
|
|
|
+ procedure SetFAlphaTestValue(AValue: byte);
|
|
|
procedure SetFAnimation(AValue: boolean);
|
|
procedure SetFAnimation(AValue: boolean);
|
|
|
procedure SetFBitmapFile(AValue: string);
|
|
procedure SetFBitmapFile(AValue: string);
|
|
|
procedure SetFBitmapOptions(AValue: TBCImageButtonSliceScalingOptions);
|
|
procedure SetFBitmapOptions(AValue: TBCImageButtonSliceScalingOptions);
|
|
@@ -276,9 +283,13 @@ type
|
|
|
procedure DoMouseUp; override;
|
|
procedure DoMouseUp; override;
|
|
|
procedure DoMouseEnter; override;
|
|
procedure DoMouseEnter; override;
|
|
|
procedure DoMouseLeave; override;
|
|
procedure DoMouseLeave; override;
|
|
|
|
|
+ procedure DoMouseMove(x, y: integer); override;
|
|
|
procedure Click; override;
|
|
procedure Click; override;
|
|
|
public
|
|
public
|
|
|
{ Public declarations }
|
|
{ Public declarations }
|
|
|
|
|
+ property AlphaTest: boolean read FAlphaTest write SetFAlphaTest default True;
|
|
|
|
|
+ property AlphaTestValue: byte
|
|
|
|
|
+ read FAlphaTestValue write SetFAlphaTestValue default 255;
|
|
|
property Toggle: boolean read FToggle write SetFToggle default False;
|
|
property Toggle: boolean read FToggle write SetFToggle default False;
|
|
|
property Pressed: boolean read FPressed write SetFPressed default False;
|
|
property Pressed: boolean read FPressed write SetFPressed default False;
|
|
|
//property State: TBCGraphicButtonState read FState;
|
|
//property State: TBCGraphicButtonState read FState;
|
|
@@ -290,8 +301,8 @@ type
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
|
{ It loads the 'BitmapFile' }
|
|
{ It loads the 'BitmapFile' }
|
|
|
- procedure LoadFromBitmapResource(Resource: string; ResourceType: PChar); overload;
|
|
|
|
|
- procedure LoadFromBitmapResource(Resource: string); overload;
|
|
|
|
|
|
|
+ procedure LoadFromBitmapResource(const Resource: string; ResourceType: PChar); overload;
|
|
|
|
|
+ procedure LoadFromBitmapResource(const Resource: string); overload;
|
|
|
procedure LoadFromBitmapFile;
|
|
procedure LoadFromBitmapFile;
|
|
|
procedure Assign(Source: TPersistent); override;
|
|
procedure Assign(Source: TPersistent); override;
|
|
|
{ Streaming }
|
|
{ Streaming }
|
|
@@ -308,6 +319,8 @@ type
|
|
|
|
|
|
|
|
TBCImageButton = class(TBCCustomImageButton)
|
|
TBCImageButton = class(TBCCustomImageButton)
|
|
|
published
|
|
published
|
|
|
|
|
+ property AlphaTest;
|
|
|
|
|
+ property AlphaTestValue;
|
|
|
property Action;
|
|
property Action;
|
|
|
property Align;
|
|
property Align;
|
|
|
property Anchors;
|
|
property Anchors;
|
|
@@ -868,6 +881,11 @@ begin
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBCGraphicButton.DoMouseMove(x, y: integer);
|
|
|
|
|
+begin
|
|
|
|
|
+ inherited;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
procedure TBCGraphicButton.Click;
|
|
procedure TBCGraphicButton.Click;
|
|
|
begin
|
|
begin
|
|
|
DoClick;
|
|
DoClick;
|
|
@@ -901,12 +919,22 @@ begin
|
|
|
DoMouseLeave;
|
|
DoMouseLeave;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBCGraphicButton.MouseMove(Shift: TShiftState; X, Y: Integer);
|
|
|
|
|
+begin
|
|
|
|
|
+ inherited MouseMove(Shift, X, Y);
|
|
|
|
|
+ DoMouseMove(X, Y);
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
{ TBCCustomImageButton }
|
|
{ TBCCustomImageButton }
|
|
|
|
|
|
|
|
procedure TBCCustomImageButton.Fade(Sender: TObject);
|
|
procedure TBCCustomImageButton.Fade(Sender: TObject);
|
|
|
begin
|
|
begin
|
|
|
if FFade.Mode <> fmSuspended then
|
|
if FFade.Mode <> fmSuspended then
|
|
|
Invalidate;
|
|
Invalidate;
|
|
|
|
|
+
|
|
|
|
|
+ if csDesigning in ComponentState then
|
|
|
|
|
+ Exit;
|
|
|
|
|
+ FTimer.Enabled := FAnimation;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TBCCustomImageButton.SetFPressed(AValue: boolean);
|
|
procedure TBCCustomImageButton.SetFPressed(AValue: boolean);
|
|
@@ -942,6 +970,20 @@ begin
|
|
|
FBitmapOptions := AValue;
|
|
FBitmapOptions := AValue;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBCCustomImageButton.SetFAlphaTest(AValue: boolean);
|
|
|
|
|
+begin
|
|
|
|
|
+ if FAlphaTest = AValue then
|
|
|
|
|
+ Exit;
|
|
|
|
|
+ FAlphaTest := AValue;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
|
|
+procedure TBCCustomImageButton.SetFAlphaTestValue(AValue: byte);
|
|
|
|
|
+begin
|
|
|
|
|
+ if FAlphaTestValue = AValue then
|
|
|
|
|
+ Exit;
|
|
|
|
|
+ FAlphaTestValue := AValue;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
procedure TBCCustomImageButton.SetFAnimation(AValue: boolean);
|
|
procedure TBCCustomImageButton.SetFAnimation(AValue: boolean);
|
|
|
begin
|
|
begin
|
|
|
if FAnimation = AValue then
|
|
if FAnimation = AValue then
|
|
@@ -1181,6 +1223,9 @@ end;
|
|
|
|
|
|
|
|
procedure TBCCustomImageButton.DoMouseDown;
|
|
procedure TBCCustomImageButton.DoMouseDown;
|
|
|
begin
|
|
begin
|
|
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
|
|
+ Exit;
|
|
|
|
|
+
|
|
|
FFade.Mode := fmFadeOut;
|
|
FFade.Mode := fmFadeOut;
|
|
|
|
|
|
|
|
if Animation then
|
|
if Animation then
|
|
@@ -1195,6 +1240,9 @@ procedure TBCCustomImageButton.DoMouseUp;
|
|
|
var
|
|
var
|
|
|
Ctrl: TControl;
|
|
Ctrl: TControl;
|
|
|
begin
|
|
begin
|
|
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
|
|
+ Exit;
|
|
|
|
|
+
|
|
|
FFade.Mode := fmFadeIn;
|
|
FFade.Mode := fmFadeIn;
|
|
|
|
|
|
|
|
if Animation then
|
|
if Animation then
|
|
@@ -1236,8 +1284,20 @@ begin
|
|
|
inherited DoMouseLeave;
|
|
inherited DoMouseLeave;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBCCustomImageButton.DoMouseMove(x, y: integer);
|
|
|
|
|
+begin
|
|
|
|
|
+ FMouse := Point(X, Y);
|
|
|
|
|
+ if FAlphaTest then
|
|
|
|
|
+ if FBGRANormal.GetPixel(X, Y).alpha >= FAlphaTestValue then
|
|
|
|
|
+ DoMouseEnter
|
|
|
|
|
+ else
|
|
|
|
|
+ DoMouseLeave;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
procedure TBCCustomImageButton.Click;
|
|
procedure TBCCustomImageButton.Click;
|
|
|
begin
|
|
begin
|
|
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
|
|
+ Exit;
|
|
|
inherited Click;
|
|
inherited Click;
|
|
|
if (Toggle) then
|
|
if (Toggle) then
|
|
|
begin
|
|
begin
|
|
@@ -1273,6 +1333,8 @@ begin
|
|
|
FBitmapOptions.Bitmap.SetPixel(0,2,BGRA(0,0,255,255));
|
|
FBitmapOptions.Bitmap.SetPixel(0,2,BGRA(0,0,255,255));
|
|
|
FBitmapOptions.Bitmap.SetPixel(0,3,BGRA(100,100,100,255));}
|
|
FBitmapOptions.Bitmap.SetPixel(0,3,BGRA(100,100,100,255));}
|
|
|
|
|
|
|
|
|
|
+ FAlphaTest := True;
|
|
|
|
|
+ FAlphaTestValue := 255;
|
|
|
FFade.Step := 15;
|
|
FFade.Step := 15;
|
|
|
FFade.Mode := fmFadeOut;
|
|
FFade.Mode := fmFadeOut;
|
|
|
FTimer := TTimer.Create(Self);
|
|
FTimer := TTimer.Create(Self);
|
|
@@ -1312,7 +1374,7 @@ begin
|
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string;
|
|
|
|
|
|
|
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string;
|
|
|
ResourceType: PChar);
|
|
ResourceType: PChar);
|
|
|
var
|
|
var
|
|
|
res: TResourceStream;
|
|
res: TResourceStream;
|
|
@@ -1326,7 +1388,7 @@ begin
|
|
|
res.Free;
|
|
res.Free;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string);
|
|
|
|
|
|
|
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string);
|
|
|
begin
|
|
begin
|
|
|
LoadFromBitmapResource(Resource, RT_RCDATA);
|
|
LoadFromBitmapResource(Resource, RT_RCDATA);
|
|
|
end;
|
|
end;
|