Changeset 463 for branches/highdpi/Packages/CevoComponents/ButtonBase.pas
- Timestamp:
- Nov 29, 2023, 2:35:44 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/ButtonBase.pas
r361 r463 9 9 TButtonBase = class(TDpiGraphicControl) 10 10 protected 11 FDown, FPermanent: boolean; 11 FDown: Boolean; 12 FPermanent: Boolean; 12 13 FGraphic: TDpiBitmap; 13 14 // FDownSound, FUpSound: string; 14 15 ClickProc: TNotifyEvent; 15 16 DownChangedProc: TNotifyEvent; 16 procedure SetDown( x: boolean);17 procedure SetDown(X: Boolean); 17 18 // procedure PlayDownSound; 18 19 // procedure PlayUpSound; 19 20 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; 20 x, y: integer); override;21 X, Y: Integer); override; 21 22 procedure MouseUp(Button: TMouseButton; Shift: TShiftState; 22 x, y: integer); override;23 procedure MouseMove(Shift: TShiftState; x, y: integer); override;23 X, Y: Integer); override; 24 procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; 24 25 private 25 Active: boolean;26 Active: Boolean; 26 27 public 27 28 constructor Create(aOwner: TComponent); override; … … 31 32 published 32 33 property Visible; 33 property Down: boolean read FDown write SetDown;34 property Permanent: boolean read FPermanent write FPermanent;34 property Down: Boolean read FDown write SetDown; 35 property Permanent: Boolean read FPermanent write FPermanent; 35 36 property OnClick: TNotifyEvent read ClickProc write ClickProc; 36 37 property OnDownChanged: TNotifyEvent read DownChangedProc … … 49 50 // FUpSound:=''; 50 51 FGraphic := nil; 51 Active := false;52 FDown := false;53 FPermanent := false;52 Active := False; 53 FDown := False; 54 FPermanent := False; 54 55 ClickProc := nil; 55 56 end; 56 57 57 58 procedure TButtonBase.MouseDown(Button: TMouseButton; Shift: TShiftState; 58 x, y: integer);59 X, Y: Integer); 59 60 begin 60 Active := true;61 MouseMove(Shift, x, y)61 Active := True; 62 MouseMove(Shift, X, Y); 62 63 end; 63 64 64 65 procedure TButtonBase.MouseUp(Button: TMouseButton; Shift: TShiftState; 65 x, y: integer);66 X, Y: Integer); 66 67 begin 67 68 if ssLeft in Shift then 68 exit;69 MouseMove(Shift, x, y);69 Exit; 70 MouseMove(Shift, X, Y); 70 71 if Active and FDown then 71 72 begin 72 73 // PlayUpSound; 73 Active := false;74 Active := False; 74 75 if FDown <> FPermanent then 75 76 begin … … 85 86 begin 86 87 // if FDown then PlayUpSound; 87 Active := false;88 Active := False; 88 89 if FDown then 89 90 begin 90 FDown := false;91 FDown := False; 91 92 Invalidate; 92 93 if @DownChangedProc <> nil then 93 94 DownChangedProc(self); 94 95 end; 95 end 96 end; 96 97 end; 97 98 98 procedure TButtonBase.MouseMove(Shift: TShiftState; x, y: integer);99 procedure TButtonBase.MouseMove(Shift: TShiftState; X, Y: Integer); 99 100 begin 100 101 if Active then 101 if ( x >= 0) and (x < Width) and (y >= 0) and (y< Height) then102 if (X >= 0) and (X < Width) and (Y >= 0) and (Y < Height) then 102 103 if (ssLeft in Shift) and not FDown then 103 104 begin 104 105 { PlayDownSound; } 105 FDown := true;106 FDown := True; 106 107 Paint; 107 108 if @DownChangedProc <> nil then … … 112 113 begin 113 114 { PlayUpSound; } 114 FDown := false;115 FDown := False; 115 116 Paint; 116 117 if @DownChangedProc <> nil then … … 119 120 end; 120 121 121 procedure TButtonBase.SetDown( x: boolean);122 procedure TButtonBase.SetDown(X: Boolean); 122 123 begin 123 FDown := x;124 FDown := X; 124 125 Invalidate; 125 126 end;
Note:
See TracChangeset
for help on using the changeset viewer.