unit FontsAndColorsUnit; { Configure the appearance of the market view. } interface uses MarketData, Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls, Dialogs, Grids; type TFontsAndColorsDlg = class(TForm) OKBtn: TButton; CancelBtn: TButton; Bevel1: TBevel; Foreground: TButton; PositiveFgButton: TButton; NegativeFgButton: TButton; Background: TButton; PositiveBgButton: TButton; NegativeBgButton: TButton; FontButton: TButton; SampleBox: TScrollBox; ColorDialog1: TColorDialog; FontDialog1: TFontDialog; NegativeBg: TLabel; ZeroBg: TLabel; PositiveBg: TLabel; NegativeFg: TLabel; ZeroFg: TLabel; PositiveFg: TLabel; HorizontalGrid: TCheckBox; VerticalGrid: TCheckBox; GridColorLabel: TLabel; procedure FormCreate(Sender: TObject); procedure ForegroundClick(Sender: TObject); procedure BackgroundClick(Sender: TObject); procedure PositiveFgButtonClick(Sender: TObject); procedure PositiveBgButtonClick(Sender: TObject); procedure NegativeFgButtonClick(Sender: TObject); procedure NegativeBgButtonClick(Sender: TObject); procedure FontButtonClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure HorizontalGridClick(Sender: TObject); procedure VerticalGridClick(Sender: TObject); procedure GridColorClick(Sender: TObject); private Procedure AskColor(Which : TStandardColors); Procedure RefreshSamples; public MarketViewColors : Array [TStandardColors] Of TColor; MarketViewGridColor : TColor; MarketViewHorizontal, MarketViewVertical : Boolean; MarketViewFont : TFont; end; var FontsAndColorsDlg: TFontsAndColorsDlg; implementation {$R *.dfm} procedure TFontsAndColorsDlg.FormCreate(Sender: TObject); begin MarketViewFont := TFont.Create end; Procedure TFontsAndColorsDlg.AskColor(Which : TStandardColors); Begin ColorDialog1.Color := MarketViewColors[Which]; If ColorDialog1.Execute Then MarketViewColors[Which] := ColorDialog1.Color End; Procedure TFontsAndColorsDlg.RefreshSamples; Var HWidth, VWidth : Integer; Begin If MarketViewHorizontal Then HWidth := 1 Else HWidth := 0; If MarketViewVertical Then VWidth := 1 Else VWidth := 0; SampleBox.Font := MarketViewFont; NegativeFg.Font := MarketViewFont; PositiveFg.Font := MarketViewFont; SampleBox.Color := MarketViewColors[scBackground]; NegativeBg.Color := MarketViewColors[scRedBg]; PositiveBg.Color := MarketViewColors[scGreenBg]; NegativeFg.Font.Color := MarketViewColors[scRedFg]; PositiveFg.Font.Color := MarketViewColors[scGreenFg]; ZeroFg.Left := PositiveFg.Width + VWidth; NegativeFg.Left := ZeroFg.Left + ZeroFg.Width + VWidth; ZeroBg.Left := PositiveBg.Width + VWidth; NegativeBg.Left := ZeroBg.Left + ZeroBg.Width + VWidth; PositiveBg.Top := PositiveFg.Height + HWidth; ZeroBg.Top := PositiveFg.Height + HWidth; NegativeBg.Top := PositiveFg.Height + HWidth; GridColorLabel.Width := NegativeBg.Left + NegativeBg.Width + VWidth; GridColorLabel.Height := NegativeBg.Top + NegativeBg.Height + HWidth; If ColorToRGB(MarketViewColors[scBackground]) = clSilver Then GridColorLabel.Color := clGray Else GridColorLabel.Color := clSilver End; procedure TFontsAndColorsDlg.ForegroundClick(Sender: TObject); begin AskColor(scForeground); MarketViewFont.Color := MarketViewColors[scForeground]; RefreshSamples end; procedure TFontsAndColorsDlg.BackgroundClick(Sender: TObject); begin AskColor(scBackground); RefreshSamples end; procedure TFontsAndColorsDlg.PositiveFgButtonClick(Sender: TObject); begin AskColor(scGreenFg); RefreshSamples end; procedure TFontsAndColorsDlg.PositiveBgButtonClick(Sender: TObject); begin AskColor(scGreenBg); RefreshSamples end; procedure TFontsAndColorsDlg.NegativeFgButtonClick(Sender: TObject); begin AskColor(scRedFg); RefreshSamples end; procedure TFontsAndColorsDlg.NegativeBgButtonClick(Sender: TObject); begin AskColor(scRedBg); RefreshSamples end; procedure TFontsAndColorsDlg.FontButtonClick(Sender: TObject); begin FontDialog1.Font := MarketViewFont; If FontDialog1.Execute Then Begin MarketViewFont := FontDialog1.Font; MarketViewColors[scForeground] := MarketViewFont.Color; RefreshSamples End end; procedure TFontsAndColorsDlg.FormShow(Sender: TObject); begin HorizontalGrid.Checked := MarketViewHorizontal; VerticalGrid.Checked := MarketViewVertical; RefreshSamples end; procedure TFontsAndColorsDlg.HorizontalGridClick(Sender: TObject); begin MarketViewHorizontal := HorizontalGrid.Checked; RefreshSamples end; procedure TFontsAndColorsDlg.VerticalGridClick(Sender: TObject); begin MarketViewVertical := VerticalGrid.Checked; RefreshSamples end; procedure TFontsAndColorsDlg.GridColorClick(Sender: TObject); begin ColorDialog1.Color := MarketViewGridColor; If ColorDialog1.Execute Then Begin MarketViewGridColor := ColorDialog1.Color; RefreshSamples End end; end.