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