View Issue Details

IDProjectCategoryView StatusLast Update
0033026LazarusLCLpublic2019-12-12 12:57
ReporterMichal Gawrycki Assigned Towp  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.9 (SVN) 
Summary0033026: TComboBoxEx and ImageIndex properties
DescriptionTComboBoxEx stores ImageIndex as SmallInt. I suggest change it to TImageIndex type. Additionally, in TImageIndexPropertyEditor.GetImageList, I suggest to make changes so that can find the right TImageList. This will allow to edit ImagIndex in OI. Finally, I suggest you change the type TComboExItem.Ident from SmallInt type to Integer.
TagsNo tags attached.
Fixed in Revision62379
LazTarget2.0.8
Widgetset
Attached Files

Activities

Michal Gawrycki

2018-01-14 17:48

reporter  

cbe-comboex.inc.patch (2,172 bytes)   
Index: lcl/include/comboex.inc
===================================================================
--- lcl/include/comboex.inc	(revision 56954)
+++ lcl/include/comboex.inc	(working copy)
@@ -27,7 +27,7 @@
   Changed(False);
 end;
 
-procedure TListControlItem.SetImageIndex(AValue: SmallInt);
+procedure TListControlItem.SetImageIndex(AValue: TImageIndex);
 begin
   if FImageIndex=AValue then exit;
   FImageIndex:=AValue;
@@ -59,7 +59,7 @@
 
 { TComboExItem.Setters }
 
-procedure TComboExItem.SetIndent(AValue: SmallInt);
+procedure TComboExItem.SetIndent(AValue: Integer);
 begin
   if FIndent=AValue then exit;
   FIndent:=AValue;
@@ -66,7 +66,7 @@
   Changed(False);
 end;
 
-procedure TComboExItem.SetOverlayImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetOverlayImageIndex(AValue: TImageIndex);
 begin
   if FOverlayImageIndex=AValue then exit;
   FOverlayImageIndex:=AValue;
@@ -73,7 +73,7 @@
   { Changed(False); }
 end;
 
-procedure TComboExItem.SetSelectedImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetSelectedImageIndex(AValue: TImageIndex);
 begin
   if FSelectedImageIndex=AValue then exit;
   FSelectedImageIndex:=AValue;
@@ -287,8 +287,8 @@
   inherited Destroy;
 end;
 
-procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: SmallInt; AImgIdx: SmallInt;
-  AOverlayImgIdx: SmallInt; ASelectedImgIdx: SmallInt);
+procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: Integer;
+  AImgIdx: TImageIndex; AOverlayImgIdx: TImageIndex; ASelectedImgIdx: TImageIndex);
 begin
   Insert(ItemsEx.Count, ACaption, AIndent, AImgIdx, AOverlayImgIdx, ASelectedImgIdx);
 end;
@@ -435,8 +435,8 @@
   FRightToLeft:=IsRightToLeft;
 end;
 
-procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-            AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1; ASelectedImgIdx: SmallInt = -1);
+procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+            AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1; ASelectedImgIdx: TImageIndex = -1);
 var aItem: TCollectionItem;
 begin
   aItem:=ItemsEx.Insert(AIndex);
cbe-comboex.inc.patch (2,172 bytes)   

Michal Gawrycki

2018-01-14 17:49

reporter  

cbe-comboex.pas.patch (3,795 bytes)   
Index: lcl/comboex.pas
===================================================================
--- lcl/comboex.pas	(revision 56954)
+++ lcl/comboex.pas	(working copy)
@@ -58,26 +58,26 @@
   private
     FCaption: TTranslateString;
     FData: TCustomData;
-    FImageIndex: SmallInt;
+    FImageIndex: TImageIndex;
     procedure SetCaption(const AValue: TTranslateString);
-    procedure SetImageIndex(AValue: SmallInt);
+    procedure SetImageIndex(AValue: TImageIndex);
   public
     property Data: TCustomData read FData write FData;
     constructor Create(ACollection: TCollection); override;
   published
     property Caption: TTranslateString read FCaption write SetCaption;
-    property ImageIndex: SmallInt read FImageIndex write SetImageIndex default -1;
+    property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
   end;
 
   { TComboExItem }
   TComboExItem = class(TListControlItem)
   private
-    FIndent: SmallInt;
-    FOverlayImageIndex: SmallInt;
-    FSelectedImageIndex: SmallInt;
-    procedure SetIndent(AValue: SmallInt);
-    procedure SetOverlayImageIndex(AValue: SmallInt);
-    procedure SetSelectedImageIndex(AValue: SmallInt);
+    FIndent: Integer;
+    FOverlayImageIndex: TImageIndex;
+    FSelectedImageIndex: TImageIndex;
+    procedure SetIndent(AValue: Integer);
+    procedure SetOverlayImageIndex(AValue: TImageIndex);
+    procedure SetSelectedImageIndex(AValue: TImageIndex);
   protected const
     cDefCaption = 'ItemEx';
   public
@@ -84,9 +84,9 @@
     constructor Create(ACollection: TCollection); override;
     destructor Destroy; override;
   published
-    property Indent: SmallInt read FIndent write SetIndent default -1;
-    property OverlayImageIndex: SmallInt read FOverlayImageIndex write SetOverlayImageIndex default -1;
-    property SelectedImageIndex: SmallInt read FSelectedImageIndex write SetSelectedImageIndex default -1;
+    property Indent: Integer read FIndent write SetIndent default -1;
+    property OverlayImageIndex: TImageIndex read FOverlayImageIndex write SetOverlayImageIndex default -1;
+    property SelectedImageIndex: TImageIndex read FSelectedImageIndex write SetSelectedImageIndex default -1;
   end;
 
   { TListControlItems }
@@ -159,9 +159,9 @@
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
     function Add: Integer; overload;
-    procedure Add(const ACaption: string; AIndent: SmallInt = -1;
-                  AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                  ASelectedImgIdx: SmallInt = -1); overload;
+    procedure Add(const ACaption: string; AIndent: Integer = -1;
+                  AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                  ASelectedImgIdx: TImageIndex = -1); overload;
     procedure AddItem(const Item: String; AnObject: TObject); override;
     procedure AssignItemsEx(AItems: TStrings); overload;
     procedure AssignItemsEx(AItemsEx: TComboExItems); overload;
@@ -168,9 +168,9 @@
     procedure Clear; override;
     procedure Delete(AIndex: Integer);
     procedure DeleteSelected;
-    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-                     AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                     ASelectedImgIdx: SmallInt = -1);
+    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+                     AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                     ASelectedImgIdx: TImageIndex = -1);
     property AutoCompleteOptions: TAutoCompleteOptions read FAutoCompleteOptions
              write FAutoCompleteOptions default cDefAutoCompOpts;
     property Images: TCustomImageList read FImages write SetImages;
cbe-comboex.pas.patch (3,795 bytes)   

Michal Gawrycki

2018-01-14 17:49

reporter  

cbe-graphpropedits.pas.patch (2,223 bytes)   
Index: components/ideintf/graphpropedits.pas
===================================================================
--- components/ideintf/graphpropedits.pas	(revision 56954)
+++ components/ideintf/graphpropedits.pas	(working copy)
@@ -646,6 +646,10 @@
 
 { TImageIndexPropertyEditor }
 
+type
+  TOwnedCollectionHelper = class(TOwnedCollection)
+  end;
+
 function TImageIndexPropertyEditor.GetImageList: TCustomImageList;
 var
   Persistent: TPersistent;
@@ -655,8 +659,25 @@
 begin
   Result := nil;
   Persistent := GetComponent(0);
-  if not (Persistent is TComponent) then
+
+  if (Persistent is TCollectionItem) and
+    (TCollectionItem(Persistent).Collection <> nil) and
+    (TCollectionItem(Persistent).Collection is TOwnedCollection) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner <> nil) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner is TComponent) then
+  begin
+    Component := TComponent(TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner);
+    PropInfo := TypInfo.GetPropInfo(Component, 'Images');
+    if PropInfo = nil then
+      Exit;
+    Obj := GetObjectProp(Component, PropInfo);
+    if Obj is TCustomImageList then
+      Exit(TCustomImageList(Obj));
     Exit;
+  end
+  else
+    if not (Persistent is TComponent) then
+      Exit;
 
   if Component is TMenuItem then
   begin
@@ -750,6 +771,8 @@
   RegisterPropertyEditor(TypeInfo(AnsiString), TFont, 'Name', TFontNamePropertyEditor);
   RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'ImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'OverlayImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'SelectedImageIndex', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TComponent, 'ImageIndexSortAsc', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TComponent, 'ImageIndexSortDesc', TImageIndexPropertyEditor);
   RegisterPropertyEditor(ClassTypeInfo(TFont), nil,'',TFontPropertyEditor);
cbe-graphpropedits.pas.patch (2,223 bytes)   

Michal Gawrycki

2018-01-14 17:49

reporter  

cbe-one-big-patch.patch (8,190 bytes)   
Index: components/ideintf/graphpropedits.pas
===================================================================
--- components/ideintf/graphpropedits.pas	(revision 56954)
+++ components/ideintf/graphpropedits.pas	(working copy)
@@ -646,6 +646,10 @@
 
 { TImageIndexPropertyEditor }
 
+type
+  TOwnedCollectionHelper = class(TOwnedCollection)
+  end;
+
 function TImageIndexPropertyEditor.GetImageList: TCustomImageList;
 var
   Persistent: TPersistent;
@@ -655,8 +659,25 @@
 begin
   Result := nil;
   Persistent := GetComponent(0);
-  if not (Persistent is TComponent) then
+
+  if (Persistent is TCollectionItem) and
+    (TCollectionItem(Persistent).Collection <> nil) and
+    (TCollectionItem(Persistent).Collection is TOwnedCollection) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner <> nil) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner is TComponent) then
+  begin
+    Component := TComponent(TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner);
+    PropInfo := TypInfo.GetPropInfo(Component, 'Images');
+    if PropInfo = nil then
+      Exit;
+    Obj := GetObjectProp(Component, PropInfo);
+    if Obj is TCustomImageList then
+      Exit(TCustomImageList(Obj));
     Exit;
+  end
+  else
+    if not (Persistent is TComponent) then
+      Exit;
 
   if Component is TMenuItem then
   begin
@@ -750,6 +771,8 @@
   RegisterPropertyEditor(TypeInfo(AnsiString), TFont, 'Name', TFontNamePropertyEditor);
   RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'ImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'OverlayImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'SelectedImageIndex', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TComponent, 'ImageIndexSortAsc', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TComponent, 'ImageIndexSortDesc', TImageIndexPropertyEditor);
   RegisterPropertyEditor(ClassTypeInfo(TFont), nil,'',TFontPropertyEditor);
Index: lcl/comboex.pas
===================================================================
--- lcl/comboex.pas	(revision 56954)
+++ lcl/comboex.pas	(working copy)
@@ -58,26 +58,26 @@
   private
     FCaption: TTranslateString;
     FData: TCustomData;
-    FImageIndex: SmallInt;
+    FImageIndex: TImageIndex;
     procedure SetCaption(const AValue: TTranslateString);
-    procedure SetImageIndex(AValue: SmallInt);
+    procedure SetImageIndex(AValue: TImageIndex);
   public
     property Data: TCustomData read FData write FData;
     constructor Create(ACollection: TCollection); override;
   published
     property Caption: TTranslateString read FCaption write SetCaption;
-    property ImageIndex: SmallInt read FImageIndex write SetImageIndex default -1;
+    property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
   end;
 
   { TComboExItem }
   TComboExItem = class(TListControlItem)
   private
-    FIndent: SmallInt;
-    FOverlayImageIndex: SmallInt;
-    FSelectedImageIndex: SmallInt;
-    procedure SetIndent(AValue: SmallInt);
-    procedure SetOverlayImageIndex(AValue: SmallInt);
-    procedure SetSelectedImageIndex(AValue: SmallInt);
+    FIndent: Integer;
+    FOverlayImageIndex: TImageIndex;
+    FSelectedImageIndex: TImageIndex;
+    procedure SetIndent(AValue: Integer);
+    procedure SetOverlayImageIndex(AValue: TImageIndex);
+    procedure SetSelectedImageIndex(AValue: TImageIndex);
   protected const
     cDefCaption = 'ItemEx';
   public
@@ -84,9 +84,9 @@
     constructor Create(ACollection: TCollection); override;
     destructor Destroy; override;
   published
-    property Indent: SmallInt read FIndent write SetIndent default -1;
-    property OverlayImageIndex: SmallInt read FOverlayImageIndex write SetOverlayImageIndex default -1;
-    property SelectedImageIndex: SmallInt read FSelectedImageIndex write SetSelectedImageIndex default -1;
+    property Indent: Integer read FIndent write SetIndent default -1;
+    property OverlayImageIndex: TImageIndex read FOverlayImageIndex write SetOverlayImageIndex default -1;
+    property SelectedImageIndex: TImageIndex read FSelectedImageIndex write SetSelectedImageIndex default -1;
   end;
 
   { TListControlItems }
@@ -159,9 +159,9 @@
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
     function Add: Integer; overload;
-    procedure Add(const ACaption: string; AIndent: SmallInt = -1;
-                  AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                  ASelectedImgIdx: SmallInt = -1); overload;
+    procedure Add(const ACaption: string; AIndent: Integer = -1;
+                  AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                  ASelectedImgIdx: TImageIndex = -1); overload;
     procedure AddItem(const Item: String; AnObject: TObject); override;
     procedure AssignItemsEx(AItems: TStrings); overload;
     procedure AssignItemsEx(AItemsEx: TComboExItems); overload;
@@ -168,9 +168,9 @@
     procedure Clear; override;
     procedure Delete(AIndex: Integer);
     procedure DeleteSelected;
-    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-                     AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                     ASelectedImgIdx: SmallInt = -1);
+    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+                     AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                     ASelectedImgIdx: TImageIndex = -1);
     property AutoCompleteOptions: TAutoCompleteOptions read FAutoCompleteOptions
              write FAutoCompleteOptions default cDefAutoCompOpts;
     property Images: TCustomImageList read FImages write SetImages;
Index: lcl/include/comboex.inc
===================================================================
--- lcl/include/comboex.inc	(revision 56954)
+++ lcl/include/comboex.inc	(working copy)
@@ -27,7 +27,7 @@
   Changed(False);
 end;
 
-procedure TListControlItem.SetImageIndex(AValue: SmallInt);
+procedure TListControlItem.SetImageIndex(AValue: TImageIndex);
 begin
   if FImageIndex=AValue then exit;
   FImageIndex:=AValue;
@@ -59,7 +59,7 @@
 
 { TComboExItem.Setters }
 
-procedure TComboExItem.SetIndent(AValue: SmallInt);
+procedure TComboExItem.SetIndent(AValue: Integer);
 begin
   if FIndent=AValue then exit;
   FIndent:=AValue;
@@ -66,7 +66,7 @@
   Changed(False);
 end;
 
-procedure TComboExItem.SetOverlayImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetOverlayImageIndex(AValue: TImageIndex);
 begin
   if FOverlayImageIndex=AValue then exit;
   FOverlayImageIndex:=AValue;
@@ -73,7 +73,7 @@
   { Changed(False); }
 end;
 
-procedure TComboExItem.SetSelectedImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetSelectedImageIndex(AValue: TImageIndex);
 begin
   if FSelectedImageIndex=AValue then exit;
   FSelectedImageIndex:=AValue;
@@ -287,8 +287,8 @@
   inherited Destroy;
 end;
 
-procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: SmallInt; AImgIdx: SmallInt;
-  AOverlayImgIdx: SmallInt; ASelectedImgIdx: SmallInt);
+procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: Integer;
+  AImgIdx: TImageIndex; AOverlayImgIdx: TImageIndex; ASelectedImgIdx: TImageIndex);
 begin
   Insert(ItemsEx.Count, ACaption, AIndent, AImgIdx, AOverlayImgIdx, ASelectedImgIdx);
 end;
@@ -435,8 +435,8 @@
   FRightToLeft:=IsRightToLeft;
 end;
 
-procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-            AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1; ASelectedImgIdx: SmallInt = -1);
+procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+            AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1; ASelectedImgIdx: TImageIndex = -1);
 var aItem: TCollectionItem;
 begin
   aItem:=ItemsEx.Insert(AIndex);
cbe-one-big-patch.patch (8,190 bytes)   

Michal Gawrycki

2018-01-14 17:51

reporter   ~0105802

I am sorry but the title should be: TComboBoxEx and ImageIndex properties

Bart Broersma

2018-01-14 18:10

developer   ~0105804

Updated summary.

Zeljan Rikalo

2018-01-14 21:23

developer   ~0105815

Smallint is probably used to be Delphi compatibile.

Michal Gawrycki

2018-01-14 21:36

reporter   ~0105816

in fact, delphi uses TImageIndex type for image indexes and Integer for Ident.
http://docwiki.embarcadero.com/Libraries/Tokyo/en/Vcl.ComCtrls.TComboExItem_Properties

CudaText man

2018-01-15 08:27

reporter   ~0105831

Using TImageIndex/Integer is good, indeed.

Michal Gawrycki

2019-12-11 20:56

reporter   ~0119768

I'm sending patches for current version of Lazarus.
cbe-graphpropedits.pas2.patch (2,269 bytes)   
Index: components/ideintf/graphpropedits.pas
===================================================================
--- components/ideintf/graphpropedits.pas	(revision 62333)
+++ components/ideintf/graphpropedits.pas	(working copy)
@@ -654,6 +654,10 @@
 
 { TImageIndexPropertyEditor }
 
+type
+  TOwnedCollectionHelper = class(TOwnedCollection)
+  end;
+
 function TImageIndexPropertyEditor.GetImageList: TCustomImageList;
 var
   Persistent: TPersistent;
@@ -663,8 +667,25 @@
 begin
   Result := nil;
   Persistent := GetComponent(0);
-  if not (Persistent is TComponent) then
+
+  if (Persistent is TCollectionItem) and
+    (TCollectionItem(Persistent).Collection <> nil) and
+    (TCollectionItem(Persistent).Collection is TOwnedCollection) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner <> nil) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner is TComponent) then
+  begin
+    Component := TComponent(TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner);
+    PropInfo := TypInfo.GetPropInfo(Component, 'Images');
+    if PropInfo = nil then
+      Exit;
+    Obj := GetObjectProp(Component, PropInfo);
+    if Obj is TCustomImageList then
+      Exit(TCustomImageList(Obj));
     Exit;
+  end
+  else
+    if not (Persistent is TComponent) then
+      Exit;
 
   if Component is TMenuItem then
   begin
@@ -788,6 +809,8 @@
   RegisterPropertyEditor(TypeInfo(AnsiString), TFont, 'Name', TFontNamePropertyEditor);
   RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'ImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'OverlayImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'SelectedImageIndex', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TGridColumnTitle, 'ImageIndex', TGridImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TCustomGrid, 'ImageIndexSortAsc', TGridImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TCustomGrid, 'ImageIndexSortDesc', TGridImageIndexPropertyEditor);
cbe-graphpropedits.pas2.patch (2,269 bytes)   
cbe-one-big-patch2.patch (8,236 bytes)   
Index: components/ideintf/graphpropedits.pas
===================================================================
--- components/ideintf/graphpropedits.pas	(revision 62333)
+++ components/ideintf/graphpropedits.pas	(working copy)
@@ -654,6 +654,10 @@
 
 { TImageIndexPropertyEditor }
 
+type
+  TOwnedCollectionHelper = class(TOwnedCollection)
+  end;
+
 function TImageIndexPropertyEditor.GetImageList: TCustomImageList;
 var
   Persistent: TPersistent;
@@ -663,8 +667,25 @@
 begin
   Result := nil;
   Persistent := GetComponent(0);
-  if not (Persistent is TComponent) then
+
+  if (Persistent is TCollectionItem) and
+    (TCollectionItem(Persistent).Collection <> nil) and
+    (TCollectionItem(Persistent).Collection is TOwnedCollection) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner <> nil) and
+    (TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner is TComponent) then
+  begin
+    Component := TComponent(TOwnedCollectionHelper(TCollectionItem(Persistent).Collection).Owner);
+    PropInfo := TypInfo.GetPropInfo(Component, 'Images');
+    if PropInfo = nil then
+      Exit;
+    Obj := GetObjectProp(Component, PropInfo);
+    if Obj is TCustomImageList then
+      Exit(TCustomImageList(Obj));
     Exit;
+  end
+  else
+    if not (Persistent is TComponent) then
+      Exit;
 
   if Component is TMenuItem then
   begin
@@ -788,6 +809,8 @@
   RegisterPropertyEditor(TypeInfo(AnsiString), TFont, 'Name', TFontNamePropertyEditor);
   RegisterPropertyEditor(TypeInfo(TFontCharset), nil, 'CharSet', TFontCharsetPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'ImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'OverlayImageIndex', TImageIndexPropertyEditor);
+  RegisterPropertyEditor(TypeInfo(TImageIndex), TPersistent, 'SelectedImageIndex', TImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TGridColumnTitle, 'ImageIndex', TGridImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TCustomGrid, 'ImageIndexSortAsc', TGridImageIndexPropertyEditor);
   RegisterPropertyEditor(TypeInfo(TImageIndex), TCustomGrid, 'ImageIndexSortDesc', TGridImageIndexPropertyEditor);
Index: lcl/comboex.pas
===================================================================
--- lcl/comboex.pas	(revision 62333)
+++ lcl/comboex.pas	(working copy)
@@ -58,26 +58,26 @@
   private
     FCaption: TTranslateString;
     FData: TCustomData;
-    FImageIndex: SmallInt;
+    FImageIndex: TImageIndex;
     procedure SetCaption(const AValue: TTranslateString);
-    procedure SetImageIndex(AValue: SmallInt);
+    procedure SetImageIndex(AValue: TImageIndex);
   public
     property Data: TCustomData read FData write FData;
     constructor Create(ACollection: TCollection); override;
   published
     property Caption: TTranslateString read FCaption write SetCaption;
-    property ImageIndex: SmallInt read FImageIndex write SetImageIndex default -1;
+    property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
   end;
 
   { TComboExItem }
   TComboExItem = class(TListControlItem)
   private
-    FIndent: SmallInt;
-    FOverlayImageIndex: SmallInt;
-    FSelectedImageIndex: SmallInt;
-    procedure SetIndent(AValue: SmallInt);
-    procedure SetOverlayImageIndex(AValue: SmallInt);
-    procedure SetSelectedImageIndex(AValue: SmallInt);
+    FIndent: Integer;
+    FOverlayImageIndex: TImageIndex;
+    FSelectedImageIndex: TImageIndex;
+    procedure SetIndent(AValue: Integer);
+    procedure SetOverlayImageIndex(AValue: TImageIndex);
+    procedure SetSelectedImageIndex(AValue: TImageIndex);
   protected const
     cDefCaption = 'ItemEx';
   public
@@ -84,9 +84,9 @@
     constructor Create(ACollection: TCollection); override;
     destructor Destroy; override;
   published
-    property Indent: SmallInt read FIndent write SetIndent default -1;
-    property OverlayImageIndex: SmallInt read FOverlayImageIndex write SetOverlayImageIndex default -1;
-    property SelectedImageIndex: SmallInt read FSelectedImageIndex write SetSelectedImageIndex default -1;
+    property Indent: Integer read FIndent write SetIndent default -1;
+    property OverlayImageIndex: TImageIndex read FOverlayImageIndex write SetOverlayImageIndex default -1;
+    property SelectedImageIndex: TImageIndex read FSelectedImageIndex write SetSelectedImageIndex default -1;
   end;
 
   { TListControlItems }
@@ -161,9 +161,9 @@
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
     function Add: Integer; overload;
-    procedure Add(const ACaption: string; AIndent: SmallInt = -1;
-                  AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                  ASelectedImgIdx: SmallInt = -1); overload;
+    procedure Add(const ACaption: string; AIndent: Integer = -1;
+                  AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                  ASelectedImgIdx: TImageIndex = -1); overload;
     procedure AddItem(const Item: String; AnObject: TObject); override;
     procedure AssignItemsEx(AItems: TStrings); overload;
     procedure AssignItemsEx(AItemsEx: TComboExItems); overload;
@@ -170,9 +170,9 @@
     procedure Clear; override;
     procedure Delete(AIndex: Integer);
     procedure DeleteSelected;
-    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-                     AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1;
-                     ASelectedImgIdx: SmallInt = -1);
+    procedure Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+                     AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1;
+                     ASelectedImgIdx: TImageIndex = -1);
     property AutoCompleteOptions: TAutoCompleteOptions read FAutoCompleteOptions
              write FAutoCompleteOptions default cDefAutoCompOpts;
     property Images: TCustomImageList read FImages write SetImages;
Index: lcl/include/comboex.inc
===================================================================
--- lcl/include/comboex.inc	(revision 62333)
+++ lcl/include/comboex.inc	(working copy)
@@ -27,7 +27,7 @@
   Changed(False);
 end;
 
-procedure TListControlItem.SetImageIndex(AValue: SmallInt);
+procedure TListControlItem.SetImageIndex(AValue: TImageIndex);
 begin
   if FImageIndex=AValue then exit;
   FImageIndex:=AValue;
@@ -59,7 +59,7 @@
 
 { TComboExItem.Setters }
 
-procedure TComboExItem.SetIndent(AValue: SmallInt);
+procedure TComboExItem.SetIndent(AValue: Integer);
 begin
   if FIndent=AValue then exit;
   FIndent:=AValue;
@@ -66,7 +66,7 @@
   Changed(False);
 end;
 
-procedure TComboExItem.SetOverlayImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetOverlayImageIndex(AValue: TImageIndex);
 begin
   if FOverlayImageIndex=AValue then exit;
   FOverlayImageIndex:=AValue;
@@ -73,7 +73,7 @@
   { Changed(False); }
 end;
 
-procedure TComboExItem.SetSelectedImageIndex(AValue: SmallInt);
+procedure TComboExItem.SetSelectedImageIndex(AValue: TImageIndex);
 begin
   if FSelectedImageIndex=AValue then exit;
   FSelectedImageIndex:=AValue;
@@ -287,8 +287,8 @@
   inherited Destroy;
 end;
 
-procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: SmallInt; AImgIdx: SmallInt;
-  AOverlayImgIdx: SmallInt; ASelectedImgIdx: SmallInt);
+procedure TCustomComboBoxEx.Add(const ACaption: string; AIndent: Integer;
+  AImgIdx: TImageIndex; AOverlayImgIdx: TImageIndex; ASelectedImgIdx: TImageIndex);
 begin
   Insert(ItemsEx.Count, ACaption, AIndent, AImgIdx, AOverlayImgIdx, ASelectedImgIdx);
 end;
@@ -437,8 +437,8 @@
   FRightToLeft:=IsRightToLeft;
 end;
 
-procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: SmallInt = -1;
-            AImgIdx: SmallInt = -1; AOverlayImgIdx: SmallInt = -1; ASelectedImgIdx: SmallInt = -1);
+procedure TCustomComboBoxEx.Insert(AIndex: Integer; const ACaption: string; AIndent: Integer = -1;
+            AImgIdx: TImageIndex = -1; AOverlayImgIdx: TImageIndex = -1; ASelectedImgIdx: TImageIndex = -1);
 var aItem: TCollectionItem;
 begin
   aItem:=ItemsEx.Insert(AIndex);
cbe-one-big-patch2.patch (8,236 bytes)   

wp

2019-12-11 22:47

developer   ~0119776

Applied. Thanks for patches.

Michal Gawrycki

2019-12-12 12:57

reporter   ~0119787

Thanks! Closed.

Issue History

Date Modified Username Field Change
2018-01-14 17:48 Michal Gawrycki New Issue
2018-01-14 17:48 Michal Gawrycki File Added: cbe-comboex.inc.patch
2018-01-14 17:49 Michal Gawrycki File Added: cbe-comboex.pas.patch
2018-01-14 17:49 Michal Gawrycki File Added: cbe-graphpropedits.pas.patch
2018-01-14 17:49 Michal Gawrycki File Added: cbe-one-big-patch.patch
2018-01-14 17:51 Michal Gawrycki Note Added: 0105802
2018-01-14 18:10 Bart Broersma LazTarget => -
2018-01-14 18:10 Bart Broersma Note Added: 0105804
2018-01-14 18:10 Bart Broersma Summary TComboBoxEx and ItemIndex properties => TComboBoxEx and ImageIndex properties
2018-01-14 21:23 Zeljan Rikalo Note Added: 0105815
2018-01-14 21:36 Michal Gawrycki Note Added: 0105816
2018-01-15 08:27 CudaText man Note Added: 0105831
2019-12-11 20:56 Michal Gawrycki File Added: cbe-graphpropedits.pas2.patch
2019-12-11 20:56 Michal Gawrycki File Added: cbe-one-big-patch2.patch
2019-12-11 20:56 Michal Gawrycki Note Added: 0119768
2019-12-11 22:27 wp Assigned To => wp
2019-12-11 22:27 wp Status new => assigned
2019-12-11 22:47 wp Status assigned => resolved
2019-12-11 22:47 wp Resolution open => fixed
2019-12-11 22:47 wp Fixed in Revision => 62379
2019-12-11 22:47 wp LazTarget - => 2.0.8
2019-12-11 22:47 wp Note Added: 0119776
2019-12-12 12:57 Michal Gawrycki Status resolved => closed
2019-12-12 12:57 Michal Gawrycki Note Added: 0119787