{------------------------------------------------------------------------------}
{
   Unit Name: YasExtContact
   Purpose  : CheckBox + Led + Edit for Yaskawa form
   Author   : Vesa Lappalainen
   Date     : 3.8.2001
   Changed  :

   ToDo     :
}
{------------------------------------------------------------------------------}
unit YasExtContact;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, kRndled;

type
  TFrameYasExtContact = class(TFrame)
    CheckBox: TCheckBox;
    Led: TkRndLed;
    Edit: TEdit;
  private
    function GetCaption: string;
    function GetText: string;
    procedure SetCaption(const Value: string);
    procedure SetText(const Value: string);
    function GetChecked: boolean;
    procedure SetChecked(const Value: boolean);
    function GetLedOn: boolean;
    procedure SetLedOn(const Value: boolean);
    function GetCWidth: integer;
    procedure SetCWidth(const Value: integer);
    function GetCTag: integer;
    procedure SetCTag(const Value: integer);
    { Private declarations }
  public
    { Public declarations }
    procedure CloneSettings(f:TFrameYasExtContact); virtual;
  published
    property Caption : string read GetCaption write SetCaption;
    property Text : string read GetText write SetText;
    property Checked : boolean read GetChecked write SetChecked;
    property LedOn : boolean read GetLedOn write SetLedOn;
    property CWidth : integer read GetCWidth write SetCWidth;
    property CTag : integer read GetCTag write SetCTag;
  end;

implementation

{$R *.dfm}

{ TFrameYasExtContact }

procedure TFrameYasExtContact.CloneSettings(f: TFrameYasExtContact);
begin
  CheckBox.Left := f.CheckBox.Left;
  CheckBox.Width := f.CheckBox.Width;
  Led.Left := f.Led.Left;
  Led.Width := f.Led.Width;
  Edit.Left := f.Edit.Left;
  Edit.Width := f.Edit.Width;
  Edit.OnChange := f.Edit.OnChange;
  CheckBox.OnClick := f.CheckBox.OnClick;
end;

function TFrameYasExtContact.GetCaption: string;
begin
  Result := CheckBox.Caption;
end;

function TFrameYasExtContact.GetChecked: boolean;
begin
  Result := CheckBox.Checked
end;

function TFrameYasExtContact.GetCTag: integer;
begin
  Result := CheckBox.Tag;
end;

function TFrameYasExtContact.GetCWidth: integer;
begin
  Result := CheckBox.Width;
end;

function TFrameYasExtContact.GetLedOn: boolean;
begin
  Result := Led.LedOn;
end;

function TFrameYasExtContact.GetText: string;
begin
  Result := Edit.Text;
end;

procedure TFrameYasExtContact.SetCaption(const Value: string);
begin
  CheckBox.Caption := Value;
end;

procedure TFrameYasExtContact.SetChecked(const Value: boolean);
begin
  CheckBox.Checked := Value;
end;

procedure TFrameYasExtContact.SetCTag(const Value: integer);
begin
  CheckBox.Tag := Value;
end;

procedure TFrameYasExtContact.SetCWidth(const Value: integer);
var d1,d2 : integer;
begin
  d1 := Led.Left - CheckBox.Width;
  d2 := Edit.Left - (Led.Width+Led.Left);
  CheckBox.Width := Value;
  Led.Left := Value + d1;
  Edit.Left := ( Led.Width + Led.Left ) + d2;
end;

procedure TFrameYasExtContact.SetLedOn(const Value: boolean);
begin
  Led.LedOn := Value;
end;

procedure TFrameYasExtContact.SetText(const Value: string);
begin
  Edit.Text := Value;
end;

end.
