home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / TeeChartPro / TeeChart5Delphi5Eval.exe / %MAINDIR% / Examples / Features / Tool_DragPoint.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-10  |  2.5 KB  |  104 lines

  1. unit Tool_DragPoint;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, Base, ExtCtrls, Grids, TeeChartGrid, TeeProcs, TeEngine, Chart,
  8.   StdCtrls, TeeDragPoint, Series;
  9.  
  10. type
  11.   TDragPointToolDemo = class(TBaseForm)
  12.     ChartGrid1: TChartGrid;
  13.     Button1: TButton;
  14.     CheckBox1: TCheckBox;
  15.     Label1: TLabel;
  16.     ComboBox1: TComboBox;
  17.     Series1: TLineSeries;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure ComboBox1Change(Sender: TObject);
  20.     procedure CheckBox1Click(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure FormShow(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.     DragPoint : TDragPointTool;
  26.     procedure DragPointEvent(Sender:TDragPointTool; Index:Integer);
  27.   public
  28.     { Public declarations }
  29.   end;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. Uses EditChar;
  36.  
  37. procedure TDragPointToolDemo.Button1Click(Sender: TObject);
  38. begin
  39.   EditChartTool(Self,DragPoint);
  40. end;
  41.  
  42. procedure TDragPointToolDemo.ComboBox1Change(Sender: TObject);
  43. begin
  44.   { set the allowed dragging direction... }
  45.   Case ComboBox1.ItemIndex of
  46.     0: DragPoint.DragStyle:=dsX;
  47.     1: DragPoint.DragStyle:=dsY;
  48.   else
  49.     DragPoint.DragStyle:=dsBoth;
  50.   end;
  51. end;
  52.  
  53. procedure TDragPointToolDemo.CheckBox1Click(Sender: TObject);
  54. begin
  55.   DragPoint.Active:=CheckBox1.Checked;
  56.  
  57.   { change the series cursor: }
  58.   if DragPoint.Active then Series1.Cursor:=crTeeHand
  59.                       else Series1.Cursor:=crDefault;
  60. end;
  61.  
  62. procedure TDragPointToolDemo.FormCreate(Sender: TObject);
  63. begin
  64.   inherited;
  65.   Series1.FillSampleValues(20);
  66.  
  67.   { create the tool... }
  68.   DragPoint:=TDragPointTool.Create(Self);
  69.   DragPoint.ParentChart:=Chart1;
  70.   DragPoint.Series:=Series1;
  71.  
  72.   { set the event... }
  73.   DragPoint.OnDragPoint:=DragPointEvent;
  74.  
  75.   { set the grid series: }
  76.   ChartGrid1.Series:=Series1;
  77.  
  78.   { tell the grid to show both the X and Y }
  79.   ChartGrid1.ShowXValues:=cgsYes;
  80.  
  81.   { do not show labels at chart grid }
  82.   ChartGrid1.ShowLabels:=False;
  83.  
  84.   { set the Series cursor: }
  85.   Series1.Cursor:=crTeeHand;
  86. end;
  87.  
  88. { this event gets called whenever a point is dragged... }
  89. procedure TDragPointToolDemo.DragPointEvent(Sender:TDragPointTool; Index:Integer);
  90. begin
  91.   ChartGrid1.Repaint;  { repaint the grid to show the new values... }
  92. end;
  93.  
  94. procedure TDragPointToolDemo.FormShow(Sender: TObject);
  95. begin
  96.   inherited;
  97.   { allow dragging in both X and Y directions }
  98.   ComboBox1.ItemIndex:=2;
  99. end;
  100.  
  101. initialization
  102.   RegisterClass(TDragPointToolDemo);
  103. end.
  104.