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