You've already forked lazarus-ccr
fpspreadsheet: Add properties BackgroundColor(s) to TsWorksheetGrid and show usage in fpsgrid demo.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3039 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -126,13 +126,14 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="mainform"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="356"/>
|
||||
<CursorPos X="40" Y="375"/>
|
||||
<TopLine Value="526"/>
|
||||
<CursorPos X="48" Y="557"/>
|
||||
<UsageCount Value="200"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 X="49" Y="494" ID="1"/>
|
||||
<Item0 X="3" Y="558" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -140,22 +141,21 @@
|
||||
<Unit2>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<UnitName Value="fpspreadsheet"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="146"/>
|
||||
<CursorPos X="3" Y="165"/>
|
||||
<UsageCount Value="98"/>
|
||||
<TopLine Value="187"/>
|
||||
<CursorPos X="10" Y="186"/>
|
||||
<UsageCount Value="99"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<UnitName Value="fpspreadsheetgrid"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="131"/>
|
||||
<CursorPos X="29" Y="155"/>
|
||||
<UsageCount Value="99"/>
|
||||
<TopLine Value="1142"/>
|
||||
<CursorPos X="19" Y="1161"/>
|
||||
<UsageCount Value="100"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
@ -247,10 +247,12 @@
|
||||
<Unit15>
|
||||
<Filename Value="d:\lazarus-svn\lcl\graphics.pp"/>
|
||||
<UnitName Value="Graphics"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="573"/>
|
||||
<CursorPos X="43" Y="593"/>
|
||||
<UsageCount Value="29"/>
|
||||
<TopLine Value="1937"/>
|
||||
<CursorPos X="11" Y="1956"/>
|
||||
<UsageCount Value="30"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="d:\lazarus-svn\fpc\2.6.2\source\rtl\objpas\classes\classesh.inc"/>
|
||||
@ -262,11 +264,11 @@
|
||||
<Unit17>
|
||||
<Filename Value="..\..\xlsbiff8.pas"/>
|
||||
<UnitName Value="xlsbiff8"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="2008"/>
|
||||
<CursorPos X="39" Y="1983"/>
|
||||
<UsageCount Value="73"/>
|
||||
<UsageCount Value="74"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
@ -287,31 +289,31 @@
|
||||
<Unit20>
|
||||
<Filename Value="..\..\xlscommon.pas"/>
|
||||
<UnitName Value="xlscommon"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1461"/>
|
||||
<CursorPos X="43" Y="1479"/>
|
||||
<UsageCount Value="69"/>
|
||||
<UsageCount Value="70"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<UnitName Value="xlsbiff5"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="56"/>
|
||||
<UsageCount Value="57"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="..\..\xlsbiff2.pas"/>
|
||||
<UnitName Value="xlsbiff2"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<EditorIndex Value="9"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="547"/>
|
||||
<CursorPos X="1" Y="563"/>
|
||||
<UsageCount Value="57"/>
|
||||
<UsageCount Value="58"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit22>
|
||||
<Unit23>
|
||||
@ -394,10 +396,12 @@
|
||||
<Unit33>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<UnitName Value="ColorBox"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="13"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="7"/>
|
||||
<TopLine Value="584"/>
|
||||
<CursorPos X="3" Y="598"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit33>
|
||||
<Unit34>
|
||||
<Filename Value="d:\lazarus-svn\lcl\dialogs.pp"/>
|
||||
@ -560,124 +564,124 @@
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1146" Column="56" TopLine="1127"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="610" Column="15" TopLine="578"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1149" Column="53" TopLine="1127"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="435" Column="32" TopLine="420"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1158" Column="61" TopLine="1140"/>
|
||||
<Caret Line="140" Column="14" TopLine="121"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1727" Column="25" TopLine="1708"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="589" Column="28" TopLine="589"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="45" Column="37" TopLine="13"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="61" Column="27" TopLine="29"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1137" Column="55" TopLine="1135"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="169" Column="27" TopLine="137"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1727" Column="22" TopLine="1708"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="365" Column="15" TopLine="333"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1755" Column="19" TopLine="1737"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="463" Column="17" TopLine="431"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1154" Column="1" TopLine="1135"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="573" Column="41" TopLine="573"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1142" Column="19" TopLine="1133"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1929" Column="3" TopLine="1898"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="61" Column="27" TopLine="29"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1730" Column="1" TopLine="1713"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="169" Column="27" TopLine="137"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="56" Column="61" TopLine="39"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="365" Column="15" TopLine="333"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="213" Column="17" TopLine="204"/>
|
||||
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
|
||||
<Caret Line="463" Column="17" TopLine="431"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="214" Column="17" TopLine="205"/>
|
||||
<Caret Line="420" Column="4" TopLine="420"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1418" Column="79" TopLine="1416"/>
|
||||
<Caret Line="140" Column="14" TopLine="121"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="239" Column="19" TopLine="206"/>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1161" Column="24" TopLine="1143"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="240" Column="19" TopLine="207"/>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="447" Column="3" TopLine="447"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="139" Column="15" TopLine="121"/>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="592" Column="56" TopLine="558"/>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1161" Column="24" TopLine="1142"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="593" Column="56" TopLine="559"/>
|
||||
<Caret Line="562" Column="28" TopLine="552"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="594" Column="56" TopLine="560"/>
|
||||
<Caret Line="433" Column="14" TopLine="417"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="595" Column="56" TopLine="561"/>
|
||||
<Caret Line="438" Column="30" TopLine="419"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="596" Column="56" TopLine="562"/>
|
||||
<Caret Line="439" Column="29" TopLine="420"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="597" Column="56" TopLine="563"/>
|
||||
<Caret Line="440" Column="23" TopLine="421"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="371" Column="65" TopLine="352"/>
|
||||
<Caret Line="439" Column="60" TopLine="420"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="187" Column="18" TopLine="166"/>
|
||||
<Caret Line="589" Column="26" TopLine="571"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="374" Column="30" TopLine="356"/>
|
||||
<Caret Line="557" Column="3" TopLine="522"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="375" Column="40" TopLine="356"/>
|
||||
<Caret Line="165" Column="77" TopLine="134"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -283,6 +283,17 @@ object Form1: TForm1
|
||||
Caption = 'ToolButton20'
|
||||
Style = tbsDivider
|
||||
end
|
||||
object CbBackgroundColor: TColorBox
|
||||
Left = 461
|
||||
Height = 24
|
||||
Top = 2
|
||||
Width = 132
|
||||
Style = [cbPrettyNames, cbCustomColors]
|
||||
OnGetColors = CbBackgroundColorGetColors
|
||||
ItemHeight = 16
|
||||
OnSelect = CbBackgroundColorSelect
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object OpenDialog1: TOpenDialog
|
||||
DefaultExt = '.xls'
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids, graphutil,
|
||||
fpspreadsheetgrid, fpspreadsheet, fpsallformats;
|
||||
ColorBox, fpspreadsheetgrid, fpspreadsheet, fpsallformats;
|
||||
|
||||
type
|
||||
|
||||
@ -54,6 +54,7 @@ type
|
||||
ActionList1: TActionList;
|
||||
CbShowHeaders: TCheckBox;
|
||||
CbShowGridLines: TCheckBox;
|
||||
CbBackgroundColor: TColorBox;
|
||||
FontComboBox: TComboBox;
|
||||
EdFrozenRows: TSpinEdit;
|
||||
FontDialog1: TFontDialog;
|
||||
@ -149,11 +150,13 @@ type
|
||||
procedure AcTextRotationExecute(Sender: TObject);
|
||||
procedure AcVertAlignmentExecute(Sender: TObject);
|
||||
procedure AcWordwrapExecute(Sender: TObject);
|
||||
procedure CbBackgroundColorSelect(Sender: TObject);
|
||||
procedure CbShowHeadersClick(Sender: TObject);
|
||||
procedure CbShowGridLinesClick(Sender: TObject);
|
||||
procedure AcOpenExecute(Sender: TObject);
|
||||
procedure AcQuitExecute(Sender: TObject);
|
||||
procedure AcSaveAsExecute(Sender: TObject);
|
||||
procedure CbBackgroundColorGetColors(Sender: TCustomColorBox; Items: TStrings);
|
||||
procedure EdFrozenColsChange(Sender: TObject);
|
||||
procedure EdFrozenRowsChange(Sender: TObject);
|
||||
procedure FontComboBoxSelect(Sender: TObject);
|
||||
@ -164,6 +167,8 @@ type
|
||||
private
|
||||
{ private declarations }
|
||||
procedure LoadFile(const AFileName: String);
|
||||
procedure SetupBackgroundColorBox;
|
||||
procedure UpdateBackgroundColorIndex;
|
||||
procedure UpdateFontActions(AFont: TsFont);
|
||||
procedure UpdateHorAlignmentActions;
|
||||
procedure UpdateTextRotationActions;
|
||||
@ -393,6 +398,11 @@ begin
|
||||
with sWorksheetGrid1 do Wordwraps[Selection] := TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TForm1.CbBackgroundColorSelect(Sender: TObject);
|
||||
begin
|
||||
with sWorksheetGrid1 do BackgroundColors[Selection] := CbBackgroundColor.ItemIndex;
|
||||
end;
|
||||
|
||||
procedure TForm1.CbShowHeadersClick(Sender: TObject);
|
||||
begin
|
||||
sWorksheetGrid1.ShowHeaders := CbShowHeaders.Checked;
|
||||
@ -424,6 +434,24 @@ begin
|
||||
sWorksheetGrid1.SaveToSpreadsheetFile(SaveDialog1.FileName);
|
||||
end;
|
||||
|
||||
procedure TForm1.CbBackgroundColorGetColors(Sender: TCustomColorBox; Items: TStrings);
|
||||
type
|
||||
TRGB = packed record R,G,B: byte end;
|
||||
var
|
||||
clr: TColor;
|
||||
rgb: TRGB absolute clr;
|
||||
i: Integer;
|
||||
begin
|
||||
if sWorksheetGrid1.Workbook <> nil then begin
|
||||
Items.Clear;
|
||||
for i:=0 to sWorksheetGrid1.Workbook.GetPaletteSize-1 do begin
|
||||
clr := sWorksheetGrid1.Workbook.GetPaletteColor(i);
|
||||
Items.AddObject(Format('Color %d: %.2x%.2x%.2x', [i, rgb.R, rgb.G, rgb.B]),
|
||||
TObject(PtrInt(clr)));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.EdFrozenColsChange(Sender: TObject);
|
||||
begin
|
||||
sWorksheetGrid1.FrozenCols := EdFrozenCols.Value;
|
||||
@ -516,6 +544,7 @@ begin
|
||||
CbShowHeaders.Checked := (soShowHeaders in sWorksheetGrid1.Worksheet.Options);
|
||||
EdFrozenCols.Value := sWorksheetGrid1.FrozenCols;
|
||||
EdFrozenRows.Value := sWorksheetGrid1.FrozenRows;
|
||||
SetupBackgroundColorBox;
|
||||
|
||||
// Create a tab in the pagecontrol for each worksheet contained in the workbook
|
||||
// This would be easer with a TTabControl. This has display issues, though.
|
||||
@ -530,6 +559,8 @@ begin
|
||||
finally
|
||||
pages.Free;
|
||||
end;
|
||||
|
||||
sWorksheetGrid1Selection(nil, sWorksheetGrid1.Col, sWorksheetGrid1.Row);
|
||||
end;
|
||||
|
||||
procedure TForm1.PageControl1Change(Sender: TObject);
|
||||
@ -538,6 +569,14 @@ begin
|
||||
sWorksheetGrid1.SelectSheetByIndex(PageControl1.ActivePageIndex);
|
||||
end;
|
||||
|
||||
procedure TForm1.SetupBackgroundColorBox;
|
||||
begin
|
||||
// This change triggers re-reading of the workbooks palette by the OnGetColors
|
||||
// event of the ColorBox.
|
||||
CbBackgroundColor.Style := CbBackgroundColor.Style - [cbCustomColors];
|
||||
CbBackgroundColor.Style := CbBackgroundColor.Style + [cbCustomColors];
|
||||
end;
|
||||
|
||||
procedure TForm1.sWorksheetGrid1Selection(Sender: TObject; aCol, aRow: Integer);
|
||||
var
|
||||
cell: PCell;
|
||||
@ -555,12 +594,24 @@ begin
|
||||
UpdateHorAlignmentActions;
|
||||
UpdateVertAlignmentActions;
|
||||
UpdateWordwraps;
|
||||
UpdateBackgroundColorIndex;
|
||||
if cell = nil then
|
||||
exit;
|
||||
lFont := sWorksheetGrid1.Workbook.GetFont(cell^.FontIndex);
|
||||
UpdateFontActions(lFont);
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateBackgroundColorIndex;
|
||||
var
|
||||
sClr: TsColor;
|
||||
begin
|
||||
with sWorksheetGrid1 do sClr := BackgroundColors[Selection];
|
||||
if sClr = scNotDefined then
|
||||
CbBackgroundColor.ItemIndex := -1
|
||||
else
|
||||
CbBackgroundColor.ItemIndex := sClr;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateHorAlignmentActions;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -210,6 +210,8 @@ const
|
||||
// Will be removed sooner or later...
|
||||
scRGBColor = $FFFF;
|
||||
|
||||
scNotDefined = $FFFF;
|
||||
|
||||
type
|
||||
{@@ Data type for rgb color values }
|
||||
TsColorValue = DWord;
|
||||
|
@ -45,6 +45,8 @@ type
|
||||
procedure FixNeighborCellBorders(ACol, ARow: Integer);
|
||||
|
||||
// Setter/Getter
|
||||
function GetBackgroundColor(ACol, ARow: Integer): TsColor;
|
||||
function GetBackgroundColors(ARect: TGridRect): TsColor;
|
||||
function GetCellBorder(ACol, ARow: Integer): TsCellBorders;
|
||||
function GetCellBorders(ARect: TGridRect): TsCellBorders;
|
||||
function GetCellBorderStyle(ACol, ARow: Integer; ABorder: TsCellBorder): TsCellBorderStyle;
|
||||
@ -59,6 +61,8 @@ type
|
||||
function GetVertAlignments(ARect: TGridRect): TsVertAlignment;
|
||||
function GetWordwrap(ACol, ARow: Integer): Boolean;
|
||||
function GetWordwraps(ARect: TGridRect): Boolean;
|
||||
procedure SetBackgroundColor(ACol, ARow: Integer; AValue: TsColor);
|
||||
procedure SetBackgroundColors(ARect: TGridRect; AValue: TsColor);
|
||||
procedure SetCellBorder(ACol, ARow: Integer; AValue: TsCellBorders);
|
||||
procedure SetCellBorders(ARect: TGridRect; AValue: TsCellBorders);
|
||||
procedure SetCellBorderStyle(ACol, ARow: Integer; ABorder: TsCellBorder; AValue: TsCellBorderStyle);
|
||||
@ -137,6 +141,10 @@ type
|
||||
property HeaderCount: Integer read FHeaderCount;
|
||||
|
||||
{ maybe these should become published ... }
|
||||
property BackgroundColor[ACol, ARow: Integer]: TsColor
|
||||
read GetBackgroundColor write SetBackgroundColor;
|
||||
property BackgroundColors[ARect: TGridRect]: TsColor
|
||||
read GetBackgroundColors write SetBackgroundColors;
|
||||
property CellBorder[ACol, ARow: Integer]: TsCellBorders
|
||||
read GetCellBorder write SetCellBorder;
|
||||
property CellBorders[ARect: TGridRect]: TsCellBorders
|
||||
@ -1146,6 +1154,35 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetBackgroundColor(ACol, ARow: Integer): TsColor;
|
||||
var
|
||||
cell: PCell;
|
||||
begin
|
||||
Result := scNotDefined;
|
||||
if Assigned(FWorksheet) then begin
|
||||
cell := FWorksheet.FindCell(GetWorksheetRow(ARow), GetWorksheetCol(ACol));
|
||||
if (cell <> nil) and (uffBackgroundColor in cell^.UsedFormattingFields) then
|
||||
Result := cell^.BackgroundColor;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetBackgroundColors(ARect: TGridRect): TsColor;
|
||||
var
|
||||
c, r: Integer;
|
||||
clr: TsColor;
|
||||
begin
|
||||
Result := GetBackgroundColor(ARect.Left, ARect.Top);
|
||||
clr := Result;
|
||||
for c := ARect.Left to ARect.Right do
|
||||
for r := ARect.Top to ARect.Bottom do begin
|
||||
Result := GetBackgroundColor(c, r);
|
||||
if Result <> clr then begin
|
||||
Result := scNotDefined;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetCellBorder(ACol, ARow: Integer): TsCellBorders;
|
||||
var
|
||||
cell: PCell;
|
||||
@ -1585,6 +1622,38 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.SetBackgroundColor(ACol, ARow: Integer;
|
||||
AValue: TsColor);
|
||||
var
|
||||
c, r: Cardinal;
|
||||
begin
|
||||
if Assigned(FWorkbook) then begin
|
||||
BeginUpdate;
|
||||
try
|
||||
c := GetWorksheetCol(ACol);
|
||||
r := GetWorksheetRow(ARow);
|
||||
FWorksheet.WriteBackgroundColor(r, c, AValue);
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.SetBackgroundColors(ARect: TGridRect;
|
||||
AValue: TsColor);
|
||||
var
|
||||
c,r: Integer;
|
||||
begin
|
||||
BeginUpdate;
|
||||
try
|
||||
for c := ARect.Left to ARect.Right do
|
||||
for r := ARect.Top to ARect.Bottom do
|
||||
SetBackgroundColor(c, r, AValue);
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.SetCellBorder(ACol, ARow: Integer;
|
||||
AValue: TsCellBorders);
|
||||
var
|
||||
|
Reference in New Issue
Block a user