unit U_PageWidth;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxLookAndFeelPainters, StdCtrls, cxButtons, cxControls,
  cxContainer, cxEdit, cxTextEdit, cxMaskEdit;

type
  TF_PageWidth = class(TForm)
    bOK: TcxButton;
    bCancel: TcxButton;
    edPageWidth: TcxMaskEdit;
    procedure bCancelClick(Sender: TObject);
    procedure bOKClick(Sender: TObject);
    procedure edPageWidthKeyPress(Sender: TObject; var Key: Char);
    procedure FormShow(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure edPageWidthExit(Sender: TObject);
  private
    { Private declarations }
  public
    CurrentPageWidth: string;
    { Public declarations }
  end;

var
  F_PageWidth: TF_PageWidth;

implementation
uses USCS_Main, U_CAD, U_Common;
{$R *.dfm}

procedure TF_PageWidth.bCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TF_PageWidth.bOKClick(Sender: TObject);
begin
  try
    GCadForm.PCad.Width := StrToInt(edPageWidth.Text);
  except
    ShowMessage('EXCEPTION: TF_PageWidth.bOKClick');
  end;
end;

procedure TF_PageWidth.edPageWidthKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    bOK.SetFocus;
    bOK.Click;
  end;
end;

procedure TF_PageWidth.FormShow(Sender: TObject);
begin
  edPageWidth.Text := IntToStr(GCadForm.PCad.Width);
  CurrentPageWidth := edPageWidth.Text;
  edPageWidth.SetFocus;
end;

procedure TF_PageWidth.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #27 then
    Close;
end;

procedure TF_PageWidth.edPageWidthExit(Sender: TObject);
begin
  if edPageWidth.Text = '' then
    edPageWidth.Text := CurrentPageWidth;
end;

end.
