source: tags/1.2.0/UControls.pas

Last change on this file was 77, checked in by chronos, 3 years ago
  • Added: Control icons for Pause, Play and Fast forward.
  • Modified: Image buttons changed to custom TImage control with Enabled property supported.
File size: 1.6 KB
Line 
1unit UControls;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Graphics;
9
10type
11
12 { TControl }
13
14 TControl = class
15 private
16 FEnabled: Boolean;
17 FOnClick: TNotifyEvent;
18 procedure SetEnabled(AValue: Boolean);
19 public
20 Bounds: TRect;
21 Canvas: TCanvas;
22 constructor Create; virtual;
23 procedure Paint; virtual;
24 property Enabled: Boolean read FEnabled write SetEnabled;
25 property OnClick: TNotifyEvent read FOnClick write FOnClick;
26 end;
27
28 { TButton }
29
30 TButton = class(TControl)
31 Text: string;
32 procedure Paint; override;
33 end;
34
35 { TImage }
36
37 TImage = class(TControl)
38 Bitmap: TBitmap;
39 BitmapDisabled: TBitmap;
40 constructor Create; override;
41 destructor Destroy; override;
42 procedure Paint; override;
43 end;
44
45implementation
46
47{ TButton }
48
49procedure TButton.Paint;
50begin
51 inherited Paint;
52end;
53
54{ TControl }
55
56procedure TControl.SetEnabled(AValue: Boolean);
57begin
58 if FEnabled = AValue then Exit;
59 FEnabled := AValue;
60 if Assigned(Canvas) then Paint;
61end;
62
63constructor TControl.Create;
64begin
65 FEnabled := True;
66end;
67
68procedure TControl.Paint;
69begin
70end;
71
72{ TImage }
73
74constructor TImage.Create;
75begin
76 inherited;
77 Bitmap := TBitmap.Create;
78 BitmapDisabled := TBitmap.Create;
79end;
80
81destructor TImage.Destroy;
82begin
83 FreeAndNil(Bitmap);
84 FreeAndNil(BitmapDisabled);
85 inherited;
86end;
87
88procedure TImage.Paint;
89begin
90 if Canvas.Brush.Color = clNone then Canvas.Brush.Style := bsClear
91 else Canvas.Brush.Style := bsSolid;
92 if FEnabled then Canvas.StretchDraw(Bounds, Bitmap)
93 else Canvas.StretchDraw(Bounds, BitmapDisabled);
94end;
95
96end.
97
Note: See TracBrowser for help on using the repository browser.