You've already forked lazarus-ccr
fpspreadsheet: Collapsable/expandable items in TsSpreadsheetInspector
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4165 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -71,6 +71,7 @@ object MainForm: TMainForm
|
|||||||
Top = 23
|
Top = 23
|
||||||
Width = 277
|
Width = 277
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
DefaultColWidth = 125
|
||||||
MouseWheelOption = mwGrid
|
MouseWheelOption = mwGrid
|
||||||
RowCount = 30
|
RowCount = 30
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@@ -114,10 +115,7 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
WorkbookSource = WorkbookSource
|
WorkbookSource = WorkbookSource
|
||||||
Mode = imWorkbook
|
Mode = imWorkbook
|
||||||
ColWidths = (
|
ExtendedColSizing = True
|
||||||
114
|
|
||||||
114
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object InspectorSplitter: TSplitter
|
object InspectorSplitter: TSplitter
|
||||||
|
@@ -395,6 +395,10 @@ type
|
|||||||
can be assigned to a tab of a TabControl. }
|
can be assigned to a tab of a TabControl. }
|
||||||
TsInspectorMode = (imWorkbook, imWorksheet, imCellValue, imCellProperties);
|
TsInspectorMode = (imWorkbook, imWorksheet, imCellValue, imCellProperties);
|
||||||
|
|
||||||
|
{@@ Inspector expanded nodes }
|
||||||
|
TsInspectorExpandedNode = (ienFormatSettings, ienPageLayout);
|
||||||
|
TsInspectorExpandedNodes = set of TsInspectorExpandedNode;
|
||||||
|
|
||||||
{@@ TsSpreadsheetInspector displays all properties of a workbook, worksheet,
|
{@@ TsSpreadsheetInspector displays all properties of a workbook, worksheet,
|
||||||
cell content and cell formatting in a way similar to the Object Inspector
|
cell content and cell formatting in a way similar to the Object Inspector
|
||||||
of Lazarus. }
|
of Lazarus. }
|
||||||
@@ -402,11 +406,14 @@ type
|
|||||||
private
|
private
|
||||||
FWorkbookSource: TsWorkbookSource;
|
FWorkbookSource: TsWorkbookSource;
|
||||||
FMode: TsInspectorMode;
|
FMode: TsInspectorMode;
|
||||||
|
FExpanded: TsInspectorExpandedNodes;
|
||||||
function GetWorkbook: TsWorkbook;
|
function GetWorkbook: TsWorkbook;
|
||||||
function GetWorksheet: TsWorksheet;
|
function GetWorksheet: TsWorksheet;
|
||||||
|
procedure SetExpanded(AValue: TsInspectorExpandedNodes);
|
||||||
procedure SetMode(AValue: TsInspectorMode);
|
procedure SetMode(AValue: TsInspectorMode);
|
||||||
procedure SetWorkbookSource(AValue: TsWorkbookSource);
|
procedure SetWorkbookSource(AValue: TsWorkbookSource);
|
||||||
protected
|
protected
|
||||||
|
procedure DblClick; override;
|
||||||
procedure DoUpdate; virtual;
|
procedure DoUpdate; virtual;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
procedure UpdateCellValue(ACell: PCell; AStrings: TStrings); virtual;
|
procedure UpdateCellValue(ACell: PCell; AStrings: TStrings); virtual;
|
||||||
@@ -432,6 +439,9 @@ type
|
|||||||
{@@ inherited from TValueListEditor, activates column titles and automatic
|
{@@ inherited from TValueListEditor, activates column titles and automatic
|
||||||
column width adjustment by default }
|
column width adjustment by default }
|
||||||
property DisplayOptions default [doColumnTitles, doAutoColResize];
|
property DisplayOptions default [doColumnTitles, doAutoColResize];
|
||||||
|
{@@ Displays subproperties }
|
||||||
|
property ExpandedNodes: TsInspectorExpandedNodes
|
||||||
|
read FExpanded write SetExpanded default [ienFormatSettings, ienPageLayout];
|
||||||
{@@ inherited from TValueListEditor. Turns of the fixed column by default}
|
{@@ inherited from TValueListEditor. Turns of the fixed column by default}
|
||||||
property FixedCols default 0;
|
property FixedCols default 0;
|
||||||
{@@ inherited from TStringGrid, but not published in TValueListEditor. }
|
{@@ inherited from TStringGrid, but not published in TValueListEditor. }
|
||||||
@@ -2457,6 +2467,7 @@ begin
|
|||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
DisplayOptions := DisplayOptions - [doKeyColFixed];
|
DisplayOptions := DisplayOptions - [doKeyColFixed];
|
||||||
FixedCols := 0;
|
FixedCols := 0;
|
||||||
|
FExpanded := [ienFormatSettings, ienPageLayout];
|
||||||
with (TitleCaptions as TStringList) do begin
|
with (TitleCaptions as TStringList) do begin
|
||||||
OnChange := nil; // This fixes an issue with Laz 1.0
|
OnChange := nil; // This fixes an issue with Laz 1.0
|
||||||
Clear;
|
Clear;
|
||||||
@@ -2476,6 +2487,32 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Double-click on an expandable line expands or collapsed the sub-items
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsSpreadsheetInspector.DblClick;
|
||||||
|
var
|
||||||
|
s: String;
|
||||||
|
expNodes: TsInspectorExpandedNodes;
|
||||||
|
begin
|
||||||
|
expNodes := FExpanded;
|
||||||
|
s := Cells[0, Row];
|
||||||
|
if (pos('FormatSettings', s) > 0) or (pos('Format settings', s) > 0) then
|
||||||
|
begin
|
||||||
|
if (ienFormatSettings in expNodes)
|
||||||
|
then Exclude(expNodes, ienFormatSettings)
|
||||||
|
else Include(expNodes, ienFormatSettings);
|
||||||
|
end else
|
||||||
|
if (pos('Page layout', s) > 0) or (pos('PageLayout', s) > 0) then
|
||||||
|
begin
|
||||||
|
if (ienPageLayout in expNodes)
|
||||||
|
then Exclude(expNodes, ienPageLayout)
|
||||||
|
else Include(expNodes, ienPageLayout);
|
||||||
|
end else
|
||||||
|
exit;
|
||||||
|
SetExpanded(expNodes);
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Updates the data shown by the inspector grid. Display depends on the FMode
|
Updates the data shown by the inspector grid. Display depends on the FMode
|
||||||
setting (workbook, worksheet, cell values, cell properties).
|
setting (workbook, worksheet, cell values, cell properties).
|
||||||
@@ -2580,6 +2617,17 @@ begin
|
|||||||
SetWorkbookSource(nil);
|
SetWorkbookSource(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Setter method for the Expanded property
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsSpreadsheetInspector.SetExpanded(AValue: TsInspectorExpandedNodes);
|
||||||
|
begin
|
||||||
|
if AValue = FExpanded then
|
||||||
|
exit;
|
||||||
|
FExpanded := AValue;
|
||||||
|
DoUpdate;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Setter method for the Mode property. This property filters groups of properties
|
Setter method for the Mode property. This property filters groups of properties
|
||||||
for display (workbook-, worksheet-, cell value- or cell formatting-related
|
for display (workbook-, worksheet-, cell value- or cell formatting-related
|
||||||
@@ -2835,7 +2883,8 @@ begin
|
|||||||
if s <> '' then Delete(s, 1, 2);
|
if s <> '' then Delete(s, 1, 2);
|
||||||
AStrings.Add('Options='+s);
|
AStrings.Add('Options='+s);
|
||||||
|
|
||||||
AStrings.Add('FormatSettings=');
|
if (ienFormatSettings in FExpanded) then begin
|
||||||
|
AStrings.Add('(-) FormatSettings=');
|
||||||
AStrings.Add(' ThousandSeparator='+AWorkbook.FormatSettings.ThousandSeparator);
|
AStrings.Add(' ThousandSeparator='+AWorkbook.FormatSettings.ThousandSeparator);
|
||||||
AStrings.Add(' DecimalSeparator='+AWorkbook.FormatSettings.DecimalSeparator);
|
AStrings.Add(' DecimalSeparator='+AWorkbook.FormatSettings.DecimalSeparator);
|
||||||
AStrings.Add(' ListSeparator='+AWorkbook.FormatSettings.ListSeparator);
|
AStrings.Add(' ListSeparator='+AWorkbook.FormatSettings.ListSeparator);
|
||||||
@@ -2867,6 +2916,8 @@ begin
|
|||||||
AStrings.Add(' PosCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.CurrencyFormat));
|
AStrings.Add(' PosCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.CurrencyFormat));
|
||||||
AStrings.Add(' NegCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.NegCurrFormat));
|
AStrings.Add(' NegCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.NegCurrFormat));
|
||||||
AStrings.Add(' TwoDigitYearCenturyWindow='+IntToStr(AWorkbook.FormatSettings.TwoDigitYearCenturyWindow));
|
AStrings.Add(' TwoDigitYearCenturyWindow='+IntToStr(AWorkbook.FormatSettings.TwoDigitYearCenturyWindow));
|
||||||
|
end else
|
||||||
|
AStrings.Add('(+) FormatSettings=(dblclick for more...)');
|
||||||
|
|
||||||
for i:=0 to AWorkbook.GetFontCount-1 do
|
for i:=0 to AWorkbook.GetFontCount-1 do
|
||||||
AStrings.Add(Format('Font%d=%s', [i, AWorkbook.GetFontAsString(i)]));
|
AStrings.Add(Format('Font%d=%s', [i, AWorkbook.GetFontAsString(i)]));
|
||||||
@@ -2912,7 +2963,9 @@ begin
|
|||||||
AStrings.Add(Format('Comments=%d items', [ASheet.Comments.Count]));
|
AStrings.Add(Format('Comments=%d items', [ASheet.Comments.Count]));
|
||||||
AStrings.Add(Format('Hyperlinks=%d items', [ASheet.Hyperlinks.Count]));
|
AStrings.Add(Format('Hyperlinks=%d items', [ASheet.Hyperlinks.Count]));
|
||||||
AStrings.Add(Format('MergedCells=%d items', [ASheet.MergedCells.Count]));
|
AStrings.Add(Format('MergedCells=%d items', [ASheet.MergedCells.Count]));
|
||||||
AStrings.Add('Page layout=');
|
if ienPageLayout in FExpanded then
|
||||||
|
begin
|
||||||
|
AStrings.Add('(+) Page layout=');
|
||||||
AStrings.Add(Format(' Orientation=%s', [GetEnumName(TypeInfo(TsPageOrientation), ord(ASheet.PageLayout.Orientation))]));
|
AStrings.Add(Format(' Orientation=%s', [GetEnumName(TypeInfo(TsPageOrientation), ord(ASheet.PageLayout.Orientation))]));
|
||||||
AStrings.Add(Format(' Page width=%.1f mm', [ASheet.PageLayout.PageWidth]));
|
AStrings.Add(Format(' Page width=%.1f mm', [ASheet.PageLayout.PageWidth]));
|
||||||
AStrings.Add(Format(' Page height=%.1f mm', [ASheet.PageLayout.PageHeight]));
|
AStrings.Add(Format(' Page height=%.1f mm', [ASheet.PageLayout.PageHeight]));
|
||||||
@@ -2946,6 +2999,8 @@ begin
|
|||||||
if po in ASheet.PageLayout.Options then s := s + '; ' + GetEnumName(typeInfo(TsPrintOption), ord(po));
|
if po in ASheet.PageLayout.Options then s := s + '; ' + GetEnumName(typeInfo(TsPrintOption), ord(po));
|
||||||
if s <> '' then Delete(s, 1, 2);
|
if s <> '' then Delete(s, 1, 2);
|
||||||
AStrings.Add(Format(' Options=%s', [s]));
|
AStrings.Add(Format(' Options=%s', [s]));
|
||||||
|
end else
|
||||||
|
AStrings.Add('(+) Page layout=(dblclick for more...)');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user