445 offset = 0 |
445 offset = 0 |
446 for button in buttons: |
446 for button in buttons: |
447 w, h = button.GetSize() |
447 w, h = button.GetSize() |
448 if direction in [wx.LEFT, wx.RIGHT]: |
448 if direction in [wx.LEFT, wx.RIGHT]: |
449 x = rect.x + (- w - offset |
449 x = rect.x + (- w - offset |
450 if direction == wx.LEFT |
450 if direction == wx.LEFT |
451 else rect.width + offset) |
451 else rect.width + offset) |
452 y = rect.y + (rect.height - h) / 2 |
452 y = rect.y + (rect.height - h) / 2 |
453 offset += w |
453 offset += w |
454 else: |
454 else: |
455 x = rect.x + (rect.width - w) / 2 |
455 x = rect.x + (rect.width - w) / 2 |
456 y = rect.y + (- h - offset |
456 y = rect.y + (- h - offset |
642 self.DismissContextualButtons() |
642 self.DismissContextualButtons() |
643 |
643 |
644 # Start a drag'n drop from mouse position in wx coordinate of |
644 # Start a drag'n drop from mouse position in wx coordinate of |
645 # parent |
645 # parent |
646 xw, yw = self.GetPosition() |
646 xw, yw = self.GetPosition() |
647 self.ParentWindow.StartDragNDrop(self, |
647 self.ParentWindow.StartDragNDrop( |
648 self.ItemsDict.values()[item_idx], |
648 self, self.ItemsDict.values()[item_idx], |
649 x + xw, y + yw, # Current mouse position |
649 x + xw, y + yw, # Current mouse position |
650 x + xw, y + yw) # Mouse position when button was clicked |
650 x + xw, y + yw) # Mouse position when button was clicked |
651 |
651 |
652 # Don't handle mouse button if canvas is 3D and let matplotlib do |
652 # Don't handle mouse button if canvas is 3D and let matplotlib do |
653 # the default behavior (rotate 3D axes) |
653 # the default behavior (rotate 3D axes) |
684 width, height = self.GetSize() |
684 width, height = self.GetSize() |
685 xw, yw = self.GetPosition() |
685 xw, yw = self.GetPosition() |
686 item = self.ParentWindow.DraggingAxesPanel.ItemsDict.values()[0] |
686 item = self.ParentWindow.DraggingAxesPanel.ItemsDict.values()[0] |
687 # Give mouse position in wx coordinate of parent |
687 # Give mouse position in wx coordinate of parent |
688 self.ParentWindow.StopDragNDrop(item.GetVariable(), |
688 self.ParentWindow.StopDragNDrop(item.GetVariable(), |
689 xw + event.x, yw + height - event.y) |
689 xw + event.x, yw + height - event.y) |
690 |
690 |
691 else: |
691 else: |
692 # Reset any move in progress |
692 # Reset any move in progress |
693 self.MouseStartPos = None |
693 self.MouseStartPos = None |
694 self.CanvasStartSize = None |
694 self.CanvasStartSize = None |
723 elif event.button is None: |
723 elif event.button is None: |
724 # Compute direction for items label according graph type |
724 # Compute direction for items label according graph type |
725 if self.GraphType == GRAPH_PARALLEL: # Graph is parallel |
725 if self.GraphType == GRAPH_PARALLEL: # Graph is parallel |
726 directions = [wx.RIGHT] * len(self.AxesLabels) + \ |
726 directions = [wx.RIGHT] * len(self.AxesLabels) + \ |
727 [wx.LEFT] * len(self.Labels) |
727 [wx.LEFT] * len(self.Labels) |
728 elif len(self.AxesLabels) > 0: # Graph is orthogonal in 2D |
728 elif len(self.AxesLabels) > 0: # Graph is orthogonal in 2D |
729 directions = [wx.RIGHT, wx.TOP, # Directions for AxesLabels |
729 directions = [wx.RIGHT, wx.TOP, # Directions for AxesLabels |
730 wx.LEFT, wx.BOTTOM] # Directions for Labels |
730 wx.LEFT, wx.BOTTOM] # Directions for Labels |
731 else: # Graph is orthogonal in 3D |
731 else: # Graph is orthogonal in 3D |
732 directions = [wx.LEFT] * len(self.Labels) |
732 directions = [wx.LEFT] * len(self.Labels) |
733 |
733 |
734 # Find if mouse is over an item label |
734 # Find if mouse is over an item label |
735 item_idx = None |
735 item_idx = None |
785 # Mouse is outside graph figure, cursor move is in progress and |
785 # Mouse is outside graph figure, cursor move is in progress and |
786 # there is only one item in Viewer, start a drag'n drop |
786 # there is only one item in Viewer, start a drag'n drop |
787 elif self.MouseStartPos is not None and len(self.Items) == 1: |
787 elif self.MouseStartPos is not None and len(self.Items) == 1: |
788 xw, yw = self.GetPosition() |
788 xw, yw = self.GetPosition() |
789 self.ParentWindow.SetCursorTick(self.StartCursorTick) |
789 self.ParentWindow.SetCursorTick(self.StartCursorTick) |
790 self.ParentWindow.StartDragNDrop(self, |
790 self.ParentWindow.StartDragNDrop( |
791 self.ItemsDict.values()[0], |
791 self, self.ItemsDict.values()[0], |
792 # Current mouse position |
792 # Current mouse position |
793 event.x + xw, height - event.y + yw, |
793 event.x + xw, height - event.y + yw, |
794 # Mouse position when button was clicked |
794 # Mouse position when button was clicked |
795 self.MouseStartPos.x + xw, |
795 self.MouseStartPos.x + xw, |
796 self.MouseStartPos.y + yw) |
796 self.MouseStartPos.y + yw) |
886 @return: wx.Size containing Viewer minimum size |
886 @return: wx.Size containing Viewer minimum size |
887 """ |
887 """ |
888 # The minimum height take in account the height of all items, padding |
888 # The minimum height take in account the height of all items, padding |
889 # inside figure and border around figure |
889 # inside figure and border around figure |
890 return wx.Size(200, |
890 return wx.Size(200, |
891 CANVAS_BORDER[0] + CANVAS_BORDER[1] + |
891 CANVAS_BORDER[0] + CANVAS_BORDER[1] + |
892 2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) |
892 2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) |
893 |
893 |
894 def SetCanvasHeight(self, height): |
894 def SetCanvasHeight(self, height): |
895 """ |
895 """ |
896 Set Viewer size checking that it respects Viewer minimum size |
896 Set Viewer size checking that it respects Viewer minimum size |
897 @param height: Viewer height |
897 @param height: Viewer height |