mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 12:59:11 +02:00
rows/cols captions for spreadsheet example
git-svn-id: trunk@17010 -
This commit is contained in:
parent
9181c5ec3c
commit
6762eefc2f
@ -51,7 +51,7 @@ object Form1: TForm1
|
|||||||
BorderSpacing.CellAlignHorizontal = ccaFill
|
BorderSpacing.CellAlignHorizontal = ccaFill
|
||||||
BorderSpacing.CellAlignVertical = ccaFill
|
BorderSpacing.CellAlignVertical = ccaFill
|
||||||
BorderStyle = bsSingle
|
BorderStyle = bsSingle
|
||||||
ColCount = 255
|
ColCount = 257
|
||||||
DefaultColWidth = 90
|
DefaultColWidth = 90
|
||||||
DefaultDrawing = True
|
DefaultDrawing = True
|
||||||
DragCursor = crDrag
|
DragCursor = crDrag
|
||||||
@ -80,6 +80,7 @@ object Form1: TForm1
|
|||||||
UseXORFeatures = False
|
UseXORFeatures = False
|
||||||
Visible = True
|
Visible = True
|
||||||
OnBeforeSelection = gridBeforeSelection
|
OnBeforeSelection = gridBeforeSelection
|
||||||
|
OnDrawCell = gridDrawCell
|
||||||
OnPrepareCanvas = gridPrepareCanvas
|
OnPrepareCanvas = gridPrepareCanvas
|
||||||
ColWidths = (
|
ColWidths = (
|
||||||
43
|
43
|
||||||
@ -337,6 +338,8 @@ object Form1: TForm1
|
|||||||
90
|
90
|
||||||
90
|
90
|
||||||
90
|
90
|
||||||
|
90
|
||||||
|
90
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,8 +19,8 @@ LazarusResources.Add('TForm1','FORMDATA',[
|
|||||||
+'erSpacing.Top'#2#0#19'BorderSpacing.Right'#2#0#20'BorderSpacing.Bottom'#2#0
|
+'erSpacing.Top'#2#0#19'BorderSpacing.Right'#2#0#20'BorderSpacing.Bottom'#2#0
|
||||||
+#20'BorderSpacing.Around'#2#0'!BorderSpacing.CellAlignHorizontal'#7#7'ccaFil'
|
+#20'BorderSpacing.Around'#2#0'!BorderSpacing.CellAlignHorizontal'#7#7'ccaFil'
|
||||||
+'l'#31'BorderSpacing.CellAlignVertical'#7#7'ccaFill'#11'BorderStyle'#7#8'bsS'
|
+'l'#31'BorderSpacing.CellAlignVertical'#7#7'ccaFill'#11'BorderStyle'#7#8'bsS'
|
||||||
+'ingle'#8'ColCount'#3#255#0#15'DefaultColWidth'#2'Z'#14'DefaultDrawing'#9#10
|
+'ingle'#8'ColCount'#3#1#1#15'DefaultColWidth'#2'Z'#14'DefaultDrawing'#9#10'D'
|
||||||
+'DragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7
|
+'ragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7
|
||||||
+'Enabled'#9#14'ExtendedSelect'#9#10'FixedColor'#7#9'clBtnFace'#9'FixedCols'#2
|
+'Enabled'#9#14'ExtendedSelect'#9#10'FixedColor'#7#9'clBtnFace'#9'FixedCols'#2
|
||||||
+#1#9'FixedRows'#2#1#4'Flat'#8#13'GridLineWidth'#2#1#14'HeaderHotZones'#11#11
|
+#1#9'FixedRows'#2#1#4'Flat'#8#13'GridLineWidth'#2#1#14'HeaderHotZones'#11#11
|
||||||
+'gzFixedCols'#0#15'HeaderPushZones'#11#11'gzFixedCols'#0#7'Options'#11#15'go'
|
+'gzFixedCols'#0#15'HeaderPushZones'#11#11'gzFixedCols'#0#7'Options'#11#15'go'
|
||||||
@ -29,8 +29,8 @@ LazarusResources.Add('TForm1','FORMDATA',[
|
|||||||
+'t'#3#232#3#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#7'TabStop'#9#16
|
+'t'#3#232#3#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#7'TabStop'#9#16
|
||||||
+'TitleFont.Height'#2#0#15'TitleFont.Style'#11#0#10'TitleStyle'#7#9'tsLazarus'
|
+'TitleFont.Height'#2#0#15'TitleFont.Style'#11#0#10'TitleStyle'#7#9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|
||||||
|
procedure gridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect;
|
||||||
|
aState: TGridDrawState);
|
||||||
procedure gridPrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
procedure gridPrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
||||||
aState: TGridDrawState);
|
aState: TGridDrawState);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
|
function IndexToAlphaIndex(AIndex: Integer): string;
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
end;
|
end;
|
||||||
@ -48,6 +51,40 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.gridDrawCell(Sender: TObject; aCol, aRow: Integer;
|
||||||
|
aRect: TRect; aState: TGridDrawState);
|
||||||
|
|
||||||
|
procedure HorizontalCenter;
|
||||||
|
var
|
||||||
|
aTextStyle : TTextStyle;
|
||||||
|
begin
|
||||||
|
aTextStyle := grid.Canvas.TextStyle;
|
||||||
|
aTextStyle.Alignment:=taCenter;
|
||||||
|
grid.Canvas.TextStyle:=aTextStyle;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
if gdFixed in aState then
|
||||||
|
begin
|
||||||
|
if (aCol=0) and (aRow>=Grid.FixedRows) then
|
||||||
|
begin
|
||||||
|
HorizontalCenter;
|
||||||
|
grid.Canvas.TextRect(aRect, aRect.Left, aRect.Top, IntToStr(aRow));
|
||||||
|
exit;
|
||||||
|
end else
|
||||||
|
if (aRow=0) and (aCol>=Grid.FixedCols) then
|
||||||
|
begin
|
||||||
|
HorizontalCenter;
|
||||||
|
grid.Canvas.TextRect(aRect, aRect.Left, aRect.Top,
|
||||||
|
IndexToAlphaIndex(aCol-Grid.FixedCols));
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
grid.DefaultDrawCell(aCol,aRow,aRect,aState);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.gridPrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
procedure TForm1.gridPrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
||||||
aState: TGridDrawState);
|
aState: TGridDrawState);
|
||||||
begin
|
begin
|
||||||
@ -58,6 +95,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TForm1.IndexToAlphaIndex(AIndex: Integer): string;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result := chr((AIndex mod 26) + ord('A'));
|
||||||
|
i := (AIndex div 26)-1;
|
||||||
|
if i>25 then
|
||||||
|
result := '['+IntToStr(AIndex)+']'
|
||||||
|
else
|
||||||
|
if i>=0 then
|
||||||
|
result := chr(i + ord('A')) + Result;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$I main.lrs}
|
{$I main.lrs}
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="/"/>
|
||||||
<Version Value="6"/>
|
<Version Value="6"/>
|
||||||
<General>
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<SaveClosedFiles Value="False"/>
|
||||||
|
<SaveOnlyProjectUnits Value="True"/>
|
||||||
|
</Flags>
|
||||||
<SessionStorage Value="InIDEConfig"/>
|
<SessionStorage Value="InIDEConfig"/>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<TargetFileExt Value=""/>
|
<TargetFileExt Value=""/>
|
||||||
@ -14,7 +18,6 @@
|
|||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
|
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||||
@ -22,7 +25,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
@ -48,7 +51,6 @@
|
|||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="8"/>
|
<Version Value="8"/>
|
||||||
<PathDelim Value="\"/>
|
|
||||||
<Linking>
|
<Linking>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
|
@ -1 +1 @@
|
|||||||
MAINICON ICON "D:\\lazarus\\source\\lazarus\\examples\\spreadsheet\\spreadsheet.ico"
|
MAINICON ICON "/home/prog/lazarus/examples/spreadsheet/spreadsheet.ico"
|
||||||
|
Loading…
Reference in New Issue
Block a user