commit-gnue
[Top][All Lists]
Advanced

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

gnue/gnuef/designer/src Incubator.py Instance.p...


From: Jason Cater
Subject: gnue/gnuef/designer/src Incubator.py Instance.p...
Date: Sat, 23 Jun 2001 14:20:00 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/06/23 14:20:00

Modified files:
        gnuef/designer/src: Incubator.py Instance.py LayoutEditor.py 
                            PropertyEditor.py 

Log message:
        Added fix for 'hidden' fields

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/designer/src/Incubator.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/designer/src/Instance.py.diff?cvsroot=OldCVS&tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/designer/src/LayoutEditor.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/designer/src/PropertyEditor.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/gnuef/designer/src/Incubator.py
diff -u gnue/gnuef/designer/src/Incubator.py:1.4 
gnue/gnuef/designer/src/Incubator.py:1.5
--- gnue/gnuef/designer/src/Incubator.py:1.4    Thu Jun 21 19:36:28 2001
+++ gnue/gnuef/designer/src/Incubator.py        Sat Jun 23 14:20:00 2001
@@ -63,10 +63,14 @@
     if not attributes.has_key(attr): 
       if attrs[attr][3] != None: 
         attributes[attr] = attrs[attr][2](attrs[attr][3])
-      elif attr in ('x','y','height'): 
-        attributes[attr] = 1 
+      elif attr in ('x','y',): 
+        attributes[attr] = 0
+      elif attr in ('height',): 
+        attributes[attr] = 1
       elif attr == 'width': 
         attributes[attr] = 10 
+      elif attr in ('text','label'): 
+        attributes[attr] = name
 
   for attr in attributes.keys(): 
     if attrs.has_key(attr): 
Index: gnue/gnuef/designer/src/Instance.py
diff -u gnue/gnuef/designer/src/Instance.py:1.11 
gnue/gnuef/designer/src/Instance.py:1.12
--- gnue/gnuef/designer/src/Instance.py:1.11    Fri Jun 22 06:16:35 2001
+++ gnue/gnuef/designer/src/Instance.py Sat Jun 23 14:20:00 2001
@@ -103,15 +103,15 @@
 
     self.propertyEditorWindow = PropertyToolFrame(self, "Property Editor")
     self.propertyEditor = self.propertyEditorWindow.propertyEditor
-#    self.eventEditor = self.propertyEditorWindow.eventEditor
+    self.eventEditor = self.propertyEditorWindow.eventEditor
 
     # Store all 
     self.objectListeners = ( self.tree, 
                              self.layoutEditor, 
                              self.triggerEditor, 
                              self.propertyEditorWindow, 
-                             self.propertyEditor, )
-#                             self.eventEditor )
+                             self.propertyEditor, 
+                             self.eventEditor )
 
     self._currentPage = self._pages[0]
 #    hsplitter.SplitHorizontally (self.tree, self.propertyEditor)
Index: gnue/gnuef/designer/src/LayoutEditor.py
diff -u gnue/gnuef/designer/src/LayoutEditor.py:1.6 
gnue/gnuef/designer/src/LayoutEditor.py:1.7
--- gnue/gnuef/designer/src/LayoutEditor.py:1.6 Fri Jun 22 06:16:35 2001
+++ gnue/gnuef/designer/src/LayoutEditor.py     Sat Jun 23 14:20:00 2001
@@ -37,7 +37,10 @@
 class LayoutEditor (wxScrolledWindow): 
   def __init__(self, instance, parentWindow): 
     wxScrolledWindow.__init__(self,parentWindow,-1,style=wxHSCROLL|wxVSCROLL)
-    self.SetBackgroundColour(wxWHITE)
+    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
@@ -52,10 +55,14 @@
     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)
+
     EVT_COMBOBOX(self, self.pageCombo.GetId(), self.OnPageSelected)
     EVT_COMBOBOX(self, self.blockCombo.GetId(), self.OnBlockSelected)
     EVT_SIZE(self, self.OnSize)
 
+    self.panel = None
     self._pageList = []  # Needed by UIwxpython
 
   def onSetCurrentObject (self, object, handler):
@@ -64,9 +71,14 @@
         o.setSelected(0)
       return
     if handler != __name__: 
-      for o in self._currentSelection.keys():
-        o.setSelected(0)
-      object.walk(self.__setCurrentObject)
+      if isinstance(object, GFObjects.GFPage) and object != self.page: 
+        if self.panel != None: 
+          self.panel.Destroy()
+          self.drawPage(object)
+      else: 
+        for o in self._currentSelection.keys():
+          o.setSelected(0)
+        object.walk(self.__setCurrentObject)
 
   def __setCurrentObject(self,object): 
     if hasattr(object, '_widgetHandler'): 
@@ -81,7 +93,7 @@
         self.__getBlocks(object)
         self.__drawItem(object)
 
-      if istype(object, GFObjects.GFPage): 
+      if isinstance(object, GFObjects.GFPage): 
         self.getPages()
 
   def onModifyObject (self, object, handler, modifications):
@@ -182,7 +194,12 @@
       self.blockCombo.Append(object.name)
 
   def __drawItem(self, object): 
-    if self.widgets.has_key(object.getObjectType()): 
+    if self.widgets.has_key(object.getObjectType()) and \
+       (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: 
+        GDebug.printMesg(7, 'Drawing item of type %s' % 
(object.getObjectType()))
       object._widgetHandler = WidgetHandler(self, object)
       object._widget = self.widgets[object.getObjectType()]\
          (object,self.panel, self.textWidth, self.textHeight, \
@@ -196,6 +213,8 @@
 
   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))
 
 
   def OnPageSelected(self, event): 
@@ -207,7 +226,7 @@
   def OnBlockSelected(self, event): 
     b = self.blockList[event.GetSelection()]
 #    if p != self.page:
-#      self._instance.onSetCurrentObject(p, None)
+    self._instance.onSetCurrentObject(b, None)
 
 
   def OnLeftDown(self, event): 
@@ -575,3 +594,34 @@
       dc.EndDrawing()
     event.Skip()
 
+#
+#
+#
+class PropertyBar (wxPanel): 
+  def __init__(self, parent): 
+    wxPanel.__init__(self, parent, -1, style=wxRAISED_BORDER|wxCLIP_CHILDREN)  
+    self.parent = parent
+    
+    self.nameLabel = wxStaticText(self, -1, "Name:", pos=wxPoint(4,4)) 
+    self.nameEditor = wxTextCtrl(self, -1,  
+          pos=calcRelPos(self.nameLabel, dx=4, dy=0))
+    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))
+    self.xEditor = wxSpinCtrl(self, -1, 
+          pos=calcRelPos(self.xLabel, dx=4, absy=4))
+
+    self.Fit()
+    
+
+  def setCurrentObject(self, object): 
+    pass
+    
+
+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)) 
Index: gnue/gnuef/designer/src/PropertyEditor.py
diff -u gnue/gnuef/designer/src/PropertyEditor.py:1.4 
gnue/gnuef/designer/src/PropertyEditor.py:1.5
--- gnue/gnuef/designer/src/PropertyEditor.py:1.4       Fri Jun 22 06:16:35 2001
+++ gnue/gnuef/designer/src/PropertyEditor.py   Sat Jun 23 14:20:00 2001
@@ -76,10 +76,84 @@
       EVT_GRID_CELL_CHANGE(self.grid, self.OnCellChange)
 
   def onCreateObject (self, object, handler):
+    pass
+
+  def onModifyObject (self, object, handler, modifications):
+    if object == None: 
+      return
+    if handler != __name__ and self.object == object:
+#      for modification in modifications: 
+#        attribute, value = modification
+      self.onSetCurrentObject(object, handler)
+
+  def onDeleteObject (self, object, handler):
+    if object == None: 
+      return
+    if handler != __name__:
+      pass
+
+  def onSize(self, event): 
+    x,y = self.GetClientSizeTuple()
+    self.panel.SetSize((x-12,y-12))
+    self.grid.SetSize(self.panel.GetClientSizeTuple())
+    w,h = self.grid.GetClientSizeTuple()
+    self.grid.SetColSize(0, w - self.grid.GetRowLabelSize())
+
+  def OnCellChange(self, evt):
+    attr = self.rowList[evt.GetRow()]
+    value = self.grid.GetCellValue(evt.GetRow(), evt.GetCol())
+
+    try: 
+      self.object.__dict__[attr] = self.attributes[attr][2](value)
+      self.instance.onModifyObject(self.object, __name__, ((attr, 
self.object.__dict__[attr]),))
+      evt.Skip()
+    except ValueError: 
+      wxBell()
+      
+#
+#
+#
+class EventEditor (wxPanel): 
+  def __init__(self, parent, instance, form): 
+    wxPanel.__init__(self,parent,-1,pos=wxPoint(0,0))
+    self.panel = wxPanel(self,-1,style=wxSIMPLE_BORDER, pos=wxPoint(6,6))
+
+    self.parent = parent
+    self.instance = instance
+    self.form = form
+    self.objectList = []
+    self.objectMap = {}
+    self.grid = wxGrid(self.panel, -1, pos=wxPoint(0,0))
+    EVT_SIZE(self, self.onSize)
+
+  def onSetCurrentObject (self, object, handler):
     if object == None: 
       return
-    self.inventoryObject(object)
-    self.generateObjectMap()
+    if handler != __name__:
+      self.object = object
+      self.attributes = elements[string.lower(object.getObjectType()[2:])][1]
+      self.elements = elements[string.lower(object.getObjectType()[2:])]
+
+      # This is a nasty temporary way of refreshing grid
+      if self.grid: 
+        self.grid.Destroy()
+      self.grid = wxGrid(self.panel, -1, pos=wxPoint(0,0))
+
+      self.grid.CreateGrid(len(self.attributes.keys()),1)
+      self.grid.SetColLabelSize(0)
+      self.rowList = self.attributes.keys()
+      self.rowList.sort()
+      i = 0
+      for key in self.rowList: 
+        self.grid.SetRowLabelValue(i, string.upper(key[0]) + 
string.lower(key[1:]))
+        if hasattr(object, key): 
+          self.grid.SetCellValue(i,0,"%s" % object.__dict__[key])
+        i = i + 1
+      self.onSize(None)
+      EVT_GRID_CELL_CHANGE(self.grid, self.OnCellChange)
+
+  def onCreateObject (self, object, handler):
+    pass
 
   def onModifyObject (self, object, handler, modifications):
     if object == None: 
@@ -126,12 +200,15 @@
     self.notebook = wxNotebook(self, -1, pos=wxPoint(6, 37), 
size=wxSize(32,32))
 
     self.propertyEditor = PropertyEditor(
+         self.notebook, instance, instance._form)
+
+    self.temp = wxPanel(self.notebook, -1)
+
+    self.eventEditor = EventEditor(
          self.notebook, instance, instance._form)
-#    self.eventEditor = EventEditor(
-#         self.notebook, instance, instance._form)
 
     self.notebook.AddPage(self.propertyEditor, 'Properties')
-#    self.notebook.AddPage(self.eventEditor, 'Events')
+    self.notebook.AddPage(self.eventEditor, 'Events')
 
     self.objectLabel = wxStaticText(self.toolpanel, -1, "Object: ", 
          pos=wxPoint(4,6))



reply via email to

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