/[papo]/gnue/designer/src/forms/Incubator.py
ViewVC logotype

Diff of /gnue/designer/src/forms/Incubator.py

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

revision 1.3 by styxman, Fri Nov 8 16:46:03 2002 UTC revision 1.3.4.1 by anthonyl, Tue Mar 4 22:11:40 2003 UTC
# Line 16  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2001-2002 Free Software Foundation  # Copyright 2001-2003 Free Software Foundation
20  #  #
21  # FILE:  # FILE:
22  # Incubator.py  # Incubator.py
# Line 29  Line 29 
29    
30  from gnue.common import GDebug, GParserHelpers  from gnue.common import GDebug, GParserHelpers
31  from gnue.forms import GFParser, GFForm  from gnue.forms import GFParser, GFForm
32  from gnue.designer.Incubator import *  from gnue.designer.base.Incubator import BaseIncubator
33    
34  def createObject(instance, form, tag, type=None, parent=None,  class Incubator(BaseIncubator):
          parentHint=None, attributes={}):  
35    
36      elements = GFParser.getXMLelements()
37    
38    GDebug.printMesg(3,'Creating a "%s" object' % tag)    def _handleUnknownAttribute(self, tag, object, attr, value):
39    GDebug.printMesg(6,"Object's parent is %s" % parentHint)      # Hackery for forms Layout Management (namespace) support
40        if attr.find(':')+1:
41    try:        object.__dict__[attr.replace(':','__')] = value
     name = attributes['name']  
   except KeyError:  
     name = instance.getNextGenericName(tag)  
   
   try:  
     objclass = elements[tag]['BaseClass']  
     if elements[tag].has_key('Attributes'):  
       attrs = elements[tag]['Attributes']  
     else:  
       attrs = {}  
   except KeyError:  
     GDebug.printMesg(1, "Attempted to create a '%s', "  
                         "but I don't know what to do!" % tag)  
     return  
   
   
   if tag == 'trigger':  
     if not attributes.has_key('type'):  
       attributes['type'] = 'NAMED'  
     if attributes['type'] == 'NAMED':  
       parent = form  
     else:  
       parent = parent or parentHint  
   elif tag in ('page','datasource','import'):  
     parent = form  
   
   o = objclass(parent or parentHint)  
   
   # Add any GContent  
   try:  
     GParserHelpers.GContent(o, attributes['_content_'])  
   except KeyError:  
     pass  
   
   # Pull default values for any attributes not supplied  
   for attr in attrs.keys():  
     if not attributes.has_key(attr):  
       if attrs[attr].has_key('Default'):  
         attributes[attr] = attrs[attr]['Typecast'](attrs[attr]['Default'])  
       elif attr in ('x','y',):  
         attributes[attr] = 0  
       elif attr in ('height',):  
         if tag in ('box','scrollbar'):  
           attributes[attr] = 4  
         else:  
           attributes[attr] = 1  
       elif attr == 'width':  
         if tag in ('scrollbar',):  
           attributes[attr] = 1  
         else:  
           attributes[attr] = 10  
       elif attr in ('text','label'):  
         attributes[attr] = name  
   
   for attr in attributes.keys():  
     if attrs.has_key(attr):  
       o.__dict__[attr] = attributes[attr]  
   
   o.name = name  
   instance.nameMappings[o.name] = o  
   o._buildObject()  
   instance.onCreateObject(o, __name__)  
   instance.onSetCurrentObject(o, __name__)  
   return o  
   
   
 def reparentObject(instance, form, object, newParent):  
   if object._parent == newParent:  
     return  
   
   # TODO  
   pass  
   
   
 def deleteObject(instance, form, object, newCurrentObject=None, firstRun=1):  
   
   if firstRun:  
     newCurrentObject = object._parent  
     parent = object._parent  
   
   for child in object._children:  
     child.deleteObject(instance, form, child, firstRun=0)  
   
   instance.onDeleteObject(object, __name__)  
   
   if firstRun:  
     o = parent  
     while not isinstance(o, GFForm.GFForm):  
       o._buildObject()  
       o = o._parent  
   
     if newCurrentObject:  
       instance.onSetCurrentObject(newCurrentObject, __name__)  
   
   
   
 #  
 # Figure out tag dependencies  
 #  
 elements = GFParser.getXMLelements()  
 elementMapping = {}  
 calcDependencies(elements, elementMapping)  
42    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.4.1

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