📄 qiplottable.pas
字号:
{*******************************************************}
{ }
{ TiPlotTable }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotTable;{$endif}
{$ifdef iCLX}unit QiPlotTable;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} Menus, iTypes, iGPFunctions, iPlotObjects, iPlotChannelCustom;{$ENDIF}
{$IFDEF iCLX}QMenus, QiTypes, QiGPFunctions, QiPlotObjects, QiPlotChannelCustom;{$ENDIF}
type
TiPlotTableButton = class(TiPlotButton)
public
procedure Draw(const Canvas: TCanvas; const BackGroundColor: TColor); override;
end;
TiPlotTableColumn = class(TObject)
protected
WidthPixels : Integer;
public
Title : String;
Width : Double;
Visible : Boolean;
TitleAlignment : TiAlignmentHorizontal;
TitleAlignmentMargin : Double;
TitleFontColor : TColor;
DataAlignment : TiAlignmentHorizontal;
DataAlignmentMargin : Double;
DataFontColor : TColor;
AutoSize : Boolean;
end;
TiPlotTable = class(TiPlotLayoutObject)
private
FUpButton : TiPlotTableButton;
FDownButton : TiPlotTableButton;
FRequiredWidth : Integer;
FRequiredHeight : Integer;
FColumnList : TStringList;
FRowDataList : TStringList;
FTempStringList : TStringList;
FItemViewStartIndex : Integer;
FItemViewStopIndex : Integer;
FRowHeight : Integer;
FMarginLeft : Double;
FMarginRight : Double;
FMarginBottom : Double;
FMarginTop : Double;
FGridBackGroundTransparent : Boolean;
FGridBackGroundColor : TColor;
FGridLinesShow : Boolean;
FGridLinesColor : TColor;
FColumnSpacing : Double;
FRowSpacing : Double;
FRowsMax : Integer;
FDataFont : TFont;
FGridRect : TRect;
FTitleRect : TRect;
FColumnTitlesVisible : Boolean;
FColumnTitlesFont : TFont;
protected
procedure SetMarginBottom (const Value: Double);
procedure SetMarginLeft (const Value: Double);
procedure SetMarginRight (const Value: Double);
procedure SetMarginTop (const Value: Double);
procedure SetGridBackGroundColor (const Value: TColor);
procedure SetGridBackGroundTransparent(const Value: Boolean);
procedure SetDataFont (const Value: TFont);
procedure SetColumnSpacing (const Value: Double);
procedure SetRowSpacing (const Value: Double);
procedure SetColumnTitlesFont (const Value: TFont);
procedure SetColumnTitlesVisible (const Value: Boolean);
procedure SetGridLinesShow (const Value: Boolean);
procedure SetGridLinesColor (const Value: TColor);
procedure SetRowsMax (const Value: Integer);
procedure CalcRects(Canvas : TCanvas);
function GetColumn (Index: Integer): TiPlotTableColumn;
function GetColumnCount: Integer;
function GetRowCount : Integer;
function GetData (Col, Row: Integer): String;
procedure SetData (Col, Row: Integer; const Value: String);
procedure ButtonInvalidate(Sender : TObject);
procedure UpButtonClick (Sender : TObject);
procedure DownButtonClick (Sender : TObject);
procedure NotificationSetFocus(Sender: TObject); override;
function GetMouseObject(X, Y: Integer): TiPlotObject; override;
function GetRequiredWidth(const Canvas: TCanvas): Integer; override;
procedure AddMenuItems(PopupMenu: TPopUpMenu); override;
procedure DoMouseUp (MouseData: TiPlotMouseData); override;
procedure Draw (const Canvas: TCanvas; const BackGroundColor: TColor); override;
procedure DrawGrid (const Canvas: TCanvas);
procedure DrawColumnTitles(const Canvas: TCanvas);
procedure DrawData (const Canvas: TCanvas);
procedure DrawDownButton (const Canvas: TCanvas);
procedure DrawUpButton (const Canvas: TCanvas);
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
function AddColumn(Title: String): Integer;
function AddRow: Integer;
procedure RemoveAllColumns;
procedure RemoveAllRows;
procedure DeleteColumn(Index: Integer);
procedure DeleteRow (Index: Integer);
property RowCount : Integer read GetRowCount;
property ColumnCount : Integer read GetColumnCount;
property Column[Index: Integer] : TiPlotTableColumn read GetColumn;
property Data[Col, Row: Integer] : String read GetData write SetData;
published
property MarginLeft : Double read FMarginLeft write SetMarginLeft;
property MarginTop : Double read FMarginTop write SetMarginTop;
property MarginRight : Double read FMarginRight write SetMarginRight;
property MarginBottom : Double read FMarginBottom write SetMarginBottom;
property GridBackGroundColor : TColor read FGridBackGroundColor write SetGridBackGroundColor default clGray;
property GridBackGroundTransparent : Boolean read FGridBackGroundTransparent write SetGridBackGroundTransparent default False;
property GridLinesColor : TColor read FGridLinesColor write SetGridLinesColor;
property GridLinesShow : Boolean read FGridLinesShow write SetGridLinesShow;
property DataFont : TFont read FDataFont write SetDataFont;
property ColumnSpacing : Double read FColumnSpacing write SetColumnSpacing;
property RowSpacing : Double read FRowSpacing write SetRowSpacing;
property RowsMax : Integer read FRowsMax write SetRowsMax;
property ColumnTitlesVisible : Boolean read FColumnTitlesVisible write SetColumnTitlesVisible default False;
property ColumnTitlesFont : TFont read FColumnTitlesFont write SetColumnTitlesFont;
end;
implementation
uses
{$ifdef iVCL} iPlotManagers, iPlotComponent;{$endif}
{$ifdef iCLX}QiPlotManagers, QiPlotComponent;{$endif}
type
TiPlotComponentAccess = class(TiPlotComponent)end;
//****************************************************************************************************************************************************
constructor TiPlotTable.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited;
FMarginLeft := 1;
FMarginRight := 1;
FMarginBottom := 1;
FMarginTop := 1;
FGridBackGroundColor := clGray;
FGridBackGroundTransparent := False;
FGridLinesColor := clWhite;
FGridLinesShow := True;
FColumnSpacing := 2;
FRowSpacing := 0.5;
FColumnTitlesVisible := True;
Horizontal := False;
FRowDataList := TStringList.Create;
FColumnList := TStringList.Create;
FTempStringList := TStringList.Create;
FDataFont := TFont.Create; FDataFont.OnChange := TriggerChange; FDataFont.Color := clWhite; FDataFont.Style := [fsBold];
FColumnTitlesFont := TFont.Create; FColumnTitlesFont.OnChange := TriggerChange; FColumnTitlesFont.Color := clAqua; FColumnTitlesFont.Style := [fsBold];
FUpButton := TiPlotTableButton.Create(Owner, nil, nil, nil, nil);
with FUpButton do
begin
Name := 'PlotTableUpButton';
TimerEnabled := True;
OnClick := UpButtonClick;
OnInvalidate := ButtonInvalidate;
end;
FDownButton := TiPlotTableButton.Create(Owner, nil, nil, nil, nil);
with FDownButton do
begin
Name := 'PlotTableDownButton';
TimerEnabled := True;
OnClick := DownButtonClick;
OnInvalidate := ButtonInvalidate;
end;
end;
//****************************************************************************************************************************************************
destructor TiPlotTable.Destroy;
begin
FRowDataList.Free;
RemoveAllColumns;
FColumnList.Free;
FDataFont.Free;
FColumnTitlesFont.Free;
FTempStringList.Free;
FUpButton.Free;
FDownButton.Free;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.AddMenuItems(PopupMenu: TPopUpMenu);
begin
inherited AddMenuItems(PopupMenu);
AddEditMenuItems(PopupMenu);
end;
//****************************************************************************************************************************************************
function TiPlotTable.GetMouseObject(X, Y: Integer): TiPlotObject;
begin
Result := inherited GetMouseObject(X, Y);
if PtInRect(FUpButton.DrawRect, Point(X, Y)) then Result := FUpButton
else if PtInRect(FDownButton.DrawRect, Point(X, Y)) then Result := FDownButton
else
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.SetMarginBottom (const Value:Double );begin SetDoubleProperty (Value,FMarginBottom, TriggerChange);end;
procedure TiPlotTable.SetMarginLeft (const Value:Double );begin SetDoubleProperty (Value,FMarginLeft, TriggerChange);end;
procedure TiPlotTable.SetMarginRight (const Value:Double );begin SetDoubleProperty (Value,FMarginRight, TriggerChange);end;
procedure TiPlotTable.SetMarginTop (const Value:Double );begin SetDoubleProperty (Value,FMarginTop, TriggerChange);end;
procedure TiPlotTable.SetGridBackGroundColor (const Value:TColor );begin SetColorProperty (Value,FGridBackGroundColor, TriggerChange);end;
procedure TiPlotTable.SetGridBackGroundTransparent(const Value:Boolean);begin SetBooleanProperty(Value,FGridBackGroundTransparent,TriggerChange);end;
procedure TiPlotTable.SetColumnSpacing (const Value:Double );begin SetDoubleProperty (Value,FColumnSpacing, TriggerChange);end;
procedure TiPlotTable.SetRowSpacing (const Value:Double );begin SetDoubleProperty (Value,FRowSpacing, TriggerChange);end;
procedure TiPlotTable.SetColumnTitlesVisible (const Value:Boolean);begin SetBooleanProperty(Value,FColumnTitlesVisible, TriggerChange);end;
procedure TiPlotTable.SetGridLinesShow (const Value:Boolean);begin SetBooleanProperty(Value,FGridLinesShow, TriggerChange);end;
procedure TiPlotTable.SetGridLinesColor (const Value:TColor );begin SetColorProperty (Value,FGridLinesColor, TriggerChange);end;
procedure TiPlotTable.SetRowsMax (const Value:Integer);begin SetIntegerProperty(Value,FRowsMax, TriggerChange);end;
//****************************************************************************************************************************************************
procedure TiPlotTable.SetDataFont (const Value:TFont);begin FDataFont.Assign(Value); end;
procedure TiPlotTable.SetColumnTitlesFont(const Value:TFont);begin FColumnTitlesFont.Assign(Value);end;
//****************************************************************************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -