source: salt-server/trunk/fuentes/py/sltlib.py @ 473

Last change on this file since 473 was 473, checked in by daduve, 3 years ago

Adding files

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1# OOo's libraries
2import uno
3try:
4  import unohelper
5except:
6  pass
7
8# An ActionListener adapter.
9# This object implements com.sun.star.awt.XActionListener.
10# When actionPerformed is called, this will call an arbitrary
11#  python procedure, passing it...
12#   1. the oActionEvent
13#   2. any other parameters you specified to this object's constructor (as a tuple).
14from com.sun.star.awt import XActionListener
15class ActionListenerProcAdapter(unohelper.Base, XActionListener ): 
16    def __init__( self, oProcToCall, tParams=() ): 
17        self.oProcToCall = oProcToCall # a python procedure
18        self.tParams = tParams # a tuple
19
20    # oActionEvent is a com.sun.star.awt.ActionEvent struct.
21    def actionPerformed( self, oActionEvent ): 
22        if callable( self.oProcToCall ): 
23            apply( self.oProcToCall, (oActionEvent,) + self.tParams ) 
24
25
26#--------------------------------------------------
27# An ItemListener adapter.
28# This object implements com.sun.star.awt.XItemListener.
29# When itemStateChanged is called, this will call an arbitrary
30#  python procedure, passing it...
31#   1. the oItemEvent
32#   2. any other parameters you specified to this object's constructor (as a tuple).
33from com.sun.star.awt import XItemListener
34class ItemListenerProcAdapter( unohelper.Base, XItemListener ): 
35    def __init__( self, oProcToCall, tParams=() ): 
36        self.oProcToCall = oProcToCall # a python procedure
37        self.tParams = tParams # a tuple
38
39    # oItemEvent is a com.sun.star.awt.ItemEvent struct.
40    def itemStateChanged( self, oItemEvent ): 
41        if callable( self.oProcToCall ): 
42            apply( self.oProcToCall, (oItemEvent,) + self.tParams ) 
43
44
45#--------------------------------------------------
46# An TextListener adapter.
47# This object implements com.sun.star.awt.XTextistener.
48# When textChanged is called, this will call an arbitrary
49#  python procedure, passing it...
50#   1. the oTextEvent
51#   2. any other parameters you specified to this object's constructor (as a tuple).
52from com.sun.star.awt import XTextListener
53class TextListenerProcAdapter( unohelper.Base, XTextListener ): 
54    def __init__( self, oProcToCall, tParams=() ): 
55        self.oProcToCall = oProcToCall # a python procedure
56        self.tParams = tParams # a tuple
57
58    # oTextEvent is a com.sun.star.awt.TextEvent struct.
59    def textChanged( self, oTextEvent ): 
60        if callable( self.oProcToCall ): 
61            apply( self.oProcToCall, (oTextEvent,) + self.tParams )
62
63#--------------------------------------------------
64# An MouseHandler adapter.
65# This object implements com.sun.star.awt.XMouseClickHandler.
66# When a mouse click is done, this will call an arbitrary
67#  python procedure, passing it...
68#   1. the oTextEvent
69#   2. any other parameters you specified to this object's constructor (as a tuple).
70from com.sun.star.awt import XMouseClickHandler
71class MouseListenerProcAdapter( unohelper.Base, XMouseClickHandler ): 
72    def __init__( self, oProcToCall, tParams=() ): 
73        self.oProcToCall = oProcToCall # a python procedure
74        self.tParams = tParams # a tuple
75
76    # oTextEvent is a com.sun.star.awt.TextEvent struct.
77    def mouseReleased( self, oMouseEvent ): 
78        if callable( self.oProcToCall ): 
79            apply( self.oProcToCall, (oMouseEvent,) + self.tParams )
Note: See TracBrowser for help on using the repository browser.