Ignore:
Timestamp:
Jan 7, 2017, 8:54:23 PM (7 years ago)
Author:
chronos
Message:
  • Removed: Do not create file association at runtime as it is done by installer program.
  • Modified: Additional source formating using Delphi formatter.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Components/ButtonBase.pas

    r10 r14  
    1010    constructor Create(aOwner: TComponent); override;
    1111  protected
    12     FDown,FPermanent: boolean;
     12    FDown, FPermanent: boolean;
    1313    FGraphic: TBitmap;
    14 //    FDownSound, FUpSound: string;
     14    // FDownSound, FUpSound: string;
    1515    ClickProc: TNotifyEvent;
    1616    DownChangedProc: TNotifyEvent;
    1717    procedure SetDown(x: boolean);
    18 //    procedure PlayDownSound;
    19 //    procedure PlayUpSound;
     18    // procedure PlayDownSound;
     19    // procedure PlayUpSound;
    2020    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
    2121      x, y: integer); override;
     
    2727  public
    2828    property Graphic: TBitmap read FGraphic write FGraphic;
    29 //    property DownSound: string read FDownSound write FDownSound;
    30 //    property UpSound: string read FUpSound write FUpSound;
     29    // property DownSound: string read FDownSound write FDownSound;
     30    // property UpSound: string read FUpSound write FUpSound;
    3131  published
    3232    property Visible;
     
    3434    property Permanent: boolean read FPermanent write FPermanent;
    3535    property OnClick: TNotifyEvent read ClickProc write ClickProc;
    36     property OnDownChanged: TNotifyEvent read DownChangedProc write DownChangedProc;
     36    property OnDownChanged: TNotifyEvent read DownChangedProc
     37      write DownChangedProc;
    3738  end;
    3839
    3940implementation
    4041
    41 //uses
    42 //  MMSystem;
     42// uses
     43// MMSystem;
    4344
    44 constructor TButtonBase.Create(AOwner: TComponent);
     45constructor TButtonBase.Create(aOwner: TComponent);
    4546begin
    4647  inherited;
    47   //FDownSound:='';
    48   //FUpSound:='';
    49   FGraphic:=nil; Active:=false; FDown:=false; FPermanent:=false;
    50   ClickProc:=nil;
     48  // FDownSound:='';
     49  // FUpSound:='';
     50  FGraphic := nil;
     51  Active := false;
     52  FDown := false;
     53  FPermanent := false;
     54  ClickProc := nil;
    5155end;
    5256
    5357procedure TButtonBase.MouseDown(Button: TMouseButton; Shift: TShiftState;
    54       x, y: integer);
     58  x, y: integer);
    5559begin
    56   Active:=true;
    57   MouseMove(Shift,x,y)
     60  Active := true;
     61  MouseMove(Shift, x, y)
    5862end;
    5963
    6064procedure TButtonBase.MouseUp(Button: TMouseButton; Shift: TShiftState;
    61       x, y: integer);
     65  x, y: integer);
    6266begin
    63   if ssLeft in Shift then exit;
    64     MouseMove(Shift,x,y);
     67  if ssLeft in Shift then
     68    exit;
     69  MouseMove(Shift, x, y);
    6570  if Active and FDown then
    6671  begin
    67 // PlayUpSound;
    68   Active:=false;
    69   if FDown<>FPermanent then
     72    // PlayUpSound;
     73    Active := false;
     74    if FDown <> FPermanent then
    7075    begin
    71     FDown:=FPermanent;
    72     Invalidate;
    73     if @DownChangedProc<>nil then DownChangedProc(self);
     76      FDown := FPermanent;
     77      Invalidate;
     78      if @DownChangedProc <> nil then
     79        DownChangedProc(self);
    7480    end;
    75   if (Button=mbLeft) and (@ClickProc<>nil) then ClickProc(self)
     81    if (Button = mbLeft) and (@ClickProc <> nil) then
     82      ClickProc(self)
    7683  end
    77 else
     84  else
    7885  begin
    79 // if FDown then PlayUpSound;
    80   Active:=false;
    81   if FDown then
     86    // if FDown then PlayUpSound;
     87    Active := false;
     88    if FDown then
    8289    begin
    83     FDown:=false;
    84     Invalidate;
    85     if @DownChangedProc<>nil then DownChangedProc(self);
     90      FDown := false;
     91      Invalidate;
     92      if @DownChangedProc <> nil then
     93        DownChangedProc(self);
    8694    end;
    8795  end
     
    9098procedure TButtonBase.MouseMove(Shift: TShiftState; x, y: integer);
    9199begin
    92 if Active then
    93    if (x>=0) and (x<Width) and (y>=0) and (y<Height) then
    94      if (ssLeft in Shift) and not FDown then
    95        begin
    96        {PlayDownSound;}
    97        FDown:=true;
    98        Paint;
    99        if @DownChangedProc<>nil then DownChangedProc(self);
    100        end
    101    else else if FDown and not FPermanent then
    102      begin
    103      {PlayUpSound;}
    104      FDown:=false;
    105      Paint;
    106      if @DownChangedProc<>nil then DownChangedProc(self);
    107      end
     100  if Active then
     101    if (x >= 0) and (x < Width) and (y >= 0) and (y < Height) then
     102      if (ssLeft in Shift) and not FDown then
     103      begin
     104        { PlayDownSound; }
     105        FDown := true;
     106        Paint;
     107        if @DownChangedProc <> nil then
     108          DownChangedProc(self);
     109      end
     110      else
     111    else if FDown and not FPermanent then
     112    begin
     113      { PlayUpSound; }
     114      FDown := false;
     115      Paint;
     116      if @DownChangedProc <> nil then
     117        DownChangedProc(self);
     118    end
    108119end;
    109120
    110121procedure TButtonBase.SetDown(x: boolean);
    111122begin
    112 FDown:=x;
    113 Invalidate
     123  FDown := x;
     124  Invalidate
    114125end;
    115126
    116 //procedure TButtonBase.PlayDownSound;
    117 //begin
    118 //if DownSound<>'' then SndPlaySound(pchar(DownSound),SND_ASYNC)
    119 //end;
     127// procedure TButtonBase.PlayDownSound;
     128// begin
     129// if DownSound<>'' then SndPlaySound(pchar(DownSound),SND_ASYNC)
     130// end;
    120131
    121 //procedure TButtonBase.PlayUpSound;
    122 //begin
    123 //if UpSound<>'' then SndPlaySound(pchar(UpSound),SND_ASYNC)
    124 //end;
     132// procedure TButtonBase.PlayUpSound;
     133// begin
     134// if UpSound<>'' then SndPlaySound(pchar(UpSound),SND_ASYNC)
     135// end;
    125136
    126137end.
    127 
Note: See TracChangeset for help on using the changeset viewer.