You've already forked lazarus-ccr
fpspreadsheet: Add new property AutoExpand to the WorksheetGrid. Extend fpsgrids demo (no install version) correspondingly.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4451 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -46,41 +46,18 @@ object Form1: TForm1
|
|||||||
OnClick = BtnNewClick
|
OnClick = BtnNewClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object Label2: TLabel
|
|
||||||
Left = 296
|
|
||||||
Height = 15
|
|
||||||
Top = 13
|
|
||||||
Width = 132
|
|
||||||
Caption = 'New text for cell [AB110]:'
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
object EdNewCellText: TEdit
|
|
||||||
Left = 451
|
|
||||||
Height = 23
|
|
||||||
Top = 9
|
|
||||||
Width = 104
|
|
||||||
TabOrder = 3
|
|
||||||
Text = 'Test'
|
|
||||||
end
|
|
||||||
object BtnEnterText: TButton
|
|
||||||
Left = 566
|
|
||||||
Height = 25
|
|
||||||
Top = 8
|
|
||||||
Width = 75
|
|
||||||
Caption = 'Set text'
|
|
||||||
OnClick = BtnEnterTextClick
|
|
||||||
TabOrder = 4
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
object WorksheetGrid: TsWorksheetGrid
|
object WorksheetGrid: TsWorksheetGrid
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 572
|
Height = 576
|
||||||
Top = 36
|
Top = 32
|
||||||
Width = 894
|
Width = 894
|
||||||
AutoCalc = True
|
AutoCalc = True
|
||||||
FrozenCols = 0
|
FrozenCols = 0
|
||||||
FrozenRows = 0
|
FrozenRows = 0
|
||||||
ReadFormulas = False
|
ReadFormulas = False
|
||||||
|
SelectionPen.JoinStyle = pjsMiter
|
||||||
|
SelectionPen.Width = 3
|
||||||
WorkbookSource = WorksheetGrid.internal
|
WorkbookSource = WorksheetGrid.internal
|
||||||
Align = alClient
|
Align = alClient
|
||||||
AutoAdvance = aaDown
|
AutoAdvance = aaDown
|
||||||
@ -95,18 +72,18 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object Panel2: TPanel
|
object Panel2: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 36
|
Height = 32
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 894
|
Width = 894
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 36
|
ClientHeight = 32
|
||||||
ClientWidth = 894
|
ClientWidth = 894
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 9
|
Top = 8
|
||||||
Width = 37
|
Width = 37
|
||||||
Caption = 'Sheets:'
|
Caption = 'Sheets:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
|
@ -17,9 +17,6 @@ type
|
|||||||
BtnOpen: TButton;
|
BtnOpen: TButton;
|
||||||
BtnSave: TButton;
|
BtnSave: TButton;
|
||||||
BtnNew: TButton;
|
BtnNew: TButton;
|
||||||
BtnEnterText: TButton;
|
|
||||||
EdNewCellText: TEdit;
|
|
||||||
Label2: TLabel;
|
|
||||||
SheetsCombo: TComboBox;
|
SheetsCombo: TComboBox;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
OpenDialog: TOpenDialog;
|
OpenDialog: TOpenDialog;
|
||||||
@ -30,7 +27,6 @@ type
|
|||||||
procedure BtnNewClick(Sender: TObject);
|
procedure BtnNewClick(Sender: TObject);
|
||||||
procedure BtnOpenClick(Sender: TObject);
|
procedure BtnOpenClick(Sender: TObject);
|
||||||
procedure BtnSaveClick(Sender: TObject);
|
procedure BtnSaveClick(Sender: TObject);
|
||||||
procedure BtnEnterTextClick(Sender: TObject);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure SheetsComboSelect(Sender: TObject);
|
procedure SheetsComboSelect(Sender: TObject);
|
||||||
private
|
private
|
||||||
@ -201,11 +197,6 @@ begin
|
|||||||
WorksheetGrid.NumberFormat[2,6] := '0.000';
|
WorksheetGrid.NumberFormat[2,6] := '0.000';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.BtnEnterTextClick(Sender: TObject);
|
|
||||||
begin
|
|
||||||
WorksheetGrid.Worksheet.WriteText(109, 27, EdNewCellText.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TForm1.SheetsComboSelect(Sender: TObject);
|
procedure TForm1.SheetsComboSelect(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
WorksheetGrid.SelectSheetByIndex(SheetsCombo.ItemIndex);
|
WorksheetGrid.SelectSheetByIndex(SheetsCombo.ItemIndex);
|
||||||
|
@ -10,18 +10,18 @@ object Form1: TForm1
|
|||||||
LCLVersion = '1.7'
|
LCLVersion = '1.7'
|
||||||
object ButtonPanel: TPanel
|
object ButtonPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 38
|
Height = 42
|
||||||
Top = 382
|
Top = 378
|
||||||
Width = 680
|
Width = 680
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 38
|
ClientHeight = 42
|
||||||
ClientWidth = 680
|
ClientWidth = 680
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object BtnNew: TButton
|
object BtnNew: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'New'
|
Caption = 'New'
|
||||||
OnClick = BtnNewClick
|
OnClick = BtnNewClick
|
||||||
@ -30,7 +30,7 @@ object Form1: TForm1
|
|||||||
object BtnLoad: TButton
|
object BtnLoad: TButton
|
||||||
Left = 94
|
Left = 94
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Load...'
|
Caption = 'Load...'
|
||||||
OnClick = BtnLoadClick
|
OnClick = BtnLoadClick
|
||||||
@ -39,41 +39,24 @@ object Form1: TForm1
|
|||||||
object BtnSave: TButton
|
object BtnSave: TButton
|
||||||
Left = 180
|
Left = 180
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Save...'
|
Caption = 'Save...'
|
||||||
OnClick = BtnSaveClick
|
OnClick = BtnSaveClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object Label1: TLabel
|
object Bevel1: TBevel
|
||||||
Left = 288
|
Left = 0
|
||||||
Height = 15
|
Height = 3
|
||||||
Top = 11
|
Top = 0
|
||||||
Width = 144
|
Width = 680
|
||||||
Caption = 'Enter value for cell [AB110]:'
|
Align = alTop
|
||||||
ParentColor = False
|
Shape = bsTopLine
|
||||||
end
|
|
||||||
object EdCellValue: TEdit
|
|
||||||
Left = 439
|
|
||||||
Height = 23
|
|
||||||
Top = 7
|
|
||||||
Width = 137
|
|
||||||
TabOrder = 3
|
|
||||||
Text = 'Test'
|
|
||||||
end
|
|
||||||
object BtnEnterText: TButton
|
|
||||||
Left = 584
|
|
||||||
Height = 25
|
|
||||||
Top = 6
|
|
||||||
Width = 75
|
|
||||||
Caption = 'Enter text'
|
|
||||||
OnClick = BtnEnterTextClick
|
|
||||||
TabOrder = 4
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object TabControl: TTabControl
|
object TabControl: TTabControl
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 382
|
Height = 345
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 680
|
Width = 680
|
||||||
OnChange = TabControlChange
|
OnChange = TabControlChange
|
||||||
@ -84,6 +67,68 @@ object Form1: TForm1
|
|||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
|
object Panel1: TPanel
|
||||||
|
Left = 0
|
||||||
|
Height = 33
|
||||||
|
Top = 345
|
||||||
|
Width = 680
|
||||||
|
Align = alBottom
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 33
|
||||||
|
ClientWidth = 680
|
||||||
|
TabOrder = 2
|
||||||
|
object Label2: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 15
|
||||||
|
Top = 8
|
||||||
|
Width = 101
|
||||||
|
Caption = 'AutoExpand mode:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object CbAutoExpandOnData: TCheckBox
|
||||||
|
Left = 128
|
||||||
|
Height = 19
|
||||||
|
Top = 6
|
||||||
|
Width = 44
|
||||||
|
Caption = 'Data'
|
||||||
|
OnChange = CbAutoExpandOnDataChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object CbAutoExpandOnNavigation: TCheckBox
|
||||||
|
Left = 184
|
||||||
|
Height = 19
|
||||||
|
Top = 6
|
||||||
|
Width = 78
|
||||||
|
Caption = 'Navigation'
|
||||||
|
OnChange = CbAutoExpandOnNavigationChange
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object Label1: TLabel
|
||||||
|
Left = 288
|
||||||
|
Height = 15
|
||||||
|
Top = 8
|
||||||
|
Width = 144
|
||||||
|
Caption = 'Enter value for cell [AB110]:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object EdCellValue: TEdit
|
||||||
|
Left = 439
|
||||||
|
Height = 23
|
||||||
|
Top = 4
|
||||||
|
Width = 137
|
||||||
|
TabOrder = 2
|
||||||
|
Text = 'Test'
|
||||||
|
end
|
||||||
|
object BtnEnterText: TButton
|
||||||
|
Left = 584
|
||||||
|
Height = 25
|
||||||
|
Top = 3
|
||||||
|
Width = 75
|
||||||
|
Caption = 'Enter text'
|
||||||
|
OnClick = BtnEnterTextClick
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
end
|
||||||
object OpenDialog: TOpenDialog
|
object OpenDialog: TOpenDialog
|
||||||
DefaultExt = '.xls'
|
DefaultExt = '.xls'
|
||||||
Filter = 'Excel spreadsheet (*.xls)|*.xls|Excel XML spreadsheet (*.xlsx)|*.xlsx|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Wikitable (pipes) (.wikitable_pipes)|.wikitable_pipes|All files (*.*)|*.*'
|
Filter = 'Excel spreadsheet (*.xls)|*.xls|Excel XML spreadsheet (*.xlsx)|*.xlsx|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Wikitable (pipes) (.wikitable_pipes)|.wikitable_pipes|All files (*.*)|*.*'
|
||||||
|
@ -14,20 +14,27 @@ type
|
|||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
|
Bevel1: TBevel;
|
||||||
BtnNew: TButton;
|
BtnNew: TButton;
|
||||||
BtnLoad: TButton;
|
BtnLoad: TButton;
|
||||||
BtnSave: TButton;
|
BtnSave: TButton;
|
||||||
BtnEnterText: TButton;
|
BtnEnterText: TButton;
|
||||||
ButtonPanel: TPanel;
|
ButtonPanel: TPanel;
|
||||||
|
CbAutoExpandOnData: TCheckBox;
|
||||||
|
CbAutoExpandOnNavigation: TCheckBox;
|
||||||
EdCellValue: TEdit;
|
EdCellValue: TEdit;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
|
Label2: TLabel;
|
||||||
OpenDialog: TOpenDialog;
|
OpenDialog: TOpenDialog;
|
||||||
|
Panel1: TPanel;
|
||||||
SaveDialog: TSaveDialog;
|
SaveDialog: TSaveDialog;
|
||||||
TabControl: TTabControl;
|
TabControl: TTabControl;
|
||||||
procedure BtnEnterTextClick(Sender: TObject);
|
procedure BtnEnterTextClick(Sender: TObject);
|
||||||
procedure BtnLoadClick(Sender: TObject);
|
procedure BtnLoadClick(Sender: TObject);
|
||||||
procedure BtnNewClick(Sender: TObject);
|
procedure BtnNewClick(Sender: TObject);
|
||||||
procedure BtnSaveClick(Sender: TObject);
|
procedure BtnSaveClick(Sender: TObject);
|
||||||
|
procedure CbAutoExpandOnDataChange(Sender: TObject);
|
||||||
|
procedure CbAutoExpandOnNavigationChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure TabControlChange(Sender: TObject);
|
procedure TabControlChange(Sender: TObject);
|
||||||
private
|
private
|
||||||
@ -65,6 +72,8 @@ begin
|
|||||||
|
|
||||||
// Useful options and properties
|
// Useful options and properties
|
||||||
Grid.Options := Grid.Options + [goColSizing, goRowSizing,
|
Grid.Options := Grid.Options + [goColSizing, goRowSizing,
|
||||||
|
// goAutoAddRows,
|
||||||
|
// goAutoAddRowsSkipContentCheck,
|
||||||
goFixedColSizing, // useful if the spreadsheet contains frozen columns
|
goFixedColSizing, // useful if the spreadsheet contains frozen columns
|
||||||
goEditing, // needed for modifying cell content
|
goEditing, // needed for modifying cell content
|
||||||
goThumbTracking, // see the grid scroll while you drag the scrollbar
|
goThumbTracking, // see the grid scroll while you drag the scrollbar
|
||||||
@ -81,6 +90,9 @@ begin
|
|||||||
Grid.RowCount := 10; // Prepare 10 columns (incl fixed header)
|
Grid.RowCount := 10; // Prepare 10 columns (incl fixed header)
|
||||||
Grid.ColCount := 8; // and 8 rows (incl fixed header) - but grid expands automatically
|
Grid.ColCount := 8; // and 8 rows (incl fixed header) - but grid expands automatically
|
||||||
|
|
||||||
|
CbAutoExpandOnData.Checked := aeData in Grid.AutoExpand;
|
||||||
|
CbAutoExpandOnNavigation.Checked := aeNavigation in Grid.AutoExpand;
|
||||||
|
|
||||||
// Add some cells and formats
|
// Add some cells and formats
|
||||||
Grid.ColWidths[1] := 180;
|
Grid.ColWidths[1] := 180;
|
||||||
Grid.ColWidths[2] := 100;
|
Grid.ColWidths[2] := 100;
|
||||||
@ -90,7 +102,7 @@ begin
|
|||||||
Grid.HorAlignment[1,1] := haCenter;
|
Grid.HorAlignment[1,1] := haCenter;
|
||||||
Grid.CellBorders[1,1, 2,1] := [cbSouth];
|
Grid.CellBorders[1,1, 2,1] := [cbSouth];
|
||||||
Grid.CellBorderStyles[1,1, 2,1, cbSouth] := THICK_BORDER;
|
Grid.CellBorderStyles[1,1, 2,1, cbSouth] := THICK_BORDER;
|
||||||
Grid.BackgroundColors[1,1, 2,1] := RGBToColor(220, 220, 220);
|
Grid.BackgroundColors[1,1, 2,1] := RGBToColor(232, 242, 255);
|
||||||
Grid.CellFontColor[1,1] := clNavy;
|
Grid.CellFontColor[1,1] := clNavy;
|
||||||
Grid.CellFontStyle[1,1] := [fssBold];
|
Grid.CellFontStyle[1,1] := [fssBold];
|
||||||
|
|
||||||
@ -127,6 +139,8 @@ begin
|
|||||||
Grid.Cells[2,6] := '=B2^2*PI()';
|
Grid.Cells[2,6] := '=B2^2*PI()';
|
||||||
Grid.CellComment[2,6] := 'Area of the circle with radius given in cell B2';
|
Grid.CellComment[2,6] := 'Area of the circle with radius given in cell B2';
|
||||||
Grid.NumberFormat[2,6] := '0.000';
|
Grid.NumberFormat[2,6] := '0.000';
|
||||||
|
|
||||||
|
ActiveControl := Grid;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.BtnLoadClick(Sender: TObject);
|
procedure TForm1.BtnLoadClick(Sender: TObject);
|
||||||
@ -186,6 +200,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CbAutoExpandOnDataChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if CbAutoExpandOnData.Checked then
|
||||||
|
Grid.AutoExpand := Grid.AutoExpand + [aeData] else
|
||||||
|
Grid.AutoExpand := Grid.AutoExpand - [aeData];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CbAutoExpandOnNavigationChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if CbAutoExpandOnNavigation.Checked then
|
||||||
|
Grid.AutoExpand := Grid.AutoExpand + [aeNavigation] else
|
||||||
|
Grid.AutoExpand := Grid.AutoExpand - [aeNavigation];
|
||||||
|
end;
|
||||||
|
|
||||||
// Loads first worksheet from file into grid
|
// Loads first worksheet from file into grid
|
||||||
procedure TForm1.LoadFile(const AFileName: String);
|
procedure TForm1.LoadFile(const AFileName: String);
|
||||||
var
|
var
|
||||||
|
@ -36,6 +36,9 @@ type
|
|||||||
|
|
||||||
{ TsCustomWorksheetGrid }
|
{ TsCustomWorksheetGrid }
|
||||||
|
|
||||||
|
TsAutoExpandMode = (aeData, aeNavigation);
|
||||||
|
TsAutoExpandModes = set of TsAutoExpandMode;
|
||||||
|
|
||||||
TsHyperlinkClickEvent = procedure(Sender: TObject;
|
TsHyperlinkClickEvent = procedure(Sender: TObject;
|
||||||
const AHyperlink: TsHyperlink) of object;
|
const AHyperlink: TsHyperlink) of object;
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ type
|
|||||||
FReadFormulas: Boolean;
|
FReadFormulas: Boolean;
|
||||||
FDrawingCell: PCell;
|
FDrawingCell: PCell;
|
||||||
FTextOverflowing: Boolean;
|
FTextOverflowing: Boolean;
|
||||||
|
FAutoExpand: TsAutoExpandModes;
|
||||||
FEnhEditMode: Boolean;
|
FEnhEditMode: Boolean;
|
||||||
FSelPen: TPen;
|
FSelPen: TPen;
|
||||||
FHyperlinkTimer: TTimer;
|
FHyperlinkTimer: TTimer;
|
||||||
@ -169,6 +173,8 @@ type
|
|||||||
{ Protected declarations }
|
{ Protected declarations }
|
||||||
procedure AutoAdjustColumn(ACol: Integer); override;
|
procedure AutoAdjustColumn(ACol: Integer); override;
|
||||||
procedure AutoAdjustRow(ARow: Integer); virtual;
|
procedure AutoAdjustRow(ARow: Integer); virtual;
|
||||||
|
procedure AutoExpandToCol(ACol: Integer; AMode: TsAutoExpandMode);
|
||||||
|
procedure AutoExpandToRow(ARow: Integer; AMode: TsAutoExpandMode);
|
||||||
function CalcWorksheetColWidth(AValue: Integer): Single;
|
function CalcWorksheetColWidth(AValue: Integer): Single;
|
||||||
function CalcWorksheetRowHeight(AValue: Integer): Single;
|
function CalcWorksheetRowHeight(AValue: Integer): Single;
|
||||||
function CellOverflow(ACol, ARow: Integer; AState: TGridDrawState;
|
function CellOverflow(ACol, ARow: Integer; AState: TGridDrawState;
|
||||||
@ -204,21 +210,13 @@ type
|
|||||||
ACellHorAlign: TsHorAlignment; ACellVertAlign: TsVertAlignment;
|
ACellHorAlign: TsHorAlignment; ACellVertAlign: TsVertAlignment;
|
||||||
ATextRot: TsTextRotation; ATextWrap: Boolean; AFontIndex: Integer;
|
ATextRot: TsTextRotation; ATextWrap: Boolean; AFontIndex: Integer;
|
||||||
AOverrideTextColor: TColor; ARichTextParams: TsRichTextParams);
|
AOverrideTextColor: TColor; ARichTextParams: TsRichTextParams);
|
||||||
{
|
|
||||||
procedure InternalDrawTextInCell(AText, AMeasureText: String; ARect: TRect;
|
|
||||||
AJustification: Byte; ACellHorAlign: TsHorAlignment;
|
|
||||||
ACellVertAlign: TsVertAlignment; ATextRot: TsTextRotation;
|
|
||||||
ATextWrap, ReplaceTooLong: Boolean; ARichTextParams: TsRichTextParams);
|
|
||||||
}
|
|
||||||
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
// procedure LoadFromWorksheet(AWorksheet: TsWorksheet);
|
|
||||||
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
||||||
procedure MoveSelection; override;
|
procedure MoveSelection; override;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
// function SelectCell(AGridCol, AGridRow: Integer): Boolean; override;
|
|
||||||
procedure SelectEditor; override;
|
procedure SelectEditor; override;
|
||||||
procedure SelPenChangeHandler(Sender: TObject);
|
procedure SelPenChangeHandler(Sender: TObject);
|
||||||
procedure SetEditText(ACol, ARow: Longint; const AValue: string); override;
|
procedure SetEditText(ACol, ARow: Longint; const AValue: string); override;
|
||||||
@ -228,8 +226,11 @@ type
|
|||||||
function TrimToCell(ACell: PCell): String;
|
function TrimToCell(ACell: PCell): String;
|
||||||
procedure UpdateColWidths(AStartIndex: Integer = 0);
|
procedure UpdateColWidths(AStartIndex: Integer = 0);
|
||||||
procedure UpdateRowHeights(AStartIndex: Integer = 0);
|
procedure UpdateRowHeights(AStartIndex: Integer = 0);
|
||||||
|
|
||||||
{@@ Automatically recalculate formulas whenever a cell value changes. }
|
{@@ Automatically recalculate formulas whenever a cell value changes. }
|
||||||
property AutoCalc: Boolean read FAutoCalc write SetAutoCalc default false;
|
property AutoCalc: Boolean read FAutoCalc write SetAutoCalc default false;
|
||||||
|
{@@ Automatically expand grid dimensions }
|
||||||
|
property AutoExpand: TsAutoExpandModes read FAutoExpand write FAutoExpand;
|
||||||
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
||||||
Deprecated. Use ShowHeaders instead. }
|
Deprecated. Use ShowHeaders instead. }
|
||||||
property DisplayFixedColRow: Boolean read GetShowHeaders write SetShowHeaders default true;
|
property DisplayFixedColRow: Boolean read GetShowHeaders write SetShowHeaders default true;
|
||||||
@ -465,6 +466,8 @@ type
|
|||||||
// inherited from TsCustomWorksheetGrid
|
// inherited from TsCustomWorksheetGrid
|
||||||
{@@ Automatically recalculates the worksheet if a cell value changes. }
|
{@@ Automatically recalculates the worksheet if a cell value changes. }
|
||||||
property AutoCalc;
|
property AutoCalc;
|
||||||
|
{@@ Automatically expand grid dimensions }
|
||||||
|
property AutoExpand default [aeData];
|
||||||
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
||||||
Deprecated. Use ShowHeaders instead. }
|
Deprecated. Use ShowHeaders instead. }
|
||||||
property DisplayFixedColRow; deprecated 'Use ShowHeaders';
|
property DisplayFixedColRow; deprecated 'Use ShowHeaders';
|
||||||
@ -953,6 +956,7 @@ begin
|
|||||||
FSelPen.Color := clBlack;
|
FSelPen.Color := clBlack;
|
||||||
FSelPen.JoinStyle := pjsMiter;
|
FSelPen.JoinStyle := pjsMiter;
|
||||||
FSelPen.OnChange := @SelPenChangeHandler;
|
FSelPen.OnChange := @SelPenChangeHandler;
|
||||||
|
FAutoExpand := [aeData];
|
||||||
FHyperlinkTimer := TTimer.Create(self);
|
FHyperlinkTimer := TTimer.Create(self);
|
||||||
FHyperlinkTimer.Interval := HYPERLINK_TIMER_INTERVAL;
|
FHyperlinkTimer.Interval := HYPERLINK_TIMER_INTERVAL;
|
||||||
FHyperlinkTimer.OnTimer := @HyperlinkTimerElapsed;
|
FHyperlinkTimer.OnTimer := @HyperlinkTimerElapsed;
|
||||||
@ -1032,6 +1036,36 @@ begin
|
|||||||
HeaderSized(false, ARow);
|
HeaderSized(false, ARow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Automatically expands the ColCount such that the specified column fits in
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsCustomWorksheetGrid.AutoExpandToCol(ACol: Integer;
|
||||||
|
AMode: TsAutoExpandMode);
|
||||||
|
begin
|
||||||
|
if ACol >= ColCount then
|
||||||
|
begin
|
||||||
|
if (AMode in FAutoExpand) then
|
||||||
|
ColCount := ACol + 1
|
||||||
|
else
|
||||||
|
raise Exception.Create(rsOperationExceedsColCount);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Automatically expands the RowCount such that the specified column fits in
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsCustomWorksheetGrid.AutoExpandToRow(ARow: Integer;
|
||||||
|
AMode: TsAutoExpandMode);
|
||||||
|
begin
|
||||||
|
if ARow >= RowCount then
|
||||||
|
begin
|
||||||
|
if (AMode in FAutoExpand) then
|
||||||
|
RowCount := ARow + 1
|
||||||
|
else
|
||||||
|
raise Exception.Create(rsOperationExceedsRowCount);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
The BeginUpdate/EndUpdate pair suppresses unnecessary painting of the grid.
|
The BeginUpdate/EndUpdate pair suppresses unnecessary painting of the grid.
|
||||||
Call BeginUpdate to stop refreshing the grid, and call EndUpdate to release
|
Call BeginUpdate to stop refreshing the grid, and call EndUpdate to release
|
||||||
@ -2447,15 +2481,14 @@ begin
|
|||||||
if Assigned(FOnClickHyperlink) then FOnClickHyperlink(self, hlink);
|
if Assigned(FOnClickHyperlink) then FOnClickHyperlink(self, hlink);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Copies the borders of a cell to its neighbors. This avoids the nightmare of
|
Copies the borders of a cell to the correspondig edges of its neighbors.
|
||||||
changing borders due to border conflicts of adjacent cells.
|
This avoids the nightmare of changing borders due to border conflicts
|
||||||
|
of adjacent cells.
|
||||||
|
|
||||||
@param ACell Pointer to the cell
|
@param ACell Pointer to the cell
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.FixNeighborCellBorders(ACell: PCell);
|
procedure TsCustomWorksheetGrid.FixNeighborCellBorders(ACell: PCell);
|
||||||
//Col, ARow: Integer);
|
|
||||||
|
|
||||||
procedure SetNeighborBorder(NewRow, NewCol: Cardinal;
|
procedure SetNeighborBorder(NewRow, NewCol: Cardinal;
|
||||||
ANewBorder: TsCellBorder; const ANewBorderStyle: TsCellBorderStyle;
|
ANewBorder: TsCellBorder; const ANewBorderStyle: TsCellBorderStyle;
|
||||||
@ -2481,21 +2514,19 @@ procedure TsCustomWorksheetGrid.FixNeighborCellBorders(ACell: PCell);
|
|||||||
var
|
var
|
||||||
fmt: PsCellFormat;
|
fmt: PsCellFormat;
|
||||||
begin
|
begin
|
||||||
if Worksheet = nil then
|
if (Worksheet = nil) or (ACell = nil) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
// cell := Worksheet.FindCell(GetWorksheetRow(ARow), GetWorksheetCol(ACol));
|
with ACell^ do
|
||||||
if (Worksheet <> nil) and (ACell <> nil) then
|
begin
|
||||||
with ACell^ do
|
fmt := Workbook.GetPointerToCellFormat(ACell^.FormatIndex);
|
||||||
begin
|
if Col > 0 then
|
||||||
fmt := Workbook.GetPointerToCellFormat(ACell^.FormatIndex);
|
SetNeighborBorder(Row, Col-1, cbEast, fmt^.BorderStyles[cbWest], cbWest in fmt^.Border);
|
||||||
if Col > 0 then
|
SetNeighborBorder(Row, Col+1, cbWest, fmt^.BorderStyles[cbEast], cbEast in fmt^.Border);
|
||||||
SetNeighborBorder(Row, Col-1, cbEast, fmt^.BorderStyles[cbWest], cbWest in fmt^.Border);
|
if Row > 0 then
|
||||||
SetNeighborBorder(Row, Col+1, cbWest, fmt^.BorderStyles[cbEast], cbEast in fmt^.Border);
|
SetNeighborBorder(Row-1, Col, cbSouth, fmt^.BorderStyles[cbNorth], cbNorth in fmt^.Border);
|
||||||
if Row > 0 then
|
SetNeighborBorder(Row+1, Col, cbNorth, fmt^.BorderStyles[cbSouth], cbSouth in fmt^.Border);
|
||||||
SetNeighborBorder(Row-1, Col, cbSouth, fmt^.BorderStyles[cbNorth], cbNorth in fmt^.Border);
|
end;
|
||||||
SetNeighborBorder(Row+1, Col, cbNorth, fmt^.BorderStyles[cbSouth], cbSouth in fmt^.Border);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
(*
|
||||||
@ -2755,7 +2786,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Returns the font to be used when painting text in a cell.
|
Returns the (LCL) font to be used when painting text in a cell.
|
||||||
|
|
||||||
@param ACol Grid column index of the cell
|
@param ACol Grid column index of the cell
|
||||||
@param ARow Grid row index of the cell
|
@param ARow Grid row index of the cell
|
||||||
@ -2781,8 +2812,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Returns the font to be used when painting text in the cells defined by the
|
Returns the (LCL) font to be used when painting text in the cells defined
|
||||||
rectangle of row/column indexes.
|
by the rectangle of row/column indexes.
|
||||||
|
|
||||||
@param ALeft Index of the left column of the cell range
|
@param ALeft Index of the left column of the cell range
|
||||||
@param ATop Index of the top row of the cell range
|
@param ATop Index of the top row of the cell range
|
||||||
@ -2949,6 +2980,7 @@ begin
|
|||||||
|
|
||||||
// Read comment
|
// Read comment
|
||||||
comment := Worksheet.ReadComment(cell);
|
comment := Worksheet.ReadComment(cell);
|
||||||
|
|
||||||
// Read hyperlink info
|
// Read hyperlink info
|
||||||
if Worksheet.HasHyperlink(cell) then begin
|
if Worksheet.HasHyperlink(cell) then begin
|
||||||
hlink := Worksheet.FindHyperlink(cell);
|
hlink := Worksheet.FindHyperlink(cell);
|
||||||
@ -2970,6 +3002,7 @@ begin
|
|||||||
if (Result = '') and (comment <> '') then
|
if (Result = '') and (comment <> '') then
|
||||||
Result := comment;
|
Result := comment;
|
||||||
|
|
||||||
|
// Call hint event handler
|
||||||
if Assigned(OnGetCellHint) then
|
if Assigned(OnGetCellHint) then
|
||||||
OnGetCellHint(self, ACol, ARow, Result);
|
OnGetCellHint(self, ACol, ARow, Result);
|
||||||
end;
|
end;
|
||||||
@ -3608,21 +3641,45 @@ end;
|
|||||||
*)
|
*)
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Standard key handling method inherited from TCustomGrid. Is overridden to
|
Standard key handling method inherited from TCustomGrid. Is overridden to
|
||||||
catch the ESC key during editing in order to restore the old cell text
|
catch some keys for special processing.
|
||||||
|
|
||||||
@param Key Key which has been pressed
|
@param Key Key which has been pressed
|
||||||
@param Shift Additional shift keys which are pressed
|
@param Shift Additional shift keys which are pressed
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.KeyDown(var Key : Word; Shift : TShiftState);
|
procedure TsCustomWorksheetGrid.KeyDown(var Key : Word; Shift : TShiftState);
|
||||||
|
var
|
||||||
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
if (Key = VK_F2) then
|
case Key of
|
||||||
FEnhEditMode := true
|
VK_RIGHT:
|
||||||
else
|
if (aeNavigation in FAutoExpand) and (Col = ColCount-1) then
|
||||||
if (Key = VK_ESCAPE) and FEditing then begin
|
ColCount := ColCount + 1;
|
||||||
SetEditText(Col, Row, FOldEditText);
|
VK_DOWN:
|
||||||
EditorHide;
|
if (aeNavigation in FAutoExpand) and (Row = RowCount-1) then
|
||||||
exit;
|
RowCount := RowCount + 1;
|
||||||
|
VK_END:
|
||||||
|
if (aeNavigation in FAutoExpand) and (Col = ColCount-1) then
|
||||||
|
begin
|
||||||
|
R := GCache.FullVisibleGrid;
|
||||||
|
ColCount := ColCount + R.Right - R.Left;
|
||||||
|
end;
|
||||||
|
VK_NEXT: // Page down
|
||||||
|
if (aeNavigation in FAutoExpand) and (Row = RowCount-1) then
|
||||||
|
begin
|
||||||
|
R := GCache.FullVisibleGrid;
|
||||||
|
RowCount := Row + R.Bottom - R.Top;
|
||||||
|
end;
|
||||||
|
VK_F2:
|
||||||
|
FEnhEditMode := true;
|
||||||
|
VK_ESCAPE:
|
||||||
|
if FEditing then
|
||||||
|
begin
|
||||||
|
SetEditText(Col, Row, FOldEditText);
|
||||||
|
EditorHide;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3776,10 +3833,8 @@ begin
|
|||||||
if (cell <> nil) then begin
|
if (cell <> nil) then begin
|
||||||
grow := GetGridRow(cell^.Row);
|
grow := GetGridRow(cell^.Row);
|
||||||
gcol := GetGridCol(cell^.Col);
|
gcol := GetGridCol(cell^.Col);
|
||||||
if grow >= RowCount then
|
AutoExpandToRow(grow, aeData);
|
||||||
RowCount := grow + 1;
|
AutoExpandToCol(gcol, aeData);
|
||||||
if gcol >= ColCount then
|
|
||||||
ColCount := gcol + 1;
|
|
||||||
end;
|
end;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
@ -3789,10 +3844,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
grow := GetGridRow(Worksheet.ActiveCellRow);
|
grow := GetGridRow(Worksheet.ActiveCellRow);
|
||||||
gcol := GetGridCol(Worksheet.ActiveCellCol);
|
gcol := GetGridCol(Worksheet.ActiveCellCol);
|
||||||
if grow >= RowCount then
|
AutoExpandToRow(grow, aeNavigation);
|
||||||
RowCount := grow + 1;
|
AutoExpandToCol(gcol, aeNavigation);
|
||||||
if gcol >= ColCount then
|
|
||||||
ColCount := gcol + 1;
|
|
||||||
if (grow <> Row) or (gcol <> Col) then
|
if (grow <> Row) or (gcol <> Col) then
|
||||||
MoveExtend(false, gcol, grow);
|
MoveExtend(false, gcol, grow);
|
||||||
end;
|
end;
|
||||||
@ -3808,8 +3861,7 @@ begin
|
|||||||
if (lniRow in AChangedItems) and (Worksheet <> nil) then
|
if (lniRow in AChangedItems) and (Worksheet <> nil) then
|
||||||
begin
|
begin
|
||||||
grow := GetGridRow({%H-}PtrInt(AData));
|
grow := GetGridRow({%H-}PtrInt(AData));
|
||||||
if grow >= RowCount then
|
AutoExpandToRow(grow, aeData);
|
||||||
RowCount := grow + 1;
|
|
||||||
RowHeights[grow] := CalcAutoRowHeight(grow);
|
RowHeights[grow] := CalcAutoRowHeight(grow);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4150,8 +4202,6 @@ begin
|
|||||||
|
|
||||||
if (Worksheet = nil) or (Worksheet.GetCellCount = 0) then begin
|
if (Worksheet = nil) or (Worksheet.GetCellCount = 0) then begin
|
||||||
if ShowHeaders then begin
|
if ShowHeaders then begin
|
||||||
// ColCount := FInitColCount + 1; //2;
|
|
||||||
// RowCount := FInitRowCount + 1; //2;
|
|
||||||
FixedCols := 1;
|
FixedCols := 1;
|
||||||
FixedRows := 1;
|
FixedRows := 1;
|
||||||
ColWidths[0] := GetDefaultHeaderColWidth;
|
ColWidths[0] := GetDefaultHeaderColWidth;
|
||||||
@ -4159,8 +4209,6 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
FixedCols := 0;
|
FixedCols := 0;
|
||||||
FixedRows := 0;
|
FixedRows := 0;
|
||||||
// ColCount := FInitColCount; //0;
|
|
||||||
// RowCount := FInitRowCount; //0;
|
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
if Worksheet <> nil then begin
|
if Worksheet <> nil then begin
|
||||||
@ -4168,8 +4216,6 @@ begin
|
|||||||
Canvas.Font.Assign(Font);
|
Canvas.Font.Assign(Font);
|
||||||
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex) + 1, ColCount);
|
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex) + 1, ColCount);
|
||||||
RowCount := Max(GetGridRow(Worksheet.GetLastRowIndex) + 1, RowCount);
|
RowCount := Max(GetGridRow(Worksheet.GetLastRowIndex) + 1, RowCount);
|
||||||
//ColCount := Max(integer(Worksheet.GetLastColIndex) + 1 + FHeaderCount, FInitColCount);
|
|
||||||
//RowCount := Max(integer(Worksheet.GetLastRowIndex) + 1 + FHeaderCount, FInitRowCount);
|
|
||||||
FixedCols := FFrozenCols + FHeaderCount;
|
FixedCols := FFrozenCols + FHeaderCount;
|
||||||
FixedRows := FFrozenRows + FHeaderCount;
|
FixedRows := FFrozenRows + FHeaderCount;
|
||||||
if ShowHeaders then begin
|
if ShowHeaders then begin
|
||||||
|
@ -163,6 +163,9 @@ resourcestring
|
|||||||
rsErrArgError = '#N/A';
|
rsErrArgError = '#N/A';
|
||||||
rsErrFormulaNotSupported = '<FORMULA?>';
|
rsErrFormulaNotSupported = '<FORMULA?>';
|
||||||
|
|
||||||
|
rsOperationExceedsColCount = 'This operation exceeds the range of defined grid columns.';
|
||||||
|
rsOperationExceedsRowCount = 'This operation exceeds the range of defined grid rows.';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user