diff --git a/designer/objectinspector.pp b/designer/objectinspector.pp index f6e4bb0160..2a51813e37 100644 --- a/designer/objectinspector.pp +++ b/designer/objectinspector.pp @@ -129,10 +129,13 @@ type public Index:integer; LastPaintedValue:string; + function GetBottom:integer; + function IsReadOnly: boolean; + public property Editor:TPropertyEditor read FEditor; property Top:integer read FTop write FTop; property Height:integer read FHeight write FHeight; - function Bottom:integer; + property Bottom: integer read GetBottom; property Lvl:integer read FLvl; property Name:string read FName; property Expanded:boolean read FExpanded; @@ -904,12 +907,14 @@ begin ValueComboBox.Items.Text:=''; ValueComboBox.Items.Clear; ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes; + ValueComboBox.Enabled:=not NewRow.IsReadOnly; NewRow.Editor.GetValues(@AddStringToComboBox); ValueComboBox.Text:=NewValue; ValueComboBox.Items.EndUpdate; end else begin FCurrentEdit:=ValueEdit; - ValueEdit.ReadOnly:=paReadOnly in NewRow.Editor.GetAttributes; + ValueEdit.ReadOnly:=NewRow.IsReadOnly; + ValueEdit.Enabled:=true; ValueEdit.MaxLength:=NewRow.Editor.GetEditLimit; ValueEdit.Text:=NewValue; end; @@ -918,13 +923,14 @@ begin if FPropertyEditorHook<>nil then FCurrentEditorLookupRoot:=FPropertyEditorHook.LookupRoot; FCurrentEdit.Visible:=true; - FCurrentEdit.Enabled:=true; - if (FDragging=false) and (FCurrentEdit.Showing) then begin + if (FDragging=false) and (FCurrentEdit.Showing) + and FCurrentEdit.Enabled + and (not NewRow.IsReadOnly) then begin FCurrentEdit.SetFocus; end; end; if FCurrentButton<>nil then - FCurrentButton.Enabled:=true; + FCurrentButton.Enabled:=not NewRow.IsReadOnly; end; Exclude(FStates,pgsChangingItemIndex); end; @@ -1175,6 +1181,7 @@ begin ShrinkRow(Index) else ExpandRow(Index); + ItemIndex:=Index; end; end else begin ItemIndex:=Index; @@ -1873,11 +1880,27 @@ begin end; end; -function TOIPropertyGridRow.Bottom:integer; +function TOIPropertyGridRow.GetBottom:integer; begin Result:=FTop+FHeight; end; +function TOIPropertyGridRow.IsReadOnly: boolean; +var + ParentRow: TOIPropertyGridRow; +begin + Result:=Editor.IsReadOnly; + if Result then exit; + ParentRow:=Parent; + while (ParentRow<>nil) do begin + if paReadOnlySubProperties in ParentRow.Editor.GetAttributes then begin + Result:=true; + exit; + end; + ParentRow:=ParentRow.Parent; + end; +end; + //============================================================================== diff --git a/designer/propedits.pp b/designer/propedits.pp index 03e1ed36d8..7943c58427 100644 --- a/designer/propedits.pp +++ b/designer/propedits.pp @@ -136,6 +136,7 @@ type rendered the full width of the inspector. paVolatileSubProperties: Any change of property value causes any shown subproperties to be recollected. + paReadOnlySubProperties: All subproperties are readonly. paReference: Property contains a reference to something else. When used in conjunction with paSubProperties the referenced object should be displayed as sub properties to this @@ -248,6 +249,7 @@ type paRevertable, paFullWidthName, paVolatileSubProperties, + paReadOnlySubProperties, paReference, paNotNestable ); @@ -311,6 +313,7 @@ type function AutoFill: Boolean; virtual; procedure Edit; virtual; function GetAttributes: TPropertyAttributes; virtual; + function IsReadOnly: boolean; virtual; function GetComponent(Index: Integer):TPersistent; function GetEditLimit: Integer; virtual; function GetName: shortstring; virtual; @@ -441,9 +444,12 @@ type should. This is useful for properties like the TSetElementPropertyEditor. } TNestedPropertyEditor = class(TPropertyEditor) + private + FParentEditor: TPropertyEditor; public constructor Create(Parent: TPropertyEditor); overload; destructor Destroy; override; + property ParentEditor: TPropertyEditor read FParentEditor; end; { TSetElementPropertyEditor @@ -1577,8 +1583,7 @@ begin 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 + // -> create a property editor for each property for I := 0 to Candidates.Count - 1 do begin EdClass := GetEditorClass(Candidates[I], Obj); @@ -1683,6 +1688,11 @@ begin Result:=[paMultiSelect,paRevertable]; end; +function TPropertyEditor.IsReadOnly: boolean; +begin + Result:=paReadOnly in GetAttributes; +end; + function TPropertyEditor.GetComponent(Index:Integer):TPersistent; begin Result:=FPropList^[Index].Instance; @@ -2511,6 +2521,7 @@ end; constructor TNestedPropertyEditor.Create(Parent: TPropertyEditor); begin + FParentEditor:=Parent; FPropertyHook:=Parent.PropertyHook; FComponents:=Parent.FComponents; FPropList:=Parent.FPropList;