mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:39:44 +02:00
MG: TComponentPropertyEditor now shows child properties
git-svn-id: trunk@3300 -
This commit is contained in:
parent
a188d432fd
commit
64d87305f7
@ -235,115 +235,11 @@ type
|
||||
TPropertyEditorFilterFunc =
|
||||
function(const ATestEditor: TPropertyEditor): Boolean of object;
|
||||
|
||||
procedure GetComponentProperties(Components: TComponentSelectionList;
|
||||
Filter: TTypeKinds; Hook: TPropertyEditorHook; Proc: TGetPropEditProc;
|
||||
EditorFilterFunc: TPropertyEditorFilterFunc);
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
procedure GetComponentProperties(Components: TComponentSelectionList;
|
||||
Filter: TTypeKinds; Hook: TPropertyEditorHook; Proc: TGetPropEditProc;
|
||||
EditorFilterFunc: TPropertyEditorFilterFunc);
|
||||
var
|
||||
I, J, CompCount: Integer;
|
||||
CompType: TClass;
|
||||
Candidates: TPropInfoList;
|
||||
PropLists: TList;
|
||||
PropEditor: TPropertyEditor;
|
||||
EdClass: TPropertyEditorClass;
|
||||
PropInfo: PPropInfo;
|
||||
AddEditor: Boolean;
|
||||
Obj: TComponent;
|
||||
begin
|
||||
if (Components = nil) or (Components.Count = 0) then Exit;
|
||||
CompCount := Components.Count;
|
||||
Obj := Components[0];
|
||||
CompType := Components[0].ClassType;
|
||||
// Create a property candidate list of all properties that can be found in
|
||||
// every component in the list and in the Filter
|
||||
Candidates := TPropInfoList.Create(Components[0], Filter);
|
||||
try
|
||||
// check each property candidate
|
||||
for I := Candidates.Count - 1 downto 0 do
|
||||
begin
|
||||
PropInfo := Candidates[I];
|
||||
// check if property is readable
|
||||
if (PropInfo^.GetProc=nil)
|
||||
or (not GShowReadOnlyProps and ((PropInfo^.PropType^.Kind <> tkClass)
|
||||
and (PropInfo^.SetProc = nil)))
|
||||
then begin
|
||||
Candidates.Delete(I);
|
||||
continue;
|
||||
end;
|
||||
EdClass := GetEditorClass(PropInfo, Obj);
|
||||
if EdClass = nil then
|
||||
Candidates.Delete(I)
|
||||
else
|
||||
begin
|
||||
// create a test property editor for the property
|
||||
PropEditor := EdClass.Create(Hook,Components,1);
|
||||
PropEditor.SetPropEntry(0, Components[0], PropInfo);
|
||||
PropEditor.Initialize;
|
||||
with PropInfo^ do
|
||||
// check for multiselection, ValueAvailable and customfilter
|
||||
if ((CompCount > 1)
|
||||
and not (paMultiSelect in PropEditor.GetAttributes))
|
||||
or not PropEditor.ValueAvailable
|
||||
or (Assigned(EditorFilterFunc) and not EditorFilterFunc(PropEditor))
|
||||
then
|
||||
Candidates.Delete(I);
|
||||
end;
|
||||
end;
|
||||
PropLists := TList.Create;
|
||||
try
|
||||
PropLists.Capacity := CompCount;
|
||||
// Create a property info list for each component in the selection
|
||||
for I := 0 to CompCount - 1 do
|
||||
PropLists.Add(TPropInfoList.Create(Components[I], Filter));
|
||||
// Eliminate each property in Candidates that is not in all property lists
|
||||
for I := 0 to CompCount - 1 do
|
||||
Candidates.Intersect(TPropInfoList(PropLists[I]));
|
||||
// Eliminate each property in the property list that are not in Candidates
|
||||
for I := 0 to CompCount - 1 do
|
||||
TPropInfoList(PropLists[I]).Intersect(Candidates);
|
||||
// PropList now has a matrix of PropInfo's.
|
||||
// -> create property editors for each property
|
||||
// with given each the array of PropInfos
|
||||
for I := 0 to Candidates.Count - 1 do
|
||||
begin
|
||||
EdClass := GetEditorClass(Candidates[I], Obj);
|
||||
if EdClass = nil then Continue;
|
||||
PropEditor := EdClass.Create(Hook, Components, CompCount);
|
||||
AddEditor := True;
|
||||
for J := 0 to CompCount - 1 do
|
||||
begin
|
||||
if (Components[J].ClassType <> CompType) and
|
||||
(GetEditorClass(TPropInfoList(PropLists[J])[I],
|
||||
Components[J]) <> EdClass) then
|
||||
begin
|
||||
AddEditor := False;
|
||||
Break;
|
||||
end;
|
||||
PropEditor.SetPropEntry(J, Components[J],
|
||||
TPropInfoList(PropLists[J])[I]);
|
||||
end;
|
||||
if AddEditor then
|
||||
begin
|
||||
PropEditor.Initialize;
|
||||
if PropEditor.ValueAvailable then Proc(PropEditor);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
for I := 0 to PropLists.Count - 1 do TPropInfoList(PropLists[I]).Free;
|
||||
PropLists.Free;
|
||||
end;
|
||||
finally
|
||||
Candidates.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ RegisterComponentEditor }
|
||||
type
|
||||
|
@ -576,8 +576,10 @@ begin
|
||||
end;
|
||||
|
||||
procedure TOIPropertyGrid.SetRowValue;
|
||||
var CurRow:TOIPropertyGridRow;
|
||||
NewValue:string;
|
||||
var
|
||||
CurRow: TOIPropertyGridRow;
|
||||
NewValue: string;
|
||||
OldExpanded: boolean;
|
||||
begin
|
||||
if (FStates*[pgsChangingItemIndex,pgsApplyingValue]=[])
|
||||
and (FCurrentEdit<>nil)
|
||||
@ -598,6 +600,13 @@ begin
|
||||
MessageDlg('Error',E.Message,mtError,[mbOk],0);
|
||||
end;
|
||||
end;
|
||||
if (paVolatileSubProperties in CurRow.Editor.GetAttributes)
|
||||
and ((CurRow.Expanded) or (CurRow.ChildCount>0)) then begin
|
||||
OldExpanded:=CurRow.Expanded;
|
||||
ShrinkRow(FitemIndex);
|
||||
if OldExpanded then
|
||||
ExpandRow(FItemIndex);
|
||||
end;
|
||||
if FCurrentEdit=ValueEdit then
|
||||
ValueEdit.Text:=CurRow.Editor.GetVisualValue
|
||||
else
|
||||
@ -758,9 +767,9 @@ begin
|
||||
ItemIndex:=-1;
|
||||
for a:=0 to FRows.Count-1 do Rows[a].Free;
|
||||
FRows.Clear;
|
||||
GetComponentProperties(FPropertyEditorHook,FComponentList,FFilter,
|
||||
@AddPropertyEditor);
|
||||
|
||||
GetComponentProperties(FComponentList,FFilter,FPropertyEditorHook,
|
||||
@AddPropertyEditor,nil);
|
||||
|
||||
FRows.Sort(@SortGridRows);
|
||||
SetItemsTops;
|
||||
for a:=FExpandedProperties.Count-1 downto 0 do begin
|
||||
@ -851,6 +860,8 @@ begin
|
||||
end;
|
||||
ARow:=ARow.Parent;
|
||||
end;
|
||||
if (FItemIndex>=StartIndex) and (FItemIndex<=EndIndex) then
|
||||
ItemIndex:=0;
|
||||
for a:=StartIndex downto EndIndex do begin
|
||||
Rows[a].Free;
|
||||
FRows.Delete(a);
|
||||
|
@ -327,6 +327,8 @@ type
|
||||
procedure PaintGrid; virtual; abstract;
|
||||
procedure ValidateRename(AComponent: TComponent;
|
||||
const CurName, NewName: string); virtual; abstract;
|
||||
function GetShiftState: TShiftState; virtual; abstract;
|
||||
Procedure SelectOnlyThisComponent(AComponent:TComponent); virtual; abstract;
|
||||
end;
|
||||
|
||||
|
||||
@ -337,7 +339,7 @@ function KeysToShiftState(Keys:Word): TShiftState;
|
||||
function KeyDataToShiftState(KeyData: Longint): TShiftState;
|
||||
|
||||
function GetParentForm(Control:TControl): TCustomForm;
|
||||
function FindDesigner(AComponent: TComponent): TIDesigner;
|
||||
function FindRootDesigner(AComponent: TComponent): TIDesigner;
|
||||
|
||||
function IsAccel(VK : Word; const Str : ShortString): Boolean;
|
||||
|
||||
@ -489,7 +491,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function FindDesigner(AComponent: TComponent): TIDesigner;
|
||||
function FindRootDesigner(AComponent: TComponent): TIDesigner;
|
||||
var
|
||||
Form: TCustomForm;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user