| 1 | unit ButtonB;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | ButtonBase, Classes, Graphics, LCLIntf, LCLType;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | TButtonB = class(TButtonBase)
|
|---|
| 10 | constructor Create(aOwner: TComponent); override;
|
|---|
| 11 | private
|
|---|
| 12 | FMask: TBitmap;
|
|---|
| 13 | FIndex: integer;
|
|---|
| 14 | procedure SetIndex(Text: integer);
|
|---|
| 15 | public
|
|---|
| 16 | property Mask: TBitmap read FMask write FMask;
|
|---|
| 17 | published
|
|---|
| 18 | property Visible;
|
|---|
| 19 | property ButtonIndex: integer read FIndex write SetIndex;
|
|---|
| 20 | property OnClick;
|
|---|
| 21 | protected
|
|---|
| 22 | procedure Paint; override;
|
|---|
| 23 | end;
|
|---|
| 24 |
|
|---|
| 25 | procedure Register;
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | implementation
|
|---|
| 29 |
|
|---|
| 30 | uses
|
|---|
| 31 | ScreenTools;
|
|---|
| 32 |
|
|---|
| 33 | procedure Register;
|
|---|
| 34 | begin
|
|---|
| 35 | RegisterComponents('C-evo', [TButtonB]);
|
|---|
| 36 | end;
|
|---|
| 37 |
|
|---|
| 38 | constructor TButtonB.Create(aOwner: TComponent);
|
|---|
| 39 | begin
|
|---|
| 40 | inherited Create(aOwner);
|
|---|
| 41 | ShowHint := True;
|
|---|
| 42 | SetBounds(0, 0, 25, 25);
|
|---|
| 43 | end;
|
|---|
| 44 |
|
|---|
| 45 | procedure TButtonB.Paint;
|
|---|
| 46 | begin
|
|---|
| 47 | with Canvas do
|
|---|
| 48 | if FGraphic <> nil then begin
|
|---|
| 49 | BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas, 169,
|
|---|
| 50 | 243 + 26 * Byte(FDown));
|
|---|
| 51 | if FIndex >= 0 then begin
|
|---|
| 52 | BitBltCanvas(Canvas, 0, 0, 25, 25, FMask.Canvas,
|
|---|
| 53 | 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCAND);
|
|---|
| 54 | BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas,
|
|---|
| 55 | 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCPAINT);
|
|---|
| 56 | end
|
|---|
| 57 | end else begin
|
|---|
| 58 | Brush.Color := $0000FF;
|
|---|
| 59 | FrameRect(Rect(0, 0, 25, 25));
|
|---|
| 60 | end;
|
|---|
| 61 | end;
|
|---|
| 62 |
|
|---|
| 63 | procedure TButtonB.SetIndex(Text: integer);
|
|---|
| 64 | begin
|
|---|
| 65 | if Text <> FIndex then begin
|
|---|
| 66 | FIndex := Text;
|
|---|
| 67 | Invalidate;
|
|---|
| 68 | end;
|
|---|
| 69 | end;
|
|---|
| 70 |
|
|---|
| 71 | end.
|
|---|