--- a/Viewer.py Thu Jul 23 17:53:54 2009 +0200
+++ b/Viewer.py Thu Jul 23 18:07:14 2009 +0200
@@ -41,6 +41,18 @@
WINDOW_BORDER = 10
SCROLL_ZONE = 10
+CURSORS = None
+
+def ResetCursors():
+ global CURSORS
+ if CURSORS == None:
+ CURSORS = [wx.NullCursor,
+ wx.StockCursor(wx.CURSOR_HAND),
+ wx.StockCursor(wx.CURSOR_SIZENWSE),
+ wx.StockCursor(wx.CURSOR_SIZENESW),
+ wx.StockCursor(wx.CURSOR_SIZEWE),
+ wx.StockCursor(wx.CURSOR_SIZENS)]
+
def AppendMenu(parent, help, id, kind, text):
if wx.VERSION >= (2, 6, 0):
parent.Append(help=help, id=id, kind=kind, text=text)
@@ -364,6 +376,10 @@
self.StartMousePos = None
self.StartScreenPos = None
+ # Initialize Cursors
+ ResetCursors()
+ self.CurrentCursor = 0
+
# Initialize Block, Wire and Comment numbers
self.block_id = self.wire_id = self.comment_id = 0
@@ -414,6 +430,12 @@
self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheelWindow)
self.Bind(wx.EVT_SIZE, self.OnMoveWindow)
+ def SetCurrentCursor(self, cursor):
+ global CURSORS
+ if self.CurrentCursor != cursor:
+ self.CurrentCursor = cursor
+ self.SetCursor(CURSORS[cursor])
+
def GetScrolledRect(self, rect):
rect.x, rect.y = self.CalcScrolledPosition(int(rect.x * self.ViewScale[0]),
int(rect.y * self.ViewScale[1]))
@@ -1492,7 +1514,7 @@
Graphic_Element.OnLeftUp(self.SelectedElement, event, dc, self.Scaling)
else:
self.SelectedElement.OnLeftUp(event, dc, self.Scaling)
- wx.CallAfter(self.SetCursor, wx.NullCursor)
+ wx.CallAfter(self.SetCurrentCursor, 0)
if self.Mode != MODE_SELECTION and not self.SavedMode:
wx.CallAfter(self.ParentWindow.ResetCurrentMode)
event.Skip()
@@ -1531,7 +1553,7 @@
Graphic_Element.OnRightUp(self.SelectedElement, event, dc, self.Scaling)
else:
self.SelectedElement.OnRightUp(event, dc, self.Scaling)
- wx.CallAfter(self.SetCursor, wx.NullCursor)
+ wx.CallAfter(self.SetCurrentCursor, 0)
elif not self.Debug:
self.PopupDefaultMenu(False)
event.Skip()
@@ -1683,7 +1705,7 @@
self.SelectedElement = None
self.RefreshBuffer()
self.RefreshScrollBars()
- self.SetCursor(wx.NullCursor)
+ wx.CallAfter(self.SetCurrentCursor, 0)
self.RefreshRect(self.GetScrolledRect(rect), False)
elif not self.Debug and keycode == wx.WXK_RETURN and self.SelectedElement is not None:
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)