{$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}

{*********************************************************}
{*                  OVCTCBEF.PAS 2.00                    *}
{*         Copyright (c) TurboPower Software 1995        *}
{*                 All rights reserved.                  *}
{*********************************************************}

unit OvcTCBEF;
  {-Orpheus Table Cell - base entry field type}

interface

uses
  {$IFDEF Win32}
  Windows,
  {$ELSE}
  WinTypes, WinProcs,
  {$ENDIF}
  SysUtils, Messages,
  Graphics, Classes, Controls, Forms, StdCtrls, Menus,
  OvcData, OvcConst, OvcBase, OvcCaret, OvcColor,
  OvcCmd, OvcEF,
  OvcTCmmn, OvcTCell, OvcTGRes, OvcTable, OvcTCStr;

type
  TOvcTCBaseEntryField = class(TOvcTCBaseString)
    protected {private}
      {.Z+}
      FEdit        : TOvcBaseEntryField;
      FEditDisplay : TOvcBaseEntryField;

      FOnError          : TValidationErrorEvent;
      FOnUserCommand    : TUserCommandEvent;
      FOnUserValidation : TUserValidationEvent;

      CopyOfData   : pointer;
      {.Z-}

    protected
      {.Z+}
      function GetAutoAdvanceChar : boolean;
      function GetAutoAdvanceLeftRight : boolean;
      function GetAutoSelect : boolean;
      function GetBeepOnError : boolean;
      function GetCaretIns : TOvcCaret;
      function GetCaretOvr : TOvcCaret;
      function GetCaretToEnd : boolean;
      function GetControlCharColor : TColor;
      function GetDataSize : integer;
      function GetDecimalPlaces : byte;
      function GetErrorColors : TOvcColors;
      function GetForceInsert : boolean;
      function GetForceOvertype : boolean;
      function GetHighlightColors : TOvcColors;
      function GetInsertPushes : boolean;
      function GetMaxLength : word;
      function GetModified : boolean;
      function GetPadChar : AnsiChar;
      function GetPasswordChar : AnsiChar;
      function GetPasswordMode : boolean;
      function GetRangeHi : string;
      function GetRangeLo : string;
      function GetRightJustify : boolean;
      function GetSoftValidation : boolean;
      function GetStripLiterals : boolean;
      function GetTextMargin : integer;
      function GetTrimBlanks : boolean;

      procedure SetAutoAdvanceChar(AAC : boolean);
      procedure SetAutoAdvanceLeftRight(AALR : boolean);
      procedure SetAutoSelect(ASel : boolean);
      procedure SetBeepOnError(BOE : boolean);
      procedure SetCaretIns(CI : TOvcCaret);
      procedure SetCaretOvr(CO : TOvcCaret);
      procedure SetCaretToEnd(CTE : boolean);
      procedure SetControlCharColor(CCC : TColor);
      procedure SetDecimalPlaces(DP : byte);
      procedure SetErrorColors(EC : TOvcColors);
      procedure SetForceInsert(FI : boolean);
      procedure SetForceOvertype(FO : boolean);
      procedure SetHighlightColors(HC : TOvcColors);
      procedure SetInsertPushes(IP : boolean);
      procedure SetMaxLength(ML : word);
      procedure SetPadChar(PC : AnsiChar);
      procedure SetPasswordChar(PC : AnsiChar);
      procedure SetPasswordMode(PM : boolean);
      procedure SetRangeHi(RI : string);
      procedure SetRangeLo(RL : string);
      procedure SetRightJustify(RJ : boolean);
      procedure SetSoftValidation(SV : boolean);
      procedure SetStripLiterals(SL : boolean);
      procedure SetTextMargin(TM : integer);
      procedure SetTrimBlanks(TB : boolean);

      procedure DefineProperties(Filer: TFiler); override;

      procedure tcPaint(TableCanvas : TCanvas;
                  const CellRect    : TRect;
                        RowNum      : TRowNum;
                        ColNum      : TColNum;
                  const CellAttr    : TOvcCellAttributes;
                        Data        : pointer); override;
      {.Z-}

      {properties for entry fields, to be exposed by descendants}
      property AutoAdvanceChar : boolean
         read GetAutoAdvanceChar write SetAutoAdvanceChar;

      property AutoAdvanceLeftRight : boolean
         read GetAutoAdvanceLeftRight write SetAutoAdvanceLeftRight;

      property AutoSelect : boolean
         read GetAutoSelect write SetAutoSelect;

      property BeepOnError : boolean
         read GetBeepOnError write SetBeepOnError;

      property CaretIns : TOvcCaret
         read GetCaretIns write SetCaretIns;

      property CaretOvr : TOvcCaret
         read GetCaretOvr write SetCaretOvr;

      property CaretToEnd : boolean
         read GetCaretToEnd write SetCaretToEnd;

      property ControlCharColor : TColor
         read GetControlCharColor write SetControlCharColor;

      property DecimalPlaces : byte
         read GetDecimalPlaces write SetDecimalPlaces;

      property ForceInsert : boolean
         read GetForceInsert write SetForceInsert;

      property ForceOvertype : boolean
         read GetForceOvertype write SetForceOvertype;

      property HighlightColors : TOvcColors
         read GetHighlightColors write SetHighlightColors;

      property InsertPushes : boolean
         read GetInsertPushes write SetInsertPushes;

      property MaxLength : word
         read GetMaxLength write SetMaxLength;

      property PadChar : AnsiChar
         read GetPadChar write SetPadChar;

      property PasswordChar : AnsiChar
         read GetPasswordChar write SetPasswordChar;

      property PasswordMode : boolean
         read GetPasswordMode write SetPasswordMode;

      property RangeHi : string
         read GetRangeHi write SetRangeHi
         stored false;

      property RightJustify : boolean
         read GetRightJustify write SetRightJustify;

      property RangeLo : string
         read GetRangeLo write SetRangeLo
         stored false;

      property StripLiterals : boolean
         read GetStripLiterals write SetStripLiterals;

      property TextMargin : integer
         read GetTextMargin write SetTextMargin;

      property TrimBlanks : boolean
         read GetTrimBlanks write SetTrimBlanks;

      {events}
      property OnError : TValidationErrorEvent
         read FOnError write FOnError;

      property OnUserCommand : TUserCommandEvent
         read FOnUserCommand write FOnUserCommand;

      property OnUserValidation : TUserValidationEvent
         read FOnUserValidation write FOnUserValidation;

    public
      constructor Create(AOwner : TComponent); override;
      function CreateEntryField(AOwner : TComponent) : TOvcBaseEntryField; virtual; abstract;

      function  EditHandle : THandle; override;
      procedure EditHide; override;
      procedure EditMove(CellRect : TRect); override;

      function CanSaveEditedData(SaveValue : boolean) : boolean; override;
      procedure SaveEditedData(Data : pointer); override;
      procedure StartEditing(RowNum : TRowNum; ColNum : TColNum;
                             CellRect : TRect;
                       const CellAttr : TOvcCellAttributes;
                             CellStyle: TOvcTblEditorStyle;
                             Data : pointer); override;
      procedure StopEditing(SaveValue : boolean;
                            Data : pointer); override;

      property DataSize : integer
         read GetDataSize;

      property Modified : boolean
         read GetModified;
  end;

implementation
