git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6603 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-16 07:32:19 +00:00
parent e86f39a03c
commit f02c683315

View File

@ -131,6 +131,7 @@ type
FRefocusing: TObject; FRefocusing: TObject;
FRefocusingSelStart: Integer; FRefocusingSelStart: Integer;
FFormulaError: Boolean; FFormulaError: Boolean;
FFixedColWidth: Integer;
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;
@ -165,6 +166,7 @@ type
function GetColWidths(ACol: Integer): Integer; function GetColWidths(ACol: Integer): Integer;
function GetDefColWidth: Integer; function GetDefColWidth: Integer;
function GetDefRowHeight: Integer; function GetDefRowHeight: Integer;
function GetFixedColWidth: Integer;
function GetHorAlignment(ACol, ARow: Integer): TsHorAlignment; function GetHorAlignment(ACol, ARow: Integer): TsHorAlignment;
function GetHorAlignments(ALeft, ATop, ARight, ABottom: Integer): TsHorAlignment; function GetHorAlignments(ALeft, ATop, ARight, ABottom: Integer): TsHorAlignment;
function GetHyperlink(ACol, ARow: Integer): String; function GetHyperlink(ACol, ARow: Integer): String;
@ -210,6 +212,7 @@ type
procedure SetDefColWidth(AValue: Integer); procedure SetDefColWidth(AValue: Integer);
procedure SetDefRowHeight(AValue: Integer); procedure SetDefRowHeight(AValue: Integer);
procedure SetEditorLineMode(AValue: TsEditorLineMode); procedure SetEditorLineMode(AValue: TsEditorLineMode);
procedure SetFixedColWidth(AValue: Integer);
procedure SetFrozenCols(AValue: Integer); procedure SetFrozenCols(AValue: Integer);
procedure SetFrozenBorderPen(AValue: TPen); procedure SetFrozenBorderPen(AValue: TPen);
procedure SetFrozenRows(AValue: Integer); procedure SetFrozenRows(AValue: Integer);
@ -287,7 +290,6 @@ type
function GetCellText(ACol, ARow: Integer; ATrim: Boolean = true): String; function GetCellText(ACol, ARow: Integer; ATrim: Boolean = true): String;
function GetEditText(ACol, ARow: Integer): String; override; function GetEditText(ACol, ARow: Integer): String; override;
function GetDefaultColumnTitle(Column: Integer): string; override; function GetDefaultColumnTitle(Column: Integer): string; override;
function GetDefaultHeaderColWidth: Integer;
function HasBorder(ACell: PCell; ABorder: TsCellBorder): Boolean; function HasBorder(ACell: PCell; ABorder: TsCellBorder): Boolean;
procedure HeaderSizing(const IsColumn:boolean; const AIndex,ASize:Integer); override; procedure HeaderSizing(const IsColumn:boolean; const AIndex,ASize:Integer); override;
procedure HeaderSized(IsColumn: Boolean; AIndex: Integer); override; procedure HeaderSized(IsColumn: Boolean; AIndex: Integer); override;
@ -342,6 +344,9 @@ type
{@@ Determines whether a single- or multi-line cell editor is used } {@@ Determines whether a single- or multi-line cell editor is used }
property EditorLineMode: TsEditorLineMode read FLineMode write SetEditorLineMode property EditorLineMode: TsEditorLineMode read FLineMode write SetEditorLineMode
default elmSingleLine; default elmSingleLine;
{@@ Width of the fixed row header column. 0 = auto width detection }
property FixedColWidth: Integer read GetFixedColWidth
write SetFixedColWidth default 0;
{@@ This number of columns at the left is "frozen", i.e. it is not possible to {@@ This number of columns at the left is "frozen", i.e. it is not possible to
scroll these columns } scroll these columns }
property FrozenCols: Integer read FFrozenCols write SetFrozenCols; property FrozenCols: Integer read FFrozenCols write SetFrozenCols;
@ -612,6 +617,8 @@ type
property DisplayFixedColRow; deprecated 'Use ShowHeaders'; property DisplayFixedColRow; deprecated 'Use ShowHeaders';
{@@ Determines whether a single- or multiline cell editor is used } {@@ Determines whether a single- or multiline cell editor is used }
property EditorLineMode; property EditorLineMode;
{@@ Width of the first fixed column (= row headers), in pixels }
property FixedColWidth;
{@@ Pen for the line separating the frozen cols/rows from the regular grid } {@@ Pen for the line separating the frozen cols/rows from the regular grid }
property FrozenBorderPen; property FrozenBorderPen;
{@@ This number of columns at the left is "frozen", i.e. it is not possible to {@@ This number of columns at the left is "frozen", i.e. it is not possible to
@ -3934,14 +3941,6 @@ begin
end; end;
{@@ ----------------------------------------------------------------------------
Returns the width of the fixed header column 0, in pixels
-------------------------------------------------------------------------------}
function TsCustomWorksheetGrid.GetDefaultHeaderColWidth: Integer;
begin
Result := Canvas.TextWidth(' 9999999 ');
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Determines the text to be passed to the cell editor. The text is determined Determines the text to be passed to the cell editor. The text is determined
from the underlying worksheet cell, but it is possible to intercept this by from the underlying worksheet cell, but it is possible to intercept this by
@ -4061,6 +4060,18 @@ begin
Result := false; Result := false;
end; end;
{@@ ----------------------------------------------------------------------------
Returns the width of the fixed header column 0, in pixels
-------------------------------------------------------------------------------}
function TsCustomWorksheetGrid.GetFixedColWidth: Integer;
begin
if FFixedColWidth = 0 then begin
PrepareCanvasFont;
Result := Canvas.TextWidth(' 9999999 ');
end else
Result := FFixedColWidth;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Converts a column index of the worksheet to a column index usable in the grid. Converts a column index of the worksheet to a column index usable in the grid.
This is required because worksheet indexes always start at zero while This is required because worksheet indexes always start at zero while
@ -4219,14 +4230,14 @@ var
idx: Integer; idx: Integer;
w, h, wdef, hdef: Single; w, h, wdef, hdef: Single;
begin begin
if (Worksheet = nil) or (FZoomLock <> 0) then if (Worksheet = nil) or (FZoomLock <> 0) or (AIndex < FHeaderCount) then
exit; exit;
if IsColumn then if IsColumn then
begin begin
w := CalcWorksheetColWidth(ColWidths[AIndex]); // w and wdef are at 100% zoom w := CalcWorksheetColWidth(ColWidths[AIndex]); // w and wdef are at 100% zoom
wdef := Worksheet.ReadDefaultColWidth(Workbook.Units); wdef := Worksheet.ReadDefaultColWidth(Workbook.Units);
if (AIndex >= FHeaderCount) and not SameValue(w, wdef, EPS) then begin if not SameValue(w, wdef, EPS) then begin
idx := GetWorksheetCol(AIndex); idx := GetWorksheetCol(AIndex);
Worksheet.WriteColWidth(idx, w, Workbook.Units); Worksheet.WriteColWidth(idx, w, Workbook.Units);
end; end;
@ -4234,7 +4245,7 @@ begin
begin begin
h := CalcWorksheetRowHeight(RowHeights[AIndex]); h := CalcWorksheetRowHeight(RowHeights[AIndex]);
hdef := Worksheet.ReadDefaultRowHeight(Workbook.Units); hdef := Worksheet.ReadDefaultRowHeight(Workbook.Units);
if (AIndex >= FHeaderCount) and not SameValue(h, hdef, EPS) then begin if not SameValue(h, hdef, EPS) then begin
idx := GetWorksheetRow(AIndex); idx := GetWorksheetRow(AIndex);
Worksheet.WriteRowHeight(idx, h, Workbook.Units); Worksheet.WriteRowHeight(idx, h, Workbook.Units);
end; end;
@ -5351,7 +5362,7 @@ begin
FixedRows := FFrozenRows + FHeaderCount; FixedRows := FFrozenRows + FHeaderCount;
if ShowHeaders then begin if ShowHeaders then begin
PrepareCanvasFont; // Applies the zoom factor PrepareCanvasFont; // Applies the zoom factor
ColWidths[0] := GetDefaultHeaderColWidth; ColWidths[0] := GetFixedColWidth;
RowHeights[0] := GetDefaultRowHeight; RowHeights[0] := GetDefaultRowHeight;
end; end;
FTopLeft := CalcTopLeft(false); FTopLeft := CalcTopLeft(false);
@ -5365,7 +5376,7 @@ begin
FixedRows := FFrozenRows + FHeaderCount; FixedRows := FFrozenRows + FHeaderCount;
if ShowHeaders then begin if ShowHeaders then begin
PrepareCanvasFont; PrepareCanvasFont;
ColWidths[0] := GetDefaultHeaderColWidth; ColWidths[0] := GetFixedColWidth;
RowHeights[0] := GetDefaultRowHeight; RowHeights[0] := GetDefaultRowHeight;
end; end;
FTopLeft := CalcTopLeft(false); FTopLeft := CalcTopLeft(false);
@ -6620,7 +6631,7 @@ begin
inherited DefaultColWidth := AValue; inherited DefaultColWidth := AValue;
if (FHeaderCount > 0) and HandleAllocated then begin if (FHeaderCount > 0) and HandleAllocated then begin
PrepareCanvasFont; PrepareCanvasFont;
ColWidths[0] := GetDefaultHeaderColWidth; ColWidths[0] := GetFixedColWidth;
end; end;
if (FZoomLock = 0) and (Worksheet <> nil) then if (FZoomLock = 0) and (Worksheet <> nil) then
Worksheet.WriteDefaultColWidth(CalcWorksheetColWidth(GetDefColWidth), Workbook.Units); Worksheet.WriteDefaultColWidth(CalcWorksheetColWidth(GetDefColWidth), Workbook.Units);
@ -6657,6 +6668,17 @@ begin
end; end;
end; end;
procedure TsCustomWorksheetGrid.SetFixedColWidth(AValue: Integer);
begin
if FFixedColWidth = AValue then exit;
FFixedColWidth := AValue;
if FHeaderCount > 0 then
begin
ColWidths[0] := GetFixedColWidth;
FTopLeft := CalcTopLeft(false);
end;
end;
procedure TsCustomWorksheetGrid.SetFrozenBorderPen(AValue: TPen); procedure TsCustomWorksheetGrid.SetFrozenBorderPen(AValue: TPen);
begin begin
FFrozenBorderPen.Assign(AValue); FFrozenBorderPen.Assign(AValue);