]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/activex/activex.py
1 # This file was created automatically by SWIG 1.3.27.
2 # Don't modify this file, modify the SWIG interface instead.
6 def _swig_setattr_nondynamic(self
,class_type
,name
,value
,static
=1):
8 if isinstance(value
, class_type
):
9 self
.__dict
__[name
] = value
.this
10 if hasattr(value
,"thisown"): self
.__dict
__["thisown"] = value
.thisown
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
18 raise AttributeError("You cannot add attributes to %s" % self
)
20 def _swig_setattr(self
,class_type
,name
,value
):
21 return _swig_setattr_nondynamic(self
,class_type
,name
,value
,0)
23 def _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
30 _object
= types
.ObjectType
32 except AttributeError:
38 def _swig_setattr_nondynamic_method(set):
39 def set_attr(self
,name
,value
):
40 if hasattr(self
,name
) or (name
in ("this", "thisown")):
43 raise AttributeError("You cannot add attributes to %s" % self
)
49 __docfilter__
= wx
.__DocFilter
(globals())
50 #---------------------------------------------------------------------------
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}').
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
):
64 __init__(self, String id) -> CLSID
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}').
72 newobj
= _activex
.new_CLSID(*args
, **kwargs
)
73 self
.this
= newobj
.this
76 def __del__(self
, destroy
=_activex
.delete_CLSID
):
79 if self
.thisown
: destroy(self
)
82 def GetCLSIDString(*args
, **kwargs
):
83 """GetCLSIDString(self) -> String"""
84 return _activex
.CLSID_GetCLSIDString(*args
, **kwargs
)
86 def GetProgIDString(*args
, **kwargs
):
87 """GetProgIDString(self) -> String"""
88 return _activex
.CLSID_GetProgIDString(*args
, **kwargs
)
90 def __str__(self
): return self
.GetCLSIDString()
92 class CLSIDPtr(CLSID
):
93 def __init__(self
, this
):
95 if not hasattr(self
,"thisown"): self
.thisown
= 0
96 self
.__class
__ = CLSID
97 _activex
.CLSID_swigregister(CLSIDPtr
)
99 #---------------------------------------------------------------------------
101 class ParamX(object):
102 """Proxy of C++ ParamX class"""
103 def __init__(self
): raise RuntimeError, "No constructor defined"
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
)
114 isIn
= property(_activex
.ParamX_IsIn
)
116 isOut
= property(_activex
.ParamX_IsOut
)
118 isRetVal
= property(_activex
.ParamX_IsRetVal
)
121 class ParamXPtr(ParamX
):
122 def __init__(self
, this
):
124 if not hasattr(self
,"thisown"): self
.thisown
= 0
125 self
.__class
__ = ParamX
126 _activex
.ParamX_swigregister(ParamXPtr
)
129 """Proxy of C++ FuncX class"""
130 def __init__(self
): raise RuntimeError, "No constructor defined"
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
)
139 class FuncXPtr(FuncX
):
140 def __init__(self
, this
):
142 if not hasattr(self
,"thisown"): self
.thisown
= 0
143 self
.__class
__ = FuncX
144 _activex
.FuncX_swigregister(FuncXPtr
)
147 """Proxy of C++ PropX class"""
148 def __init__(self
): raise RuntimeError, "No constructor defined"
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
)
158 canSet
= property(_activex
.PropX_CanSet
)
161 class PropXPtr(PropX
):
162 def __init__(self
, this
):
164 if not hasattr(self
,"thisown"): self
.thisown
= 0
165 self
.__class
__ = PropX
166 _activex
.PropX_swigregister(PropXPtr
)
168 class ParamXArray(object):
169 """Proxy of C++ ParamXArray class"""
170 def __init__(self
): raise RuntimeError, "No constructor defined"
172 return "<%s.%s; proxy of C++ wxParamXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
173 def __nonzero__(*args
, **kwargs
):
174 """__nonzero__(self) -> bool"""
175 return _activex
.ParamXArray___nonzero__(*args
, **kwargs
)
177 def __len__(*args
, **kwargs
):
178 """__len__(self) -> int"""
179 return _activex
.ParamXArray___len__(*args
, **kwargs
)
181 def __getitem__(*args
, **kwargs
):
182 """__getitem__(self, int idx) -> ParamX"""
183 return _activex
.ParamXArray___getitem__(*args
, **kwargs
)
186 class ParamXArrayPtr(ParamXArray
):
187 def __init__(self
, this
):
189 if not hasattr(self
,"thisown"): self
.thisown
= 0
190 self
.__class
__ = ParamXArray
191 _activex
.ParamXArray_swigregister(ParamXArrayPtr
)
193 class FuncXArray(object):
194 """Proxy of C++ FuncXArray class"""
195 def __init__(self
): raise RuntimeError, "No constructor defined"
197 return "<%s.%s; proxy of C++ wxFuncXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
198 def __nonzero__(*args
, **kwargs
):
199 """__nonzero__(self) -> bool"""
200 return _activex
.FuncXArray___nonzero__(*args
, **kwargs
)
202 def __len__(*args
, **kwargs
):
203 """__len__(self) -> int"""
204 return _activex
.FuncXArray___len__(*args
, **kwargs
)
206 def __getitem__(*args
, **kwargs
):
207 """__getitem__(self, int idx) -> FuncX"""
208 return _activex
.FuncXArray___getitem__(*args
, **kwargs
)
211 class FuncXArrayPtr(FuncXArray
):
212 def __init__(self
, this
):
214 if not hasattr(self
,"thisown"): self
.thisown
= 0
215 self
.__class
__ = FuncXArray
216 _activex
.FuncXArray_swigregister(FuncXArrayPtr
)
218 class PropXArray(object):
219 """Proxy of C++ PropXArray class"""
220 def __init__(self
): raise RuntimeError, "No constructor defined"
222 return "<%s.%s; proxy of C++ wxPropXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
223 def __nonzero__(*args
, **kwargs
):
224 """__nonzero__(self) -> bool"""
225 return _activex
.PropXArray___nonzero__(*args
, **kwargs
)
227 def __len__(*args
, **kwargs
):
228 """__len__(self) -> int"""
229 return _activex
.PropXArray___len__(*args
, **kwargs
)
231 def __getitem__(*args
, **kwargs
):
232 """__getitem__(self, int idx) -> PropX"""
233 return _activex
.PropXArray___getitem__(*args
, **kwargs
)
236 class PropXArrayPtr(PropXArray
):
237 def __init__(self
, this
):
239 if not hasattr(self
,"thisown"): self
.thisown
= 0
240 self
.__class
__ = PropXArray
241 _activex
.PropXArray_swigregister(PropXArrayPtr
)
243 #---------------------------------------------------------------------------
245 class ActiveXWindow(_core
.Window
):
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.
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
):
261 __init__(self, Window parent, CLSID clsId, int id=-1, Point pos=DefaultPosition,
262 Size size=DefaultSize, long style=0,
263 String name=PanelNameStr) -> ActiveXWindow
265 Creates an ActiveX control from the clsID given and makes it act
266 as much like a regular wx.Window as possible.
268 newobj
= _activex
.new_ActiveXWindow(*args
, **kwargs
)
269 self
.this
= newobj
.this
272 self
._setOORInfo
(self
)
274 def GetCLSID(*args
, **kwargs
):
276 GetCLSID(self) -> CLSID
278 Return the CLSID used to construct this ActiveX window
280 return _activex
.ActiveXWindow_GetCLSID(*args
, **kwargs
)
282 def GetAXEventCount(*args
, **kwargs
):
284 GetAXEventCount(self) -> int
286 Number of events defined for this control
288 return _activex
.ActiveXWindow_GetAXEventCount(*args
, **kwargs
)
290 def GetAXEventDesc(*args
, **kwargs
):
292 GetAXEventDesc(self, int idx) -> FuncX
294 Returns event description by index
296 return _activex
.ActiveXWindow_GetAXEventDesc(*args
, **kwargs
)
298 def GetAXPropCount(*args
, **kwargs
):
300 GetAXPropCount(self) -> int
302 Number of properties defined for this control
304 return _activex
.ActiveXWindow_GetAXPropCount(*args
, **kwargs
)
306 def GetAXPropDesc(*args
):
308 GetAXPropDesc(self, int idx) -> PropX
309 GetAXPropDesc(self, String name) -> PropX
311 return _activex
.ActiveXWindow_GetAXPropDesc(*args
)
313 def GetAXMethodCount(*args
, **kwargs
):
315 GetAXMethodCount(self) -> int
317 Number of methods defined for this control
319 return _activex
.ActiveXWindow_GetAXMethodCount(*args
, **kwargs
)
321 def GetAXMethodDesc(*args
):
323 GetAXMethodDesc(self, int idx) -> FuncX
324 GetAXMethodDesc(self, String name) -> FuncX
326 return _activex
.ActiveXWindow_GetAXMethodDesc(*args
)
328 def GetAXEvents(*args
, **kwargs
):
330 GetAXEvents(self) -> FuncXArray
332 Returns a sequence of FuncX objects describing the events
333 available for this ActiveX object.
335 return _activex
.ActiveXWindow_GetAXEvents(*args
, **kwargs
)
337 def GetAXMethods(*args
, **kwargs
):
339 GetAXMethods(self) -> FuncXArray
341 Returns a sequence of FuncX objects describing the methods
342 available for this ActiveX object.
344 return _activex
.ActiveXWindow_GetAXMethods(*args
, **kwargs
)
346 def GetAXProperties(*args
, **kwargs
):
348 GetAXProperties(self) -> PropXArray
350 Returns a sequence of PropX objects describing the properties
351 available for this ActiveX object.
353 return _activex
.ActiveXWindow_GetAXProperties(*args
, **kwargs
)
355 def SetAXProp(*args
, **kwargs
):
357 SetAXProp(self, String name, PyObject value)
359 Set a property of the ActiveX object by name.
361 return _activex
.ActiveXWindow_SetAXProp(*args
, **kwargs
)
363 def GetAXProp(*args
, **kwargs
):
365 GetAXProp(self, String name) -> PyObject
367 Get the value of an ActiveX property by name.
369 return _activex
.ActiveXWindow_GetAXProp(*args
, **kwargs
)
371 def _CallAXMethod(*args
):
373 _CallAXMethod(self, String name, PyObject args) -> PyObject
375 The implementation for CallMethod. Calls an ActiveX method, by
376 name passing the parameters given in args.
378 return _activex
.ActiveXWindow__CallAXMethod(*args
)
380 def CallAXMethod(self
, name
, *args
):
382 Front-end for _CallMethod. Simply passes all positional args
383 after the name as a single tuple to _CallMethod.
385 return self
._CallAXMethod
(name
, args
)
388 class ActiveXWindowPtr(ActiveXWindow
):
389 def __init__(self
, this
):
391 if not hasattr(self
,"thisown"): self
.thisown
= 0
392 self
.__class
__ = ActiveXWindow
393 _activex
.ActiveXWindow_swigregister(ActiveXWindowPtr
)
395 #---------------------------------------------------------------------------
398 def RegisterActiveXEvent(*args
, **kwargs
):
400 RegisterActiveXEvent(String eventName) -> wxEventType
402 Creates a standard wx event ID for the given eventName.
404 return _activex
.RegisterActiveXEvent(*args
, **kwargs
)
405 class ActiveXEvent(_core
.CommandEvent
):
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
411 return (surprisingly <wink>) the name of the ActiveX event.
413 def __init__(self
): raise RuntimeError, "No constructor defined"
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
)
418 def _preCallInit(*args
, **kwargs
):
419 """_preCallInit(self, PyObject pyself)"""
420 return _activex
.ActiveXEvent__preCallInit(*args
, **kwargs
)
422 def _postCallCleanup(*args
, **kwargs
):
423 """_postCallCleanup(self, PyObject pyself)"""
424 return _activex
.ActiveXEvent__postCallCleanup(*args
, **kwargs
)
427 class ActiveXEventPtr(ActiveXEvent
):
428 def __init__(self
, this
):
430 if not hasattr(self
,"thisown"): self
.thisown
= 0
431 self
.__class
__ = ActiveXEvent
432 _activex
.ActiveXEvent_swigregister(ActiveXEventPtr
)
434 #---------------------------------------------------------------------------
436 class IEHtmlWindowBase(ActiveXWindow
):
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
444 self
._setOORInfo
(self
)
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
)
452 class IEHtmlWindowBasePtr(IEHtmlWindowBase
):
453 def __init__(self
, this
):
455 if not hasattr(self
,"thisown"): self
.thisown
= 0
456 self
.__class
__ = IEHtmlWindowBase
457 _activex
.IEHtmlWindowBase_swigregister(IEHtmlWindowBasePtr
)
459 #---------------------------------------------------------------------------
460 # Some helper and utility functions for ActiveX
468 Returns a printable summary of the TypeInfo from the ActiveX instance
472 def ProcessFuncX(f
, out
, name
):
474 out
.append(t4
+ "retType: %s" % f
.retType
.vt_type
)
476 out
.append(t4
+ "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
))
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
))
489 out
.append("PROPERTIES")
491 for p
in ax
.GetAXProperties():
495 out
.append("METHODS")
497 for m
in ax
.GetAXMethods():
498 ProcessFuncX(m
, out
, GernerateAXModule
.trimMethodName(m
.name
))
503 for e
in ax
.GetAXEvents():
504 ProcessFuncX(e
, out
, GernerateAXModule
.trimEventName(e
.name
))
507 return "\n".join(out
)
511 class GernerateAXModule
:
512 def __init__(self
, ax
, className
, modulePath
, moduleName
=None, verbose
=False):
514 Make a Python module file with a class that has been specialized
515 for the AcitveX object.
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.
524 if moduleName
is None:
525 moduleName
= className
+ '.py'
526 filename
= os
.path
.join(modulePath
, moduleName
)
528 print "Creating module in:", filename
529 print " ProgID: ", ax
.GetCLSID().GetProgIDString()
530 print " CLSID: ", ax
.GetCLSID().GetCLSIDString()
532 self
.mf
= file(filename
, "w")
533 self
.WriteFileHeader(ax
)
535 self
.WriteClassHeader(ax
, className
)
536 self
.WriteMethods(ax
)
537 self
.WriteProperties(ax
)
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()))
553 def WriteEvents(self
, ax
):
554 events
= ax
.GetAXEvents()
556 self
.write("# Create eventTypes and event binders")
558 self
.write("wxEVT_%s = wx.activex.RegisterActiveXEvent('%s')"
559 % (self
.trimEventName(e
.name
), e
.name
))
562 n
= self
.trimEventName(e
.name
)
563 self
.write("EVT_%s = wx.PyEventBinder(wxEVT_%s, 1)" % (n
,n
))
567 def WriteClassHeader(self
, ax
, className
):
568 self
.write("# Derive a new class from ActiveXWindow")
570 class %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()) )
579 def WriteMethods(self
, ax
):
580 methods
= ax
.GetAXMethods()
582 self
.write(t4
, "# Methods exported by the ActiveX object")
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)))
590 def WriteProperties(self
, ax
):
591 props
= ax
.GetAXProperties()
593 self
.write(t4
, "# Getters, Setters and properties")
595 getterName
= setterName
= "None"
597 getterName
= "_get_" + p
.name
598 self
.write(t4
, "def %s(self):" % getterName
)
599 self
.write(t8
, "return self.GetAXProp('%s')" % p
.name
)
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
))
605 self
.write(t4
, "%s = property(%s, %s)" %
606 (self
.trimPropName(p
.name
), getterName
, setterName
))
610 def WriteDocs(self
, ax
):
613 for line
in doc
.split('\n'):
614 self
.write("# ", line
)
618 def write(self
, *args
):
624 def trimEventName(name
):
625 if name
.startswith("On"):
628 trimEventName
= staticmethod(trimEventName
)
631 def trimPropName(name
):
632 #name = name[0].lower() + name[1:]
635 if name
in keyword
.kwlist
: name
+= '_'
637 trimPropName
= staticmethod(trimPropName
)
640 def trimMethodName(name
):
642 if name
in keyword
.kwlist
: name
+= '_'
644 trimMethodName
= staticmethod(trimMethodName
)
647 def getParameters(self
, m
, withDefaults
):
650 # collect the input parameters, if both isIn and isOut are
651 # False then assume it is an input paramater
654 if p
.isIn
or (not p
.isIn
and not p
.isOut
):
659 if name
in keyword
.kwlist
: name
+= '_'
662 if withDefaults
and p
.isOptional
:
667 #---------------------------------------------------------------------------