You've already forked lazarus-ccr
fpspreadsheet: Major reconstructor of color management: no more palettes now, use direct rgb colors instead. May break existing code - sorry! Update all demos and unit tests (passed).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4156 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -9,6 +9,7 @@ object MainFrm: TMainFrm
|
||||
Menu = MainMenu
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
ShowHint = True
|
||||
LCLVersion = '1.5'
|
||||
object Panel1: TPanel
|
||||
@@ -425,7 +426,7 @@ object MainFrm: TMainFrm
|
||||
end
|
||||
end
|
||||
object InspectorSplitter: TSplitter
|
||||
Left = 639
|
||||
Left = 591
|
||||
Height = 453
|
||||
Top = 84
|
||||
Width = 5
|
||||
@@ -433,10 +434,10 @@ object MainFrm: TMainFrm
|
||||
ResizeAnchor = akRight
|
||||
end
|
||||
object InspectorPageControl: TPageControl
|
||||
Left = 644
|
||||
Left = 596
|
||||
Height = 453
|
||||
Top = 84
|
||||
Width = 241
|
||||
Width = 289
|
||||
ActivePage = PgCellValue
|
||||
Align = alRight
|
||||
TabIndex = 0
|
||||
@@ -445,18 +446,20 @@ object MainFrm: TMainFrm
|
||||
object PgCellValue: TTabSheet
|
||||
Caption = 'Cell value'
|
||||
ClientHeight = 425
|
||||
ClientWidth = 233
|
||||
ClientWidth = 281
|
||||
object CellInspector: TValueListEditor
|
||||
Left = 0
|
||||
Height = 425
|
||||
Top = 0
|
||||
Width = 233
|
||||
Width = 281
|
||||
Align = alClient
|
||||
FixedCols = 0
|
||||
MouseWheelOption = mwGrid
|
||||
RowCount = 15
|
||||
TabOrder = 0
|
||||
TitleStyle = tsNative
|
||||
DisplayOptions = [doColumnTitles, doAutoColResize]
|
||||
DisplayOptions = [doColumnTitles]
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goAlwaysShowEditor, goThumbTracking]
|
||||
Strings.Strings = (
|
||||
'Row='
|
||||
'Column='
|
||||
@@ -478,8 +481,8 @@ object MainFrm: TMainFrm
|
||||
''
|
||||
)
|
||||
ColWidths = (
|
||||
114
|
||||
115
|
||||
138
|
||||
139
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -494,7 +497,7 @@ object MainFrm: TMainFrm
|
||||
Left = 0
|
||||
Height = 453
|
||||
Top = 84
|
||||
Width = 639
|
||||
Width = 591
|
||||
OnChange = TabControlChange
|
||||
Align = alClient
|
||||
TabOrder = 3
|
||||
@@ -502,7 +505,7 @@ object MainFrm: TMainFrm
|
||||
Left = 2
|
||||
Height = 448
|
||||
Top = 3
|
||||
Width = 635
|
||||
Width = 587
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
|
||||
@@ -8,7 +8,7 @@ uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids,
|
||||
ColorBox, ValEdit,
|
||||
fpstypes, fpspreadsheetgrid, fpspreadsheet,
|
||||
fpstypes, fpspalette, fpspreadsheetgrid, fpspreadsheet,
|
||||
{%H-}fpsallformats;
|
||||
|
||||
type
|
||||
@@ -325,6 +325,7 @@ type
|
||||
procedure FontSizeComboBoxSelect(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure InspectorPageControlChange(Sender: TObject);
|
||||
procedure MemoFormulaEditingDone(Sender: TObject);
|
||||
procedure TabControlChange(Sender: TObject);
|
||||
@@ -334,6 +335,7 @@ type
|
||||
|
||||
private
|
||||
FCopiedFormat: TCell;
|
||||
FPalette: TsPalette;
|
||||
|
||||
function EditComment(ACaption: String; var AText: String): Boolean;
|
||||
procedure LoadFile(const AFileName: String);
|
||||
@@ -928,9 +930,9 @@ begin
|
||||
if WorksheetGrid.Workbook <> nil then begin
|
||||
Items.Clear;
|
||||
Items.AddObject('no fill', TObject(PtrInt(clNone)));
|
||||
for i:=0 to WorksheetGrid.Workbook.GetPaletteSize-1 do begin
|
||||
clr := WorksheetGrid.Workbook.GetPaletteColor(i);
|
||||
clrName := WorksheetGrid.Workbook.GetColorName(i);
|
||||
for i:=0 to FPalette.Count-1 do begin
|
||||
clr := FPalette[i];
|
||||
clrName := GetColorName(clr);
|
||||
Items.AddObject(Format('%d: %s', [i, clrName]), TObject(PtrInt(clr)));
|
||||
end;
|
||||
end;
|
||||
@@ -947,7 +949,7 @@ begin
|
||||
if CbBackgroundColor.ItemIndex <= 0 then
|
||||
with WorksheetGrid do BackgroundColors[Selection] := scNotDefined
|
||||
else
|
||||
with WorksheetGrid do BackgroundColors[Selection] := CbBackgroundColor.ItemIndex - 1;
|
||||
with WorksheetGrid do BackgroundColors[Selection] := PtrInt(CbBackgroundColor.Items.Objects[CbBackgroundColor.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TMainFrm.CbHeaderStyleChange(Sender: TObject);
|
||||
@@ -1087,12 +1089,20 @@ begin
|
||||
FontSizeCombobox.DropDownCount := DROPDOWN_COUNT;
|
||||
CbBackgroundColor.DropDownCount := DROPDOWN_COUNT;
|
||||
|
||||
FPalette := TsPalette.Create;
|
||||
FPalette.AddExcelColors;
|
||||
|
||||
// Initialize a new empty workbook
|
||||
AcNewExecute(nil);
|
||||
|
||||
ActiveControl := WorksheetGrid;
|
||||
end;
|
||||
|
||||
procedure TMainFrm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FPalette.Free;
|
||||
end;
|
||||
|
||||
procedure TMainFrm.InspectorPageControlChange(Sender: TObject);
|
||||
begin
|
||||
CellInspector.Parent := InspectorPageControl.ActivePage;
|
||||
@@ -1184,13 +1194,14 @@ end;
|
||||
|
||||
procedure TMainFrm.UpdateBackgroundColorIndex;
|
||||
var
|
||||
sClr: TsColor;
|
||||
clr: TsColor;
|
||||
begin
|
||||
with WorksheetGrid do sClr := BackgroundColors[Selection];
|
||||
if sClr = scNotDefined then
|
||||
with WorksheetGrid do
|
||||
clr := BackgroundColors[Selection];
|
||||
if (clr = scNotDefined) or (clr = scTransparent) then
|
||||
CbBackgroundColor.ItemIndex := 0 // no fill
|
||||
else
|
||||
CbBackgroundColor.ItemIndex := sClr + 1;
|
||||
CbBackgroundColor.ItemIndex := CbBackgroundColor.Items.IndexOfObject(TObject(PtrInt(clr)));
|
||||
end;
|
||||
|
||||
procedure TMainFrm.UpdateHorAlignmentActions;
|
||||
@@ -1214,6 +1225,7 @@ var
|
||||
cb: TsCellBorder;
|
||||
r1,r2,c1,c2: Cardinal;
|
||||
fmt: TsCellFormat;
|
||||
nfparams: TsNumFormatParams;
|
||||
begin
|
||||
with CellInspector do
|
||||
begin
|
||||
@@ -1223,10 +1235,10 @@ begin
|
||||
if InspectorPageControl.ActivePage = PgCellValue then
|
||||
begin
|
||||
if ACell=nil
|
||||
then Strings.Add('Row=')
|
||||
then Strings.Add(Format('Row=%d', [WorksheetGrid.GetWorksheetRow(WorksheetGrid.Row)]))
|
||||
else Strings.Add(Format('Row=%d', [ACell^.Row]));
|
||||
if ACell=nil
|
||||
then Strings.Add('Column=')
|
||||
then Strings.Add(Format('Column=%d', [WorksheetGrid.GetWorksheetCol(WorksheetGrid.Col)]))
|
||||
else Strings.Add(Format('Column=%d', [ACell^.Col]));
|
||||
if ACell=nil
|
||||
then Strings.Add('ContentType=')
|
||||
@@ -1308,29 +1320,40 @@ begin
|
||||
else
|
||||
Strings.Add(Format('BorderStyles[%s]=%s, %s', [
|
||||
GetEnumName(TypeInfo(TsCellBorder), ord(cb)),
|
||||
GetEnumName(TypeInfo(TsLineStyle), ord(fmt.BorderStyles[cbEast].LineStyle)),
|
||||
WorksheetGrid.Workbook.GetColorName(fmt.BorderStyles[cbEast].Color)
|
||||
GetEnumName(TypeInfo(TsLineStyle), ord(fmt.BorderStyles[cb].LineStyle)),
|
||||
GetColorName(fmt.BorderStyles[cb].Color)
|
||||
]));
|
||||
if (ACell=nil) or not (uffBackground in fmt.UsedformattingFields)
|
||||
then Strings.Add('BackgroundColor=')
|
||||
else Strings.Add(Format('BackgroundColor=%d (%s)', [
|
||||
else Strings.Add(Format('BackgroundColor=$%8x (%s)', [
|
||||
fmt.Background.BgColor,
|
||||
WorksheetGrid.Workbook.GetColorName(fmt.Background.BgColor)
|
||||
GetColorName(fmt.Background.BgColor)
|
||||
]));
|
||||
if (ACell=nil) or not (uffNumberFormat in fmt.UsedFormattingFields)
|
||||
then Strings.Add('NumberFormat=')
|
||||
else Strings.Add(Format('NumberFormat=%s', [GetEnumName(TypeInfo(TsNumberFormat), ord(fmt.NumberFormat))]));
|
||||
else begin
|
||||
nfparams := WorksheetGrid.Workbook.GetNumberFormat(fmt.NumberFormatIndex);
|
||||
if nfparams = nil then
|
||||
begin
|
||||
Strings.Add('NumberFormat=General');
|
||||
Strings.Add('NumberFormatStr=');
|
||||
end else
|
||||
begin
|
||||
Strings.Add(Format('NumberFormat=%s', [GetEnumName(TypeInfo(TsNumberFormat), ord(nfparams.NumFormat))]));
|
||||
Strings.Add(Format('NumberFormatStr=%s', [nfparams.NumFormatStr]));
|
||||
end;
|
||||
end;
|
||||
{
|
||||
if (ACell=nil) or not (uffNumberFormat in fmt.UsedFormattingFields)
|
||||
then Strings.Add('NumberFormatStr=')
|
||||
else Strings.Add('NumberFormatStr=' + fmt.NumberFormatStr);
|
||||
if not WorksheetGrid.Worksheet.IsMerged(ACell) then
|
||||
Strings.Add('Merged range=')
|
||||
else
|
||||
begin
|
||||
WorksheetGrid.Worksheet.FindMergedRange(ACell, r1, c1, r2, c2);
|
||||
Strings.Add('Merged range=' + GetCellRangeString(r1, c1, r2, c2));
|
||||
end;
|
||||
|
||||
}
|
||||
if not WorksheetGrid.Worksheet.IsMerged(ACell)
|
||||
then Strings.Add('Merged range=')
|
||||
else begin
|
||||
WorksheetGrid.Worksheet.FindMergedRange(ACell, r1, c1, r2, c2);
|
||||
Strings.Add('Merged range=' + GetCellRangeString(r1, c1, r2, c2));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
<ComponentName Value="MainFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="mainform"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\shared\scsvparamsform.pas"/>
|
||||
@@ -128,6 +127,7 @@
|
||||
<Unit5>
|
||||
<Filename Value="..\shared\sctrls.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="sCtrls"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\shared\scurrencyform.pas"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ object MainFrm: TMainFrm
|
||||
Menu = MainMenu
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
ShowHint = True
|
||||
LCLVersion = '1.5'
|
||||
object MainToolBar: TToolBar
|
||||
|
||||
@@ -9,7 +9,7 @@ uses
|
||||
StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Grids, ColorBox, SynEdit,
|
||||
SynEditHighlighter, SynHighlighterHTML, SynHighlighterMulti,
|
||||
SynHighlighterCss, SynGutterCodeFolding, fpspreadsheetgrid,
|
||||
fpstypes, fpspreadsheet, fpsallformats;
|
||||
fpstypes, fpspalette, fpspreadsheet, fpsallformats;
|
||||
|
||||
type
|
||||
|
||||
@@ -187,6 +187,7 @@ type
|
||||
procedure FontSizeComboBoxSelect(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure PageControlChange(Sender: TObject);
|
||||
procedure TabControlChange(Sender: TObject);
|
||||
procedure WorksheetGridSelection(Sender: TObject; aCol, aRow: Integer);
|
||||
@@ -194,6 +195,7 @@ type
|
||||
WorksheetGrid: TsWorksheetGrid;
|
||||
FCopiedFormat: TCell;
|
||||
FHighlighter: TSynCustomHighlighter;
|
||||
FPalette: TsPalette;
|
||||
procedure LoadFile(const AFileName: String);
|
||||
procedure SetupBackgroundColorBox;
|
||||
procedure UpdateBackgroundColorIndex;
|
||||
@@ -543,20 +545,22 @@ begin
|
||||
if (WorksheetGrid <> nil) and (WorksheetGrid.Workbook <> nil) then begin
|
||||
Items.Clear;
|
||||
Items.AddObject('no fill', TObject(PtrInt(clNone)));
|
||||
for i:=0 to WorksheetGrid.Workbook.GetPaletteSize-1 do begin
|
||||
clr := WorksheetGrid.Workbook.GetPaletteColor(i);
|
||||
clrName := WorksheetGrid.Workbook.GetColorName(i);
|
||||
for i:=0 to FPalette.Count-1 do begin
|
||||
clr := FPalette[i];
|
||||
clrName := GetColorName(clr);
|
||||
Items.AddObject(Format('%d: %s', [i, clrName]), TObject(PtrInt(clr)));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainFrm.CbBackgroundColorSelect(Sender: TObject);
|
||||
var
|
||||
clr: TsColor;
|
||||
begin
|
||||
if CbBackgroundColor.ItemIndex <= 0 then
|
||||
with WorksheetGrid do BackgroundColors[Selection] := scNotDefined
|
||||
else
|
||||
with WorksheetGrid do BackgroundColors[Selection] := CbBackgroundColor.ItemIndex - 1;
|
||||
with WorksheetGrid do BackgroundColors[Selection] := PtrInt(CbBackgroundColor.Items.Objects[CbBackgroundColor.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TMainFrm.FontComboBoxSelect(Sender: TObject);
|
||||
@@ -637,6 +641,9 @@ begin
|
||||
CbBackgroundColor.ColorRectWidth := CbBackgroundColor.ItemHeight - 6; // to get a square box...
|
||||
{$ENDIF}
|
||||
|
||||
FPalette := TsPalette.Create;
|
||||
FPalette.AddExcelColors;
|
||||
|
||||
// Initialize a new empty workbook
|
||||
AcNewExecute(nil);
|
||||
|
||||
@@ -645,6 +652,11 @@ begin
|
||||
ActiveControl := WorksheetGrid;
|
||||
end;
|
||||
|
||||
procedure TMainFrm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FPalette.Free;
|
||||
end;
|
||||
|
||||
procedure TMainFrm.PageControlChange(Sender: TObject);
|
||||
var
|
||||
stream: TMemoryStream;
|
||||
@@ -726,13 +738,13 @@ end;
|
||||
|
||||
procedure TMainFrm.UpdateBackgroundColorIndex;
|
||||
var
|
||||
sClr: TsColor;
|
||||
clr: TsColor;
|
||||
begin
|
||||
with WorksheetGrid do sClr := BackgroundColors[Selection];
|
||||
if sClr = scNotDefined then
|
||||
with WorksheetGrid do clr := BackgroundColors[Selection];
|
||||
if (clr = scNotDefined) or (clr = scTransparent) then
|
||||
CbBackgroundColor.ItemIndex := 0 // no fill
|
||||
else
|
||||
CbBackgroundColor.ItemIndex := sClr + 1;
|
||||
CbBackgroundColor.ItemIndex := CbBackgroundColor.Items.IndexOfObject(TObject(PtrInt(clr)));
|
||||
end;
|
||||
|
||||
procedure TMainFrm.UpdateHorAlignmentActions;
|
||||
|
||||
Reference in New Issue
Block a user