commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src/templates/forms Simple.py


From: Bajusz Tamás
Subject: gnue/designer/src/templates/forms Simple.py
Date: Sun, 22 Dec 2002 17:05:51 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Bajusz Tamás <address@hidden>   02/12/22 17:05:51

Modified files:
        designer/src/templates/forms: Simple.py 

Log message:
        Reworked 'Simple form wizard' according to new 0.5 gfd format

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/templates/forms/Simple.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: gnue/designer/src/templates/forms/Simple.py
diff -c gnue/designer/src/templates/forms/Simple.py:1.12 
gnue/designer/src/templates/forms/Simple.py:1.13
*** gnue/designer/src/templates/forms/Simple.py:1.12    Sat Sep 28 10:48:03 2002
--- gnue/designer/src/templates/forms/Simple.py Sun Dec 22 17:05:51 2002
***************
*** 178,192 ****
            'type': 'object',
            'name': 'dts%s' %  tableKey })
  
!     page = None
      for child in self.form._children:
        if child._type == 'GFPage':
          page = child
          break
  
      if not page:
        # Create a single page on which to place blocks and labels
!       page = self.AddElement('page', self.form,
           {  'name': 'pg%s' % tableKey })
  
  
--- 178,208 ----
            'type': 'object',
            'name': 'dts%s' %  tableKey })
  
!     logic = None
!     for child in self.form._children:
!       if child._type == 'GFLogic':
!         logic = child
!         break
!     if not logic:
!       logic = self.AddElement('logic', self.form, {})
! 
!     layout = None
      for child in self.form._children:
+       if child._type == 'GFLayout':
+         layout = child
+         break
+     if not layout:
+       layout = self.AddElement('layout', self.form, {})
+ 
+     page = None
+     for child in layout._children:
        if child._type == 'GFPage':
          page = child
          break
  
      if not page:
        # Create a single page on which to place blocks and labels
!       page = self.AddElement('page', layout,
           {  'name': 'pg%s' % tableKey })
  
  
***************
*** 201,207 ****
        attrs['rows'] = 10
  
      # Create the block
!     block = self.AddElement('block', page, attrs)
  
      schema = self.GetSourceSchema(self.variables['connection'],
                           self.variables['table'])
--- 217,223 ----
        attrs['rows'] = 10
  
      # Create the block
!     block = self.AddElement('block', logic, attrs)
  
      schema = self.GetSourceSchema(self.variables['connection'],
                           self.variables['table'])
***************
*** 219,224 ****
--- 235,241 ----
        if field.name in self.variables['fields']:
          fields[field.name] = field
  
+     fieldQueue = []
      entryQueue = []
      labelQueue = []
      largestField = 0
***************
*** 237,242 ****
--- 254,269 ----
          fieldKey = string.join(string.split(string.capwords( \
                       string.replace(field.name,'_',' '))),'')
  
+       # Create the field element
+       attrs={'name': "inp%s" % fieldKey,
+              'field': field.name}
+       # If we have a length for the field, use this as the max_length
+       # for the field.
+       if hasattr(field,'length'):
+         attrs['max_length'] = field.length
+ 
+       fieldQueue.append(self.AddElement('field', block, attrs))
+       
        # Create a label. If the schema specified a label for a field,
        # use that as is.  If not, use the field name, replacing any '_'
        # with spaces and tacking on a colon.
***************
*** 244,253 ****
               string.capwords(string.replace(field.name,'_',' ')) + ':'
  
        labelQueue.append(self.AddElement('label', page,
!                   {'x':1, 'y': 1,
                     'name': "lbl%s" % fieldKey,
                     'text': text,
!                    'width': len(text)}))
  
        # Keep track of the greatest label width
        largestLabel = largestLabel < len(text) and len(text) or largestLabel
--- 271,280 ----
               string.capwords(string.replace(field.name,'_',' ')) + ':'
  
        labelQueue.append(self.AddElement('label', page,
!                   {'Char:x':1, 'Char:y': 1,
                     'name': "lbl%s" % fieldKey,
                     'text': text,
!                    'Char:width': len(text)}))
  
        # Keep track of the greatest label width
        largestLabel = largestLabel < len(text) and len(text) or largestLabel
***************
*** 255,281 ****
  
        # Create an entry for this field.
  
!       attrs={'x':1, 'y': 1,
!              'name': "inp%s" % fieldKey,
!              'field': field.name,
               'typecast': field.datatype,
!              'width': 10}
  
!       # If we have a length for the field, use this as the max_length
!       # for the entry. Also, adjust the display width if necessary.
        if hasattr(field,'length'):
-         attrs['max_length'] = field.length
          if field.length < 25:
!           attrs['width'] = field.length
          else:
!           attrs['width'] = 25
  
        # Keep track of the greatest field width
!       largestField = largestField < attrs['width'] and \
!              attrs['width'] or largestField
  
        # Create the entry element
!       entryQueue.append(self.AddElement('entry', block, attrs))
  
  
      # Rearrange the fields and labels to snugly fit the screen
--- 282,306 ----
  
        # Create an entry for this field.
  
!       attrs={'Char:x':1, 'Char:y': 1,
!              'block': 'blk%s' % tableKey,
!              'field': "inp%s" % fieldKey,
               'typecast': field.datatype,
!              'Char:width': 10}
  
!       # If we have a length, adjust the display width if necessary.
        if hasattr(field,'length'):
          if field.length < 25:
!           attrs['Char:width'] = field.length
          else:
!           attrs['Char:width'] = 25
  
        # Keep track of the greatest field width
!       largestField = largestField < attrs['Char:width'] and \
!              attrs['Char:width'] or largestField
  
        # Create the entry element
!       entryQueue.append(self.AddElement('entry', page, attrs))
  
  
      # Rearrange the fields and labels to snugly fit the screen
***************
*** 289,306 ****
        x = 1
  
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],x=x,y=1)
!         self.ModifyElement(entryQueue[i],x=x,y=2)
  
          # If label width is larger than entry width, center the entry
!         if entryQueue[i].width < labelQueue[i].width:
!           self.ModifyElement(entryQueue[i],x=entryQueue[i].x + \
!               int((labelQueue[i].width - entryQueue[i].width)/2))
  
  
          # Calculate the starting x for the next label/entry
!         dx = (entryQueue[i].width < labelQueue[i].width and \
!               labelQueue[i].width or entryQueue[i].width) + 1
  
          # Increase the form width accordingly
          width += dx
--- 314,331 ----
        x = 1
  
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],Char__x=x,Char__y=1)
!         self.ModifyElement(entryQueue[i],Char__x=x,Char__y=2)
  
          # If label width is larger than entry width, center the entry
!         if entryQueue[i].Char__width < labelQueue[i].Char__width:
!           self.ModifyElement(entryQueue[i],Char__x=entryQueue[i].Char__x + \
!               int((labelQueue[i].Char__width - entryQueue[i].Char__width)/2))
  
  
          # Calculate the starting x for the next label/entry
!         dx = (entryQueue[i].Char__width < labelQueue[i].Char__width and \
!               labelQueue[i].Char__width or entryQueue[i].Char__width) + 1
  
          # Increase the form width accordingly
          width += dx
***************
*** 331,345 ****
        # Rearrange
        height = fy+2-fdy
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],x=lx,y=ly)
!         self.ModifyElement(entryQueue[i],x=fx,y=fy)
          ly = ly + ldy
          lx = lx + ldx
          fy = fy + fdy
          fx = fx + fdx
          height += fdy
  
!     self.ModifyElement(self.form, width=width, height=height)
  
      # That's it... we're done.
      return 1
--- 356,370 ----
        # Rearrange
        height = fy+2-fdy
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],Char__x=lx,Char__y=ly)
!         self.ModifyElement(entryQueue[i],Char__x=fx,Char__y=fy)
          ly = ly + ldy
          lx = lx + ldx
          fy = fy + fdy
          fx = fx + fdx
          height += fdy
  
!     self.ModifyElement(layout, Char__width=width, Char__height=height)
  
      # That's it... we're done.
      return 1



reply via email to

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