commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r10326 - in trunk/gnue-designer: . src/forms src/forms/PagePainte


From: reinhard
Subject: [gnue] r10326 - in trunk/gnue-designer: . src/forms src/forms/PagePainter src/forms/PagePainter/skins src/templates/forms
Date: Sat, 18 Jun 2011 04:18:03 -0500 (CDT)

Author: reinhard
Date: 2011-06-18 04:18:03 -0500 (Sat, 18 Jun 2011)
New Revision: 10326

Modified:
   trunk/gnue-designer/
   trunk/gnue-designer/src/forms/PagePainter/PagePainter.py
   trunk/gnue-designer/src/forms/PagePainter/skins/default.py
   trunk/gnue-designer/src/forms/document.py
   trunk/gnue-designer/src/templates/forms/FormBuilder.py
   trunk/gnue-designer/src/templates/forms/Simple.py
Log:
First pass at managed layout, with simple form wizard.
* Grid & Labels-to-Left generated well.
* Labels-above current is laying out horizontally instead of vertically
* Display of form elements in Designer canvas, is broken again -
  see PagePainter/skins/default.py - cf using Forms API single-sourced.
* Need layout xmlns:s="GNUe:Layout:Sizer" cf xmlns:Char="GNUe:Layout:Char".
* Need to mind FormBuilder as well as Simple.



Property changes on: trunk/gnue-designer
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2011-06-02 10:46:55.282999992 -0700
committer: whizman
properties: 
        branch-nick: designer

   + timestamp: 2011-06-03 18:08:05.282999992 -0700
committer: whizman
properties: 
        branch-nick: designer

Name: bzr:file-ids
   - src/forms/PagePainter/PagePainter.py       
address@hidden:trunk%2Fgnue-designer:src%2Fforms%2FPagePainter%2FPagePainter.py

   + src/forms/PagePainter/PagePainter.py       
address@hidden:trunk%2Fgnue-designer:src%2Fforms%2FPagePainter%2FPagePainter.py
src/forms/PagePainter/skins/default.py  
address@hidden:trunk%2Fgnue-designer:src%2Fforms%2FPagePainter%2Fskins%2Fdefault.py
src/forms/document.py   
address@hidden:trunk%2Fgnue-designer:src%2Fforms%2Fdocument.py
src/templates/forms/FormBuilder.py      
address@hidden:trunk%2Fgnue-designer:src%2Ftemplates%2Fforms%2FFormBuilder.py
src/templates/forms/Simple.py   
address@hidden:trunk%2Fgnue-designer:src%2Ftemplates%2Fforms%2FSimple.py

Name: bzr:revision-id:v4
   - 937 address@hidden
938 whizman_software_solutions_www.whizman.com-20110131201023-bmx4kgkf4erlim85
939 whizman_software_solutions_www.whizman.com-20110226005239-cn6eioyybe5p62rh
940 whizman-20110504201148-w669gtbff176vhop
941 whizman-20110505231025-243w4sfxhzqcbzt2
942 whizman-20110509181949-gnbxobve89qk8pr5
943 whizman-20110509204654-xx9cb9tiuszib409
944 whizman-20110519181636-ighctsn5h1uftknz
945 whizman-20110527230256-kqjr2eb33a29zy9o
946 whizman-20110527235820-zqeownp0345308ww
947 whizman-20110601222222-rvg8tu47q0x6y6rf
948 whizman-20110602174655-bbnm4cs5i6ht5mbg

   + 937 address@hidden
938 whizman_software_solutions_www.whizman.com-20110131201023-bmx4kgkf4erlim85
939 whizman_software_solutions_www.whizman.com-20110226005239-cn6eioyybe5p62rh
940 whizman-20110504201148-w669gtbff176vhop
941 whizman-20110505231025-243w4sfxhzqcbzt2
942 whizman-20110509181949-gnbxobve89qk8pr5
943 whizman-20110509204654-xx9cb9tiuszib409
944 whizman-20110519181636-ighctsn5h1uftknz
945 whizman-20110527230256-kqjr2eb33a29zy9o
946 whizman-20110527235820-zqeownp0345308ww
947 whizman-20110601222222-rvg8tu47q0x6y6rf
948 whizman-20110602174655-bbnm4cs5i6ht5mbg
949 whizman-20110604010805-vqpv6d319epfvvq0

Name: bzr:text-parents
   - src/forms/PagePainter/PagePainter.py       
svn-v3-single1-dHJ1bmsvZ251ZS1kZXNpZ25lcg..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-designer:9955

   + src/forms/PagePainter/skins/default.py     
svn-v3-single1-dHJ1bmsvZ251ZS1kZXNpZ25lcg..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-designer:9955
src/forms/document.py   whizman-20110527230256-kqjr2eb33a29zy9o
src/templates/forms/FormBuilder.py      
svn-v3-single1-dHJ1bmsvZ251ZS1kZXNpZ25lcg..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-designer:9955
src/templates/forms/Simple.py   
svn-v3-single1-dHJ1bmsvZ251ZS1kZXNpZ25lcg..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-designer:9955


Modified: trunk/gnue-designer/src/forms/PagePainter/PagePainter.py
===================================================================
--- trunk/gnue-designer/src/forms/PagePainter/PagePainter.py    2011-06-18 
09:18:00 UTC (rev 10325)
+++ trunk/gnue-designer/src/forms/PagePainter/PagePainter.py    2011-06-18 
09:18:03 UTC (rev 10326)
@@ -40,6 +40,7 @@
 #--------------------------------------------------------------------------
 # GNUe Imports
 #--------------------------------------------------------------------------
+from gnue.common.base import log
 from gnue.designer.base.EditorBase import EditorBase
 from gnue.designer.ui.wx.uihelpers.doccanvas.canvas import DocumentCanvas
 
@@ -106,19 +107,17 @@
         Inventory each object as it is identified or added
         """
 
-        # Right now, we assume if an object has an x,y component, it is
-        # drawable. This won't be true when we support layout management.
-        try:
-            object['Char:x']
-            object['Char:y']
-        except:
-            if not object._type == 'GFPage':
-                return
+        # Previously, we assumed if an object has an x,y component, it is
+        # drawable. This is not true now that we support layout management.
+        # try:
+        #     object['Char:x']
+        #     object['Char:y']
+        # except:
+        #     if not object._type == 'GFPage':
+        #         return
 
         canvas = self.canvas
-
         cls = getWidgetSkinClass(object)
-
         widget = cls(object, canvas)
         canvas.add(widget)
 

Modified: trunk/gnue-designer/src/forms/PagePainter/skins/default.py
===================================================================
--- trunk/gnue-designer/src/forms/PagePainter/skins/default.py  2011-06-18 
09:18:00 UTC (rev 10325)
+++ trunk/gnue-designer/src/forms/PagePainter/skins/default.py  2011-06-18 
09:18:03 UTC (rev 10326)
@@ -77,8 +77,8 @@
         # Char positioning starts counting at "0".
         x = -1 * common.char_x_scale
         y = -1 * common.char_y_scale
-        width = object['Char:width'] + 1
-        height = object['Char:height'] + 1
+        width = 41  #object['Char:width'] + 1
+        height = 13  #object['Char:height'] + 1
 
         # Convert from Char positions into wx positions
         width *= common.char_x_scale

Modified: trunk/gnue-designer/src/forms/document.py
===================================================================
--- trunk/gnue-designer/src/forms/document.py   2011-06-18 09:18:00 UTC (rev 
10325)
+++ trunk/gnue-designer/src/forms/document.py   2011-06-18 09:18:03 UTC (rev 
10326)
@@ -136,8 +136,8 @@
         form.height = 12
         GFObjects.GFLogic(form)
         layout = GFObjects.GFLayout(form)
-        layout.Char__width = 40
-        layout.Char__height = 12
+        #layout.Char__width = 40
+        #layout.Char__height = 12
         GFObjects.GFPage(layout)
         return form
 

Modified: trunk/gnue-designer/src/templates/forms/FormBuilder.py
===================================================================
--- trunk/gnue-designer/src/templates/forms/FormBuilder.py      2011-06-18 
09:18:00 UTC (rev 10325)
+++ trunk/gnue-designer/src/templates/forms/FormBuilder.py      2011-06-18 
09:18:03 UTC (rev 10326)
@@ -401,16 +401,12 @@
             leftlabels = self.variables['tablearrangement%s' % count] == 'left'
 
 
-            # We will need a block to hold our entries...
+            # We will need a block to hold our fields...
 
             # The basic attributes for a block
             attrs = {'name' : 'blk%s' % tableKey,
                      'datasource': datasource['name']}
 
-            # If this is a multirecord form, set rows at the block level.
-            if multirecord:
-                attrs['rows'] = 10
-
             # Create the block
             block = self.AddElement('block', logic, attrs)
 
@@ -434,6 +430,7 @@
             labelQueue = []
             largestField = 0
             largestLabel = 0
+            defaultWidth = 10
 
             # First, let's make all the fields
             for name in self.variables['tablefields%s' % count]:
@@ -466,16 +463,16 @@
 
                 attrs={ 'name': "fld%s" % fieldKey,
                         'field': field.name,
-                        'typecast': self.TYPEMAP.get (field.type, 'text')}
+                        'datatype': self.TYPEMAP.get (field.type, 'text')}
 
-                # If we have a length for the field, use this as the maxLength
+                # If we have a length for the field, use this as the  length
                 # for the entry. Also, adjust the display width if necessary.
-                if hasattr(field,'length'):
-                    ln = max(min(field.length, 40),0) or 10
-                    attrs['maxLength'] = ln
+                if hasattr(field, 'length'):
+                    ln = max(min(field.length, 40),0) or defaultWidth
+                    attrs['length'] = ln
                     largestField = max(largestField, ln)
                 else:
-                    largestField = max(largestField, 10)
+                    largestField = max(largestField, defaultWidth)
 
                 # Create the entry element
                 fld = self.AddElement('field', block, attrs)
@@ -489,6 +486,10 @@
             # based on the layout arrangement selected by the user.
             #
 
+            # # If this is a multirecord form, set rows at the block level.
+            # if multirecord:
+            #     attrs['rows'] = 10
+
             # Grid/multirecord layout
             if multirecord:
 
@@ -507,10 +508,15 @@
                     entryQueue[i][2] = basey + 2
 
                     # If label width is larger than entry width, center the 
entry
+                # if hasattr(field, 'length'):
+                #     entryWidth = min(field.length,40) or defaultWidth  # 
beware None
+                #     # max(min(field.length, 40),0) or defaultWidth
+                # else:
+                #     entryWidth = defaultWidth
                     try:
-                        entryWidth = min(field['maxLength'],40)
+                        entryWidth = min(field['length'],40)
                     except KeyError:
-                        entryWidth = 10
+                        entryWidth = defaultWidth
                     if entryWidth < textLen:
                         entryQueue[i][1] += int((textLen - entryWidth)/2)
 
@@ -584,12 +590,12 @@
                        'block': block['name'],
                        'Char:x': x,
                        'Char:y': y,
-                       'Char:width': 10 }
+                       'Char:width': defaultWidth }
 
-                # If we have a length for the field, use this as the maxLength
+                # If we have a length for the field, use this as the length
                 # for the entry. Also, adjust the display width if necessary.
                 try:
-                    attrs['Char:width'] = min(field['maxLength'], 40)
+                    attrs['Char:width'] = min(field['length'], 40)
                 except KeyError:
                     pass
 

Modified: trunk/gnue-designer/src/templates/forms/Simple.py
===================================================================
--- trunk/gnue-designer/src/templates/forms/Simple.py   2011-06-18 09:18:00 UTC 
(rev 10325)
+++ trunk/gnue-designer/src/templates/forms/Simple.py   2011-06-18 09:18:03 UTC 
(rev 10326)
@@ -85,7 +85,7 @@
                                    
WizardInput('connection',label='Connection:', required=1,
                                                
set=self.GetAvailableConnections()),
                                    WizardText('You may be asked to login to 
this connection.'),
-                                  ),
+                                   ),
                        'prev': None,
                        'next': '1' }
 
@@ -120,8 +120,8 @@
                                    WizardInput('fields', label='Columns:', 
required=1,
                                                maxSelections=-1, orderable=1,
                                                set=self.GetAvailableFields( \
-                                                      
self.variables['connection'],
-                                                      
self.variables['table'])),
+                            self.variables['connection'],
+                            self.variables['table'])),
                                    WizardInput('arrangement', 
label='Arrangement Method:',
                                                required=1,
                                                set=(('left','Single Record 
with Labels to Left'),
@@ -164,7 +164,7 @@
             tableKey = string.upper(self.variables['table'])
         else:
             tableKey = string.upper(self.variables['table'][0]) + \
-                          string.replace(self.variables['table'][1:],' ','_')
+                string.replace(self.variables['table'][1:],' ','_')
 
         # Is this a grid style form?
         multirecord = self.variables['arrangement'] == 'grid'
@@ -178,37 +178,33 @@
 
         # Create a single datasource based on user's input
         datasource = self.AddElement('datasource', self.form,
-           {  'connection': self.variables['connection'],
-              'table': self.variables['table'],
-              'type': 'object',
-              'name': 'dts%s' %  tableKey })
+                                     {  'connection': 
self.variables['connection'],
+                                        'table': self.variables['table'],
+                                        'type': 'object',
+                                        'name': 'dts%s' %  tableKey })
 
         logic = self.current['logic']
         layout = self.current['layout']
         page = self.current['page'] or self.AddElement('page', layout,
-             {  'name': 'pg%s' % tableKey })
+                                                       {  'name': 'pg%s' % 
tableKey })
 
 
-        # We will need a block to hold our entries...
+        # We will need a block to hold our fields...
 
         # The basic attributes for a block
-        attrs = {'name' : 'blk%s' % tableKey,
+        blockName = 'blk%s' % tableKey
+        attrs = {'name' : blockName,
                  'datasource': datasource.name}
 
-        # If this is a multirecord form, set rows at the block level.
-        if multirecord:
-            attrs['rows'] = 10
-
         # Create the block
         block = self.AddElement('block', logic, attrs)
 
         schema = self.GetSourceSchema(self.variables['connection'],
-                             self.variables['table'])
+                                      self.variables['table'])
 
 
         # Create the entries and labels...
 
-
         # Make a map of all the field schemas we will need
         # We will not actually create the entries at this point
         # because we want to keep in the order that the user
@@ -222,6 +218,7 @@
         labelQueue = []
         largestField = 0
         largestLabel = 0
+        defaultWidth = 10
 
         # First, let's make all the fields
         for name in self.variables['fields']:
@@ -235,13 +232,13 @@
                 fieldKey = string.upper(field.name)
             else:
                 fieldKey = string.join(string.split(string.capwords( \
-                             string.replace(field.name,'_',' '))),'')
+                            string.replace(field.name,'_',' '))),'')
 
             # 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.
             text = hasattr(field,'label') and label or \
-                   string.capwords(string.replace(field.name,'_',' ')) + ':'
+                string.capwords(string.replace(field.name,'_',' ')) + ':'
 
             # Add text, x, y to labelQueue
             # The x,y will be replaced by logic later on...
@@ -254,18 +251,18 @@
 
             attrs={ 'name': "fld%s" % fieldKey,
                     'field': field.name,
-                    'typecast': self.TYPEMAP.get (field.type, 'text')}
+                    'datatype': self.TYPEMAP.get (field.type, 'text')}
 
-            # If we have a length for the field, use this as the maxLength
+            # If we have a length for the field, use this as the  length
             # for the entry. Also, adjust the display width if necessary.
-            if hasattr(field,'length'):
-                ln = max(min(field.length, 40),0) or 10
+            if hasattr(field, 'length'):
+                ln = max(min(field.length, 40),0) or defaultWidth
 
                 ##ln = min(field.length, 40)
-                attrs['maxLength'] = ln
+                attrs['length'] = ln
                 largestField = max(largestField, ln)
             else:
-                largestField = max(largestField, 10)
+                largestField = max(largestField, defaultWidth)
 
             # Create the entry element
             fld = self.AddElement('field', block, attrs)
@@ -278,14 +275,22 @@
         # Rearrange the fields and labels to snugly fit the screen
         # based on the layout arrangement selected by the user.
         #
+        curParent = page
+        # If this is a multirecord form, set rows at the block level.
+        # managed-layout GFD: layout-grid rather than logic-block
+        # if multirecord:
+        #     attrs['rows'] = 10
 
         # Grid/multirecord layout
         if multirecord:
 
-            height = 13
+            #height = 13
             width = 1
             x = 1
-
+            curParent = self.AddElement('grid', page,
+                                        {'block': blockName,
+                                         'rows': 10})
+            curParent = self.AddElement('gridline', curParent)
             for i in range(len(entryQueue)):
                 field = entryQueue[i][0]
                 text = labelQueue[i][0]
@@ -297,10 +302,11 @@
                 entryQueue[i][2] = 2
 
                 # If label width is larger than entry width, center the entry
-                try:
-                    entryWidth = min(field['maxLength'],40)
-                except KeyError:
-                    entryWidth = 10
+                if hasattr(field, 'length'):
+                    entryWidth = min(field.length,40) or defaultWidth  # 
beware None
+                    # max(min(field.length, 40),0) or defaultWidth
+                else:
+                    entryWidth = defaultWidth
                 if entryWidth < textLen:
                     entryQueue[i][1] += int((textLen - entryWidth)/2)
 
@@ -318,39 +324,42 @@
             # as well as the delta (x,y) values.
             if leftlabels:
                 # Labels to the left of the entries
-                lx, ly, ldx, ldy = (1, 1, 0, 1)
-                fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
-
+                # lx, ly, ldx, ldy = (1, 1, 0, 1)
+                # fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
                 # Set form width
-                width = largestField + largestLabel + 3
+                # width = largestField + largestLabel + 3
+                boxTag = 'vbox'
 
             else:
                 # Labels above the entries
-                lx, ly, ldx, ldy = (1, 1, 0, 3)
-                fx, fy, fdx, fdy = (1, 2, 0, 3)
+                boxTag = 'hbox'
+                # lx, ly, ldx, ldy = (1, 1, 0, 3)
+                # fx, fy, fdx, fdy = (1, 2, 0, 3)
+                # # Set the form width
+                # width = 2 + max(largestField, largestLabel)
 
-                # Set the form width
-                width = 2 + max(largestField, largestLabel)
-
+            # Add appropriate box container
+            curParent = self.AddElement(boxTag, page,
+                                        {'block': blockName})
             # Rearrange
-            height = fy+2-fdy
+            #height = fy+2-fdy
             for i in range(len(entryQueue)):
-                labelQueue[i][1] = lx
-                labelQueue[i][2] = ly
-                entryQueue[i][1] = fx
-                entryQueue[i][2] = fy
+                labelQueue[i][1] = 0  #lx
+                labelQueue[i][2] = 0  #ly
+                entryQueue[i][1] = 0  #fx
+                entryQueue[i][2] = 0  #fy
 
-                ly = ly + ldy
-                lx = lx + ldx
-                fy = fy + fdy
-                fx = fx + fdx
-                height += fdy
+                # ly = ly + ldy
+                # lx = lx + ldx
+                # fy = fy + fdy
+                # fx = fx + fdx
+                # height += fdy
 
         #
         # Resize the layout screen to fit our form
         #
-        layout['Char:width'] = width
-        layout['Char:height'] = height
+        # layout['Char:width'] = width
+        # layout['Char:height'] = height
 
 
         #
@@ -361,13 +370,13 @@
             #
             # First, the label
             #
-            text, x, y = labelQueue[i]
-            self.AddElement( 'label', page,
-                        {'Char:x': x,
-                         'Char:y': y,
-                         'name': "lbl%s" % (text[-1]==':' and text[:-1] or 
text),
-                         'text': text,
-                         'Char:width': len(text)})
+            labelText, x, y = labelQueue[i]
+            # self.AddElement( 'label', curParent,
+            #             {'Char:x': x,
+            #              'Char:y': y,
+            #              'name': "lbl%s" % (text[-1]==':' and text[:-1] or 
text),
+            #              'text': text,
+            #              'Char:width': len(text)})
 
             #
             # And the entry...
@@ -376,19 +385,24 @@
             attrs={'name': "ent%s" % field['name'][3:],
                    'field': field['name'],
                    'block': block['name'],
-                   'Char:x': x,
-                   'Char:y': y,
-                   'Char:width': 10 }
+                   'label': labelText
+                   #'Char:x': x,
+                   #'Char:y': y,
+                   #'Char:width': defaultWidth
+                   }
 
-            # If we have a length for the field, use this as the maxLength
+            # If we have a length for the field, use this as the length
             # for the entry. Also, adjust the display width if necessary.
-            try:
-                attrs['Char:width'] = min(field['maxLength'], 40)
-            except KeyError:
-                pass
+            # 2011-06: change to managed layout
+            #    if do anything with this in meantime, see hasattr above
+            # try:
+            #     attrs['Char:width'] = min(field['length'], 40) \
+            #         or defaultWidth  # beware None
+            # except KeyError:
+            #     pass
 
             # Create the entry element
-            self.AddElement('entry', page, attrs)
+            self.AddElement('entry', curParent, attrs)
 
 
         # That's it... we're done.




reply via email to

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