diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm index b43a6e0e4..14ec5a110 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm @@ -319,10 +319,9 @@ object BasicSPCForm: TBasicSPCForm Left = 0 Height = 22 Top = 6 - Width = 533 + Width = 537 AutoSize = True BorderSpacing.Top = 6 - BorderSpacing.Right = 4 BorderSpacing.Bottom = 6 Caption = 'ReportToolBar' EdgeBorders = [] @@ -357,47 +356,6 @@ object BasicSPCForm: TBasicSPCForm end object ChartPage: TTabSheet Caption = 'Chart' - ClientHeight = 398 - ClientWidth = 537 - object ChartToolBar: TToolBar - Left = 0 - Height = 22 - Top = 6 - Width = 533 - AutoSize = True - BorderSpacing.Top = 6 - BorderSpacing.Right = 4 - BorderSpacing.Bottom = 6 - Caption = 'ChartToolBar' - EdgeBorders = [] - Images = MainDataModule.ImageList - TabOrder = 0 - Transparent = True - object tbSaveChart: TToolButton - Left = 1 - Hint = 'Save chart to file' - Top = 0 - Caption = 'Save' - ImageIndex = 4 - OnClick = tbSaveChartClick - end - object tbPrintChart: TToolButton - Left = 24 - Hint = 'Print chart' - Top = 0 - Caption = 'Print' - ImageIndex = 5 - OnClick = tbPrintChartClick - end - object tbCopyChart: TToolButton - Left = 47 - Hint = 'Copy chart to clipboard' - Top = 0 - Caption = 'Copy' - ImageIndex = 7 - OnClick = tbCopyChartClick - end - end end end object SaveDialog: TSaveDialog diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas index 55d821c78..cf8078e7f 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas @@ -38,14 +38,10 @@ type MeasOutBtn: TSpeedButton; GroupInBtn: TSpeedButton; GroupOutBtn: TSpeedButton; - tbPrintChart: TToolButton; tbPrintReport: TToolButton; - tbSaveChart: TToolButton; tbSaveReport: TToolButton; - ChartToolBar: TToolBar; ReportToolBar: TToolBar; tbCopyReport: TToolButton; - tbCopyChart: TToolButton; VarList: TListBox; VarListLabel: TLabel; procedure CloseBtnClick(Sender: TObject); @@ -59,11 +55,8 @@ type procedure MeasInBtnClick(Sender: TObject); procedure MeasOutBtnClick(Sender: TObject); procedure ResetBtnClick(Sender: TObject); - procedure tbCopyChartClick(Sender: TObject); procedure tbCopyReportClick(Sender: TObject); - procedure tbPrintChartClick(Sender: TObject); procedure tbPrintReportClick(Sender: TObject); - procedure tbSaveChartClick(Sender: TObject); procedure tbSaveReportClick(Sender: TObject); procedure VarListClick(Sender: TObject); private @@ -191,7 +184,7 @@ begin FChartFrame := TChartFrame.Create(self); FChartFrame.Parent := ChartPage; FChartFrame.Align := alClient; - FChartFrame.BorderSpacing.Around := Scale96ToFont(8); + FChartFrame.BorderSpacing.Top := Scale96ToFont(6); FChartFrame.Chart.Legend.SymbolWidth := Scale96ToFont(30); FChartFrame.Chart.Legend.Alignment := laBottomCenter; FChartFrame.Chart.Legend.ColumnCount := 3; @@ -448,12 +441,6 @@ begin end; -procedure TBasicSPCForm.tbCopyChartClick(Sender: TObject); -begin - FChartFrame.Chart.CopyToClipboardBitmap; -end; - - procedure TBasicSPCForm.tbCopyReportClick(Sender: TObject); begin with ReportMemo do @@ -465,12 +452,6 @@ begin end; -procedure TBasicSPCForm.tbPrintChartClick(Sender: TObject); -begin - FChartFrame.Print; -end; - - procedure TBasicSPCForm.tbPrintReportClick(Sender: TObject); begin if PrintDialog.Execute then @@ -485,12 +466,6 @@ begin end; -procedure TBasicSPCForm.tbSaveChartClick(Sender: TObject); -begin - FChartFrame.Save; -end; - - procedure TBasicSPCForm.tbSaveReportClick(Sender: TObject); begin SaveDialog.Filter := 'LazStats text files (*.txt)|*.txt;*.TXT|All files (*.*)|*.*'; @@ -512,9 +487,7 @@ begin tbPrintReport.Enabled := ReportMemo.Lines.Count > 0; tbCopyReport.Enabled := ReportMemo.Lines.Count > 0; - tbSaveChart.Enabled := FChartFrame.Chart.SeriesCount > 0; - tbPrintChart.Enabled := FChartFrame.Chart.SeriesCount > 0; - tbCopyChart.Enabled := FChartFrame.Chart.SeriesCount > 0; + FChartFrame.UpdateButtons; end; diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm index e091d383a..d2454b6a6 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm @@ -166,9 +166,6 @@ inherited UChartForm: TUChartForm end inherited ChartPage: TTabSheet ClientWidth = 470 - inherited ChartToolBar: TToolBar - Width = 466 - end end end inherited SaveDialog: TSaveDialog diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm index e50a00587..939777fb5 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm @@ -257,12 +257,5 @@ inherited XBarChartForm: TXBarChartForm Width = 511 end end - inherited ChartPage: TTabSheet - ClientHeight = 403 - ClientWidth = 427 - inherited ChartToolBar: TToolBar - Width = 423 - end - end end end diff --git a/applications/lazstats/source/frames/chartframeunit.lfm b/applications/lazstats/source/frames/chartframeunit.lfm index 7df5009d2..13c3b2585 100644 --- a/applications/lazstats/source/frames/chartframeunit.lfm +++ b/applications/lazstats/source/frames/chartframeunit.lfm @@ -9,10 +9,10 @@ object ChartFrame: TChartFrame DesignLeft = 518 DesignTop = 150 object Chart: TChart - Left = 0 - Height = 403 - Top = 0 - Width = 620 + Left = 6 + Height = 367 + Top = 30 + Width = 608 AxisList = < item Grid.Color = clSilver @@ -45,8 +45,51 @@ object ChartFrame: TChartFrame ) Toolset = ChartToolset Align = alClient + BorderSpacing.Left = 6 + BorderSpacing.Right = 6 + BorderSpacing.Bottom = 6 Color = clWhite end + object ChartToolBar: TToolBar + Left = 0 + Height = 24 + Top = 0 + Width = 616 + AutoSize = True + BorderSpacing.Right = 4 + BorderSpacing.Bottom = 6 + ButtonHeight = 22 + ButtonWidth = 25 + Caption = 'ChartToolBar' + EdgeBorders = [ebBottom] + Images = MainDataModule.ImageList + TabOrder = 1 + Transparent = True + object tbSaveChart: TToolButton + Left = 1 + Hint = 'Save chart to file' + Top = 0 + Caption = 'Save' + ImageIndex = 4 + OnClick = tbSaveChartClick + end + object tbPrintChart: TToolButton + Left = 26 + Hint = 'Print chart' + Top = 0 + Caption = 'Print' + ImageIndex = 5 + OnClick = tbPrintChartClick + end + object tbCopyChart: TToolButton + Left = 51 + Hint = 'Copy chart to clipboard' + Top = 0 + Caption = 'Copy' + ImageIndex = 7 + OnClick = tbCopyChartClick + end + end object PrintDialog: TPrintDialog Left = 279 Top = 102 diff --git a/applications/lazstats/source/frames/chartframeunit.pas b/applications/lazstats/source/frames/chartframeunit.pas index ea2d49697..a454df7c4 100644 --- a/applications/lazstats/source/frames/chartframeunit.pas +++ b/applications/lazstats/source/frames/chartframeunit.pas @@ -5,9 +5,9 @@ unit ChartFrameUnit; interface uses - Classes, SysUtils, LCLVersion, Forms, Controls, Graphics, ExtDlgs, PrintersDlgs, - TAGraph, TATypes, TACustomSource, TACustomSeries, TASeries, TATools, - Globals; + Classes, SysUtils, LCLVersion, Forms, Controls, Graphics, ExtDlgs, ComCtrls, + PrintersDlgs, TAGraph, TATypes, TACustomSource, TACustomSeries, TASeries, + TATools, Globals; type TPlotType = (ptLines, ptSymbols, ptLinesAndSymbols, ptHorBars, ptVertBars, @@ -17,11 +17,18 @@ type TChartFrame = class(TFrame) Chart: TChart; + ChartToolBar: TToolBar; ChartToolset: TChartToolset; PanDragTool: TPanDragTool; PrintDialog: TPrintDialog; SavePictureDialog: TSavePictureDialog; + tbCopyChart: TToolButton; + tbPrintChart: TToolButton; + tbSaveChart: TToolButton; ZoomDragTool: TZoomDragTool; + procedure tbCopyChartClick(Sender: TObject); + procedure tbPrintChartClick(Sender: TObject); + procedure tbSaveChartClick(Sender: TObject); protected function Constline(xy: Double; ADirection: TLineStyle; AColor: TColor; @@ -43,6 +50,7 @@ type procedure SetTitle(const ATitle: String; Alignment: TAlignment = taCenter); procedure SetXTitle(const ATitle: String); procedure SetYTitle(const ATitle: String); + procedure UpdateButtons; virtual; function VertLine(x: Double; AColor: TColor; ALineStyle: TPenStyle; ALegendTitle: String): TConstantLine; end; @@ -63,6 +71,7 @@ begin ZoomDragTool.LimitToExtent := [zdDown]; PanDragTool.LimitToExtent := [pdDown]; {$IFEND} + UpdateButtons; end; @@ -76,7 +85,6 @@ begin Chart.Legend.Visible := false; end; - function TChartFrame.Constline(xy: Double; ADirection: TLineStyle; AColor: TColor; ALineStyle: TPenStyle; ALegendTitle: String): TConstantLine; begin @@ -88,6 +96,7 @@ begin Result.Title := ALegendTitle; Result.Legend.Visible := ALegendTitle <> ''; Chart.AddSeries(Result); + UpdateButtons; end; @@ -186,6 +195,7 @@ begin Result.Title := LegendTitle; Chart.AddSeries(Result); Chart.Legend.Visible := Chart.SeriesCount > 0; + UpdateButtons; end; @@ -264,5 +274,31 @@ begin end; +procedure TChartFrame.UpdateButtons; +begin + tbSaveChart.Enabled := Chart.SeriesCount > 0; + tbPrintChart.Enabled := Chart.SeriesCount > 0; + tbCopyChart.Enabled := Chart.SeriesCount > 0; +end; + + +procedure TChartFrame.tbSaveChartClick(Sender: TObject); +begin + Save; +end; + + +procedure TChartFrame.tbPrintChartClick(Sender: TObject); +begin + Print; +end; + + +procedure TChartFrame.tbCopyChartClick(Sender: TObject); +begin + Chart.CopyToClipboardBitmap; +end; + + end.