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:
wp_xxyyzz
2015-05-30 14:32:09 +00:00
parent 5b0181c297
commit dc32996691
2 changed files with 121 additions and 68 deletions

View File

@@ -71,6 +71,7 @@ object MainForm: TMainForm
Top = 23
Width = 277
Align = alClient
DefaultColWidth = 125
MouseWheelOption = mwGrid
RowCount = 30
TabOrder = 1
@@ -114,10 +115,7 @@ object MainForm: TMainForm
)
WorkbookSource = WorkbookSource
Mode = imWorkbook
ColWidths = (
114
114
)
ExtendedColSizing = True
end
end
object InspectorSplitter: TSplitter

View File

@@ -395,6 +395,10 @@ type
can be assigned to a tab of a TabControl. }
TsInspectorMode = (imWorkbook, imWorksheet, imCellValue, imCellProperties);
{@@ Inspector expanded nodes }
TsInspectorExpandedNode = (ienFormatSettings, ienPageLayout);
TsInspectorExpandedNodes = set of TsInspectorExpandedNode;
{@@ TsSpreadsheetInspector displays all properties of a workbook, worksheet,
cell content and cell formatting in a way similar to the Object Inspector
of Lazarus. }
@@ -402,11 +406,14 @@ type
private
FWorkbookSource: TsWorkbookSource;
FMode: TsInspectorMode;
FExpanded: TsInspectorExpandedNodes;
function GetWorkbook: TsWorkbook;
function GetWorksheet: TsWorksheet;
procedure SetExpanded(AValue: TsInspectorExpandedNodes);
procedure SetMode(AValue: TsInspectorMode);
procedure SetWorkbookSource(AValue: TsWorkbookSource);
protected
procedure DblClick; override;
procedure DoUpdate; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure UpdateCellValue(ACell: PCell; AStrings: TStrings); virtual;
@@ -432,6 +439,9 @@ type
{@@ inherited from TValueListEditor, activates column titles and automatic
column width adjustment by default }
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}
property FixedCols default 0;
{@@ inherited from TStringGrid, but not published in TValueListEditor. }
@@ -2457,6 +2467,7 @@ begin
inherited Create(AOwner);
DisplayOptions := DisplayOptions - [doKeyColFixed];
FixedCols := 0;
FExpanded := [ienFormatSettings, ienPageLayout];
with (TitleCaptions as TStringList) do begin
OnChange := nil; // This fixes an issue with Laz 1.0
Clear;
@@ -2476,6 +2487,32 @@ begin
inherited Destroy;
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
setting (workbook, worksheet, cell values, cell properties).
@@ -2580,6 +2617,17 @@ begin
SetWorkbookSource(nil);
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
for display (workbook-, worksheet-, cell value- or cell formatting-related
@@ -2835,7 +2883,8 @@ begin
if s <> '' then Delete(s, 1, 2);
AStrings.Add('Options='+s);
AStrings.Add('FormatSettings=');
if (ienFormatSettings in FExpanded) then begin
AStrings.Add('(-) FormatSettings=');
AStrings.Add(' ThousandSeparator='+AWorkbook.FormatSettings.ThousandSeparator);
AStrings.Add(' DecimalSeparator='+AWorkbook.FormatSettings.DecimalSeparator);
AStrings.Add(' ListSeparator='+AWorkbook.FormatSettings.ListSeparator);
@@ -2867,6 +2916,8 @@ begin
AStrings.Add(' PosCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.CurrencyFormat));
AStrings.Add(' NegCurrencyFormat='+IntToStr(AWorkbook.FormatSettings.NegCurrFormat));
AStrings.Add(' TwoDigitYearCenturyWindow='+IntToStr(AWorkbook.FormatSettings.TwoDigitYearCenturyWindow));
end else
AStrings.Add('(+) FormatSettings=(dblclick for more...)');
for i:=0 to AWorkbook.GetFontCount-1 do
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('Hyperlinks=%d items', [ASheet.Hyperlinks.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(' Page width=%.1f mm', [ASheet.PageLayout.PageWidth]));
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 s <> '' then Delete(s, 1, 2);
AStrings.Add(Format(' Options=%s', [s]));
end else
AStrings.Add('(+) Page layout=(dblclick for more...)');
end;
end;