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

  1. {**********************************************}
  2. {  TCustomChart (or derived) Editor Dialog     }
  3. {  Copyright (c) 1996-98 by David Berneda      }
  4. {**********************************************}
  5. {$I teedefs.inc}
  6. unit IEdiSeri;
  7.  
  8. interface
  9.  
  10. uses
  11.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12.   StdCtrls, ExtCtrls, ComCtrls, Teengine;
  13.  
  14. type
  15.   TTeeDataSourceStyle=( dsStyle_NoData ,
  16.                         dsStyle_Random ,
  17.                         dsStyle_Function,
  18.                         dsStyle_Dataset,
  19.                         dsStyle_DataSource  );
  20.  
  21.   {$IFNDEF D1}
  22.   { special case for TFormDesigner in Charteg unit }
  23.   TAddComponentDataSource=Procedure( Const AComponent:TComponent;
  24.                                      AItems:TStrings;
  25.                                      AddCurrent:Boolean) of object;
  26.  
  27.   { special case for TFormDesigner in Charteg unit }
  28.   TOnGetDesignerNamesEvent=Procedure( AProc:TAddComponentDataSource;
  29.                                       ASeries:TChartSeries;
  30.                                       AItems:TStrings;
  31.                                       AddCurrent:Boolean );
  32.   {$ENDIF}
  33.  
  34.   TFormTeeSeries=class;
  35.  
  36.   TOnChartFillFields=Procedure(AForm:TFormTeeSeries);
  37.   TOnChartGetSourceStyle=Function(ASeries:TChartSeries):TTeeDataSourceStyle;
  38.   TOnChartIsDateTimeSource=Procedure( AComponent:TComponent;
  39.                                       Const ValueSource:String;
  40.                                       Var IsDateTime:Boolean);
  41.  
  42.   TOnChartIsValidComponentSource=Function( AComponent:TComponent;
  43.                                            DataSourceStyle:TTeeDataSourceStyle):Boolean;
  44.  
  45.   TFormTeeSeries = class(TForm)
  46.     CBSeries: TComboBox;
  47.     ImageSeries: TImage;
  48.     CBPersistent: TCheckBox;
  49.     PageSeries: TPageControl;
  50.     TheTabSheet: TTabSheet;
  51.     TabGeneral: TTabSheet;
  52.     GB5: TGroupBox;
  53.     L27: TLabel;
  54.     CBShowInLegend: TCheckBox;
  55.     CBSeriesCursor: TComboBox;
  56.     GB2: TGroupBox;
  57.     L15: TLabel;
  58.     L21: TLabel;
  59.     EValueformat: TEdit;
  60.     EPercentFormat: TEdit;
  61.     RGHorizAxis: TRadioGroup;
  62.     RGVertAxis: TRadioGroup;
  63.     CBXDateTime: TCheckBox;
  64.     CBYDateTime: TCheckBox;
  65.     TabMarks: TTabSheet;
  66.     CBMarksVisible: TCheckBox;
  67.     GB3: TGroupBox;
  68.     L32: TLabel;
  69.     SEArrowLength: TEdit;
  70.     BMarkLinCol: TButton;
  71.     RGMarkStyle: TRadioGroup;
  72.     GB11: TGroupBox;
  73.     BMarksBackColor: TButton;
  74.     CBTransparent: TCheckBox;
  75.     BMarkFont: TButton;
  76.     BMarksFrame: TButton;
  77.     CBMarkClip: TCheckBox;
  78.     TabDataSource: TTabSheet;
  79.     CBDataSourcestyle: TComboBox;
  80.     PCData: TPageControl;
  81.     TabDatabase: TTabSheet;
  82.     L16: TLabel;
  83.     CBListDataSets: TComboBox;
  84.     TabFunctions: TTabSheet;
  85.     L34: TLabel;
  86.     CBFunctions: TComboBox;
  87.     GB9: TGroupBox;
  88.     L22: TLabel;
  89.     L24: TLabel;
  90.     LBAvailSeries: TListBox;
  91.     LBSelectedSeries: TListBox;
  92.     BRightOne: TButton;
  93.     BRightAll: TButton;
  94.     BLeftOne: TButton;
  95.     BLeftAll: TButton;
  96.     BEditFunc: TButton;
  97.     LabelSeriesClass: TLabel;
  98.     PCDataStyle: TPageControl;
  99.     TBDataSet: TTabSheet;
  100.     TBDataSource: TTabSheet;
  101.     GroupFields: TScrollBox;
  102.     LabelLabels: TLabel;
  103.     CBLabelsField: TComboBox;
  104.     Label1: TLabel;
  105.     Label2: TLabel;
  106.     LBAvailFields: TListBox;
  107.     LBSelFields: TListBox;
  108.     BROneDS: TButton;
  109.     BRAllDS: TButton;
  110.     BLOneDS: TButton;
  111.     BLAllDS: TButton;
  112.     procedure RGHorizAxisClick(Sender: TObject);
  113.     procedure BMarksBackColorClick(Sender: TObject);
  114.     procedure EValueformatChange(Sender: TObject);
  115.     procedure EPercentFormatChange(Sender: TObject);
  116.     procedure PageSeriesChange(Sender: TObject);
  117.     procedure CBSeriesChange(Sender: TObject);
  118.     procedure FormCreate(Sender: TObject);
  119.     procedure RGMarkStyleClick(Sender: TObject);
  120.     procedure BEditFuncClick(Sender: TObject);
  121.     procedure CBPersistentClick(Sender: TObject);
  122.     procedure CBYDateTimeClick(Sender: TObject);
  123.     procedure CBXDateTimeClick(Sender: TObject);
  124.     procedure CBDataSourcestyleChange(Sender: TObject);
  125.     procedure CBFunctionsChange(Sender: TObject);
  126.     procedure LBSelectedSeriesDblClick(Sender: TObject);
  127.     procedure LBAvailSeriesDblClick(Sender: TObject);
  128.     procedure BLeftAllClick(Sender: TObject);
  129.     procedure BRightAllClick(Sender: TObject);
  130.     procedure BLeftOneClick(Sender: TObject);
  131.     procedure BRightOneClick(Sender: TObject);
  132.     procedure CBLabelsFieldChange(Sender: TObject);
  133.     procedure CBListDataSetsChange(Sender: TObject);
  134.     procedure CBShowInLegendClick(Sender: TObject);
  135.     procedure RGVertAxisClick(Sender: TObject);
  136.     procedure CBSeriesCursorChange(Sender: TObject);
  137.     procedure BMarkLinColClick(Sender: TObject);
  138.     procedure BMarksFrameClick(Sender: TObject);
  139.     procedure BMarkFontClick(Sender: TObject);
  140.     procedure SEArrowLengthChange(Sender: TObject);
  141.     procedure CBMarkClipClick(Sender: TObject);
  142.     procedure CBTransparentClick(Sender: TObject);
  143.     procedure CBMarksVisibleClick(Sender: TObject);
  144.     procedure PageSeriesChanging(Sender: TObject;
  145.       var AllowChange: Boolean);
  146.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  147.     procedure FormDestroy(Sender: TObject);
  148.     procedure FormShow(Sender: TObject);
  149.   private
  150.     { Private declarations }
  151.     TheSeriesForms       : Array[1..4] of TForm;
  152.     NumSeriesForms       : Integer;
  153.     ApplyChangesFunction : Boolean;
  154.     ApplyChangesDataSet  : Boolean;
  155.     CreatingForm         : Boolean;
  156.     FromList             : TListBox;
  157.     ToList               : TListBox;
  158.     Procedure AddSeriesForm(AForm:TForm; ATab:TTabSheet; ATag:Longint);
  159.     Procedure AddComponentDataSource( Const AComponent:TComponent;
  160.                                       AItems:TStrings;
  161.                                       AddCurrent:Boolean);
  162.     procedure CBValuesChange(Sender: TObject);
  163.     procedure CBDateTimeClick(Sender: TObject);
  164.     Procedure ChangeApply;
  165.     procedure CheckApplyChanges;
  166.     procedure DestroySeriesForms;
  167.     Function DataSourceStyle:TTeeDataSourceStyle;
  168.     procedure EnableDataSourceControls(IsDatabase,IsFunction:Boolean);
  169.     procedure EnableListButtons;
  170.     Procedure FillFields;  { virtual }
  171.     procedure FillSourceSeries;
  172.     Procedure FillSources(AItems:TStrings; AddCurrent:Boolean);
  173.     Procedure IsDateTimeSource( AComponent:TComponent;
  174.                                 Const ValueSource:String;
  175.                                 Var IsDateTime:Boolean);
  176.     Function IsValidComponentSource(AComponent:TComponent):Boolean;
  177.     procedure ProcGetCursors(const S: string);
  178.     procedure SetCurrentDataSource;
  179.     procedure SetSelectedSourceDatabase;
  180.     procedure SetSelectedSourceSeries;
  181.     procedure SetTabSeriesDataSource;
  182.     procedure SetTabSeriesFunctions;
  183.     Procedure SetTextItemIndex(Combo:TComboBox);
  184.   public
  185.     { Public declarations }
  186.     TheSeries:TChartSeries;
  187.     IsDssGraph:Boolean;
  188.     ShowTabDataSource:Boolean;
  189.     ShowTabGeneral:Boolean;
  190.     ShowTabMarks:Boolean;
  191.     OnGetDesignerNames:TOnGetDesignerNamesEvent;
  192.     OnChartFillFields:TOnChartFillFields;
  193.     OnChartGetSourceStyle:TOnChartGetSourceStyle;
  194.     OnChartIsDateTimeSource:TOnChartIsDateTimeSource;
  195.     OnChartIsValidComponentSource:TOnChartIsValidComponentSource;
  196.     Function GetSourceCombo(Index:Integer):TComboBox;
  197.     Function GetSelectedSource:TComponent;
  198.     Procedure SetCBSeries;
  199.     Function InsertSeriesForm( EditorClass:TFormClass;
  200.                                Position:Integer;
  201.                                Const EditorTabName:String;
  202.                                AnObject:TPersistent):TForm;
  203.     { For ax }
  204.     procedure DoApplyChangesDataset;
  205.     procedure DoApplyChangesFunction;
  206.     procedure FillSourceDatasets;
  207.   end;
  208.  
  209. implementation
  210.  
  211. {$R *.DFM}
  212. Uses TeeConst,Chart,PenDlg,TeeProcs,TeCanvas,TeeGally,TeeLisB,BrushDlg,
  213.      IEdiPeri, Series {<-because TPointSeries editor trick} ;
  214.  
  215. Const MaxValueSources=16;
  216.  
  217. type
  218.   TChartEditSource=class
  219.   public
  220.     SelectedValueSource:String;
  221.     CBValues:TComboBox;
  222.     LabelValues:TLabel;
  223.     CBDateTime:TCheckBox;
  224.     Destructor Destroy; override;
  225.   end;
  226.  
  227.   TChartEditSources=class
  228.   public
  229.     ParentForm:TForm;
  230.     SelectedDataSource:TComponent;
  231.     TheSeries:TChartSeries;
  232.     SelectedXLabelsSource:String;
  233.     Values:Array[0..MaxValueSources-1] of TChartEditSource;
  234.     Constructor Create(AParent:TForm; ASeries:TChartSeries);
  235.     Destructor Destroy; override;
  236.     procedure ClearValueSources;
  237.     procedure SetSeries(TheSeries:TChartSeries);
  238.     procedure ClearCombos(EnableCombos:Boolean);
  239.     procedure SetSeriesDatabaseSource(TheSeries:TChartSeries);
  240.     procedure ClearSources;
  241.   end;
  242.  
  243. Var TheSource:TChartEditSources;
  244.  
  245. { Helper functions }
  246. procedure FillTeeFunctions(AList:TStrings);
  247. var t:Longint;
  248. begin
  249.   AList.Clear;
  250.   AList.Add(TeeMsg_FunctionNone);
  251.   With TeeSeriesTypes do
  252.   for t:=0 to Count-1 do
  253.     With SeriesType[t] do
  254.     if Assigned(FunctionClass) and
  255.        (not Assigned(SeriesClass)) and
  256.        ( AList.IndexOfObject(TObject(FunctionClass))=-1) then
  257.           AList.InsertObject(1,Description,TObject(FunctionClass));
  258. end;
  259.  
  260. { TChartEditSource }
  261. Destructor TChartEditSource.Destroy;
  262. begin
  263.   CBValues.Free;
  264.   CBValues:=nil;
  265.   LabelValues.Free;
  266.   LabelValues:=nil;
  267.   CBDateTime.Free;
  268.   CBDateTime:=nil;
  269.   SelectedValueSource:='';
  270.   inherited Destroy;
  271. end;
  272.  
  273. { TChartEditSources }
  274. Constructor TChartEditSources.Create(AParent:TForm; ASeries:TChartSeries);
  275. var t:Longint;
  276. begin
  277.   inherited Create;
  278.   ParentForm:=AParent;
  279.   TheSeries:=ASeries;
  280.   for t:=0 to MaxValueSources-1 do Values[t]:=TChartEditSource.Create;
  281.   ClearValueSources;
  282. end;
  283.  
  284. procedure TChartEditSources.ClearSources;
  285. var t:Longint;
  286. begin
  287.   SelectedXLabelsSource:='';
  288.   for t:=0 to TheSeries.ValuesLists.Count-1 do
  289.   With Self.Values[t] do
  290.   begin
  291.     CBValues.ItemIndex:=-1;
  292.     SelectedValueSource:='';
  293.   end;
  294. end;
  295.  
  296. procedure TChartEditSources.SetSeriesDatabaseSource(TheSeries:TChartSeries);
  297. var t:Longint;
  298. begin
  299.   for t:=0 to TheSeries.ValuesLists.Count-1 do
  300.   With Self.Values[t] do
  301.   begin
  302.     CBValues.ItemIndex:=CBValues.Items.IndexOf(SelectedValueSource);
  303.     CBDateTime.Checked:=TheSeries.ValuesLists[t].DateTime;
  304.   end;
  305. end;
  306.  
  307. procedure TChartEditSources.ClearCombos(EnableCombos:Boolean);
  308. var t:Longint;
  309. begin
  310.   for t:=0 to TheSeries.ValuesLists.Count-1 do
  311.   With Self.Values[t] do
  312.   begin
  313.     CBValues.Items.Clear;
  314.     CBValues.Enabled:=EnableCombos;
  315.   end;
  316. end;
  317.  
  318. procedure TChartEditSources.SetSeries(TheSeries:TChartSeries);
  319. var t:Longint;
  320. begin
  321.   With TheSeries do
  322.   begin
  323.     SelectedDataSource:=DataSource;
  324.     SelectedXLabelsSource:=XLabelsSource;
  325.     for t:=0 to MaxValueSources-1 do
  326.     begin
  327.       Values[t].Free;
  328.       Values[t]:=TChartEditSource.Create;
  329.     end;
  330.     for t:=0 to ValuesLists.Count-1 do
  331.         Values[t].SelectedValueSource:=ValuesLists[t].ValueSource;
  332.   end;
  333. end;
  334.  
  335. procedure TChartEditSources.ClearValueSources;
  336. var t:Longint;
  337. begin
  338.   SelectedDataSource:=nil;
  339.   for t:=0 to MaxValueSources-1 do Values[t].SelectedValueSource:='';
  340.   SelectedXLabelsSource:='';
  341. end;
  342.  
  343. Destructor TChartEditSources.Destroy;
  344. var t:Longint;
  345. begin
  346.   for t:=0 to MaxValueSources-1 do Values[t].Free;
  347.   inherited Destroy;
  348. end;
  349.  
  350. { TFormTeeSeries}
  351. procedure TFormTeeSeries.RGHorizAxisClick(Sender: TObject);
  352. begin
  353.   TheSeries.HorizAxis:=THorizAxis(RGHorizAxis.ItemIndex);
  354. end;
  355.  
  356. procedure TFormTeeSeries.BMarksBackColorClick(Sender: TObject);
  357. begin
  358.   With TheSeries.Marks do BackColor:=EditColor(Self,BackColor);
  359.   CBTransparent.Checked:=False;
  360. end;
  361.  
  362. procedure TFormTeeSeries.EValueformatChange(Sender: TObject);
  363. begin
  364.   TheSeries.ValueFormat:=LocalToDelphiFormat(EValueFormat.Text);
  365. end;
  366.  
  367. procedure TFormTeeSeries.EPercentFormatChange(Sender: TObject);
  368. begin
  369.   TheSeries.PercentFormat:=LocalToDelphiFormat(EPercentFormat.Text);
  370. end;
  371.  
  372. Procedure TFormTeeSeries.SetCBSeries;
  373. begin
  374.   TheSource.TheSeries:=TheSeries;
  375.   if Assigned(TheSeries) then
  376.   begin
  377.     CBSeries.ItemIndex:=CBSeries.Items.IndexOfObject(TheSeries);
  378.     CBSeriesChange(Self);
  379.   end
  380.   else PageSeries.Visible:=False;
  381. end;
  382.  
  383. Const TeeCursorPrefix='cr';
  384.  
  385. Function DeleteCursorPrefix(Const S:String):String;
  386. begin
  387.   result:=S;
  388.   if Copy(result,1,2)=TeeCursorPrefix then Delete(result,1,2);
  389. end;
  390.  
  391. procedure TFormTeeSeries.ProcGetCursors(const S: string);
  392. begin
  393.   CBSeriesCursor.Items.Add(DeleteCursorPrefix(S));
  394. end;
  395.  
  396. procedure TFormTeeSeries.PageSeriesChange(Sender: TObject);
  397.  
  398.   procedure SetTabSeriesMarks;
  399.   begin
  400.     With TheSeries.Marks do
  401.     begin
  402.       RGMarkStyle.ItemIndex  :=Ord(Style);
  403.       CBMarksVisible.Checked :=Visible;
  404.       SEArrowLength.Text     :=IntToStr(ArrowLength);
  405.       CBTransparent.Checked  :=Transparent;
  406.       CBMarkClip.Checked     :=Clip;
  407.     end;
  408.   end;
  409.  
  410.   procedure SetTabSeriesGeneral;
  411.   var tmpSt:String;
  412.   begin
  413.     With TheSeries do
  414.     begin
  415.       CBShowInLegend.Checked   :=ShowInLegend;
  416.       EValueFormat.Text        :=DelphiToLocalFormat(ValueFormat);
  417.       EPercentFormat.Text      :=DelphiToLocalFormat(PercentFormat);
  418.       With RGHorizAxis do
  419.       begin
  420.         Enabled:=TheSeries.HorizAxis<>aCustomHorizAxis;
  421.         if Enabled then ItemIndex:=Ord(TheSeries.HorizAxis);
  422.       end;
  423.       With RGVertAxis do
  424.       begin
  425.         Enabled:=TheSeries.VertAxis<>aCustomVertAxis;
  426.         if Enabled then ItemIndex:=Ord(TheSeries.VertAxis);
  427.       end;
  428.       CBXDateTime.Checked:=XValues.DateTime;
  429.       CBYDateTime.Checked:=YValues.DateTime;
  430.     end;
  431.     With CBSeriesCursor do
  432.     begin
  433.       Items.BeginUpdate;
  434.       Clear;
  435.       GetCursorValues(ProcGetCursors);
  436.       ProcGetCursors(TeeMsg_TeeHand);
  437.       Items.EndUpdate;
  438.     end;
  439.     With CBSeriesCursor do
  440.     if TeeCursorToIdent(TheSeries.Cursor,tmpSt) then
  441.        ItemIndex:=Items.IndexOf(DeleteCursorPrefix(tmpSt))
  442.     else
  443.        ItemIndex:=-1;
  444.   end;
  445.  
  446. begin
  447.   With PageSeries.ActivePage do
  448.   if PageIndex=TabGeneral.PageIndex then SetTabSeriesGeneral else
  449.   if PageIndex=TabMarks.PageIndex   then SetTabSeriesMarks   else
  450.   if PageIndex=TabDataSource.PageIndex then SetTabSeriesDataSource;
  451. end;
  452.  
  453. Procedure TFormTeeSeries.AddSeriesForm(AForm:TForm; ATab:TTabSheet; ATag:Longint);
  454. var OldVisibleFlag: Boolean;
  455. begin
  456.   With AForm do
  457.   begin
  458.     Position:=poDesigned;
  459.     BorderStyle:=bsNone;
  460.     BorderIcons:=[];
  461.     Tag:=ATag;
  462.     Parent:=ATab;
  463.     Left:=((ATab.PageControl.ClientWidth-ClientWidth) div 2);
  464.     Top:=MinLong(8,Abs(ATab.PageControl.ClientHeight-ClientHeight) div 2);
  465.     OldVisibleFlag:=Parent.Visible;
  466.     Parent.Visible:=True;
  467.     Show;
  468.     {$IFDEF D2C1}
  469.     ClientWidth:=ATab.PageControl.ClientWidth;
  470.     {$ENDIF}
  471.     Parent.Visible:=OldVisibleFlag;
  472.   end;
  473. end;
  474.  
  475. Function TFormTeeSeries.InsertSeriesForm( EditorClass:TFormClass;
  476.                                           Position:Integer;
  477.                                           Const EditorTabName:String;
  478.                                           AnObject:TPersistent):TForm;
  479. var tmpPage  : TTabSheet;
  480. begin
  481.   tmpPage:=TTabSheet.Create(Self);
  482.   With tmpPage do
  483.   begin
  484.     PageControl:=PageSeries;
  485.     PageIndex:=Position;
  486.     Caption:=EditorTabName;
  487.   end;
  488.   result:=EditorClass.Create(Self);
  489.   Inc(NumSeriesForms);
  490.   TheSeriesForms[NumSeriesForms]:=result;
  491.   AddSeriesForm(result,tmpPage,Longint(AnObject));
  492. end;
  493.  
  494. procedure TFormTeeSeries.DestroySeriesForms;
  495. var t       : Integer;
  496.     tmpPage : TTabSheet;
  497. begin
  498.   for t:=1 to NumSeriesForms do
  499.   if Assigned(TheSeriesForms[t]) then
  500.   begin
  501.     tmpPage:=(TheSeriesForms[t].Parent as TTabSheet);
  502.     TheSeriesForms[t].Free;
  503.     TheSeriesForms[t]:=nil;
  504.     if tmpPage.PageIndex>0 then
  505.        if not (csDestroying in tmpPage.PageControl.ComponentState) then
  506.           tmpPage.Free;
  507.   end;
  508.   NumSeriesForms:=0;
  509. end;
  510.  
  511. procedure TFormTeeSeries.CBSeriesChange(Sender: TObject);
  512.  
  513.     Procedure CreateTheSeriesForm;
  514.     var tmpClass : TFormClass;
  515.     begin
  516.       tmpClass:=TFormClass(GetClass(TheSeries.GetEditorClass));
  517.       if Assigned(tmpClass) then
  518.       begin
  519.         Inc(NumSeriesForms);
  520.         TheSeriesForms[NumSeriesForms]:=tmpClass.Create(Self);
  521.         AddSeriesForm(TheSeriesForms[NumSeriesForms],TheTabSheet,Longint(TheSeries));
  522.       end
  523.       else DestroySeriesForms;
  524.     end;
  525.  
  526.     Procedure HideSeriesPage;
  527.     begin
  528.       ImageSeries.Visible:=False;
  529.       LabelSeriesClass.Caption:='';
  530.       PageSeries.Visible:=False;
  531.     end;
  532.  
  533. var OldTab    : TTabSheet;
  534.     tmpBitmap : TBitmap;
  535. begin
  536.   CreatingForm:=True;
  537.   OldTab:=PageSeries.ActivePage;
  538.   PageSeries.ActivePage:=TheTabSheet;
  539.   CheckApplyChanges;
  540.   With CBSeries do
  541.   if ItemIndex<>-1 then
  542.   begin
  543.     TheSeries:=TChartSeries(CBSeries.Items.Objects[ItemIndex]);
  544.     if Assigned(TheSeries) then
  545.     begin
  546.       tmpBitmap:=TBitmap.Create;
  547.       try
  548.         TheSeries.GetBitmapEditor(tmpBitmap);
  549.         {$IFDEF D3}
  550.         ImageSeries.Transparent:=True;
  551.         {$ENDIF}
  552.         ImageSeries.Picture.Assign(tmpBitmap);
  553.       finally
  554.         tmpBitmap.Free;
  555.       end;
  556.       LabelSeriesClass.Caption:=GetGallerySeriesName(TheSeries)+': '+TheSeries.Name; { <-- don't translate }
  557.       ImageSeries.Visible:=True;
  558.       PageSeries.Visible:=True;
  559.       TabGeneral.TabVisible:=ShowTabGeneral;
  560.       TabMarks.TabVisible:=ShowTabMarks;
  561.       {$IFDEF D3}
  562.       TabDataSource.TabVisible:=ShowTabDataSource and
  563.                                 ( (not (tssIsTemplate in TheSeries.Style)) and
  564.                                   (not (tssHideDataSource in TheSeries.Style)) );
  565.       {$ENDIF}
  566.       if (OldTab=nil) or
  567.          ((OldTab=TabDataSource) and (not TabDataSource.TabVisible)) then
  568.          PageSeries.ActivePage:=TheTabSheet
  569.       else
  570.          PageSeries.ActivePage:=OldTab;
  571.       PageSeriesChange(Self);
  572.       ShowControls(TheSeries.UseAxis,[ RGHorizAxis,RGVertAxis,
  573.                                        CBXDateTime,CBYDateTime]);
  574.       DestroySeriesForms;
  575.       CreateTheSeriesForm;
  576.       if PageSeries.ActivePage=nil then PageSeries.ActivePage:=TheTabSheet;
  577.       SetTabSeriesDataSource;
  578.       {$IFDEF D3}
  579.       CBPersistent.Visible:=IsDssGraph and (not (tssIsTemplate in TheSeries.Style));
  580.       if CBPersistent.Visible then
  581.          CBPersistent.Checked:=(tssIsPersistent in TheSeries.Style);
  582.       {$ENDIF}
  583.     end
  584.     else HideSeriesPage;
  585.   end
  586.   else HideSeriesPage;
  587.   CreatingForm:=False;
  588. end;
  589.  
  590. { special case at design time }
  591. Function TFormTeeSeries.IsValidComponentSource(AComponent:TComponent):Boolean;
  592. begin
  593.   result:= (CBDataSourceStyle.ItemIndex=Ord(dsStyle_Function)) and
  594.            (AComponent is TChartSeries);
  595.   if not result then
  596.      if CBDataSourceStyle.ItemIndex>Ord(dsStyle_Function) then
  597.         if Assigned(OnChartIsValidComponentSource) then
  598.            result:=OnChartIsValidComponentSource(AComponent,
  599.                  TTeeDataSourceStyle(CBDataSourceStyle.ItemIndex));
  600. end;
  601.  
  602. Procedure TFormTeeSeries.AddComponentDataSource( Const AComponent:TComponent;
  603.                                                  AItems:TStrings;
  604.                                                  AddCurrent:Boolean);
  605. Var tmp,tmpFormName:String;
  606. begin
  607.   if AddCurrent or (TheSeries.DataSources.IndexOf(AComponent)=-1) then
  608.   if IsValidComponentSource(AComponent) then
  609.      if TheSeries.ParentChart.IsValidDataSource(TheSeries,AComponent) then
  610.      begin
  611.        if AComponent is TChartSeries then
  612.        With TChartSeries(AComponent) do
  613.        begin
  614.          if Title<>'' then tmp:=Title
  615.                       else tmp:=Name;
  616.        end
  617.        else
  618.        begin
  619.          tmp:=AComponent.Name;
  620.          if Pos('ODBC',tmp)=1 then tmp:=pString(pointer(AComponent.Tag))^;
  621.        end;
  622.        if (TheSeries.Owner<>AComponent.Owner) and
  623.           (AComponent.Owner<>nil) then
  624.        begin
  625.          tmpFormName:=AComponent.Owner.Name;
  626.          if tmpFormName<>'' then tmp:=tmpFormName+'.'+tmp;
  627.        end;
  628.        AItems.AddObject(tmp,AComponent);
  629.      end;
  630. end;
  631.  
  632. Procedure TFormTeeSeries.FillSources(AItems:TStrings; AddCurrent:Boolean);
  633.  
  634.   Procedure FillSourcesForm(AOwner:TComponent);
  635.   var t:Longint;
  636.   begin
  637.     if Assigned(AOwner) then
  638.     With AOwner do
  639.     for t:=0 to ComponentCount-1 do
  640.         AddComponentDataSource(Components[t],AItems,AddCurrent);
  641.   end;
  642.  
  643. var t:Longint;
  644. begin
  645.   if (csDesigning in TheSeries.ComponentState) and
  646.      Assigned(OnGetDesignerNames) then
  647.         OnGetDesignerNames(AddComponentDataSource,TheSeries,AItems,AddCurrent)
  648.   else
  649.   begin
  650.     With Screen do
  651.     for t:=0 to DataModuleCount-1 do FillSourcesForm(DataModules[t]);
  652.     FillSourcesForm(TheSeries.ParentChart.Owner);
  653.     if DataSourceStyle<>dsStyle_DataSource then
  654.        FillSourcesForm(TheSeries.ParentChart);
  655.   end;
  656. end;
  657.  
  658. procedure TFormTeeSeries.FillSourceDatasets;
  659. begin
  660.   CBListDataSets.Items.Clear;
  661.   FillSources(CBListDataSets.Items,True);
  662.   SetCurrentDataSource;
  663.   ApplyChangesDataSet:=True;
  664. end;
  665.  
  666. procedure TFormTeeSeries.EnableDataSourceControls(IsDatabase,IsFunction:Boolean);
  667.  
  668.   procedure SetTabSeriesDatabase;
  669.   var t       : Longint;
  670.       tmpName : String;
  671.   begin
  672.     L16.Caption:=TeeMsg_AskDataSet;
  673.     GroupFields.Visible:=False;
  674.     FillSourceDatasets;
  675.     TheSource.SetSeries(TheSeries);
  676.     With TheSeries,TheSource do
  677.     begin
  678.       for t:=0 to ValuesLists.Count-1 do
  679.       With TheSource.Values[t] do
  680.       begin
  681.         tmpName:=ValuesLists[t].Name;
  682.         CBValues:=TComboBox.Create(ParentForm);
  683.         With CBValues do
  684.         begin
  685.           Parent:=GroupFields;
  686.           Left:=CBLabelsField.Left;
  687.           Style:=csDropDown;
  688.           HelpContext:=178;
  689.           Width:=CBLabelsField.Width;
  690.           Top:=2+CBLabelsField.Top+CBLabelsField.Height+((CBValues.Height+4)*t+1);
  691.           OnChange:=CBValuesChange;
  692.           Tag:=t;
  693.           Visible:=tmpName<>'';
  694.         end;
  695.         LabelValues:=TLabel.Create(ParentForm);
  696.         With LabelValues do
  697.         begin
  698.           Alignment:=taRightJustify;
  699.           Parent:=GroupFields;
  700.           Top:=CBValues.Top+4;
  701.           AutoSize:=False;
  702.           Left:=LabelLabels.Left;
  703.           Width:=LabelLabels.Width;
  704.           Caption:=tmpName+':';
  705.           Visible:=tmpName<>'';
  706.         end;
  707.         CBDateTime:=TCheckBox.Create(ParentForm);
  708.         With CBDateTime do
  709.         begin
  710.           Parent:=GroupFields;
  711.           Left:=CBLabelsField.Left+CBLabelsField.Width+6;
  712.           Top:=CBValues.Top;
  713.           HelpContext:=178;
  714.           Caption:=TeeMsg_DateTime;
  715.           Width:=Canvas.TextWidth(Caption + 'www'); { <-- ugly... }
  716.           Tag:=t;
  717.           Visible:=tmpName<>'';
  718.           OnClick:=CBDateTimeClick;
  719.         end;
  720.         SelectedValueSource:=ValuesLists[t].ValueSource;
  721.       end;
  722.     end;
  723.     TheSource.SetSeriesDatabaseSource(TheSeries);
  724.     SetCurrentDataSource;
  725.     SetSelectedSourceDatabase;
  726.     GroupFields.Visible:=True;
  727.     PCDataStyle.ActivePage:=TBDataSet;
  728.     ApplyChangesDataSet:=False;
  729.   end;
  730.  
  731.   procedure SetTabDataSource;
  732.   begin
  733.     L16.Caption:=TeeMsg_AskDataSource;
  734.     FillSourceDatasets;
  735.     TheSource.SetSeries(TheSeries);
  736.     SetCurrentDataSource;
  737.     SetSelectedSourceDatabase;
  738.     PCDataStyle.ActivePage:=TBDataSource;
  739.     FromList:=LBAvailFields;
  740.     ToList:=LBSelFields;
  741.     EnableListButtons;
  742.     ApplyChangesDataSet:=False;
  743.   end;
  744.  
  745. Var tmp:Boolean;
  746. begin
  747.   tmp:=False;
  748.   Case DataSourceStyle of
  749.     dsStyle_DataSet: begin
  750.                        SetTabSeriesDatabase;
  751.                        PCData.ActivePage:=TabDatabase;
  752.                        tmp:=True;
  753.                      end;
  754.     dsStyle_DataSource: begin
  755.                        SetTabDataSource;
  756.                        PCData.ActivePage:=TabDatabase;
  757.                        tmp:=True;
  758.                      end;
  759.     dsStyle_Function: begin
  760.                        SetTabSeriesFunctions;
  761.                        PCData.ActivePage:=TabFunctions;
  762.                        tmp:=True;
  763.                      end;
  764.   end;
  765.   PCData.Visible:=tmp;
  766. end;
  767.  
  768. procedure TFormTeeSeries.SetTabSeriesDataSource;
  769. Var Old:Boolean;
  770. begin
  771.   Old:=TabDataSource.Visible;
  772.   TabDataSource.Visible:=False;
  773.   if TheSeries.DataSource=nil then
  774.   begin
  775.     if TheSeries.FunctionType<>nil then
  776.     begin
  777.       CBDataSourceStyle.ItemIndex:=Ord(dsStyle_Function);
  778.       EnableDataSourceControls(False,True);
  779.     end
  780.     else
  781.     begin
  782.       if TheSeries.Count>0 then
  783.          CBDataSourceStyle.ItemIndex:=Ord(dsStyle_Random)
  784.       else
  785.          CBDataSourceStyle.ItemIndex:=Ord(dsStyle_NoData);
  786.       EnableDataSourceControls(False,False);
  787.     end;
  788.   end
  789.   else
  790.   if TheSeries.DataSource is TChartSeries then
  791.   begin
  792.     CBDataSourceStyle.ItemIndex:=Ord(dsStyle_Function);
  793.     EnableDataSourceControls(False,True);
  794.   end
  795.   else
  796.   begin
  797.     if Assigned(OnChartGetSourceStyle) then { 4.01 }
  798.        CBDataSourceStyle.ItemIndex:=Ord(OnChartGetSourceStyle(TheSeries))
  799.     else
  800.        CBDataSourceStyle.ItemIndex:=0;
  801.     EnableDataSourceControls(True,False);
  802.   end;
  803.   TabDataSource.Visible:=Old;
  804. end;
  805.  
  806. procedure TFormTeeSeries.CheckApplyChanges;
  807. begin
  808.   if ApplyChangesDataSet then DoApplyChangesDataSet
  809.   else
  810.   if ApplyChangesFunction then DoApplyChangesFunction;
  811. end;
  812.  
  813. procedure TFormTeeSeries.FormCreate(Sender: TObject);
  814. begin
  815.   CreatingForm:=True;
  816.   NumSeriesForms:=0;
  817.   ShowTabDataSource:=True;
  818.   ShowTabGeneral:=True;
  819.   ShowTabMarks:=True;
  820.   IsDssGraph:=False;
  821.   OnGetDesignerNames:=nil;
  822.   OnChartFillFields:=nil;
  823.   OnChartGetSourceStyle:=nil;
  824.   OnChartIsDateTimeSource:=nil;
  825.   OnChartIsValidComponentSource:=nil;
  826.   TheSource:=TChartEditSources.Create(Self,nil);
  827.   PageSeries.ActivePage:=TheTabSheet;
  828.   {$IFDEF D3}
  829.   PageSeries.HotTrack:=True;
  830.   {$ENDIF}
  831. end;
  832.  
  833. procedure TFormTeeSeries.RGMarkStyleClick(Sender: TObject);
  834. begin
  835.   TheSeries.Marks.Style:=TSeriesMarksStyle(RGMarkStyle.ItemIndex);
  836. end;
  837.  
  838. procedure TFormTeeSeries.BEditFuncClick(Sender: TObject);
  839. begin
  840.   if ApplyChangesFunction then DoApplyChangesFunction;
  841.   if TheSeries.FunctionType<>nil then
  842.   With TFormPeriod.Create(Self) do
  843.   try
  844.     With TheSeries.FunctionType do
  845.     begin
  846.       ThePeriod      :=Period;
  847.       ThePeriodStyle :=PeriodStyle;
  848.       TheCanRange    :=not MovingFunction;
  849.       TheAlignment   :=PeriodAlign;
  850.       LCalc.Caption  :=Format(TeeMsg_CalcPeriod,[CBFunctions.Text]);
  851.     end;
  852.     With TheSeries do
  853.     if ( DataSource<>nil ) and (DataSource is TChartSeries) then
  854.       TheIsDateTime:=TChartSeries(DataSource).XValues.DateTime
  855.     else
  856.       TheIsDateTime:=False;
  857.     if ShowModal=mrOk then
  858.     With TheSeries.FunctionType do
  859.     begin
  860.       BeginUpdate;
  861.       PeriodStyle:=ThePeriodStyle;
  862.       Period     :=ThePeriod;
  863.       PeriodAlign:=TheAlignment;
  864.       EndUpdate;
  865.     end;
  866.   finally
  867.     Free;
  868.   end;
  869. end;
  870.  
  871. procedure TFormTeeSeries.CBPersistentClick(Sender: TObject);
  872. begin
  873.   {$IFDEF D3}
  874.   With TheSeries do
  875.   if CBPersistent.Checked then Style:=Style+[tssIsPersistent]
  876.                           else Style:=Style-[tssIsPersistent];
  877.   {$ENDIF}
  878. end;
  879.  
  880. procedure TFormTeeSeries.CBYDateTimeClick(Sender: TObject);
  881. begin
  882.   TheSeries.YValues.DateTime:=CBYDateTime.Checked;
  883. end;
  884.  
  885. procedure TFormTeeSeries.CBXDateTimeClick(Sender: TObject);
  886. begin
  887.   TheSeries.XValues.DateTime:=CBXDateTime.Checked;
  888. end;
  889.  
  890. Procedure TFormTeeSeries.IsDateTimeSource( AComponent:TComponent;
  891.                                            Const ValueSource:String;
  892.                                            Var IsDateTime:Boolean);
  893. begin
  894.   if Assigned(OnChartIsDateTimeSource) then
  895.      OnChartIsDateTimeSource(AComponent,ValueSource,IsDateTime);
  896. end;
  897.  
  898. procedure TFormTeeSeries.CBDataSourcestyleChange(Sender: TObject);
  899. begin
  900.   PCData.Visible:= (CBDataSourceStyle.ItemIndex<>Ord(dsStyle_NoData)) and
  901.                    (CBDataSourceStyle.ItemIndex<>Ord(dsStyle_Random));
  902.   Case TTeeDataSourceStyle(CBDataSourceStyle.ItemIndex) of
  903.     dsStyle_NoData:
  904.        begin
  905.          TheSource.ClearValueSources;
  906.          EnableDataSourceControls(False,False);
  907.          TheSeries.DataSource:=nil;
  908.          TheSeries.Clear;
  909.        end;
  910.     dsStyle_Random:
  911.        begin
  912.          TheSource.ClearValueSources;
  913.          EnableDataSourceControls(False,False);
  914.          With TheSeries do
  915.          begin
  916.            DataSource:=nil;
  917.            SetFunction(nil);
  918.            FillSampleValues(NumSampleValues);
  919.          end;
  920.        end;
  921.    dsStyle_Function: EnableDataSourceControls(False,True);
  922.   else
  923.     {dsStyle_Dataset:} EnableDataSourceControls(True,False);
  924.   end;
  925. end;
  926.  
  927. procedure TFormTeeSeries.DoApplyChangesFunction;
  928. var t        : Longint;
  929.     tmp      : TChartSeries;
  930.     tmpClass : TTeeFunctionClass;
  931. begin
  932.   { Set datasources... }
  933.   if LBSelectedSeries.Items.Count=0 then TheSeries.DataSource:=nil
  934.   else
  935.   begin
  936.     for t:=0 to LBSelectedSeries.Items.Count-1 do
  937.     begin
  938.       tmp:=TChartSeries(LBSelectedSeries.Items.Objects[t]);
  939.       TheSeries.CheckOtherSeries(tmp);
  940.     end;
  941.     With TheSeries.DataSources do
  942.     begin
  943.       for t:=0 to Count-1 do
  944.           TChartSeries(TheSeries.DataSources[t]).RemoveLinkedSeries(TheSeries);
  945.       Clear;
  946.       for t:=0 to LBSelectedSeries.Items.Count-1 do
  947.       begin
  948.         tmp:=TChartSeries(LBSelectedSeries.Items.Objects[t]);
  949.         Add(tmp);
  950.         TChartSeries(tmp).AddLinkedSeries(TheSeries);
  951.       end;
  952.     end;
  953.   end;
  954.   { Set function... }
  955.   if CBFunctions.ItemIndex>0 then
  956.   begin
  957.     tmpClass:=TTeeFunctionClass(CBFunctions.Items.Objects[CBFunctions.ItemIndex]);
  958.     if (TheSeries.FunctionType=nil) or
  959.        (TheSeries.FunctionType.ClassType<>tmpClass) then
  960.           CreateNewTeeFunction(TheSeries,tmpClass)
  961.     else
  962.           TheSeries.CheckDataSource;
  963.   end
  964.   else TheSeries.SetFunction(nil);
  965.   ApplyChangesFunction:=False;
  966. end;
  967.  
  968. Function TFormTeeSeries.GetSelectedSource:TComponent;
  969. begin
  970.   result:=TheSource.SelectedDataSource;
  971. end;
  972.  
  973. Function TFormTeeSeries.GetSourceCombo(Index:Integer):TComboBox;
  974. begin
  975.   result:=TheSource.Values[Index].CBValues;
  976. end;
  977.  
  978. procedure TFormTeeSeries.CBFunctionsChange(Sender: TObject);
  979. begin
  980.   ApplyChangesFunction:=True;
  981.   BEditFunc.Enabled:=CBFunctions.ItemIndex>0;
  982. end;
  983.  
  984. procedure TFormTeeSeries.LBSelectedSeriesDblClick(Sender: TObject);
  985. begin
  986.   BLeftOneClick(Self);
  987. end;
  988.  
  989. procedure TFormTeeSeries.LBAvailSeriesDblClick(Sender: TObject);
  990. begin
  991.   BRightOneClick(Self);
  992. end;
  993.  
  994. procedure TFormTeeSeries.BLeftAllClick(Sender: TObject);
  995. begin
  996.   MoveListAll(ToList,FromList);
  997.   EnableListButtons;
  998.   ApplyChangesFunction:=True;
  999. end;
  1000.  
  1001. Procedure TFormTeeSeries.ChangeApply;
  1002. begin
  1003.   Case DataSourceStyle of
  1004.     dsStyle_Function: ApplyChangesFunction:=True;
  1005.     dsStyle_Dataset,
  1006.     dsStyle_DataSource: ApplyChangesDataset:=True;
  1007.   end;
  1008. end;
  1009.  
  1010. procedure TFormTeeSeries.BRightAllClick(Sender: TObject);
  1011. begin
  1012.   MoveListAll(FromList,ToList);
  1013.   EnableListButtons;
  1014.   ChangeApply;
  1015. end;
  1016.  
  1017. procedure TFormTeeSeries.BLeftOneClick(Sender: TObject);
  1018. begin
  1019.   MoveList(ToList,FromList);
  1020.   EnableListButtons;
  1021.   ChangeApply;
  1022. end;
  1023.  
  1024. procedure TFormTeeSeries.BRightOneClick(Sender: TObject);
  1025. begin
  1026.   MoveList(FromList,ToList);
  1027.   EnableListButtons;
  1028.   ChangeApply;
  1029. end;
  1030.  
  1031. procedure TFormTeeSeries.EnableListButtons;
  1032. begin
  1033.   Case DataSourceStyle of
  1034.     dsStyle_Function: begin
  1035.      BRightOne.Enabled:=FromList.Items.Count>0;
  1036.      BRightAll.Enabled:=BRightOne.Enabled;
  1037.      BLeftOne.Enabled :=ToList.Items.Count>0;
  1038.      BLeftAll.Enabled :=BLeftOne.Enabled;
  1039.   end;
  1040.   dsStyle_DataSource: begin
  1041.     BROneDS.Enabled:=FromList.Items.Count>0;
  1042.     BRAllDS.Enabled:=BROneDS.Enabled;
  1043.     BLOneDS.Enabled :=ToList.Items.Count>0;
  1044.     BLAllDS.Enabled :=BLOneDS.Enabled;
  1045.   end;
  1046.   end;
  1047. end;
  1048.  
  1049. Procedure TFormTeeSeries.FillFields;  { virtual }
  1050. begin
  1051.   if Assigned(OnChartFillFields) then OnChartFillFields(Self);
  1052. end;
  1053.  
  1054. procedure TFormTeeSeries.CBLabelsFieldChange(Sender: TObject);
  1055. begin
  1056.   SetTextItemIndex(CBLabelsField);
  1057.   With CBLabelsField do
  1058.   if ItemIndex=-1 then
  1059.      TheSource.SelectedXLabelsSource:=''
  1060.   else
  1061.      TheSource.SelectedXLabelsSource:=Items[ItemIndex];
  1062.   ApplyChangesDataSet:=True;
  1063. end;
  1064.  
  1065. Procedure TFormTeeSeries.SetTextItemIndex(Combo:TComboBox);
  1066. var tmp : Integer;
  1067. begin
  1068.   With Combo do
  1069.   begin
  1070.     tmp:=Items.IndexOf(Text);
  1071.     if tmp<>ItemIndex then ItemIndex:=tmp;
  1072.   end;
  1073. end;
  1074.  
  1075. procedure TFormTeeSeries.CBValuesChange(Sender: TObject);
  1076. var tmp:Boolean;
  1077. begin
  1078.   SetTextItemIndex(TComboBox(Sender));
  1079.   With TComboBox(Sender),TheSource.Values[Tag] do
  1080.   begin
  1081.     if ItemIndex=-1 then SelectedValueSource:=''
  1082.                     else SelectedValueSource:=Items[ItemIndex];
  1083.     if SelectedValueSource<>'' then
  1084.     begin
  1085.       tmp:=CBDateTime.Checked;
  1086.       IsDateTimeSource(TheSource.SelectedDataSource,SelectedValueSource,tmp);
  1087.       CBDateTime.Checked:=tmp;
  1088.     end;
  1089.   end;
  1090.   ApplyChangesDataSet:=True;
  1091. end;
  1092.  
  1093. procedure TFormTeeSeries.CBDateTimeClick(Sender: TObject);
  1094. begin
  1095.   ApplyChangesDataSet:=True;
  1096. end;
  1097.  
  1098. procedure TFormTeeSeries.DoApplyChangesDataset;
  1099.  
  1100.   Procedure CheckFieldIsBlank(Const AFieldName:String);
  1101.   begin
  1102.     if AFieldName<>'' then
  1103.        Raise ChartException.CreateFmt(TeeMsg_FieldNotFound,[AFieldName]);
  1104.   end;
  1105.  
  1106.   Procedure CheckValidFields;
  1107.   var t:Integer;
  1108.   begin
  1109.     for t:=0 to TheSeries.ValuesLists.Count-1 do
  1110.     With TheSource.Values[t],CBValues do
  1111.     begin
  1112.       SetTextItemIndex(CBValues);
  1113.       if ItemIndex=-1 then CheckFieldIsBlank(Text);
  1114.     end;
  1115.     SetTextItemIndex(CBLabelsField);
  1116.     With CBLabelsField do
  1117.     if ItemIndex=-1 then CheckFieldIsBlank(Text);
  1118.   end;
  1119.  
  1120. var t     : Integer;
  1121.     tmpSt : String;
  1122. begin
  1123.   if Assigned(TheSeries) then
  1124.   With TheSeries do
  1125.   begin
  1126.     if TheSource.SelectedDataSource=nil then
  1127.        CBDataSourceStyle.ItemIndex:=Ord(dsStyle_NoData)
  1128.     else
  1129.     begin
  1130.       if DataSourceStyle=dsStyle_DataSet then
  1131.          CheckValidFields; { raise exception if non valid user input }
  1132.       DataSource:=nil;
  1133.       if DataSourceStyle=dsStyle_DataSet then
  1134.       begin
  1135.         for t:=0 to ValuesLists.Count-1 do
  1136.         With ValuesLists[t],TheSource.Values[t] do
  1137.         begin
  1138.           if CBValues.ItemIndex=-1 then ValueSource:=''
  1139.                                    else ValueSource:=SelectedValueSource;
  1140.           DateTime:=CBDateTime.Checked;
  1141.         end;
  1142.         With CBLabelsField do
  1143.         if ItemIndex=-1 then XLabelsSource:=''
  1144.                         else XLabelsSource:=TheSource.SelectedXLabelsSource;
  1145.       end
  1146.       else
  1147.       begin
  1148.         if LBSelFields.Items.Count>0 then
  1149.         begin
  1150.            tmpSt:=LBSelFields.Items[0];
  1151.            for t:=1 to LBSelFields.Items.Count-1 do
  1152.                tmpSt:=tmpSt+';'+LBSelFields.Items[t];
  1153.         end
  1154.         else tmpSt:='';
  1155.         MandatoryValueList.ValueSource:=tmpSt;
  1156.       end;
  1157.       DataSource:=TheSource.SelectedDataSource;
  1158.     end;
  1159.   end;
  1160.   ApplyChangesDataSet:=False;
  1161. end;
  1162.  
  1163. procedure TFormTeeSeries.CBListDataSetsChange(Sender: TObject);
  1164. begin
  1165.   SetSelectedSourceDatabase;
  1166.   ApplyChangesDataset:=True;
  1167. end;
  1168.  
  1169. procedure TFormTeeSeries.CBShowInLegendClick(Sender: TObject);
  1170. begin
  1171.   TheSeries.ShowInLegend:=CBShowInLegend.Checked;
  1172. end;
  1173.  
  1174. procedure TFormTeeSeries.RGVertAxisClick(Sender: TObject);
  1175. begin
  1176.   TheSeries.VertAxis:=TVertAxis(RGVertAxis.ItemIndex);
  1177. end;
  1178.  
  1179. procedure TFormTeeSeries.CBSeriesCursorChange(Sender: TObject);
  1180. var tmpCursor:Longint;
  1181. begin
  1182.   if TeeIdentToCursor(TeeCursorPrefix+
  1183.                       CBSeriesCursor.Items[CBSeriesCursor.ItemIndex],
  1184.                       tmpCursor) then
  1185.      TheSeries.Cursor:=tmpCursor;
  1186. end;
  1187.  
  1188. procedure TFormTeeSeries.BMarkLinColClick(Sender: TObject);
  1189. begin
  1190.   EditChartPen(Self,TheSeries.Marks.Arrow);
  1191. end;
  1192.  
  1193. procedure TFormTeeSeries.BMarksFrameClick(Sender: TObject);
  1194. begin
  1195.   EditChartPen(Self,TheSeries.Marks.Frame);
  1196. end;
  1197.  
  1198. procedure TFormTeeSeries.BMarkFontClick(Sender: TObject);
  1199. begin
  1200.   With TheSeries.Marks do Font:=InternalEditFont(Self,Font);
  1201. end;
  1202.  
  1203. procedure TFormTeeSeries.SEArrowLengthChange(Sender: TObject);
  1204. begin
  1205.   if (not CreatingForm) and (SEArrowLength.Text<>'') then
  1206.      TheSeries.Marks.ArrowLength:=StrToInt(SEArrowLength.Text);
  1207. end;
  1208.  
  1209. procedure TFormTeeSeries.CBMarkClipClick(Sender: TObject);
  1210. begin
  1211.   TheSeries.Marks.Clip:=CBMarkClip.Checked;
  1212. end;
  1213.  
  1214. procedure TFormTeeSeries.CBTransparentClick(Sender: TObject);
  1215. begin
  1216.   TheSeries.Marks.Transparent:=CBTransparent.Checked;
  1217. end;
  1218.  
  1219. procedure TFormTeeSeries.CBMarksVisibleClick(Sender: TObject);
  1220. begin
  1221.   TheSeries.Marks.Visible:=CBMarksVisible.Checked;
  1222. end;
  1223.  
  1224. procedure TFormTeeSeries.SetCurrentDataSource;
  1225. begin
  1226.   if TheSource.SelectedDataSource=nil then
  1227.      CBListDataSets.ItemIndex:=-1
  1228.   else
  1229.      CBListDataSets.ItemIndex:=CBListDataSets.Items.IndexOfObject(TheSource.SelectedDataSource);
  1230. end;
  1231.  
  1232. Function TFormTeeSeries.DataSourceStyle:TTeeDataSourceStyle;
  1233. begin
  1234.   result:=TTeeDataSourceStyle(CBDataSourceStyle.ItemIndex);
  1235. end;
  1236.  
  1237. procedure TFormTeeSeries.SetSelectedSourceDatabase;
  1238. begin
  1239.   if DataSourceStyle=dsStyle_DataSet then
  1240.   begin
  1241.     CBLabelsField.Items.Clear;
  1242.     CBLabelsField.Enabled:= (CBListDataSets.ItemIndex<>-1);
  1243.     TheSource.ClearCombos(CBListDataSets.ItemIndex<>-1);
  1244.   end;
  1245.   if CBListDataSets.ItemIndex=-1 then
  1246.   begin
  1247.     TheSource.SelectedDataSource:=nil;
  1248.     if DataSourceStyle=dsStyle_DataSource then
  1249.     begin
  1250.       LBAvailFields.Clear;
  1251.       LBSelFields.Clear;
  1252.     end;
  1253.   end
  1254.   else
  1255.   begin
  1256.     TheSource.SelectedDataSource:=TComponent(CBListDataSets.Items.Objects[CBListDataSets.ItemIndex]);
  1257.     if Assigned(TheSource.SelectedDataSource) then FillFields;
  1258.   end;
  1259.   if DataSourceStyle=dsStyle_DataSet then
  1260.   begin
  1261.     CBLabelsField.ItemIndex:=CBLabelsField.Items.IndexOf(TheSource.SelectedXLabelsSource);
  1262.     TheSource.SetSeriesDatabaseSource(TheSeries);
  1263.   end;
  1264. end;
  1265.  
  1266. procedure TFormTeeSeries.FillSourceSeries;
  1267. begin
  1268.   FillTeeFunctions(CBFunctions.Items);
  1269.   LBAvailSeries.Items.Clear;
  1270.   FillSources(LBAvailSeries.Items,False);
  1271.   if TheSource.SelectedDataSource=nil then
  1272.      LBAvailSeries.ItemIndex:=-1
  1273.   else
  1274.      LBAvailSeries.ItemIndex:=LBAvailSeries.Items.IndexOfObject(TheSource.SelectedDataSource);
  1275.   SetSelectedSourceSeries;
  1276. end;
  1277.  
  1278. procedure TFormTeeSeries.SetTabSeriesFunctions;
  1279. var t:Integer;
  1280.     tmpSeries:TChartSeries;
  1281.     tmpSt:String;
  1282. begin
  1283.   FillSourceSeries;
  1284.   TheSource.SetSeries(TheSeries);
  1285.   With LBSelectedSeries do
  1286.   begin
  1287.     Items.BeginUpdate;
  1288.     Clear;
  1289.     if (TheSeries.DataSource<>nil) then
  1290.     for t:=0 to TheSeries.DataSources.Count-1 do
  1291.     begin
  1292.       if TComponent(TheSeries.DataSources[t]) is TChartSeries then
  1293.       begin
  1294.         tmpSeries:=TChartSeries(TheSeries.DataSources[t]);
  1295.         With tmpSeries do
  1296.         begin
  1297.           if Title<>'' then tmpSt:=Title else tmpSt:=Name;
  1298.           Items.AddObject(tmpSt,tmpSeries);
  1299.         end;
  1300.       end;
  1301.     end;
  1302.     Items.EndUpdate;
  1303.   end;
  1304.   With CBFunctions do
  1305.   if TheSeries.FunctionType<>nil then
  1306.      ItemIndex:=Items.IndexOfObject(TObject(TTeeFunction(TheSeries.FunctionType).ClassType))
  1307.   else
  1308.      ItemIndex:=0;
  1309.   BEditFunc.Enabled:=CBFunctions.ItemIndex>0;
  1310.   ApplyChangesFunction:=False;
  1311.   FromList:=LBAvailSeries;
  1312.   ToList:=LBSelectedSeries;
  1313.   EnableListButtons;
  1314. end;
  1315.  
  1316. procedure TFormTeeSeries.SetSelectedSourceSeries;
  1317. begin
  1318. end;
  1319.  
  1320. procedure TFormTeeSeries.PageSeriesChanging(Sender: TObject;
  1321.   var AllowChange: Boolean);
  1322.  
  1323.   Function YesNoCancel(Const Message:String):Integer;
  1324.   Begin
  1325.     Screen.Cursor:=crDefault;
  1326.     result:=MessageDlg(Message,mtConfirmation,mbYesNoCancel,0);
  1327.   End;
  1328.  
  1329. begin
  1330.   AllowChange:=False;
  1331.   if (PageSeries.ActivePage=TabDataSource) then
  1332.   begin
  1333.     if ApplyChangesDataset or ApplyChangesFunction then
  1334.        Case YesNoCancel(TeeMsg_SureToApply) of
  1335.          mrYes   : begin
  1336.                      try
  1337.                        if ApplyChangesDataset then DoApplyChangesDataset
  1338.                                               else DoApplyChangesFunction;
  1339.                        AllowChange:=True;
  1340.                      except
  1341.                        on E:Exception do Application.ShowException(E);
  1342.                      end;
  1343.                    end;
  1344.          mrNo    : begin
  1345.                      ApplyChangesDataSet:=False;
  1346.                      ApplyChangesFunction:=False;
  1347.                      AllowChange:=True;
  1348.                    end;
  1349.        end
  1350.     else AllowChange:=TheSeries<>nil;
  1351.   end
  1352.   else AllowChange:=True;
  1353. end;
  1354.  
  1355. procedure TFormTeeSeries.FormCloseQuery(Sender: TObject;
  1356.   var CanClose: Boolean);
  1357. begin
  1358.   if ApplyChangesDataset then DoApplyChangesDataset
  1359.   else
  1360.   if ApplyChangesFunction then DoApplyChangesFunction;
  1361. end;
  1362.  
  1363. procedure TFormTeeSeries.FormDestroy(Sender: TObject);
  1364. begin
  1365.   TheSource.Free;
  1366.   DestroySeriesForms;
  1367. end;
  1368.  
  1369. procedure TFormTeeSeries.FormShow(Sender: TObject);
  1370. begin
  1371.   CreatingForm:=False;
  1372. end;
  1373.  
  1374. end.
  1375.