unit DLGNew;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, Mask, MiscRoutines, Spin;

type
  TPlanType = (ptFFE, ptCCO, ptCCR, ptFromWizard);

type
  TNewDialog = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    LDegree: TLabel;
    TypeGroup: TGroupBox;
    FFEButton: TRadioButton;
    CCOButton: TRadioButton;
    CCRButton: TRadioButton;
    EDegree: TSpinEdit;
    procedure FFEButtonClick(Sender: TObject);
    procedure CCOButtonClick(Sender: TObject);
    procedure CCRButtonClick(Sender: TObject);
    procedure DlgNewCreate(Sender: TObject);
    procedure DlgNewCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure EDegreeExit(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    function  Validate:Boolean;
    procedure Clean;
  public
    pType     : TPlanType;
    Degree    : Integer;
  end;

var
  NewDialog: TNewDialog;

implementation

{$R *.DFM}

function TNewDialog.Validate:Boolean;
begin
  Result:=CheckSpinContens(Edegree,'Число факторов');
end;

procedure TNewDialog.Clean;
begin
  Edegree.Value:=ValidInteger(Edegree);
end;

procedure TNewDialog.FFEButtonClick(Sender: TObject);
begin
  pType:=ptFFE;
end;

procedure TNewDialog.CCOButtonClick(Sender: TObject);
begin
  pType:=ptCCO;
end;

procedure TNewDialog.CCRButtonClick(Sender: TObject);
begin
  pType:=ptCCR;
end;

procedure TNewDialog.DlgNewCreate(Sender: TObject);
begin
  pType:=ptFFE;
  Degree:=2;
  EDegree.Value:=2;
end;

procedure TNewDialog.DlgNewCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  CanClose:=ValidateByResult(Validate,Clean,ModalResult);
  if(CanClose) then
    Degree:=EDegree.Value;
end;

procedure TNewDialog.EDegreeExit(Sender: TObject);
begin
  if(not CheckSpinContens(Edegree,'Число факторов')) then
    ActiveControl:=EDegree;
end;

procedure TNewDialog.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if(ChooseResult(Key,ModalResult)<>mrNone) then
    ModalResult:=ChooseResult(Key,ModalResult);
end;

end.

