ConfigureApplicationForm.pas 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 23014: ConfigureApplicationForm.pas
  11. {
  12. { Rev 1.1 09/11/2003 3:20:48 PM Jeremy Darling
  13. { Completed Log Color customization.
  14. }
  15. {
  16. { Rev 1.0 09/11/2003 12:49:18 PM Jeremy Darling
  17. { Project Added to TC
  18. }
  19. unit ConfigureApplicationForm;
  20. interface
  21. uses
  22. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  23. ComCtrls, ExtCtrls, StdCtrls, ApplicationConfiguration, ColorGrd;
  24. type
  25. TfrmConfigureApplication = class(TForm)
  26. pcMain: TPageControl;
  27. tsLogColors: TTabSheet;
  28. btnCancel: TButton;
  29. btnOk: TButton;
  30. cbElements: TComboBox;
  31. Label1: TLabel;
  32. Label2: TLabel;
  33. cgColors: TColorGrid;
  34. Panel1: TPanel;
  35. procedure cbElementsChange(Sender: TObject);
  36. procedure cgColorsChange(Sender: TObject);
  37. private
  38. { Private declarations }
  39. public
  40. { Public declarations }
  41. end;
  42. var
  43. frmConfigureApplication: TfrmConfigureApplication;
  44. function ConfigureApplication(AppConfig : TApplicationConfig) : Boolean;
  45. implementation
  46. {$R *.DFM}
  47. function ConfigureApplication(AppConfig : TApplicationConfig) : Boolean;
  48. var
  49. i : Integer;
  50. begin
  51. Result := false;
  52. with TfrmConfigureApplication.Create(Application) do
  53. begin
  54. try
  55. for i := 0 to AppConfig.LogColors.Count -1 do
  56. begin
  57. cbElements.Items.AddObject(AppConfig.LogColors[i], Pointer(AppConfig.LogColors.Colors[AppConfig.LogColors[i]]));
  58. end;
  59. cbElements.ItemIndex := 0;
  60. cbElementsChange(cbElements);
  61. case ShowModal of
  62. mrOk : begin
  63. for i := 0 to AppConfig.LogColors.Count -1 do
  64. begin
  65. AppConfig.LogColors.Colors[AppConfig.LogColors[i]] := TColor(Pointer(cbElements.Items.Objects[i]));
  66. end;
  67. result := true;
  68. end;
  69. mrCancel : begin
  70. result := false;
  71. end;
  72. end;
  73. finally
  74. Free;
  75. end;
  76. end;
  77. end;
  78. procedure TfrmConfigureApplication.cbElementsChange(Sender: TObject);
  79. begin
  80. cgColors.ForegroundIndex := cgColors.ColorToIndex(TColor(Pointer(cbElements.Items.Objects[cbElements.ItemIndex])));
  81. end;
  82. procedure TfrmConfigureApplication.cgColorsChange(Sender: TObject);
  83. begin
  84. if cbElements.ItemIndex > -1 then
  85. cbElements.Items.Objects[cbElements.ItemIndex] := pointer(cgColors.ForegroundColor);
  86. end;
  87. end.