[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/src/forms LayoutEditor.py
From: |
James Thompson |
Subject: |
gnue/designer/src/forms LayoutEditor.py |
Date: |
Fri, 25 Jan 2002 01:32:44 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/01/25 01:32:44
Modified files:
designer/src/forms: LayoutEditor.py
Log message:
Switched from old mouse logic to drag and drop for layout editor
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/LayoutEditor.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gnue/designer/src/forms/LayoutEditor.py
diff -c gnue/designer/src/forms/LayoutEditor.py:1.3
gnue/designer/src/forms/LayoutEditor.py:1.4
*** gnue/designer/src/forms/LayoutEditor.py:1.3 Tue Jan 22 15:39:35 2002
--- gnue/designer/src/forms/LayoutEditor.py Fri Jan 25 01:32:44 2002
***************
*** 261,271 ****
EVT_CHAR(self.panel, self.keyTrap)
! EVT_LEFT_UP(self.panel, self.OnLeftUp)
! # EVT_LEFT_DOWN(self.panel, self.OnLeftDown)
EVT_RIGHT_UP(self.panel, self.OnRightUp)
- # EVT_MOTION(self.panel, self.OnMotion)
-
def __drawItem(self, object):
if self.widgets.has_key(object.getObjectType()) and \
--- 261,269 ----
EVT_CHAR(self.panel, self.keyTrap)
! ## TODO: I Don't think this is needed anymore (jamest)
! ## EVT_LEFT_UP(self.panel, self.OnLeftUp)
EVT_RIGHT_UP(self.panel, self.OnRightUp)
def __drawItem(self, object):
if self.widgets.has_key(object.getObjectType()) and \
***************
*** 303,367 ****
self._instance.onSetCurrentObject(b, None)
! def OnLeftUp(self, event):
!
! if self.mode == 'move':
! return
!
! x, y = event.GetPositionTuple()
!
! x = int(x / self.gridWidth)
! y = int(y / self.gridHeight)
!
! mode = self.mode
! self.toolbar.resetTool(mode)
! self.mode = 'move'
! type = None
! attributes = {'x':x,'y':y}
! parent = self.block
! checkblock = 1
!
! if mode in ('box','button','label'):
! parent = self.page
! type = mode
! checkblock = 0
!
! elif modeEntryMap.has_key(mode):
! type = 'entry'
! attributes.update(modeEntryMap[mode])
!
! elif mode in ('scrollbar',):
! type = 'scrollbar'
!
!
! # Create a new block if one is needed and none exists
! if checkblock and self.block is None:
!
! parent = Incubator.createObject(
! self._instance,
! self._instance.rootObject,
! 'block',
! parent=self.page,
! attributes={})
!
!
! if type is not None:
! #
! # Create our new object
! #
! Incubator.createObject(
! self._instance,
! self._instance.rootObject,
! type,
! parent=parent,
! attributes=attributes)
! event.Skip()
def OnRightUp(self, event):
self.toolbar.resetTool(self.mode)
self.mode = 'move'
--- 301,368 ----
self._instance.onSetCurrentObject(b, None)
! ## TODO: I Don't think this is needed anymore (jamest)
! ## def OnLeftUp(self, event):
! ## if self.mode == 'move':
! ## event.Skip()
! ## return
!
! ## x, y = event.GetPositionTuple()
!
! ## x = int(x / self.gridWidth)
! ## y = int(y / self.gridHeight)
!
! ## mode = self.mode
! ## self.toolbar.resetTool(mode)
! ## self.mode = 'move'
!
! ## type = None
! ## attributes = {'x':x,'y':y}
! ## parent = self.block
! ## checkblock = 1
!
! ## if mode in ('box','button','label'):
! ## parent = self.page
! ## type = mode
! ## checkblock = 0
!
! ## elif modeEntryMap.has_key(mode):
! ## type = 'entry'
! ## attributes.update(modeEntryMap[mode])
!
! ## elif mode in ('scrollbar',):
! ## type = 'scrollbar'
!
!
! ## # Create a new block if one is needed and none exists
! ## if checkblock and self.block is None:
!
! ## parent = Incubator.createObject(
! ## self._instance,
! ## self._instance.rootObject,
! ## 'block',
! ## parent=self.page,
! ## attributes={})
!
!
! ## if type is not None:
! ## #
! ## # Create our new object
! ## #
! ## Incubator.createObject(
! ## self._instance,
! ## self._instance.rootObject,
! ## type,
! ## parent=parent,
! ## attributes=attributes)
! ## event.Skip()
def OnRightUp(self, event):
+
self.toolbar.resetTool(self.mode)
self.mode = 'move'
***************
*** 501,548 ****
def OnLeftDown(self, event):
self.mouseStartX, self.mouseStartY = event.GetPositionTuple()
! if not event.ShiftDown():
for selection in self.instance._currentSelection.keys():
selection.setSelected(0)
self.instance._currentSelection = {}
selection = self
! if self.instance._currentSelection.has_key(selection):
del self.instance._currentSelection[selection]
selection.setSelected(0)
! else:
self.instance._currentSelection[selection] = 1
self.instance._instance.onSetCurrentObject(selection.object,__name__)
selection.setSelected(1)
def OnLeftUp(self, event):
pass
# self.instance.panel.ReleaseMouse()
def OnMotion(self, event):
! if event.Dragging() and event.LeftIsDown():
! xshift = 0
! yshift = 0
! x, y = event.GetPositionTuple()
! positionWidget = wxPyTypeCast(event.GetEventObject(),'wxWindow')
! relativeX = x - self.mouseStartX
! relativeY = y - self.mouseStartY
- # GDebug.printMesg(0, 'Start XY %s, %s Current X,Y %s, %s Movement %s,
%s' %
- # (self.mouseStartX,self.mouseStartY,
x,y,relativeX,relativeY))
! if abs(relativeX) > self.instance.gridWidth/2:
! xshift = (abs(relativeX)/relativeX)
! if abs(relativeY) > self.instance.gridHeight/2:
! yshift = (abs(relativeY)/relativeY)
! if xshift or yshift:
! # GDebug.printMesg(0, 'Shift Start XY %s, %s Movement %s, %s Shift
%s,%s' %
! # (self.mouseStartX,self.mouseStartY,
relativeX,relativeY,xshift,yshift))
! self.relativeMove(xshift,yshift)
def OnRightDown(self, event):
pass
--- 502,570 ----
def OnLeftDown(self, event):
self.mouseStartX, self.mouseStartY = event.GetPositionTuple()
! if not event.ShiftDown(): # Select only 1
widget
for selection in self.instance._currentSelection.keys():
selection.setSelected(0)
self.instance._currentSelection = {}
selection = self
! if self.instance._currentSelection.has_key(selection): # Remove widget
from selection hash
del self.instance._currentSelection[selection]
selection.setSelected(0)
! else: # Add widget to
selection hash
self.instance._currentSelection[selection] = 1
self.instance._instance.onSetCurrentObject(selection.object,__name__)
selection.setSelected(1)
+ # Drag and drop TODO: This needs changed to pull all selected widgets
+
+ object = self.object
+
+ data = [ { "Type" : "selectedWidgets",
+ "Attributes": {'startingX': object.x,
+ 'startingY': object.y,
+ }
+ }]
+ # "name": dname,
+ # "table": object.name,
+ # "database": self.connectionName } }
+ #
+ #
+ do = wxCustomDataObject(wxCustomDataFormat("GNUeDesVisualElement"))
+ do.SetData(cPickle.dumps(data,1))
+
+ dropSource = wxDropSource(self.instance)
+ dropSource.SetData(do)
+ result = dropSource.DoDragDrop(false)
+
+
+
def OnLeftUp(self, event):
pass
# self.instance.panel.ReleaseMouse()
def OnMotion(self, event):
! pass
! # TODO : Disable old mouse support
! ## if event.Dragging() and event.LeftIsDown():
! ## xshift = 0
! ## yshift = 0
! ## x, y = event.GetPositionTuple()
! ## positionWidget = wxPyTypeCast(event.GetEventObject(),'wxWindow')
! ## relativeX = x - self.mouseStartX
! ## relativeY = y - self.mouseStartY
! ## if abs(relativeX) > self.instance.gridWidth/2:
! ## xshift = (abs(relativeX)/relativeX)
! ## if abs(relativeY) > self.instance.gridHeight/2:
! ## yshift = (abs(relativeY)/relativeY)
! ## if xshift or yshift:
! ## self.relativeMove(xshift,yshift)
def OnRightDown(self, event):
pass
***************
*** 961,967 ****
nextY = int(y / self.editor.gridHeight)
for params in unpickled:
-
x = int(x / self.editor.gridWidth)
y = nextY
--- 983,988 ----
***************
*** 1057,1062 ****
--- 1078,1088 ----
elif params['Type'] in ('block',):
parent = self.editor.page
+ elif params['Type'] in ('selectedWidgets',):
+ xshift = x - int(attributes['startingX'])
+ yshift = y - int(attributes['startingY'])
+ for uiwidget in self.editor._currentSelection.keys():
+ uiwidget.relativeMove(xshift,yshift)
else:
parent = self.editor.page
nextY += 1
***************
*** 1064,1078 ****
attributes['x'] = x
attributes['y'] = y
#
# Create our new object
#
! Incubator.createObject(
! self.editor._instance,
! self.editor._instance.rootObject,
! params['Type'],
! parent=parent,
! attributes=attributes)
return d # what is returned signals the source what to do
--- 1090,1107 ----
attributes['x'] = x
attributes['y'] = y
+
+
#
# Create our new object
#
! if not params['Type'] in ('selectedWidgets',):
! Incubator.createObject(
! self.editor._instance,
! self.editor._instance.rootObject,
! params['Type'],
! parent=parent,
! attributes=attributes)
return d # what is returned signals the source what to do
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/22
- gnue/designer/src/forms LayoutEditor.py,
James Thompson <=
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/25
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/25
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/25
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/26
- gnue/designer/src/forms LayoutEditor.py, Jason Cater, 2002/01/26