rows/cols captions for spreadsheet example

git-svn-id: trunk@17010 -
This commit is contained in:
jesus 2008-10-15 19:09:02 +00:00
parent 9181c5ec3c
commit 6762eefc2f
5 changed files with 67 additions and 11 deletions

View File

@ -51,7 +51,7 @@ object Form1: TForm1
BorderSpacing.CellAlignHorizontal = ccaFill
BorderSpacing.CellAlignVertical = ccaFill
BorderStyle = bsSingle
ColCount = 255
ColCount = 257
DefaultColWidth = 90
DefaultDrawing = True
DragCursor = crDrag
@ -80,6 +80,7 @@ object Form1: TForm1
UseXORFeatures = False
Visible = True
OnBeforeSelection = gridBeforeSelection
OnDrawCell = gridDrawCell
OnPrepareCanvas = gridPrepareCanvas
ColWidths = (
43
@ -337,6 +338,8 @@ object Form1: TForm1
90
90
90
90
90
)
end
end

View File

@ -19,8 +19,8 @@ LazarusResources.Add('TForm1','FORMDATA',[
+'erSpacing.Top'#2#0#19'BorderSpacing.Right'#2#0#20'BorderSpacing.Bottom'#2#0
+#20'BorderSpacing.Around'#2#0'!BorderSpacing.CellAlignHorizontal'#7#7'ccaFil'
+'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
+'DragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7
+'ingle'#8'ColCount'#3#1#1#15'DefaultColWidth'#2'Z'#14'DefaultDrawing'#9#10'D'
+'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
+#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'
@ -29,8 +29,8 @@ LazarusResources.Add('TForm1','F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Z'#2'Z'#2'Z'#2'Z'#2'Z'#2
+'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#0#0#0#0
+'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2
+'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#2'Z'#0#0#0#0
]);

View File

@ -15,10 +15,13 @@ type
TForm1 = class(TForm)
grid: TStringGrid;
procedure gridBeforeSelection(Sender: TObject; aCol, aRow: Integer);
procedure gridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect;
aState: TGridDrawState);
procedure gridPrepareCanvas(sender: TObject; aCol, aRow: Integer;
aState: TGridDrawState);
private
{ private declarations }
function IndexToAlphaIndex(AIndex: Integer): string;
public
{ public declarations }
end;
@ -48,6 +51,40 @@ begin
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;
aState: TGridDrawState);
begin
@ -58,6 +95,19 @@ begin
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
{$I main.lrs}

View File

@ -1,9 +1,13 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<PathDelim Value="/"/>
<Version Value="6"/>
<General>
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
</Flags>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
@ -14,7 +18,6 @@
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
@ -22,7 +25,7 @@
<RunParams>
<local>
<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>
</RunParams>
<RequiredPackages Count="1">
@ -48,7 +51,6 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<Linking>
<Options>
<Win32>

View File

@ -1 +1 @@
MAINICON ICON "D:\\lazarus\\source\\lazarus\\examples\\spreadsheet\\spreadsheet.ico"
MAINICON ICON "/home/prog/lazarus/examples/spreadsheet/spreadsheet.ico"