From 7c9bda810433c03917d72f363ba6dd444f475deb Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 12 Apr 2018 20:07:34 +0000 Subject: [PATCH] fpspreadsheet: Add events OnGetColHeaderText and OnGetRowHeaderText to override the default column and row header captions of the WorksheetGrid. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6302 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/visual/fpspreadsheetgrid.pas | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas b/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas index fb5ade7c3..b58cdbd97 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas @@ -50,6 +50,9 @@ type TsHyperlinkClickEvent = procedure(Sender: TObject; const AHyperlink: TsHyperlink) of object; + TsGetCellTextEvent = procedure(Sender: TObject; AIndex: Integer; + var AText: String) of object; + TsSelPen = class(TPen) public constructor Create; override; @@ -122,6 +125,8 @@ type FDragStartCol, FDragStartRow: Integer; FOldDragStartCol, FOldDragStartRow: Integer; FDragSelection: TGridRect; + FGetRowHeaderText: TsGetCellTextEvent; + FGetColHeaderText: TsGetCellTextEvent; function CalcAutoRowHeight(ARow: Integer): Integer; function CalcColWidthFromSheet(AWidth: Single): Integer; function CalcRowHeightFromSheet(AHeight: Single): Integer; @@ -346,6 +351,10 @@ type property TextOverflow: Boolean read FTextOverflow write FTextOverflow default false; {@@ Event called when an external hyperlink is clicked } property OnClickHyperlink: TsHyperlinkClickEvent read FOnClickHyperlink write FOnClickHyperlink; + {@@ Event allowing to modifiy the text displayed in a column header} + property OnGetColHeaderText: TsGetCellTextEvent read FGetColHeaderText write FGetColHeaderText; + {@@ Event allowing to modifiy the text displayed in a row header } + property OnGetRowHeaderText: TsGetCellTextEvent read FGetRowHeaderText write FGetRowHeaderText; public { public methods } @@ -718,6 +727,10 @@ type property OnColRowInserted; {@@ inherited from ancestors} property OnColRowMoved; + {@@ inherited from TCustomWorksheetGrid} + property OnGetColHeaderText; + {@@ inherited from TCustomWorksheetGrid} + property OnGetRowHeaderText; (* {@@ inherited from ancestors} property OnCompareCells; // apply userdefined sorting to worksheet directly! @@ -3887,12 +3900,16 @@ begin if (ARow = 0) then begin Result := GetColString(ACol - FHeaderCount); + if Assigned(FGetColHeaderText) then + FGetColHeaderText(Self, ACol, Result); exit; end else if (ACol = 0) then begin Result := IntToStr(ARow); + if Assigned(FGetRowHeaderText) then + FGetRowHeaderText(Self, ARow, Result); exit; end; end;