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

  1. {*********************************************}
  2. { TeeChart Delphi Component Library           }
  3. { Print Previewer component Demo              }
  4. { Copyright (c) 1995-1998 by David Berneda    }
  5. { All rights reserved                         }
  6. {*********************************************}
  7. unit UChaPre;
  8.  
  9. interface
  10.  
  11. uses
  12.   WinProcs,WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   Buttons, StdCtrls, ExtCtrls, TeEngine, TeeSurfa, TeeEdit, TeeProcs, Chart;
  14.  
  15. type
  16.   TChartPreviewForm = class(TForm)
  17.     Panel1: TPanel;
  18.     Memo1: TMemo;
  19.     Button1: TButton;
  20.     BShow: TBitBtn;
  21.     Chart1: TChart;
  22.     Panel2: TPanel;
  23.     ChartPreviewer1: TChartPreviewer;
  24.     Label1: TLabel;
  25.     Shape1: TShape;
  26.     Label2: TLabel;
  27.     CBWindowStyle: TComboBox;
  28.     Series1: TSurfaceSeries;
  29.     Edit1: TEdit;
  30.     Label3: TLabel;
  31.     GroupBox1: TGroupBox;
  32.     CBPrinter: TCheckBox;
  33.     CBSetup: TCheckBox;
  34.     CBResize: TCheckBox;
  35.     CBMove: TCheckBox;
  36.     CBDetail: TCheckBox;
  37.     CBOrient: TCheckBox;
  38.     CBMargins: TCheckBox;
  39.     CBPropor: TCheckBox;
  40.     CBDrag: TCheckBox;
  41.     CBPanel: TCheckBox;
  42.     CBBitmap: TCheckBox;
  43.     procedure FormCreate(Sender: TObject);
  44.     procedure Shape1MouseUp(Sender: TObject; Button: TMouseButton;
  45.       Shift: TShiftState; X, Y: Integer);
  46.     procedure Edit1Change(Sender: TObject);
  47.     procedure CBWindowStyleChange(Sender: TObject);
  48.     procedure Button1Click(Sender: TObject);
  49.     procedure BShowClick(Sender: TObject);
  50.   private
  51.     { Private declarations }
  52.   public
  53.     { Public declarations }
  54.   end;
  55.  
  56. implementation
  57.  
  58. {$R *.DFM}
  59. Uses PenDlg;
  60.  
  61. procedure TChartPreviewForm.FormCreate(Sender: TObject);
  62. begin
  63.   CBWindowStyle.ItemIndex:=0;
  64.   Shape1.Cursor:=crTeeHand;
  65.  
  66.   Series1.FillSampleValues(10);
  67. end;
  68.  
  69. procedure TChartPreviewForm.Shape1MouseUp(Sender: TObject;
  70.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  71. begin
  72.   With ChartPreviewer1 do
  73.   begin
  74.     PaperColor:=EditColor(Self,PaperColor);
  75.     Shape1.Brush.Color:=PaperColor;
  76.   end;
  77. end;
  78.  
  79. procedure TChartPreviewForm.Edit1Change(Sender: TObject);
  80. begin
  81.   ChartPreviewer1.Title:=Edit1.Text;
  82. end;
  83.  
  84. procedure TChartPreviewForm.CBWindowStyleChange(Sender: TObject);
  85. begin
  86.   Case CBWindowStyle.ItemIndex of
  87.     0: ChartPreviewer1.WindowState:=wsNormal;
  88.     1: ChartPreviewer1.WindowState:=wsMaximized;
  89.     2: ChartPreviewer1.WindowState:=wsMinimized;
  90.   end;
  91. end;
  92.  
  93. procedure TChartPreviewForm.Button1Click(Sender: TObject);
  94. begin
  95.   Close;
  96. end;
  97.  
  98. procedure TChartPreviewForm.BShowClick(Sender: TObject);
  99. begin
  100.   { Set the different Options depending on the check boxes }
  101.   With ChartPreviewer1 do
  102.   begin
  103.     Options:=[];
  104.     if CBPrinter.Checked then Options:=Options +[cpoChangePrinter];
  105.     if CBSetup.Checked then Options:=Options   +[cpoSetupPrinter];
  106.     if CBResize.Checked then Options:=Options  +[cpoResizeChart];
  107.     if CBPanel.Checked then Options:=Options   +[cpoPrintPanel];
  108.     if CBMove.Checked then Options:=Options    +[cpoMoveChart];
  109.     if CBDetail.Checked then Options:=Options  +[cpoChangeDetail];
  110.     if CBOrient.Checked then Options:=Options  +[cpoChangePaperOrientation];
  111.     if CBMargins.Checked then Options:=Options +[cpoChangeMargins];
  112.     if CBBitmap.Checked then Options:=Options  +[cpoAsBitmap];
  113.     if CBDrag.Checked then Options:=Options    +[cpoDragChart];
  114.     if CBPropor.Checked then Options:=Options  +[cpoProportional];
  115.  
  116.    { Show the Preview !! }
  117.     Execute;
  118.   end;
  119. end;
  120.  
  121. end.
  122.