|
Last change
on this file was 188, checked in by chronos, 5 years ago |
- Modified: Simplified code by replacing BitBlt which uses always handles by BitBltCanvas which uses directly TCanvas objects. Used default ROP SRCCOPY.
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | unit ButtonC;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | ButtonBase, Classes, Graphics, LCLIntf, LCLType, ScreenTools;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | TButtonC = class(TButtonBase)
|
|---|
| 10 | constructor Create(aOwner: TComponent); override;
|
|---|
| 11 | private
|
|---|
| 12 | FIndex: Integer;
|
|---|
| 13 | procedure SetIndex(Text: Integer);
|
|---|
| 14 | published
|
|---|
| 15 | property Visible;
|
|---|
| 16 | property ButtonIndex: integer read FIndex write SetIndex;
|
|---|
| 17 | property OnClick;
|
|---|
| 18 | protected
|
|---|
| 19 | procedure Paint; override;
|
|---|
| 20 | end;
|
|---|
| 21 |
|
|---|
| 22 | procedure Register;
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | implementation
|
|---|
| 26 |
|
|---|
| 27 | procedure Register;
|
|---|
| 28 | begin
|
|---|
| 29 | RegisterComponents('C-evo', [TButtonC]);
|
|---|
| 30 | end;
|
|---|
| 31 |
|
|---|
| 32 | constructor TButtonC.Create(aOwner: TComponent);
|
|---|
| 33 | begin
|
|---|
| 34 | inherited Create(aOwner);
|
|---|
| 35 | ShowHint := True;
|
|---|
| 36 | SetBounds(0, 0, 12, 12);
|
|---|
| 37 | end;
|
|---|
| 38 |
|
|---|
| 39 | procedure TButtonC.Paint;
|
|---|
| 40 | begin
|
|---|
| 41 | with Canvas do
|
|---|
| 42 | if FGraphic <> nil then
|
|---|
| 43 | BitBltCanvas(Canvas, 0, 0, 12, 12, FGraphic.Canvas,
|
|---|
| 44 | 169 + 13 * Byte(FDown), 159 + 13 * FIndex)
|
|---|
| 45 | else
|
|---|
| 46 | begin
|
|---|
| 47 | Brush.Color := $0000FF;
|
|---|
| 48 | FrameRect(Rect(0, 0, 12, 12))
|
|---|
| 49 | end;
|
|---|
| 50 | end;
|
|---|
| 51 |
|
|---|
| 52 | procedure TButtonC.SetIndex(Text: integer);
|
|---|
| 53 | begin
|
|---|
| 54 | if Text <> FIndex then
|
|---|
| 55 | begin
|
|---|
| 56 | FIndex := Text;
|
|---|
| 57 | Invalidate;
|
|---|
| 58 | end;
|
|---|
| 59 | end;
|
|---|
| 60 |
|
|---|
| 61 | end.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.