fpspreadsheet: TsWorksheetGrid transfers row height and col width changes to underlying Worksheet. Automatic adjustment of row height if font changes in a chell.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3029 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-08 21:52:04 +00:00
parent 666f399fb1
commit 72bcfc3a5b
5 changed files with 248 additions and 183 deletions

View File

@ -116,7 +116,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="10" Y="7"/>
<UsageCount Value="157"/>
<UsageCount Value="159"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -128,34 +128,34 @@
<UnitName Value="mainform"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="411"/>
<CursorPos X="15" Y="417"/>
<UsageCount Value="157"/>
<Bookmarks Count="1">
<Item0 X="17" Y="438" ID="1"/>
</Bookmarks>
<TopLine Value="313"/>
<CursorPos X="3" Y="341"/>
<UsageCount Value="159"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\fpspreadsheet.pas"/>
<UnitName Value="fpspreadsheet"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="273"/>
<CursorPos X="15" Y="381"/>
<UsageCount Value="73"/>
<TopLine Value="385"/>
<CursorPos X="15" Y="402"/>
<UsageCount Value="74"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<UnitName Value="fpspreadsheetgrid"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="1021"/>
<CursorPos X="1" Y="1027"/>
<UsageCount Value="74"/>
<TopLine Value="1052"/>
<CursorPos X="13" Y="1057"/>
<UsageCount Value="75"/>
<Bookmarks Count="1">
<Item0 X="10" Y="1065" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -224,10 +224,12 @@
<Unit12>
<Filename Value="d:\lazarus-svn\lcl\grids.pas"/>
<UnitName Value="Grids"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="3429"/>
<CursorPos X="1" Y="3434"/>
<UsageCount Value="32"/>
<TopLine Value="6220"/>
<CursorPos X="22" Y="6221"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="..\..\fpsutils.pas"/>
@ -236,7 +238,7 @@
<WindowIndex Value="0"/>
<TopLine Value="35"/>
<CursorPos X="1" Y="62"/>
<UsageCount Value="49"/>
<UsageCount Value="50"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
@ -266,9 +268,9 @@
<UnitName Value="xlsbiff8"/>
<EditorIndex Value="7"/>
<WindowIndex Value="0"/>
<TopLine Value="1881"/>
<CursorPos X="24" Y="1898"/>
<UsageCount Value="48"/>
<TopLine Value="104"/>
<CursorPos X="15" Y="123"/>
<UsageCount Value="49"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
@ -291,9 +293,9 @@
<UnitName Value="xlscommon"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="1530"/>
<CursorPos X="47" Y="1554"/>
<UsageCount Value="44"/>
<TopLine Value="1269"/>
<CursorPos X="1" Y="1286"/>
<UsageCount Value="45"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
@ -303,7 +305,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1319"/>
<CursorPos X="3" Y="1325"/>
<UsageCount Value="31"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit21>
<Unit22>
@ -313,7 +315,7 @@
<WindowIndex Value="0"/>
<TopLine Value="547"/>
<CursorPos X="1" Y="563"/>
<UsageCount Value="32"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
@ -490,134 +492,132 @@
<Unit45>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<UnitName Value="Grids"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="923"/>
<CursorPos X="15" Y="936"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit45>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="mainform.pas"/>
<Caret Line="121" Column="15" TopLine="107"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1766" Column="1" TopLine="1746"/>
</Position1>
<Position2>
<Filename Value="mainform.pas"/>
<Caret Line="122" Column="15" TopLine="108"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1767" Column="1" TopLine="1746"/>
</Position2>
<Position3>
<Filename Value="mainform.pas"/>
<Caret Line="123" Column="15" TopLine="109"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1046" Column="1" TopLine="1027"/>
</Position3>
<Position4>
<Filename Value="mainform.pas"/>
<Caret Line="124" Column="15" TopLine="110"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1277" Column="3" TopLine="1269"/>
</Position4>
<Position5>
<Filename Value="mainform.pas"/>
<Caret Line="125" Column="15" TopLine="111"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1279" Column="1" TopLine="1269"/>
</Position5>
<Position6>
<Filename Value="mainform.pas"/>
<Caret Line="126" Column="15" TopLine="112"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1280" Column="1" TopLine="1269"/>
</Position6>
<Position7>
<Filename Value="mainform.pas"/>
<Caret Line="127" Column="15" TopLine="113"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1281" Column="1" TopLine="1269"/>
</Position7>
<Position8>
<Filename Value="mainform.pas"/>
<Caret Line="128" Column="15" TopLine="114"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1282" Column="1" TopLine="1269"/>
</Position8>
<Position9>
<Filename Value="mainform.pas"/>
<Caret Line="162" Column="18" TopLine="147"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1284" Column="1" TopLine="1269"/>
</Position9>
<Position10>
<Filename Value="mainform.pas"/>
<Caret Line="165" Column="29" TopLine="150"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1285" Column="1" TopLine="1269"/>
</Position10>
<Position11>
<Filename Value="mainform.pas"/>
<Caret Line="162" Column="6" TopLine="153"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1286" Column="1" TopLine="1269"/>
</Position11>
<Position12>
<Filename Value="mainform.pas"/>
<Caret Line="174" Column="19" TopLine="159"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="376" Column="15" TopLine="359"/>
</Position12>
<Position13>
<Filename Value="mainform.pas"/>
<Caret Line="176" Column="46" TopLine="159"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="337" Column="37" TopLine="304"/>
</Position13>
<Position14>
<Filename Value="mainform.pas"/>
<Caret Line="179" Column="18" TopLine="161"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="353" Column="30" TopLine="353"/>
</Position14>
<Position15>
<Filename Value="mainform.pas"/>
<Caret Line="176" Column="41" TopLine="157"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position15>
<Position16>
<Filename Value="mainform.pas"/>
<Caret Line="181" Column="46" TopLine="157"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="333" Column="22" TopLine="328"/>
</Position16>
<Position17>
<Filename Value="mainform.pas"/>
<Caret Line="187" Column="84" TopLine="163"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="35" Column="1" TopLine="33"/>
</Position17>
<Position18>
<Filename Value="mainform.pas"/>
<Caret Line="181" Column="19" TopLine="164"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="38" Column="15" TopLine="19"/>
</Position18>
<Position19>
<Filename Value="mainform.pas"/>
<Caret Line="180" Column="27" TopLine="165"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="354" Column="44" TopLine="322"/>
</Position19>
<Position20>
<Filename Value="mainform.pas"/>
<Caret Line="181" Column="30" TopLine="166"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1184" Column="52" TopLine="1151"/>
</Position20>
<Position21>
<Filename Value="mainform.pas"/>
<Caret Line="425" Column="12" TopLine="410"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="37" Column="15" TopLine="18"/>
</Position21>
<Position22>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="52" Column="23" TopLine="11"/>
<Caret Line="371" Column="91" TopLine="347"/>
</Position22>
<Position23>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="1202" Column="3" TopLine="1199"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="372" Column="33" TopLine="353"/>
</Position23>
<Position24>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="2486" Column="21" TopLine="2461"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="20" Column="1" TopLine="20"/>
</Position24>
<Position25>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="7059" Column="60" TopLine="7035"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1480" Column="24" TopLine="1461"/>
</Position25>
<Position26>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="7804" Column="26" TopLine="7779"/>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1479" Column="14" TopLine="1461"/>
</Position26>
<Position27>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="1028" Column="36" TopLine="1018"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1064" Column="10" TopLine="1051"/>
</Position27>
<Position28>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="1166" Column="28" TopLine="1153"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="353" Column="1" TopLine="348"/>
</Position28>
<Position29>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="1231" Column="25" TopLine="1515"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1070" Column="23" TopLine="1045"/>
</Position29>
<Position30>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
<Caret Line="1202" Column="3" TopLine="1187"/>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<Caret Line="1057" Column="13" TopLine="1052"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -4,7 +4,7 @@ object Form1: TForm1
Top = 258
Width = 636
Caption = 'fpsGrid'
ClientHeight = 381
ClientHeight = 386
ClientWidth = 636
Menu = MainMenu1
OnActivate = FormActivate
@ -14,7 +14,7 @@ object Form1: TForm1
object Panel1: TPanel
Left = 0
Height = 73
Top = 308
Top = 313
Width = 636
Align = alBottom
BevelOuter = bvNone
@ -23,9 +23,9 @@ object Form1: TForm1
TabOrder = 0
object CbShowHeaders: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 11
Width = 116
Width = 93
Caption = 'Show headers'
Checked = True
OnClick = CbShowHeadersClick
@ -34,9 +34,9 @@ object Form1: TForm1
end
object CbShowGridLines: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 36
Width = 125
Width = 100
Caption = 'Show grid lines'
Checked = True
OnClick = CbShowGridLinesClick
@ -45,7 +45,7 @@ object Form1: TForm1
end
object EdFrozenCols: TSpinEdit
Left = 238
Height = 28
Height = 23
Top = 8
Width = 52
OnChange = EdFrozenColsChange
@ -53,7 +53,7 @@ object Form1: TForm1
end
object EdFrozenRows: TSpinEdit
Left = 238
Height = 28
Height = 23
Top = 39
Width = 52
OnChange = EdFrozenRowsChange
@ -61,18 +61,18 @@ object Form1: TForm1
end
object Label1: TLabel
Left = 152
Height = 20
Height = 15
Top = 13
Width = 77
Width = 62
Caption = 'Frozen cols:'
FocusControl = EdFrozenCols
ParentColor = False
end
object Label2: TLabel
Left = 153
Height = 20
Height = 15
Top = 40
Width = 82
Width = 66
Caption = 'Frozen rows:'
FocusControl = EdFrozenRows
ParentColor = False
@ -80,7 +80,7 @@ object Form1: TForm1
end
object PageControl1: TPageControl
Left = 0
Height = 250
Height = 255
Top = 58
Width = 636
ActivePage = TabSheet1
@ -90,11 +90,11 @@ object Form1: TForm1
OnChange = PageControl1Change
object TabSheet1: TTabSheet
Caption = 'Sheet1'
ClientHeight = 217
ClientHeight = 227
ClientWidth = 628
object sWorksheetGrid1: TsWorksheetGrid
Left = 0
Height = 217
Height = 227
Top = 0
Width = 628
FrozenCols = 0
@ -108,7 +108,7 @@ object Form1: TForm1
TitleStyle = tsNative
OnSelectCell = sWorksheetGrid1SelectCell
ColWidths = (
56
42
64
)
end
@ -184,19 +184,19 @@ object Form1: TForm1
end
object FontComboBox: TComboBox
Left = 1
Height = 28
Height = 23
Top = 2
Width = 127
ItemHeight = 20
ItemHeight = 15
OnSelect = FontComboBoxSelect
TabOrder = 0
end
object FontSizeComboBox: TComboBox
Left = 128
Height = 28
Height = 23
Top = 2
Width = 48
ItemHeight = 20
ItemHeight = 15
Items.Strings = (
'8'
'9'

View File

@ -2,74 +2,74 @@
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'r'#1#6'Height'#3#150#1#3'Top'#3#2#1#5'Wid'
+'th'#3'|'#2#7'Caption'#6#7'fpsGrid'#12'ClientHeight'#3'}'#1#11'ClientWidth'#3
+'|'#2#4'Menu'#7#9'MainMenu1'#10'OnActivate'#7#12'FormActivate'#8'OnCreate'#7
+#10'FormCreate'#8'ShowHint'#9#10'LCLVersion'#6#3'1.3'#0#6'TPanel'#6'Panel1'#4
+'Left'#2#0#6'Height'#2'I'#3'Top'#3'4'#1#5'Width'#3'|'#2#5'Align'#7#8'alBotto'
+'m'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'I'#11'ClientWidth'#3'|'#2#8
+'TabOrder'#2#0#0#9'TCheckBox'#13'CbShowHeaders'#4'Left'#2#8#6'Height'#2#24#3
+'Top'#2#11#5'Width'#2't'#7'Caption'#6#12'Show headers'#7'Checked'#9#7'OnClic'
+'k'#7#18'CbShowHeadersClick'#5'State'#7#9'cbChecked'#8'TabOrder'#2#0#0#0#9'T'
+'CheckBox'#15'CbShowGridLines'#4'Left'#2#8#6'Height'#2#24#3'Top'#2'$'#5'Widt'
+'h'#2'}'#7'Caption'#6#15'Show grid lines'#7'Checked'#9#7'OnClick'#7#20'CbSho'
+'wGridLinesClick'#5'State'#7#9'cbChecked'#8'TabOrder'#2#1#0#0#9'TSpinEdit'#12
+'EdFrozenCols'#4'Left'#3#238#0#6'Height'#2#28#3'Top'#2#8#5'Width'#2'4'#8'OnC'
+'hange'#7#18'EdFrozenColsChange'#8'TabOrder'#2#2#0#0#9'TSpinEdit'#12'EdFroze'
+'nRows'#4'Left'#3#238#0#6'Height'#2#28#3'Top'#2''''#5'Width'#2'4'#8'OnChange'
+#7#18'EdFrozenRowsChange'#8'TabOrder'#2#3#0#0#6'TLabel'#6'Label1'#4'Left'#3
+#152#0#6'Height'#2#20#3'Top'#2#13#5'Width'#2'M'#7'Caption'#6#12'Frozen cols:'
+#12'FocusControl'#7#12'EdFrozenCols'#11'ParentColor'#8#0#0#6'TLabel'#6'Label'
+'2'#4'Left'#3#153#0#6'Height'#2#20#3'Top'#2'('#5'Width'#2'R'#7'Caption'#6#12
+'Frozen rows:'#12'FocusControl'#7#12'EdFrozenRows'#11'ParentColor'#8#0#0#0#12
+'TPageControl'#12'PageControl1'#4'Left'#2#0#6'Height'#3#250#0#3'Top'#2':'#5
+'Width'#3'|'#2#10'ActivePage'#7#9'TabSheet1'#5'Align'#7#8'alClient'#8'TabInd'
+'ex'#2#0#8'TabOrder'#2#1#8'OnChange'#7#18'PageControl1Change'#0#9'TTabSheet'
+#9'TabSheet1'#7'Caption'#6#6'Sheet1'#12'ClientHeight'#3#217#0#11'ClientWidth'
+#3't'#2#0#15'TsWorksheetGrid'#15'sWorksheetGrid1'#4'Left'#2#0#6'Height'#3#217
+#0#3'Top'#2#0#5'Width'#3't'#2#10'FrozenCols'#2#0#10'FrozenRows'#2#0#5'Align'
+#7#8'alClient'#8'ColCount'#2#2#14'ExtendedSelect'#8#7'Options'#11#15'goFixed'
+'VertLine'#15'goFixedHorzLine'#10'goVertLine'#10'goHorzLine'#13'goRangeSelec'
+'t'#11'goRowSizing'#11'goColSizing'#15'goThumbTracking'#14'goSmoothScroll'#16
+'goFixedColSizing'#0#8'RowCount'#2#2#8'TabOrder'#2#0#10'TitleStyle'#7#8'tsNa'
+'tive'#12'OnSelectCell'#7#25'sWorksheetGrid1SelectCell'#9'ColWidths'#1#2'8'#2
+'@'#0#0#0#0#0#8'TToolBar'#8'ToolBar1'#4'Left'#2#0#6'Height'#2#26#3'Top'#2#0#5
+'Width'#3'|'#2#12'ButtonHeight'#2#24#7'Caption'#6#8'ToolBar1'#11'EdgeBorders'
+#11#0#6'Images'#7#10'ImageList1'#8'TabOrder'#2#2#0#11'TToolButton'#11'ToolBu'
+'tton1'#4'Left'#2#1#3'Top'#2#0#6'Action'#7#6'AcOpen'#0#0#11'TToolButton'#11
+'ToolButton2'#4'Left'#2#24#3'Top'#2#0#6'Action'#7#8'AcSaveAs'#0#0#11'TToolBu'
+'tton'#11'ToolButton3'#4'Left'#2'P'#3'Top'#2#0#6'Action'#7#6'AcQuit'#0#0#11
+'TToolButton'#11'ToolButton5'#4'Left'#2'/'#3'Top'#2#0#5'Width'#2#5#7'Caption'
+#6#11'ToolButton5'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#11'ToolButt'
+'on4'#4'Left'#2'4'#3'Top'#2#0#6'Action'#7#6'AcEdit'#0#0#11'TToolButton'#11'T'
+'oolButton6'#4'Left'#2'K'#3'Top'#2#0#5'Width'#2#5#7'Caption'#6#11'ToolButton'
+'6'#5'Style'#7#10'tbsDivider'#0#0#0#8'TToolBar'#13'FormatToolBar'#4'Left'#2#0
+#3'Top'#2#26#5'Width'#3'|'#2#12'ButtonHeight'#2#28#7'Caption'#6#13'FormatToo'
+'lBar'#6'Images'#7#10'ImageList1'#8'TabOrder'#2#3#0#11'TToolButton'#12'ToolB'
+'utton10'#4'Left'#3#17#1#3'Top'#2#2#6'Action'#7#11'AcLeftAlign'#0#0#11'TTool'
+'Button'#12'ToolButton12'#4'Left'#3'('#1#3'Top'#2#2#6'Action'#7#16'AcHorCent'
+'erAlign'#0#0#11'TToolButton'#12'ToolButton13'#4'Left'#3'?'#1#3'Top'#2#2#6'A'
+'ction'#7#12'AcRightAlign'#0#0#9'TComboBox'#12'FontComboBox'#4'Left'#2#1#6'H'
+'eight'#2#28#3'Top'#2#2#5'Width'#2#127#10'ItemHeight'#2#20#8'OnSelect'#7#18
+'FontComboBoxSelect'#8'TabOrder'#2#0#0#0#9'TComboBox'#16'FontSizeComboBox'#4
+'Left'#3#128#0#6'Height'#2#28#3'Top'#2#2#5'Width'#2'0'#10'ItemHeight'#2#20#13
+'Items.Strings'#1#6#1'8'#6#1'9'#6#2'10'#6#2'11'#6#2'12'#6#2'14'#6#2'16'#6#2
+'18'#6#2'20'#6#2'24'#0#8'OnSelect'#7#18'FontComboBoxSelect'#8'TabOrder'#2#1#0
+#0#11'TToolButton'#11'ToolButton7'#4'Left'#3#176#0#3'Top'#2#2#6'Action'#7#10
+'AcFontBold'#0#0#11'TToolButton'#11'ToolButton8'#4'Left'#3#199#0#3'Top'#2#2#6
+'Action'#7#12'AcFontItalic'#0#0#11'TToolButton'#11'ToolButton9'#4'Left'#3#222
+#0#3'Top'#2#2#6'Action'#7#15'AcFontUnderline'#0#0#11'TToolButton'#12'ToolBut'
+'ton11'#4'Left'#3#245#0#3'Top'#2#2#6'Action'#7#15'AcFontStrikeout'#0#0#11'TT'
+'oolButton'#12'ToolButton14'#4'Left'#3#12#1#3'Top'#2#2#5'Width'#2#5#7'Captio'
+'n'#6#12'ToolButton14'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#12'Tool'
+'Button15'#4'Left'#3'V'#1#3'Top'#2#2#5'Width'#2#5#7'Caption'#6#12'ToolButton'
+'15'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#12'ToolButton16'#4'Left'#3
+'['#1#3'Top'#2#2#6'Action'#7#11'AcVAlignTop'#0#0#11'TToolButton'#12'ToolButt'
+'on17'#4'Left'#3'r'#1#3'Top'#2#2#6'Action'#7#14'AcVAlignCenter'#0#0#11'TTool'
,'Button'#12'ToolButton18'#4'Left'#3#137#1#3'Top'#2#2#6'Action'#7#14'AcVAlign'
+'Bottom'#0#0#11'TToolButton'#12'ToolButton19'#4'Left'#3#160#1#3'Top'#2#2#5'W'
+'idth'#2#5#7'Caption'#6#12'ToolButton19'#5'Style'#7#10'tbsDivider'#0#0#11'TT'
+'oolButton'#12'ToolButton20'#4'Left'#3#165#1#3'Top'#2#2#6'Action'#7#12'AcBor'
+'derLeft'#0#0#11'TToolButton'#12'ToolButton21'#4'Left'#3#188#1#3'Top'#2#2#6
+'th'#3'|'#2#7'Caption'#6#7'fpsGrid'#12'ClientHeight'#3#130#1#11'ClientWidth'
+#3'|'#2#4'Menu'#7#9'MainMenu1'#10'OnActivate'#7#12'FormActivate'#8'OnCreate'
+#7#10'FormCreate'#8'ShowHint'#9#10'LCLVersion'#6#3'1.3'#0#6'TPanel'#6'Panel1'
+#4'Left'#2#0#6'Height'#2'I'#3'Top'#3'9'#1#5'Width'#3'|'#2#5'Align'#7#8'alBot'
+'tom'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'I'#11'ClientWidth'#3'|'#2
+#8'TabOrder'#2#0#0#9'TCheckBox'#13'CbShowHeaders'#4'Left'#2#8#6'Height'#2#19
+#3'Top'#2#11#5'Width'#2']'#7'Caption'#6#12'Show headers'#7'Checked'#9#7'OnCl'
+'ick'#7#18'CbShowHeadersClick'#5'State'#7#9'cbChecked'#8'TabOrder'#2#0#0#0#9
+'TCheckBox'#15'CbShowGridLines'#4'Left'#2#8#6'Height'#2#19#3'Top'#2'$'#5'Wid'
+'th'#2'd'#7'Caption'#6#15'Show grid lines'#7'Checked'#9#7'OnClick'#7#20'CbSh'
+'owGridLinesClick'#5'State'#7#9'cbChecked'#8'TabOrder'#2#1#0#0#9'TSpinEdit'
+#12'EdFrozenCols'#4'Left'#3#238#0#6'Height'#2#23#3'Top'#2#8#5'Width'#2'4'#8
+'OnChange'#7#18'EdFrozenColsChange'#8'TabOrder'#2#2#0#0#9'TSpinEdit'#12'EdFr'
+'ozenRows'#4'Left'#3#238#0#6'Height'#2#23#3'Top'#2''''#5'Width'#2'4'#8'OnCha'
+'nge'#7#18'EdFrozenRowsChange'#8'TabOrder'#2#3#0#0#6'TLabel'#6'Label1'#4'Lef'
+'t'#3#152#0#6'Height'#2#15#3'Top'#2#13#5'Width'#2'>'#7'Caption'#6#12'Frozen '
+'cols:'#12'FocusControl'#7#12'EdFrozenCols'#11'ParentColor'#8#0#0#6'TLabel'#6
+'Label2'#4'Left'#3#153#0#6'Height'#2#15#3'Top'#2'('#5'Width'#2'B'#7'Caption'
+#6#12'Frozen rows:'#12'FocusControl'#7#12'EdFrozenRows'#11'ParentColor'#8#0#0
+#0#12'TPageControl'#12'PageControl1'#4'Left'#2#0#6'Height'#3#255#0#3'Top'#2
+':'#5'Width'#3'|'#2#10'ActivePage'#7#9'TabSheet1'#5'Align'#7#8'alClient'#8'T'
+'abIndex'#2#0#8'TabOrder'#2#1#8'OnChange'#7#18'PageControl1Change'#0#9'TTabS'
+'heet'#9'TabSheet1'#7'Caption'#6#6'Sheet1'#12'ClientHeight'#3#227#0#11'Clien'
+'tWidth'#3't'#2#0#15'TsWorksheetGrid'#15'sWorksheetGrid1'#4'Left'#2#0#6'Heig'
+'ht'#3#227#0#3'Top'#2#0#5'Width'#3't'#2#10'FrozenCols'#2#0#10'FrozenRows'#2#0
+#5'Align'#7#8'alClient'#8'ColCount'#2#2#14'ExtendedSelect'#8#7'Options'#11#15
+'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLine'#10'goHorzLine'#13'goRan'
+'geSelect'#11'goRowSizing'#11'goColSizing'#15'goThumbTracking'#14'goSmoothSc'
+'roll'#16'goFixedColSizing'#0#8'RowCount'#2#2#8'TabOrder'#2#0#10'TitleStyle'
+#7#8'tsNative'#12'OnSelectCell'#7#25'sWorksheetGrid1SelectCell'#9'ColWidths'
+#1#2'*'#2'@'#0#0#0#0#0#8'TToolBar'#8'ToolBar1'#4'Left'#2#0#6'Height'#2#26#3
+'Top'#2#0#5'Width'#3'|'#2#12'ButtonHeight'#2#24#7'Caption'#6#8'ToolBar1'#11
+'EdgeBorders'#11#0#6'Images'#7#10'ImageList1'#8'TabOrder'#2#2#0#11'TToolButt'
+'on'#11'ToolButton1'#4'Left'#2#1#3'Top'#2#0#6'Action'#7#6'AcOpen'#0#0#11'TTo'
+'olButton'#11'ToolButton2'#4'Left'#2#24#3'Top'#2#0#6'Action'#7#8'AcSaveAs'#0
+#0#11'TToolButton'#11'ToolButton3'#4'Left'#2'P'#3'Top'#2#0#6'Action'#7#6'AcQ'
+'uit'#0#0#11'TToolButton'#11'ToolButton5'#4'Left'#2'/'#3'Top'#2#0#5'Width'#2
+#5#7'Caption'#6#11'ToolButton5'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'
+#11'ToolButton4'#4'Left'#2'4'#3'Top'#2#0#6'Action'#7#6'AcEdit'#0#0#11'TToolB'
+'utton'#11'ToolButton6'#4'Left'#2'K'#3'Top'#2#0#5'Width'#2#5#7'Caption'#6#11
+'ToolButton6'#5'Style'#7#10'tbsDivider'#0#0#0#8'TToolBar'#13'FormatToolBar'#4
+'Left'#2#0#3'Top'#2#26#5'Width'#3'|'#2#12'ButtonHeight'#2#28#7'Caption'#6#13
+'FormatToolBar'#6'Images'#7#10'ImageList1'#8'TabOrder'#2#3#0#11'TToolButton'
+#12'ToolButton10'#4'Left'#3#17#1#3'Top'#2#2#6'Action'#7#11'AcLeftAlign'#0#0
+#11'TToolButton'#12'ToolButton12'#4'Left'#3'('#1#3'Top'#2#2#6'Action'#7#16'A'
+'cHorCenterAlign'#0#0#11'TToolButton'#12'ToolButton13'#4'Left'#3'?'#1#3'Top'
+#2#2#6'Action'#7#12'AcRightAlign'#0#0#9'TComboBox'#12'FontComboBox'#4'Left'#2
+#1#6'Height'#2#23#3'Top'#2#2#5'Width'#2#127#10'ItemHeight'#2#15#8'OnSelect'#7
+#18'FontComboBoxSelect'#8'TabOrder'#2#0#0#0#9'TComboBox'#16'FontSizeComboBox'
+#4'Left'#3#128#0#6'Height'#2#23#3'Top'#2#2#5'Width'#2'0'#10'ItemHeight'#2#15
+#13'Items.Strings'#1#6#1'8'#6#1'9'#6#2'10'#6#2'11'#6#2'12'#6#2'14'#6#2'16'#6
+#2'18'#6#2'20'#6#2'24'#0#8'OnSelect'#7#18'FontComboBoxSelect'#8'TabOrder'#2#1
+#0#0#11'TToolButton'#11'ToolButton7'#4'Left'#3#176#0#3'Top'#2#2#6'Action'#7
+#10'AcFontBold'#0#0#11'TToolButton'#11'ToolButton8'#4'Left'#3#199#0#3'Top'#2
+#2#6'Action'#7#12'AcFontItalic'#0#0#11'TToolButton'#11'ToolButton9'#4'Left'#3
+#222#0#3'Top'#2#2#6'Action'#7#15'AcFontUnderline'#0#0#11'TToolButton'#12'Too'
+'lButton11'#4'Left'#3#245#0#3'Top'#2#2#6'Action'#7#15'AcFontStrikeout'#0#0#11
+'TToolButton'#12'ToolButton14'#4'Left'#3#12#1#3'Top'#2#2#5'Width'#2#5#7'Capt'
+'ion'#6#12'ToolButton14'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#12'To'
+'olButton15'#4'Left'#3'V'#1#3'Top'#2#2#5'Width'#2#5#7'Caption'#6#12'ToolButt'
+'on15'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#12'ToolButton16'#4'Left'
+#3'['#1#3'Top'#2#2#6'Action'#7#11'AcVAlignTop'#0#0#11'TToolButton'#12'ToolBu'
+'tton17'#4'Left'#3'r'#1#3'Top'#2#2#6'Action'#7#14'AcVAlignCenter'#0#0#11'TTo'
,'olButton'#12'ToolButton18'#4'Left'#3#137#1#3'Top'#2#2#6'Action'#7#14'AcVAli'
+'gnBottom'#0#0#11'TToolButton'#12'ToolButton19'#4'Left'#3#160#1#3'Top'#2#2#5
+'Width'#2#5#7'Caption'#6#12'ToolButton19'#5'Style'#7#10'tbsDivider'#0#0#11'T'
+'ToolButton'#12'ToolButton20'#4'Left'#3#165#1#3'Top'#2#2#6'Action'#7#12'AcBo'
+'rderLeft'#0#0#11'TToolButton'#12'ToolButton21'#4'Left'#3#188#1#3'Top'#2#2#6
+'Action'#7#11'AcBorderTop'#0#0#11'TToolButton'#12'ToolButton22'#4'Left'#3#211
+#1#3'Top'#2#2#6'Action'#7#14'AcBorderBottom'#0#0#11'TToolButton'#12'ToolButt'
+'on23'#4'Left'#3#234#1#3'Top'#2#2#6'Action'#7#17'AcBorderBottomDbl'#0#0#11'T'

View File

@ -330,9 +330,11 @@ type
FTopPaneHeight: Integer;
FOptions: TsSheetOptions;
FOnChangeCell: TsCellEvent;
FOnChangeFont: TsCellEvent;
procedure RemoveCallback(data, arg: pointer);
protected
procedure ChangedCell(ARow, ACol: Cardinal);
procedure ChangedFont(ARow, ACol: Cardinal);
public
Name: string;
{ Base methods }
@ -410,6 +412,7 @@ type
property LeftPaneWidth: Integer read FLeftPaneWidth write FLeftPaneWidth;
property TopPaneHeight: Integer read FTopPaneHeight write FTopPaneHeight;
property OnChangeCell: TsCellEvent read FOnChangeCell write FOnChangeCell;
property OnChangeFont: TsCellEvent read FOnChangeFont write FOnChangeFont;
end;
@ -870,6 +873,13 @@ begin
if Assigned(FOnChangeCell) then FOnChangeCell(Self, ARow, ACol);
end;
{ Is called whenever a font height changes. Event can be caught by the grid
to update the row height. }
procedure TsWorksheet.ChangedFont(ARow, ACol: Cardinal);
begin
if Assigned(FonChangeFont) then FOnChangeFont(Self, ARow, ACol);
end;
procedure TsWorksheet.CopyCell(AFromRow, AFromCol, AToRow, AToCol: Cardinal;
AFromWorksheet: TsWorksheet);
var
@ -1466,7 +1476,7 @@ begin
if Result = -1 then
result := FWorkbook.AddFont(AFontName, AFontSize, AFontStyle, AFontColor);
lCell^.FontIndex := Result;
ChangedCell(ARow, ACol);
ChangedFont(ARow, ACol);
end;
procedure TsWorksheet.WriteFont(ARow, ACol: Cardinal; AFontIndex: Integer);
@ -1479,7 +1489,7 @@ begin
lCell := GetCell(ARow, ACol);
Include(lCell^.UsedFormattingFields, uffFont);
lCell^.FontIndex := AFontIndex;
ChangedCell(ARow, ACol);
ChangedFont(ARow, ACol);
end else
raise Exception.Create(lpInvalidFontIndex);
end;
@ -1532,7 +1542,7 @@ begin
ACell := GetCell(ARow, ACol);
Include(ACell^.UsedFormattingFields, uffTextRotation);
ACell^.TextRotation := ARotation;
ChangedCell(ARow, ACol);
ChangedFont(ARow, ACol);
end;
procedure TsWorksheet.WriteUsedFormatting(ARow, ACol: Cardinal;

View File

@ -35,6 +35,7 @@ type
function CalcColWidth(AWidth: Single): Integer;
function CalcRowHeight(AHeight: Single): Integer;
procedure ChangedCellHandler(ASender: TObject; ARow, ACol: Cardinal);
procedure ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
function GetShowGridLines: Boolean;
function GetShowHeaders: Boolean;
procedure SetFrozenCols(AValue: Integer);
@ -51,6 +52,7 @@ type
function GetCellHeight(ACol, ARow: Integer): Integer;
function GetCellText(ACol, ARow: Integer): String;
function GetEditText(ACol, ARow: Integer): String; override;
procedure HeaderSized(IsColumn: Boolean; index: Integer); override;
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
procedure Loaded; override;
procedure LoadFromWorksheet(AWorksheet: TsWorksheet);
@ -314,19 +316,21 @@ begin
inc(FLockCount);
end;
// Converts the column width, given in "characters", to pixels
// Converts the column width, given in "characters" of the default font, to pixels
// All chars are assumed to have the same width defined by the "0".
// Therefore, this calculation is only approximate.
function TsCustomWorksheetGrid.CalcColWidth(AWidth: Single): Integer;
var
w0: Integer;
begin
Convert_sFont_to_Font(FWorkbook.GetFont(0), Canvas.Font);
w0 := Canvas.TextWidth('0');
Result := Round(AWidth * w0);
end;
{ Finds the max cell height per row and uses this to define the RowHeights[].
Returns DefaultRowHeight if the row does not contain any cells. }
Returns DefaultRowHeight if the row does not contain any cells.
ARow is a grid row index. }
function TsCustomWorksheetGrid.CalcAutoRowHeight(ARow: Integer): Integer;
var
c: Integer;
@ -352,6 +356,26 @@ begin
if FLockCount = 0 then Invalidate;
end;
{ Handler for the event that the font has changed in a given cell.
As a consequence, the row height may have to be adapted.
Row/Col coordinates are in worksheet units here! }
procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
var
h: Integer;
lRow: PRow;
begin
if (FWorksheet <> nil) then begin
lRow := FWorksheet.FindRow(ARow);
if lRow = nil then begin
// There is no row record --> row height changes according to font height
// Otherwise the row height would be fixed according to the value in the row record.
ARow := ARow + FHeaderCount; // convert row index to grid units
RowHeights[ARow] := CalcAutoRowHeight(ARow);
end;
Invalidate;
end;
end;
{ Converts a spreadsheet font to a font used for painting (TCanvas.Font). }
procedure TsCustomWorksheetGrid.Convert_sFont_to_Font(sFont: TsFont; AFont: TFont);
begin
@ -880,7 +904,7 @@ begin
end;
{ Returns the height (in pixels) of the cell at ACol/ARow. }
{ Returns the height (in pixels) of the cell at ACol/ARow (of the grid). }
function TsCustomWorksheetGrid.GetCellHeight(ACol, ARow: Integer): Integer;
var
lCell: PCell;
@ -1009,16 +1033,46 @@ begin
Result := FHeaderCount <> 0;
end;
{ Calculates the index of the worksheet column that is displayed in the
given column of the grid. If the sheet headers are turned on, both numbers
differ by 1, otherwise they are equal. Saves an "if" in cases. }
function TsCustomWorksheetGrid.GetWorksheetCol(AGridCol: Integer): cardinal;
begin
Result := AGridCol - FHeaderCount;
end;
{ Calculates the index of the worksheet row that is displayed in the
given row of the grid. If the sheet headers are turned on, both numbers
differ by 1, otherwise they are equal. Save an "if" in cases. }
function TsCustomWorksheetGrid.GetWorksheetRow(AGridRow: Integer): Cardinal;
begin
Result := AGridRow - FHeaderCount;
end;
{ Column width or row heights have changed. Stores the new number in the
worksheet. }
procedure TsCustomWorksheetGrid.HeaderSized(IsColumn: Boolean; index: Integer);
var
w0: Integer;
h: Single;
begin
if FWorksheet = nil then
exit;
Convert_sFont_to_Font(FWorkbook.GetFont(0), Canvas.Font);
if IsColumn then begin
// The grid's column width is in "pixels", the worksheet's column width is
// in "characters".
w0 := Canvas.TextWidth('0');
FWorksheet.WriteColWidth(GetWorksheetCol(Index), ColWidths[Index] div w0);
end else begin
// The grid's row heights are in "pixels", the worksheet's row heights are
// in millimeters.
h := (RowHeights[Index] - 2*constCellPadding) / Screen.PixelsPerInch * 25.4;
FWorksheet.WriteRowHeight(GetWorksheetRow(Index), h);
end;
end;
{ Catches the ESC key during editing in order to restore the old cell text }
procedure TsCustomWorksheetGrid.KeyDown(var Key : Word; Shift : TShiftState);
begin
@ -1034,8 +1088,8 @@ begin
Setup;
end;
{ Is called when editing starts. Stores the old text just in case the user
presses ESC to cancel editing. }
{ Is called when editing starts. Stores the old text just for the case that
the user presses ESC to cancel editing. }
procedure TsCustomWorksheetGrid.SelectEditor;
begin
FOldEditText := GetCellText(Col, Row);
@ -1134,6 +1188,7 @@ begin
FWorksheet := AWorksheet;
if FWorksheet <> nil then begin
FWorksheet.OnChangeCell := @ChangedCellHandler;
FWorksheet.OnChangeFont := @ChangedFontHandler;
ShowHeaders := (soShowHeaders in FWorksheet.Options);
ShowGridLines := (soShowGridLines in FWorksheet.Options);
if (soHasFrozenPanes in FWorksheet.Options) then begin