commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/designer/src Instance.py LayoutEditor.py P...


From: Jason Cater
Subject: gnue/designer/src Instance.py LayoutEditor.py P...
Date: Sun, 24 Jun 2001 19:59:30 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/06/24 19:59:30

Modified files:
        designer/src   : Instance.py LayoutEditor.py PropertyEditor.py 
Added files:
        designer/src   : TemplateBase.py 

Log message:
        Added a property bar on layout screen; fixed several layout bugs; 
restructured relative moving

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/TemplateBase.py?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/Instance.py.diff?cvsroot=OldCVS&tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/LayoutEditor.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/PropertyEditor.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gnue/designer/src/Instance.py
diff -u gnue/designer/src/Instance.py:1.12 gnue/designer/src/Instance.py:1.13
--- gnue/designer/src/Instance.py:1.12  Sat Jun 23 14:20:00 2001
+++ gnue/designer/src/Instance.py       Sun Jun 24 19:59:30 2001
@@ -90,9 +90,6 @@
     vsplitter = wxSplitterWindow (self, -1, style=wxSP_3D|wxNO_3D)
     vsplitter.SetMinimumPaneSize (100)
 
-#    hsplitter = wxSplitterWindow (vsplitter, -1, style=wxSP_3D|wxNO_3D)
-#    hsplitter.SetMinimumPaneSize (100)
-
     self._form.walk(self.inventoryLoadedItems)
 
     # Create our tools
@@ -114,15 +111,11 @@
                              self.eventEditor )
 
     self._currentPage = self._pages[0]
-#    hsplitter.SplitHorizontally (self.tree, self.propertyEditor)
     vsplitter.SplitVertically(self.tree, self.layoutEditor)
     vsplitter.SetSashPosition (
         RuntimeSettings.getint(self.runtime_section, 'vsash', 170), true)
     self.vsplitter = vsplitter
-#    self.hsplitter = hsplitter
     self.layoutEditor.drawPage(self._currentPage)
- #   hsplitter.SetSashPosition (
-#        RuntimeSettings.getint(self.runtime_section, 'hsash', 170), true)
     self.tree.Expand(self._form._treeItem)
 
     self._menubar.lastToolAdded()
@@ -130,7 +123,6 @@
     app.addInstance(self) 
 
     # Fit the widgets to the screen
-#    hsplitter.Fit()
     vsplitter.Fit()
     self.layoutEditor.Fit()
     self.Fit()
@@ -156,8 +148,8 @@
     x, y = self.GetPositionTuple()
     width, height = self.GetSizeTuple()
     return ( self.runtime_section, 
-             { 'x': x, 
-               'y': y, 
+             { 'x': abs(x), 
+               'y': abs(y), 
                'height': height, 
                'width': width, 
                'vsash': self.vsplitter.GetSashPosition()  } )
Index: gnue/designer/src/LayoutEditor.py
diff -u gnue/designer/src/LayoutEditor.py:1.7 
gnue/designer/src/LayoutEditor.py:1.8
--- gnue/designer/src/LayoutEditor.py:1.7       Sat Jun 23 14:20:00 2001
+++ gnue/designer/src/LayoutEditor.py   Sun Jun 24 19:59:30 2001
@@ -34,13 +34,10 @@
 from gnue.forms import GFObjects, GFTrigger, GFLibrary, UIwxpython
 
 
-class LayoutEditor (wxScrolledWindow): 
+class LayoutEditor (wxPanel): 
   def __init__(self, instance, parentWindow): 
-    wxScrolledWindow.__init__(self,parentWindow,-1,style=wxHSCROLL|wxVSCROLL)
+    wxPanel.__init__(self,parentWindow,-1)
     self.panelColor = self.GetBackgroundColour()
-    self.SetBackgroundColour(wxColour(self.panelColor.Red()+32,
-                 self.panelColor.Green()+32,    
-                 self.panelColor.Blue()+32))
     self._instance = instance
     self._form = instance._form
     self._app = instance._app
@@ -50,13 +47,23 @@
 
     self.toolpanel = wxPanel(self, -1, pos=wxPoint(0,0), size=wxSize(32,32), 
style=wxRAISED_BORDER|wxCLIP_CHILDREN)
 
+    # TODO: self.workspace needs to have SetScrollbars called with 
+    # 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: for the workspace. What happens if a color value > (255-32)?
+    self.workspace.SetBackgroundColour(wxColour(self.panelColor.Red()+32,
+                 self.panelColor.Green()+32,    
+                 self.panelColor.Blue()+32))
+
     self.page = None
     self.pageNameLabel = wxStaticText(self.toolpanel, -1, "Page: ", 
pos=wxPoint(4,6))
     self.pageCombo = wxComboBox(self.toolpanel, -1, 
pos=wxPoint(self.pageNameLabel.GetSize().width + 10,4), style=wxCB_READONLY)
     self.blockNameLabel = wxStaticText(self.toolpanel, -1, "Block:", 
pos=wxPoint(self.pageCombo.GetPosition().x + self.pageCombo.GetSize().width + 
20,6))
     self.blockCombo = wxComboBox(self.toolpanel, -1, 
pos=wxPoint(self.blockNameLabel.GetPosition().x + 
self.blockNameLabel.GetSize().width + 11,4), style=wxCB_READONLY)
 
-#    self.propBar = PropertyBar(self)
+    self.propBar = PropertyBar(self)
 
     EVT_COMBOBOX(self, self.pageCombo.GetId(), self.OnPageSelected)
     EVT_COMBOBOX(self, self.blockCombo.GetId(), self.OnBlockSelected)
@@ -70,6 +77,8 @@
       for o in self._currentSelection.keys():
         o.setSelected(0)
       return
+    if hasattr(object, '_widgetHandler'): 
+      self.propBar.setCurrentObject(object)
     if handler != __name__: 
       if isinstance(object, GFObjects.GFPage) and object != self.page: 
         if self.panel != None: 
@@ -99,6 +108,7 @@
   def onModifyObject (self, object, handler, modifications):
     if object == None: 
       return
+    self.propBar.onModifyObject(object, handler, modifications)
     if handler != __name__:
       if object == self.page or object in self.widgetList: 
         self.drawPage(self.page)
@@ -113,7 +123,7 @@
   def drawPage(self, page): 
     self._currentSelection = {}
     self.page = page
-    self.panel = GridPane(self, self, wxPoint(10,60))
+    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,    
@@ -213,10 +223,10 @@
 
   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.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): 
     p = self._instance._pages[event.GetSelection()]
     if p != self.page:
@@ -430,38 +440,28 @@
 
 
   def relativeMove(self, dx, dy): 
-    if dx == -1 and \
-       self.object.x > 0: 
-      self.object.x = self.object.x - 1 
-      for widget in self.mainWidget.widgets: 
-        x,y = widget.GetPositionTuple()
-        widget.SetPosition(wxPoint(x-self.instance.gridWidth,y))
-      self.instance._instance.onModifyObject(self.object, __name__, 
-          (('x', self.object.width)))
-    if dx == 1:
-      self.object.x = self.object.x + 1 
-      for widget in self.mainWidget.widgets: 
-        x,y = widget.GetPositionTuple()
-        widget.SetPosition(wxPoint(x+self.instance.gridWidth,y))
-      self.instance._instance.onModifyObject(self.object, __name__, 
-          (('x', self.object.width)))
-    if dy == -1 and \
-       self.object.y > 0: 
-      self.object.y = self.object.y - 1 
-      for widget in self.mainWidget.widgets: 
-        x,y = widget.GetPositionTuple()
-        widget.SetPosition(wxPoint(x,y-self.instance.gridHeight))
-      self.instance._instance.onModifyObject(self.object, __name__, 
-          (('y', self.object.width)))
-    if dy == 1:
-      self.object.y = self.object.y + 1 
+    if not (dx or dy): 
+      return 0
+
+    nx = dx * self.instance.gridWidth
+    ny = dy * self.instance.gridHeight
+
+    if (self.object.x + dx < 0 or self.object.y + dy < 0): 
+      return 0
+    else: 
       for widget in self.mainWidget.widgets: 
         x,y = widget.GetPositionTuple()
-        widget.SetPosition(wxPoint(x,y+self.instance.gridHeight))
-      self.instance._instance.onModifyObject(self.object, __name__, 
-          (('y', self.object.width)))
-    self.recalcBoundaries()
-
+        widget.SetPosition(wxPoint(x + nx,y + ny))
+      changes = []
+      if dx: 
+        self.object.x = self.object.x + dx
+        changes.append(['x',self.object.x])
+      if dy: 
+        self.object.y = self.object.y + dy
+        changes.append(['y',self.object.y])
+      self.instance._instance.onModifyObject(self.object, __name__, changes)
+      self.recalcBoundaries()
+ 
   def Destroy(self): 
     self.highlightBox.Destroy()
     for widget in self.mainWidget.widgets: 
@@ -476,7 +476,7 @@
     self.selected = 0
     self.parent = parent
     self.x1 = 1
-    self.y1 = 1
+    self.y1 = 1        
     self.x2 = 2
     self.y2 = 2
     self.west = None
@@ -602,26 +602,139 @@
     wxPanel.__init__(self, parent, -1, style=wxRAISED_BORDER|wxCLIP_CHILDREN)  
     self.parent = parent
     
-    self.nameLabel = wxStaticText(self, -1, "Name:", pos=wxPoint(4,4)) 
+    self.nameLabel = wxStaticText(self, -1, "Name:", pos=wxPoint(4,8)) 
     self.nameEditor = wxTextCtrl(self, -1,  
-          pos=calcRelPos(self.nameLabel, dx=4, dy=0))
+          pos=calcRelPos(self.nameLabel, dx=6, absy=4))
     self.typeLabel = wxStaticText(self, -1, "Class:", 
-          pos=calcRelPos(self.nameLabel, absx=4, dy=4))
-    self.nameEditor = wxTextCtrl(self, -1,  
-          pos=calcRelPos(self.nameLabel, dx=4, dy=4))
-    self.xLabel = wxSpinCtrl(self, -1, "x:",
-          pos=calcRelPos(self.nameEditor, dx=4, absy=4))
+          pos=calcRelPos(self.nameEditor, absx=4, dy=8))
+    self.typeEditor = wxTextCtrl(self, -1,  
+          pos=calcRelPos(self.nameLabel, self.nameEditor, dx=6, dy=4))
+    self.typeEditor.SetEditable(0)
+
+    self.xLabel = wxStaticText(self, -1, "x:",
+          pos=calcRelPos(self.nameEditor, dx=10, absy=8))
     self.xEditor = wxSpinCtrl(self, -1, 
-          pos=calcRelPos(self.xLabel, dx=4, absy=4))
+          pos=calcRelPos(self.xLabel, dx=4, absy=6))
+    self.xEditor.SetSize((50, self.xEditor.GetSize().height))
 
+    self.wLabel = wxStaticText(self, -1, "Width:  ",
+          pos=calcRelPos(self.xEditor, dx=6, absy=8))
+    self.wEditor = wxSpinCtrl(self, -1, 
+          pos=calcRelPos(self.wLabel, dx=4, absy=6))
+    self.wEditor.SetSize(self.xEditor.GetSize())
+
+    self.yLabel = wxStaticText(self, -1, "y:",
+          pos=calcRelPos(self.nameEditor, self.xEditor, dx=10, dy=8))
+    self.yEditor = wxSpinCtrl(self, -1, 
+          pos=calcRelPos(self.xLabel, self.xEditor, dx=4, dy=6))
+    self.yEditor.SetSize(self.xEditor.GetSize())
+
+    self.hLabel = wxStaticText(self, -1, "Height:",
+          pos=calcRelPos(self.xEditor, self.wEditor, dx=6, dy=8))
+    self.hEditor = wxSpinCtrl(self, -1, 
+          pos=calcRelPos(self.wLabel, self.wEditor, dx=4, dy=6))
+    self.hEditor.SetSize(self.wEditor.GetSize())
+
     self.Fit()
+
+    EVT_SPINCTRL(self, self.xEditor.GetId(), self.OnXUpdated)
+    EVT_SPINCTRL(self, self.yEditor.GetId(), self.OnYUpdated)
     
 
+  def OnNameUpdated(self, event): 
+    self.object.name = self.nameEditor.GetValue()
+#    self.parent._instance.onModifyObject(self.object, __name__, 
+
+  def OnXUpdated(self, event): 
+    if hasattr(self.object, 'x'):
+      dx = self.xEditor.GetValue() - self.object.x
+      if dx: 
+        self.object._widgetHandler.relativeMove(dx,0)
+    else: 
+      self.xEditor.SetValue(0)
+
+  def OnYUpdated(self, event): 
+    if hasattr(self.object, 'y'):
+      dy = self.yEditor.GetValue() - self.object.y
+      if dy: 
+        self.object._widgetHandler.relativeMove(0, dy)
+    else: 
+      self.xEditor.SetValue(0)
+
   def setCurrentObject(self, object): 
-    pass
+    self.object = object
+   
+    self.typeEditor.SetValue(object.getObjectType()[2:])
+
+    if hasattr(object, 'x'): 
+      self.xEditor.SetValue(object.x)
+#      self.xEditor.SetEditable(1)
+    else: 
+      self.xEditor.SetValue(0)
+#      self.xEditor.SetEditable(0)
+
+    if hasattr(object, 'y'): 
+      self.yEditor.SetValue(object.y)
+#      self.yEditor.SetEditable(1)
+    else: 
+      self.yEditor.SetValue(0)
+#      self.yEditor.SetEditable(0)
+
+    if hasattr(object, 'width'): 
+      self.wEditor.SetValue(object.width)
+#      self.wEditor.SetEditable(1)
+    else: 
+      self.wEditor.SetValue(0)
+#      self.wEditor.SetEditable(0)
+
+    if hasattr(object, 'height'): 
+      self.hEditor.SetValue(object.height)
+#      self.hEditor.SetEditable(1)
+    else: 
+      self.hEditor.SetValue(0)
+#      self.hEditor.SetEditable(0)
+
+    if hasattr(object, 'name'): 
+      self.nameEditor.SetValue(object.name)
+      self.nameEditor.SetEditable(0)
+    else: 
+      self.nameEditor.SetValue(0)
+      self.nameEditor.SetEditable(0)
     
+  def onModifyObject (self, object, handler, modifications):
+    if object == None: 
+      return
+    if object == self.object: 
+      for modification in modifications: 
+        field, value = modification
+        if field == 'x': 
+          self.xEditor.SetValue(value)
+        elif field == 'y': 
+          self.yEditor.SetValue(value)
+        elif field == 'width': 
+          self.wEditor.SetValue(value)
+        elif field == 'height': 
+          self.hEditor.SetValue(value)
+        elif field == 'name': 
+          self.nameEditor.SetValue(value)
+
+
+def calcRelPos(xsource, ysource=None, absx=None, absy=None, dx=None, dy=None): 
+  if ysource == None: 
+    ysource = xsource
+  x = xsource.GetPosition().x
+  y = ysource.GetPosition().y
+  w = xsource.GetSize().width
+  h = ysource.GetSize().height
+
+  if absx != None: 
+    x = absx
+  else: 
+    x = x + w + dx
+
+  if absy != None: 
+    y = absy
+  else: 
+    y = y + h + dy
 
-def calcRelPos(source, absx=0, absy=0, dx=0, dy=0): 
-  x, y = source.GetPositionTuple()
-  w, h = source.GetSizeTuple() 
-  return wxPoint (absx or (x + w + dx), absy or (y + h + dy)) 
+  return wxPoint (x,y) 
Index: gnue/designer/src/PropertyEditor.py
diff -u gnue/designer/src/PropertyEditor.py:1.5 
gnue/designer/src/PropertyEditor.py:1.6
--- gnue/designer/src/PropertyEditor.py:1.5     Sat Jun 23 14:20:00 2001
+++ gnue/designer/src/PropertyEditor.py Sun Jun 24 19:59:30 2001
@@ -44,6 +44,7 @@
     self.parent = parent
     self.instance = instance
     self.form = form
+    self.object = None
     self.objectList = []
     self.objectMap = {}
     self.grid = wxGrid(self.panel, -1, pos=wxPoint(0,0))
@@ -123,6 +124,7 @@
     self.form = form
     self.objectList = []
     self.objectMap = {}
+    self.object = None
     self.grid = wxGrid(self.panel, -1, pos=wxPoint(0,0))
     EVT_SIZE(self, self.onSize)
 
@@ -275,13 +277,9 @@
     if object == None: 
       return
 
-    # All we need to monitor is a name change
-    if handler != __name__ and self.object == object:
-      for modification in modifications: 
-        attribute, value = modification
-        if attribute == 'name': 
-          self.objectTree[self.objectMap['name']] = modification
-          self.generateObjectMap()
+    # TODO: This should see if object is listed in 
+    # TODO: the pull-down box. If so, monitor for 
+    # TODO: name change.
 
   def onDeleteObject (self, object, handler):
     if object == None: 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]