(*****************************************************************************)
(* MODULE: BTRINFOU                                                          *)
(* AUTHOR: Peter Blair                                                       *)
(* RIGHTS: Reggatta Systems, Inc. - COPYRIGHT 1995 - 1998                    *)
(* DESCR.: This module contains classes for InfoPower compatibility          *)
(*****************************************************************************)
Unit BtrInfoU;
Interface

{$I BSE.INC}

uses
  BtrMain,
  Classes,
  wwTypes;


Type
  TwwTbQuery =
  Class( TtbQuery )
    Private
      FControlType    : TStrings;
      FPictureMasks   : TStrings;
      FUsePictureMask : boolean;
      FOnInvalidValue : TwwInvalidValueEvent;

      Function GetControlType : TStrings;
      Procedure SetControlType( sel : TStrings );
      Function GetPictureMasks : TStrings;
      Procedure SetPictureMasks( sel : TStrings );

    Protected
      Procedure DoBeforePost; Override; { For picture support }

    Public
      Constructor Create( AOwner : TComponent ); Override;
      Destructor Destroy; Override;

    Published
      Property ControlType : TStrings
        Read  GetControlType
        Write SetControlType;
      Property PictureMasks: TStrings
        Read GetPictureMasks
        Write SetPictureMasks;
      Property ValidateWithMask : boolean
        Read FUsePictureMask
        Write FUsePictureMask;
      Property OnInvalidValue: TwwInvalidValueEvent
        Read FOnInvalidValue
        Write FOnInvalidValue;
  end;


  TwwTbTable =
  Class( TtbTable )
    Private
      FControlType    : TStrings;
      FPictureMasks   : TStrings;
      FUsePictureMask : boolean;
      FOnInvalidValue : TwwInvalidValueEvent;

      Function GetControlType : TStrings;
      Procedure SetControlType( sel : TStrings );
      Function GetPictureMasks : TStrings;
      Procedure SetPictureMasks( sel : TStrings );

    Protected
      Procedure DoBeforePost; Override; { For picture support }

    Public
      Constructor Create( AOwner : TComponent ); Override;
      Destructor Destroy; Override;

    Published
      Property ControlType : TStrings
        Read  GetControlType
        Write setControltype;
      Property PictureMasks: TStrings
        Read GetPictureMasks
        Write SetPictureMasks;
      Property ValidateWithMask : boolean
        Read FUsePictureMask
        Write FUsePictureMask;
      Property OnInvalidValue: TwwInvalidValueEvent
        Read FOnInvalidValue
        Write FOnInvalidValue;
  end;

Procedure Register;

implementation
uses
  wwCommon;

{$I BAPI.INC}

Constructor TwwTbQuery.Create( AOwner : TComponent );
begin
  inherited Create( AOwner );
  FControlType    := TStringList.create;
  FPictureMasks   := TStringList.create;
  FUsePictureMask := True;
end;


Destructor TwwTbQuery.Destroy;
begin
  FControlType.Free;
  FPictureMasks.Free;
  FPictureMasks:= NIL;
  Inherited Destroy;
end;


Function TwwTbQuery.GetControltype : TStrings;
begin
  Result := FControlType;
end;


Procedure TwwTbQuery.SetControlType( sel : TStrings );
begin
  FControlType.Assign( sel );
end;


Function TwwTbQuery.GetPictureMasks : TStrings;
begin
  Result:= FPictureMasks
end;


Procedure TwwTbQuery.SetPictureMasks( sel : TStrings );
begin
  FPictureMasks.Assign( sel );
end;


Procedure TwwTbQuery.DoBeforePost;
begin
  Inherited DoBeforePost;
  if FUsePictureMask then
    wwValidatePictureFields( self, FOnInvalidValue );
end;


Constructor TwwTbTable.create( AOwner : TComponent );
begin
  inherited Create( AOwner );
  FControlType    := TStringList.create;
  FPictureMasks   := TStringList.create;
  FUsePictureMask := True;
end;


Destructor TwwTbTable.Destroy;
begin
  FControlType.Free;
  FPictureMasks.Free;
  FPictureMasks:= NIL;
  Inherited Destroy;
end;


Function TwwTbTable.GetControltype : TStrings;
begin
  Result := FControlType;
end;


Procedure TwwTbTable.SetControlType( sel : TStrings );
begin
  FControlType.Assign( sel );
end;


Function TwwTbTable.GetPictureMasks : TStrings;
begin
  Result:= FPictureMasks
end;


Procedure TwwTbTable.SetPictureMasks( sel : TStrings );
begin
  FPictureMasks.Assign( sel );
end;


Procedure TwwTbTable.DoBeforePost;
begin
  Inherited DoBeforePost;
  if FUsePictureMask then
    wwValidatePictureFields( self, FOnInvalidValue );
end;


Procedure Register;
begin
  RegisterComponents('IP Access', [ TwwTbTable, TwwTbQuery ] );
end;


end.
