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

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

unit OvcRLbl;
  {-Rotated label component}

interface

uses
  {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
  Classes, Controls, Forms, Graphics, Menus, Messages, SysUtils,
  OvcConst, OvcData, OvcExcpt, OvcMisc;

const
  {default property values}
  DefAlignment      = taLeftJustify;
  DefAutoSizeHeight = False;
  DefAutoSizeWidth  = False;
  DefFontAngle      = 0;
  DefFontName       = 'Courier New';
  DefHeight         = 20;
  DefShadowColor    = clBtnShadow;
  DefShadowedText   = False;
  DefTransparent    = False;
  DefWidth          = 130;
  DefOriginX        = 0;
  DefOriginY        = 0;

type
  TOvcCustomRotatedLabel = class(TGraphicControl)
  {.Z+}
  protected {private}
    {property instance variables}
    FAlignment      : TAlignment;
    FAutoSizeHeight : Boolean;
    FAutoSizeWidth  : Boolean;
    FCaption        : string;
    FFontAngle      : Integer;
    FOriginX        : Integer;
    FOriginY        : Integer;
    FShadowColor    : TColor;       {color for text shadowing}
    FShadowedText   : Boolean;      {true to draw shadowed text}

    {property methods}
    function GetTransparent : Boolean;
    procedure SetAlignment(Value : TAlignment);
    procedure SetAutoSizeHeight(Value : Boolean);
    procedure SetAutoSizeWidth(Value : Boolean);
    procedure SetCaption(const Value : string);
    procedure SetOriginX(Value : Integer);
    procedure SetOriginY(Value : Integer);
    procedure SetShadowColor(const Value : TColor);
    procedure SetShadowedText(Value : Boolean);
    procedure SetTransparent(Value : Boolean);
    procedure SetFontAngle(Value : Integer);

    {internal methods}
    procedure lblAdjustSize;
      {-adjust horizontal and/or vertical size of control}
    procedure lblDrawText(var R : TRect; Flags : Word);
      {-draw the label text}

    {VCL message handling methods}
    procedure CMFontChanged(var Msg : TMessage);
      message CM_FONTCHANGED;

    {windows message response methods}
    procedure WMEraseBkGnd(var Msg : TWMEraseBkGnd);
      message WM_ERASEBKGND;

  protected
    procedure Loaded;
      override;
    procedure Paint;
      override;
    procedure SetName(const NewName : TComponentName);
      override;
  {.Z-}

    property Alignment : TAlignment
      read FAlignment
      write SetAlignment
      default DefAlignment;

    property AutoSizeHeight : Boolean
      read FAutoSizeHeight
      write SetAutoSizeHeight
      default DefAutoSizeHeight;

    property AutoSizeWidth : Boolean
      read FAutoSizeWidth
      write SetAutoSizeWidth
      default DefAutoSizeWidth;

    property Caption : string
      read FCaption
      write SetCaption;

    property FontAngle : Integer
      read FFontAngle
      write SetFontAngle
      default DefFontAngle;

    property OriginX : Integer
      read FOriginX
      write SetOriginX;

    property OriginY : Integer
      read FOriginY
      write SetOriginY;

    property ShadowColor : TColor
      read FShadowColor
      write SetShadowColor
      default DefShadowColor;

    property ShadowedText : Boolean
      read FShadowedText
      write SetShadowedText
      default DefShadowedText;

    property Transparent  : Boolean
      read GetTransparent
      write SetTransparent
      default DefTransparent;

  public
    constructor Create(AOwner: TComponent);
      override;

    {public properties}
    property Canvas;
  end;

  TOvcRotatedLabel = class(TOvcCustomRotatedLabel)
  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;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShadowColor;
    property ShadowedText;
    property ShowHint;
    property Transparent;
    property Visible;

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


implementation
