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