Fix bug preventing to copy block in SFC with SPACE key
authorgreg
Sat, 30 May 2009 17:16:11 +0200
changeset 362 f56181aa99ea
parent 361 62570186dad4
child 363 5eb9c5536334
Fix bug preventing to copy block in SFC with SPACE key
SFCViewer.py
--- a/SFCViewer.py	Sat May 30 17:15:22 2009 +0200
+++ b/SFCViewer.py	Sat May 30 17:16:11 2009 +0200
@@ -290,66 +290,69 @@
 #-------------------------------------------------------------------------------
 
     def OnChar(self, event):
-        xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL)
-        xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL)
-        ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL)
-        keycode = event.GetKeyCode()
-        if self.Scaling:
-            scaling = self.Scaling
-        else:
-            scaling = (8, 8)
-        if keycode == wx.WXK_DELETE and self.SelectedElement:
-            self.SelectedElement.Delete()
-            self.SelectedElement = None
-            self.RefreshBuffer()
-            self.RefreshScrollBars()
-            self.Refresh(False)
-        elif keycode == wx.WXK_LEFT:
-            if event.ControlDown() and event.ShiftDown():
-                self.Scroll(0, ypos)
-            elif event.ControlDown():
-                event.Skip()
-            elif self.SelectedElement:
-                self.SelectedElement.Move(-scaling[0], 0)
-                self.SelectedElement.RefreshModel()
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnChar(self, event)
+        else:
+            xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL)
+            xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL)
+            ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL)
+            keycode = event.GetKeyCode()
+            if self.Scaling:
+                scaling = self.Scaling
+            else:
+                scaling = (8, 8)
+            if keycode == wx.WXK_DELETE and self.SelectedElement:
+                self.SelectedElement.Delete()
+                self.SelectedElement = None
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)), False)
-        elif keycode == wx.WXK_RIGHT:
-            if event.ControlDown() and event.ShiftDown():
-                self.Scroll(xmax, ypos)
-            elif event.ControlDown():
+                self.Refresh(False)
+            elif keycode == wx.WXK_LEFT:
+                if event.ControlDown() and event.ShiftDown():
+                    self.Scroll(0, ypos)
+                elif event.ControlDown():
+                    event.Skip()
+                elif self.SelectedElement:
+                    self.SelectedElement.Move(-scaling[0], 0)
+                    self.SelectedElement.RefreshModel()
+                    self.RefreshBuffer()
+                    self.RefreshScrollBars()
+                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)), False)
+            elif keycode == wx.WXK_RIGHT:
+                if event.ControlDown() and event.ShiftDown():
+                    self.Scroll(xmax, ypos)
+                elif event.ControlDown():
+                    event.Skip()
+                elif self.SelectedElement:
+                    self.SelectedElement.Move(scaling[0], 0)
+                    self.SelectedElement.RefreshModel()
+                    self.RefreshBuffer()
+                    self.RefreshScrollBars()
+                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)), False)
+            elif keycode == wx.WXK_UP:
+                if event.ControlDown() and event.ShiftDown():
+                    self.Scroll(xpos, 0)
+                elif event.ControlDown():
+                    event.Skip()
+                elif self.SelectedElement:
+                    self.SelectedElement.Move(0, -scaling[1])
+                    self.SelectedElement.RefreshModel()
+                    self.RefreshBuffer()
+                    self.RefreshScrollBars()
+                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])), False)
+            elif keycode == wx.WXK_DOWN:
+                if event.ControlDown() and event.ShiftDown():
+                    self.Scroll(xpos, ymax)
+                elif event.ControlDown():
+                    event.Skip()
+                elif self.SelectedElement:
+                    self.SelectedElement.Move(0, scaling[1])
+                    self.SelectedElement.RefreshModel()
+                    self.RefreshBuffer()
+                    self.RefreshScrollBars()
+                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])), False)
+            else:
                 event.Skip()
-            elif self.SelectedElement:
-                self.SelectedElement.Move(scaling[0], 0)
-                self.SelectedElement.RefreshModel()
-                self.RefreshBuffer()
-                self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)), False)
-        elif keycode == wx.WXK_UP:
-            if event.ControlDown() and event.ShiftDown():
-                self.Scroll(xpos, 0)
-            elif event.ControlDown():
-                event.Skip()
-            elif self.SelectedElement:
-                self.SelectedElement.Move(0, -scaling[1])
-                self.SelectedElement.RefreshModel()
-                self.RefreshBuffer()
-                self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])), False)
-        elif keycode == wx.WXK_DOWN:
-            if event.ControlDown() and event.ShiftDown():
-                self.Scroll(xpos, ymax)
-            elif event.ControlDown():
-                event.Skip()
-            elif self.SelectedElement:
-                self.SelectedElement.Move(0, scaling[1])
-                self.SelectedElement.RefreshModel()
-                self.RefreshBuffer()
-                self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])), False)
-        else:
-            event.Skip()
         
 #-------------------------------------------------------------------------------
 #                          Adding element functions