{$I OVC.INC}

{$B-} {Complete Boolean Evaluation}
{$I+} {Input/Output-Checking}
{$P+} {Open Parameters}
{$T-} {Typed @ Operator}
{$W-} {Windows Stack Frame}
{$X+} {Extended Syntax}

{$IFNDEF Win32}
{$G+} {286 Instructions}
{$N+} {Numeric Coprocessor}
{$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
{$ENDIF}

{*********************************************************}
{*                    OVCPF.PAS 2.00                     *}
{*     Copyright (c) TurboPower Software Co 1995-96      *}
{*                 All rights reserved.                  *}
{*********************************************************}

unit OvcPF;
  {-picture field component}

interface

uses
  {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
  Classes, Controls, Forms, Graphics, Menus, Messages, SysUtils,
  OvcBase, OvcCaret, OvcColor, OvcConst, OvcCmd,
  OvcData, OvcEf, OvcExcpt, OvcMisc, OvcPb, OvcStr, STDate;

type
  {picture field types}
  TPictureDataType   = (
    pftString, pftChar, pftBoolean, pftYesNo, pftLongInt,
    pftWord, pftInteger, pftByte, pftShortInt, pftReal, pftExtended,
    pftDouble, pftSingle, pftComp, pftDate, pftTime);

const
  DefInitDateTime    = False;
  DefPictureDataType = pftString;
  DefPictureMask     = 'XXXXXXXXXXXXXXX';

type
  TOvcCustomPictureField = class(TOvcPictureBase)
  {.Z+}
  protected {private}
    {property instance variables}
    FInitDateTime     : Boolean;
    FPictureDataType  : TPictureDataType;
    FPictureMask      : string;

    {property methods}
    procedure SetInitDateTime(Value : Boolean);
      {-set the InitDateTime property}

    {internal methods}
    function pfGetDataType(Value : TPictureDataType) : Byte;
      {-return a Byte value representing the type of this field}
    procedure pfResetFieldProperties(FT : TPictureDataType);
      {-reset field properties based on current setings}
    procedure pfSetDefaultRanges;
      {-set default range values based on the field type}

  protected
    procedure Assign(Source : TPersistent);
      override;
    procedure CreateParams(var Params : TCreateParams);
      override;
    procedure CreateWnd;
      override;

    procedure efEdit(var Msg : TMessage; Cmd : Word);
      override;
      {-process the specified editing command}
    procedure efIncDecValue(Wrap : Boolean; Delta : Double);
      override;
      {-increment field by Delta}
    function efTransfer(DataPtr : Pointer; TransferFlag : Word) : Word;
      override;
      {-transfer data to/from the entry fields}

    {virtual property methods}
    procedure pfSetDataType(Value : TPictureDataType);
      virtual;
      {-set the data type for this field}
    procedure pfSetPictureMask(const Value : string);
      virtual;
      {-set the picture mask}
    procedure SetAsString(const Value : string);
      {-sets the field value to a String Value}
      override;
  {.Z-}

  public
    constructor Create(AOwner: TComponent);
      override;

  {.Z+}
    function efValidateField : Word;
      override;
      {-validate contents of field; result is error code or 0}
  {.Z-}

    {public properties}
    property DataType : TPictureDataType
      read FPictureDataType
      write pfSetDataType
      default DefPictureDataType;

    property InitDateTime : Boolean
      read FInitDateTime
      write SetInitDateTime
      default DefInitDateTime;

    property PictureMask : string
      read FPictureMask
      write pfSetPictureMask;

  published
  end;

  TOvcPictureField = class(TOvcCustomPictureField)
  published
    {inherited properties}
    property DataType;            {needs to load before most other properties}
    property AutoAdvanceChar;
    property AutoAdvanceLeftRight;
    property AutoAdvanceUpDown;
    property AutoSelect;
    property AutoSize;
    property BeepOnError;
    property BorderStyle;
    property CaretIns;
    property CaretOvr;
    property CaretToEnd;
    property Color;
    property Controller;
    property ControlCharColor;
    property Ctl3D;
    property DecimalPlaces;
    property DragCursor;
    property DragMode;
    property Enabled;
    property Epoch;
    property ErrorColors;
    property Font;
    property ForceInsert;
    property ForceOvertype;
    property HighlightColors;
    property InitDateTime;
    property InputRequired;
    property InsertPushes;
    property MaxLength;
    property PadChar;
    property ParentColor default DefParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PasswordChar;
    property PasswordMode;
    property PictureMask;
    property PopupMenu;
    property RangeHi stored False;
    property RangeLo stored False;
    property ReadOnly;
    property RightJustify;
    property ShowHint;
    property SoftValidation;
    property StripLiterals;
    property TabOrder;
    property TabStop default DefTabStop;
    property Tag;
    property TextMargin;
    property TrimBlanks;
    property Uninitialized;
    property Visible;
    property ZeroDisplay;
    property ZeroDisplayValue;

    {inherited events}
    property OnChange;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnEnter;
    property OnError;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    {$IFDEF Win32}
    property OnStartDrag;
    {$ENDIF}
    property OnUserCommand;
    property OnUserValidation;
  end;


implementation
