dtanalogcommon.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. // SPDX-License-Identifier: LGPL-3.0-linking-exception
  2. {
  3. Part of BGRA Controls. Made by third party.
  4. For detailed information see readme.txt
  5. Site: https://sourceforge.net/p/bgra-controls/
  6. Wiki: http://wiki.lazarus.freepascal.org/BGRAControls
  7. Forum: http://forum.lazarus.freepascal.org/index.php/board,46.0.html
  8. }
  9. {******************************* CONTRIBUTOR(S) ******************************
  10. - Edivando S. Santos Brasil | [email protected]
  11. (Compatibility with delphi VCL 11/2018)
  12. ***************************** END CONTRIBUTOR(S) *****************************}
  13. unit DTAnalogCommon;
  14. {$I bgracontrols.inc}
  15. interface
  16. uses
  17. Classes, SysUtils, {$IFDEF FPC}LResources,{$ELSE}Types, {$ENDIF} Forms, Controls, Graphics, Dialogs,
  18. BCBaseCtrls, BGRABitmap, BGRABitmapTypes;
  19. type
  20. TDTFillStyle = (fsnone, fsGradient{, fsTexture});
  21. TDTNeedleStyle = (nsLine, nsTriangle{, nsLineExt, nsTriangleExt});
  22. { TDTOrigin }
  23. TDTOrigin = packed record
  24. CenterPoint: TPoint;
  25. Radius: integer;
  26. end;
  27. { TDTPointerCapSettings }
  28. TDTPointerCapSettings = class(TPersistent)
  29. private
  30. FEdgeColor: TColor;
  31. FEdgeThickness: integer;
  32. FFillColor: TColor;
  33. FOnChange: TNotifyEvent;
  34. FRadius: integer;
  35. procedure SetEdgeColor(AValue: TColor);
  36. procedure SetEdgeThickness(AValue: integer);
  37. procedure SetFillColor(AValue: TColor);
  38. procedure SetOnChange(AValue: TNotifyEvent);
  39. procedure SetRadius(AValue: integer);
  40. protected
  41. public
  42. constructor Create;
  43. destructor Destroy; override;
  44. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  45. published
  46. property EdgeColor: TColor read FEdgeColor write SetEdgeColor;
  47. property FillColor: TColor read FFillColor write SetFillColor;
  48. property Radius: integer read FRadius write SetRadius;
  49. property EdgeThickness: integer read FEdgeThickness write SetEdgeThickness;
  50. end;
  51. { TDTPointerSettings }
  52. TDTPointerSettings = class(TPersistent)
  53. private
  54. FColor: TColor;
  55. FLength: integer;
  56. FOnChange: TNotifyEvent;
  57. FThickness: integer;
  58. procedure SetColor(AValue: TColor);
  59. procedure SetLength(AValue: integer);
  60. procedure SetOnChange(AValue: TNotifyEvent);
  61. procedure SetThickness(AValue: integer);
  62. protected
  63. public
  64. constructor Create;
  65. destructor Destroy; override;
  66. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  67. published
  68. property Color: TColor read FColor write SetColor;
  69. property Length: integer read FLength write SetLength;
  70. property Thickness: integer read FThickness write SetThickness;
  71. end;
  72. { TDTNeedleSettings }
  73. TDTNeedleSettings = class(TPersistent)
  74. private
  75. FCapColor: TColor;
  76. FCapEdgeColor: TColor;
  77. FCapRadius: integer;
  78. FNeedleColor: TColor;
  79. FNeedleLength: integer;
  80. FNeedleStyle: TDTNeedleStyle;
  81. FOnChange: TNotifyEvent;
  82. procedure SetCapColor(AValue: TColor);
  83. procedure SetCapEdgeColor(AValue: TColor);
  84. procedure SetCapRadius(AValue: integer);
  85. procedure SetNeedleColor(AValue: TColor);
  86. procedure SetNeedleLength(AValue: integer);
  87. procedure SetNeedleStyle(AValue: TDTNeedleStyle);
  88. procedure SetOnChange(AValue: TNotifyEvent);
  89. protected
  90. public
  91. constructor Create;
  92. destructor Destroy; override;
  93. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  94. property NeedleStyle: TDTNeedleStyle read FNeedleStyle write SetNeedleStyle;
  95. published
  96. property NeedleColor: TColor read FNeedleColor write SetNeedleColor;
  97. property NeedleLength: integer read FNeedleLength write SetNeedleLength;
  98. property CapRadius: integer read FCapRadius write SetCapRadius;
  99. property CapColor: TColor read FCapColor write SetCapColor;
  100. property CapEdgeColor: TColor read FCapEdgeColor write SetCapEdgeColor;
  101. end;
  102. { TDTScaleSettings }
  103. TDTScaleSettings = class(TPersistent)
  104. private
  105. FEnableScaleText: boolean;
  106. FMaximum: integer;
  107. FTesting: boolean;
  108. FTextFont: string;
  109. FTextRadius: integer;
  110. FTextSize: integer;
  111. FTickColor: TColor;
  112. FEnableMainTicks: boolean;
  113. FEnableRangeIndicator: boolean;
  114. FEnableSubTicks: boolean;
  115. FLengthMainTick: integer;
  116. FLengthSubTick: integer;
  117. FMainTickCount: integer;
  118. FMinimum: integer;
  119. FOnChange: TNotifyEvent;
  120. FSubTickCount: integer;
  121. FTextColor: TColor;
  122. FThicknessMainTick: integer;
  123. FThicknessSubTick: integer;
  124. FAngle: integer;
  125. procedure SetEnableScaleText(AValue: boolean);
  126. procedure SetFAngle(AValue: integer);
  127. procedure SetMaximum(AValue: integer);
  128. procedure SetTesting(AValue: boolean);
  129. procedure SetTextFont(AValue: string);
  130. procedure SetTextRadius(AValue: integer);
  131. procedure SetTextSize(AValue: integer);
  132. procedure SetTickColor(AValue: TColor);
  133. procedure SetEnableMainTicks(AValue: boolean);
  134. procedure SetEnableRangeIndicator(AValue: boolean);
  135. procedure SetEnableSubTicks(AValue: boolean);
  136. procedure SetLengthMainTick(AValue: integer);
  137. procedure SetLengthSubTick(AValue: integer);
  138. procedure SetMainTickCount(AValue: integer);
  139. procedure SetOnChange(AValue: TNotifyEvent);
  140. procedure SetSubTickCount(AValue: integer);
  141. procedure SetTextColor(AValue: TColor);
  142. procedure SetThicknessMainTick(AValue: integer);
  143. procedure SetThicknessSubTick(AValue: integer);
  144. protected
  145. property Testing: boolean read FTesting write SetTesting;
  146. public
  147. constructor Create;
  148. destructor Destroy; override;
  149. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  150. published
  151. property TickColor: TColor read FTickColor write SetTickColor;
  152. property TextColor: TColor read FTextColor write SetTextColor;
  153. property TextSize: integer read FTextSize write SetTextSize;
  154. property TextFont: string read FTextFont write SetTextFont;
  155. property EnableMainTicks: boolean read FEnableMainTicks write SetEnableMainTicks;
  156. property EnableSubTicks: boolean read FEnableSubTicks write SetEnableSubTicks;
  157. property EnableScaleText: boolean read FEnableScaleText write SetEnableScaleText;
  158. property Maximum: integer read FMaximum write SetMaximum;
  159. property MainTickCount: integer read FMainTickCount write SetMainTickCount;
  160. property SubTickCount: integer read FSubTickCount write SetSubTickCount;
  161. property LengthMainTick: integer read FLengthMainTick write SetLengthMainTick;
  162. property LengthSubTick: integer read FLengthSubTick write SetLengthSubTick;
  163. property ThicknessMainTick: integer read FThicknessMainTick write SetThicknessMainTick;
  164. property ThicknessSubTick: integer read FThicknessSubTick write SetThicknessSubTick;
  165. property TextRadius: integer read FTextRadius write SetTextRadius;
  166. property Angle: integer read FAngle write SetFAngle;
  167. property EnableRangeIndicator: boolean read FEnableRangeIndicator write SetEnableRangeIndicator;
  168. //property RangeMinValue: integer read FRangeMinValue write SetRangeMinValue;
  169. //property RangeMidValue: integer read FRangeMidValue write SetRangeMidValue;
  170. //property RangeMaxValue: integer read FRangeMaxValue write SetRangeMaxValue;
  171. //property RangeMinColor: TColor read FRangeMinColor write SetRangeMinColor;
  172. //property RangeMidColor: TColor read FRangeMidColor write SetRangeMidColor;
  173. //property RangeMaxColor: TColor read FRangeMaxColor write SetRangeMaxColor;
  174. end;
  175. { TDTFaceSettings }
  176. TDTFaceSettings = class(TPersistent)
  177. private
  178. FColorEnd: TColor;
  179. FColorFrame: TColor;
  180. FColorStart: TColor;
  181. FFillStyle: TDTFillStyle;
  182. FOnChange: TNotifyEvent;
  183. procedure SetColorEnd(AValue: TColor);
  184. procedure SetColorFrame(AValue: TColor);
  185. procedure SetColorStart(AValue: TColor);
  186. procedure SetFillStyle(AValue: TDTFillStyle);
  187. procedure SetOnChange(AValue: TNotifyEvent);
  188. protected
  189. public
  190. constructor Create;
  191. destructor Destroy; override;
  192. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  193. published
  194. property FillStyle: TDTFillStyle read FFillStyle write SetFillStyle;
  195. property ColorFrame: TColor read FColorFrame write SetColorFrame;
  196. property ColorStart: TColor read FColorStart write SetColorStart;
  197. property ColorEnd: TColor read FColorEnd write SetColorEnd;
  198. end;
  199. { TDTBaseAnalogDevice }
  200. TDTBaseAnalogDevice = class(TBGRAGraphicCtrl)
  201. private
  202. FFaceSettings: TDTFaceSettings;
  203. FScaleSettings: TDTScaleSettings;
  204. procedure SetFaceSettings(AValue: TDTFaceSettings);
  205. procedure SetScaleSettings(AValue: TDTScaleSettings);
  206. protected
  207. procedure DoChange({%H-}Sender: TObject);
  208. public
  209. fGaugeBitmap: TBGRABitmap;
  210. FFrameBitmap: TBGRABitmap;
  211. FFaceBitmap: TBGRABitmap;
  212. constructor Create(AOwner: TComponent); override;
  213. destructor Destroy; override;
  214. property FaceSettings: TDTFaceSettings read FFaceSettings write SetFaceSettings;
  215. property ScaleSettings: TDTScaleSettings read FScaleSettings write SetScaleSettings;
  216. procedure Paint; override;
  217. procedure DrawGauge;
  218. procedure DrawFrame;
  219. procedure DrawFace;
  220. end;
  221. function Initializebitmap(var Bitmap: TBGRABitmap; Width, Height: integer): TDTOrigin;
  222. implementation
  223. function Initializebitmap(var Bitmap: TBGRABitmap; Width, Height: integer): TDTOrigin;
  224. begin
  225. Bitmap.SetSize(Width, Height);
  226. // Clear bitmap to transparent
  227. BitMap.Fill(BGRA(0, 0, 0, 0));
  228. // Get origin information
  229. Result.CenterPoint.x := Width div 2;
  230. Result.CenterPoint.y := Height div 2;
  231. Result.Radius := Result.CenterPoint.y;
  232. if Result.CenterPoint.x > Result.CenterPoint.y then
  233. Result.Radius := Result.CenterPoint.y;
  234. if Result.CenterPoint.x < Result.CenterPoint.y then
  235. Result.Radius := Result.CenterPoint.x;
  236. end;
  237. { TDTPointerCapSettings }
  238. procedure TDTPointerCapSettings.SetEdgeColor(AValue: TColor);
  239. begin
  240. if FEdgeColor = AValue then
  241. Exit;
  242. FEdgeColor := AValue;
  243. if Assigned(FOnChange) then
  244. FOnChange(Self);
  245. end;
  246. procedure TDTPointerCapSettings.SetEdgeThickness(AValue: integer);
  247. begin
  248. if FEdgeThickness = AValue then
  249. Exit;
  250. FEdgeThickness := AValue;
  251. if Assigned(FOnChange) then
  252. FOnChange(Self);
  253. end;
  254. procedure TDTPointerCapSettings.SetFillColor(AValue: TColor);
  255. begin
  256. if FFillColor = AValue then
  257. Exit;
  258. FFillColor := AValue;
  259. if Assigned(FOnChange) then
  260. FOnChange(Self);
  261. end;
  262. procedure TDTPointerCapSettings.SetOnChange(AValue: TNotifyEvent);
  263. begin
  264. //# if FOnChange = AValue then
  265. //# Exit;
  266. FOnChange := AValue;
  267. if Assigned(FOnChange) then
  268. FOnChange(Self);
  269. end;
  270. procedure TDTPointerCapSettings.SetRadius(AValue: integer);
  271. begin
  272. if FRadius = AValue then
  273. Exit;
  274. FRadius := AValue;
  275. if Assigned(FOnChange) then
  276. FOnChange(Self);
  277. end;
  278. constructor TDTPointerCapSettings.Create;
  279. begin
  280. FEdgeColor := $00CCDCDC;
  281. FFillColor := $003F3F3F;
  282. FRadius := 10;
  283. FEdgeThickness := 1;
  284. end;
  285. destructor TDTPointerCapSettings.Destroy;
  286. begin
  287. inherited Destroy;
  288. end;
  289. { TDTPointerSettings }
  290. procedure TDTPointerSettings.SetColor(AValue: TColor);
  291. begin
  292. if FColor = AValue then
  293. Exit;
  294. FColor := AValue;
  295. if Assigned(FOnChange) then
  296. FOnChange(Self);
  297. end;
  298. procedure TDTPointerSettings.SetLength(AValue: integer);
  299. begin
  300. if FLength = AValue then
  301. Exit;
  302. FLength := AValue;
  303. if Assigned(FOnChange) then
  304. FOnChange(Self);
  305. end;
  306. procedure TDTPointerSettings.SetOnChange(AValue: TNotifyEvent);
  307. begin
  308. //# if FOnChange = AValue then
  309. //# Exit;
  310. FOnChange := AValue;
  311. if Assigned(FOnChange) then
  312. FOnChange(Self);
  313. end;
  314. procedure TDTPointerSettings.SetThickness(AValue: integer);
  315. begin
  316. if FThickness = AValue then
  317. Exit;
  318. FThickness := AValue;
  319. if Assigned(FOnChange) then
  320. FOnChange(Self);
  321. end;
  322. constructor TDTPointerSettings.Create;
  323. begin
  324. FColor := BGRA(199, 199, 173);
  325. FLength := 100;
  326. FThickness := 3;
  327. end;
  328. destructor TDTPointerSettings.Destroy;
  329. begin
  330. inherited Destroy;
  331. end;
  332. { TDTBaseAnalogDevice }
  333. procedure TDTBaseAnalogDevice.SetFaceSettings(AValue: TDTFaceSettings);
  334. begin
  335. if FFaceSettings = AValue then
  336. Exit;
  337. FFaceSettings := AValue;
  338. DoChange(self);
  339. end;
  340. procedure TDTBaseAnalogDevice.SetScaleSettings(AValue: TDTScaleSettings);
  341. begin
  342. if FScaleSettings = AValue then
  343. Exit;
  344. FScaleSettings := AValue;
  345. DoChange(self);
  346. end;
  347. procedure TDTBaseAnalogDevice.DoChange(Sender: TObject);
  348. begin
  349. Invalidate;
  350. end;
  351. constructor TDTBaseAnalogDevice.Create(AOwner: TComponent);
  352. begin
  353. inherited Create(AOwner);
  354. Width := 240;
  355. Height := 240;
  356. FScaleSettings := TDTScaleSettings.Create;
  357. ScaleSettings.OnChange := DoChange;
  358. ScaleSettings.TextRadius := round((Width * 0.6) / 2);
  359. FFaceSettings := TDTFaceSettings.Create;
  360. FaceSettings.OnChange := DoChange;
  361. FGaugeBitmap := TBGRABitmap.Create;
  362. FFaceBitmap := TBGRABitmap.Create;
  363. FFrameBitmap := TBGRABitmap.Create;
  364. end;
  365. destructor TDTBaseAnalogDevice.Destroy;
  366. begin
  367. FScaleSettings.Free;
  368. FFaceSettings.Free;
  369. fGaugeBitmap.Free;
  370. FFaceBitmap.Free;
  371. FFrameBitmap.Free;
  372. inherited Destroy;
  373. end;
  374. procedure TDTBaseAnalogDevice.Paint;
  375. begin
  376. inherited Paint;
  377. FGaugeBitmap.Fill(BGRA(0, 0, 0, 0));
  378. fGaugeBitmap.SetSize(Width, Height);
  379. DrawGauge;
  380. FGaugeBitmap.BlendImage(0, 0, FFrameBitmap, boLinearBlend);
  381. FGaugeBitmap.BlendImage(0, 0, FFaceBitmap, boLinearBlend);
  382. FGaugeBitmap.Draw(Canvas, 0, 0, False);
  383. end;
  384. procedure TDTBaseAnalogDevice.DrawGauge;
  385. begin
  386. DrawFrame;
  387. DrawFace;
  388. end;
  389. procedure TDTBaseAnalogDevice.DrawFrame;
  390. var
  391. Origin: TDTOrigin;
  392. r: integer;
  393. begin
  394. Origin := Initializebitmap(FFrameBitmap, Width, Height);
  395. r := round(Origin.Radius * 0.95);
  396. // Draw Bitmap frame
  397. FFrameBitmap.FillEllipseAntialias(Origin.CenterPoint.x,
  398. Origin.CenterPoint.y,
  399. r, r, FFaceSettings.ColorFrame);
  400. // Draw thin antialiased border to smooth against background
  401. FFrameBitmap.EllipseAntialias(Origin.CenterPoint.x,
  402. Origin.CenterPoint.y,
  403. r, r, ColorToBGRA(clBlack, 120), 1);
  404. end;
  405. procedure TDTBaseAnalogDevice.DrawFace;
  406. var
  407. Origin: TDTOrigin;
  408. r: integer;
  409. begin
  410. Origin := Initializebitmap(FFaceBitmap, Width, Height);
  411. r := round(Origin.Radius * 0.95) - 5;
  412. case FFaceSettings.FillStyle of
  413. fsGradient:
  414. FFaceBitmap.FillEllipseLinearColorAntialias(Origin.CenterPoint.x, Origin.CenterPoint.y, r, r, ColorToBGRA(FFaceSettings.ColorStart), ColorToBGRA(FFaceSettings.ColorEnd));
  415. fsnone:
  416. FFaceBitmap.FillEllipseAntialias(Origin.CenterPoint.x, Origin.CenterPoint.y, r, r, FFaceSettings.ColorStart);
  417. end;
  418. end;
  419. { TDTNeedleSettings }
  420. procedure TDTNeedleSettings.SetCapColor(AValue: TColor);
  421. begin
  422. if FCapColor = AValue then
  423. Exit;
  424. FCapColor := AValue;
  425. if Assigned(FOnChange) then
  426. FOnChange(Self);
  427. end;
  428. procedure TDTNeedleSettings.SetCapEdgeColor(AValue: TColor);
  429. begin
  430. if FCapEdgeColor = AValue then
  431. Exit;
  432. FCapEdgeColor := AValue;
  433. if Assigned(FOnChange) then
  434. FOnChange(Self);
  435. end;
  436. procedure TDTNeedleSettings.SetCapRadius(AValue: integer);
  437. begin
  438. if FCapRadius = AValue then
  439. Exit;
  440. FCapRadius := AValue;
  441. if Assigned(FOnChange) then
  442. FOnChange(Self);
  443. end;
  444. procedure TDTNeedleSettings.SetNeedleColor(AValue: TColor);
  445. begin
  446. if FNeedleColor = AValue then
  447. Exit;
  448. FNeedleColor := AValue;
  449. if Assigned(FOnChange) then
  450. FOnChange(Self);
  451. end;
  452. procedure TDTNeedleSettings.SetNeedleLength(AValue: integer);
  453. begin
  454. if FNeedleLength = AValue then
  455. Exit;
  456. FNeedleLength := AValue;
  457. if Assigned(FOnChange) then
  458. FOnChange(Self);
  459. end;
  460. procedure TDTNeedleSettings.SetNeedleStyle(AValue: TDTNeedleStyle);
  461. begin
  462. if FNeedleStyle = AValue then
  463. Exit;
  464. FNeedleStyle := AValue;
  465. if Assigned(FOnChange) then
  466. FOnChange(Self);
  467. end;
  468. procedure TDTNeedleSettings.SetOnChange(AValue: TNotifyEvent);
  469. begin
  470. //# if FOnChange = AValue then
  471. //# Exit;
  472. FOnChange := AValue;
  473. if Assigned(FOnChange) then
  474. FOnChange(Self);
  475. end;
  476. constructor TDTNeedleSettings.Create;
  477. begin
  478. FCapColor := BGRA(63, 63, 63);
  479. FCapEdgeColor := BGRA(220, 220, 204);
  480. FCapRadius := 10;
  481. FNeedleStyle := nsLine;
  482. FNeedleColor := BGRA(255, 81, 81);
  483. FNeedleLength := 100;
  484. end;
  485. destructor TDTNeedleSettings.Destroy;
  486. begin
  487. inherited Destroy;
  488. end;
  489. { TDTScaleSettings }
  490. constructor TDTScaleSettings.Create;
  491. begin
  492. FTickColor := bgra(223, 196, 125);
  493. FTextColor := bgra(140, 208, 211);
  494. FTextFont := 'Calibri';
  495. FTextSize := 15;
  496. FEnableMainTicks := True;
  497. FEnableSubTicks := True;
  498. FEnableScaleText := True;
  499. FMainTickCount := 10;
  500. FSubTickCount := 5;
  501. FMaximum := 100;
  502. FMinimum := 0;
  503. FLengthMainTick := 15;
  504. FLengthSubTick := 8;
  505. FThicknessMainTick := 3;
  506. FThicknessSubTick := 1;
  507. FAngle := 300;
  508. FEnableRangeIndicator := True;
  509. end;
  510. destructor TDTScaleSettings.Destroy;
  511. begin
  512. inherited Destroy;
  513. end;
  514. procedure TDTScaleSettings.SetTextFont(AValue: string);
  515. begin
  516. if FTextFont = AValue then
  517. Exit;
  518. FTextFont := AValue;
  519. if Assigned(FOnChange) then
  520. FOnChange(Self);
  521. end;
  522. procedure TDTScaleSettings.SetEnableScaleText(AValue: boolean);
  523. begin
  524. if FEnableScaleText = AValue then
  525. Exit;
  526. FEnableScaleText := AValue;
  527. if Assigned(FOnChange) then
  528. FOnChange(Self);
  529. end;
  530. procedure TDTScaleSettings.SetFAngle(AValue: integer);
  531. begin
  532. if FAngle=AValue then Exit;
  533. FAngle:=AValue;
  534. end;
  535. procedure TDTScaleSettings.SetMaximum(AValue: integer);
  536. begin
  537. if FMaximum = AValue then
  538. Exit;
  539. FMaximum := AValue;
  540. if Assigned(FOnChange) then
  541. FOnChange(Self);
  542. end;
  543. procedure TDTScaleSettings.SetTesting(AValue: boolean);
  544. begin
  545. if FTesting = AValue then
  546. Exit;
  547. FTesting := AValue;
  548. if Assigned(FOnChange) then
  549. FOnChange(Self);
  550. end;
  551. procedure TDTScaleSettings.SetTextRadius(AValue: integer);
  552. begin
  553. if FTextRadius = AValue then
  554. Exit;
  555. FTextRadius := AValue;
  556. if Assigned(FOnChange) then
  557. FOnChange(Self);
  558. end;
  559. procedure TDTScaleSettings.SetTextSize(AValue: integer);
  560. begin
  561. if FTextSize = AValue then
  562. Exit;
  563. FTextSize := AValue;
  564. if Assigned(FOnChange) then
  565. FOnChange(Self);
  566. end;
  567. procedure TDTScaleSettings.SetTickColor(AValue: TColor);
  568. begin
  569. if FTickColor = AValue then
  570. Exit;
  571. FTickColor := AValue;
  572. if Assigned(FOnChange) then
  573. FOnChange(Self);
  574. end;
  575. procedure TDTScaleSettings.SetEnableMainTicks(AValue: boolean);
  576. begin
  577. if FEnableMainTicks = AValue then
  578. Exit;
  579. FEnableMainTicks := AValue;
  580. if Assigned(FOnChange) then
  581. FOnChange(Self);
  582. end;
  583. procedure TDTScaleSettings.SetEnableRangeIndicator(AValue: boolean);
  584. begin
  585. if FEnableRangeIndicator = AValue then
  586. Exit;
  587. FEnableRangeIndicator := AValue;
  588. if Assigned(FOnChange) then
  589. FOnChange(Self);
  590. end;
  591. procedure TDTScaleSettings.SetEnableSubTicks(AValue: boolean);
  592. begin
  593. if FEnableSubTicks = AValue then
  594. Exit;
  595. FEnableSubTicks := AValue;
  596. if Assigned(FOnChange) then
  597. FOnChange(Self);
  598. end;
  599. procedure TDTScaleSettings.SetLengthMainTick(AValue: integer);
  600. begin
  601. if FLengthMainTick = AValue then
  602. Exit;
  603. FLengthMainTick := AValue;
  604. if Assigned(FOnChange) then
  605. FOnChange(Self);
  606. end;
  607. procedure TDTScaleSettings.SetLengthSubTick(AValue: integer);
  608. begin
  609. if FLengthSubTick = AValue then
  610. Exit;
  611. FLengthSubTick := AValue;
  612. if Assigned(FOnChange) then
  613. FOnChange(Self);
  614. end;
  615. procedure TDTScaleSettings.SetMainTickCount(AValue: integer);
  616. begin
  617. if FMainTickCount = AValue then
  618. Exit;
  619. FMainTickCount := AValue;
  620. if Assigned(FOnChange) then
  621. FOnChange(Self);
  622. end;
  623. procedure TDTScaleSettings.SetOnChange(AValue: TNotifyEvent);
  624. begin
  625. //# if FOnChange = AValue then
  626. //# Exit;
  627. FOnChange := AValue;
  628. if Assigned(FOnChange) then
  629. FOnChange(Self);
  630. end;
  631. procedure TDTScaleSettings.SetSubTickCount(AValue: integer);
  632. begin
  633. if FSubTickCount = AValue then
  634. Exit;
  635. FSubTickCount := AValue;
  636. if Assigned(FOnChange) then
  637. FOnChange(Self);
  638. end;
  639. procedure TDTScaleSettings.SetTextColor(AValue: TColor);
  640. begin
  641. if FTextColor = AValue then
  642. Exit;
  643. FTextColor := AValue;
  644. if Assigned(FOnChange) then
  645. FOnChange(Self);
  646. end;
  647. procedure TDTScaleSettings.SetThicknessMainTick(AValue: integer);
  648. begin
  649. if FThicknessMainTick = AValue then
  650. Exit;
  651. FThicknessMainTick := AValue;
  652. if Assigned(FOnChange) then
  653. FOnChange(Self);
  654. end;
  655. procedure TDTScaleSettings.SetThicknessSubTick(AValue: integer);
  656. begin
  657. if FThicknessSubTick = AValue then
  658. Exit;
  659. FThicknessSubTick := AValue;
  660. if Assigned(FOnChange) then
  661. FOnChange(Self);
  662. end;
  663. { TDTFaceSettings }
  664. constructor TDTFaceSettings.Create;
  665. begin
  666. FColorFrame := BGRA(35, 35, 35);
  667. FColorStart := BGRA(63, 63, 63);
  668. FColorEnd := BGRA(93, 93, 93);
  669. FFillStyle := fsGradient;
  670. end;
  671. destructor TDTFaceSettings.Destroy;
  672. begin
  673. inherited Destroy;
  674. end;
  675. procedure TDTFaceSettings.SetColorEnd(AValue: TColor);
  676. begin
  677. if FColorEnd = AValue then
  678. Exit;
  679. FColorEnd := AValue;
  680. if Assigned(FOnChange) then
  681. FOnChange(Self);
  682. end;
  683. procedure TDTFaceSettings.SetColorFrame(AValue: TColor);
  684. begin
  685. if FColorFrame = AValue then
  686. Exit;
  687. FColorFrame := AValue;
  688. if Assigned(FOnChange) then
  689. FOnChange(Self);
  690. end;
  691. procedure TDTFaceSettings.SetColorStart(AValue: TColor);
  692. begin
  693. if FColorStart = AValue then
  694. Exit;
  695. FColorStart := AValue;
  696. if Assigned(FOnChange) then
  697. FOnChange(Self);
  698. end;
  699. procedure TDTFaceSettings.SetFillStyle(AValue: TDTFillStyle);
  700. begin
  701. if FFillStyle = AValue then
  702. Exit;
  703. FFillStyle := AValue;
  704. if Assigned(FOnChange) then
  705. FOnChange(Self);
  706. end;
  707. procedure TDTFaceSettings.SetOnChange(AValue: TNotifyEvent);
  708. begin
  709. //# if FOnChange = AValue then
  710. //3 Exit;
  711. FOnChange := AValue;
  712. if Assigned(FOnChange) then
  713. FOnChange(Self);
  714. end;
  715. { TDTBackGround }
  716. end.