Changeset 77 for trunk/UControls.pas


Ignore:
Timestamp:
May 19, 2021, 11:30:41 AM (3 years ago)
Author:
chronos
Message:
  • Added: Control icons for Pause, Play and Fast forward.
  • Modified: Image buttons changed to custom TImage control with Enabled property supported.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UControls.pas

    r64 r77  
    66
    77uses
    8   Classes, SysUtils;
     8  Classes, SysUtils, Graphics;
    99
    1010type
     11
     12  { TControl }
     13
    1114  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;
    1227
    13   end;
     28  { TButton }
    1429
    1530  TButton = class(TControl)
    1631    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;
    1743  end;
    1844
    1945implementation
    2046
     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
    2196end.
    2297
Note: See TracChangeset for help on using the changeset viewer.