home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 December
/
Chip_2001-12_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
DM2KVCL.ZIP
/
AXISDLG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
2001-08-20
|
6KB
|
174 lines
{****************************************************************************}
{ Data Master 2000 }
{****************************************************************************}
unit AxisDlg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ImgList, StdCtrls, Buttons, Spin, ExtCtrls, ColorGrd, Plot,
FloatEd;
type
TAxisPropsForm = class(TForm)
OkBitBtn: TBitBtn;
CancelBitBtn: TBitBtn;
HelpBitBtn: TBitBtn;
ImageList: TImageList;
FontDialog: TFontDialog;
ColorDialog: TColorDialog;
PageControl: TPageControl;
ScaleTabSheet: TTabSheet;
LabelsTabSheet: TTabSheet;
LineTabSheet: TTabSheet;
ManualScalePanel: TPanel;
FormatGroupBox: TGroupBox;
WidthLabel: TLabel;
DigitsLabel: TLabel;
SampleLabel: TLabel;
WidthSpinEdit: TSpinEdit;
FormatRadioGroup: TRadioGroup;
DigitsSpinEdit: TSpinEdit;
ManualScaleRadioButton: TRadioButton;
MinScaleLabel: TLabel;
MaxScaleLabel: TLabel;
AutoScalePanel: TPanel;
MarginsLabel: TLabel;
AutoScaleRadioButton: TRadioButton;
ExpressionLabel: TLabel;
ExpressionComboBox: TComboBox;
FontBitBtn: TBitBtn;
CaptionLabel: TLabel;
CaptionEdit: TEdit;
LineWidthLabel: TLabel;
LineWidthSpinEdit: TSpinEdit;
TicksGroupBox: TGroupBox;
MajorTicksLabel: TLabel;
MajorTicksSpinEdit: TSpinEdit;
MinorTicksLabel: TLabel;
MinorTicksSpinEdit: TSpinEdit;
GridCheckBox: TCheckBox;
LineColorGroupBox: TGroupBox;
LineColorGrid: TColorGrid;
LineColorBitBtn: TBitBtn;
MarginsFloatEdit: TFloatEdit;
MinScaleFloatEdit: TFloatEdit;
MaxScaleFloatEdit: TFloatEdit;
TextSpeedButton: TSpeedButton;
procedure LineColorGridChange(Sender: TObject);
procedure LineColorBitBtnClick(Sender: TObject);
procedure FontBitBtnClick(Sender: TObject);
procedure FormatChange(Sender: TObject);
procedure ScaleFloatEditChange(Sender: TObject);
procedure TextSpeedButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function Execute(Axis: TAxis): boolean; {returns true if pressed OK}
end;
var AxisPropsForm: TAxisPropsForm;
implementation
uses TextDlg;
{$R *.DFM}
{ TAxisPropsForm }
function TAxisPropsForm.Execute(Axis: TAxis): boolean;
var B: boolean; I: integer;
begin
MarginsFloatEdit.Value:=Axis.Margins; {copy properties from axis}
MinScaleFloatEdit.Value:=Axis.Min;
MaxScaleFloatEdit.Value:=Axis.Max;
MinScaleFloatEdit.Increment:=(Axis.Max-Axis.Min)/Axis.MajorTicks;
MaxScaleFloatEdit.Increment:=(Axis.Max-Axis.Min)/Axis.MajorTicks;
ExpressionComboBox.Text:=Axis.Expression;
WidthSpinEdit.Value:=Axis.LabelWidth;
DigitsSpinEdit.Value:=Axis.LabelDecimals;
case Axis.labelType of
ffGeneral: FormatRadioGroup.ItemIndex:=0;
ffFixed: FormatRadioGroup.ItemIndex:=1;
ffExponent: FormatRadioGroup.ItemIndex:=2;
end;{case}
FormatChange(Self); {must be called AFTER setting format controls}
AutoScaleRadioButton.Checked:=Axis.AutoScale;
ManualScaleRadioButton.Checked:=not Axis.AutoScale; // else both may be off!
CaptionEdit.Text:=Axis.Title;
MajorTicksSpinEdit.Value:=Axis.MajorTicks;
MinorTicksSpinEdit.Value:=Axis.MinorTicks;
LineWidthSpinEdit.Value:=Axis.Pen.Width;
GridCheckBox.Checked:=Axis.ShowGrid;
LineColorGrid.ForegroundIndex:=-1;
ColorDialog.Color:=Axis.Pen.Color;
FontDialog.Font:=Axis.Font;
Result:=ShowModal=mrOK; if not Result then Exit; {cancelled}
Axis.Margins:=MarginsFloatEdit.Value; {copy properties to axis}
Axis.Min:=MinScaleFloatEdit.Value;
Axis.Max:=MaxScaleFloatEdit.Value;
Axis.Expression:=ExpressionComboBox.Text;
Axis.AutoScale:=AutoScaleRadioButton.Checked;
Axis.LabelWidth:=WidthSpinEdit.Value;
Axis.LabelDecimals:=DigitsSpinEdit.Value;
case FormatRadioGroup.ItemIndex of
0: Axis.labelType:=ffGeneral;
1: Axis.labelType:=ffFixed;
2: Axis.labelType:=ffExponent;
end;
Axis.Title:=CaptionEdit.Text;
Axis.MajorTicks:=MajorTicksSpinEdit.Value;
Axis.MinorTicks:=MinorTicksSpinEdit.Value;
Axis.Pen.Width:=LineWidthSpinEdit.Value;
Axis.ShowGrid:=GridCheckBox.Checked;
Axis.Pen.Color:=ColorDialog.Color;
Axis.Font:=FontDialog.Font;
B:=true; {check expression for duplication and add to the top of list}
with ExpressionComboBox.Items do for I:=0 to Count-1 do
if Strings[I]=ExpressionComboBox.Text then B:=false;
if B and (ExpressionComboBox.Text<>'')
then ExpressionComboBox.Items.Insert(0, ExpressionComboBox.Text);
end;
procedure TAxisPropsForm.LineColorGridChange(Sender: TObject);
begin ColorDialog.Color:=LineColorGrid.ForegroundColor; end;
procedure TAxisPropsForm.LineColorBitBtnClick(Sender: TObject);
begin ColorDialog.Execute; LineColorGrid.ForegroundIndex:=-1; end;
procedure TAxisPropsForm.FontBitBtnClick(Sender: TObject);
begin FontDialog.Execute; end;
procedure TAxisPropsForm.FormatChange(Sender: TObject);
begin
case FormatRadioGroup.ItemIndex of {update scale editors}
0: MinScaleFloatEdit.FType:=ffGeneral;
1: MinScaleFloatEdit.FType:=ffFixed;
2: MinScaleFloatEdit.FType:=ffExponent;
end;{case}
MinScaleFloatEdit.MinWidth:=WidthSpinEdit.Value;
MinScaleFloatEdit.Decimals:=DigitsSpinEdit.Value;
MaxScaleFloatEdit.FType:=MinScaleFloatEdit.FType;
MaxScaleFloatEdit.MinWidth:=MinScaleFloatEdit.MinWidth;
MaxScaleFloatEdit.Decimals:=MinScaleFloatEdit.Decimals;
with MaxScaleFloatEdit do SampleLabel.Caption:=FloatToStrF((Value+
MinScaleFloatEdit.Value)/2,FType,MinWidth,Decimals); {update sample}
end;
procedure TAxisPropsForm.ScaleFloatEditChange(Sender: TObject);
begin
if (Sender as TFloatEdit).Focused then ManualScaleRadioButton.Checked:=true;
end;
procedure TAxisPropsForm.TextSpeedButtonClick(Sender: TObject);
var S: string;
begin
S:=ExpressionComboBox.Text;
if InputText(S,ExpressionComboBox) then ExpressionComboBox.Text:=S;
end;
end.