fpspreadsheet: Add method AddColors and event OnGetColorName to TsCellCombobox. Remove ComboColors.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4607 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
6f5068b304
commit
7b9a56cd3e
@ -78,7 +78,7 @@ object MainForm: TMainForm
|
|||||||
Align = alClient
|
Align = alClient
|
||||||
DefaultColWidth = 125
|
DefaultColWidth = 125
|
||||||
MouseWheelOption = mwGrid
|
MouseWheelOption = mwGrid
|
||||||
RowCount = 30
|
RowCount = 33
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
TitleStyle = tsNative
|
TitleStyle = tsNative
|
||||||
DisplayOptions = [doColumnTitles]
|
DisplayOptions = [doColumnTitles]
|
||||||
@ -108,11 +108,14 @@ object MainForm: TMainForm
|
|||||||
' PosCurrencyFormat=3'
|
' PosCurrencyFormat=3'
|
||||||
' NegCurrencyFormat=8'
|
' NegCurrencyFormat=8'
|
||||||
' TwoDigitYearCenturyWindow=50'
|
' TwoDigitYearCenturyWindow=50'
|
||||||
'Font0=Arial; size 10; black'
|
'(-) Images='
|
||||||
'Font1=Arial; size 10; blue; underline'
|
'(-) Fonts='
|
||||||
'Font2=Arial; size 10; black; bold'
|
' Font0=Arial; size 10; black'
|
||||||
'Font3=Arial; size 10; black; italic'
|
' Font1=Arial; size 10; blue; underline'
|
||||||
'CellFormat0=nfGeneral'
|
' Font2=Arial; size 10; black; bold'
|
||||||
|
' Font3=Arial; size 10; black; italic'
|
||||||
|
'(-) Cell formats='
|
||||||
|
' CellFormat0=nfGeneral'
|
||||||
)
|
)
|
||||||
TitleCaptions.Strings = (
|
TitleCaptions.Strings = (
|
||||||
'Properties'
|
'Properties'
|
||||||
@ -374,6 +377,7 @@ object MainForm: TMainForm
|
|||||||
ColorRectOffset = 3
|
ColorRectOffset = 3
|
||||||
ColorRectWidth = -1
|
ColorRectWidth = -1
|
||||||
WorkbookSource = WorkbookSource
|
WorkbookSource = WorkbookSource
|
||||||
|
OnAddColors = ColorComboboxAddColors
|
||||||
DropDownCount = 24
|
DropDownCount = 24
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
@ -388,6 +392,7 @@ object MainForm: TMainForm
|
|||||||
ColorRectOffset = 3
|
ColorRectOffset = 3
|
||||||
ColorRectWidth = -1
|
ColorRectWidth = -1
|
||||||
WorkbookSource = WorkbookSource
|
WorkbookSource = WorkbookSource
|
||||||
|
OnAddColors = ColorComboboxAddColors
|
||||||
DropDownCount = 24
|
DropDownCount = 24
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
|
@ -376,6 +376,7 @@ type
|
|||||||
procedure AcShowHeadersUpdate(Sender: TObject);
|
procedure AcShowHeadersUpdate(Sender: TObject);
|
||||||
procedure AcViewInspectorExecute(Sender: TObject);
|
procedure AcViewInspectorExecute(Sender: TObject);
|
||||||
procedure EditCut1Execute(Sender: TObject);
|
procedure EditCut1Execute(Sender: TObject);
|
||||||
|
procedure ColorComboboxAddColors(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure HyperlinkHandler(Sender: TObject; ACaption: String;
|
procedure HyperlinkHandler(Sender: TObject; ACaption: String;
|
||||||
var AHyperlink: TsHyperlink);
|
var AHyperlink: TsHyperlink);
|
||||||
@ -408,7 +409,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
LCLIntf, inifiles, uriparser,
|
LCLIntf, inifiles, uriparser,
|
||||||
fpsUtils, fpsCSV,
|
fpsUtils, fpsCSV,
|
||||||
// fpsCSV, fpsHTML, fpsOpenDocument, xlsbiff2, xlsbiff5, xlsbiff8, xlsxooxml, wikitable,
|
|
||||||
sCSVParamsForm, sCurrencyForm, sFormatSettingsForm, sSortParamsForm,
|
sCSVParamsForm, sCurrencyForm, sFormatSettingsForm, sSortParamsForm,
|
||||||
sHyperlinkForm, sNumFormatForm, sSearchForm;
|
sHyperlinkForm, sNumFormatForm, sSearchForm;
|
||||||
|
|
||||||
@ -651,6 +651,63 @@ begin
|
|||||||
InspectorSplitter.Left := 0; // Make sure that the splitter is always at the left of the inspector
|
InspectorSplitter.Left := 0; // Make sure that the splitter is always at the left of the inspector
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.ColorComboboxAddColors(Sender: TObject);
|
||||||
|
begin
|
||||||
|
with TsCellCombobox(Sender) do begin
|
||||||
|
// These are the Excel-8 palette colors, a bit rearranged and without the
|
||||||
|
// duplicates.
|
||||||
|
AddColor($000000, 'black');
|
||||||
|
AddColor($333333, 'gray 80%');
|
||||||
|
AddColor($808080, 'gray 50%');
|
||||||
|
AddColor($969696, 'gray 40%');
|
||||||
|
AddColor($C0C0C0, 'silver');
|
||||||
|
AddColor($FFFFFF, 'white');
|
||||||
|
AddColor($FF0000, 'red');
|
||||||
|
AddColor($00FF00, 'green');
|
||||||
|
AddColor($0000FF, 'blue');
|
||||||
|
AddColor($FFFF00, 'yellow');
|
||||||
|
AddColor($FF00FF, 'magenta');
|
||||||
|
AddColor($00FFFF, 'cyan');
|
||||||
|
|
||||||
|
AddColor($800000, 'dark red');
|
||||||
|
AddColor($008000, 'dark green');
|
||||||
|
AddColor($000080, 'dark blue');
|
||||||
|
AddColor($808000, 'olive');
|
||||||
|
AddColor($800080, 'purple');
|
||||||
|
AddColor($008080, 'teal');
|
||||||
|
AddColor($9999FF, 'periwinkle');
|
||||||
|
AddColor($993366, 'plum');
|
||||||
|
AddColor($FFFFCC, 'ivory');
|
||||||
|
AddColor($CCFFFF, 'light turquoise');
|
||||||
|
AddColor($660066, 'dark purple');
|
||||||
|
AddColor($FF8080, 'coral');
|
||||||
|
AddColor($0066CC, 'ocean blue');
|
||||||
|
AddColor($CCCCFF, 'ice blue');
|
||||||
|
|
||||||
|
AddColor($00CCFF, 'sky blue');
|
||||||
|
AddColor($CCFFCC, 'light green');
|
||||||
|
AddColor($FFFF99, 'light yellow');
|
||||||
|
AddColor($99CCFF, 'pale blue');
|
||||||
|
AddColor($FF99CC, 'rose');
|
||||||
|
AddColor($CC99FF, 'lavander');
|
||||||
|
AddColor($FFCC99, 'tan');
|
||||||
|
|
||||||
|
AddColor($3366FF, 'light blue');
|
||||||
|
AddColor($33CCCC, 'aqua');
|
||||||
|
AddColor($99CC00, 'lime');
|
||||||
|
AddColor($FFCC00, 'gold');
|
||||||
|
AddColor($FF9900, 'light orange');
|
||||||
|
AddColor($FF6600, 'orange');
|
||||||
|
AddColor($666699, 'blue gray');
|
||||||
|
AddColor($003366, 'dark teal');
|
||||||
|
AddColor($339966, 'sea green');
|
||||||
|
AddColor($003300, 'very dark green');
|
||||||
|
AddColor($333300, 'olive green');
|
||||||
|
AddColor($993300, 'brown');
|
||||||
|
AddColor($333399, 'indigo');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.EditCut1Execute(Sender: TObject);
|
procedure TMainForm.EditCut1Execute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//
|
//
|
||||||
|
@ -21,6 +21,7 @@ uses
|
|||||||
type
|
type
|
||||||
|
|
||||||
{ TsPalette }
|
{ TsPalette }
|
||||||
|
|
||||||
TsPalette = class
|
TsPalette = class
|
||||||
private
|
private
|
||||||
FColors: array of TsColor;
|
FColors: array of TsColor;
|
||||||
|
@ -301,6 +301,9 @@ type
|
|||||||
|
|
||||||
{ TsCellCombobox }
|
{ TsCellCombobox }
|
||||||
|
|
||||||
|
TsColorNameEvent = procedure (Sender: TObject; AColor: TColor;
|
||||||
|
out AColorName: String) of object;
|
||||||
|
|
||||||
{@@ TsCellCombobox is a multi-purpose combobox for selection of formatting
|
{@@ TsCellCombobox is a multi-purpose combobox for selection of formatting
|
||||||
items of a cell }
|
items of a cell }
|
||||||
TsCellCombobox = class(TCustomCombobox, IsSpreadsheetControl)
|
TsCellCombobox = class(TCustomCombobox, IsSpreadsheetControl)
|
||||||
@ -309,6 +312,8 @@ type
|
|||||||
FFormatItem: TsCellFormatItem;
|
FFormatItem: TsCellFormatItem;
|
||||||
FColorRectOffset: Integer;
|
FColorRectOffset: Integer;
|
||||||
FColorRectWidth: Integer;
|
FColorRectWidth: Integer;
|
||||||
|
FOnAddColors: TNotifyEvent;
|
||||||
|
FOnGetColorName: TsColorNameEvent;
|
||||||
function GetWorkbook: TsWorkbook;
|
function GetWorkbook: TsWorkbook;
|
||||||
function GetWorksheet: TsWorksheet;
|
function GetWorksheet: TsWorksheet;
|
||||||
procedure SetColorRectOffset(AValue: Integer);
|
procedure SetColorRectOffset(AValue: Integer);
|
||||||
@ -331,6 +336,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure AddColor(AColor: TsColor; AColorName: String);
|
||||||
procedure ListenerNotification(AChangedItems: TsNotificationItems;
|
procedure ListenerNotification(AChangedItems: TsNotificationItems;
|
||||||
AData: Pointer = nil);
|
AData: Pointer = nil);
|
||||||
procedure RemoveWorkbookSource;
|
procedure RemoveWorkbookSource;
|
||||||
@ -347,6 +353,10 @@ type
|
|||||||
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 10;
|
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 10;
|
||||||
{@@ Link to the WorkbookSource which provides the workbook and worksheet. }
|
{@@ Link to the WorkbookSource which provides the workbook and worksheet. }
|
||||||
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
||||||
|
{@@ Event which adds the colors to the combobox }
|
||||||
|
property OnAddColors: TNotifyEvent read FOnAddColors write FOnAddColors;
|
||||||
|
{@@ Event to get a decent name of the colors of the combo }
|
||||||
|
property OnGetColorName: TsColorNameEvent read FOnGetColorName write FOnGetColorName;
|
||||||
|
|
||||||
{ inherited properties }
|
{ inherited properties }
|
||||||
property Align;
|
property Align;
|
||||||
@ -483,9 +493,6 @@ type
|
|||||||
|
|
||||||
function SpreadsheetFormatInClipboard: Boolean;
|
function SpreadsheetFormatInClipboard: Boolean;
|
||||||
|
|
||||||
var
|
|
||||||
ComboColors: TsPalette = nil;
|
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
|
|
||||||
@ -2116,6 +2123,20 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Adds a named color to the combobox items
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsCellCombobox.AddColor(AColor: TsColor; AColorName: String);
|
||||||
|
var
|
||||||
|
noText: Boolean;
|
||||||
|
begin
|
||||||
|
if (FFormatItem in [cfiFontColor, cfiBackgroundColor, cfiBorderColor]) then
|
||||||
|
begin
|
||||||
|
noText := (FColorRectWidth = -1);
|
||||||
|
Items.AddObject(StrUtils.IfThen(noText, '', AColorName), TObject(PtrInt(AColor)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Applies the format to a cell. Override according to the format item for
|
Applies the format to a cell. Override according to the format item for
|
||||||
which the combobox is responsible.
|
which the combobox is responsible.
|
||||||
@ -2389,6 +2410,7 @@ procedure TsCellCombobox.Populate;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
clr: TsColor;
|
clr: TsColor;
|
||||||
|
clrname: String;
|
||||||
noText: Boolean;
|
noText: Boolean;
|
||||||
begin
|
begin
|
||||||
if Workbook = nil then
|
if Workbook = nil then
|
||||||
@ -2407,10 +2429,18 @@ begin
|
|||||||
Items.Clear;
|
Items.Clear;
|
||||||
if FFormatItem = cfiBackgroundColor then
|
if FFormatItem = cfiBackgroundColor then
|
||||||
Items.AddObject(StrUtils.IfThen(noText, '', '(none)'), TObject(scTransparent));
|
Items.AddObject(StrUtils.IfThen(noText, '', '(none)'), TObject(scTransparent));
|
||||||
for i:=0 to ComboColors.Count-1 do
|
if Assigned(FOnAddColors) then
|
||||||
begin
|
FOnAddColors(self)
|
||||||
clr := ComboColors[i];
|
else begin
|
||||||
Items.AddObject(StrUtils.IfThen(noText, '', GetColorName(clr)), TObject(PtrInt(clr)));
|
// By default, add the Excel2 colors.
|
||||||
|
AddColor(scBlack, GetColorName(scBlack));
|
||||||
|
AddColor(scWhite, GetColorName(scWhite));
|
||||||
|
AddColor(scRed, GetColorName(scRed));
|
||||||
|
AddColor(scGreen, GetColorName(scGreen));
|
||||||
|
AddColor(scBlue, GetColorName(scBlue));
|
||||||
|
AddColor(scYellow, GetColorName(scYellow));
|
||||||
|
AddColor(scMagenta, GetColorName(scMagenta));
|
||||||
|
AddColor(scCyan, GetColorName(scCyan));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -3397,13 +3427,11 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
{$I fpspreadsheetctrls.lrs}
|
{$I fpspreadsheetctrls.lrs}
|
||||||
|
|
||||||
// CellClipboard := TsCellList.Create;
|
RegisterPropertyToSkip(TsSpreadsheetInspector, 'RowHeights',
|
||||||
|
'For compatibility with older Laz versions.', '');
|
||||||
|
|
||||||
ComboColors := TsPalette.Create;
|
RegisterPropertyToSkip(TsSpreadsheetInspector, 'ColWidths',
|
||||||
ComboColors.AddExcelColors;
|
'For compatibility with older Laz versions.', '');
|
||||||
|
|
||||||
RegisterPropertyToSkip(TsSpreadsheetInspector, 'RowHeights', 'For compatibility with older Laz versions.', '');
|
|
||||||
RegisterPropertyToSkip(TsSpreadsheetInspector, 'ColWidths', 'For compatibility with older Laz versions.', '');
|
|
||||||
|
|
||||||
{ Clipboard formats }
|
{ Clipboard formats }
|
||||||
cfBiff8Format := RegisterclipboardFormat('Biff8');
|
cfBiff8Format := RegisterclipboardFormat('Biff8');
|
||||||
@ -3411,14 +3439,10 @@ initialization
|
|||||||
cfHTMLFormat := RegisterClipboardFormat('HTML Format');
|
cfHTMLFormat := RegisterClipboardFormat('HTML Format');
|
||||||
cfTextHTMLFormat := RegisterClipboardFormat('text/html');
|
cfTextHTMLFormat := RegisterClipboardFormat('text/html');
|
||||||
cfCSVFormat := RegisterClipboardFormat('CSV');
|
cfCSVFormat := RegisterClipboardFormat('CSV');
|
||||||
|
|
||||||
{ not working...
|
{ not working...
|
||||||
cfOpenDocumentFormat := RegisterClipboardFormat('application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)"');
|
cfOpenDocumentFormat := RegisterClipboardFormat('application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)"');
|
||||||
cfStarObjectDescriptor := RegisterClipboardFormat('application/x-openoffice-objectdescriptor-xml;windows_formatname="Star Object Descriptor (XML)"');
|
cfStarObjectDescriptor := RegisterClipboardFormat('application/x-openoffice-objectdescriptor-xml;windows_formatname="Star Object Descriptor (XML)"');
|
||||||
}
|
}
|
||||||
|
|
||||||
finalization
|
|
||||||
// CellClipboard.Free;
|
|
||||||
if ComboColors <> nil then ComboColors.Free;
|
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user