ed_event.py
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
###############################################################################
# Name: ed_event.py #
# Purpose: Custom events used by Editra #
# Author: Cody Precord <cprecord@editra.org> #
# Copyright: (c) 2007 Cody Precord <staff@editra.org> #
# License: wxWindows License #
###############################################################################
"""
Provides custom events for the editors controls/objects to utilize
"""
__author__ = "Cody Precord <cprecord@editra.org>"
__svnid__ = "$Id: ed_event.py 63789 2010-03-30 02:25:17Z CJP $"
__revision__ = "$Revision: 63789 $"
#-----------------------------------------------------------------------------#
# Dependencies
import wx
#-----------------------------------------------------------------------------#
edEVT_UPDATE_TEXT = wx.NewEventType()
EVT_UPDATE_TEXT = wx.PyEventBinder(edEVT_UPDATE_TEXT, 1)
class UpdateTextEvent(wx.PyCommandEvent):
"""Event to signal that text needs updating"""
def __init__(self, etype, eid, value=None):
"""Creates the event object"""
wx.PyCommandEvent.__init__(self, etype, eid)
self._value = value
def GetValue(self):
"""Returns the value from the event.
@return: the value of this event
"""
return self._value
#--------------------------------------------------------------------------#
edEVT_NOTIFY = wx.NewEventType()
EVT_NOTIFY = wx.PyEventBinder(edEVT_NOTIFY, 1)
class NotificationEvent(UpdateTextEvent):
"""General notification event"""
def __init__(self, etype, eid, value=None, obj=None):
UpdateTextEvent.__init__(self, etype, eid, value)
self.SetEventObject(obj)
#--------------------------------------------------------------------------#
edEVT_MAINWINDOW_EXIT = wx.NewEventType()
EVT_MAINWINDOW_EXIT = wx.PyEventBinder(edEVT_MAINWINDOW_EXIT, 1)
class MainWindowExitEvent(wx.PyCommandEvent):
"""Event to signal that the main window is exiting"""
pass
#--------------------------------------------------------------------------#
edEVT_STATUS = wx.NewEventType()
EVT_STATUS = wx.PyEventBinder(edEVT_STATUS, 1)
class StatusEvent(wx.PyCommandEvent):
"""Event for posting status events"""
def __init__(self, etype, eid, msg=None, sec=0):
"""Create an event that can be used to post status messages
to the main windows status bar.
@param etype: The type of event to create
@param eid: The event id
@keyword msg: The status message to post with the event
@keyword sec: The section of the status bar to post message to
"""
wx.PyCommandEvent.__init__(self, etype, eid)
self._msg = msg
self._sec = sec
def GetMessage(self):
"""Returns the value from the event.
@return: the value of this event
"""
return self._msg
def GetSection(self):
"""Returns the messages posting section
@return: int zero based index of where to post to statusbar
"""
return self._sec