]>
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 #--------------------------------------------------------------------------- 
  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 _preCallInit(*args
, **kwargs
): 
 371         """_preCallInit(PyObject pyself)""" 
 372         return _activex
.ActiveXEvent__preCallInit(*args
, **kwargs
) 
 374     def _postCallCleanup(*args
, **kwargs
): 
 375         """_postCallCleanup(PyObject pyself)""" 
 376         return _activex
.ActiveXEvent__postCallCleanup(*args
, **kwargs
) 
 379 class ActiveXEventPtr(ActiveXEvent
): 
 380     def __init__(self
, this
): 
 382         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 383         self
.__class
__ = ActiveXEvent
 
 384 _activex
.ActiveXEvent_swigregister(ActiveXEventPtr
) 
 386 #--------------------------------------------------------------------------- 
 388 class IEHtmlWindowBase(ActiveXWindow
): 
 390         return "<%s.%s; proxy of C++ wxIEHtmlWindowBase instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,) 
 391     def __init__(self
, *args
, **kwargs
): 
 392         newobj 
= _activex
.new_IEHtmlWindowBase(*args
, **kwargs
) 
 393         self
.this 
= newobj
.this
 
 396     def SetCharset(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_SetCharset(*args
, **kwargs
) 
 397     def LoadString(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadString(*args
, **kwargs
) 
 398     def LoadStream(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_LoadStream(*args
, **kwargs
) 
 399     def GetStringSelection(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetStringSelection(*args
, **kwargs
) 
 400     def GetText(*args
, **kwargs
): return _activex
.IEHtmlWindowBase_GetText(*args
, **kwargs
) 
 402 class IEHtmlWindowBasePtr(IEHtmlWindowBase
): 
 403     def __init__(self
, this
): 
 405         if not hasattr(self
,"thisown"): self
.thisown 
= 0 
 406         self
.__class
__ = IEHtmlWindowBase
 
 407 _activex
.IEHtmlWindowBase_swigregister(IEHtmlWindowBasePtr
) 
 409 #--------------------------------------------------------------------------- 
 410 # Some helper and utility functions for ActiveX 
 418     Returns a printable summary of the TypeInfo from the ActiveX instance 
 422     def ProcessFuncX(f
, out
, name
): 
 424         out
.append(t4 
+ "retType:  %s" % f
.retType
.vt_type
) 
 426             out
.append(t4 
+ "params:") 
 428                 out
.append(t8 
+ p
.name
) 
 429                 out
.append(t8
+t4
+ "in:%s  out:%s  optional:%s  type:%s" % (p
.isIn
, p
.isOut
, p
.isOptional
, p
.vt_type
)) 
 432     def ProcessPropX(p
, out
): 
 433         out
.append(GernerateAXModule
.trimPropName(p
.name
)) 
 434         out
.append(t4
+ "type:%s  arg:%s  canGet:%s  canSet:%s" % (p
.type.vt_type
, p
.arg
.vt_type
, p
.canGet
, p
.canSet
)) 
 439     out
.append("PROPERTIES") 
 441     for p 
in ax
.GetAXProperties(): 
 445     out
.append("METHODS") 
 447     for m 
in ax
.GetAXMethods(): 
 448         ProcessFuncX(m
, out
, GernerateAXModule
.trimMethodName(m
.name
)) 
 453     for e 
in ax
.GetAXEvents(): 
 454         ProcessFuncX(e
, out
, GernerateAXModule
.trimEventName(e
.name
)) 
 457     return "\n".join(out
) 
 461 class GernerateAXModule
: 
 462     def __init__(self
, ax
, className
, modulePath
, moduleName
=None, verbose
=False): 
 464         Make a Python module file with a class that has been specialized 
 465         for the AcitveX object. 
 467             ax           An instance of the ActiveXWindow class 
 468             className    The name to use for the new class 
 469             modulePath   The path where the new module should be written to 
 470             moduleName   The name of the .py file to create.  If not given 
 471                          then the className will be used. 
 474         if moduleName 
is None: 
 475             moduleName 
= className 
+ '.py' 
 476         filename 
= os
.path
.join(modulePath
, moduleName
) 
 478             print "Creating module in:", filename
 
 479             print "  ProgID:  ", ax
.GetCLSID().GetProgIDString() 
 480             print "  CLSID:   ", ax
.GetCLSID().GetCLSIDString() 
 482         self
.mf 
= file(filename
, "w") 
 483         self
.WriteFileHeader(ax
) 
 485         self
.WriteClassHeader(ax
, className
) 
 486         self
.WriteMethods(ax
) 
 487         self
.WriteProperties(ax
) 
 493     def WriteFileHeader(self
, ax
): 
 494         self
.write("# This module was generated by the wx.activex.GernerateAXModule class\n" 
 495                    "# (See also the genaxmodule script.)\n") 
 496         self
.write("import wx") 
 497         self
.write("import wx.activex\n") 
 498         self
.write("clsID = '%s'\nprogID = '%s'\n" 
 499                    % (ax
.GetCLSID().GetCLSIDString(), ax
.GetCLSID().GetProgIDString())) 
 503     def WriteEvents(self
, ax
): 
 504         events 
= ax
.GetAXEvents() 
 506             self
.write("# Create eventTypes and event binders") 
 508                 self
.write("wxEVT_%s = wx.activex.RegisterActiveXEvent('%s')" 
 509                            % (self
.trimEventName(e
.name
), e
.name
)) 
 512                 n 
= self
.trimEventName(e
.name
) 
 513                 self
.write("EVT_%s = wx.PyEventBinder(wxEVT_%s, 1)" % (n
,n
)) 
 517     def WriteClassHeader(self
, ax
, className
): 
 518         self
.write("# Derive a new class from ActiveXWindow") 
 520 class %s(wx.activex.ActiveXWindow): 
 521     def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, 
 522                  size=wx.DefaultSize, style=0, name='%s'): 
 523         wx.activex.ActiveXWindow.__init__(self, parent, 
 524             wx.activex.CLSID('%s'), 
 525             ID, pos, size, style, name) 
 526         """ % (className
, className
, ax
.GetCLSID().GetCLSIDString()) ) 
 529     def WriteMethods(self
, ax
): 
 530         methods 
= ax
.GetAXMethods() 
 532             self
.write(t4
, "# Methods exported by the ActiveX object") 
 534                 name 
= self
.trimMethodName(m
.name
) 
 535                 self
.write(t4
, "def %s(self%s):" % (name
, self
.getParameters(m
, True))) 
 536                 self
.write(t8
, "return self.CallAXMethod('%s'%s)" % (m
.name
, self
.getParameters(m
, False))) 
 540     def WriteProperties(self
, ax
): 
 541         props 
= ax
.GetAXProperties() 
 543             self
.write(t4
, "# Getters, Setters and properties") 
 545                 getterName 
= setterName 
= "None" 
 547                     getterName 
= "_get_" + p
.name
 
 548                     self
.write(t4
, "def %s(self):" % getterName
) 
 549                     self
.write(t8
, "return self.GetAXProp('%s')" % p
.name
) 
 551                     setterName 
= "_set_" + p
.name
 
 552                     self
.write(t4
, "def %s(self, %s):" % (setterName
, p
.arg
.name
)) 
 553                     self
.write(t8
, "self.SetAXProp('%s', %s)" % (p
.name
, p
.arg
.name
)) 
 555                 self
.write(t4
, "%s = property(%s, %s)" % 
 556                            (self
.trimPropName(p
.name
), getterName
, setterName
)) 
 560     def WriteDocs(self
, ax
): 
 563         for line 
in doc
.split('\n'): 
 564             self
.write("#  ", line
) 
 568     def write(self
, *args
): 
 574     def trimEventName(name
): 
 575         if name
.startswith("On"): 
 578     trimEventName 
= staticmethod(trimEventName
) 
 581     def trimPropName(name
): 
 582         #name = name[0].lower() + name[1:] 
 585         if name 
in keyword
.kwlist
: name 
+= '_' 
 587     trimPropName 
= staticmethod(trimPropName
) 
 590     def trimMethodName(name
): 
 592         if name 
in keyword
.kwlist
: name 
+= '_' 
 594     trimMethodName 
= staticmethod(trimMethodName
) 
 597     def getParameters(self
, m
, withDefaults
): 
 600         # collect the input parameters, if both isIn and isOut are 
 601         # False then assume it is an input paramater 
 604             if p
.isIn 
or (not p
.isIn 
and not p
.isOut
): 
 609             if name 
in keyword
.kwlist
: name 
+= '_' 
 612             if withDefaults 
and p
.isOptional
: 
 617 #---------------------------------------------------------------------------