|
|
@@ -45,7 +45,7 @@ uses
|
|
|
{ BGRAControls }
|
|
|
BCBaseCtrls, BCEffect,
|
|
|
{ BGRABitmap }
|
|
|
- BGRABitmap, BGRABitmapTypes, BGRASliceScaling;
|
|
|
+ BGRABitmap, BGRABitmapTypes, BGRASliceScaling, Dialogs;
|
|
|
|
|
|
{off $DEFINE DEBUG}
|
|
|
|
|
|
@@ -75,6 +75,7 @@ type
|
|
|
procedure DoMouseUp; virtual;
|
|
|
procedure DoMouseEnter; virtual;
|
|
|
procedure DoMouseLeave; virtual;
|
|
|
+ procedure DoMouseMove(x, y: integer); virtual;
|
|
|
protected
|
|
|
procedure Click; override;
|
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
|
@@ -82,6 +83,7 @@ type
|
|
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
|
|
procedure MouseEnter; override;
|
|
|
procedure MouseLeave; override;
|
|
|
+ procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
|
|
|
public
|
|
|
property ModalResult: TModalResult
|
|
|
read FModalResult write FModalResult default mrNone;
|
|
|
@@ -228,6 +230,8 @@ type
|
|
|
|
|
|
TBCCustomImageButton = class(TBCGraphicButton)
|
|
|
private
|
|
|
+ FAlphaTest: boolean;
|
|
|
+ FAlphaTestValue: byte;
|
|
|
{ Private declarations }
|
|
|
{$IFDEF DEBUG}
|
|
|
FDrawCount: integer;
|
|
|
@@ -244,6 +248,9 @@ type
|
|
|
FBitmapFile: string;
|
|
|
FTextVisible: boolean;
|
|
|
FToggle: boolean;
|
|
|
+ FMouse: TPoint;
|
|
|
+ procedure SetFAlphaTest(AValue: boolean);
|
|
|
+ procedure SetFAlphaTestValue(AValue: byte);
|
|
|
procedure SetFAnimation(AValue: boolean);
|
|
|
procedure SetFBitmapFile(AValue: string);
|
|
|
procedure SetFBitmapOptions(AValue: TBCImageButtonSliceScalingOptions);
|
|
|
@@ -265,9 +272,13 @@ type
|
|
|
procedure DoMouseUp; override;
|
|
|
procedure DoMouseEnter; override;
|
|
|
procedure DoMouseLeave; override;
|
|
|
+ procedure DoMouseMove(x, y: integer); override;
|
|
|
procedure Click; override;
|
|
|
public
|
|
|
{ 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 Pressed: boolean read FPressed write SetFPressed default False;
|
|
|
//property State: TBCGraphicButtonState read FState;
|
|
|
@@ -279,8 +290,8 @@ type
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
destructor Destroy; override;
|
|
|
{ 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 Assign(Source: TPersistent); override;
|
|
|
{ Streaming }
|
|
|
@@ -295,6 +306,8 @@ type
|
|
|
|
|
|
TBCImageButton = class(TBCCustomImageButton)
|
|
|
published
|
|
|
+ property AlphaTest;
|
|
|
+ property AlphaTestValue;
|
|
|
property Action;
|
|
|
property Align;
|
|
|
property Anchors;
|
|
|
@@ -853,6 +866,11 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TBCGraphicButton.DoMouseMove(x, y: integer);
|
|
|
+begin
|
|
|
+ inherited;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TBCGraphicButton.Click;
|
|
|
begin
|
|
|
DoClick;
|
|
|
@@ -886,6 +904,12 @@ begin
|
|
|
DoMouseLeave;
|
|
|
end;
|
|
|
|
|
|
+procedure TBCGraphicButton.MouseMove(Shift: TShiftState; X, Y: Integer);
|
|
|
+begin
|
|
|
+ inherited MouseMove(Shift, X, Y);
|
|
|
+ DoMouseMove(X, Y);
|
|
|
+end;
|
|
|
+
|
|
|
{ TBCCustomImageButton }
|
|
|
|
|
|
procedure TBCCustomImageButton.Fade(Sender: TObject);
|
|
|
@@ -933,10 +957,25 @@ begin
|
|
|
Exit;
|
|
|
FAnimation := AValue;
|
|
|
|
|
|
- if csDesigning in ComponentState then Exit;
|
|
|
+ if csDesigning in ComponentState then
|
|
|
+ Exit;
|
|
|
FTimer.Enabled := FAnimation;
|
|
|
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.SetFBitmapFile(AValue: string);
|
|
|
begin
|
|
|
if FBitmapFile = AValue then
|
|
|
@@ -1107,7 +1146,8 @@ begin
|
|
|
dmSet);
|
|
|
FBGRAActive.Rectangle(0, 0, Width, Height, BGRA(0, 84, 153), BGRA(204, 228, 247),
|
|
|
dmSet);
|
|
|
- FBGRADisabled.Rectangle(0, 0, Width, Height, BGRA(191, 191, 191), BGRA(204, 204, 204),
|
|
|
+ FBGRADisabled.Rectangle(0, 0, Width, Height, BGRA(191, 191, 191),
|
|
|
+ BGRA(204, 204, 204),
|
|
|
dmSet);
|
|
|
|
|
|
{ Draw Text }
|
|
|
@@ -1156,6 +1196,8 @@ end;
|
|
|
|
|
|
procedure TBCCustomImageButton.DoMouseDown;
|
|
|
begin
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
+ Exit;
|
|
|
FFade.Mode := fmFadeOut;
|
|
|
|
|
|
if Animation then
|
|
|
@@ -1170,6 +1212,8 @@ procedure TBCCustomImageButton.DoMouseUp;
|
|
|
var
|
|
|
Ctrl: TControl;
|
|
|
begin
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
+ Exit;
|
|
|
FFade.Mode := fmFadeIn;
|
|
|
|
|
|
if Animation then
|
|
|
@@ -1210,8 +1254,20 @@ begin
|
|
|
inherited DoMouseLeave;
|
|
|
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;
|
|
|
begin
|
|
|
+ if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
|
|
|
+ Exit;
|
|
|
inherited Click;
|
|
|
if (Toggle) then
|
|
|
begin
|
|
|
@@ -1241,6 +1297,8 @@ begin
|
|
|
FBitmapOptions.Bitmap.SetPixel(0,2,BGRA(0,0,255,255));
|
|
|
FBitmapOptions.Bitmap.SetPixel(0,3,BGRA(100,100,100,255));}
|
|
|
|
|
|
+ FAlphaTest := True;
|
|
|
+ FAlphaTestValue := 255;
|
|
|
FFade.Step := 15;
|
|
|
FFade.Mode := fmFadeOut;
|
|
|
FTimer := TTimer.Create(Self);
|
|
|
@@ -1277,7 +1335,7 @@ begin
|
|
|
inherited Destroy;
|
|
|
end;
|
|
|
|
|
|
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string;
|
|
|
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string;
|
|
|
ResourceType: PChar);
|
|
|
var
|
|
|
res: TResourceStream;
|
|
|
@@ -1291,7 +1349,7 @@ begin
|
|
|
res.Free;
|
|
|
end;
|
|
|
|
|
|
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string);
|
|
|
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string);
|
|
|
begin
|
|
|
LoadFromBitmapResource(Resource, RT_RCDATA);
|
|
|
end;
|