home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Src Code / TEECOMMA.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  20.3 KB  |  733 lines

  1. {**********************************************}
  2. {   TTeeCommander Component                    }
  3. {   Copyright (c) 1998 by David Berneda        }
  4. {**********************************************}
  5. {$I teedefs.inc}
  6. unit TeeComma;
  7.  
  8. interface
  9.  
  10. uses Classes, Controls, StdCtrls, Buttons, TeeProcs, ExtCtrls,
  11.      Forms, Graphics, Series, TeeEdit, Chart
  12.      {$IFDEF D1}
  13.      ,Menus, WinProcs
  14.      {$ENDIF}
  15.      ;
  16.  
  17. type
  18.   TCustomTeeCommander=class(TCustomPanel)
  19.   private
  20.     FPanel         : TCustomTeePanel;
  21.     FPanelMouseDown: TMouseEvent;
  22.     FPanelMouseMove: TMouseMoveEvent;
  23.     FPanelMouseUp  : TMouseEvent;
  24.   protected
  25.     Procedure CheckPanel;
  26.     Procedure DoMouseDown(X,Y:Integer); virtual;
  27.     Procedure DoMouseMove(X,Y:Integer); virtual;
  28.     Procedure DoMouseUp; virtual;
  29.     Function DoPanelMouse:Boolean; virtual;
  30.     procedure Loaded; override;
  31.     procedure Notification( AComponent: TComponent;
  32.                             Operation: TOperation); override;
  33.     procedure SetPanel(Const Value: TCustomTeePanel); virtual;
  34.     Function TeePanelClass:String;
  35.     Procedure ShowHideControls(Value:Boolean); virtual;
  36.   public
  37.     { Public declarations }
  38.     Constructor Create(AOwner:TComponent); override;
  39.     Destructor Destroy; override;
  40.  
  41.     Procedure CreateBevel(APos:Integer);
  42.     Function CreateBitButton( ALeft:Integer;
  43.                               AProc:TNotifyEvent; AHint:String):TBitBtn;
  44.     Function CreateButton( ALeft:Integer; AProc:TNotifyEvent;
  45.                            AHint:String):TSpeedButton;
  46.     Function CreateLabel(APos:Integer; AColor:TColor):TLabel;
  47.  
  48.     procedure PanelMouseDown(Sender: TObject; Button: TMouseButton;
  49.                           Shift: TShiftState; X, Y: Integer);
  50.     procedure PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
  51.                           Y: Integer);
  52.     procedure PanelMouseUp(Sender: TObject; Button: TMouseButton;
  53.                           Shift: TShiftState; X, Y: Integer);
  54.   published
  55.     { Published declarations }
  56.     property OnChartMouseDown:TMouseEvent read FPanelMouseDown write FPanelMouseDown;
  57.     property OnChartMouseMove:TMouseMoveEvent read FPanelMouseMove write FPanelMouseMove;
  58.     property OnChartMouseUp:TMouseEvent read FPanelMouseUp write FPanelMouseUp;
  59.     property Panel:TCustomTeePanel read FPanel write SetPanel;
  60.  
  61.     { TPanel properties }
  62.     property Align;
  63.     property BevelInner;
  64.     property BevelOuter;
  65.     property BevelWidth;
  66.     property BorderWidth;
  67.     property BorderStyle;
  68.     property Color;
  69.     property DragCursor;
  70.     property DragMode;
  71.     property Enabled;
  72.     property ParentColor;
  73.     property ParentShowHint;
  74.     property PopupMenu;
  75.     property ShowHint;
  76.     property TabOrder;
  77.     property TabStop;
  78.     property Visible;
  79.     {$IFDEF D4}
  80.     property Anchors;
  81.     property AutoSize;
  82.     property Constraints;
  83.     property DragKind;
  84.     {$ENDIF}
  85.  
  86.     { TPanel events }
  87.     property OnClick;
  88.     property OnDblClick;
  89.     property OnDragDrop;
  90.     property OnDragOver;
  91.     property OnEndDrag;
  92.     property OnEnter;
  93.     property OnExit;
  94.     property OnMouseDown;
  95.     property OnMouseMove;
  96.     property OnMouseUp;
  97.     property OnResize;
  98.     {$IFDEF D3}
  99.     property OnStartDrag;
  100.     {$ENDIF}
  101.     {$IFDEF D4}
  102.     property OnCanResize;
  103.     property OnConstrainedResize;
  104.     property OnDockDrop;
  105.     property OnDockOver;
  106.     property OnEndDock;
  107.     property OnStartDock;
  108.     property OnUnDock;
  109.     {$ENDIF}
  110.   end;
  111.  
  112. type
  113.   {$IFDEF TEE5}
  114.   TTeeCommander=class;
  115.  
  116.   TTeeEditedChartEvent=procedure(Sender:TTeeCommander; AChart:TCustomChart) of object;
  117.   {$ENDIF}
  118.  
  119.   TTeeCommander=class(TCustomTeeCommander)
  120.   private
  121.     { Private declarations }
  122.     FButtonCopy    : TBitBtn;
  123.     FButtonDepth   : TSpeedButton;
  124.     FButtonEdit    : TBitBtn;
  125.     FButtonMove    : TSpeedButton;
  126.     FButtonNormal  : TSpeedButton;
  127.     FButtonPrint   : TBitBtn;
  128.     FButtonRotate  : TSpeedButton;
  129.     FButtonZoom    : TSpeedButton;
  130.     FEditor        : TCustomChartEditor;
  131.     FLabel         : TLabel;
  132.     FLabelValues   : Boolean;
  133.  
  134.     FDragging      : Boolean;
  135.     FDraggingIndex : Integer;
  136.     FOldX          : Integer;
  137.     FOldY          : Integer;
  138.  
  139.     {$IFDEF TEE5}
  140.     FOnEditedChart : TTeeEditedChartEvent;
  141.     {$ENDIF}
  142.     procedure ButtonCopyClick(Sender: TObject);
  143.     procedure ButtonDepthClick(Sender: TObject);
  144.     procedure ButtonEditClick(Sender: TObject);
  145.     procedure ButtonMoveClick(Sender: TObject);
  146.     procedure ButtonNormalClick(Sender: TObject);
  147.     procedure ButtonPrintClick(Sender: TObject);
  148.     procedure ButtonRotateClick(Sender: TObject);
  149.     procedure ButtonZoomClick(Sender: TObject);
  150.     procedure SetLabelCaption(Const ACaption:String);
  151.     procedure SetLabelValues(Value:Boolean);
  152.     Function FirstSeriesPie:TPieSeries;
  153.   protected
  154.     { Protected declarations }
  155.     Procedure DoMouseDown(X,Y:Integer); override;
  156.     Procedure DoMouseMove(X,Y:Integer); override;
  157.     Procedure DoMouseUp; override;
  158.     Function DoPanelMouse:Boolean; override;
  159.     Procedure ShowHideControls(Value:Boolean); override;
  160.   public
  161.     { Public declarations }
  162.     Constructor Create(AOwner:TComponent); override;
  163.  
  164.     property ButtonCopy    : TBitBtn read FButtonCopy;
  165.     property ButtonDepth   : TSpeedButton read FButtonDepth;
  166.     property ButtonEdit    : TBitBtn read FButtonEdit;
  167.     property ButtonMove    : TSpeedButton read FButtonMove;
  168.     property ButtonNormal  : TSpeedButton read FButtonNormal;
  169.     property ButtonPrint   : TBitBtn read FButtonPrint;
  170.     property ButtonRotate  : TSpeedButton read FButtonRotate;
  171.     property ButtonZoom    : TSpeedButton read FButtonZoom;
  172.     property ChartEditor   : TCustomChartEditor read FEditor write FEditor;
  173.     property LabelText     : TLabel read FLabel;
  174.     Procedure ShowValues;
  175.   published
  176.     property LabelValues:Boolean read FLabelValues write SetLabelValues default True;
  177.     {$IFDEF TEE5}
  178.     property OnEditedChart:TTeeEditedChartEvent read FOnEditedChart
  179.                                                 write FOnEditedChart;
  180.     {$ENDIF}
  181.   end;
  182.  
  183.   TTeeCommanderChain=Procedure(Sender:TCustomTeeCommander);
  184.  
  185. Const TeeCommanderChain:TTeeCommanderChain=nil;
  186.  
  187. implementation
  188.  
  189. {$IFDEF D1}
  190. {$R TEECOMMA.R16}
  191. {$ELSE}
  192. {$R TEECOMMA.RES}
  193. {$ENDIF}
  194.  
  195. Uses Teengine,TeCanvas,SysUtils,EditChar,TeePrevi,TeeProCo;
  196.  
  197. { TCustomTeeCommander }
  198. Constructor TCustomTeeCommander.Create(AOwner:TComponent);
  199. begin
  200.   inherited Create(AOwner);
  201.   ControlStyle:=ControlStyle-[csSetCaption];
  202.   SetPanel(nil);
  203.   Height:=33;
  204.   Width:=400;
  205.   if (csDesigning in ComponentState) and
  206.      (not (csLoading in Owner.ComponentState)) then Align:=alTop;
  207. end;
  208.  
  209. procedure TCustomTeeCommander.Notification(AComponent: TComponent;
  210.   Operation: TOperation);
  211. begin
  212.   inherited Notification(AComponent, Operation);
  213.   if Operation=opRemove then
  214.      if Assigned(FPanel) and (AComponent=FPanel) then
  215.         Panel:=nil;
  216. end;
  217.  
  218. procedure TCustomTeeCommander.PanelMouseDown(Sender: TObject; Button: TMouseButton;
  219.   Shift: TShiftState; X, Y: Integer);
  220. begin
  221.   DoMouseDown(X,Y);
  222.   if Assigned(FPanelMouseDown) and DoPanelMouse then
  223.      FPanelMouseDown(Sender,Button,Shift,X,Y);
  224. end;
  225.  
  226. procedure TCustomTeeCommander.PanelMouseUp(Sender: TObject; Button: TMouseButton;
  227.   Shift: TShiftState; X, Y: Integer);
  228. begin
  229.   DoMouseUp;
  230.   if Assigned(FPanelMouseUp)  and DoPanelMouse then
  231.      FPanelMouseUp(Sender,Button,Shift,X,Y);
  232. end;
  233.  
  234. procedure TCustomTeeCommander.PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
  235.   Y: Integer);
  236. begin
  237.   DoMouseMove(X,Y);
  238.   if Assigned(FPanelMouseMove)  and DoPanelMouse then
  239.      FPanelMouseMove(Sender,Shift,X,Y);
  240. end;
  241.  
  242. Procedure TCustomTeeCommander.DoMouseDown(X,Y:Integer);
  243. begin
  244. end;
  245.  
  246. Procedure TCustomTeeCommander.DoMouseMove(X,Y:Integer);
  247. begin
  248. end;
  249.  
  250. Procedure TCustomTeeCommander.DoMouseUp;
  251. begin
  252. end;
  253.  
  254. Procedure TCustomTeeCommander.ShowHideControls(Value:Boolean);
  255. Var t:Integer;
  256. begin
  257.   if not( csDestroying in ComponentState) then
  258.      for t:=0 to ControlCount-1 do
  259.          if Controls[t].Owner=Self then Controls[t].Enabled:=Value;
  260. end;
  261.  
  262. Procedure TCustomTeeCommander.CheckPanel;
  263. begin
  264.   if Assigned(FPanel) then
  265.   begin
  266.     if FPanel is TDraw3D then
  267.     With TDraw3D(FPanel) do
  268.     begin
  269.       OnMouseDown :=PanelMouseDown;
  270.       OnMouseMove :=PanelMouseMove;
  271.       OnMouseUp   :=PanelMouseUp;
  272.     end
  273.     else
  274.     if FPanel is TCustomChart then
  275.     With TCustomChart(FPanel) do
  276.     begin
  277.       OnMouseDown :=PanelMouseDown;
  278.       OnMouseMove :=PanelMouseMove;
  279.       OnMouseUp   :=PanelMouseUp;
  280.     end
  281.     else
  282.     if FPanel is TCustomTeePanel then
  283.     With TCustomTeePanel(FPanel) do
  284.     begin
  285.       TCustomTeePanel(FPanel).OnMouseDown :=PanelMouseDown;
  286.       OnMouseMove :=PanelMouseMove;
  287.       OnMouseUp   :=PanelMouseUp;
  288.     end;
  289.   end;
  290.   ShowHideControls(Assigned(FPanel));
  291. end;
  292.  
  293. procedure TCustomTeeCommander.Loaded;
  294. begin
  295.   inherited Loaded;
  296.   CheckPanel;
  297.   if Assigned(TeeCommanderChain) then TeeCommanderChain(Self);
  298. end;
  299.  
  300. procedure TCustomTeeCommander.SetPanel(const Value: TCustomTeePanel);
  301. begin
  302.   FPanel := Value;
  303.   CheckPanel;
  304. end;
  305.  
  306. Function TCustomTeeCommander.CreateButton( ALeft:Integer;
  307.                                            AProc:TNotifyEvent;
  308.                                            AHint:String):TSpeedButton;
  309. {$IFDEF D1}
  310. Var tmpSt:Array[0..255] of Char;
  311. {$ENDIF}
  312. begin
  313.   result:=TSpeedButton.Create(Self);
  314.   With result do
  315.   begin
  316.     OnClick:=AProc;
  317.     Left := ALeft;
  318.     Top := 4;
  319.     Width := 25;
  320.     Height := 25;
  321.     Hint := AHint;
  322.     Down := True;
  323.     {$IFDEF D3}
  324.     Flat := True;
  325.     {$ENDIF}
  326.     ParentShowHint := False;
  327.     ShowHint := True;
  328.     {$IFDEF D1}
  329.     Glyph.Handle:=LoadBitmap(Hinstance,StrPCopy(tmpSt,'Tee'+AHint));
  330.     {$ELSE}
  331.     Glyph.LoadFromResourceName(HInstance,'Tee'+AHint);
  332.     {$ENDIF}
  333.     Parent:=Self;
  334.     GroupIndex := 1;
  335.   end;
  336. end;
  337.  
  338. Function TCustomTeeCommander.DoPanelMouse:Boolean;
  339. begin
  340.   result:=True;
  341. end;
  342.  
  343. Function TCustomTeeCommander.CreateBitButton(ALeft:Integer; AProc:TNotifyEvent; AHint:String):TBitBtn;
  344. {$IFDEF D1}
  345. Var tmpSt:Array[0..255] of Char;
  346. {$ENDIF}
  347. begin
  348.   result:=TBitBtn.Create(Self);
  349.   With result do
  350.   begin
  351.     OnClick:=AProc;
  352.     Left := ALeft;
  353.     TabStop:=False;
  354.     Top := 3;
  355.     Width := 27;
  356.     Height := 27;
  357.     Hint := AHint;
  358.     Caption:='';
  359.     ParentShowHint := False;
  360.     ShowHint := True;
  361.     {$IFDEF D1}
  362.     Glyph.Handle:=LoadBitmap(Hinstance,StrPCopy(tmpSt,'Tee'+AHint));
  363.     {$ELSE}
  364.     Glyph.LoadFromResourceName(HInstance,'Tee'+AHint);
  365.     {$ENDIF}
  366.     Parent:=Self;
  367.   end;
  368. end;
  369.  
  370. Procedure TCustomTeeCommander.CreateBevel(APos:Integer);
  371. begin
  372.   With TBevel.Create(Self) do
  373.   begin
  374.     Shape:=bsLeftLine;
  375.     Width:=2;
  376.     Height:=Self.Height-2;
  377.     Top:=1;
  378.     Left:=APos;
  379.     Parent:=Self;
  380.   end;
  381. end;
  382.  
  383. Function TCustomTeeCommander.CreateLabel(APos:Integer; AColor:TColor):TLabel;
  384. begin
  385.   result:=TLabel.Create(Self);
  386.   With result do
  387.   begin
  388.     Left:=APos;
  389.     Top:=12;
  390.     Font.Name:=GetDefaultFontName;
  391.     Font.Color:=AColor;
  392.     Font.Size:=GetDefaultFontSize;
  393.     Caption:='';
  394.     Parent:=Self;
  395.   end;
  396. end;
  397.  
  398. Function TCustomTeeCommander.TeePanelClass:String;
  399. begin
  400.   if FPanel is TCustomAxisPanel then result:=TeeCommanMsg_Chart
  401.                                 else result:=TeeCommanMsg_Panel;
  402. end;
  403.  
  404. Destructor TCustomTeeCommander.Destroy;
  405. var Num : Integer;
  406.     tmp : Integer;
  407.     t   : Integer;
  408. begin
  409.   Repeat
  410.     Num:=0;
  411.     tmp:=-1;
  412.     for t:=0 to ControlCount-1 do
  413.     if Controls[t].Owner=Self then
  414.     begin
  415.       Inc(Num);
  416.       tmp:=t;
  417.     end;
  418.     if tmp<>-1 then Controls[tmp].Free;
  419.   Until Num=0;
  420.   inherited Destroy;
  421. end;
  422.  
  423. { TTeeCommander }
  424. Constructor TTeeCommander.Create(AOwner:TComponent);
  425. begin
  426.   inherited Create(AOwner);
  427.   FEditor:=nil;
  428.   FDragging:=False;
  429.   FLabelValues:=True;
  430.  
  431.   FButtonNormal := CreateButton(  4,ButtonNormalClick,TeeCommanMsg_Normal);
  432.   CreateBevel(32);
  433.   FButtonRotate := CreateButton( 36,ButtonRotateClick,TeeCommanMsg_Rotate);
  434.   FButtonMove   := CreateButton( 61,ButtonMoveClick,TeeCommanMsg_Move);
  435.   FButtonZoom   := CreateButton( 86,ButtonZoomClick,TeeCommanMsg_Zoom);
  436.   FButtonDepth  := CreateButton(111,ButtonDepthClick,TeeCommanMsg_Depth);
  437.   CreateBevel(137);
  438.   FButtonEdit   := CreateBitButton(142,ButtonEditClick,TeeCommanMsg_Edit);
  439.   FButtonPrint  := CreateBitButton(172,ButtonPrintClick,TeeCommanMsg_Print);
  440.   FButtonCopy   := CreateBitButton(202,ButtonCopyClick,TeeCommanMsg_Copy);
  441.   FLabel        := CreateLabel(234,clNavy);
  442.  
  443.   FButtonNormal.Down:=True;
  444. end;
  445.  
  446. Procedure TTeeCommander.DoMouseDown(X,Y:Integer);
  447. var tmpSeries:TPieSeries;
  448. begin
  449.   tmpSeries:=FirstSeriesPie;
  450.   if Assigned(tmpSeries) or (not FButtonNormal.Down) then
  451.   begin
  452.     FDragging:=True;
  453.     FOldX:=X;
  454.     FOldY:=Y;
  455.     if Assigned(tmpSeries) then FDraggingIndex:=tmpSeries.Clicked(X,Y)
  456.                            else FDraggingIndex:=-1;
  457.     if FPanel is TCustomAxisPanel then
  458.        TCustomAxisPanel(FPanel).CancelMouse:=True;
  459.   end;
  460. end;
  461.  
  462. Function TTeeCommander.DoPanelMouse:Boolean;
  463. begin
  464.   result:=FButtonNormal.Down;
  465. end;
  466.  
  467. Procedure TTeeCommander.DoMouseUp;
  468. begin
  469.   FDragging:=False;
  470.   FDraggingIndex:=-1;
  471. end;
  472.  
  473. Function TTeeCommander.FirstSeriesPie:TPieSeries;
  474. var t:Integer;
  475. begin
  476.   result:=nil;
  477.   if FPanel is TCustomChart then
  478.   With TCustomChart(FPanel) do
  479.   begin
  480.     for t:=0 to SeriesCount-1 do
  481.     if (Series[t] is TPieSeries) and (Series[t].Active) then
  482.     begin
  483.       result:=Series[t] as TPieSeries;
  484.       exit;
  485.     end;
  486.   end;
  487. end;
  488.  
  489. Procedure TTeeCommander.DoMouseMove(X,Y:Integer);
  490.  
  491.     Procedure DoRotate;
  492.  
  493.       Function CorrectAngle(Const AAngle:Integer):Integer;
  494.       begin
  495.         result:=AAngle;
  496.         if result>360 then result:=result-360 else
  497.         if result<0 then result:=360+result;
  498.       end;
  499.  
  500.     Var tmpMinAngle : Integer;
  501.         tmp         : Integer;
  502.         tmpSeries   : TPieSeries;
  503.     begin
  504.       With FPanel,View3DOptions do
  505.       begin
  506.         View3D:=True;
  507.         Orthogonal:=False;
  508.         tmp:=Round(90.0*(X-FOldX)/Width);
  509.         tmpSeries:=FirstSeriesPie;
  510.         if Canvas.SupportsFullRotation then Rotation:=CorrectAngle(Rotation+tmp)
  511.         else
  512.         if Assigned(tmpSeries) then
  513.         begin
  514.           Rotation:=360;
  515.           if tmp<>0 then
  516.           With tmpSeries do RotationAngle:=CorrectAngle(RotationAngle+tmp);
  517.         end
  518.         else
  519.           if tmp>0 then Rotation:=MinLong(360,Rotation+tmp)
  520.                    else
  521.                    begin
  522.                      if Canvas.SupportsFullRotation then
  523.                         tmpMinAngle:=0
  524.                      else
  525.                         tmpMinAngle:=270;
  526.                      Rotation:=MaxLong(tmpMinAngle,Rotation+tmp);
  527.                    end;
  528.         tmp:=Round(90.0*(FOldY-Y)/Height);
  529.         if Assigned(tmpSeries) then tmp:=-tmp;
  530.         if Canvas.SupportsFullRotation then Elevation:=CorrectAngle(Elevation+tmp)
  531.         else
  532.         if tmp>0 then Elevation:=MinLong(360,Elevation+tmp)
  533.                  else
  534.                  begin
  535.                    if Canvas.SupportsFullRotation then
  536.                       tmpMinAngle:=0
  537.                    else
  538.                       tmpMinAngle:=270;
  539.                    Elevation:=MaxLong(tmpMinAngle,Elevation+tmp);
  540.                  end;
  541.         FOldX:=X;
  542.         FOldY:=Y;
  543.       end;
  544.     end;
  545.  
  546.     Procedure DoMove;
  547.     begin
  548.       FPanel.View3D:=True;
  549.       With FPanel.View3DOptions do
  550.       begin
  551.         HorizOffset:=HorizOffset+(X-FOldX);
  552.         VertOffset:=VertOffset+(Y-FOldY);
  553.       end;
  554.       FOldX:=X;
  555.       FOldY:=Y;
  556.     end;
  557.  
  558.     Procedure DoZoom;
  559.     var tmp : Integer;
  560.     begin
  561.       With FPanel,View3DOptions do
  562.       begin
  563.         View3D:=True;
  564.         tmp:=Round(10.0*(FOldY-Y)/ChartHeight);
  565.         Zoom:=Zoom+tmp;
  566.         if Zoom<5 then Zoom:=5;
  567.       end;
  568.     end;
  569.  
  570.     Function CalcDistPercent(APercent,AWidth,AHeight:Integer):Integer;
  571.     Var Dist      : Longint;
  572.         ChartDiag : Longint;
  573.     begin
  574.       Dist:=Round(Sqrt(Sqr(1.0*FOldX-X)+Sqr(1.0*FOldY-Y)));
  575.       ChartDiag:=Round(Sqrt(Sqr(1.0*AWidth)+Sqr(1.0*AHeight)));
  576.       result:=Round(1.0*APercent*Dist/ChartDiag);
  577.     end;
  578.  
  579.     Procedure DoDepth;
  580.     var tmp : Longint;
  581.     begin
  582.       if FPanel is TCustomAxisPanel then
  583.       With TCustomAxisPanel(FPanel) do
  584.       begin
  585.         View3D:=True;
  586.         tmp:=CalcDistPercent(200,ChartWidth,ChartHeight);
  587.         if (tmp>=1) then Chart3DPercent:=MinLong(100,tmp);
  588.       end;
  589.     end;
  590.  
  591.     Procedure DoNormal;
  592.     Var tmpSeries : TPieSeries;
  593.         tmp       : Integer;
  594.     begin
  595.       if FDraggingIndex<>-1 then
  596.       begin
  597.         tmpSeries:=FirstSeriesPie;
  598.         if Assigned(tmpSeries) then
  599.         With tmpSeries do
  600.         begin
  601.           tmp:=MinLong(100,CalcDistPercent(100,CircleWidth,CircleHeight));
  602.           ExplodedSlice.Value[FDraggingIndex]:= tmp;
  603.         end;
  604.       end;
  605.     end;
  606.  
  607. begin
  608.   if FDragging then
  609.   begin
  610.     FDragging:=False;
  611.     if FButtonRotate.Down then DoRotate else
  612.     if FButtonMove.Down then DoMove else
  613.     if FButtonZoom.Down then DoZoom else
  614.     if FButtonDepth.Down then DoDepth else
  615.     if FButtonNormal.Down then DoNormal;
  616.     if FLabelValues then ShowValues;
  617.     FDragging:=True;
  618.   end;
  619. end;
  620.  
  621. procedure TTeeCommander.SetLabelCaption(Const ACaption:String);
  622. begin
  623.   if FLabelValues then
  624.      FLabel.Caption:=Format(ACaption,[TeePanelClass])
  625.   else
  626.      FLabel.Visible:=False;
  627. end;
  628.  
  629. procedure TTeeCommander.ButtonRotateClick(Sender: TObject);
  630. begin
  631.   SetLabelCaption(TeeCommanMsg_RotateLabel);
  632. end;
  633.  
  634. procedure TTeeCommander.ButtonMoveClick(Sender: TObject);
  635. begin
  636.   SetLabelCaption(TeeCommanMsg_MoveLabel);
  637. end;
  638.  
  639. procedure TTeeCommander.ButtonZoomClick(Sender: TObject);
  640. begin
  641.   SetLabelCaption(TeeCommanMsg_ZoomLabel);
  642. end;
  643.  
  644. procedure TTeeCommander.ButtonDepthClick(Sender: TObject);
  645. begin
  646.   SetLabelCaption(TeeCommanMsg_DepthLabel);
  647. end;
  648.  
  649. procedure TTeeCommander.ButtonEditClick(Sender: TObject);
  650. begin
  651.   if Assigned(FEditor) then FEditor.Execute
  652.   else
  653.   if Assigned(FPanel) and (FPanel is TCustomChart) then
  654.      EditChart(nil,FPanel as TCustomChart);
  655.   {$IFDEF TEE5}
  656.   if Assigned(FOnEditedChart) then FOnEditedChart(Self,FPanel as TCustomChart);
  657.   {$ENDIF}
  658. end;
  659.  
  660. procedure TTeeCommander.ButtonPrintClick(Sender: TObject);
  661. begin
  662.   if Assigned(FPanel) then ChartPreview(nil,FPanel);
  663. end;
  664.  
  665. procedure TTeeCommander.ButtonCopyClick(Sender: TObject);
  666. begin
  667.   if Assigned(FPanel) then FPanel.CopyToClipboardBitmap;
  668. end;
  669.  
  670. procedure TTeeCommander.ButtonNormalClick(Sender: TObject);
  671. begin
  672.   if FirstSeriesPie=nil then SetLabelCaption(TeeCommanMsg_NormalLabel)
  673.                         else SetLabelCaption(TeeCommanMsg_NormalPieLabel)
  674. end;
  675.  
  676. Procedure TTeeCommander.ShowHideControls(Value:Boolean);
  677. begin
  678.   if not Assigned(FButtonRotate) then Exit;
  679.   FButtonRotate.Enabled:=Value;
  680.   FButtonMove.Enabled:=Value;
  681.   FButtonZoom.Enabled:=Value;
  682.   FButtonNormal.Enabled:=Value;
  683.   FButtonCopy.Enabled:=Value;
  684.   FButtonPrint.Enabled:=Value;
  685.   Value:=Value and (FPanel is TCustomAxisPanel);
  686.   FButtonDepth.Enabled:=Value;
  687.   FButtonEdit.Enabled:=Value;
  688. end;
  689.  
  690. procedure TTeeCommander.SetLabelValues(Value:Boolean);
  691. begin
  692.   if FLabelValues<>Value then
  693.   begin
  694.     FLabelValues:=Value;
  695.     FLabel.Visible:=FLabelValues;
  696.   end;
  697. end;
  698.  
  699. Procedure TTeeCommander.ShowValues;
  700. var tmpSeries:TPieSeries;
  701. begin
  702.   With FPanel.View3DOptions do
  703.   if FButtonRotate.Down then
  704.      FLabel.Caption:=Format(TeeCommanMsg_Rotating,[Rotation,Elevation])
  705.   else
  706.   if FButtonMove.Down then
  707.      FLabel.Caption:=Format(TeeCommanMsg_Moving,[HorizOffset,VertOffset])
  708.   else
  709.   if FButtonZoom.Down then
  710.      FLabel.Caption:=Format(TeeCommanMsg_Zooming,[Zoom])
  711.   else
  712.   if FButtonDepth.Down then
  713.   begin
  714.     if FPanel is TCustomAxisPanel then
  715.     With TCustomAxisPanel(FPanel) do
  716.       FLabel.Caption:=Format(TeeCommanMsg_Depthing,[Chart3DPercent])
  717.   end
  718.   else
  719.   if FButtonNormal.Down and (FDraggingIndex<>-1) then
  720.   begin
  721.     tmpSeries:=FirstSeriesPie;
  722.     if tmpSeries=nil then
  723.        FLabel.Caption:=''
  724.     else
  725.        FLabel.Caption:=Format( TeeCommanMsg_PieExploding,
  726.                                [FDraggingIndex,tmpSeries.ExplodedSlice.Value[FDraggingIndex]]);
  727.   end
  728.   else FLabel.Caption:='';
  729.   FLabel.Update;
  730. end;
  731.  
  732. end.
  733.