/[papo]/gnue/designer/templates/forms/Simple.py
ViewVC logotype

Diff of /gnue/designer/templates/forms/Simple.py

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

revision 1.7 by charlie, Tue Aug 27 21:30:53 2002 UTC revision 1.8 by styxman, Fri Nov 8 16:46:04 2002 UTC
# Line 1  Line 1 
1  #  #
 # Copyright 2001 Free Software Foundation  
 #  
2  # This file is part of GNU Enterprise.  # This file is part of GNU Enterprise.
3  #  #
4  # GNU Enterprise is free software; you can redistribute it  # GNU Enterprise is free software; you can redistribute it
# Line 18  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
20    #
21  # FILE:  # FILE:
22  # Simple.py  # Simple.py
23  #  #
# Line 29  Line 29 
29  # as a "learning-by-example" tool.  # as a "learning-by-example" tool.
30    
31    
32  from gnue.designer.TemplateBase import *  from gnue.designer.forms.TemplateSupport import *
33  import string  import string
34    
35  # NOTE: It is VERY important that in any references to a  # NOTE: It is VERY important that in any references to a
# Line 55  class SimpleFormTemplate(FormTemplate): Line 55  class SimpleFormTemplate(FormTemplate):
55    #    #
56    # Initialize any runtime variables    # Initialize any runtime variables
57    #    #
58    def Start(self, form):    def Start(self, form, current):
59      self.form = form      self.form = form
60    
61    
# Line 72  class SimpleFormTemplate(FormTemplate): Line 72  class SimpleFormTemplate(FormTemplate):
72      if stepCode == '0':      if stepCode == '0':
73        return   { 'title': 'Basic Form Information',        return   { 'title': 'Basic Form Information',
74                   'content': (WizardText('Welcome to the sample form wizard.'),                   'content': (WizardText('Welcome to the sample form wizard.'),
75                               WizardText('To create your form, I need to know some basic information. \n'                               WizardText('To create your form, I need to know some basic information.\n\n'
76                                          'First, what shall I call your form? This name will appear in \n'                                          'First, what shall I call your form? This name will appear in '
77                                          'the title bar.'),                                          'the title bar.'),
78                               WizardInput('title', label='Form Title:', required=1,                               WizardInput('title', label='Form Title:', required=1,
79                                           size=40),                                           size=40),
80                               WizardText('What connection should this form use to connect to the \ndatabase?'),                               WizardText('What connection should this form use to connect to the database?'),
81                               WizardInput('connection',label='Connection:', required=1,                               WizardInput('connection',label='Connection:', required=1,
82                                           set=self.GetAvailableConnections()),                                           set=self.GetAvailableConnections()),
83                               WizardText('You may be asked to login to this connection.'),                               WizardText('You may be asked to login to this connection.'),
# Line 169  class SimpleFormTemplate(FormTemplate): Line 169  class SimpleFormTemplate(FormTemplate):
169      leftlabels = self.variables['arrangement'] == 'left'      leftlabels = self.variables['arrangement'] == 'left'
170    
171      # Set the basic attributes of the form      # Set the basic attributes of the form
172      self.form.title = self.variables['title']      self.ModifyElement(self.form, title=self.variables['title'])
173    
174      # Create a single datasource based on user's input      # Create a single datasource based on user's input
175      datasource = self.AddElement('datasource', self.form,      datasource = self.AddElement('datasource', self.form,
# Line 178  class SimpleFormTemplate(FormTemplate): Line 178  class SimpleFormTemplate(FormTemplate):
178            'type': 'object',            'type': 'object',
179            'name': 'dts%s' %  tableKey })            'name': 'dts%s' %  tableKey })
180    
181      # Create a single page on which to place blocks and labels      page = None
182      page = self.AddElement('page', self.form,      for child in self.form._children:
183         {  'name': 'pg%s' % tableKey })        if child._type == 'GFPage':
184            page = child
185            break
186    
187        if not page:
188          # Create a single page on which to place blocks and labels
189          page = self.AddElement('page', self.form,
190             {  'name': 'pg%s' % tableKey })
191    
192    
193      # We will need a block to hold our entries...      # We will need a block to hold our entries...
# Line 251  class SimpleFormTemplate(FormTemplate): Line 258  class SimpleFormTemplate(FormTemplate):
258        attrs={'x':1, 'y': 1,        attrs={'x':1, 'y': 1,
259               'name': "inp%s" % fieldKey,               'name': "inp%s" % fieldKey,
260               'field': field.name,               'field': field.name,
261               'typecast': field.datatype,               'typecast': field.datatype,
262               'width': 10}               'width': 10}
263    
264        # If we have a length for the field, use this as the max_length        # If we have a length for the field, use this as the max_length
# Line 277  class SimpleFormTemplate(FormTemplate): Line 284  class SimpleFormTemplate(FormTemplate):
284      # Grid/multirecord layout      # Grid/multirecord layout
285      if multirecord:      if multirecord:
286    
287        self.form.height = 13        height = 13
288        self.form.width = 1        width = 1
289        x = 1        x = 1
290    
291        for i in range(len(entryQueue)):        for i in range(len(entryQueue)):
292          labelQueue[i].x = x          self.ModifyElement(labelQueue[i],x=x,y=1)
293          labelQueue[i].y = 1          self.ModifyElement(entryQueue[i],x=x,y=2)
         entryQueue[i].x = x  
         entryQueue[i].y = 2  
294    
295          # If label width is larger than entry width, center the entry          # If label width is larger than entry width, center the entry
296          if entryQueue[i].width < labelQueue[i].width:          if entryQueue[i].width < labelQueue[i].width:
297            entryQueue[i].x = entryQueue[i].x + \            self.ModifyElement(entryQueue[i],x=entryQueue[i].x + \
298                int((labelQueue[i].width - entryQueue[i].width)/2)                int((labelQueue[i].width - entryQueue[i].width)/2))
299    
300    
301          # Calculate the starting x for the next label/entry          # Calculate the starting x for the next label/entry
# Line 298  class SimpleFormTemplate(FormTemplate): Line 303  class SimpleFormTemplate(FormTemplate):
303                labelQueue[i].width or entryQueue[i].width) + 1                labelQueue[i].width or entryQueue[i].width) + 1
304    
305          # Increase the form width accordingly          # Increase the form width accordingly
306          self.form.width = self.form.width + dx          width += dx
307          x = x + dx          x = x + dx
308    
309      # Single Record layout (regardless of label location)      # Single Record layout (regardless of label location)
# Line 312  class SimpleFormTemplate(FormTemplate): Line 317  class SimpleFormTemplate(FormTemplate):
317          fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)          fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
318    
319          # Set form width          # Set form width
320          self.form.width = largestField + largestLabel + 3          width = largestField + largestLabel + 3
321    
322        else:        else:
323          # Labels above the entries          # Labels above the entries
# Line 320  class SimpleFormTemplate(FormTemplate): Line 325  class SimpleFormTemplate(FormTemplate):
325          fx, fy, fdx, fdy = (1, 2, 0, 3)          fx, fy, fdx, fdy = (1, 2, 0, 3)
326    
327          # Set the form width          # Set the form width
328          self.form.width = 2 + (largestField > largestLabel and largestField \          width = 2 + (largestField > largestLabel and largestField \
329                                 or largestLabel)                                 or largestLabel)
330    
331        # Rearrange        # Rearrange
332        self.form.height = fy+2-fdy        height = fy+2-fdy
333        for i in range(len(entryQueue)):        for i in range(len(entryQueue)):
334          entryQueue[i].x = fx          self.ModifyElement(labelQueue[i],x=lx,y=ly)
335          entryQueue[i].y = fy          self.ModifyElement(entryQueue[i],x=fx,y=fy)
         labelQueue[i].x = lx  
         labelQueue[i].y = ly  
336          ly = ly + ldy          ly = ly + ldy
337          lx = lx + ldx          lx = lx + ldx
338          fy = fy + fdy          fy = fy + fdy
339          fx = fx + fdx          fx = fx + fdx
340          self.form.height = self.form.height + fdy          height += fdy
341    
342        self.ModifyElement(self.form, width=width, height=height)
343    
344      # That's it... we're done.      # That's it... we're done.
345      return 1      return 1

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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