]>
Commit | Line | Data |
---|---|---|
554f62e9 | 1 | # This file was created automatically by SWIG 1.3.29. |
b7c75283 RD |
2 | # Don't modify this file, modify the SWIG interface instead. |
3 | ||
4 | import _activex | |
554f62e9 RD |
5 | import new |
6 | new_instancemethod = new.instancemethod | |
093d3ff1 | 7 | def _swig_setattr_nondynamic(self,class_type,name,value,static=1): |
554f62e9 | 8 | if (name == "thisown"): return self.this.own(value) |
093d3ff1 | 9 | if (name == "this"): |
554f62e9 RD |
10 | if type(value).__name__ == 'PySwigObject': |
11 | self.__dict__[name] = value | |
093d3ff1 RD |
12 | return |
13 | method = class_type.__swig_setmethods__.get(name,None) | |
14 | if method: return method(self,value) | |
554f62e9 | 15 | if (not static) or hasattr(self,name): |
093d3ff1 RD |
16 | self.__dict__[name] = value |
17 | else: | |
18 | raise AttributeError("You cannot add attributes to %s" % self) | |
19 | ||
20 | def _swig_setattr(self,class_type,name,value): | |
21 | return _swig_setattr_nondynamic(self,class_type,name,value,0) | |
22 | ||
23 | def _swig_getattr(self,class_type,name): | |
554f62e9 | 24 | if (name == "thisown"): return self.this.own() |
093d3ff1 RD |
25 | method = class_type.__swig_getmethods__.get(name,None) |
26 | if method: return method(self) | |
27 | raise AttributeError,name | |
28 | ||
554f62e9 RD |
29 | def _swig_repr(self): |
30 | try: strthis = "proxy of " + self.this.__repr__() | |
31 | except: strthis = "" | |
32 | return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) | |
33 | ||
093d3ff1 RD |
34 | import types |
35 | try: | |
36 | _object = types.ObjectType | |
37 | _newclass = 1 | |
38 | except AttributeError: | |
39 | class _object : pass | |
40 | _newclass = 0 | |
41 | del types | |
42 | ||
43 | ||
44 | def _swig_setattr_nondynamic_method(set): | |
45 | def set_attr(self,name,value): | |
554f62e9 RD |
46 | if (name == "thisown"): return self.this.own(value) |
47 | if hasattr(self,name) or (name == "this"): | |
093d3ff1 RD |
48 | set(self,name,value) |
49 | else: | |
50 | raise AttributeError("You cannot add attributes to %s" % self) | |
51 | return set_attr | |
52 | ||
53 | ||
d55e5bfc RD |
54 | import _core |
55 | wx = _core | |
c24da6d6 | 56 | __docfilter__ = wx.__DocFilter(globals()) |
b7c75283 RD |
57 | #--------------------------------------------------------------------------- |
58 | ||
59 | class CLSID(object): | |
60 | """ | |
61 | This class wraps the Windows CLSID structure and is used to | |
62 | specify the class of the ActiveX object that is to be created. A | |
63 | CLSID can be constructed from either a ProgID string, (such as | |
64 | 'WordPad.Document.1') or a classID string, (such as | |
65 | '{CA8A9783-280D-11CF-A24D-444553540000}'). | |
66 | """ | |
554f62e9 RD |
67 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
68 | __repr__ = _swig_repr | |
69 | def __init__(self, *args, **kwargs): | |
b7c75283 | 70 | """ |
a95a7133 | 71 | __init__(self, String id) -> CLSID |
b7c75283 RD |
72 | |
73 | This class wraps the Windows CLSID structure and is used to | |
74 | specify the class of the ActiveX object that is to be created. A | |
75 | CLSID can be constructed from either a ProgID string, (such as | |
76 | 'WordPad.Document.1') or a classID string, (such as | |
77 | '{CA8A9783-280D-11CF-A24D-444553540000}'). | |
78 | """ | |
554f62e9 RD |
79 | _activex.CLSID_swiginit(self,_activex.new_CLSID(*args, **kwargs)) |
80 | __swig_destroy__ = _activex.delete_CLSID | |
81 | __del__ = lambda self : None; | |
b7c75283 | 82 | def GetCLSIDString(*args, **kwargs): |
a95a7133 | 83 | """GetCLSIDString(self) -> String""" |
b7c75283 RD |
84 | return _activex.CLSID_GetCLSIDString(*args, **kwargs) |
85 | ||
86 | def GetProgIDString(*args, **kwargs): | |
a95a7133 | 87 | """GetProgIDString(self) -> String""" |
b7c75283 RD |
88 | return _activex.CLSID_GetProgIDString(*args, **kwargs) |
89 | ||
90 | def __str__(self): return self.GetCLSIDString() | |
554f62e9 RD |
91 | CLSID_swigregister = _activex.CLSID_swigregister |
92 | CLSID_swigregister(CLSID) | |
b7c75283 RD |
93 | |
94 | #--------------------------------------------------------------------------- | |
95 | ||
96 | class ParamX(object): | |
093d3ff1 | 97 | """Proxy of C++ ParamX class""" |
554f62e9 RD |
98 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
99 | def __init__(self): raise AttributeError, "No constructor defined" | |
100 | __repr__ = _swig_repr | |
b7c75283 RD |
101 | flags = property(_activex.ParamX_flags_get) |
102 | isPtr = property(_activex.ParamX_isPtr_get) | |
103 | isSafeArray = property(_activex.ParamX_isSafeArray_get) | |
104 | isOptional = property(_activex.ParamX_isOptional_get) | |
105 | vt = property(_activex.ParamX_vt_get) | |
106 | name = property(_activex.ParamX_name_get) | |
107 | vt_type = property(_activex.ParamX_vt_type_get) | |
108 | ||
109 | isIn = property(_activex.ParamX_IsIn) | |
110 | ||
111 | isOut = property(_activex.ParamX_IsOut) | |
112 | ||
113 | isRetVal = property(_activex.ParamX_IsRetVal) | |
114 | ||
554f62e9 RD |
115 | ParamX_swigregister = _activex.ParamX_swigregister |
116 | ParamX_swigregister(ParamX) | |
b7c75283 RD |
117 | |
118 | class FuncX(object): | |
093d3ff1 | 119 | """Proxy of C++ FuncX class""" |
554f62e9 RD |
120 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
121 | def __init__(self): raise AttributeError, "No constructor defined" | |
122 | __repr__ = _swig_repr | |
b7c75283 RD |
123 | name = property(_activex.FuncX_name_get) |
124 | memid = property(_activex.FuncX_memid_get) | |
125 | hasOut = property(_activex.FuncX_hasOut_get) | |
126 | retType = property(_activex.FuncX_retType_get) | |
127 | params = property(_activex.FuncX_params_get) | |
554f62e9 RD |
128 | FuncX_swigregister = _activex.FuncX_swigregister |
129 | FuncX_swigregister(FuncX) | |
b7c75283 RD |
130 | |
131 | class PropX(object): | |
093d3ff1 | 132 | """Proxy of C++ PropX class""" |
554f62e9 RD |
133 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
134 | def __init__(self): raise AttributeError, "No constructor defined" | |
135 | __repr__ = _swig_repr | |
b7c75283 RD |
136 | name = property(_activex.PropX_name_get) |
137 | memid = property(_activex.PropX_memid_get) | |
138 | type = property(_activex.PropX_type_get) | |
139 | arg = property(_activex.PropX_arg_get) | |
140 | putByRef = property(_activex.PropX_putByRef_get) | |
141 | canGet = property(_activex.PropX_CanGet) | |
142 | ||
143 | canSet = property(_activex.PropX_CanSet) | |
144 | ||
554f62e9 RD |
145 | PropX_swigregister = _activex.PropX_swigregister |
146 | PropX_swigregister(PropX) | |
b7c75283 RD |
147 | |
148 | class ParamXArray(object): | |
093d3ff1 | 149 | """Proxy of C++ ParamXArray class""" |
554f62e9 RD |
150 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
151 | def __init__(self): raise AttributeError, "No constructor defined" | |
152 | __repr__ = _swig_repr | |
b7c75283 | 153 | def __nonzero__(*args, **kwargs): |
a95a7133 | 154 | """__nonzero__(self) -> bool""" |
b7c75283 RD |
155 | return _activex.ParamXArray___nonzero__(*args, **kwargs) |
156 | ||
157 | def __len__(*args, **kwargs): | |
a95a7133 | 158 | """__len__(self) -> int""" |
b7c75283 RD |
159 | return _activex.ParamXArray___len__(*args, **kwargs) |
160 | ||
161 | def __getitem__(*args, **kwargs): | |
a95a7133 | 162 | """__getitem__(self, int idx) -> ParamX""" |
b7c75283 RD |
163 | return _activex.ParamXArray___getitem__(*args, **kwargs) |
164 | ||
554f62e9 RD |
165 | ParamXArray_swigregister = _activex.ParamXArray_swigregister |
166 | ParamXArray_swigregister(ParamXArray) | |
b7c75283 RD |
167 | |
168 | class FuncXArray(object): | |
093d3ff1 | 169 | """Proxy of C++ FuncXArray class""" |
554f62e9 RD |
170 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
171 | def __init__(self): raise AttributeError, "No constructor defined" | |
172 | __repr__ = _swig_repr | |
b7c75283 | 173 | def __nonzero__(*args, **kwargs): |
a95a7133 | 174 | """__nonzero__(self) -> bool""" |
b7c75283 RD |
175 | return _activex.FuncXArray___nonzero__(*args, **kwargs) |
176 | ||
177 | def __len__(*args, **kwargs): | |
a95a7133 | 178 | """__len__(self) -> int""" |
b7c75283 RD |
179 | return _activex.FuncXArray___len__(*args, **kwargs) |
180 | ||
181 | def __getitem__(*args, **kwargs): | |
a95a7133 | 182 | """__getitem__(self, int idx) -> FuncX""" |
b7c75283 RD |
183 | return _activex.FuncXArray___getitem__(*args, **kwargs) |
184 | ||
554f62e9 RD |
185 | FuncXArray_swigregister = _activex.FuncXArray_swigregister |
186 | FuncXArray_swigregister(FuncXArray) | |
b7c75283 RD |
187 | |
188 | class PropXArray(object): | |
093d3ff1 | 189 | """Proxy of C++ PropXArray class""" |
554f62e9 RD |
190 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
191 | def __init__(self): raise AttributeError, "No constructor defined" | |
192 | __repr__ = _swig_repr | |
b7c75283 | 193 | def __nonzero__(*args, **kwargs): |
a95a7133 | 194 | """__nonzero__(self) -> bool""" |
b7c75283 RD |
195 | return _activex.PropXArray___nonzero__(*args, **kwargs) |
196 | ||
197 | def __len__(*args, **kwargs): | |
a95a7133 | 198 | """__len__(self) -> int""" |
b7c75283 RD |
199 | return _activex.PropXArray___len__(*args, **kwargs) |
200 | ||
201 | def __getitem__(*args, **kwargs): | |
a95a7133 | 202 | """__getitem__(self, int idx) -> PropX""" |
b7c75283 RD |
203 | return _activex.PropXArray___getitem__(*args, **kwargs) |
204 | ||
554f62e9 RD |
205 | PropXArray_swigregister = _activex.PropXArray_swigregister |
206 | PropXArray_swigregister(PropXArray) | |
b7c75283 RD |
207 | |
208 | #--------------------------------------------------------------------------- | |
209 | ||
d55e5bfc | 210 | class ActiveXWindow(_core.Window): |
b7c75283 RD |
211 | """ |
212 | ActiveXWindow derives from wxWindow and the constructor accepts a | |
213 | CLSID for the ActiveX Control that should be created. The | |
214 | ActiveXWindow class simply adds methods that allow you to query | |
215 | some of the TypeInfo exposed by the ActiveX object, and also to | |
216 | get/set properties or call methods by name. The Python | |
217 | implementation automatically handles converting parameters and | |
218 | return values to/from the types expected by the ActiveX code as | |
219 | specified by the TypeInfo. | |
220 | ||
221 | """ | |
554f62e9 RD |
222 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
223 | __repr__ = _swig_repr | |
224 | def __init__(self, *args, **kwargs): | |
b7c75283 | 225 | """ |
a95a7133 | 226 | __init__(self, Window parent, CLSID clsId, int id=-1, Point pos=DefaultPosition, |
b7c75283 RD |
227 | Size size=DefaultSize, long style=0, |
228 | String name=PanelNameStr) -> ActiveXWindow | |
229 | ||
230 | Creates an ActiveX control from the clsID given and makes it act | |
231 | as much like a regular wx.Window as possible. | |
232 | """ | |
554f62e9 | 233 | _activex.ActiveXWindow_swiginit(self,_activex.new_ActiveXWindow(*args, **kwargs)) |
b7c75283 RD |
234 | self._setOORInfo(self) |
235 | ||
236 | def GetCLSID(*args, **kwargs): | |
237 | """ | |
a95a7133 | 238 | GetCLSID(self) -> CLSID |
b7c75283 RD |
239 | |
240 | Return the CLSID used to construct this ActiveX window | |
241 | """ | |
242 | return _activex.ActiveXWindow_GetCLSID(*args, **kwargs) | |
243 | ||
244 | def GetAXEventCount(*args, **kwargs): | |
245 | """ | |
a95a7133 | 246 | GetAXEventCount(self) -> int |
b7c75283 RD |
247 | |
248 | Number of events defined for this control | |
249 | """ | |
250 | return _activex.ActiveXWindow_GetAXEventCount(*args, **kwargs) | |
251 | ||
252 | def GetAXEventDesc(*args, **kwargs): | |
253 | """ | |
a95a7133 | 254 | GetAXEventDesc(self, int idx) -> FuncX |
b7c75283 RD |
255 | |
256 | Returns event description by index | |
257 | """ | |
258 | return _activex.ActiveXWindow_GetAXEventDesc(*args, **kwargs) | |
259 | ||
260 | def GetAXPropCount(*args, **kwargs): | |
261 | """ | |
a95a7133 | 262 | GetAXPropCount(self) -> int |
b7c75283 RD |
263 | |
264 | Number of properties defined for this control | |
265 | """ | |
266 | return _activex.ActiveXWindow_GetAXPropCount(*args, **kwargs) | |
267 | ||
268 | def GetAXPropDesc(*args): | |
269 | """ | |
a95a7133 RD |
270 | GetAXPropDesc(self, int idx) -> PropX |
271 | GetAXPropDesc(self, String name) -> PropX | |
b7c75283 RD |
272 | """ |
273 | return _activex.ActiveXWindow_GetAXPropDesc(*args) | |
274 | ||
275 | def GetAXMethodCount(*args, **kwargs): | |
276 | """ | |
a95a7133 | 277 | GetAXMethodCount(self) -> int |
b7c75283 RD |
278 | |
279 | Number of methods defined for this control | |
280 | """ | |
281 | return _activex.ActiveXWindow_GetAXMethodCount(*args, **kwargs) | |
282 | ||
283 | def GetAXMethodDesc(*args): | |
284 | """ | |
a95a7133 RD |
285 | GetAXMethodDesc(self, int idx) -> FuncX |
286 | GetAXMethodDesc(self, String name) -> FuncX | |
b7c75283 RD |
287 | """ |
288 | return _activex.ActiveXWindow_GetAXMethodDesc(*args) | |
289 | ||
290 | def GetAXEvents(*args, **kwargs): | |
291 | """ | |
a95a7133 | 292 | GetAXEvents(self) -> FuncXArray |
b7c75283 RD |
293 | |
294 | Returns a sequence of FuncX objects describing the events | |
295 | available for this ActiveX object. | |
296 | """ | |
297 | return _activex.ActiveXWindow_GetAXEvents(*args, **kwargs) | |
298 | ||
299 | def GetAXMethods(*args, **kwargs): | |
300 | """ | |
a95a7133 | 301 | GetAXMethods(self) -> FuncXArray |
b7c75283 RD |
302 | |
303 | Returns a sequence of FuncX objects describing the methods | |
304 | available for this ActiveX object. | |
305 | """ | |
306 | return _activex.ActiveXWindow_GetAXMethods(*args, **kwargs) | |
307 | ||
308 | def GetAXProperties(*args, **kwargs): | |
309 | """ | |
a95a7133 | 310 | GetAXProperties(self) -> PropXArray |
b7c75283 RD |
311 | |
312 | Returns a sequence of PropX objects describing the properties | |
313 | available for this ActiveX object. | |
314 | """ | |
315 | return _activex.ActiveXWindow_GetAXProperties(*args, **kwargs) | |
316 | ||
317 | def SetAXProp(*args, **kwargs): | |
318 | """ | |
a95a7133 | 319 | SetAXProp(self, String name, PyObject value) |
b7c75283 RD |
320 | |
321 | Set a property of the ActiveX object by name. | |
322 | """ | |
323 | return _activex.ActiveXWindow_SetAXProp(*args, **kwargs) | |
324 | ||
325 | def GetAXProp(*args, **kwargs): | |
326 | """ | |
a95a7133 | 327 | GetAXProp(self, String name) -> PyObject |
b7c75283 RD |
328 | |
329 | Get the value of an ActiveX property by name. | |
330 | """ | |
331 | return _activex.ActiveXWindow_GetAXProp(*args, **kwargs) | |
332 | ||
333 | def _CallAXMethod(*args): | |
334 | """ | |
a95a7133 | 335 | _CallAXMethod(self, String name, PyObject args) -> PyObject |
b7c75283 RD |
336 | |
337 | The implementation for CallMethod. Calls an ActiveX method, by | |
338 | name passing the parameters given in args. | |
339 | """ | |
340 | return _activex.ActiveXWindow__CallAXMethod(*args) | |
341 | ||
342 | def CallAXMethod(self, name, *args): | |
343 | """ | |
344 | Front-end for _CallMethod. Simply passes all positional args | |
345 | after the name as a single tuple to _CallMethod. | |
346 | """ | |
347 | return self._CallAXMethod(name, args) | |
348 | ||
554f62e9 RD |
349 | ActiveXWindow_swigregister = _activex.ActiveXWindow_swigregister |
350 | ActiveXWindow_swigregister(ActiveXWindow) | |
b7c75283 RD |
351 | |
352 | #--------------------------------------------------------------------------- | |
353 | ||
354 | ||
355 | def RegisterActiveXEvent(*args, **kwargs): | |
554f62e9 | 356 | """ |
f460c29d | 357 | RegisterActiveXEvent(String eventName) -> EventType |
b7c75283 RD |
358 | |
359 | Creates a standard wx event ID for the given eventName. | |
360 | """ | |
554f62e9 | 361 | return _activex.RegisterActiveXEvent(*args, **kwargs) |
d55e5bfc | 362 | class ActiveXEvent(_core.CommandEvent): |
b7c75283 RD |
363 | """ |
364 | An instance of ActiveXEvent is sent to the handler for all bound | |
365 | ActiveX events. Any event parameters from the ActiveX cntrol are | |
366 | turned into attributes of the Python proxy for this event object. | |
367 | Additionally, there is a property called eventName that will | |
c24da6d6 | 368 | return (surprisingly <wink>) the name of the ActiveX event. |
b7c75283 | 369 | """ |
554f62e9 RD |
370 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
371 | def __init__(self): raise AttributeError, "No constructor defined" | |
372 | __repr__ = _swig_repr | |
b7c75283 RD |
373 | eventName = property(_activex.ActiveXEvent_EventName) |
374 | ||
0dabb2a2 | 375 | def _preCallInit(*args, **kwargs): |
a95a7133 | 376 | """_preCallInit(self, PyObject pyself)""" |
0dabb2a2 | 377 | return _activex.ActiveXEvent__preCallInit(*args, **kwargs) |
b7c75283 | 378 | |
0dabb2a2 | 379 | def _postCallCleanup(*args, **kwargs): |
a95a7133 | 380 | """_postCallCleanup(self, PyObject pyself)""" |
0dabb2a2 | 381 | return _activex.ActiveXEvent__postCallCleanup(*args, **kwargs) |
b7c75283 | 382 | |
554f62e9 RD |
383 | ActiveXEvent_swigregister = _activex.ActiveXEvent_swigregister |
384 | ActiveXEvent_swigregister(ActiveXEvent) | |
b7c75283 RD |
385 | |
386 | #--------------------------------------------------------------------------- | |
387 | ||
388 | class IEHtmlWindowBase(ActiveXWindow): | |
554f62e9 RD |
389 | thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') |
390 | __repr__ = _swig_repr | |
391 | def __init__(self, *args, **kwargs): | |
392 | _activex.IEHtmlWindowBase_swiginit(self,_activex.new_IEHtmlWindowBase(*args, **kwargs)) | |
a8f72945 RD |
393 | self._setOORInfo(self) |
394 | ||
b7c75283 RD |
395 | def SetCharset(*args, **kwargs): return _activex.IEHtmlWindowBase_SetCharset(*args, **kwargs) |
396 | def LoadString(*args, **kwargs): return _activex.IEHtmlWindowBase_LoadString(*args, **kwargs) | |
397 | def LoadStream(*args, **kwargs): return _activex.IEHtmlWindowBase_LoadStream(*args, **kwargs) | |
398 | def GetStringSelection(*args, **kwargs): return _activex.IEHtmlWindowBase_GetStringSelection(*args, **kwargs) | |
399 | def GetText(*args, **kwargs): return _activex.IEHtmlWindowBase_GetText(*args, **kwargs) | |
554f62e9 RD |
400 | IEHtmlWindowBase_swigregister = _activex.IEHtmlWindowBase_swigregister |
401 | IEHtmlWindowBase_swigregister(IEHtmlWindowBase) | |
b7c75283 RD |
402 | |
403 | #--------------------------------------------------------------------------- | |
404 | # Some helper and utility functions for ActiveX | |
405 | ||
406 | ||
407 | t4 = " " * 4 | |
408 | t8 = " " * 8 | |
409 | ||
410 | def GetAXInfo(ax): | |
411 | """ | |
412 | Returns a printable summary of the TypeInfo from the ActiveX instance | |
413 | passed in. | |
414 | """ | |
415 | ||
416 | def ProcessFuncX(f, out, name): | |
417 | out.append(name) | |
418 | out.append(t4 + "retType: %s" % f.retType.vt_type) | |
419 | if f.params: | |
420 | out.append(t4 + "params:") | |
421 | for p in f.params: | |
422 | out.append(t8 + p.name) | |
423 | out.append(t8+t4+ "in:%s out:%s optional:%s type:%s" % (p.isIn, p.isOut, p.isOptional, p.vt_type)) | |
424 | out.append('') | |
425 | ||
426 | def ProcessPropX(p, out): | |
427 | out.append(GernerateAXModule.trimPropName(p.name)) | |
428 | out.append(t4+ "type:%s arg:%s canGet:%s canSet:%s" % (p.type.vt_type, p.arg.vt_type, p.canGet, p.canSet)) | |
429 | out.append('') | |
430 | ||
431 | out = [] | |
432 | ||
433 | out.append("PROPERTIES") | |
434 | out.append("-"*20) | |
435 | for p in ax.GetAXProperties(): | |
436 | ProcessPropX(p, out) | |
437 | out.append('\n\n') | |
438 | ||
439 | out.append("METHODS") | |
440 | out.append("-"*20) | |
441 | for m in ax.GetAXMethods(): | |
442 | ProcessFuncX(m, out, GernerateAXModule.trimMethodName(m.name)) | |
443 | out.append('\n\n') | |
444 | ||
445 | out.append("EVENTS") | |
446 | out.append("-"*20) | |
447 | for e in ax.GetAXEvents(): | |
448 | ProcessFuncX(e, out, GernerateAXModule.trimEventName(e.name)) | |
449 | out.append('\n\n') | |
450 | ||
451 | return "\n".join(out) | |
452 | ||
453 | ||
454 | ||
455 | class GernerateAXModule: | |
456 | def __init__(self, ax, className, modulePath, moduleName=None, verbose=False): | |
457 | """ | |
458 | Make a Python module file with a class that has been specialized | |
459 | for the AcitveX object. | |
460 | ||
461 | ax An instance of the ActiveXWindow class | |
462 | className The name to use for the new class | |
463 | modulePath The path where the new module should be written to | |
464 | moduleName The name of the .py file to create. If not given | |
465 | then the className will be used. | |
466 | """ | |
467 | import os | |
468 | if moduleName is None: | |
469 | moduleName = className + '.py' | |
470 | filename = os.path.join(modulePath, moduleName) | |
471 | if verbose: | |
472 | print "Creating module in:", filename | |
473 | print " ProgID: ", ax.GetCLSID().GetProgIDString() | |
474 | print " CLSID: ", ax.GetCLSID().GetCLSIDString() | |
475 | ||
476 | self.mf = file(filename, "w") | |
477 | self.WriteFileHeader(ax) | |
478 | self.WriteEvents(ax) | |
479 | self.WriteClassHeader(ax, className) | |
480 | self.WriteMethods(ax) | |
481 | self.WriteProperties(ax) | |
482 | self.WriteDocs(ax) | |
483 | self.mf.close() | |
484 | del self.mf | |
485 | ||
486 | ||
487 | def WriteFileHeader(self, ax): | |
488 | self.write("# This module was generated by the wx.activex.GernerateAXModule class\n" | |
489 | "# (See also the genaxmodule script.)\n") | |
490 | self.write("import wx") | |
491 | self.write("import wx.activex\n") | |
492 | self.write("clsID = '%s'\nprogID = '%s'\n" | |
493 | % (ax.GetCLSID().GetCLSIDString(), ax.GetCLSID().GetProgIDString())) | |
494 | self.write("\n") | |
495 | ||
496 | ||
497 | def WriteEvents(self, ax): | |
498 | events = ax.GetAXEvents() | |
499 | if events: | |
500 | self.write("# Create eventTypes and event binders") | |
501 | for e in events: | |
502 | self.write("wxEVT_%s = wx.activex.RegisterActiveXEvent('%s')" | |
503 | % (self.trimEventName(e.name), e.name)) | |
504 | self.write() | |
505 | for e in events: | |
506 | n = self.trimEventName(e.name) | |
507 | self.write("EVT_%s = wx.PyEventBinder(wxEVT_%s, 1)" % (n,n)) | |
508 | self.write("\n") | |
509 | ||
510 | ||
511 | def WriteClassHeader(self, ax, className): | |
512 | self.write("# Derive a new class from ActiveXWindow") | |
513 | self.write("""\ | |
514 | class %s(wx.activex.ActiveXWindow): | |
515 | def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, | |
516 | size=wx.DefaultSize, style=0, name='%s'): | |
517 | wx.activex.ActiveXWindow.__init__(self, parent, | |
518 | wx.activex.CLSID('%s'), | |
519 | ID, pos, size, style, name) | |
520 | """ % (className, className, ax.GetCLSID().GetCLSIDString()) ) | |
521 | ||
522 | ||
523 | def WriteMethods(self, ax): | |
524 | methods = ax.GetAXMethods() | |
525 | if methods: | |
526 | self.write(t4, "# Methods exported by the ActiveX object") | |
527 | for m in methods: | |
528 | name = self.trimMethodName(m.name) | |
529 | self.write(t4, "def %s(self%s):" % (name, self.getParameters(m, True))) | |
530 | self.write(t8, "return self.CallAXMethod('%s'%s)" % (m.name, self.getParameters(m, False))) | |
531 | self.write() | |
532 | ||
533 | ||
534 | def WriteProperties(self, ax): | |
535 | props = ax.GetAXProperties() | |
536 | if props: | |
537 | self.write(t4, "# Getters, Setters and properties") | |
538 | for p in props: | |
539 | getterName = setterName = "None" | |
540 | if p.canGet: | |
541 | getterName = "_get_" + p.name | |
542 | self.write(t4, "def %s(self):" % getterName) | |
543 | self.write(t8, "return self.GetAXProp('%s')" % p.name) | |
544 | if p.canSet: | |
545 | setterName = "_set_" + p.name | |
546 | self.write(t4, "def %s(self, %s):" % (setterName, p.arg.name)) | |
547 | self.write(t8, "self.SetAXProp('%s', %s)" % (p.name, p.arg.name)) | |
548 | ||
549 | self.write(t4, "%s = property(%s, %s)" % | |
550 | (self.trimPropName(p.name), getterName, setterName)) | |
551 | self.write() | |
552 | ||
553 | ||
554 | def WriteDocs(self, ax): | |
555 | self.write() | |
556 | doc = GetAXInfo(ax) | |
557 | for line in doc.split('\n'): | |
558 | self.write("# ", line) | |
559 | ||
560 | ||
561 | ||
562 | def write(self, *args): | |
563 | for a in args: | |
564 | self.mf.write(a) | |
565 | self.mf.write("\n") | |
566 | ||
567 | ||
568 | def trimEventName(name): | |
569 | if name.startswith("On"): | |
570 | name = name[2:] | |
571 | return name | |
572 | trimEventName = staticmethod(trimEventName) | |
573 | ||
574 | ||
575 | def trimPropName(name): | |
576 | #name = name[0].lower() + name[1:] | |
577 | name = name.lower() | |
578 | import keyword | |
579 | if name in keyword.kwlist: name += '_' | |
580 | return name | |
581 | trimPropName = staticmethod(trimPropName) | |
582 | ||
583 | ||
584 | def trimMethodName(name): | |
585 | import keyword | |
586 | if name in keyword.kwlist: name += '_' | |
587 | return name | |
588 | trimMethodName = staticmethod(trimMethodName) | |
589 | ||
590 | ||
591 | def getParameters(self, m, withDefaults): | |
592 | import keyword | |
593 | st = "" | |
594 | # collect the input parameters, if both isIn and isOut are | |
595 | # False then assume it is an input paramater | |
596 | params = [] | |
597 | for p in m.params: | |
598 | if p.isIn or (not p.isIn and not p.isOut): | |
599 | params.append(p) | |
600 | # did we get any? | |
601 | for p in params: | |
602 | name = p.name | |
603 | if name in keyword.kwlist: name += '_' | |
604 | st += ", " | |
605 | st += name | |
606 | if withDefaults and p.isOptional: | |
607 | st += '=None' | |
608 | return st | |
609 | ||
610 | ||
611 | #--------------------------------------------------------------------------- | |
612 | ||
613 | ||
7449af73 | 614 |