comparison pyink/FSM_window.py @ 1495:75cfacaa106e

Refactoring _dragger
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 03 May 2011 01:45:14 +0800
parents ac390af12152
children 042587afed2e
comparison
equal deleted inserted replaced
1494:ac390af12152 1495:75cfacaa106e
12 _state = 0 12 _state = 0
13 13
14 def __init__(self): 14 def __init__(self):
15 pass 15 pass
16 16
17 ## \brief Mouse event handler
18 #
19 # This is a placeholder for mouse vent handlers. This attribute
20 # of instances is switched between _mouse_event_waiting and
21 # _mouse_event_pressed.
22 #
17 def mouse_event(self, evtype, button, x, y): 23 def mouse_event(self, evtype, button, x, y):
18 raise RuntimeError, 'should not be here' 24 raise RuntimeError, 'should not be here'
19 25
20 def mouse_event_waiting(self, evtype, button, x, y): 26 def _mouse_event_waiting(self, evtype, button, x, y):
21 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS and \ 27 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS and \
22 button == 1: 28 button == 1:
23 self._start_x = x 29 self._start_x = x
24 self._start_y = y 30 self._start_y = y
25 self.mouse_event = self.mouse_event_pressed 31 self.mouse_event = self._mouse_event_pressed
26 self.start_drag() 32 self.start_drag()
27 pass 33 pass
28 pass 34 pass
29 35
30 def mouse_event_pressed(self, evtype, button, x, y): 36 def _mouse_event_pressed(self, evtype, button, x, y):
31 rx = x - self._start_x 37 rx = x - self._start_x
32 ry = y - self._start_y 38 ry = y - self._start_y
33 39
34 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: 40 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE:
35 self.mouse_event = self.mouse_event_waiting 41 self.mouse_event = self._mouse_event_waiting
36 self.stop_drag(rx, ry) 42 self.stop_drag(rx, ry)
37 pass 43 pass
38 44
39 self.update(rx, ry) 45 self.update(rx, ry)
40 pass 46 pass
41 47
42 def start(self): 48 def start(self):
43 self.mouse_event = self.mouse_event_waiting 49 self.mouse_event = self._mouse_event_waiting
44 pass 50 pass
45 51
46 def stop(self): 52 def stop(self):
47 pass 53 pass
48 54