]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/activex/activex.py
e834d9e643906d7ab146ca2ab78820d68df53c6d
1 # This file was created automatically by SWIG.
2 # Don't modify this file, modify the SWIG interface instead.
8 #---------------------------------------------------------------------------
12 This class wraps the Windows CLSID structure and is used to
13 specify the class of the ActiveX object that is to be created. A
14 CLSID can be constructed from either a ProgID string, (such as
15 'WordPad.Document.1') or a classID string, (such as
16 '{CA8A9783-280D-11CF-A24D-444553540000}').
19 return "<%s.%s; proxy of C++ CLSID instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
20 def __init__(self
, *args
, **kwargs
):
22 __init__(String id) -> CLSID
24 This class wraps the Windows CLSID structure and is used to
25 specify the class of the ActiveX object that is to be created. A
26 CLSID can be constructed from either a ProgID string, (such as
27 'WordPad.Document.1') or a classID string, (such as
28 '{CA8A9783-280D-11CF-A24D-444553540000}').
30 newobj
= _activex
.new_CLSID(*args
, **kwargs
)
31 self
.this
= newobj
.this
34 def __del__(self
, destroy
=_activex
.delete_CLSID
):
37 if self
.thisown
: destroy(self
)
40 def GetCLSIDString(*args
, **kwargs
):
41 """GetCLSIDString() -> String"""
42 return _activex
.CLSID_GetCLSIDString(*args
, **kwargs
)
44 def GetProgIDString(*args
, **kwargs
):
45 """GetProgIDString() -> String"""
46 return _activex
.CLSID_GetProgIDString(*args
, **kwargs
)
48 def __str__(self
): return self
.GetCLSIDString()
50 class CLSIDPtr(CLSID
):
51 def __init__(self
, this
):
53 if not hasattr(self
,"thisown"): self
.thisown
= 0
54 self
.__class
__ = CLSID
55 _activex
.CLSID_swigregister(CLSIDPtr
)
57 #---------------------------------------------------------------------------
60 def __init__(self
): raise RuntimeError, "No constructor defined"
62 return "<%s.%s; proxy of C++ wxParamX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
63 flags
= property(_activex
.ParamX_flags_get
)
64 isPtr
= property(_activex
.ParamX_isPtr_get
)
65 isSafeArray
= property(_activex
.ParamX_isSafeArray_get
)
66 isOptional
= property(_activex
.ParamX_isOptional_get
)
67 vt
= property(_activex
.ParamX_vt_get
)
68 name
= property(_activex
.ParamX_name_get
)
69 vt_type
= property(_activex
.ParamX_vt_type_get
)
71 isIn
= property(_activex
.ParamX_IsIn
)
73 isOut
= property(_activex
.ParamX_IsOut
)
75 isRetVal
= property(_activex
.ParamX_IsRetVal
)
78 class ParamXPtr(ParamX
):
79 def __init__(self
, this
):
81 if not hasattr(self
,"thisown"): self
.thisown
= 0
82 self
.__class
__ = ParamX
83 _activex
.ParamX_swigregister(ParamXPtr
)
86 def __init__(self
): raise RuntimeError, "No constructor defined"
88 return "<%s.%s; proxy of C++ wxFuncX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
89 name
= property(_activex
.FuncX_name_get
)
90 memid
= property(_activex
.FuncX_memid_get
)
91 hasOut
= property(_activex
.FuncX_hasOut_get
)
92 retType
= property(_activex
.FuncX_retType_get
)
93 params
= property(_activex
.FuncX_params_get
)
95 class FuncXPtr(FuncX
):
96 def __init__(self
, this
):
98 if not hasattr(self
,"thisown"): self
.thisown
= 0
99 self
.__class
__ = FuncX
100 _activex
.FuncX_swigregister(FuncXPtr
)
103 def __init__(self
): raise RuntimeError, "No constructor defined"
105 return "<%s.%s; proxy of C++ wxPropX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
106 name
= property(_activex
.PropX_name_get
)
107 memid
= property(_activex
.PropX_memid_get
)
108 type = property(_activex
.PropX_type_get
)
109 arg
= property(_activex
.PropX_arg_get
)
110 putByRef
= property(_activex
.PropX_putByRef_get
)
111 canGet
= property(_activex
.PropX_CanGet
)
113 canSet
= property(_activex
.PropX_CanSet
)
116 class PropXPtr(PropX
):
117 def __init__(self
, this
):
119 if not hasattr(self
,"thisown"): self
.thisown
= 0
120 self
.__class
__ = PropX
121 _activex
.PropX_swigregister(PropXPtr
)
123 class ParamXArray(object):
124 def __init__(self
): raise RuntimeError, "No constructor defined"
126 return "<%s.%s; proxy of C++ wxParamXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
127 def __nonzero__(*args
, **kwargs
):
128 """__nonzero__() -> bool"""
129 return _activex
.ParamXArray___nonzero__(*args
, **kwargs
)
131 def __len__(*args
, **kwargs
):
132 """__len__() -> int"""
133 return _activex
.ParamXArray___len__(*args
, **kwargs
)
135 def __getitem__(*args
, **kwargs
):
136 """__getitem__(int idx) -> ParamX"""
137 return _activex
.ParamXArray___getitem__(*args
, **kwargs
)
140 class ParamXArrayPtr(ParamXArray
):
141 def __init__(self
, this
):
143 if not hasattr(self
,"thisown"): self
.thisown
= 0
144 self
.__class
__ = ParamXArray
145 _activex
.ParamXArray_swigregister(ParamXArrayPtr
)
147 class FuncXArray(object):
148 def __init__(self
): raise RuntimeError, "No constructor defined"
150 return "<%s.%s; proxy of C++ wxFuncXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
151 def __nonzero__(*args
, **kwargs
):
152 """__nonzero__() -> bool"""
153 return _activex
.FuncXArray___nonzero__(*args
, **kwargs
)
155 def __len__(*args
, **kwargs
):
156 """__len__() -> int"""
157 return _activex
.FuncXArray___len__(*args
, **kwargs
)
159 def __getitem__(*args
, **kwargs
):
160 """__getitem__(int idx) -> FuncX"""
161 return _activex
.FuncXArray___getitem__(*args
, **kwargs
)
164 class FuncXArrayPtr(FuncXArray
):
165 def __init__(self
, this
):
167 if not hasattr(self
,"thisown"): self
.thisown
= 0
168 self
.__class
__ = FuncXArray
169 _activex
.FuncXArray_swigregister(FuncXArrayPtr
)
171 class PropXArray(object):
172 def __init__(self
): raise RuntimeError, "No constructor defined"
174 return "<%s.%s; proxy of C++ wxPropXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
175 def __nonzero__(*args
, **kwargs
):
176 """__nonzero__() -> bool"""
177 return _activex
.PropXArray___nonzero__(*args
, **kwargs
)
179 def __len__(*args
, **kwargs
):
180 """__len__() -> int"""
181 return _activex
.PropXArray___len__(*args
, **kwargs
)
183 def __getitem__(*args
, **kwargs
):
184 """__getitem__(int idx) -> PropX"""
185 return _activex
.PropXArray___getitem__(*args
, **kwargs
)
188 class PropXArrayPtr(PropXArray
):
189 def __init__(self
, this
):
191 if not hasattr(self
,"thisown"): self
.thisown
= 0
192 self
.__class
__ = PropXArray
193 _activex
.PropXArray_swigregister(PropXArrayPtr
)
195 #---------------------------------------------------------------------------
197 class ActiveXWindow(core
.Window
):
199 ActiveXWindow derives from wxWindow and the constructor accepts a
200 CLSID for the ActiveX Control that should be created. The
201 ActiveXWindow class simply adds methods that allow you to query
202 some of the TypeInfo exposed by the ActiveX object, and also to
203 get/set properties or call methods by name. The Python
204 implementation automatically handles converting parameters and
205 return values to/from the types expected by the ActiveX code as
206 specified by the TypeInfo.
210 return "<%s.%s; proxy of C++ wxActiveXWindow instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
211 def __init__(self
, *args
, **kwargs
):
213 __init__(Window parent, CLSID clsId, int id=-1, Point pos=DefaultPosition,
214 Size size=DefaultSize, long style=0,
215 String name=PanelNameStr) -> ActiveXWindow
217 Creates an ActiveX control from the clsID given and makes it act
218 as much like a regular wx.Window as possible.
220 newobj
= _activex
.new_ActiveXWindow(*args
, **kwargs
)
221 self
.this
= newobj
.this
224 self
._setOORInfo
(self
)
226 def GetCLSID(*args
, **kwargs
):
230 Return the CLSID used to construct this ActiveX window
232 return _activex
.ActiveXWindow_GetCLSID(*args
, **kwargs
)
234 def GetAXEventCount(*args
, **kwargs
):
236 GetAXEventCount() -> int
238 Number of events defined for this control
240 return _activex
.ActiveXWindow_GetAXEventCount(*args
, **kwargs
)
242 def GetAXEventDesc(*args
, **kwargs
):
244 GetAXEventDesc(int idx) -> FuncX
246 Returns event description by index
248 return _activex
.ActiveXWindow_GetAXEventDesc(*args
, **kwargs
)
250 def GetAXPropCount(*args
, **kwargs
):
252 GetAXPropCount() -> int
254 Number of properties defined for this control
256 return _activex
.ActiveXWindow_GetAXPropCount(*args
, **kwargs
)
258 def GetAXPropDesc(*args
):
260 GetAXPropDesc(int idx) -> PropX
261 GetAXPropDesc(String name) -> PropX
263 return _activex
.ActiveXWindow_GetAXPropDesc(*args
)
265 def GetAXMethodCount(*args
, **kwargs
):
267 GetAXMethodCount() -> int
269 Number of methods defined for this control
271 return _activex
.ActiveXWindow_GetAXMethodCount(*args
, **kwargs
)
273 def GetAXMethodDesc(*args
):
275 GetAXMethodDesc(int idx) -> FuncX
276 GetAXMethodDesc(String name) -> FuncX
278 return _activex
.ActiveXWindow_GetAXMethodDesc(*args
)
280 def GetAXEvents(*args
, **kwargs
):
282 GetAXEvents() -> FuncXArray
284 Returns a sequence of FuncX objects describing the events
285 available for this ActiveX object.
287 return _activex
.ActiveXWindow_GetAXEvents(*args
, **kwargs
)
289 def GetAXMethods(*args
, **kwargs
):
291 GetAXMethods() -> FuncXArray
293 Returns a sequence of FuncX objects describing the methods
294 available for this ActiveX object.
296 return _activex
.ActiveXWindow_GetAXMethods(*args
, **kwargs
)
298 def GetAXProperties(*args
, **kwargs
):
300 GetAXProperties() -> PropXArray
302 Returns a sequence of PropX objects describing the properties
303 available for this ActiveX object.
305 return _activex
.ActiveXWindow_GetAXProperties(*args
, **kwargs
)
307 def SetAXProp(*args
, **kwargs
):
309 SetAXProp(String name, PyObject value)
311 Set a property of the ActiveX object by name.
313 return _activex
.ActiveXWindow_SetAXProp(*args
, **kwargs
)
315 def GetAXProp(*args
, **kwargs
):
317 GetAXProp(String name) -> PyObject
319 Get the value of an ActiveX property by name.
321 return _activex
.ActiveXWindow_GetAXProp(*args
, **kwargs
)
323 def _CallAXMethod(*args
):
325 _CallAXMethod(String name, PyObject args) -> PyObject
327 The implementation for CallMethod. Calls an ActiveX method, by
328 name passing the parameters given in args.
330 return _activex
.ActiveXWindow__CallAXMethod(*args
)
332 def CallAXMethod(self
, name
, *args
):
334 Front-end for _CallMethod. Simply passes all positional args
335 after the name as a single tuple to _CallMethod.
337 return self
._CallAXMethod
(name
, args
)
340 class ActiveXWindowPtr(ActiveXWindow
):
341 def __init__(self
, this
):
343 if not hasattr(self
,"thisown"): self
.thisown
= 0
344 self
.__class
__ = ActiveXWindow
345 _activex
.ActiveXWindow_swigregister(ActiveXWindowPtr
)
347 #---------------------------------------------------------------------------
350 def RegisterActiveXEvent(*args
, **kwargs
):
352 RegisterActiveXEvent(String eventName) -> wxEventType
354 Creates a standard wx event ID for the given eventName.
356 return _activex
.RegisterActiveXEvent(*args
, **kwargs
)
357 class ActiveXEvent(core
.CommandEvent
):
359 An instance of ActiveXEvent is sent to the handler for all bound
360 ActiveX events. Any event parameters from the ActiveX cntrol are
361 turned into attributes of the Python proxy for this event object.
362 Additionally, there is a property called eventName that will
363 return (suprizingly <wink>) the name of the ActiveX event.
365 def __init__(self
): raise RuntimeError, "No constructor defined"
367 return "<%s.%s; proxy of C++ wxActiveXEvent instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
368 eventName
= property(_activex
.ActiveXEvent_EventName
)
370 def _preInit(*args
, **kwargs
):
372 _preInit(PyObject pyself)
374 This is called by the EventThunker before calling the handler.
375 We'll convert and load the ActiveX event parameters into
376 attributes of the Python event object.
378 return _activex
.ActiveXEvent__preInit(*args
, **kwargs
)
381 class ActiveXEventPtr(ActiveXEvent
):
382 def __init__(self
, this
):
384 if not hasattr(self
,"thisown"): self
.thisown
= 0
385 self
.__class
__ = ActiveXEvent
386 _activex
.ActiveXEvent_swigregister(ActiveXEventPtr
)
388 #---------------------------------------------------------------------------
390 class IEHtmlWindowBase(ActiveXWindow
):
392 return "<%s.%s; proxy of C++ wxIEHtmlWindowBase instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
393 def __init__(self
, *args
, **kwargs
):
394 newobj
= _activex
.new_IEHtmlWindowBase(*args
, **kwargs
)
395 self
.this
= newobj
.this
398 def SetCharset(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_SetCharset(*args
, **kwargs
)
399 def LoadString(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadString(*args
, **kwargs
)
400 def LoadStream(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadStream(*args
, **kwargs
)
401 def GetStringSelection(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetStringSelection(*args
, **kwargs
)
402 def GetText(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetText(*args
, **kwargs
)
404 class IEHtmlWindowBasePtr(IEHtmlWindowBase
):
405 def __init__(self
, this
):
407 if not hasattr(self
,"thisown"): self
.thisown
= 0
408 self
.__class
__ = IEHtmlWindowBase
409 _activex
.IEHtmlWindowBase_swigregister(IEHtmlWindowBasePtr
)
411 #---------------------------------------------------------------------------
412 # Some helper and utility functions for ActiveX
420 Returns a printable summary of the TypeInfo from the ActiveX instance
424 def ProcessFuncX(f
, out
, name
):
426 out
.append(t4
+ "retType: %s" % f
.retType
.vt_type
)
428 out
.append(t4
+ "params:")
430 out
.append(t8
+ p
.name
)
431 out
.append(t8
+t4
+ "in:%s out:%s optional:%s type:%s" % (p
.isIn
, p
.isOut
, p
.isOptional
, p
.vt_type
))
434 def ProcessPropX(p
, out
):
435 out
.append(GernerateAXModule
.trimPropName(p
.name
))
436 out
.append(t4
+ "type:%s arg:%s canGet:%s canSet:%s" % (p
.type.vt_type
, p
.arg
.vt_type
, p
.canGet
, p
.canSet
))
441 out
.append("PROPERTIES")
443 for p
in ax
.GetAXProperties():
447 out
.append("METHODS")
449 for m
in ax
.GetAXMethods():
450 ProcessFuncX(m
, out
, GernerateAXModule
.trimMethodName(m
.name
))
455 for e
in ax
.GetAXEvents():
456 ProcessFuncX(e
, out
, GernerateAXModule
.trimEventName(e
.name
))
459 return "\n".join(out
)
463 class GernerateAXModule
:
464 def __init__(self
, ax
, className
, modulePath
, moduleName
=None, verbose
=False):
466 Make a Python module file with a class that has been specialized
467 for the AcitveX object.
469 ax An instance of the ActiveXWindow class
470 className The name to use for the new class
471 modulePath The path where the new module should be written to
472 moduleName The name of the .py file to create. If not given
473 then the className will be used.
476 if moduleName
is None:
477 moduleName
= className
+ '.py'
478 filename
= os
.path
.join(modulePath
, moduleName
)
480 print "Creating module in:", filename
481 print " ProgID: ", ax
.GetCLSID().GetProgIDString()
482 print " CLSID: ", ax
.GetCLSID().GetCLSIDString()
484 self
.mf
= file(filename
, "w")
485 self
.WriteFileHeader(ax
)
487 self
.WriteClassHeader(ax
, className
)
488 self
.WriteMethods(ax
)
489 self
.WriteProperties(ax
)
495 def WriteFileHeader(self
, ax
):
496 self
.write("# This module was generated by the wx.activex.GernerateAXModule class\n"
497 "# (See also the genaxmodule script.)\n")
498 self
.write("import wx")
499 self
.write("import wx.activex\n")
500 self
.write("clsID = '%s'\nprogID = '%s'\n"
501 % (ax
.GetCLSID().GetCLSIDString(), ax
.GetCLSID().GetProgIDString()))
505 def WriteEvents(self
, ax
):
506 events
= ax
.GetAXEvents()
508 self
.write("# Create eventTypes and event binders")
510 self
.write("wxEVT_%s = wx.activex.RegisterActiveXEvent('%s')"
511 % (self
.trimEventName(e
.name
), e
.name
))
514 n
= self
.trimEventName(e
.name
)
515 self
.write("EVT_%s = wx.PyEventBinder(wxEVT_%s, 1)" % (n
,n
))
519 def WriteClassHeader(self
, ax
, className
):
520 self
.write("# Derive a new class from ActiveXWindow")
522 class %s(wx.activex.ActiveXWindow):
523 def __init__(self, parent, ID=-1, pos=wx.DefaultPosition,
524 size=wx.DefaultSize, style=0, name='%s'):
525 wx.activex.ActiveXWindow.__init__(self, parent,
526 wx.activex.CLSID('%s'),
527 ID, pos, size, style, name)
528 """ % (className
, className
, ax
.GetCLSID().GetCLSIDString()) )
531 def WriteMethods(self
, ax
):
532 methods
= ax
.GetAXMethods()
534 self
.write(t4
, "# Methods exported by the ActiveX object")
536 name
= self
.trimMethodName(m
.name
)
537 self
.write(t4
, "def %s(self%s):" % (name
, self
.getParameters(m
, True)))
538 self
.write(t8
, "return self.CallAXMethod('%s'%s)" % (m
.name
, self
.getParameters(m
, False)))
542 def WriteProperties(self
, ax
):
543 props
= ax
.GetAXProperties()
545 self
.write(t4
, "# Getters, Setters and properties")
547 getterName
= setterName
= "None"
549 getterName
= "_get_" + p
.name
550 self
.write(t4
, "def %s(self):" % getterName
)
551 self
.write(t8
, "return self.GetAXProp('%s')" % p
.name
)
553 setterName
= "_set_" + p
.name
554 self
.write(t4
, "def %s(self, %s):" % (setterName
, p
.arg
.name
))
555 self
.write(t8
, "self.SetAXProp('%s', %s)" % (p
.name
, p
.arg
.name
))
557 self
.write(t4
, "%s = property(%s, %s)" %
558 (self
.trimPropName(p
.name
), getterName
, setterName
))
562 def WriteDocs(self
, ax
):
565 for line
in doc
.split('\n'):
566 self
.write("# ", line
)
570 def write(self
, *args
):
576 def trimEventName(name
):
577 if name
.startswith("On"):
580 trimEventName
= staticmethod(trimEventName
)
583 def trimPropName(name
):
584 #name = name[0].lower() + name[1:]
587 if name
in keyword
.kwlist
: name
+= '_'
589 trimPropName
= staticmethod(trimPropName
)
592 def trimMethodName(name
):
594 if name
in keyword
.kwlist
: name
+= '_'
596 trimMethodName
= staticmethod(trimMethodName
)
599 def getParameters(self
, m
, withDefaults
):
602 # collect the input parameters, if both isIn and isOut are
603 # False then assume it is an input paramater
606 if p
.isIn
or (not p
.isIn
and not p
.isOut
):
611 if name
in keyword
.kwlist
: name
+= '_'
614 if withDefaults
and p
.isOptional
:
619 #---------------------------------------------------------------------------