brookconfiguratorhandler.pas 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. (*
  2. Brook for Free Pascal
  3. Copyright (C) 2014-2019 Silvio Clecio
  4. See the file LICENSE.txt, included in this distribution,
  5. for details about the copyright.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. *)
  10. { Configurator handler classes. }
  11. unit BrookConfiguratorHandler;
  12. {$i brook.inc}
  13. interface
  14. uses
  15. BrookConfigurator, Classes;
  16. type
  17. { Handles exceptions for @link(TBrookConfiguratorHandler). }
  18. EBrookConfiguratorHandler = class(EBrookConfigurator);
  19. { Is a metaclass for @link(TBrookConfiguratorHandler) class. }
  20. TBrookConfiguratorHandlerClass = class of TBrookConfiguratorHandler;
  21. { Handles the configurator features. }
  22. TBrookConfiguratorHandler = class(TBrookConfigurator)
  23. private
  24. FAutoConfig: Boolean;
  25. function GetTargetComp: TComponent;
  26. procedure SetTargetComp(AValue: TComponent);
  27. protected
  28. procedure Loaded; override;
  29. procedure Notification(AComponent: TComponent;
  30. AOperation: TOperation); override;
  31. published
  32. { Defines if the configuration is done automatically. }
  33. property AutoConfig: Boolean read FAutoConfig write FAutoConfig;
  34. property IgnoredParams;
  35. property Params;
  36. property Target: TComponent read GetTargetComp write SetTargetComp;
  37. property AfterConfigure;
  38. property BeforeConfgure;
  39. end;
  40. implementation
  41. { TBrookConfiguratorHandler }
  42. procedure TBrookConfiguratorHandler.Loaded;
  43. begin
  44. inherited Loaded;
  45. if FAutoConfig then
  46. Configure;
  47. end;
  48. procedure TBrookConfiguratorHandler.Notification(AComponent: TComponent;
  49. AOperation: TOperation);
  50. begin
  51. inherited Notification(AComponent, AOperation);
  52. if (AOperation = opRemove) and (AComponent = Target) then
  53. Target := nil;
  54. end;
  55. function TBrookConfiguratorHandler.GetTargetComp: TComponent;
  56. begin
  57. Result := TComponent(inherited GetTarget);
  58. end;
  59. procedure TBrookConfiguratorHandler.SetTargetComp(AValue: TComponent);
  60. begin
  61. inherited SetTarget(AValue);
  62. end;
  63. end.