/[gnue]/gnue-designer/src/forms/LayoutEditor/LayoutEditor.py
ViewVC logotype

Diff of /gnue-designer/src/forms/LayoutEditor/LayoutEditor.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.93 by jcater, Tue Jul 15 22:21:15 2003 UTC revision 1.94 by jcater, Tue Aug 12 22:45:13 2003 UTC
# Line 44  from GridPane import GridPane Line 44  from GridPane import GridPane
44  from WidgetHandler import WidgetHandler  from WidgetHandler import WidgetHandler
45  from PropertyBar import PropertyBar  from PropertyBar import PropertyBar
46  from DisplayDropTarget import DisplayDropTarget  from DisplayDropTarget import DisplayDropTarget
47    from ReorderFocus import ReorderFocus
48    
49  class LayoutEditor (ToolBase):  class LayoutEditor (ToolBase):
50    
# Line 91  class LayoutEditor (ToolBase): Line 91  class LayoutEditor (ToolBase):
91    
92      self._currentObject = None      self._currentObject = None
93      self.mode = 'move'      self.mode = 'move'
94        self.reorderfocus = ReorderFocus(self.instance)
95    
96      # Internal mouse states... used by OnMotion, etc      # Internal mouse states... used by OnMotion, etc
97      self.__drawing = 0      self.__drawing = 0
# Line 107  class LayoutEditor (ToolBase): Line 108  class LayoutEditor (ToolBase):
108                         'ObjectDeleted'       : self.onDeleteObject,                         'ObjectDeleted'       : self.onDeleteObject,
109                         'LayoutEditor:ZoomIn' : self.zoomIn,                         'LayoutEditor:ZoomIn' : self.zoomIn,
110                         'LayoutEditor:ZoomOut': self.zoomOut,                         'LayoutEditor:ZoomOut': self.zoomOut,
111                           'LayoutEditor:FocusOrder': self.beginFocusOrder,
112                           'Cancel:LayoutEditor:FocusOrder': self.endFocusOrder,
113                           'LayoutEditor:Prepositioning': self.beginPrePositioningTemplate,
114                           'Cancel:LayoutEditor:Prepositioning': self.cancelPrePositioningTemplate,
115                           'LayoutEditor:Select': self.beginSelectMode,
116                           'Cancel:LayoutEditor:Select': self.cancelSelectMode,
117                           'EndWizard': self.endWizard,
118                        })                        })
119    
120      self.instance.rootObject.walk (self.inventoryObject)      self.instance.rootObject.walk (self.inventoryObject)
# Line 115  class LayoutEditor (ToolBase): Line 123  class LayoutEditor (ToolBase):
123      except KeyError:      except KeyError:
124        pass        pass
125    
   
126      ## Stuff needed by UIwxpython      ## Stuff needed by UIwxpython
127      self._pageList = []  # Needed by UIwxpython      self._pageList = []  # Needed by UIwxpython
128    
# Line 502  class LayoutEditor (ToolBase): Line 509  class LayoutEditor (ToolBase):
509      self.__OnGridSize(None)      self.__OnGridSize(None)
510    
511    def OnLeftDown(self, event):    def OnLeftDown(self, event):
     # Save starting coordinates for cross-selection box  
512      x, y = event.GetPositionTuple()      x, y = event.GetPositionTuple()
513        self.handleLeftDown(x,y)
514        event.Skip()
515    
516    
517      def handleLeftDown(self, x, y):
518      self.__drawing = 1      self.__drawing = 1
519    
520        # Save starting coordinates for cross-selection box
521      self.__cx = cx = int(x / self.gridWidth)      self.__cx = cx = int(x / self.gridWidth)
522      self.__cy = cy = int(y / self.gridHeight)      self.__cy = cy = int(y / self.gridHeight)
523    
# Line 518  class LayoutEditor (ToolBase): Line 529  class LayoutEditor (ToolBase):
529      self.__y = y      self.__y = y
530      self.__ox = None      self.__ox = None
531      self.__oy = None      self.__oy = None
     event.Skip()  
532    
533    
534    # Used by the dragging routines to draw a selection box    # Used by the dragging routines to draw a selection box
# Line 562  class LayoutEditor (ToolBase): Line 572  class LayoutEditor (ToolBase):
572    
573    
574    def OnLeftUp(self, event):    def OnLeftUp(self, event):
575        x, y = event.GetPositionTuple()
576        self.handleLeftUp(x,y)
577        event.Skip()
578    
579    
580      def handleLeftUp(self, x, y):
581      selection = []      selection = []
582    
583      self.setFeedback('')      self.setFeedback('')
# Line 576  class LayoutEditor (ToolBase): Line 591  class LayoutEditor (ToolBase):
591      self.__drawing = 0      self.__drawing = 0
592    
593      # Set x1,y1 to be smaller coordinates, and x2,y2 to be larger      # Set x1,y1 to be smaller coordinates, and x2,y2 to be larger
     x, y = event.GetPositionTuple()  
594      x1, x2 = order(int(self.__x / self.gridWidth), int(x / self.gridWidth))      x1, x2 = order(int(self.__x / self.gridWidth), int(x / self.gridWidth))
595      y1, y2 = order(int(self.__y / self.gridHeight),int(y / self.gridHeight))      y1, y2 = order(int(self.__y / self.gridHeight),int(y / self.gridHeight))
596    
# Line 587  class LayoutEditor (ToolBase): Line 601  class LayoutEditor (ToolBase):
601    
602      areaSelected = (x1 <> x2 or y1 <> y2)      areaSelected = (x1 <> x2 or y1 <> y2)
603    
     event.Skip()  
   
604      if self.mode == 'move':      if self.mode == 'move':
605        if areaSelected:        if areaSelected:
606          # We are selecting an area          # We are selecting an area
# Line 633  class LayoutEditor (ToolBase): Line 645  class LayoutEditor (ToolBase):
645    def OnRightUp(self, event):    def OnRightUp(self, event):
646  ##    self.toolbar.resetTool(self.mode)  ##    self.toolbar.resetTool(self.mode)
647      self.mode = 'move'      self.mode = 'move'
648        self.dispatchEvent('LayoutEditor:Select')
649    
650      x, y = event.GetPositionTuple()      x, y = event.GetPositionTuple()
651    
# Line 731  class LayoutEditor (ToolBase): Line 744  class LayoutEditor (ToolBase):
744              break              break
745    
746    
   
   def startPrePositioningTemplate(self, template):  
     self.mode = 'positioning'  
     ##self.panel.SetCursor(wxCROSS_CURSOR)  
     wxSetCursor(wxCROSS_CURSOR)  
     self.__template = template  
   
   
   def endPrePositioningTemplate(self, x, y, width=None, height=None):  
     self.mode = 'move'  
     TemplateParser(self.instance, self.instance.rootObject,  
           self.instance, self.__template, currentObject=self.block or self.page).run(x=x, y=y,  
                                                width=width,  
                                                height=height)  
     self.instance.dispatchEvent(Event('EndWizard', template=self.__template))  
   
   
747    def zoomIn(self, event):    def zoomIn(self, event):
748      size = UIwxpython.getPointSize()      size = UIwxpython.getPointSize()
749      if size < 72:      if size < 72:
# Line 772  class LayoutEditor (ToolBase): Line 768  class LayoutEditor (ToolBase):
768        self.setFeedback(_('Cannot adjust point size to less than 6pt'))        self.setFeedback(_('Cannot adjust point size to less than 6pt'))
769    
770    
771      def beginPrePositioningTemplate(self, event):
772        mode = self.mode
773        self.mode = 'positioning'
774        if mode == 'move':
775          self.dispatchEvent('Cancel:LayoutEditor:Select')
776        elif mode == 'refocus':
777          self.dispatchEvent('Cancel:LayoutEditor:FocusOrder')
778    
779        ##self.panel.SetCursor(wxCROSS_CURSOR)
780        wxSetCursor(wxCROSS_CURSOR)
781        self.__wizardrunner = event.wizardrunner
782    
783      def cancelPrePositioningTemplate(self, event=None):
784        if self.mode == 'prepositioning':
785          self.__wizardrunner.cancel()
786        wxSetCursor(wxSTANDARD_CURSOR)
787    
788      def endPrePositioningTemplate(self, x, y, width=None, height=None):
789        self.mode = 'move'
790        self.dispatchEvent('Cancel:LayoutEditor:Prepositioning')
791        self.dispatchEvent('LayoutEditor:Select')
792        self.__wizardrunner.positioned_run(x=x, y=y, width=width, height=height)
793    
794    
795      def beginFocusOrder(self, event):
796        mode = self.mode
797        self.mode = 'refocus'
798        if mode == 'move':
799          event.dispatchAfter('Cancel:LayoutEditor:Select')
800        elif mode == 'positioning':
801          self.__wizardrunner.cancel()
802          # Yes, you are reading this right...
803          # I'm triggering the exact event that
804          # triggered this method. Blame it on
805          # the Tuesday night atmospheric crack
806          # levels.
807          self.dispatchEvent('LayoutEditor:FocusOrder')
808          return
809    
810        self.reorderfocus.start(self.page)
811    
812      def endFocusOrder(self, event):
813        self.reorderfocus.end()
814        if self.mode == 'refocus':
815          self.mode = 'move'
816          self.dispatchEvent('LayoutEditor:Select')
817    
818      def beginSelectMode(self, event=None):
819        mode = self.mode
820        self.mode = 'move'
821        if mode == 'refocus':
822          self.dispatchEvent('Cancel:LayoutEditor:FocusOrder')
823        elif mode == 'positioning':
824          self.dispatchEvent('Cancel:LayoutEditor:Prepositioning')
825    
826      def cancelSelectMode(self, event=None):
827        if self.mode == 'move':
828          event.dispatchAfter('LayoutEditor:Select')
829    
830      def endWizard(self, event=None):
831        mode = self.mode
832        self.mode = 'move'
833        if mode == 'refocus':
834          self.dispatchEvent('Cancel:LayoutEditor:FocusOrder')
835        elif mode == 'positioning':
836          self.dispatchEvent('Cancel:LayoutEditor:Prepositioning')
837        self.dispatchEvent('LayoutEditor:Select')
838    
839  class PrepositioningTimer(wxTimer):  class PrepositioningTimer(wxTimer):
840      def __init__(self, method, *args, **params):      def __init__(self, method, *args, **params):

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26