chiark / gitweb /
3ca84575156dc4ce5af8aabd8e314da8aeb316ae
[cura.git] /
1 """
2 Display line is a mouse tool to display the line index of the line clicked, counting from one, and the line itself.
3
4 """
5
6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
8 import __init__
9
10
11 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
12 __date__ = '$Date: 2008/21/04 $'
13 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
14
15
16 class MouseToolBase:
17         "The mouse tool base class, which does nothing."
18         def button1(self, event):
19                 "The left button was clicked, <Button-1> function."
20                 pass
21
22         def buttonRelease1(self, event):
23                 "The left button was released, <ButtonRelease-1> function."
24                 pass
25
26         def destroyEverything(self):
27                 "Destroy items."
28                 self.canvas.delete('mouse_item')
29
30         def destroyEverythingGetFocus(self):
31                 "Destroy items and get the focus for the canvas."
32                 self.destroyEverything()
33                 self.canvas.focus_set()
34
35         def getReset( self, window ):
36                 "Reset the mouse tool to default."
37                 self.setWindowItems( window )
38                 self.destroyEverything()
39                 return self
40
41         def getTagsGivenXY( self, x, y ):
42                 "Get the tag for the x and y."
43                 tags = self.canvas.itemcget( self.canvas.find_closest(x, y), 'tags')
44                 currentEnd = ' current'
45                 if tags.find( currentEnd ) != - 1:
46                         return tags[ : - len( currentEnd ) ]
47                 return tags
48
49         def isSelectionTool(self):
50                 "Return if this mouse tool is a selection tool."
51                 return False
52
53         def keyPressDown(self, event):
54                 "The down arrow was pressed."
55                 pass
56
57         def keyPressLeft(self, event):
58                 "The left arrow was pressed."
59                 pass
60
61         def keyPressReturn(self, event):
62                 "The return key was pressed."
63                 pass
64
65         def keyPressRight(self, event):
66                 "The right arrow was pressed."
67                 pass
68
69         def keyPressUp(self, event):
70                 "The up arrow was pressed."
71                 pass
72
73         def motion( self, event, shift = False ):
74                 "The mouse moved, <Motion> function."
75                 pass
76
77         def setWindowItems( self, window ):
78                 "Set the canvas and items."
79                 self.canvas = window.canvas
80                 self.repository = window.repository
81                 self.window = window
82
83         def update(self):
84                 "Update the mouse tool."
85                 pass