SynEdit Gutter: Refactor, add ability to save GutterParts to LFM file (Designer)

git-svn-id: trunk@18331 -
This commit is contained in:
martin 2009-01-18 17:46:11 +00:00
parent 77c9b560ff
commit 76ed95a0d7
8 changed files with 749 additions and 0 deletions

7
.gitattributes vendored
View File

@ -1344,8 +1344,15 @@ components/sqlite/tsqlite3dataset.png -text
components/sqlite/tsqlitedataset.png -text
components/synedit/allsyneditunits.pp svneol=native#text/pascal
components/synedit/design/README.txt svneol=native#text/plain
components/synedit/design/syndesignstringconstants.pas svneol=native#text/plain
components/synedit/design/syneditdesign.lpk svneol=native#text/plain
components/synedit/design/syneditdesign.pas svneol=native#text/plain
components/synedit/design/syneditdesignregister.pas svneol=native#text/plain
components/synedit/design/syneditlazdsgn.bat svneol=native#text/plain
components/synedit/design/syneditlazdsgn.txt svneol=native#text/plain
components/synedit/design/synpropertyeditobjectlist.lfm svneol=native#text/plain
components/synedit/design/synpropertyeditobjectlist.lrs svneol=native#text/plain
components/synedit/design/synpropertyeditobjectlist.pas svneol=native#text/plain
components/synedit/design/tsynanysyn.png -text svneol=unset#image/png
components/synedit/design/tsynautocomplete.png -text svneol=unset#image/png
components/synedit/design/tsyncppsyn.png -text svneol=unset#image/png

View File

@ -0,0 +1,21 @@
unit SynDesignStringConstants;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
resourcestring
syndsLineNumbers = 'Line Numbers';
syndsCodeFolding = 'Code fFolding';
syndsChangeMarker = 'Change Marker';
syndsBookmarks = 'Bookmarks';
syndsSeparator = 'Separator';
implementation
end.

View File

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="3">
<PathDelim Value="\"/>
<Name Value="SynEditDesign"/>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
<VerifyObjMethodCallValidity Value="True"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="5">
<Item1>
<Filename Value="synpropertyeditobjectlist.lfm"/>
<Type Value="LFM"/>
</Item1>
<Item2>
<Filename Value="synpropertyeditobjectlist.lrs"/>
<Type Value="LRS"/>
</Item2>
<Item3>
<Filename Value="synpropertyeditobjectlist.pas"/>
<UnitName Value="SynPropertyEditObjectList"/>
</Item3>
<Item4>
<Filename Value="syneditdesignregister.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="SynEditDesignRegister"/>
</Item4>
<Item5>
<Filename Value="syndesignstringconstants.pas"/>
<UnitName Value="syndesignstringconstants"/>
</Item5>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
</Item2>
<Item3>
<PackageName Value="SynEdit"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,21 @@
{ This file was automatically created by Lazarus. do not edit !
This source is only used to compile and install the package.
}
unit SynEditDesign;
interface
uses
SynPropertyEditObjectList, SynEditDesignRegister, SynDesignStringConstants, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('SynEditDesignRegister', @SynEditDesignRegister.Register);
end;
initialization
RegisterPackage('SynEditDesign', @Register);
end.

View File

@ -0,0 +1,30 @@
unit SynEditDesignRegister;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
SynGutter, SynGutterChanges,SynGutterCodeFolding, SynGutterLineNumber,
SynGutterMarks, SynPropertyEditObjectList, SynEdit, SynDesignStringConstants,
LazarusPackageIntf, LResources, PropEdits;
procedure Register;
implementation
procedure Register;
begin
RegisterPropertyEditor(ClassTypeInfo(TSynGutterPartList), nil,
'', TSynPropertyEditGutterPartList);
RegisterGutterPartClass(TSynGutterLineNumber, syndsLineNumbers);
RegisterGutterPartClass(TSynGutterCodeFolding, syndsCodeFolding);
RegisterGutterPartClass(TSynGutterChanges, syndsChangeMarker);
RegisterGutterPartClass(TSynGutterMarks, syndsBookmarks);
RegisterGutterPartClass(TSynGutterSeparator, syndsSeparator);
end;
end.

View File

@ -0,0 +1,89 @@
object SynObjectPartListPropertyEditorForm: TSynObjectPartListPropertyEditorForm
Left = 207
Height = 300
Top = 207
Width = 190
ActiveControl = SynObjectPartsListBox
BorderStyle = bsSizeToolWin
Caption = 'SynObjectPartListPropertyEditorForm'
ClientHeight = 300
ClientWidth = 190
Constraints.MinHeight = 100
Constraints.MinWidth = 190
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poDefaultPosOnly
LCLVersion = '0.9.27'
object ToolBar1: TToolBar
AnchorSideTop.Control = ClassComboBox
AnchorSideTop.Side = asrBottom
Left = 0
Height = 42
Top = 0
Width = 190
AutoSize = True
ButtonHeight = 40
ButtonWidth = 44
Caption = 'ToolBar1'
Ctl3D = False
ShowCaptions = True
TabOrder = 0
object AddButton: TToolButton
Left = 1
Top = 2
Caption = 'Add'
OnClick = AddButtonClick
end
object DeleteButton: TToolButton
Left = 45
Top = 2
Caption = 'Delete'
OnClick = DeleteButtonClick
end
object ToolButton3: TToolButton
Left = 89
Top = 2
Width = 10
Caption = 'ToolButton3'
Style = tbsSeparator
end
object MoveUpButton: TToolButton
Left = 99
Top = 2
Caption = 'Up'
OnClick = MoveUpButtonClick
end
object MoveDownButton: TToolButton
Left = 143
Top = 2
Caption = 'Down'
OnClick = MoveDownButtonClick
end
end
object SynObjectPartsListBox: TListBox
Left = 0
Height = 237
Top = 63
Width = 190
Align = alClient
ItemHeight = 0
OnClick = SynObjectPartsListBoxClick
TabOrder = 1
end
object ClassComboBox: TComboBox
AnchorSideTop.Control = ToolBar1
AnchorSideTop.Side = asrBottom
Left = 0
Height = 21
Top = 42
Width = 190
Align = alTop
Anchors = []
AutoComplete = False
Ctl3D = False
ItemHeight = 13
ItemWidth = 0
Style = csDropDownList
TabOrder = 2
end
end

View File

@ -0,0 +1,30 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TSynObjectPartListPropertyEditorForm','FORMDATA',[
'TPF0$TSynObjectPartListPropertyEditorForm#SynObjectPartListPropertyEditorFor'
+'m'#4'Left'#3#207#0#6'Height'#3','#1#3'Top'#3#207#0#5'Width'#3#190#0#13'Acti'
+'veControl'#7#21'SynObjectPartsListBox'#11'BorderStyle'#7#13'bsSizeToolWin'#7
+'Caption'#6'#SynObjectPartListPropertyEditorForm'#12'ClientHeight'#3','#1#11
+'ClientWidth'#3#190#0#21'Constraints.MinHeight'#2'd'#20'Constraints.MinWidth'
+#3#190#0#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#8'Posit'
+'ion'#7#16'poDefaultPosOnly'#10'LCLVersion'#6#6'0.9.27'#0#8'TToolBar'#8'Tool'
+'Bar1'#21'AnchorSideTop.Control'#7#13'ClassComboBox'#18'AnchorSideTop.Side'#7
+#9'asrBottom'#4'Left'#2#0#6'Height'#2'*'#3'Top'#2#0#5'Width'#3#190#0#8'AutoS'
+'ize'#9#12'ButtonHeight'#2'('#11'ButtonWidth'#2','#7'Caption'#6#8'ToolBar1'#5
+'Ctl3D'#8#12'ShowCaptions'#9#8'TabOrder'#2#0#0#11'TToolButton'#9'AddButton'#4
+'Left'#2#1#3'Top'#2#2#7'Caption'#6#3'Add'#7'OnClick'#7#14'AddButtonClick'#0#0
+#11'TToolButton'#12'DeleteButton'#4'Left'#2'-'#3'Top'#2#2#7'Caption'#6#6'Del'
+'ete'#7'OnClick'#7#17'DeleteButtonClick'#0#0#11'TToolButton'#11'ToolButton3'
+#4'Left'#2'Y'#3'Top'#2#2#5'Width'#2#10#7'Caption'#6#11'ToolButton3'#5'Style'
+#7#12'tbsSeparator'#0#0#11'TToolButton'#12'MoveUpButton'#4'Left'#2'c'#3'Top'
+#2#2#7'Caption'#6#2'Up'#7'OnClick'#7#17'MoveUpButtonClick'#0#0#11'TToolButto'
+'n'#14'MoveDownButton'#4'Left'#3#143#0#3'Top'#2#2#7'Caption'#6#4'Down'#7'OnC'
+'lick'#7#19'MoveDownButtonClick'#0#0#0#8'TListBox'#21'SynObjectPartsListBox'
+#4'Left'#2#0#6'Height'#3#237#0#3'Top'#2'?'#5'Width'#3#190#0#5'Align'#7#8'alC'
+'lient'#10'ItemHeight'#2#0#7'OnClick'#7#26'SynObjectPartsListBoxClick'#8'Tab'
+'Order'#2#1#0#0#9'TComboBox'#13'ClassComboBox'#21'AnchorSideTop.Control'#7#8
+'ToolBar1'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#21#3
+'Top'#2'*'#5'Width'#3#190#0#5'Align'#7#5'alTop'#7'Anchors'#11#0#12'AutoCompl'
+'ete'#8#5'Ctl3D'#8#10'ItemHeight'#2#13#9'ItemWidth'#2#0#5'Style'#7#14'csDrop'
+'DownList'#8'TabOrder'#2#2#0#0#0
]);

View File

@ -0,0 +1,477 @@
{ PropertyEditor
Copyright (C) <year> <name of author> <contact>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit SynPropertyEditObjectList;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LCLProc,
SynGutter, SynEditMiscClasses,
LResources, PropEdits, Forms, StdCtrls, ComCtrls, Dialogs,
ObjInspStrConsts, Controls, IDEImagesIntf, typinfo;
type
{ TSynPropertEditClassList }
TSynPropertyEditObjectList = class(TListPropertyEditor)
protected
function ReadElementCount: integer; override;
function ReadElement(Index: integer): TPersistent; override;
function ClassList: TStringList; virtual; abstract;
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
class function ShowClassListEditor(AClassList: TSynObjectList;
OwnerPersistent: TPersistent; const PropName: String): TCustomForm;
end;
{ TSynPropertyEditGutterPartList }
TSynPropertyEditGutterPartList = class(TSynPropertyEditObjectList)
protected
function ClassList: TStringList; override;
end;
{ TSynObjectPartListPropertyEditorForm }
TSynObjectPartListPropertyEditorForm = class(TForm)
SynObjectPartsListBox: TListBox;
ToolBar1: TToolBar;
AddButton: TToolButton;
ClassComboBox: TComboBox;
DeleteButton: TToolButton;
ToolButton3: TToolButton;
MoveUpButton: TToolButton;
MoveDownButton: TToolButton;
procedure AddButtonClick(Sender: TObject);
procedure SynObjectPartsListBoxClick(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure MoveDownButtonClick(Sender: TObject);
procedure MoveUpButtonClick(Sender: TObject);
private
FSynObjectPartList: TSynObjectList;
FOwnerPersistent: TPersistent;
FPropertyName: String;
FClassesList: TStringList;
protected
procedure UpdateCaption;
procedure UpdateButtons;
procedure ComponentRenamed(AComponent: TComponent);
procedure PersistentDeleting(APersistent: TPersistent);
procedure RefreshPropertyValues;
public
procedure FillSynObjectPartsListBox;
procedure SelectInObjectInspector(UnselectAll: Boolean);
procedure SetSynObjectPartList(NewSynObjectPartList: TSynObjectList;
NewClassesList: TStringList;
NewOwnerPersistent: TPersistent; const NewPropName: String);
procedure Modified;
public
property SynObjectPartList: TSynObjectList read FSynObjectPartList;
property OwnerPersistent: TPersistent read FOwnerPersistent;
property PropertyName: String read FPropertyName;
end;
procedure RegisterGutterPartClass(AClass: TSynGutterPartBaseClass; AName: String);
implementation
const
SynObjectPartListForm: TSynObjectPartListPropertyEditorForm = nil;
KnownSynGutterPartClasses: TStringList = nil;
procedure RegisterGutterPartClass(AClass: TSynGutterPartBaseClass; AName: String);
begin
if KnownSynGutterPartClasses = nil then
KnownSynGutterPartClasses := TStringList.Create;
KnownSynGutterPartClasses.AddObject(AName, TObject(Pointer(AClass)));
end;
{ TSynObjectPartListPropertyEditorForm }
procedure TSynObjectPartListPropertyEditorForm.AddButtonClick(Sender: TObject);
var
i: Integer;
begin
if (SynObjectPartList = nil) or (FClassesList = nil) then Exit;
i := ClassComboBox.ItemIndex;
if (i < 0) or (i >= FClassesList.Count) then
exit;
TSynObjectListItemClass(Pointer(FClassesList.Objects[i])).Create(SynObjectPartList);
FillSynObjectPartsListBox;
if SynObjectPartsListBox.Items.Count > 0 then
SynObjectPartsListBox.ItemIndex := SynObjectPartsListBox.Items.Count - 1;
SelectInObjectInspector(False);
UpdateButtons;
UpdateCaption;
Modified;
end;
procedure TSynObjectPartListPropertyEditorForm.SynObjectPartsListBoxClick(Sender: TObject);
begin
UpdateButtons;
UpdateCaption;
SelectInObjectInspector(False);
end;
procedure TSynObjectPartListPropertyEditorForm.DeleteButtonClick(Sender: TObject);
var
I : Integer;
NewItemIndex: Integer;
begin
if SynObjectPartList = nil then Exit;
I := SynObjectPartsListBox.ItemIndex;
if (I >= 0) and (I < SynObjectPartList.Count) then
begin
if MessageDlg(oisConfirmDelete,
Format(oisDeleteItem, ['"', SynObjectPartList.BaseItems[I].DisplayName, '"']),
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
// select other item, or unselect
NewItemIndex := I + 1;
while (NewItemIndex < SynObjectPartsListBox.Items.Count)
and (SynObjectPartsListBox.Selected[NewItemIndex]) do Inc(NewItemIndex);
if NewItemIndex = SynObjectPartsListBox.Items.Count then
begin
NewItemIndex := 0;
while (NewItemIndex < Pred(I))
and not (SynObjectPartsListBox.Selected[NewItemIndex]) do Inc(NewItemIndex);
if NewItemIndex = I then NewItemIndex := -1;
end;
SynObjectPartsListBox.ItemIndex := -1;
if NewItemIndex > I then Dec(NewItemIndex);
// unselect all items in OI
SelectInObjectInspector(True);
// now delete
SynObjectPartList.BaseItems[I].Free;
// update listbox after whatever happened
FillSynObjectPartsListBox;
// set NewItemIndex
if NewItemIndex < SynObjectPartsListBox.Items.Count then
begin
SynObjectPartsListBox.ItemIndex := NewItemIndex;
SelectInObjectInspector(False);
end;
Modified;
end;
end;
UpdateButtons;
UpdateCaption;
end;
procedure TSynObjectPartListPropertyEditorForm.FormCreate(Sender: TObject);
begin
ToolBar1.Images := IDEImages.Images_16;
AddButton.Caption := oiColEditAdd;
DeleteButton.Caption := oiColEditDelete;
MoveUpButton.Caption := oiColEditUp;
MoveDownButton.Caption := oiColEditDown;
AddButton.ImageIndex := IDEImages.LoadImage(16, 'laz_add');
DeleteButton.ImageIndex := IDEImages.LoadImage(16, 'laz_delete');
MoveUpButton.ImageIndex := IDEImages.LoadImage(16, 'arrow_up');
MoveDownButton.ImageIndex := IDEImages.LoadImage(16, 'arrow_down');
end;
procedure TSynObjectPartListPropertyEditorForm.FormDestroy(Sender: TObject);
begin
if GlobalDesignHook <> nil then
GlobalDesignHook.RemoveAllHandlersForObject(Self);
end;
procedure TSynObjectPartListPropertyEditorForm.MoveDownButtonClick(Sender: TObject);
var
I: Integer;
begin
if SynObjectPartList = nil then Exit;
I := SynObjectPartsListBox.ItemIndex;
if I >= SynObjectPartList.Count - 1 then Exit;
SynObjectPartList.BaseItems[I].Index := I + 1;
SynObjectPartsListBox.ItemIndex := I + 1;
FillSynObjectPartsListBox;
SelectInObjectInspector(False);
Modified;
end;
procedure TSynObjectPartListPropertyEditorForm.MoveUpButtonClick(Sender: TObject);
var
I: Integer;
begin
if SynObjectPartList = nil then Exit;
I := SynObjectPartsListBox.ItemIndex;
if I < 0 then Exit;
SynObjectPartList.BaseItems[I].Index := I - 1;
SynObjectPartsListBox.ItemIndex := I - 1;
FillSynObjectPartsListBox;
SelectInObjectInspector(False);
Modified;
end;
procedure TSynObjectPartListPropertyEditorForm.UpdateCaption;
var
NewCaption: String;
begin
//"Editing ComponentName.PropertyName[Index]"
if OwnerPersistent is TComponent then
NewCaption := TComponent(OwnerPersistent).Name
else
if OwnerPersistent <> nil then
NewCaption := OwnerPersistent.GetNamePath
else
NewCaption := '';
if NewCaption <> '' then NewCaption := NewCaption + '.';
NewCaption := oiColEditEditing + ' ' + NewCaption + PropertyName;
if SynObjectPartsListBox.ItemIndex > -1 then
NewCaption := NewCaption + '[' + IntToStr(SynObjectPartsListBox.ItemIndex) + ']';
Caption := NewCaption;
end;
procedure TSynObjectPartListPropertyEditorForm.UpdateButtons;
var
I: Integer;
begin
I := SynObjectPartsListBox.ItemIndex;
AddButton.Enabled := SynObjectPartList <> nil;
DeleteButton.Enabled := I > -1;
MoveUpButton.Enabled := I > 0;
MoveDownButton.Enabled := (I >= 0) and (I < SynObjectPartList.Count - 1);
end;
procedure TSynObjectPartListPropertyEditorForm.ComponentRenamed(AComponent: TComponent);
begin
if AComponent = OwnerPersistent then UpdateCaption;
end;
procedure TSynObjectPartListPropertyEditorForm.PersistentDeleting(APersistent: TPersistent);
var
OldSynObjectPartList: TSynObjectList;
begin
debugln(['TSynObjectPartListPropertyEditorForm.PersistentDeleting ']);
if APersistent = OwnerPersistent then
begin
debugln('xxxxxxx');
OldSynObjectPartList := SynObjectPartList;
SetSynObjectPartList(nil, nil, nil, '');
SelectInObjectInspector(True);
GlobalDesignHook.Unselect(OldSynObjectPartList); // XXX unselect all the individual parts
if GlobalDesignHook.LookupRoot = OldSynObjectPartList then
GlobalDesignHook.LookupRoot := nil;
Hide;
end;
end;
procedure TSynObjectPartListPropertyEditorForm.RefreshPropertyValues;
begin
FillSynObjectPartsListBox;
Modified;
end;
procedure TSynObjectPartListPropertyEditorForm.FillSynObjectPartsListBox;
var
I: Integer;
CurItem: String;
Cnt: Integer;
begin
SynObjectPartsListBox.Items.BeginUpdate;
try
if SynObjectPartList <> nil then Cnt := SynObjectPartList.Count
else Cnt := 0;
// add or replace list items
for I := 0 to Cnt - 1 do
begin
CurItem := IntToStr(I) + ' - ' + SynObjectPartList.BaseItems[I].DisplayName;
if I >= SynObjectPartsListBox.Items.Count then
SynObjectPartsListBox.Items.Add(CurItem)
else
SynObjectPartsListBox.Items[I] := CurItem;
end;
// delete unneeded list items
if Cnt > 0 then
begin
while SynObjectPartsListBox.Items.Count > Cnt do
begin
SynObjectPartsListBox.Items.Delete(SynObjectPartsListBox.Items.Count - 1);
end;
end
else
begin
SynObjectPartsListBox.Items.Clear;
end;
finally
SynObjectPartsListBox.Items.EndUpdate;
UpdateButtons;
UpdateCaption;
end;
end;
procedure TSynObjectPartListPropertyEditorForm.SelectInObjectInspector(UnselectAll: Boolean);
var
I: Integer;
NewSelection: TPersistentSelectionList;
begin
if SynObjectPartList = nil then Exit;
// select in OI
NewSelection := TPersistentSelectionList.Create;
try
if not UnselectAll then
begin
for I := 0 to SynObjectPartsListBox.Items.Count - 1 do
if SynObjectPartsListBox.Selected[I] then
NewSelection.Add(SynObjectPartList.BaseItems[I]);
end;
GlobalDesignHook.SetSelection(NewSelection);
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(OwnerPersistent);
finally
NewSelection.Free;
end;
end;
procedure TSynObjectPartListPropertyEditorForm.SetSynObjectPartList
(NewSynObjectPartList: TSynObjectList; NewClassesList: TStringList;
NewOwnerPersistent: TPersistent; const NewPropName: String);
begin
if (FSynObjectPartList = NewSynObjectPartList)
and (FClassesList = NewClassesList)
and (FOwnerPersistent = NewOwnerPersistent)
and (FPropertyName = NewPropName) then Exit;
FSynObjectPartList := NewSynObjectPartList;
FClassesList := NewClassesList;
if assigned(FClassesList) then
ClassComboBox.Items.Assign(FClassesList)
else
ClassComboBox.Clear;
if ClassComboBox.Items.Count >0 then
ClassComboBox.ItemIndex := 0;
if (assigned(NewOwnerPersistent)) and (NewOwnerPersistent is TSynObjectList) then
FOwnerPersistent := (NewOwnerPersistent as TSynObjectList).Owner
else
FOwnerPersistent := NewOwnerPersistent;
FPropertyName := NewPropName;
//debugln('TSynObjectPartListPropertyEditorForm.SetSynObjectPartList A SynObjectPartList=',dbgsName(FSynObjectPartList),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName);
if GlobalDesignHook <> nil then
begin
if FOwnerPersistent <> nil then
begin
GlobalDesignHook.AddHandlerComponentRenamed(@ComponentRenamed);
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
GlobalDesignHook.AddHandlerRefreshPropertyValues(@RefreshPropertyValues);
end
else
begin
GlobalDesignHook.RemoveAllHandlersForObject(Self);
end;
end;
FillSynObjectPartsListBox;
UpdateCaption;
end;
procedure TSynObjectPartListPropertyEditorForm.Modified;
begin
GlobalDesignHook.Modified(Self);
//SelectInObjectInspector(False);
end;
{ TSynPropertyEditObjectList }
function TSynPropertyEditObjectList.ReadElementCount: integer;
var
SynObjectList: TSynObjectList;
begin
SynObjectList := TSynObjectList(GetObjectValue);
if (SynObjectList <> nil) and (SynObjectList is TSynObjectList) then
Result:=SynObjectList.Count
else
Result:=0;
end;
function TSynPropertyEditObjectList.ReadElement(Index: integer): TPersistent;
var
SynObjectList: TSynObjectList;
begin
SynObjectList := TSynObjectList(GetObjectValue);
Result := SynObjectList.BaseItems[Index];
end;
function TSynPropertyEditObjectList.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
procedure TSynPropertyEditObjectList.Edit;
var
TheSynObjectList: TSynObjectList;
begin
TheSynObjectList := TSynObjectList(GetObjectValue);
if TheSynObjectList = nil then
raise Exception.Create('ObjectPartList=nil');
ShowClassListEditor(TheSynObjectList, GetComponent(0), GetName);
end;
class function TSynPropertyEditObjectList.ShowClassListEditor(AClassList: TSynObjectList;
OwnerPersistent: TPersistent; const PropName: String): TCustomForm;
begin
if SynObjectPartListForm = nil then
SynObjectPartListForm := TSynObjectPartListPropertyEditorForm.Create(Application);
SynObjectPartListForm.SetSynObjectPartList(AClassList, ClassList, OwnerPersistent, PropName);
SynObjectPartListForm.EnsureVisible;
Result := SynObjectPartListForm;
end;
{ TSynPropertyEditGutterPartList }
function TSynPropertyEditGutterPartList.ClassList: TStringList;
begin
Result := KnownSynGutterPartClasses;
end;
initialization
{$I synpropertyeditobjectlist.lrs}
if KnownSynGutterPartClasses = nil then
KnownSynGutterPartClasses := TStringList.Create;
finalization
FreeAndNil(KnownSynGutterPartClasses);
end.