[Lazarus] How to hide class names in a property grid?
Gabor Boros
gaborboros at yahoo.com
Sat Nov 14 18:53:16 CET 2015
2015.11.14. 16:57 keltezéssel, Mattias Gaertner írta:
>> I created a property and attached the patch. Please review.
>
> Only TClassPropertyEditor shows the classname. Descends like
> TPersistentPropertyEditor shows the name for Components.
>
> Maybe better make the option a class option of TClassPropertyEditor.
New patch attached. I hope better than the previous.
Gabor
-------------- next part --------------
Index: components/ideintf/objectinspector.pp
===================================================================
--- components/ideintf/objectinspector.pp (revision 50331)
+++ components/ideintf/objectinspector.pp (working copy)
@@ -295,6 +295,7 @@
FActiveRowBmp: TCustomBitmap;
FFirstClickTime: DWORD;
FKeySearchText: string;
+ FHideClassNames: Boolean;
// hint stuff
FHintTimer: TTimer;
@@ -507,6 +508,7 @@
property TopY: integer read FTopY write SetTopY default 0;
property Favorites: TOIFavoriteProperties read FFavorites write SetFavorites;
property Filter : TTypeKinds read FFilter write SetFilter;
+ property HideClassNames: Boolean read FHideClassNames write FHideClassNames;
end;
@@ -1859,6 +1861,8 @@
end;
if PropEditor is TClassPropertyEditor then
(PropEditor as TClassPropertyEditor).SubPropsTypeFilter := FFilter;
+ if PropEditor is TClassPropertyEditor then
+ (PropEditor as TClassPropertyEditor).HideClassName:=FHideClassNames;
NewRow := TOIPropertyGridRow.Create(Self, PropEditor, nil, WidgetSets);
FRows.Add(NewRow);
if FRows.Count>1 then begin
@@ -1983,6 +1987,8 @@
begin
if PropEditor is TClassPropertyEditor then
(PropEditor as TClassPropertyEditor).SubPropsTypeFilter := FFilter;
+ if PropEditor is TClassPropertyEditor then
+ (PropEditor as TClassPropertyEditor).HideClassName:=FHideClassNames;
NewRow:=TOIPropertyGridRow.Create(Self,PropEditor,FExpandingRow, []);
NewIndex:=FExpandingRow.Index+1+FExpandingRow.ChildCount;
NewRow.FIndex:=NewIndex;
Index: components/ideintf/propedits.pp
===================================================================
--- components/ideintf/propedits.pp (revision 50331)
+++ components/ideintf/propedits.pp (working copy)
@@ -571,6 +571,7 @@
TClassPropertyEditor = class(TPropertyEditor)
private
FSubPropsTypeFilter: TTypeKinds;
+ FHideClassName: Boolean;
procedure SetSubPropsTypeFilter(const AValue: TTypeKinds);
function EditorFilter(const AEditor: TPropertyEditor): Boolean;
protected
@@ -584,6 +585,7 @@
property SubPropsTypeFilter: TTypeKinds
read FSubPropsTypeFilter write SetSubPropsTypeFilter default tkAny;
+ property HideClassName: Boolean read FHideClassName write FHideClassName;
end;
{ TMethodPropertyEditor
@@ -4222,7 +4224,7 @@
function TClassPropertyEditor.GetValue: ansistring;
begin
- Result:='(' + GetPropType^.Name + ')';
+ if not FHideClassName then Result:='(' + GetPropType^.Name + ')';
end;
procedure TClassPropertyEditor.SetSubPropsTypeFilter(const AValue: TTypeKinds);
More information about the Lazarus
mailing list