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

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

unit OvcDbEd;
  {-data aware version of the TOvcEditor}

interface

uses
  {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
  Classes, Controls, Db, DbConsts, DbCtrls, DbTables, Forms, Graphics,
  Menus, Messages, StdCtrls, SysUtils,
  OvcBase, OvcCaret, OvcCmd, OvcColor, OvcData, OvcEdit, OvcEditU,
  OvcFxFnt;

const
  DefAutoUpdate = True;
  DefDbEdLimit  = High(SmallInt);

type
  TOvcDbEditor = class(TOvcCustomEditor)
  {.Z+}
  protected
    {property variables}
    FAutoUpdate : Boolean;
    FDataLink   : TFieldDataLink;

    {property methods}
    function GetField : TField;
    function GetDataField : string;
    function GetDataSource : TDataSource;
    procedure SetDataField(const Value : string);
    procedure SetDataSource(Value : TDataSource);

    {internal methods}
    procedure eddbGetEditorValue;
    procedure eddbDataChange(Sender : TObject);
    procedure eddbEditingChange(Sender : TObject);
    procedure eddbSetEditorValue;
    procedure eddbUpdateData(Sender : TObject);

    {vcl methods}
    procedure CMEnter(var Msg : TMessage);
      message CM_ENTER;
    procedure CMExit(var Msg : TMessage);
      message CM_EXIT;
    {$IFDEF Win32}
    procedure CMGetDataLink(var Msg : TMessage);
      message CM_GETDATALINK;
    {$ENDIF}

    {windows message methods}
    procedure WMChar(var Msg : TWMChar);
      message WM_CHAR;
    procedure WMKeyDown(var Msg : TWMKeyDown);
      message WM_KEYDOWN    ;

    procedure CreateWnd;
      override;
    procedure edAddSampleParas;
      override;
    procedure Notification(AComponent : TComponent; Operation : TOperation);
      override;

    {virtual property methods}
    function GetReadOnly : Boolean;
      override;
      {-return the read-only status}
    procedure SetByteLimit(Value : LongInt);
      override;
      {-set a limit on the total number of bytes}
  {.Z-}

  public
    constructor Create(AOwner : TComponent);
      override;
    destructor Destroy;
      override;

    procedure CutToClipboard;
      override;
      {-copy highlighted text to the clipboard and then delete it}
    procedure Redo;
      {-redo the last undone operation}
      override;
    function Replace(const S, R : string;
                     Options : TSearchOptionSet) : LongInt;
      {-search for a string and replace it with another string}
      override;
    procedure PasteFromClipboard;
      override;
      {-paste the contents of the clipboard}
    procedure Undo;
      {-undo the last change}
      override;

    property Field : TField
      read GetField;

  published
    property AutoUpdate : Boolean
      read FAutoUpdate
      write FAutoUpdate
      default DefAutoUpdate;

    property DataField : string
      read GetDataField
      write SetDataField;

    property DataSource : TDataSource
      read GetDataSource
      write SetDataSource;

    property AutoIndent;
    property BorderStyle;
    property ByteLimit default DefDbEdLimit;
    property CaretIns;
    property CaretOvr;
    property FixedFont;
    property HideSelection;
    property HighlightColors;
    property InsertMode;
    property LeftMargin;
    property ParaLengthLimit;
    property ParaLimit;
    property ReadOnly;
    property RightMargin;
    property ScrollBars;
    property ScrollBarsAlways;
    property ScrollPastEnd;
    property ShowBookmarks;
    property TabSize;
    property TabType;
    property UndoBufferSize;
    property WantEnter;
    property WantTab;
    property WordWrap;
    property WrapAtLeft;
    property WrapColumn;
    property WrapToWindow;

    property OnError;
    property OnShowStatus;
    property OnUserCommand;

    {inherited properties}
    property Align;
    property Color;
    property Controller;
    property Ctl3D default DefCtl3D;
    property DragCursor;
    property DragMode;
    property Enabled;
    property ParentColor default DefParentColor;
    property ParentCtl3D default DefParentCtl3D;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop default DefTabStop;
    property Visible;

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


implementation
