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
This commit is contained in:
wp_xxyyzz
2018-04-12 20:07:34 +00:00
parent 4b1a4cb70b
commit 7c9bda8104

View File

@ -50,6 +50,9 @@ type
TsHyperlinkClickEvent = procedure(Sender: TObject; TsHyperlinkClickEvent = procedure(Sender: TObject;
const AHyperlink: TsHyperlink) of object; const AHyperlink: TsHyperlink) of object;
TsGetCellTextEvent = procedure(Sender: TObject; AIndex: Integer;
var AText: String) of object;
TsSelPen = class(TPen) TsSelPen = class(TPen)
public public
constructor Create; override; constructor Create; override;
@ -122,6 +125,8 @@ type
FDragStartCol, FDragStartRow: Integer; FDragStartCol, FDragStartRow: Integer;
FOldDragStartCol, FOldDragStartRow: Integer; FOldDragStartCol, FOldDragStartRow: Integer;
FDragSelection: TGridRect; FDragSelection: TGridRect;
FGetRowHeaderText: TsGetCellTextEvent;
FGetColHeaderText: TsGetCellTextEvent;
function CalcAutoRowHeight(ARow: Integer): Integer; function CalcAutoRowHeight(ARow: Integer): Integer;
function CalcColWidthFromSheet(AWidth: Single): Integer; function CalcColWidthFromSheet(AWidth: Single): Integer;
function CalcRowHeightFromSheet(AHeight: Single): Integer; function CalcRowHeightFromSheet(AHeight: Single): Integer;
@ -346,6 +351,10 @@ type
property TextOverflow: Boolean read FTextOverflow write FTextOverflow default false; property TextOverflow: Boolean read FTextOverflow write FTextOverflow default false;
{@@ Event called when an external hyperlink is clicked } {@@ Event called when an external hyperlink is clicked }
property OnClickHyperlink: TsHyperlinkClickEvent read FOnClickHyperlink write FOnClickHyperlink; 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
{ public methods } { public methods }
@ -718,6 +727,10 @@ type
property OnColRowInserted; property OnColRowInserted;
{@@ inherited from ancestors} {@@ inherited from ancestors}
property OnColRowMoved; property OnColRowMoved;
{@@ inherited from TCustomWorksheetGrid}
property OnGetColHeaderText;
{@@ inherited from TCustomWorksheetGrid}
property OnGetRowHeaderText;
(* (*
{@@ inherited from ancestors} {@@ inherited from ancestors}
property OnCompareCells; // apply userdefined sorting to worksheet directly! property OnCompareCells; // apply userdefined sorting to worksheet directly!
@ -3887,12 +3900,16 @@ begin
if (ARow = 0) then if (ARow = 0) then
begin begin
Result := GetColString(ACol - FHeaderCount); Result := GetColString(ACol - FHeaderCount);
if Assigned(FGetColHeaderText) then
FGetColHeaderText(Self, ACol, Result);
exit; exit;
end end
else else
if (ACol = 0) then if (ACol = 0) then
begin begin
Result := IntToStr(ARow); Result := IntToStr(ARow);
if Assigned(FGetRowHeaderText) then
FGetRowHeaderText(Self, ARow, Result);
exit; exit;
end; end;
end; end;