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

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

unit OvcPLb;
  {-Picture label component}

interface

uses
  {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
  Classes, Controls, Forms, Graphics, Menus, Messages, SysUtils,
  OvcData, OvcIntl, OvcRLbl, OvcStr, OvcUser, STDate;

type
  TPictureLabelDataType =
    (plNone, plBoolean, plYesNo, plDate, plFloat, plInteger,
     plStDate, plStTime, plString, plTime);

const
  DefCtrlColor         = clRed;
  DefParentColor       = True;
  DefPictureMask       = 'XXXXXXXXXX';
  DefTransparent       = False;
  DefUseIntlMask       = False;

type
  TOvcCustomPictureLabel = class(TOvcCustomRotatedLabel)
  {.Z+}
  protected {private}
    FData           : string[255];
    FDataType       : TPictureLabelDataType;
    FIntlSupport    : TOvcIntlSup;  {international support object}
    FPictureMask    : string;
    FPictureFlags   : array[1..255] of Byte;
    FUseIntlMask    : Boolean;
    FUserData       : TOvcUserData;

    {property methods}
    procedure SetAsBoolean(Value : Boolean);
      {-set the field value to a Boolean value}
    procedure SetAsDate(Value : TDateTime);
      {-set the field value to a Delphi date value}
    procedure SetAsFloat(Value : Extended);
      {-set the field value to a Double value}
    procedure SetAsInteger(Value : Longint);
      {-set the field value to a LongInt value}
    procedure SetAsStDate(Value : TStDate);
      {-set the field value to an Orpheus date value}
    procedure SetAsStTime(Value : TStTime);
      {-set the field value to an Orpheus time value}
    procedure SetAsString(const Value : string);
      {-set the field value to a string value}
    procedure SetAsTime(Value : TDateTime);
      {-set the field value to a Delphi time value}
    {$IFDEF Win32}
    procedure SetAsVariant(Value : Variant);
      {-sets the field value to a Variant value}
    {$ENDIF}
    procedure SetAsYesNo(Value : Boolean);
      {-set the field value to a Boolean value}
    procedure SetIntlSupport(Value : TOvcIntlSup);
      {-set the international support object to use}
    procedure SetPictureMask(const Value : string);
      {-set the picture mask}
    procedure SetUseIntlMask(Value : Boolean);
      {-set the use of the international picture masks}
    procedure SetUserData(Value : TOvcUserData);
      {-set user-defined mask data object}

    {internal methods}
    procedure plCalcWidthAndPlaces(var Width, Places : Word);
      {-calculate width and decimal places for a numeric value}
    procedure plFixCase(PicChar : AnsiChar; var Ch : AnsiChar; PrevCh : AnsiChar);
      {-fix the case of Ch based on PicChar}
    procedure plFixDecimalPoint(var S : string);
      {-fix decimal points for real numbers before merging}
    function plGetDisplayString : string;
      {-return the display string}
    procedure plInitPictureFlags;
      {-initialize flags for the picture mask}
    function plIsLiteral(N : Word) : Boolean;
      {-return True if the N'th mask character is a literal. N is 1-based}
    function plIsSemiLiteral(N : Word) : Boolean;
      {-return True if the N'th mask character is a semi-literal. N is 1-based}
    function plMergePicture(const Src : string) : string;
      {-merge Src with picture and return result}

  protected
    function plGetSampleDisplayData : string;
      dynamic;
      {-return the text to display while in design mode}
  {.Z-}

    {properties}
    property PictureMask : string
      read FPictureMask
      write SetPictureMask;

    property UseIntlMask : Boolean
      read FUseIntlMask
      write SetUseIntlMask
      default DefUseIntlMask;

  public
    constructor Create(AOwner : TComponent);
      override;
    procedure PaintTo(DC : hDC; X, Y : Integer);
      virtual;

    procedure Clear;
      {-clear the field contents and picture mask}
    function GetDisplayString : string;
      {-return the display string}
      virtual;

    {public properties}
    property AsBoolean : Boolean
      write SetAsBoolean;

    property AsDate : TDateTime
      write SetAsDate;

    property AsFloat : Extended
      write SetAsFloat;

    property AsInteger : Longint
      write SetAsInteger;

    property AsString : string
      write SetAsString;

    property AsTime : TDateTime
      write SetAsTime;

    {$IFDEF Win32}
    property AsVariant : Variant
      write SetAsVariant;
    {$ENDIF}

    property AsStDate : TStDate
      write SetAsStDate;

    property AsStTime : TStTime
      write SetAsStTime;

    property AsYesNo : Boolean
      write SetAsYesNo;

    property Canvas;

    property IntlSupport : TOvcIntlSup
      read FIntlSupport
      write SetIntlSupport;

    property Text : string
      read GetDisplayString
      write SetAsString;

    property UserData :  TOvcUserData
      read FUserData
      write SetUserData;

  published
  end;

  TOvcPictureLabel = class(TOvcCustomPictureLabel)
  published
    property Align;
    property Alignment;
    property AutoSizeHeight;
    property AutoSizeWidth;
    property Caption;
    property Color;
    property DragCursor;
    property DragMode;
    property Enabled;
    property Font;
    property FontAngle;
    property OriginX;
    property OriginY;
    property ParentColor
      default DefParentColor;
    property ParentFont;
    property ParentShowHint;
    property PictureMask;
    property PopupMenu;
    property ShadowColor;
    property ShadowedText;
    property ShowHint;
    property Transparent;
    property UseIntlMask;
    property Visible;

    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    {$IFDEF Win32}
    property OnStartDrag;
    {$ENDIF}
  end;


implementation
