home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / EXTENDED / UGRADIEN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  2.8 KB  |  109 lines

  1. {*********************************************}
  2. { TeeChart Delphi Component Library           }
  3. { Gradient Styles Demo                        }
  4. { Copyright (c) 1995-1998 by David Berneda    }
  5. { All rights reserved                         }
  6. {*********************************************}
  7. unit UGradien;
  8.  
  9. interface
  10.  
  11. uses
  12.   WinProcs,WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   Series, TeEngine, TeeProcs, Chart, StdCtrls, ExtCtrls;
  14.  
  15. type
  16.   TGradientForm = class(TForm)
  17.     Panel1: TPanel;
  18.     Memo1: TMemo;
  19.     Button1: TButton;
  20.     Chart1: TChart;
  21.     Series1: TLineSeries;
  22.     Series2: TBarSeries;
  23.     Label1: TLabel;
  24.     ComboBox1: TComboBox;
  25.     Label2: TLabel;
  26.     Shape1: TShape;
  27.     Shape2: TShape;
  28.     Label3: TLabel;
  29.     Button2: TButton;
  30.     procedure Button1Click(Sender: TObject);
  31.     procedure FormCreate(Sender: TObject);
  32.     procedure ComboBox1Change(Sender: TObject);
  33.     procedure Button2Click(Sender: TObject);
  34.     procedure Shape1MouseUp(Sender: TObject; Button: TMouseButton;
  35.       Shift: TShiftState; X, Y: Integer);
  36.     procedure Shape2MouseUp(Sender: TObject; Button: TMouseButton;
  37.       Shift: TShiftState; X, Y: Integer);
  38.   private
  39.     { Private declarations }
  40.   public
  41.     { Public declarations }
  42.   end;
  43.  
  44. implementation
  45.  
  46. {$R *.DFM}
  47.  
  48. { This unit (TeCanvas) is necessary to use the gradient constants }
  49. Uses TeCanvas,PenDlg;
  50.  
  51. procedure TGradientForm.Button1Click(Sender: TObject);
  52. begin
  53.   Close;
  54. end;
  55.  
  56. procedure TGradientForm.FormCreate(Sender: TObject);
  57. begin
  58.   Series1.FillSampleValues(30);
  59.   Series2.FillSampleValues(6);
  60.  
  61.  
  62.   { Set initial values for this demo controls }
  63.   ComboBox1.ItemIndex:=6;
  64.   Shape1.Cursor:=crTeeHand;
  65.   Shape2.Cursor:=crTeeHand;
  66.   Shape1.Brush.Color:=Chart1.Gradient.StartColor;
  67.   Shape2.Brush.Color:=Chart1.Gradient.EndColor;
  68. end;
  69.  
  70. procedure TGradientForm.ComboBox1Change(Sender: TObject);
  71. begin
  72.   { change the gradient style direction }
  73.   Chart1.Gradient.Direction:=TGradientDirection(ComboBox1.ItemIndex);
  74. end;
  75.  
  76. procedure TGradientForm.Button2Click(Sender: TObject);
  77. var tmp:TColor;
  78. begin
  79.   { exchange the Start and End colors }
  80.   With Chart1.Gradient do
  81.   begin
  82.     tmp:=StartColor;
  83.     StartColor:=EndColor;
  84.     EndColor:=tmp;
  85.   end;
  86. end;
  87.  
  88. procedure TGradientForm.Shape1MouseUp(Sender: TObject;
  89.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  90. begin
  91.   with Chart1.Gradient do
  92.   begin
  93.     StartColor:=EditColor(Self,StartColor);
  94.     Shape1.Brush.Color:=StartColor;
  95.   end;
  96. end;
  97.  
  98. procedure TGradientForm.Shape2MouseUp(Sender: TObject;
  99.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  100. begin
  101.   with Chart1.Gradient do
  102.   begin
  103.     EndColor:=EditColor(Self,EndColor);
  104.     Shape2.Brush.Color:=EndColor;
  105.   end;
  106. end;
  107.  
  108. end.
  109.