Recent

Author Topic: Object Inspector - code  (Read 223 times)

J-23

  • Jr. Member
  • **
  • Posts: 69
Object Inspector - code
« on: April 06, 2020, 09:47:49 pm »
Builds my own: Inspector Object with additions from scratch. I need to connect to the editors stitched in the components and I started analyzing the default Inspector Object (included in Lazarus). After my observations there are a few unused property there (I think it is a residue from previous versions) as an example I will give such properties as:

Code: Pascal  [Select][+][-]
  1.    property Favorites: TOIFavoriteProperties read FFavorites write SetFavorites;    
  2.    property PropNameFilter : String read FPropNameFilter write FPropNameFilter;      
  3.  

These are the properties of the TOICustomPropertyGrid class located in the "ObjectInspector.pp" file line 267 in the Lazarus directory

I still have doubts about the procedure:

Code: Pascal  [Select][+][-]
  1. @AddPropertyEditor
  2.  

which is used by:
  GetPersistentProperties (FSelection, FFilter + [tkClass], FPropertyEditorHook,
       @AddPropertyEditor, @EditorFilter);

Code: Pascal  [Select][+][-]
  1. procedure TOICustomPropertyGrid.AddPropertyEditor(PropEditor: TPropertyEditor);
  2. var
  3.   NewRow: TOIPropertyGridRow;
  4.   WidgetSets: TLCLPlatforms;
  5. begin
  6.   WidgetSets := [];
  7.   if Favorites<>nil then begin
  8.     //debugln('TOICustomPropertyGrid.AddPropertyEditor A ',PropEditor.GetName);
  9.     if Favorites is TOIRestrictedProperties then
  10.     begin
  11.       WidgetSets := (Favorites as TOIRestrictedProperties).AreRestricted(
  12.                                                   Selection,PropEditor.GetName);
  13.       if WidgetSets = [] then
  14.       begin
  15.         PropEditor.Free;
  16.         Exit;
  17.       end;
  18.     end
  19.     else
  20.       if not Favorites.AreFavorites(Selection,PropEditor.GetName) then begin
  21.         PropEditor.Free;
  22.         exit;
  23.       end;
  24.   end;
  25.   if PropEditor is TClassPropertyEditor then
  26.   begin
  27.     (PropEditor as TClassPropertyEditor).SubPropsNameFilter := PropNameFilter;
  28.     (PropEditor as TClassPropertyEditor).SubPropsTypeFilter := FFilter;
  29.     (PropEditor as TClassPropertyEditor).HideClassName:=FHideClassNames;
  30.   end;
  31.   NewRow := TOIPropertyGridRow.Create(Self, PropEditor, nil, WidgetSets);
  32.   FRows.Add(NewRow);
  33.   if FRows.Count>1 then begin
  34.     NewRow.FPriorBrother:=Rows[FRows.Count-2];
  35.     NewRow.FPriorBrother.FNextBrother:=NewRow;
  36.   end;
  37. end;
  38.  

Condition:
Code: Pascal  [Select][+][-]
  1. if Favorites<>nil then begin
  2.  

It will never be made because the Favorites property has not been used anywhere (I think)

Now the question is, am I right that these are the remains of the previous code?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3761
  • I like bugs.
Re: Object Inspector - code
« Reply #1 on: April 06, 2020, 11:23:47 pm »
Builds my own: Inspector Object with additions from scratch. I need to connect to the editors stitched in the components and I started analyzing the default Inspector Object (included in Lazarus).
You can also use Object Inspector directly from its IdeIntf package. Possible bugs can be fixed and missing features added if needed.

Quote
Condition:
Code: Pascal  [Select][+][-]
  1. if Favorites<>nil then begin
It will never be made because the Favorites property has not been used anywhere (I think)
It is used for the "Favorites" and "Restricted" tabs in Object Inspector. You can debug the code by placing DebugLn() calls there, building Lazarus and then looking at the log output. For example uncomment the debugln already in AddPropertyEditor and see how it produces tons of output.
The test "Favorites is TOIRestrictedProperties" looks strange first but it inherits like this:
Code: Pascal  [Select][+][-]
  1. TOIRestrictedProperties = class(TOIFavoriteProperties)

PropNameFilter is used for the user's manual filtering by PropFilterEdit. It is set in procedure TObjectInspectorDlg.PropFilterEditAfterFilter.
Code: Pascal  [Select][+][-]
  1. GetActivePropertyGrid.PropNameFilter := PropFilterEdit.Filter;
You can find the assignment with "Find" or "Find in Files" easily.
Hint: "Find in Files" also has a "search in active file" option. Handy in some cases.
« Last Edit: April 06, 2020, 11:35:30 pm by JuhaManninen »

J-23

  • Jr. Member
  • **
  • Posts: 69
Re: Object Inspector - code
« Reply #2 on: April 07, 2020, 02:26:19 pm »
Builds my own: Inspector Object with additions from scratch. I need to connect to the editors stitched in the components and I started analyzing the default Inspector Object (included in Lazarus).
You can also use Object Inspector directly from its IdeIntf package. Possible bugs can be fixed and missing features added if needed.

Quote
Condition:
Code: Pascal  [Select][+][-]
  1. if Favorites<>nil then begin
It will never be made because the Favorites property has not been used anywhere (I think)
It is used for the "Favorites" and "Restricted" tabs in Object Inspector. You can debug the code by placing DebugLn() calls there, building Lazarus and then looking at the log output. For example uncomment the debugln already in AddPropertyEditor and see how it produces tons of output.
The test "Favorites is TOIRestrictedProperties" looks strange first but it inherits like this:
Code: Pascal  [Select][+][-]
  1. TOIRestrictedProperties = class(TOIFavoriteProperties)

PropNameFilter is used for the user's manual filtering by PropFilterEdit. It is set in procedure TObjectInspectorDlg.PropFilterEditAfterFilter.
Code: Pascal  [Select][+][-]
  1. GetActivePropertyGrid.PropNameFilter := PropFilterEdit.Filter;
You can find the assignment with "Find" or "Find in Files" easily.
Hint: "Find in Files" also has a "search in active file" option. Handy in some cases.

Hello, thanks for the clarification regarding my ownership.

 

TinyPortal © 2005-2018