]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/activex/activex.py
   1 # This file was created automatically by SWIG. 
   2 # Don't modify this file, modify the SWIG interface instead. 
   8 __docfilter__ 
= wx
.__DocFilter
(globals())  
   9 #--------------------------------------------------------------------------- 
  13     This class wraps the Windows CLSID structure and is used to 
  14     specify the class of the ActiveX object that is to be created.  A 
  15     CLSID can be constructed from either a ProgID string, (such as 
  16     'WordPad.Document.1') or a classID string, (such as 
  17     '{CA8A9783-280D-11CF-A24D-444553540000}'). 
  20         return "<%s.%s; proxy of C++ CLSID instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
  21     def __init__(self
, *args
, **kwargs
): 
  23         __init__(self, String id) -> CLSID 
  25         This class wraps the Windows CLSID structure and is used to 
  26         specify the class of the ActiveX object that is to be created.  A 
  27         CLSID can be constructed from either a ProgID string, (such as 
  28         'WordPad.Document.1') or a classID string, (such as 
  29         '{CA8A9783-280D-11CF-A24D-444553540000}'). 
  31         newobj 
= _activex
.new_CLSID(*args
, **kwargs
) 
  32         self
.this 
= newobj
.this
 
  35     def __del__(self
, destroy
=_activex
.delete_CLSID
): 
  38             if self
.thisown
: destroy(self
) 
  41     def GetCLSIDString(*args
, **kwargs
): 
  42         """GetCLSIDString(self) -> String""" 
  43         return _activex
.CLSID_GetCLSIDString(*args
, **kwargs
) 
  45     def GetProgIDString(*args
, **kwargs
): 
  46         """GetProgIDString(self) -> String""" 
  47         return _activex
.CLSID_GetProgIDString(*args
, **kwargs
) 
  49     def __str__(self
):   return self
.GetCLSIDString()  
  51 class CLSIDPtr(CLSID
): 
  52     def __init__(self
, this
): 
  54         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
  55         self
.__class
__ = CLSID
 
  56 _activex
.CLSID_swigregister(CLSIDPtr
) 
  58 #--------------------------------------------------------------------------- 
  61     def __init__(self
): raise RuntimeError, "No constructor defined" 
  63         return "<%s.%s; proxy of C++ wxParamX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
  64     flags 
= property(_activex
.ParamX_flags_get
) 
  65     isPtr 
= property(_activex
.ParamX_isPtr_get
) 
  66     isSafeArray 
= property(_activex
.ParamX_isSafeArray_get
) 
  67     isOptional 
= property(_activex
.ParamX_isOptional_get
) 
  68     vt 
= property(_activex
.ParamX_vt_get
) 
  69     name 
= property(_activex
.ParamX_name_get
) 
  70     vt_type 
= property(_activex
.ParamX_vt_type_get
) 
  72     isIn 
= property(_activex
.ParamX_IsIn
) 
  74     isOut 
= property(_activex
.ParamX_IsOut
) 
  76     isRetVal 
= property(_activex
.ParamX_IsRetVal
) 
  79 class ParamXPtr(ParamX
): 
  80     def __init__(self
, this
): 
  82         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
  83         self
.__class
__ = ParamX
 
  84 _activex
.ParamX_swigregister(ParamXPtr
) 
  87     def __init__(self
): raise RuntimeError, "No constructor defined" 
  89         return "<%s.%s; proxy of C++ wxFuncX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
  90     name 
= property(_activex
.FuncX_name_get
) 
  91     memid 
= property(_activex
.FuncX_memid_get
) 
  92     hasOut 
= property(_activex
.FuncX_hasOut_get
) 
  93     retType 
= property(_activex
.FuncX_retType_get
) 
  94     params 
= property(_activex
.FuncX_params_get
) 
  96 class FuncXPtr(FuncX
): 
  97     def __init__(self
, this
): 
  99         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 100         self
.__class
__ = FuncX
 
 101 _activex
.FuncX_swigregister(FuncXPtr
) 
 104     def __init__(self
): raise RuntimeError, "No constructor defined" 
 106         return "<%s.%s; proxy of C++ wxPropX instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 107     name 
= property(_activex
.PropX_name_get
) 
 108     memid 
= property(_activex
.PropX_memid_get
) 
 109     type = property(_activex
.PropX_type_get
) 
 110     arg 
= property(_activex
.PropX_arg_get
) 
 111     putByRef 
= property(_activex
.PropX_putByRef_get
) 
 112     canGet 
= property(_activex
.PropX_CanGet
) 
 114     canSet 
= property(_activex
.PropX_CanSet
) 
 117 class PropXPtr(PropX
): 
 118     def __init__(self
, this
): 
 120         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 121         self
.__class
__ = PropX
 
 122 _activex
.PropX_swigregister(PropXPtr
) 
 124 class ParamXArray(object): 
 125     def __init__(self
): raise RuntimeError, "No constructor defined" 
 127         return "<%s.%s; proxy of C++ wxParamXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 128     def __nonzero__(*args
, **kwargs
): 
 129         """__nonzero__(self) -> bool""" 
 130         return _activex
.ParamXArray___nonzero__(*args
, **kwargs
) 
 132     def __len__(*args
, **kwargs
): 
 133         """__len__(self) -> int""" 
 134         return _activex
.ParamXArray___len__(*args
, **kwargs
) 
 136     def __getitem__(*args
, **kwargs
): 
 137         """__getitem__(self, int idx) -> ParamX""" 
 138         return _activex
.ParamXArray___getitem__(*args
, **kwargs
) 
 141 class ParamXArrayPtr(ParamXArray
): 
 142     def __init__(self
, this
): 
 144         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 145         self
.__class
__ = ParamXArray
 
 146 _activex
.ParamXArray_swigregister(ParamXArrayPtr
) 
 148 class FuncXArray(object): 
 149     def __init__(self
): raise RuntimeError, "No constructor defined" 
 151         return "<%s.%s; proxy of C++ wxFuncXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 152     def __nonzero__(*args
, **kwargs
): 
 153         """__nonzero__(self) -> bool""" 
 154         return _activex
.FuncXArray___nonzero__(*args
, **kwargs
) 
 156     def __len__(*args
, **kwargs
): 
 157         """__len__(self) -> int""" 
 158         return _activex
.FuncXArray___len__(*args
, **kwargs
) 
 160     def __getitem__(*args
, **kwargs
): 
 161         """__getitem__(self, int idx) -> FuncX""" 
 162         return _activex
.FuncXArray___getitem__(*args
, **kwargs
) 
 165 class FuncXArrayPtr(FuncXArray
): 
 166     def __init__(self
, this
): 
 168         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 169         self
.__class
__ = FuncXArray
 
 170 _activex
.FuncXArray_swigregister(FuncXArrayPtr
) 
 172 class PropXArray(object): 
 173     def __init__(self
): raise RuntimeError, "No constructor defined" 
 175         return "<%s.%s; proxy of C++ wxPropXArray instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 176     def __nonzero__(*args
, **kwargs
): 
 177         """__nonzero__(self) -> bool""" 
 178         return _activex
.PropXArray___nonzero__(*args
, **kwargs
) 
 180     def __len__(*args
, **kwargs
): 
 181         """__len__(self) -> int""" 
 182         return _activex
.PropXArray___len__(*args
, **kwargs
) 
 184     def __getitem__(*args
, **kwargs
): 
 185         """__getitem__(self, int idx) -> PropX""" 
 186         return _activex
.PropXArray___getitem__(*args
, **kwargs
) 
 189 class PropXArrayPtr(PropXArray
): 
 190     def __init__(self
, this
): 
 192         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 193         self
.__class
__ = PropXArray
 
 194 _activex
.PropXArray_swigregister(PropXArrayPtr
) 
 196 #--------------------------------------------------------------------------- 
 198 class ActiveXWindow(_core
.Window
): 
 200     ActiveXWindow derives from wxWindow and the constructor accepts a 
 201     CLSID for the ActiveX Control that should be created.  The 
 202     ActiveXWindow class simply adds methods that allow you to query 
 203     some of the TypeInfo exposed by the ActiveX object, and also to 
 204     get/set properties or call methods by name.  The Python 
 205     implementation automatically handles converting parameters and 
 206     return values to/from the types expected by the ActiveX code as 
 207     specified by the TypeInfo. 
 211         return "<%s.%s; proxy of C++ wxActiveXWindow instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 212     def __init__(self
, *args
, **kwargs
): 
 214         __init__(self, Window parent, CLSID clsId, int id=-1, Point pos=DefaultPosition,  
 215             Size size=DefaultSize, long style=0,  
 216             String name=PanelNameStr) -> ActiveXWindow 
 218         Creates an ActiveX control from the clsID given and makes it act 
 219         as much like a regular wx.Window as possible. 
 221         newobj 
= _activex
.new_ActiveXWindow(*args
, **kwargs
) 
 222         self
.this 
= newobj
.this
 
 225         self
._setOORInfo
(self
) 
 227     def GetCLSID(*args
, **kwargs
): 
 229         GetCLSID(self) -> CLSID 
 231         Return the CLSID used to construct this ActiveX window 
 233         return _activex
.ActiveXWindow_GetCLSID(*args
, **kwargs
) 
 235     def GetAXEventCount(*args
, **kwargs
): 
 237         GetAXEventCount(self) -> int 
 239         Number of events defined for this control 
 241         return _activex
.ActiveXWindow_GetAXEventCount(*args
, **kwargs
) 
 243     def GetAXEventDesc(*args
, **kwargs
): 
 245         GetAXEventDesc(self, int idx) -> FuncX 
 247         Returns event description by index 
 249         return _activex
.ActiveXWindow_GetAXEventDesc(*args
, **kwargs
) 
 251     def GetAXPropCount(*args
, **kwargs
): 
 253         GetAXPropCount(self) -> int 
 255         Number of properties defined for this control 
 257         return _activex
.ActiveXWindow_GetAXPropCount(*args
, **kwargs
) 
 259     def GetAXPropDesc(*args
): 
 261         GetAXPropDesc(self, int idx) -> PropX 
 262         GetAXPropDesc(self, String name) -> PropX 
 264         return _activex
.ActiveXWindow_GetAXPropDesc(*args
) 
 266     def GetAXMethodCount(*args
, **kwargs
): 
 268         GetAXMethodCount(self) -> int 
 270         Number of methods defined for this control 
 272         return _activex
.ActiveXWindow_GetAXMethodCount(*args
, **kwargs
) 
 274     def GetAXMethodDesc(*args
): 
 276         GetAXMethodDesc(self, int idx) -> FuncX 
 277         GetAXMethodDesc(self, String name) -> FuncX 
 279         return _activex
.ActiveXWindow_GetAXMethodDesc(*args
) 
 281     def GetAXEvents(*args
, **kwargs
): 
 283         GetAXEvents(self) -> FuncXArray 
 285         Returns a sequence of FuncX objects describing the events 
 286         available for this ActiveX object. 
 288         return _activex
.ActiveXWindow_GetAXEvents(*args
, **kwargs
) 
 290     def GetAXMethods(*args
, **kwargs
): 
 292         GetAXMethods(self) -> FuncXArray 
 294         Returns a sequence of FuncX objects describing the methods 
 295         available for this ActiveX object. 
 297         return _activex
.ActiveXWindow_GetAXMethods(*args
, **kwargs
) 
 299     def GetAXProperties(*args
, **kwargs
): 
 301         GetAXProperties(self) -> PropXArray 
 303         Returns a sequence of PropX objects describing the properties 
 304         available for this ActiveX object. 
 306         return _activex
.ActiveXWindow_GetAXProperties(*args
, **kwargs
) 
 308     def SetAXProp(*args
, **kwargs
): 
 310         SetAXProp(self, String name, PyObject value) 
 312         Set a property of the ActiveX object by name. 
 314         return _activex
.ActiveXWindow_SetAXProp(*args
, **kwargs
) 
 316     def GetAXProp(*args
, **kwargs
): 
 318         GetAXProp(self, String name) -> PyObject 
 320         Get the value of an ActiveX property by name. 
 322         return _activex
.ActiveXWindow_GetAXProp(*args
, **kwargs
) 
 324     def _CallAXMethod(*args
): 
 326         _CallAXMethod(self, String name, PyObject args) -> PyObject 
 328         The implementation for CallMethod.  Calls an ActiveX method, by 
 329         name passing the parameters given in args. 
 331         return _activex
.ActiveXWindow__CallAXMethod(*args
) 
 333     def CallAXMethod(self
, name
, *args
): 
 335         Front-end for _CallMethod.  Simply passes all positional args 
 336         after the name as a single tuple to _CallMethod. 
 338         return self
._CallAXMethod
(name
, args
) 
 341 class ActiveXWindowPtr(ActiveXWindow
): 
 342     def __init__(self
, this
): 
 344         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 345         self
.__class
__ = ActiveXWindow
 
 346 _activex
.ActiveXWindow_swigregister(ActiveXWindowPtr
) 
 348 #--------------------------------------------------------------------------- 
 351 def RegisterActiveXEvent(*args
, **kwargs
): 
 353     RegisterActiveXEvent(String eventName) -> wxEventType 
 355     Creates a standard wx event ID for the given eventName. 
 357     return _activex
.RegisterActiveXEvent(*args
, **kwargs
) 
 358 class ActiveXEvent(_core
.CommandEvent
): 
 360     An instance of ActiveXEvent is sent to the handler for all bound 
 361     ActiveX events.  Any event parameters from the ActiveX cntrol are 
 362     turned into attributes of the Python proxy for this event object. 
 363     Additionally, there is a property called eventName that will 
 364     return (surprisingly <wink>) the name of the ActiveX event. 
 366     def __init__(self
): raise RuntimeError, "No constructor defined" 
 368         return "<%s.%s; proxy of C++ wxActiveXEvent instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 369     eventName 
= property(_activex
.ActiveXEvent_EventName
) 
 371     def _preCallInit(*args
, **kwargs
): 
 372         """_preCallInit(self, PyObject pyself)""" 
 373         return _activex
.ActiveXEvent__preCallInit(*args
, **kwargs
) 
 375     def _postCallCleanup(*args
, **kwargs
): 
 376         """_postCallCleanup(self, PyObject pyself)""" 
 377         return _activex
.ActiveXEvent__postCallCleanup(*args
, **kwargs
) 
 380 class ActiveXEventPtr(ActiveXEvent
): 
 381     def __init__(self
, this
): 
 383         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 384         self
.__class
__ = ActiveXEvent
 
 385 _activex
.ActiveXEvent_swigregister(ActiveXEventPtr
) 
 387 #--------------------------------------------------------------------------- 
 389 class IEHtmlWindowBase(ActiveXWindow
): 
 391         return "<%s.%s; proxy of C++ wxIEHtmlWindowBase instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 392     def __init__(self
, *args
, **kwargs
): 
 393         newobj 
= _activex
.new_IEHtmlWindowBase(*args
, **kwargs
) 
 394         self
.this 
= newobj
.this
 
 397     def SetCharset(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_SetCharset(*args
, **kwargs
) 
 398     def LoadString(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadString(*args
, **kwargs
) 
 399     def LoadStream(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadStream(*args
, **kwargs
) 
 400     def GetStringSelection(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetStringSelection(*args
, **kwargs
) 
 401     def GetText(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetText(*args
, **kwargs
) 
 403 class IEHtmlWindowBasePtr(IEHtmlWindowBase
): 
 404     def __init__(self
, this
): 
 406         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 407         self
.__class
__ = IEHtmlWindowBase
 
 408 _activex
.IEHtmlWindowBase_swigregister(IEHtmlWindowBasePtr
) 
 410 #--------------------------------------------------------------------------- 
 411 # Some helper and utility functions for ActiveX 
 419     Returns a printable summary of the TypeInfo from the ActiveX instance 
 423     def ProcessFuncX(f
, out
, name
): 
 425         out
.append(t4 
+ "retType:  %s" % f
.retType
.vt_type
) 
 427             out
.append(t4 
+ "params:") 
 429                 out
.append(t8 
+ p
.name
) 
 430                 out
.append(t8
+t4
+ "in:%s  out:%s  optional:%s  type:%s" % (p
.isIn
, p
.isOut
, p
.isOptional
, p
.vt_type
)) 
 433     def ProcessPropX(p
, out
): 
 434         out
.append(GernerateAXModule
.trimPropName(p
.name
)) 
 435         out
.append(t4
+ "type:%s  arg:%s  canGet:%s  canSet:%s" % (p
.type.vt_type
, p
.arg
.vt_type
, p
.canGet
, p
.canSet
)) 
 440     out
.append("PROPERTIES") 
 442     for p 
in ax
.GetAXProperties(): 
 446     out
.append("METHODS") 
 448     for m 
in ax
.GetAXMethods(): 
 449         ProcessFuncX(m
, out
, GernerateAXModule
.trimMethodName(m
.name
)) 
 454     for e 
in ax
.GetAXEvents(): 
 455         ProcessFuncX(e
, out
, GernerateAXModule
.trimEventName(e
.name
)) 
 458     return "\n".join(out
) 
 462 class GernerateAXModule
: 
 463     def __init__(self
, ax
, className
, modulePath
, moduleName
=None, verbose
=False): 
 465         Make a Python module file with a class that has been specialized 
 466         for the AcitveX object. 
 468             ax           An instance of the ActiveXWindow class 
 469             className    The name to use for the new class 
 470             modulePath   The path where the new module should be written to 
 471             moduleName   The name of the .py file to create.  If not given 
 472                          then the className will be used. 
 475         if moduleName 
is None: 
 476             moduleName 
= className 
+ '.py' 
 477         filename 
= os
.path
.join(modulePath
, moduleName
) 
 479             print "Creating module in:", filename
 
 480             print "  ProgID:  ", ax
.GetCLSID().GetProgIDString() 
 481             print "  CLSID:   ", ax
.GetCLSID().GetCLSIDString() 
 483         self
.mf 
= file(filename
, "w") 
 484         self
.WriteFileHeader(ax
) 
 486         self
.WriteClassHeader(ax
, className
) 
 487         self
.WriteMethods(ax
) 
 488         self
.WriteProperties(ax
) 
 494     def WriteFileHeader(self
, ax
): 
 495         self
.write("# This module was generated by the wx.activex.GernerateAXModule class\n" 
 496                    "# (See also the genaxmodule script.)\n") 
 497         self
.write("import wx") 
 498         self
.write("import wx.activex\n") 
 499         self
.write("clsID = '%s'\nprogID = '%s'\n" 
 500                    % (ax
.GetCLSID().GetCLSIDString(), ax
.GetCLSID().GetProgIDString())) 
 504     def WriteEvents(self
, ax
): 
 505         events 
= ax
.GetAXEvents() 
 507             self
.write("# Create eventTypes and event binders") 
 509                 self
.write("wxEVT_%s = wx.activex.RegisterActiveXEvent('%s')" 
 510                            % (self
.trimEventName(e
.name
), e
.name
)) 
 513                 n 
= self
.trimEventName(e
.name
) 
 514                 self
.write("EVT_%s = wx.PyEventBinder(wxEVT_%s, 1)" % (n
,n
)) 
 518     def WriteClassHeader(self
, ax
, className
): 
 519         self
.write("# Derive a new class from ActiveXWindow") 
 521 class %s(wx.activex.ActiveXWindow): 
 522     def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, 
 523                  size=wx.DefaultSize, style=0, name='%s'): 
 524         wx.activex.ActiveXWindow.__init__(self, parent, 
 525             wx.activex.CLSID('%s'), 
 526             ID, pos, size, style, name) 
 527         """ % (className
, className
, ax
.GetCLSID().GetCLSIDString()) ) 
 530     def WriteMethods(self
, ax
): 
 531         methods 
= ax
.GetAXMethods() 
 533             self
.write(t4
, "# Methods exported by the ActiveX object") 
 535                 name 
= self
.trimMethodName(m
.name
) 
 536                 self
.write(t4
, "def %s(self%s):" % (name
, self
.getParameters(m
, True))) 
 537                 self
.write(t8
, "return self.CallAXMethod('%s'%s)" % (m
.name
, self
.getParameters(m
, False))) 
 541     def WriteProperties(self
, ax
): 
 542         props 
= ax
.GetAXProperties() 
 544             self
.write(t4
, "# Getters, Setters and properties") 
 546                 getterName 
= setterName 
= "None" 
 548                     getterName 
= "_get_" + p
.name
 
 549                     self
.write(t4
, "def %s(self):" % getterName
) 
 550                     self
.write(t8
, "return self.GetAXProp('%s')" % p
.name
) 
 552                     setterName 
= "_set_" + p
.name
 
 553                     self
.write(t4
, "def %s(self, %s):" % (setterName
, p
.arg
.name
)) 
 554                     self
.write(t8
, "self.SetAXProp('%s', %s)" % (p
.name
, p
.arg
.name
)) 
 556                 self
.write(t4
, "%s = property(%s, %s)" % 
 557                            (self
.trimPropName(p
.name
), getterName
, setterName
)) 
 561     def WriteDocs(self
, ax
): 
 564         for line 
in doc
.split('\n'): 
 565             self
.write("#  ", line
) 
 569     def write(self
, *args
): 
 575     def trimEventName(name
): 
 576         if name
.startswith("On"): 
 579     trimEventName 
= staticmethod(trimEventName
) 
 582     def trimPropName(name
): 
 583         #name = name[0].lower() + name[1:] 
 586         if name 
in keyword
.kwlist
: name 
+= '_' 
 588     trimPropName 
= staticmethod(trimPropName
) 
 591     def trimMethodName(name
): 
 593         if name 
in keyword
.kwlist
: name 
+= '_' 
 595     trimMethodName 
= staticmethod(trimMethodName
) 
 598     def getParameters(self
, m
, withDefaults
): 
 601         # collect the input parameters, if both isIn and isOut are 
 602         # False then assume it is an input paramater 
 605             if p
.isIn 
or (not p
.isIn 
and not p
.isOut
): 
 610             if name 
in keyword
.kwlist
: name 
+= '_' 
 613             if withDefaults 
and p
.isOptional
: 
 618 #---------------------------------------------------------------------------