DataSetBuilder.st
changeset 380 42aacfc3d263
parent 379 1a24037cd490
child 391 5c7fa5484d14
equal deleted inserted replaced
379:1a24037cd490 380:42aacfc3d263
   185           #'component:' 
   185           #'component:' 
   186            #(#SpecCollection
   186            #(#SpecCollection
   187               #'collection:' 
   187               #'collection:' 
   188                #(
   188                #(
   189                  #(#FramedBoxSpec
   189                  #(#FramedBoxSpec
   190                     #'name:' 'colorsBox'
   190                     #'name:' 'defaultColorsBox'
   191                     #'layout:' #(#LayoutFrame 0 0.0 24 0 0 1.0 121 0)
   191                     #'layout:' #(#LayoutFrame 0 0.0 22 0 0 1.0 121 0)
   192                     #'component:' 
   192                     #'component:' 
   193                      #(#SpecCollection
   193                      #(#SpecCollection
   194                         #'collection:' 
   194                         #'collection:' 
   195                          #(
   195                          #(
   196                            #(#ColorMenuSpec
   196                            #(#ColorMenuSpec
   219                               #'activeHelpKey:' #backgroundColor
   219                               #'activeHelpKey:' #backgroundColor
   220                               #'model:' #backgroundColor
   220                               #'model:' #backgroundColor
   221                           )
   221                           )
   222                         )
   222                         )
   223                     )
   223                     )
   224                     #'label:' 'Colors:'
   224                     #'label:' 'Default Colors:'
       
   225                     #'labelPosition:' #topLeft
       
   226                 )
       
   227                  #(#FramedBoxSpec
       
   228                     #'name:' 'cellColorsBox'
       
   229                     #'layout:' #(#LayoutFrame 0 0 127 0 0 1.0 226 0)
       
   230                     #'component:' 
       
   231                      #(#SpecCollection
       
   232                         #'collection:' 
       
   233                          #(
       
   234                            #(#LabelSpec
       
   235                               #'name:' 'fgSelLabel'
       
   236                               #'layout:' #(#AlignmentOrigin 100 0 32 0 1 0.5)
       
   237                               #'label:' 'FG-Color:'
       
   238                               #'adjust:' #right
       
   239                               #'resizeForLabel:' true
       
   240                           )
       
   241                            #(#InputFieldSpec
       
   242                               #'name:' 'fgSelField'
       
   243                               #'layout:' #(#LayoutFrame 101 0 23 0 10 1.0 45 0)
       
   244                               #'model:' #foregroundSelector
       
   245                               #'activeHelpKey:' #foregroundSelector
       
   246                               #'type:' #symbolOrNil
       
   247                           )
       
   248                            #(#LabelSpec
       
   249                               #'name:' 'bgSelLabel'
       
   250                               #'layout:' #(#AlignmentOrigin 100 0 66 0 1 0.5)
       
   251                               #'label:' 'BG-Color:'
       
   252                               #'adjust:' #right
       
   253                               #'resizeForLabel:' true
       
   254                           )
       
   255                            #(#InputFieldSpec
       
   256                               #'name:' 'bgSelField'
       
   257                               #'layout:' #(#LayoutFrame 101 0 57 0 10 1.0 79 0)
       
   258                               #'model:' #backgroundSelector
       
   259                               #'activeHelpKey:' #backgroundSelector
       
   260                               #'type:' #symbolOrNil
       
   261                           )
       
   262                         )
       
   263                     )
       
   264                     #'label:' 'Color Selectors (Cell):'
   225                     #'labelPosition:' #topLeft
   265                     #'labelPosition:' #topLeft
   226                 )
   266                 )
   227               )
   267               )
   228           )
   268           )
   229       )
   269       )
   648   ^ super helpSpec addPairsFrom:#(
   688   ^ super helpSpec addPairsFrom:#(
   649 
   689 
   650 #backgroundColor
   690 #backgroundColor
   651 'set the background color of the column if the color-checkBox is turned on. Otherwise, the column uses its default background color (which is specified in the styleSheet).'
   691 'set the background color of the column if the color-checkBox is turned on. Otherwise, the column uses its default background color (which is specified in the styleSheet).'
   652 
   692 
       
   693 #backgroundSelector
       
   694 'selector which returns the background color for a cell (optional). If the selector is nil or returns nil, the default background color is set.'
       
   695 
   653 #canSelect
   696 #canSelect
   654 'if true, each cell in the column can be selected. In case of having a menu, the menu can be opened by selecting the cell and pressing down the right or middle button of the mouse. if false, the whole line is selected. The menu opened derives from the DataSetView, which is specified in the window specification (Basics).'
   697 'if true, each cell in the column can be selected. In case of having a menu, the menu can be opened by selecting the cell and pressing down the right or middle button of the mouse. if false, the whole line is selected. The menu opened derives from the DataSetView, which is specified in the window specification (Basics).'
   655 
   698 
   656 #choices
   699 #choices
   657 'selector to get the collection of choices for a column which is selectable and its editor is kind of a ComboBox or ComboList. If a cell in the column is selected, the visual editor is opened and in case of having choices, the choices are assigned to the widget.'
   700 'selector to get the collection of choices for a column which is selectable and its editor is kind of a ComboBox or ComboList. If a cell in the column is selected, the visual editor is opened and in case of having choices, the choices are assigned to the widget.'
   660 'type of visual editor (using default editors) or a selector, which will return an visual editor. If the cell is selected, a visual editor is opened in in the cell. In case of an unsupported selector (user defined editor), the row object is asked for the visual editor by performing the selector on the row. A widget instance must be returned which is opened in the cell.'
   703 'type of visual editor (using default editors) or a selector, which will return an visual editor. If the cell is selected, a visual editor is opened in in the cell. In case of an unsupported selector (user defined editor), the row object is asked for the visual editor by performing the selector on the row. A widget instance must be returned which is opened in the cell.'
   661 
   704 
   662 #foregroundColor
   705 #foregroundColor
   663 'set the foreground color of the column  if the color-checkBox is turned on. Otherwise, the column uses its default foreground color (which is specified in the styleSheet).'
   706 'set the foreground color of the column  if the color-checkBox is turned on. Otherwise, the column uses its default foreground color (which is specified in the styleSheet).'
   664 
   707 
       
   708 #foregroundSelector
       
   709 'selector which returns the foreground color for a cell (optional). If the selector is nil or returns nil, the default foreground color is set.'
       
   710 
   665 #formatString
   711 #formatString
   666 'format string, which specifies the output format of a text in a cell. \ At the moment only numbers are supported. \ \ for example: 0.0000'
   712 'format string, which specifies the output format of a text in a cell. \ At the moment only numbers are supported. \ \ for example: 0.0000'
   667 
   713 
   668 #height
   714 #height
   669 'preferred height (optional)'
   715 'preferred height (optional)'
   682 
   728 
   683 #printSelector
   729 #printSelector
   684 'a selector with one argument, the DataSetView. Used to access a drawable display object. In case of nil, the value derived from the readSelector is shown in the unselected cell.\ \ Using bitmaps, the DataSetView offers three important methods:\ \ #registerImage:anImage key:aSymbol\ register an image with an unique symbol. This symbol can be used by the row object to access the image, using #registeredImageAt:. The image will be associated to the device.\ \ #registeredImageAt:aSymbol\ returns an image assigned to the symbol or nil. The image returned is associated to the device.\ \ #releaseAllRegisteredImages\ relaese all registered images'
   730 'a selector with one argument, the DataSetView. Used to access a drawable display object. In case of nil, the value derived from the readSelector is shown in the unselected cell.\ \ Using bitmaps, the DataSetView offers three important methods:\ \ #registerImage:anImage key:aSymbol\ register an image with an unique symbol. This symbol can be used by the row object to access the image, using #registeredImageAt:. The image will be associated to the device.\ \ #registeredImageAt:aSymbol\ returns an image assigned to the symbol or nil. The image returned is associated to the device.\ \ #releaseAllRegisteredImages\ relaese all registered images'
   685 
   731 
   686 #readSelector
   732 #readSelector
   687 'a selector, which is used to get or set the value of a cell. The value returned by the method can be a string object or a bitmap. The set operation only is performed if the column is selectable.'
   733 'a selector, which is used to get or set (if the write selector is undefined) the value of a cell. The value returned by the method can be a string object or a bitmap. The set operation only is performed if the column is selectable.'
   688 
   734 
   689 #rendererType
   735 #rendererType
   690 'This type specifies, how the text of an unselected cell should be shown. As Text, CheckToggle, ComboBox, ComboList or as a RowSelector.'
   736 'This type specifies, how the text of an unselected cell should be shown. As Text, CheckToggle, ComboBox, ComboList or as a RowSelector.'
   691 
   737 
   692 #selectSelector
   738 #selectSelector
   704 #type
   750 #type
   705 'a type converter symbol used by the input field'
   751 'a type converter symbol used by the input field'
   706 
   752 
   707 #width
   753 #width
   708 'the width of a fixed column; in case of nil or 0 the column width will be computed dependent on the contents.'
   754 'the width of a fixed column; in case of nil or 0 the column width will be computed dependent on the contents.'
       
   755 
       
   756 #writeSelector
       
   757 'a selector, which is used to set the value of a cell. If the selector is not defined, the selector derives from the printSelector.'
   709 
   758 
   710 )
   759 )
   711 ! !
   760 ! !
   712 
   761 
   713 !DataSetBuilder class methodsFor:'images'!
   762 !DataSetBuilder class methodsFor:'images'!
  1296 
  1345 
  1297     self generateChoicesIn:cls.
  1346     self generateChoicesIn:cls.
  1298     self generateMenuIn:cls.
  1347     self generateMenuIn:cls.
  1299     self generatePrintSelectorIn:cls.
  1348     self generatePrintSelectorIn:cls.
  1300     self generateReadSelectorIn:cls.
  1349     self generateReadSelectorIn:cls.
       
  1350     self generateBackgroundSelectorIn:cls.
       
  1351     self generateForegroundSelectorIn:cls.
  1301     self generateSelectSelectorIn:cls.
  1352     self generateSelectSelectorIn:cls.
  1302     self generateWriteSelectorIn:cls.
  1353     self generateWriteSelectorIn:cls.
  1303 !
  1354 !
  1304 
  1355 
  1305 doMoveColumn:upOrDown
  1356 doMoveColumn:upOrDown
  1542 
  1593 
  1543 compile:aCode forClass:aClass inCategory:aCategory
  1594 compile:aCode forClass:aClass inCategory:aCategory
  1544     "compile method for class in a category
  1595     "compile method for class in a category
  1545     "
  1596     "
  1546     ByteCodeCompiler compile:aCode withCRs forClass:aClass inCategory:aCategory
  1597     ByteCodeCompiler compile:aCode withCRs forClass:aClass inCategory:aCategory
       
  1598 !
       
  1599 
       
  1600 generateBackgroundSelectorIn:aClass
       
  1601     "generate code for #backgroundSelector
       
  1602     "
       
  1603     |sel catg code bCode|
       
  1604 
       
  1605     catg := 'accessing colors' asSymbol.
       
  1606     code :=   '\'
       
  1607             , '    "automatically generated by DataSetBuilder ..."\'
       
  1608             , '\'
       
  1609             , '    "specific background color for a cell"\'
       
  1610             , '\'
       
  1611             .
       
  1612 
       
  1613     columns do:[:aCol|
       
  1614         ((sel := aCol backgroundSelector) notNil and:[(aClass implements:sel) not]) ifTrue:[
       
  1615             bCode := sel asString, code, '    ^ nil'.
       
  1616             self compile:bCode forClass:aClass inCategory:catg
       
  1617         ]
       
  1618     ]
       
  1619 
       
  1620 
  1547 !
  1621 !
  1548 
  1622 
  1549 generateChoicesIn:aClass
  1623 generateChoicesIn:aClass
  1550     "generate code for #choices
  1624     "generate code for #choices
  1551     "
  1625     "
  1567          and:[(aClass implements:sel) not]]]
  1641          and:[(aClass implements:sel) not]]]
  1568         ) ifTrue:[
  1642         ) ifTrue:[
  1569             self compile:(sel asString, code) forClass:aClass inCategory:catg
  1643             self compile:(sel asString, code) forClass:aClass inCategory:catg
  1570         ]
  1644         ]
  1571     ]
  1645     ]
       
  1646 !
       
  1647 
       
  1648 generateForegroundSelectorIn:aClass
       
  1649     "generate code for #foregroundSelector
       
  1650     "
       
  1651     |sel catg code bCode|
       
  1652 
       
  1653     catg := 'accessing colors' asSymbol.
       
  1654     code :=   '\'
       
  1655             , '    "automatically generated by DataSetBuilder ..."\'
       
  1656             , '\'
       
  1657             , '    "specific foreground color for a cell"\'
       
  1658             , '\'
       
  1659             .
       
  1660 
       
  1661     columns do:[:aCol|
       
  1662         ((sel := aCol foregroundSelector) notNil and:[(aClass implements:sel) not]) ifTrue:[
       
  1663             bCode := sel asString, code, '    ^ nil'.
       
  1664             self compile:bCode forClass:aClass inCategory:catg
       
  1665         ]
       
  1666     ]
       
  1667 
       
  1668 
  1572 !
  1669 !
  1573 
  1670 
  1574 generateMenuIn:aClass
  1671 generateMenuIn:aClass
  1575     "generate code for #menu
  1672     "generate code for #menu
  1576     "
  1673     "
  1735         type
  1832         type
  1736         width
  1833         width
  1737         minWidth
  1834         minWidth
  1738         height
  1835         height
  1739         menu
  1836         menu
       
  1837         foregroundSelector
       
  1838         backgroundSelector
  1740         selectSelector
  1839         selectSelector
  1741         printSelector
  1840         printSelector
  1742         readSelector
  1841         readSelector
  1743         writeSelector
  1842         writeSelector
  1744         rendererType
  1843         rendererType