1
1
{ $I Definition.Inc}
2
2
3
- unit WrapFMXImgList ;
3
+ unit WrapFmxImgList ;
4
4
5
5
interface
6
6
@@ -16,6 +16,7 @@ TPyDelphiCustomImageList = class (TPyDelphiBaseImageList)
16
16
protected
17
17
function BitmapItemByName_Wrapper (AArgs: PPyObject): PPyObject; cdecl;
18
18
function BestSize_Wrapper (AArgs: PPyObject): PPyObject; cdecl;
19
+ function AddOrSet_Wrapper (AArgs: PPyObject): PPyObject; cdecl;
19
20
public
20
21
class function DelphiObjectClass : TClass; override;
21
22
class procedure RegisterMethods (PythonType: TPythonType); override;
@@ -39,7 +40,7 @@ implementation
39
40
System.Types,
40
41
FMX.MultiResBitmap,
41
42
WrapDelphiTypes,
42
- WrapFmxTypes;
43
+ WrapFmxTypes, System.UITypes ;
43
44
44
45
{ Register the wrappers, the globals and the constants }
45
46
type
@@ -66,6 +67,52 @@ procedure TFmxImageListRegistration.RegisterWrappers(
66
67
67
68
{ TPyDelphiCustomImageList }
68
69
70
+ function TPyDelphiCustomImageList.AddOrSet_Wrapper (AArgs: PPyObject): PPyObject;
71
+ var
72
+ LPySourceName: PPyObject;
73
+ LPyScales: PPyObject;
74
+ LPyFileNames: PPyObject;
75
+
76
+ LSourceName: string;
77
+ LScales: array of single;
78
+ LFileNames: array of string;
79
+ LTransparentColor: integer;
80
+ LWidth: integer;
81
+ LHeight: integer;
82
+ I: integer;
83
+ begin
84
+ Adjust(@Self);
85
+ LTransparentColor := TColors.SysNone;
86
+ LWidth := 0 ;
87
+ LHeight := 0 ;
88
+ if GetPythonEngine().PyArg_ParseTuple(AArgs, ' OOO|iii:AddOrSet' ,
89
+ @LPySourceName, @LPyScales, @LPyFileNames, @LTransparentColor, @LWidth, @LHeight) <> 0 then
90
+ begin
91
+ if not CheckStrAttribute(LPySourceName, ' SourceName' , LSourceName) then
92
+ Exit(nil );
93
+
94
+ if not GetPythonEngine().PyList_Check(LPyScales) then
95
+ Exit(nil );
96
+
97
+ if not GetPythonEngine().PyList_Check(LPyFileNames) then
98
+ Exit(nil );
99
+
100
+ SetLength(LScales, PythonType.Engine.PyList_Size(LPyScales));
101
+ for I := 0 to GetPythonEngine().PyList_Size(LPyScales) - 1 do
102
+ LScales[I] := GetPythonEngine().PyFloat_AsDouble(
103
+ GetPythonEngine().PyList_GetItem(LPyScales, I));
104
+
105
+ SetLength(LFileNames, PythonType.Engine.PyList_Size(LPyFileNames));
106
+ for I := 0 to GetPythonEngine().PyList_Size(LPyFileNames) - 1 do
107
+ LFileNames[I] := GetPythonEngine.PyUnicodeAsString(
108
+ GetPythonEngine().PyList_GetItem(LPyFileNames, I));
109
+
110
+ Result := GetPythonEngine().PyLong_FromLong(
111
+ DelphiObject.AddOrSet(LSourceName, LScales, LFileNames, LTransparentColor, LWidth, LHeight));
112
+ end else
113
+ Result := nil ;
114
+ end ;
115
+
69
116
function TPyDelphiCustomImageList.BestSize_Wrapper (AArgs: PPyObject): PPyObject;
70
117
71
118
procedure Append (const AList, AItem: PPyObject; const AIx: integer);
@@ -77,7 +124,6 @@ function TPyDelphiCustomImageList.BestSize_Wrapper(AArgs: PPyObject): PPyObject;
77
124
end ;
78
125
79
126
var
80
- LPyIndex: PPyObject;
81
127
LPySize: PPyObject;
82
128
LIndex: integer;
83
129
LSize: TSize;
@@ -89,11 +135,9 @@ function TPyDelphiCustomImageList.BestSize_Wrapper(AArgs: PPyObject): PPyObject;
89
135
90
136
// We adjust the transmitted self argument
91
137
Adjust(@Self);
92
- if GetPythonEngine().PyArg_ParseTuple(AArgs, ' iO:BestSize' , @LPyIndex, @LPySize) <> 0 then begin
93
- if CheckIntAttribute(LPyIndex, ' Index' , LIndex)
94
- and (CheckSizeAttribute(LPySize, ' Size' , LSize)
95
- or
96
- (CheckSizeFAttribute(LPySize, ' Size' , LSizeF))) then
138
+ if GetPythonEngine().PyArg_ParseTuple(AArgs, ' iO:BestSize' , @LIndex, @LPySize) <> 0 then begin
139
+ if (CheckSizeAttribute(LPySize, ' Size' , LSize) or
140
+ (CheckSizeFAttribute(LPySize, ' Size' , LSizeF))) then
97
141
begin
98
142
if not CheckIndex(LIndex, DelphiObject.Count) then
99
143
Exit(nil );
@@ -141,7 +185,7 @@ function TPyDelphiCustomImageList.BitmapItemByName_Wrapper(
141
185
142
186
// We adjust the transmitted self argument
143
187
Adjust(@Self);
144
- if GetPythonEngine().PyArg_ParseTuple(AArgs, ' sOO :BitmapItemByName' , @LPyName, @LPyItem, @LPySize) <> 0 then begin
188
+ if GetPythonEngine().PyArg_ParseTuple(AArgs, ' OOO :BitmapItemByName' , @LPyName, @LPyItem, @LPySize) <> 0 then begin
145
189
if CheckStrAttribute(LPyName, ' Name' , LName)
146
190
and CheckObjAttribute(LPyItem, ' Item' , TCustomBitmapItem, TObject(LItem))
147
191
and CheckSizeAttribute(LPySize, ' Size' , LSize) then
@@ -175,6 +219,19 @@ class procedure TPyDelphiCustomImageList.RegisterMethods(
175
219
@TPyDelphiCustomImageList.BitmapItemByName_Wrapper,
176
220
' TCustomImageList.BitmapItemByName()' #10 +
177
221
' Tries to find, in the source collection, the bitmap item specified by name.' );
222
+
223
+ PythonType.AddMethod(' BestSize' ,
224
+ @TPyDelphiCustomImageList.BestSize_Wrapper,
225
+ ' TCustomImageList.BestSize()' #10 +
226
+ ' Tries to find, in the source collection, the bitmap item specified by name. ' +
227
+ ' This method trying to determine the maximum size of layer, which less than input size. ' +
228
+ ' If TLayer.MultiResBitmap has multiple images for different scales, then the search is performed among all images.' );
229
+
230
+ PythonType.AddMethod(' AddOrSet' ,
231
+ @TPyDelphiCustomImageList.AddOrSet_Wrapper,
232
+ ' TCustomImageList.AddOrSet()' #10 +
233
+ ' Adds or replaces several files in the source collection, ' +
234
+ ' and adds the item to the destination collection if it does not exist.' );
178
235
end ;
179
236
180
237
procedure TPyDelphiCustomImageList.SetDelphiObject (
0 commit comments