graphics/GraphicCommons.py
changeset 381 98890d848701
parent 372 8cab11dd2325
child 384 ed27a676d5c9
--- a/graphics/GraphicCommons.py	Thu Jul 23 17:53:54 2009 +0200
+++ b/graphics/GraphicCommons.py	Thu Jul 23 18:07:14 2009 +0200
@@ -92,18 +92,6 @@
 
 # Color for Highlighting
 HIGHLIGHTCOLOR = wx.CYAN
-
-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)]
            
 HANDLE_CURSORS = {
     (1, 1) : 2,
@@ -470,8 +458,6 @@
         self.Size = wx.Size(0, 0)
         self.BoundingBox = wx.Rect(0, 0, 0, 0)
         self.Visible = False
-        self.CurrentCursor = 0
-        ResetCursors()
     
     def TestVisible(self, screen):
         self.Visible = self.GetRedrawRect().Intersects(screen)
@@ -630,9 +616,7 @@
         # Find which type of handle have been clicked,
         # Save a resize event and change the cursor
         cursor = HANDLE_CURSORS.get(handle, 1)
-        if cursor != self.CurrentCursor:
-            self.Parent.SetCursor(CURSORS[cursor])
-            self.CurrentCursor = cursor
+        wx.CallAfter(self.Parent.SetCurrentCursor, cursor)
         if cursor > 1:
             self.Handle = (HANDLE_RESIZE, handle)
         else:
@@ -649,9 +633,7 @@
         if self.Dragging and self.oldPos:
             self.RefreshModel()
             self.Parent.RefreshBuffer()
-        if self.CurrentCursor != 0:
-            self.Parent.SetCursor(CURSORS[0])
-            self.CurrentCursor = 0
+        wx.CallAfter(self.Parent.SetCurrentCursor, 0)
         self.SetSelected(True)
         self.oldPos = None
 
@@ -664,9 +646,7 @@
         if self.Dragging and self.oldPos:
             self.RefreshModel()
             self.Parent.RefreshBuffer()
-        if self.CurrentCursor != 0:
-            self.Parent.SetCursor(CURSORS[0])
-            self.CurrentCursor = 0
+        wx.CallAfter(self.Parent.SetCurrentCursor, 0)
         self.SetSelected(True)
         self.oldPos = None
 
@@ -703,9 +683,7 @@
             # Find which type of handle have been clicked,
             # Save a resize event and change the cursor
             cursor = HANDLE_CURSORS.get(handle, 0)
-            if cursor != self.CurrentCursor:
-                self.Parent.SetCursor(CURSORS[cursor])
-                self.CurrentCursor = cursor
+            wx.CallAfter(self.Parent.SetCurrentCursor, cursor)
             return 0, 0
 
     # Moves the element
@@ -2374,15 +2352,15 @@
         #result = self.TestPoint(pos)
         #if result != None:
         #    self.Handle = (HANDLE_POINT, result)
-        #    self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
+        #    wx.CallAfter(self.Parent.SetCurrentCursor, 1)
         #else:
         # Test if a segment have been handled
         result = self.TestSegment(pos)
         if result != None:
             if result[1] in (NORTH, SOUTH):
-                self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE))
+                wx.CallAfter(self.Parent.SetCurrentCursor, 4)
             elif result[1] in (EAST, WEST):
-                self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS))
+                wx.CallAfter(self.Parent.SetCurrentCursor, 5)
             self.Handle = (HANDLE_SEGMENT, result)
         # Execute the default method for a graphic element
         else:
@@ -2461,13 +2439,9 @@
             result = self.TestSegment(pos)
             if result:
                 if result[1] in (NORTH, SOUTH):
-                    if self.CurrentCursor != 4:
-                        self.CurrentCursor = 4
-                        wx.CallAfter(self.Parent.SetCursor, CURSORS[4])
+                    wx.CallAfter(self.Parent.SetCurrentCursor, 4)
                 elif result[1] in (EAST, WEST):
-                    if self.CurrentCursor != 5:
-                        self.CurrentCursor = 5
-                        wx.CallAfter(self.Parent.SetCursor, CURSORS[5])
+                    wx.CallAfter(self.Parent.SetCurrentCursor, 5)
                 return 0, 0
             else:
                 # Test if a point has been handled