{********************************************}
{   TDraw3D component                        }
{ Copyright (c) 1995-2020 by Steema Software }
{        All Rights Reserved                 }
{********************************************}
unit TeeDraw3D;
{$I TeeDefs.inc}

interface

Uses {$IFNDEF LINUX}
     {$IFNDEF LCL}
     Windows,
     {$ENDIF}
     {$ENDIF}
     Classes, TeeProcs;

type
  TDraw3DPaintEvent=procedure(Sender:TObject; Const ARect:TRect) of object;

  {$IFDEF D16}
  [ComponentPlatformsAttribute(pidWin32 or pidWin64)]
  {$ENDIF}
  TDraw3D=class(TCustomTeePanelExtended)
  private
    FOnPaint : TDraw3DPaintEvent;
  protected
    IDontResetCanvas : Boolean;

    procedure DoCustomPaint(Const UserRectangle:TRect); virtual;
    Procedure InternalDraw(Const UserRectangle:TRect); override;
  published
    { TCustomTeePanelExtended properties }
    property BackImage;
    property BackImageMode;
    property Border;
    property BorderRound;
    property Emboss;
    property Gradient;
    property OnAfterDraw;

    { TCustomTeePanel properties }
    property BufferedDisplay default True;
    property MarginLeft;
    property MarginTop;
    property MarginRight;
    property MarginBottom;
    property MarginUnits;
    property Monochrome;
    property PrintProportional;
    property PrintResolution;
    property Shadow;
    property View3D;
    property View3DOptions;
    property OnPaint:TDraw3DPaintEvent read FOnPaint write FOnPaint;

    { TPanel properties }
    property Align;
    property BevelInner;
    property BevelOuter;
    property BevelWidth;

    property BorderWidth;
    property Color;
    property DragCursor;
    property DragMode;
    property Enabled;
    property ParentColor;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;
    property Anchors;
    property AutoSize;
    property Constraints;
    property DragKind;
    {$IFNDEF LCL}
    property Locked;
    {$ENDIF}

    { TPanel events }
    property OnClick;
    property OnContextPopup;
    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 OnResize;
    property OnMouseWheel;
    property OnMouseWheelDown;
    property OnMouseWheelUp;
    property OnStartDrag;
    {$IFNDEF LCL}
    property OnCanResize;
    {$ENDIF}
    property OnConstrainedResize;
    property OnDockDrop;
    property OnDockOver;
    property OnEndDock;
    property OnGetSiteInfo;
    property OnStartDock;
    property OnUnDock;

    {$IFDEF D10}
    property OnMouseEnter;
    property OnMouseLeave;
    {$ENDIF}
  end;

implementation

{ TDraw3D }

Procedure TDraw3D.InternalDraw(Const UserRectangle:TRect);
var Old : Boolean;
    tmp : TRect;
begin
  Old:=AutoRepaint;
  AutoRepaint:=False;

  tmp:=UserRectangle;

  if not InternalCanvas.SupportsFullRotation then
     PanelPaint(tmp);

  RecalcWidthHeight;
  Width3D:=100;
  InternalCanvas.Projection(Width3D,ChartBounds,ChartRect);

  if InternalCanvas.SupportsFullRotation then
  begin
    ChartRect:=tmp;
    PanelPaint(ChartRect);
  end;

  if not IDontResetCanvas then
     Canvas.ResetState;

  DoCustomPaint(UserRectangle);

  if Zoom.Active then
     DrawZoomRectangle;

  if not IDontResetCanvas then
     Canvas.ResetState;

  if Assigned(FOnAfterDraw) then
     FOnAfterDraw(Self);

  AutoRepaint:=Old;
end;

procedure TDraw3D.DoCustomPaint(Const UserRectangle:TRect);
begin
  if Assigned(FOnPaint) then
     FOnPaint(Self,UserRectangle);
end;

end.
