FRTrackBarEdit.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // The graphics rendering engine GLScene http://glscene.org
  3. //
  4. unit FRTrackBarEdit;
  5. (* Frame combining a TrackBar and an Edit. *)
  6. interface
  7. {$I GLScene.inc}
  8. uses
  9. System.Classes,
  10. System.SysUtils,
  11. VCL.Forms,
  12. VCL.StdCtrls,
  13. VCL.ComCtrls,
  14. VCL.Controls;
  15. type
  16. TRTrackBarEdit = class(TFrame)
  17. TrackBar: TTrackBar;
  18. Edit: TEdit;
  19. procedure TrackBarChange(Sender: TObject);
  20. procedure EditChange(Sender: TObject);
  21. private
  22. procedure SetValue(const val : Integer);
  23. function GetValue : Integer;
  24. procedure SetValueMin(const val : Integer);
  25. function GetValueMin : Integer;
  26. procedure SetValueMax(const val : Integer);
  27. function GetValueMax : Integer;
  28. public
  29. property Value : Integer read GetValue write SetValue;
  30. property ValueMin : Integer read GetValueMin write SetValueMin;
  31. property ValueMax : Integer read GetValueMax write SetValueMax;
  32. end;
  33. //---------------------------------------------------------------------
  34. implementation
  35. //---------------------------------------------------------------------
  36. {$R *.dfm}
  37. procedure TRTrackBarEdit.TrackBarChange(Sender: TObject);
  38. begin
  39. Edit.Text:=IntToStr(TrackBar.Position);
  40. end;
  41. procedure TRTrackBarEdit.EditChange(Sender: TObject);
  42. var
  43. i : Integer;
  44. begin
  45. try
  46. i:=StrToInt(Edit.Text);
  47. TrackBar.Position:=i;
  48. except
  49. // ignore
  50. end;
  51. end;
  52. procedure TRTrackBarEdit.SetValue(const val : Integer);
  53. begin
  54. TrackBar.Position:=val;
  55. TrackBarChange(Self);
  56. end;
  57. function TRTrackBarEdit.GetValue : Integer;
  58. begin
  59. Result:=TrackBar.Position;
  60. end;
  61. procedure TRTrackBarEdit.SetValueMax(const val : Integer);
  62. begin
  63. TrackBar.Max:=val;
  64. TrackBarChange(Self);
  65. end;
  66. function TRTrackBarEdit.GetValueMax : Integer;
  67. begin
  68. Result:=TrackBar.Max;
  69. end;
  70. procedure TRTrackBarEdit.SetValueMin(const val : Integer);
  71. begin
  72. TrackBar.Min:=val;
  73. TrackBarChange(Self);
  74. end;
  75. function TRTrackBarEdit.GetValueMin : Integer;
  76. begin
  77. Result:=TrackBar.Min;
  78. end;
  79. end.