Changeset 3222

Show
Ignore:
Timestamp:
06/30/07 06:30:06 (2 years ago)
Author:
ed
Message:

Removed trailing whitespace.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dEvents.py

    r3221 r3222  
    99class dEvent(dObject): 
    1010    """ Base class for Dabo events. 
    11      
    12     Event objects are instantiated in self.raiseEvent(), and passed to all  
     11 
     12    Event objects are instantiated in self.raiseEvent(), and passed to all 
    1313    callbacks registered with self.bindEvent(). 
    14      
    15     User code can define custom events by simply subclassing Event and then  
     14 
     15    User code can define custom events by simply subclassing Event and then 
    1616    using self.bindEvent() and self.raiseEvent() in your objects. 
    17     """         
     17    """ 
    1818    def __init__(self, eventObject, uiEvent=None, eventData=None, *args, **kwargs): 
    1919        # Event objects get instantiated with every single event, so try 
    2020        # to keep code to a minimum here. 
    2121        #super(dEvent, self).__init__(*args, **kwargs) 
    22          
     22 
    2323        self._eventObject = eventObject 
    2424        self._uiEvent = uiEvent 
     
    2727        self._continue = True 
    2828        self._baseClass = dEvent 
    29          
     29 
    3030        self._insertEventData() 
    3131        if eventData: 
    3232            self._eventData.update(eventData) 
    33          
     33 
    3434        if dabo.eventLogging: 
    3535            self._logEvent() 
    36          
    37      
     36 
     37 
    3838    def appliesToClass(eventClass, objectClass): 
    3939        """ Returns True if this event can be raised by the passed class. 
    40          
     40 
    4141        Stub: subclass events need to override with appropriate logic. 
    4242        """ 
    4343        return False 
    4444    appliesToClass = classmethod(appliesToClass) 
    45              
    46          
     45 
     46 
    4747    def stop(self): 
    4848        """Stop the event from being handled by other handlers. 
    49          
     49 
    5050        This is an alternative to setting the Continue property to False. 
    5151        """ 
    5252        self.Continue = False 
    53          
    54          
     53 
     54 
    5555    def _insertEventData(self): 
    5656        """ Place ui-specific stuff into the ui-agnostic EventData dictionary.""" 
    57         eventData = {}      
     57        eventData = {} 
    5858        nativeEvent = self._uiEvent 
    5959        kwargs = self._kwargs 
    60          
     60 
    6161        eventData["timestamp"] = time.localtime() 
    6262 
     
    6969            # Each UI lib should implement getEventData() 
    7070            uiEventData = dabo.ui.getEventData(nativeEvent) 
    71              
     71 
    7272            for key in uiEventData.keys(): 
    7373                eventData[key] = uiEventData[key] 
    74                  
    75         self._eventData = eventData                 
    76                  
    77              
     74 
     75        self._eventData = eventData 
     76 
     77 
    7878    def _logEvent(self): 
    7979        """ Log the event if the event object's LogEvents property is set.""" 
    8080        eventName = self.__class__.__name__ 
    81          
     81 
    8282        try: 
    8383            logEvents = self._eventObject._getLogEvents() 
     
    8585            logEvents = [] 
    8686        noLogEvents = [] 
    87          
     87 
    8888        if len(logEvents) > 0 and logEvents[0].lower() == "all": 
    8989            # If there are any events listed explicitly, those must not be 
     
    9191            noLogEvents = logEvents[1:] 
    9292 
    93         if eventName not in noLogEvents:        
     93        if eventName not in noLogEvents: 
    9494            for logEventName in logEvents: 
    9595                if logEventName.lower() == "all" or logEventName == eventName: 
    96                     dabo.infoLog.write("dEvent Fired: %s %s" %  
    97                             (self._eventObject.getAbsoluteName(),  
     96                    dabo.infoLog.write("dEvent Fired: %s %s" % 
     97                            (self._eventObject.getAbsoluteName(), 
    9898                            self.__class__.__name__,)) 
    9999                    break 
     
    105105        raise AttributeError, "%s.%s object has no attribute %s." % ( 
    106106            self.__class__.__module__, self.__class__.__name__, att) 
    107              
    108              
     107 
     108 
    109109    def _getContinue(self): 
    110110        return self._continue 
    111          
     111 
    112112    def _setContinue(self, val): 
    113113        self._continue = bool(val) 
    114          
    115          
     114 
     115 
    116116    def _getEventObject(self): 
    117117        return self._eventObject 
    118          
     118 
    119119    def _setEventObject(self, obj): 
    120120        self._eventObject = obj 
    121      
    122      
     121 
     122 
    123123    def _getEventData(self): 
    124124        return self._eventData 
    125          
     125 
    126126    def _setEventData(self, dict): 
    127127        self._eventData = dict 
    128      
    129      
     128 
     129 
    130130    Continue = property(_getContinue, _setContinue, None, 
    131             _("""Specifies whether the event is allowed to continue  
     131            _("""Specifies whether the event is allowed to continue 
    132132            on to the next handler.  (bool)""")) 
    133          
    134     EventObject = property(_getEventObject, _setEventObject, None,  
     133 
     134    EventObject = property(_getEventObject, _setEventObject, None, 
    135135            _("References the object that emitted the event.  (obj)""")) 
    136          
     136 
    137137    EventData = property(_getEventData, _setEventData, None, 
    138             _("""Dictionary of data name/value pairs associated  
     138            _("""Dictionary of data name/value pairs associated 
    139139            with the event.  (dict)""")) 
    140140 
    141 # Eventually deprecate Event        
     141# Eventually deprecate Event 
    142142Event=dEvent 
    143143 
     
    146146        return issubclass(objectClass, dabo.biz.dBizobj) 
    147147    appliesToClass = classmethod(appliesToClass) 
    148          
    149          
     148 
     149 
    150150class EditorEvent(dEvent): 
    151151    def appliesToClass(eventClass, objectClass): 
    152152        return issubclass(objectClass, dabo.ui.dEditor) 
    153153    appliesToClass = classmethod(appliesToClass) 
    154              
     154 
    155155class GridEvent(dEvent): 
    156156    def appliesToClass(eventClass, objectClass): 
    157157        return issubclass(objectClass, dabo.ui.dGrid) 
    158158    appliesToClass = classmethod(appliesToClass) 
    159      
     159 
    160160class KeyEvent(dEvent): 
    161161    def appliesToClass(eventClass, objectClass): 
    162162        return issubclass(objectClass, (dabo.ui.dPemMixin, dabo.dApp)) 
    163163    appliesToClass = classmethod(appliesToClass) 
    164      
    165      
     164 
     165 
    166166class ListEvent(dEvent): 
    167167    def appliesToClass(eventClass, objectClass): 
    168168        return issubclass(objectClass, (dabo.ui.dListControl, dabo.ui.dListBox)) 
    169169    appliesToClass = classmethod(appliesToClass) 
    170      
     170 
    171171 
    172172class MenuEvent(dEvent): 
     
    175175                dabo.ui.dMenuBar)) 
    176176    appliesToClass = classmethod(appliesToClass) 
    177      
     177 
    178178 
    179179class MouseEvent(dEvent): 
     
    181181        return issubclass(objectClass, dabo.ui.dPemMixin) 
    182182    appliesToClass = classmethod(appliesToClass) 
    183      
     183 
    184184 
    185185class SashEvent(dEvent): 
     
    207207                dabo.ui.dFormMain, dabo.ui.dDialog)) 
    208208    appliesToClass = classmethod(appliesToClass) 
    209      
     209 
    210210 
    211211class Close(dEvent): 
     
    215215                dabo.ui.dDialog)) 
    216216    appliesToClass = classmethod(appliesToClass) 
    217      
    218      
     217 
     218 
    219219class Create(dEvent): 
    220220    """Occurs after the control or form is created.""" 
     
    222222        return issubclass(objectClass, dabo.ui.dPemMixin) 
    223223    appliesToClass = classmethod(appliesToClass) 
    224      
    225      
     224 
     225 
    226226class ChildBorn(dEvent): 
    227227    """Occurs when a child control is created.""" 
     
    244244    """ 
    245245    pass 
    246      
     246 
    247247 
    248248class Deactivate(dEvent): 
     
    252252                dabo.ui.dFormMain, dabo.ui.dDialog)) 
    253253    appliesToClass = classmethod(appliesToClass) 
    254      
     254 
    255255 
    256256class Destroy(dEvent): 
     
    259259        return issubclass(objectClass, dabo.ui.dPemMixin) 
    260260    appliesToClass = classmethod(appliesToClass) 
    261      
     261 
    262262 
    263263class FontPropertiesChanged(dEvent): 
     
    269269 
    270270class Hit(dEvent): 
    271     """Occurs with the control's default event (button click,  
     271    """Occurs with the control's default event (button click, 
    272272    listbox pick, checkbox, etc.) 
    273273    """ 
     
    278278                ui.dTimer, ui.dToggleButton, ui.dMenuItem)) 
    279279    appliesToClass = classmethod(appliesToClass) 
    280      
     280 
    281281 
    282282class Idle(dEvent): 
    283283    """Occurs when the event loop has no active events to process. 
    284      
    285     This is a good place to put redraw or other such UI-intensive code, so that it  
    286     will only run when the application is otherwise not busy doing other (more  
     284 
     285    This is a good place to put redraw or other such UI-intensive code, so that it 
     286    will only run when the application is otherwise not busy doing other (more 
    287287    important) things. 
    288288    """ 
     
    290290        return issubclass(objectClass, dabo.ui.dPemMixin) 
    291291    appliesToClass = classmethod(appliesToClass) 
    292      
     292 
    293293 
    294294class GotFocus(dEvent): 
     
    298298    appliesToClass = classmethod(appliesToClass) 
    299299 
    300      
     300 
    301301class KeyChar(KeyEvent): 
    302     """Occurs when a key is depressed and released on the  
     302    """Occurs when a key is depressed and released on the 
    303303    focused control or form. 
    304304    """ 
    305305    pass 
    306      
     306 
    307307 
    308308class KeyDown(KeyEvent): 
    309309    """Occurs when any key is depressed on the focused control or form.""" 
    310310    pass 
    311      
     311 
    312312 
    313313class KeyUp(KeyEvent): 
     
    315315    pass 
    316316 
    317      
     317 
    318318class LostFocus(dEvent): 
    319319    """Occurs when the control loses the focus.""" 
     
    347347        return issubclass(objectClass, dabo.ui.dPemMixin) 
    348348    appliesToClass = classmethod(appliesToClass) 
    349      
    350          
     349 
     350 
    351351class MouseEnter(MouseEvent): 
    352352    """Occurs when the mouse pointer enters the form or control.""" 
    353353    pass 
    354      
    355  
    356 class MouseLeave(MouseEvent):  
     354 
     355 
     356class MouseLeave(MouseEvent): 
    357357    """Occurs when the mouse pointer leaves the form or control.""" 
    358358    pass 
     
    362362    """Occurs when the mouse moves in the control.""" 
    363363    pass 
    364      
     364 
    365365 
    366366class MouseWheel(MouseEvent): 
    367367    """Occurs when the user scrolls the mouse wheel.""" 
    368368    pass 
    369      
     369 
    370370 
    371371class MouseLeftDown(MouseEvent): 
    372372    """Occurs when the mouse's left button is depressed on the control.""" 
    373373    pass 
    374      
     374 
    375375 
    376376class MouseLeftUp(MouseEvent): 
    377377    """Occurs when the mouse's left button is released on the control.""" 
    378378    pass 
    379      
     379 
    380380 
    381381class MouseLeftClick(MouseEvent): 
    382     """Occurs when the mouse's left button is depressed  
     382    """Occurs when the mouse's left button is depressed 
    383383    and released on the control. 
    384384    """ 
    385385    pass 
    386      
     386 
    387387 
    388388class MouseLeftDoubleClick(MouseEvent): 
    389389    """Occurs when the mouse's left button is double-clicked on the control.""" 
    390390    pass 
    391      
     391 
    392392 
    393393class MouseRightDown(MouseEvent): 
    394394    """Occurs when the mouse's right button is depressed on the control.""" 
    395395    pass 
    396      
     396 
    397397 
    398398class MouseRightUp(MouseEvent): 
     
    402402 
    403403class MouseRightClick(MouseEvent): 
    404     """Occurs when the mouse mouse's right button is depressed  
     404    """Occurs when the mouse mouse's right button is depressed 
    405405    and released on the control. 
    406406    """ 
    407407    pass 
    408      
     408 
    409409 
    410410class MouseRightDoubleClick(MouseEvent): 
    411411    """Occurs when the mouse's right button is double-clicked on the control.""" 
    412412    pass 
    413      
     413 
    414414 
    415415class MouseMiddleDown(MouseEvent): 
    416416    """Occurs when the mouse's middle button is depressed on the control.""" 
    417417    pass 
    418      
     418 
    419419 
    420420class MouseMiddleUp(MouseEvent): 
     
    428428    """ 
    429429    pass 
    430      
     430 
    431431 
    432432class MouseMiddleDoubleClick(MouseEvent): 
    433     """Occurs when the mouse's middle button is double-clicked  
     433    """Occurs when the mouse's middle button is double-clicked 
    434434    on the control. 
    435435    """ 
    436436    pass 
    437      
    438      
     437 
     438 
    439439class Paint(dEvent): 
    440440    """Occurs when it is time to paint the control.""" 
     
    442442        return issubclass(objectClass, dabo.ui.dPemMixin) 
    443443    appliesToClass = classmethod(appliesToClass) 
    444      
     444 
    445445 
    446446class PageChanged(dEvent): 
    447447    """Occurs when a page in a pageframe-like control changes""" 
    448448    def appliesToClass(eventClass, objectClass): 
    449         return issubclass(objectClass, (dabo.ui.dPageFrame, dabo.ui.dPageList,  
     449        return issubclass(objectClass, (dabo.ui.dPageFrame, dabo.ui.dPageList, 
    450450                dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs)) 
    451451    appliesToClass = classmethod(appliesToClass) 
    452      
     452 
    453453 
    454454class PageChanging(dEvent): 
    455455    """Occurs when the current page in a pageframe-like control is about to change""" 
    456456    def appliesToClass(eventClass, objectClass): 
    457         return issubclass(objectClass, (dabo.ui.dPageFrame, dabo.ui.dPageList,  
     457        return issubclass(objectClass, (dabo.ui.dPageFrame, dabo.ui.dPageList, 
    458458                dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs)) 
    459459    appliesToClass = classmethod(appliesToClass) 
    460      
     460 
    461461 
    462462class PageEnter(dEvent): 
     
    465465        return issubclass(objectClass, dabo.ui.dPage) 
    466466    appliesToClass = classmethod(appliesToClass) 
    467      
     467 
    468468 
    469469class PageLeave(dEvent): 
     
    479479        return issubclass(objectClass, dabo.ui.dPemMixin) 
    480480    appliesToClass = classmethod(appliesToClass) 
    481      
    482          
     481 
     482 
    483483class FoldPanelChange(dEvent): 
    484484    """Occurs when a panel in a dFoldPanelBar control is hidden or shown.""" 
     
    486486        return issubclass(objectClass, (dabo.ui.dFoldPanelBar, dabo.ui.dFoldPanel)) 
    487487    appliesToClass = classmethod(appliesToClass) 
    488      
    489          
     488 
     489 
    490490class FoldPanelCaptionClick(dEvent): 
    491491    """Occurs when the caption bar of a dFoldPanel is clicked.""" 
     
    493493        return issubclass(objectClass, (dabo.ui.dFoldPanelBar, dabo.ui.dFoldPanel)) 
    494494    appliesToClass = classmethod(appliesToClass) 
    495      
    496          
     495 
     496 
    497497class RowNumChanged(DataEvent): 
    498498    """Occurs when the cursor's row number has changed.""" 
    499499    pass 
    500500 
    501      
     501 
    502502class SashDoubleClick(SashEvent): 
    503503    """Occurs when a user double-clicks on the sash of a splitter window.""" 
     
    523523    """Occurs when the month on a calendar is changed.""" 
    524524    pass 
    525      
     525 
    526526 
    527527class CalendarYearChanged(CalendarEvent): 
     
    751751class DocumentationHint(EditorEvent): 
    752752    """Occurs when the editor wants documentation information to change. 
    753      
     753 
    754754    The IDE can bind to this to direct detailed documentation into a separate 
    755755    window, likely replacing previous documentation. The user can choose how 
    756756    to display that window, if at all. 
    757      
     757 
    758758    Raise this event with three additional keyword arguments: 
    759759        + shortDoc: a one-liner call tip 
    760760        + longDoc: a multi-line call tip plus expanded documentation 
    761761        + object: a reference to the object to be documented, in case 
    762             the listener wants to format additional information about  
     762            the listener wants to format additional information about 
    763763            the object. 
    764764    """ 
     
    774774    """Occurs when the contents of the Editor are modified.""" 
    775775    pass 
    776      
     776 
    777777 
    778778class ValueChanged(dEvent): 
     
    783783        return issubclass(objectClass, dabo.ui.dDataControlMixin) 
    784784    appliesToClass = classmethod(appliesToClass) 
    785      
     785 
    786786 
    787787class Update(dEvent):