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

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

unit OvcTCEdt;
  {-Orpheus Table Cell - Windows edit Control type}

interface

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

type
  TOvcTCStringEdit = class(TEdit)
    protected {private}
      {.Z+}
      FCell : TOvcBaseTableCell;
      {.Z-}

    protected
      {.Z+}
      procedure WMChar(var Msg : TWMKey); message WM_CHAR;
      procedure WMGetDlgCode(var Msg : TMessage); message WM_GETDLGCODE;
      procedure WMKeyDown(var Msg : TWMKey); message WM_KEYDOWN;
      procedure WMKillFocus(var Msg : TWMKillFocus); message WM_KILLFOCUS;
      procedure WMSetFocus(var Msg : TWMSetFocus); message WM_SETFOCUS;

      property CellOwner : TOvcBaseTableCell
         read FCell write FCell;
      {.Z-}
  end;

  TOvcTCCustomString = class(TOvcTCBaseString)
    protected {private}
      {.Z+}
      FEdit        : TOvcTCStringEdit;
      FMaxLength   : word;
      FAutoAdvanceChar      : boolean;
      FAutoAdvanceLeftRight : boolean;
      {.Z-}

    protected
      {.Z+}
      function GetCellEditor : TControl; override;
      function GetModified : boolean;
      {.Z-}

      property AutoAdvanceChar : boolean
         read FAutoAdvanceChar write FAutoAdvanceChar;

      property AutoAdvanceLeftRight : boolean
         read FAutoAdvanceLeftRight write FAutoAdvanceLeftRight;

      property MaxLength : word
         read FMaxLength write FMaxLength;

    public
      function CreateEditControl(AOwner : TComponent) : TOvcTCStringEdit; virtual;

      function  EditHandle : THandle; override;
      procedure EditHide; override;
      procedure EditMove(CellRect : TRect); 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 Modified : boolean
         read GetModified;
  end;

  TOvcTCString = class(TOvcTCCustomString)
    published
      {properties inherited from custom ancestor}
      property Access;
      property Adjust;
      property AutoAdvanceChar;
      property AutoAdvanceLeftRight;
      property Color;
      property Font;
      property Hint;
      property Margin;
      property MaxLength;
      property ShowHint;
      property Table;
      property TableColor;
      property TableFont;
      property TextHiColor;
      property TextStyle;
      property UseWordWrap;
      property UseASCIIZStrings;

      {events inherited from custom ancestor}
      property OnChange;
      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;
      property OnOwnerDraw;
  end;

type
  TOvcTCMemoEdit = class(TMemo)
    protected {private}
      {.Z+}
      FCell : TOvcBaseTableCell;
      {.Z-}

    protected
      {.Z+}
      procedure WMChar(var Msg : TWMKey); message WM_CHAR;
      procedure WMGetDlgCode(var Msg : TMessage); message WM_GETDLGCODE;
      procedure WMKeyDown(var Msg : TWMKey); message WM_KEYDOWN;
      procedure WMKillFocus(var Msg : TWMKillFocus); message WM_KILLFOCUS; 
      procedure WMSetFocus(var Msg : TWMSetFocus); message WM_SETFOCUS;
      {.Z-}

      property CellOwner : TOvcBaseTableCell
         read FCell write FCell;
  end;

  TOvcTCCustomMemo = class(TOvcTCBaseString)
    protected {private}
      {.Z+}
      FEdit        : TOvcTCMemoEdit;
      FMaxLength   : word;
      FWantReturns : boolean;
      FWantTabs    : boolean;
      {.Z-}

    protected
      {.Z+}
      function GetCellEditor : TControl; override;
      function GetModified : boolean;
      {.Z-}

      property MaxLength : word
         read FMaxLength write FMaxLength;

      property WantReturns : boolean
         read FWantReturns write FWantReturns;

      property WantTabs : boolean
         read FWantTabs write FWantTabs;

    public
      constructor Create(AOwner : TComponent); override;
      function CreateEditControl(AOwner : TComponent) : TOvcTCMemoEdit; virtual;

      function  EditHandle : THandle; override;
      procedure EditHide; override;
      procedure EditMove(CellRect : TRect); 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 Modified : boolean
         read GetModified;
  end;

  TOvcTCMemo = class(TOvcTCCustomMemo)
    published
      {properties inherited from custom ancestor}
      property Access;
      property Adjust;
      property Color;
      property Font;
      property Hint;
      property Margin;
      property MaxLength;
      property ShowHint;
      property Table;
      property TableColor;
      property TableFont;
      property TextHiColor;
      property TextStyle;
      property WantReturns;
      property WantTabs;

      {events inherited from custom ancestor}
      property OnChange;
      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;
      property OnOwnerDraw;
  end;

implementation
