[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/src LayoutEditor.py
From: |
Jason Cater |
Subject: |
gnue/designer/src LayoutEditor.py |
Date: |
Sun, 04 Nov 2001 11:44:33 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/11/04 11:44:33
Modified files:
designer/src : LayoutEditor.py
Log message:
changes to mouse movement routines
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/LayoutEditor.py.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text
Patches:
Index: gnue/designer/src/LayoutEditor.py
diff -u gnue/designer/src/LayoutEditor.py:1.21
gnue/designer/src/LayoutEditor.py:1.22
--- gnue/designer/src/LayoutEditor.py:1.21 Sun Nov 4 10:54:24 2001
+++ gnue/designer/src/LayoutEditor.py Sun Nov 4 11:44:33 2001
@@ -51,7 +51,7 @@
# TODO: reasonable values based on size and position of self.panel
self.workspace = wxScrolledWindow(self, -1, pos=wxPoint(0,32),
style=wxCLIP_CHILDREN|wxHSCROLL|wxVSCROLL)
- # TODO: There must be a better way of calculating a lighter shade
+ # TODO: There must be a better way of calculating a lighter shade
# TODO: for the workspace. What happens if a color value > (255-32)?
self.workspace.SetBackgroundColour(wxColour(self.panelColor.Red()+32,
self.panelColor.Green()+32,
@@ -84,7 +84,7 @@
self.getPages()
self._setCurrentPage(object)
- def _setCurrentPage(self, object):
+ def _setCurrentPage(self, object):
if isinstance(object, GFObjects.GFPage) and object != self.page:
if self.panel != None:
self.panel.Destroy()
@@ -104,7 +104,7 @@
if object == None:
return
if handler != __name__:
- if object.findParentOfType('GFPage') == self.page:
+ if object.findParentOfType('GFPage') == self.page:
self.__getBlocks(object)
self.__drawItem(object)
@@ -112,27 +112,27 @@
self.getPages()
def onModifyObject (self, object, handler, modifications):
- if object == None:
+ if object == None:
return
self.propBar.onModifyObject(object, handler, modifications)
if handler != __name__:
- if object in (self._form, self.page) or object in self.widgetList:
+ if object in (self._form, self.page) or object in self.widgetList:
self.drawPage(self.page)
def onDeleteObject (self, object, handler):
- if object == None:
+ if object == None:
return
if handler != __name__:
if hasattr(object, '_widgetHandler') and object._widgetHandler != None:
object._widgetHandler.Destroy()
- def drawPage(self, page):
+ def drawPage(self, page):
self._currentSelection = {}
self.page = page
self.panel = GridPane(self, self.workspace, wxPoint(10,12))
self.panelColor = self.panel.GetBackgroundColour()
self.panelGridColor = wxColour(self.panelColor.Red()+16,
- self.panelColor.Green()+16,
+ self.panelColor.Green()+16,
self.panelColor.Blue()+16)
UIwxpython.initFont(self.panel)
@@ -141,7 +141,7 @@
# need to add string.punctionation if we dump python 1.5.2
checkchars = string.letters+string.digits+"-\|"
- for letter in checkchars:
+ for letter in checkchars:
width,height,descent,leading = self.panel.GetFullTextExtent(letter)
maxWidth = maxWidth > width and maxWidth or width
maxHeight = maxHeight > height and maxHeight or height
@@ -168,7 +168,7 @@
self.menu_sb_space=2 # the extra spaces needed by the menu, toolbar and
statusbar
- self.panel.SetClientSize(wxSize(int(width)*int(self.widgetWidth),
+ self.panel.SetClientSize(wxSize(int(width)*int(self.widgetWidth),
int(height)*int(self.widgetHeight)))
self.panel.Refresh()
@@ -182,13 +182,13 @@
# 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)
+ EVT_MOTION(self.panel, self.OnMotion)
def getPages(self):
self.pageCombo.Clear()
i = 0
selected = 0
- for p in self._instance._pages:
+ for p in self._instance._pages:
if p == self.page:
selected = i
self.pageCombo.Append(p.name)
@@ -196,7 +196,7 @@
self.pageCombo.SetSelection(selected)
- def getBlocks(self):
+ def getBlocks(self):
self.blockCombo.Clear()
self.blockList = []
self.page.walk(self.__getBlocks)
@@ -212,7 +212,7 @@
(not hasattr(object, 'hidden') or not object.hidden):
if hasattr(object, 'name'):
GDebug.printMesg(7, 'Drawing item %s of type %s' % (object.name,
object.getObjectType()))
- else:
+ else:
GDebug.printMesg(7, 'Drawing item of type %s' %
(object.getObjectType()))
object._widgetHandler = WidgetHandler(self, object)
object._widget = self.widgets[object.getObjectType()]\
@@ -225,28 +225,28 @@
object._widgetHandler.setSelected(0)
self.widgetList.append(object)
- def OnSize(self, event):
+ def OnSize(self, event):
self.toolpanel.SetSize(wxSize(self.GetClientSize().x,
self.toolpanel.GetSize().y))
self.propBar.SetSize(wxSize(self.GetClientSize().x,
self.propBar.GetSize().y))
self.propBar.SetPosition(wxPoint(0, self.GetClientSize().y -
self.propBar.GetSize().y))
self.workspace.SetSize(wxSize(self.GetClientSize().x,
self.GetClientSize().y - self.toolpanel.GetSize().y - self.propBar.GetSize().y))
- def OnPageSelected(self, event):
+ def OnPageSelected(self, event):
p = self._instance._pages[event.GetSelection()]
if p != self.page:
self._instance.onSetCurrentObject(p, __name__)
self._setCurrentPage(p)
- def OnBlockSelected(self, event):
+ def OnBlockSelected(self, event):
b = self.blockList[event.GetSelection()]
# if p != self.page:
self._instance.onSetCurrentObject(b, None)
-
-
- def OnRightUp(self, event):
- x, y = event.GetPositionTuple()
+
+ def OnRightUp(self, event):
+ x, y = event.GetPositionTuple()
+
x = int(x / self.gridWidth)
y = int(y / self.gridHeight)
@@ -267,57 +267,85 @@
self.panel.PopupMenu(menu, event.GetPosition())
- def OnMotion(self, event):
- if event.Dragging() and event.LeftIsDown():
- pos = event.GetPositionTuple()
- print pos
- pass
-
def keyTrap(self, event):
if event.KeyCode() in (WXK_LEFT, WXK_RIGHT, WXK_UP, WXK_DOWN) and \
len(self._currentSelection.keys()):
if event.AltDown(): # or event.MetaDown():
if event.KeyCode() == WXK_LEFT:
- for widget in self._currentSelection.keys():
+ for widget in self._currentSelection.keys():
widget.relativeResize(-1,0)
if event.KeyCode() == WXK_RIGHT:
- for widget in self._currentSelection.keys():
+ for widget in self._currentSelection.keys():
widget.relativeResize(1,0)
- if event.KeyCode() == WXK_UP:
- for widget in self._currentSelection.keys():
+ if event.KeyCode() == WXK_UP:
+ for widget in self._currentSelection.keys():
widget.relativeResize(0,-1)
if event.KeyCode() == WXK_DOWN:
- for widget in self._currentSelection.keys():
+ for widget in self._currentSelection.keys():
widget.relativeResize(0,1)
- else:
- if event.KeyCode() == WXK_LEFT:
- for widget in self._currentSelection.keys():
+ else:
+ if event.KeyCode() == WXK_LEFT:
+ for widget in self._currentSelection.keys():
widget.relativeMove(-1,0)
if event.KeyCode() == WXK_RIGHT:
- for widget in self._currentSelection.keys():
+ for widget in self._currentSelection.keys():
widget.relativeMove(1,0)
- if event.KeyCode() == WXK_UP:
- for widget in self._currentSelection.keys():
+ if event.KeyCode() == WXK_UP:
+ for widget in self._currentSelection.keys():
widget.relativeMove(0,-1)
if event.KeyCode() == WXK_DOWN:
- for widget in self._currentSelection.keys():
+ for widget in self._currentSelection.keys():
widget.relativeMove(0,1)
+ def OnMotion(self, event):
+ if event.Dragging() and event.LeftIsDown():
+
+ xshift = 0
+ yshift = 0
+
+ x, y = event.GetPositionTuple()
+# dx, dy = self.mouseWidget.widget.GetPositionTuple()
+# relativeX = self.mouseStartX - dx - x
+# relativeY = self.mouseStartY - dy - y
+ relativeX = self.mouseStartX - x
+ relativeY = self.mouseStartY - y
+ 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.gridWidth:
+ xshift = (abs(relativeX)/relativeX) * -1 #(abs(relativeX)/4)
+ if abs(relativeY) > self.gridHeight:
+ yshift = (abs(relativeY)/relativeY) * -1 #(abs(relativeY)/4)
+
+ 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.mouseWidget.relativeMove(xshift,yshift)
+
+# self.mouseWidget.mainWidget.widgets[0].WarpPointer(self.mouseStartX +
xshift*self.gridWidth,
+#
self.mouseStartY+yshift*self.gridHeight)
+#
self.mouseWidget.mainWidget.widgets[0].WarpPointer(self.mouseStartX,self.mouseStartY)
+ self.mouseWidget.mainWidget.widgets[0].WarpPointer(x,y)
+
+ self.mouseStartX = x
+ self.mouseStartY = y
+
+
#
#
#
-class WidgetHandler(wxEvtHandler):
- def __init__(self, instance, object):
+class WidgetHandler(wxEvtHandler):
+ def __init__(self, instance, object):
wxEvtHandler.__init__(self)
self.instance = instance
- self.object = object
+ self.object = object
self.hasFocus = 0
self.highlightBox = WidgetHighlighter(self.instance.panel)
- def initialize(self, widget):
+ def initialize(self, widget):
self.widget = widget.widgets[0]
- self.mainWidget = widget
+ self.mainWidget = widget
self.recalcBoundaries()
@@ -332,7 +360,7 @@
self.setAllChildren(EVT_LEFT_DOWN, widget, self.OnLeftDown)
self.setAllChildren(EVT_RIGHT_DOWN, widget, self.OnRightDown)
self.setAllChildren(EVT_RIGHT_UP, widget, self.OnRightUp)
- self.setAllChildren(EVT_MOTION, widget, self.OnMotion)
+# self.setAllChildren(EVT_MOTION, widget, self.instance.OnMotion)
self.setAllChildren(EVT_LEFT_DCLICK, widget, self.OnEditProperties)
self.setAllChildren(EVT_KEY_UP, self.highlightBox, self.instance.keyTrap)
self.setAllChildren(EVT_SET_FOCUS, self.highlightBox, self.focusGainedTrap)
@@ -340,113 +368,86 @@
self.setAllChildren(EVT_LEFT_UP, self.highlightBox, self.OnLeftUp)
self.setAllChildren(EVT_LEFT_DOWN, self.highlightBox, self.OnLeftDown)
self.setAllChildren(EVT_RIGHT_UP, self.highlightBox, self.OnRightUp)
- self.setAllChildren(EVT_MOTION, self.highlightBox, self.instance.OnMotion)
+# self.setAllChildren(EVT_MOTION, self.highlightBox, self.instance.OnMotion)
- self.widget.Refresh()
+ self.widget.Refresh()
- def recalcBoundaries(self):
+ def recalcBoundaries(self):
x1,y1,x2,y2 = (9999999,9999999,0,0)
-
+
for widget in self.mainWidget.widgets:
tx, ty = widget.GetPositionTuple()
tw, th = widget.GetSizeTuple()
self.instance.positionMappings[widget] = [tx,ty,tx+tw-1,ty+tw-1,self]
- if tx < x1:
+ if tx < x1:
x1 = tx
- if ty < y1:
+ if ty < y1:
y1 = ty
- if tw + tx > x2:
+ if tw + tx > x2:
x2 = tw + tx
- if th + ty > y2:
+ if th + ty > y2:
y2 = th + ty
self.highlightBox.setBoundary(x1-2,y1-2,x2+2,y2+2)
- for widget in self.mainWidget.widgets:
+ for widget in self.mainWidget.widgets:
widget.Refresh()
- def setSelected(self, selected):
+ def setSelected(self, selected):
self.highlightBox.setSelected(selected)
def setAllChildren(self, event, widget, trap):
- try:
- event(widget, trap)
- except:
+ try:
+ event(widget, trap)
+ except:
pass
- for child in widget.GetChildren():
+ for child in widget.GetChildren():
self.setAllChildren(event, child, trap)
- def focusGainedTrap(self, event):
+ def focusGainedTrap(self, event):
self.instance.panel.SetFocus()
pass
# event.Skip()
- def focusLostTrap(self, event):
+ def focusLostTrap(self, event):
event.Skip()
- def OnLeftDown(self, event):
+ def OnLeftDown(self, event):
- self.mouseStartX, self.mouseStartY = event.GetPositionTuple()
+ x,y = event.GetPositionTuple()
+ dx,dy = self.widget.GetPositionTuple()
+ self.instance.mouseStartX, self.instance.mouseStartY = (dx+x,dy+y)
+ self.instance.mouseWidget = self
- if not event.ShiftDown():
- for selection in self.instance._currentSelection.keys():
+ 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):
+ if self.instance._currentSelection.has_key(selection):
del self.instance._currentSelection[selection]
selection.setSelected(0)
- else:
+ else:
self.instance._currentSelection[selection] = 1
self.instance._instance.onSetCurrentObject(selection.object,__name__)
selection.setSelected(1)
-
-
- def OnLeftUp(self, event):
+
+
+ def OnLeftUp(self, event):
pass
-# self.instance.panel.ReleaseMouse()
+# self.instance.panel.ReleaseMouse()
- def OnRightDown(self, event):
+ def OnRightDown(self, event):
pass
-
- def OnRightUp(self, event):
- pt = event.GetPositionTuple()
+
+ def OnRightUp(self, event):
+ pt = event.GetPositionTuple()
self.instance._instance.onSetCurrentObject(self.object, None)
wxPyTypeCast(event.GetEventObject(),'wxWindow') \
.PopupMenu(self.object._popupMenu, pt)
-
- def OnMotion(self, event):
- if event.Dragging() and event.LeftIsDown():
- xshift = 0
- yshift = 0
-
- x, y = event.GetPositionTuple()
- relativeX = self.mouseStartX - x
- relativeY = self.mouseStartY - y
- 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) > 4:
- xshift = (abs(relativeX)/relativeX) * -1 #(abs(relativeX)/4)
- if abs(relativeY) > 4:
- yshift = (abs(relativeY)/relativeY) * -1 #(abs(relativeY)/4)
-
- 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)
-
- self.mainWidget.widgets[0].WarpPointer(self.mouseStartX,#
xshift*self.instance.gridWidth,
-
self.mouseStartY+yshift*self.instance.gridHeight)
-#
self.mainWidget.widgets[0].WarpPointer(self.mouseStartX,self.mouseStartY)
-# self.mainWidget.widgets[0].WarpPointer(x,y)
-
- #self.mouseStartX = x
- #self.mouseStartY = y
-
- def OnEditProperties(self, event):
+ def OnEditProperties(self, event):
self.instance._instance.propertyEditorWindow.Show(1)
self.instance._instance.propertyEditorWindow.Raise()
self.instance._instance.propertyEditorWindow.SetFocus()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/designer/src LayoutEditor.py,
Jason Cater <=