IDEIntf: object inspector: support unicodestring properties, added Filter property

git-svn-id: trunk@53348 -
This commit is contained in:
mattias 2016-11-11 18:53:12 +00:00
parent 7b6d4222ec
commit 36882d29bb
2 changed files with 127 additions and 50 deletions

View File

@ -60,6 +60,11 @@ const
DefGutterColor = DefBackgroundColor; DefGutterColor = DefBackgroundColor;
DefGutterEdgeColor = cl3DShadow; DefGutterEdgeColor = cl3DShadow;
DefaultOITypeKinds = [
tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkSet,{ tkMethod,}
tkSString, tkLString, tkAString, tkWString, tkVariant,
{tkArray, tkRecord, tkInterface,} tkClass, tkObject, tkWChar, tkBool,
tkInt64, tkQWord, tkUString, tkUChar];
type type
EObjectInspectorException = class(Exception); EObjectInspectorException = class(Exception);
@ -678,52 +683,68 @@ type
procedure PropFilterEditAfterFilter(Sender: TObject); procedure PropFilterEditAfterFilter(Sender: TObject);
procedure NoteBookPageChange(Sender: TObject); procedure NoteBookPageChange(Sender: TObject);
private private
StateOfHintsOnMainPopupMenu: Boolean; FAutoShow: Boolean;
FCheckboxForBoolean: Boolean;
FComponentEditor: TBaseComponentEditor;
FDefaultItemHeight: integer;
FEnableHookGetSelection: boolean;
FFavorites: TOIFavoriteProperties; FFavorites: TOIFavoriteProperties;
FFilter: TTypeKinds;
FFlags: TOIFlags;
FInfoBoxHeight: integer; FInfoBoxHeight: integer;
FOnPropertyHint: TOIPropertyHint; FLastActiveRowName: String;
FOnSelectionChange: TNotifyEvent; FOnAddAvailablePersistent: TOnAddAvailablePersistent;
FRestricted: TOIRestrictedProperties;
FOnAddToFavorites: TNotifyEvent; FOnAddToFavorites: TNotifyEvent;
FOnAutoShow: TNotifyEvent;
FOnFindDeclarationOfProperty: TNotifyEvent; FOnFindDeclarationOfProperty: TNotifyEvent;
FOnModified: TNotifyEvent;
FOnNodeGetImageIndex: TOnOINodeGetImageEvent;
FOnOIKeyDown: TKeyEvent; FOnOIKeyDown: TKeyEvent;
FOnPropertyHint: TOIPropertyHint;
FOnRemainingKeyDown: TKeyEvent; FOnRemainingKeyDown: TKeyEvent;
FOnRemainingKeyUp: TKeyEvent; FOnRemainingKeyUp: TKeyEvent;
FOnRemoveFromFavorites: TNotifyEvent; FOnRemoveFromFavorites: TNotifyEvent;
FOnSelectionChange: TNotifyEvent;
FOnSelectPersistentsInOI: TNotifyEvent;
FOnShowOptions: TNotifyEvent;
FOnUpdateRestricted: TNotifyEvent; FOnUpdateRestricted: TNotifyEvent;
FOnViewRestricted: TNotifyEvent; FOnViewRestricted: TNotifyEvent;
FSelection: TPersistentSelectionList;
FDefaultItemHeight: integer;
FFlags: TOIFlags;
FOnShowOptions: TNotifyEvent;
FPropertyEditorHook: TPropertyEditorHook; FPropertyEditorHook: TPropertyEditorHook;
FOnAddAvailablePersistent: TOnAddAvailablePersistent; FRefreshingSelectionCount: integer;
FOnSelectPersistentsInOI: TNotifyEvent; FRestricted: TOIRestrictedProperties;
FOnModified: TNotifyEvent; FSelection: TPersistentSelectionList;
FAutoShow: Boolean; FSettingSelectionCount: integer;
FCheckboxForBoolean: Boolean;
FShowComponentTree: Boolean; FShowComponentTree: Boolean;
FShowFavorites: Boolean; FShowFavorites: Boolean;
FShowInfoBox: Boolean; FShowInfoBox: Boolean;
FShowRestricted: Boolean; FShowRestricted: Boolean;
FShowStatusBar: Boolean; FShowStatusBar: Boolean;
FStateOfHintsOnMainPopupMenu: Boolean;
FUpdateLock: integer; FUpdateLock: integer;
FUpdatingAvailComboBox: Boolean; FUpdatingAvailComboBox: Boolean;
FComponentEditor: TBaseComponentEditor; function GetComponentPanelHeight: integer;
FOnNodeGetImageIndex: TOnOINodeGetImageEvent;
procedure TopSplitterMoved(Sender: TObject);
procedure CreateTopSplitter;
procedure CreateBottomSplitter;
function GetParentCandidates: TFPList;
function GetGridControl(Page: TObjectInspectorPage): TOICustomPropertyGrid; function GetGridControl(Page: TObjectInspectorPage): TOICustomPropertyGrid;
function GetInfoBoxHeight: integer;
function GetParentCandidates: TFPList;
procedure CreateBottomSplitter;
procedure CreateTopSplitter;
procedure DefSelectionVisibleInDesigner;
procedure DoChangeParentItemClick(Sender: TObject);
procedure DoCollectionAddItem(Sender: TObject);
procedure DoComponentEditorVerbMenuItemClick(Sender: TObject);
procedure DoZOrderItemClick(Sender: TObject);
procedure RestrictedPaint(
ABox: TPaintBox; const ARestrictions: TWidgetSetRestrictionsArray);
procedure SetComponentEditor(const AValue: TBaseComponentEditor); procedure SetComponentEditor(const AValue: TBaseComponentEditor);
procedure SetFavorites(const AValue: TOIFavoriteProperties);
procedure SetComponentPanelHeight(const AValue: integer); procedure SetComponentPanelHeight(const AValue: integer);
procedure SetDefaultItemHeight(const AValue: integer); procedure SetDefaultItemHeight(const AValue: integer);
procedure SetEnableHookGetSelection(AValue: boolean);
procedure SetFavorites(const AValue: TOIFavoriteProperties);
procedure SetFilter(const AValue: TTypeKinds);
procedure SetInfoBoxHeight(const AValue: integer); procedure SetInfoBoxHeight(const AValue: integer);
procedure SetRestricted(const AValue: TOIRestrictedProperties);
procedure SetOnShowOptions(const AValue: TNotifyEvent); procedure SetOnShowOptions(const AValue: TNotifyEvent);
procedure SetPropertyEditorHook(NewValue: TPropertyEditorHook); procedure SetPropertyEditorHook(NewValue: TPropertyEditorHook);
procedure SetRestricted(const AValue: TOIRestrictedProperties);
procedure SetSelection(const ASelection: TPersistentSelectionList); procedure SetSelection(const ASelection: TPersistentSelectionList);
procedure SetShowComponentTree(const AValue: boolean); procedure SetShowComponentTree(const AValue: boolean);
procedure SetShowFavorites(const AValue: Boolean); procedure SetShowFavorites(const AValue: Boolean);
@ -731,22 +752,7 @@ type
procedure SetShowRestricted(const AValue: Boolean); procedure SetShowRestricted(const AValue: Boolean);
procedure SetShowStatusBar(const AValue: Boolean); procedure SetShowStatusBar(const AValue: Boolean);
procedure ShowNextPage(Delta: integer); procedure ShowNextPage(Delta: integer);
procedure RestrictedPaint( procedure TopSplitterMoved(Sender: TObject);
ABox: TPaintBox; const ARestrictions: TWidgetSetRestrictionsArray);
procedure DoChangeParentItemClick(Sender: TObject);
procedure DoComponentEditorVerbMenuItemClick(Sender: TObject);
procedure DoCollectionAddItem(Sender: TObject);
procedure DoZOrderItemClick(Sender: TObject);
private
FEnableHookGetSelection: boolean;
FSettingSelectionCount: integer;
FRefreshingSelectionCount: integer;
FOnAutoShow: TNotifyEvent;
FLastActiveRowName: String;
procedure DefSelectionVisibleInDesigner;
function GetComponentPanelHeight: integer;
function GetInfoBoxHeight: integer;
procedure SetEnableHookGetSelection(AValue: boolean);
protected protected
function PersistentToString(APersistent: TPersistent): string; function PersistentToString(APersistent: TPersistent): string;
procedure AddPersistentToList(APersistent: TPersistent; List: TStrings); procedure AddPersistentToList(APersistent: TPersistent; List: TStrings);
@ -787,7 +793,7 @@ type
procedure HookRefreshPropertyValues; procedure HookRefreshPropertyValues;
procedure ActivateGrid(Grid: TOICustomPropertyGrid); procedure ActivateGrid(Grid: TOICustomPropertyGrid);
procedure FocusGrid(Grid: TOICustomPropertyGrid = nil); procedure FocusGrid(Grid: TOICustomPropertyGrid = nil);
public
property ComponentPanelHeight: integer read GetComponentPanelHeight property ComponentPanelHeight: integer read GetComponentPanelHeight
write SetComponentPanelHeight; write SetComponentPanelHeight;
property DefaultItemHeight: integer read FDefaultItemHeight property DefaultItemHeight: integer read FDefaultItemHeight
@ -795,6 +801,7 @@ type
property EnableHookGetSelection: Boolean read FEnableHookGetSelection property EnableHookGetSelection: Boolean read FEnableHookGetSelection
write SetEnableHookGetSelection; write SetEnableHookGetSelection;
property Favorites: TOIFavoriteProperties read FFavorites write SetFavorites; property Favorites: TOIFavoriteProperties read FFavorites write SetFavorites;
property Filter: TTypeKinds read FFilter write SetFilter;
property GridControl[Page: TObjectInspectorPage]: TOICustomPropertyGrid property GridControl[Page: TObjectInspectorPage]: TOICustomPropertyGrid
read GetGridControl; read GetGridControl;
property InfoBoxHeight: integer read GetInfoBoxHeight write SetInfoBoxHeight; property InfoBoxHeight: integer read GetInfoBoxHeight write SetInfoBoxHeight;
@ -4148,6 +4155,7 @@ begin
FInfoBoxHeight := 80; FInfoBoxHeight := 80;
FShowInfoBox := True; FShowInfoBox := True;
FComponentEditor := nil; FComponentEditor := nil;
FFilter := DefaultOITypeKinds;
Caption := oisObjectInspector; Caption := oisObjectInspector;
FilterLabel.Caption := oisBtnComponents; FilterLabel.Caption := oisBtnComponents;
@ -4855,7 +4863,7 @@ end;
procedure TObjectInspectorDlg.MainPopupMenuClose(Sender: TObject); procedure TObjectInspectorDlg.MainPopupMenuClose(Sender: TObject);
begin begin
if StateOfHintsOnMainPopupMenu then OnShowHintPopupMenuItemClick(nil); if FStateOfHintsOnMainPopupMenu then OnShowHintPopupMenuItemClick(nil);
end; end;
procedure TObjectInspectorDlg.OnGridKeyDown(Sender: TObject; var Key: Word; procedure TObjectInspectorDlg.OnGridKeyDown(Sender: TObject; var Key: Word;
@ -5339,12 +5347,6 @@ procedure TObjectInspectorDlg.CreateNoteBook;
end; end;
end; end;
const
PROPS = [
tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkSet,{ tkMethod,}
tkSString, tkLString, tkAString, tkWString, tkVariant,
{tkArray, tkRecord, tkInterface,} tkClass, tkObject, tkWChar, tkBool,
tkInt64, tkQWord];
function AddPage(PageName, TabCaption: string): TTabSheet; function AddPage(PageName, TabCaption: string): TTabSheet;
begin begin
Result:=TTabSheet.Create(Self); Result:=TTabSheet.Create(Self);
@ -5382,11 +5384,11 @@ begin
NoteBook.PageIndex:=0; NoteBook.PageIndex:=0;
PropertyGrid := CreateGrid(PROPS, oipgpProperties, 0); PropertyGrid := CreateGrid(Filter - [tkMethod], oipgpProperties, 0);
EventGrid := CreateGrid([tkMethod], oipgpEvents, 1); EventGrid := CreateGrid([tkMethod], oipgpEvents, 1);
FavoriteGrid := CreateGrid(PROPS + [tkMethod], oipgpFavorite, 2); FavoriteGrid := CreateGrid(Filter + [tkMethod], oipgpFavorite, 2);
FavoriteGrid.Favorites := FFavorites; FavoriteGrid.Favorites := FFavorites;
RestrictedGrid := CreateGrid(PROPS + [tkMethod], oipgpRestricted, 3); RestrictedGrid := CreateGrid(Filter + [tkMethod], oipgpRestricted, 3);
RestrictedPanel := TPanel.Create(Self); RestrictedPanel := TPanel.Create(Self);
with RestrictedPanel do with RestrictedPanel do
@ -5648,7 +5650,7 @@ begin
RemovePropertyEditorMenuItems; RemovePropertyEditorMenuItems;
RemoveComponentEditorMenuItems; RemoveComponentEditorMenuItems;
ShowHintsPopupMenuItem.Checked := PropertyGrid.ShowHint; ShowHintsPopupMenuItem.Checked := PropertyGrid.ShowHint;
StateOfHintsOnMainPopupMenu:=PropertyGrid.ShowHint; FStateOfHintsOnMainPopupMenu:=PropertyGrid.ShowHint;
for Page := Low(TObjectInspectorPage) to High(TObjectInspectorPage) do for Page := Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page] <> nil then if GridControl[Page] <> nil then
GridControl[Page].ShowHint := False; GridControl[Page].ShowHint := False;
@ -5844,6 +5846,15 @@ begin
FPropertyEditorHook.RemoveHandlerGetSelection(@HookGetSelection) FPropertyEditorHook.RemoveHandlerGetSelection(@HookGetSelection)
end; end;
procedure TObjectInspectorDlg.SetFilter(const AValue: TTypeKinds);
begin
if FFilter=AValue then Exit;
FFilter:=AValue;
PropertyGrid.Filter := Filter - [tkMethod];
FavoriteGrid.Filter := Filter + [tkMethod];
RestrictedGrid.Filter := Filter + [tkMethod];
end;
procedure TObjectInspectorDlg.HookRefreshPropertyValues; procedure TObjectInspectorDlg.HookRefreshPropertyValues;
begin begin
RefreshPropertyValues; RefreshPropertyValues;

View File

@ -356,6 +356,8 @@ type
function GetVarValueAt(Index: Integer):Variant; function GetVarValueAt(Index: Integer):Variant;
function GetWideStrValue: WideString; function GetWideStrValue: WideString;
function GetWideStrValueAt(Index: Integer): WideString; function GetWideStrValueAt(Index: Integer): WideString;
function GetUnicodeStrValue: UnicodeString;
function GetUnicodeStrValueAt(Index: Integer): UnicodeString;
function GetValue: ansistring; virtual; function GetValue: ansistring; virtual;
function GetHint({%H-}HintType: TPropEditHint; {%H-}x, {%H-}y: integer): string; virtual; function GetHint({%H-}HintType: TPropEditHint; {%H-}x, {%H-}y: integer): string; virtual;
function GetDefaultValue: ansistring; virtual; function GetDefaultValue: ansistring; virtual;
@ -375,6 +377,7 @@ type
procedure SetPtrValue(const NewValue: Pointer); procedure SetPtrValue(const NewValue: Pointer);
procedure SetStrValue(const NewValue: AnsiString); procedure SetStrValue(const NewValue: AnsiString);
procedure SetWideStrValue(const NewValue: WideString); procedure SetWideStrValue(const NewValue: WideString);
procedure SetUnicodeStrValue(const NewValue: UnicodeString);
procedure SetVarValue(const NewValue: Variant); procedure SetVarValue(const NewValue: Variant);
procedure Modified(PropName: ShortString = ''); procedure Modified(PropName: ShortString = '');
function ValueAvailable: Boolean; function ValueAvailable: Boolean;
@ -554,6 +557,16 @@ type
AState: TPropEditDrawState); override; AState: TPropEditDrawState); override;
end; end;
{ TUnicodeStringPropertyEditor
The default property editor for unicodestrings}
TUnicodeStringPropertyEditor = class(TPropertyEditor)
public
function AllEqual: Boolean; override;
function GetValue: ansistring; override;
procedure SetValue(const NewValue: ansistring); override;
end;
{ TNestedPropertyEditor { TNestedPropertyEditor
A property editor that uses the PropertyHook, PropList and PropCount. A property editor that uses the PropertyHook, PropList and PropCount.
The constructor and destructor do not call inherited, but all derived classes The constructor and destructor do not call inherited, but all derived classes
@ -2032,7 +2045,7 @@ const
nil, // tkDynArray nil, // tkDynArray
nil, // tkInterfaceRaw, nil, // tkInterfaceRaw,
nil, // tkProcVar nil, // tkProcVar
nil, // tkUString TUnicodeStringPropertyEditor,// tkUString
nil // tkUChar nil // tkUChar
{$IF declared(tkHelper)} {$IF declared(tkHelper)}
,nil // tkHelper ,nil // tkHelper
@ -2872,6 +2885,16 @@ begin
with FPropList^[Index] do Result:=GetWideStrProp(Instance,PropInfo); with FPropList^[Index] do Result:=GetWideStrProp(Instance,PropInfo);
end; end;
function TPropertyEditor.GetUnicodeStrValue: UnicodeString;
begin
Result:=GetUnicodeStrValueAt(0);
end;
function TPropertyEditor.GetUnicodeStrValueAt(Index: Integer): UnicodeString;
begin
with FPropList^[Index] do Result:=GetUnicodeStrProp(Instance,PropInfo);
end;
function TPropertyEditor.GetValue:ansistring; function TPropertyEditor.GetValue:ansistring;
begin begin
Result:=oisUnknown; Result:=oisUnknown;
@ -3096,6 +3119,23 @@ begin
end; end;
end; end;
procedure TPropertyEditor.SetUnicodeStrValue(const NewValue: UnicodeString);
var
I: Integer;
Changed: boolean;
begin
Changed:=false;
for I:=0 to FPropCount-1 do
with FPropList^[I] do
Changed:=Changed or (GetUnicodeStrProp(Instance,PropInfo)<>NewValue);
if Changed then
for I:=0 to FPropCount-1 do
with FPropList^[I] do begin
SetUnicodeStrProp(Instance,PropInfo,NewValue);
Modified(PropInfo^.Name);
end;
end;
procedure TPropertyEditor.SetVarValue(const NewValue: Variant); procedure TPropertyEditor.SetVarValue(const NewValue: Variant);
var var
I: Integer; I: Integer;
@ -3867,6 +3907,32 @@ begin
DrawValue(UTF8Encode(GetPassword),ACanvas,ARect,AState); DrawValue(UTF8Encode(GetPassword),ACanvas,ARect,AState);
end; end;
{ TUnicodeStringPropertyEditor }
function TUnicodeStringPropertyEditor.AllEqual: Boolean;
var
I: Integer;
V: UnicodeString;
begin
Result := False;
if PropCount > 1 then begin
V := GetUnicodeStrValue;
for I := 1 to PropCount - 1 do
if GetUnicodeStrValueAt(I) <> V then Exit;
end;
Result := True;
end;
function TUnicodeStringPropertyEditor.GetValue: ansistring;
begin
Result:=UTF8Encode(GetUnicodeStrValue);
end;
procedure TUnicodeStringPropertyEditor.SetValue(const NewValue: ansistring);
begin
SetUnicodeStrValue(UTF8Decode(NewValue));
end;
{ TNestedPropertyEditor } { TNestedPropertyEditor }
constructor TNestedPropertyEditor.Create(Parent: TPropertyEditor); constructor TNestedPropertyEditor.Create(Parent: TPropertyEditor);