ideintf: make ImageList search more generic for ImageIndex property editor

git-svn-id: trunk@22140 -
This commit is contained in:
paul 2009-10-13 09:43:23 +00:00
parent b716faba72
commit 95cc044bf8

View File

@ -24,7 +24,7 @@ interface
uses uses
Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, LCLType, GraphType, Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, LCLType, GraphType,
FileUtil, Graphics, StdCtrls, Buttons, ComCtrls, Menus, ExtCtrls, Dialogs, FileUtil, Graphics, StdCtrls, Buttons, ComCtrls, Menus, ExtCtrls, Dialogs,
LCLIntf, ExtDlgs, PropEdits, ImgList, Math, ActnList, LCLIntf, ExtDlgs, PropEdits, ImgList, Math,
GraphicPropEdit; // defines TGraphicPropertyEditorForm GraphicPropEdit; // defines TGraphicPropertyEditorForm
type type
@ -656,7 +656,10 @@ function TImageIndexPropertyEditor.GetImageList: TCustomImageList;
var var
Persistent: TPersistent; Persistent: TPersistent;
Component: TComponent absolute Persistent; Component: TComponent absolute Persistent;
PropInfo: PPropInfo;
Obj: TObject;
begin begin
Result := nil;
Persistent := GetComponent(0); Persistent := GetComponent(0);
if not (Persistent is TComponent) then if not (Persistent is TComponent) then
Exit; Exit;
@ -674,13 +677,17 @@ begin
end; end;
end end
else else
if Component is TCustomAction then
begin begin
Component := Component.GetParentComponent; Component := Component.GetParentComponent;
if Component is TCustomActionList then if Component = nil then
Exit(TCustomActionList(Component).Images); Exit;
PropInfo := TypInfo.GetPropInfo(Component, 'Images');
if PropInfo = nil then
Exit;
Obj := GetObjectProp(Component, PropInfo);
if Obj is TCustomImageList then
Exit(TCustomImageList(Obj));
end; end;
Result := nil;
end; end;
function TImageIndexPropertyEditor.GetAttributes: TPropertyAttributes; function TImageIndexPropertyEditor.GetAttributes: TPropertyAttributes;
@ -751,8 +758,7 @@ initialization
RegisterPropertyEditor(ClassTypeInfo(TBitmap), TSpeedButton,'Glyph', TButtonGlyphPropEditor); RegisterPropertyEditor(ClassTypeInfo(TBitmap), TSpeedButton,'Glyph', TButtonGlyphPropEditor);
RegisterPropertyEditor(ClassTypeInfo(TBitmap), TBitBtn,'Glyph', TButtonGlyphPropEditor); RegisterPropertyEditor(ClassTypeInfo(TBitmap), TBitBtn,'Glyph', TButtonGlyphPropEditor);
RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor); RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor);
RegisterPropertyEditor(TypeInfo(TImageIndex), TMenuItem, 'ImageIndex', TImageIndexPropertyEditor); RegisterPropertyEditor(TypeInfo(TImageIndex), TComponent, 'ImageIndex', TImageIndexPropertyEditor);
RegisterPropertyEditor(TypeInfo(TImageIndex), TContainedAction, 'ImageIndex', TImageIndexPropertyEditor);
end. end.