1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Effects, FMX.Memo.Types,
FMX.ScrollBox, FMX.Memo;
{.$DEFINE MOVE_GLOW} // présente un bug
type
TMySpeedButton = class(TSpeedButton)
private
x, y: Integer;
{$IFNDEF MOVE_GLOW}
Glow: TInnerGlowEffect;
{$ENDIF}
end;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
Buttons: array[0..6, 0..6] of TMySpeedButton;
{$IFDEF MOVE_GLOW}
Glow1: TInnerGlowEffect;
Glow2: TInnerGlowEffect;
{$ELSE}
Button1: TMySpeedButton;
Button2: TMySpeedButton;
{$ENDIF}
procedure CreateButton(x, y: Integer);
procedure ButtonClick(Sender: TObject);
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.ButtonClick(Sender: TObject);
var
Button: TMySpeedButton;
begin
Button := TMySpeedButton(Sender);
{$IFDEF MOVE_GLOW}
Glow1.Parent := Button;
Glow1.Enabled := True;
{$ELSE}
if Button1 <> nil then
Button1.Glow.Enabled := False;
if Button2 <> nil then
Button2.Glow.Enabled := False;
Button1 := Button;
Button1.Glow.GlowColor := TAlphaColorRec.Blue;
Button1.Glow.Enabled := True;
{$ENDIF}
if (Button.y = 0) then
Button := nil
else
Button := Buttons[Button.x, Button.y - 1];
{$IFDEF MOVE_GLOW}
if Button = nil then
begin
Glow2.Enabled := False;
end else begin
Glow2.Parent := Button;
Glow2.Enabled := True;
end;
{$ELSE}
Button2 := Button;
if Button2 <> nil then
begin
Button2.Glow.GlowColor := TAlphaColorRec.Red;
Button2.Glow.Enabled := True;
end;
{$ENDIF}
end;
procedure TForm1.CreateButton(x, y: Integer);
const
SIZE = 60;
var
Button: TMySpeedButton;
begin
Button := TMySpeedButton.Create(Self);
Button.SetBounds(10 + x * SIZE, 10 + y * SIZE, SIZE, SIZE);
Button.Text := '(' + IntToStr(x) + ',' + IntToStr(y) + ')';
Button.Parent := Self;
Button.x := x;
Button.y := y;
Button.OnClick := ButtonClick;
{$IFNDEF MOVE_GLOW}
Button.Glow := TInnerGlowEffect.Create(Button);
Button.Glow.Softness := 1;
Button.Glow.Opacity := 1;
Button.Glow.Enabled := False;
Button.Glow.Parent := Button;
{$ENDIF}
Buttons[x, y] := Button;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
x, y: Integer;
begin
for y := 0 to 6 do
begin
for x := 2 to 4 do
begin
CreateButton(x, y);
end;
end;
for y := 2 to 4 do
begin
for x := 0 to 1 do
begin
CreateButton(x, y);
CreateButton(x + 5, y);
end;
end;
{$IFDEF MOVE_GLOW}
Glow1 := TInnerGlowEffect.Create(Self);
Glow1.Softness := 1;
Glow1.Opacity := 1;
Glow1.GlowColor := TAlphaColorRec.Blue;
Glow2 := TInnerGlowEffect.Create(Self);
Glow2.Softness := 1;
Glow2.Opacity := 1;
Glow2.GlowColor := TAlphaColorRec.Red;
{$ENDIF}
end;
end. |
Partager