LabelledEnterField.st
changeset 56 aa651da467e2
parent 53 b14d7766c3a2
child 62 378b60ba1200
equal deleted inserted replaced
55:75c4a8031e66 56:aa651da467e2
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 SimpleView subclass:#LabelledEnterField
    13 View subclass:#LabelledEnterField
    14 	 instanceVariableNames:'labelField textField'
    14 	 instanceVariableNames:'labelField textField'
    15 	 classVariableNames:''
    15 	 classVariableNames:''
    16 	 poolDictionaries:''
    16 	 poolDictionaries:''
    17 	 category:'Views-Interactors'
    17 	 category:'Views-Interactors'
    18 !
    18 !
    19 
    19 
    20 LabelledEnterField comment:'
    20 LabelledEnterField comment:'
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.6 1995-05-07 00:18:17 claus Exp $
    24 $Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.7 1995-05-12 18:34:16 claus Exp $
    25 written winter 91 by claus
    25 written winter 91 by claus
    26 '!
    26 '!
    27 
    27 
    28 !LabelledEnterField class methodsFor:'documentation'!
    28 !LabelledEnterField class methodsFor:'documentation'!
    29 
    29 
    30 documentation
    30 documentation
    31 "
    31 "
    32     An EnterField with a name.
    32     An EnterField with a name. Its protocol mimics that of an
    33 
    33     inputfield for the most common cases. However, for access to
       
    34     some specific things, you have to get the components 
       
    35     (labelField and inputField)
       
    36     and send those message directly.
       
    37 "
       
    38 !
       
    39 
       
    40 examples 
       
    41 "
       
    42     |top panel f1 f2 f3 f4 model data|
       
    43 
       
    44     data := #('John' 'F' 'Smith' '1234567').
       
    45     model := Plug new.
       
    46     model respondTo:#firstName with:[data at:1].
       
    47     model respondTo:#firstName: with:[:arg | data at:1 put:arg].
       
    48     model respondTo:#middleInitial with:[data at:2].
       
    49     model respondTo:#middleInitial: with:[:arg | data at:2 put:arg].
       
    50     model respondTo:#lastName with:[data at:3].
       
    51     model respondTo:#lastName: with:[:arg | data at:3 put:arg].
       
    52     model respondTo:#telNo with:[data at:4].
       
    53     model respondTo:#telNo: with:[:arg | data at:4 put:arg].
       
    54 
       
    55     top := StandardSystemView new.
       
    56     top extent:300@300.
       
    57 
       
    58     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
       
    59     panel verticalLayout:#topSpace.
       
    60 
       
    61     f1 := LabelledEnterField new.
       
    62     f1 label:'Firstname:'.
       
    63     f1 model:model; aspect:#firstName; change:#firstName:.
       
    64     panel add:f1.
       
    65 
       
    66     f2 := LabelledEnterField new.
       
    67     f2 label:'Middle Initial:'.
       
    68     f2 model:model; aspect:#middleInitial; change:#middleInitial:.
       
    69     panel add:f2.
       
    70 
       
    71     f3 := LabelledEnterField new.
       
    72     f3 label:'Lastname:'.
       
    73     f3 model:model; aspect:#lastName; change:#lastName:.
       
    74     panel add:f3.
       
    75 
       
    76     f4 := LabelledEnterField new.
       
    77     f4 label:'Telephone:'.
       
    78     f4 model:model; aspect:#telNo; change:#telNo:.
       
    79     panel add:f4.
       
    80 
       
    81     top open
    34 "
    82 "
    35 !
    83 !
    36 
    84 
    37 version
    85 version
    38 "
    86 "
    39 $Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.6 1995-05-07 00:18:17 claus Exp $
    87 $Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.7 1995-05-12 18:34:16 claus Exp $
    40 "
    88 "
    41 !
    89 !
    42 
    90 
    43 copyright
    91 copyright
    44 "
    92 "
    59 initialize
   107 initialize
    60     "setup; create the label and an enterfield"
   108     "setup; create the label and an enterfield"
    61 
   109 
    62     super initialize.
   110     super initialize.
    63 
   111 
    64     labelField := Label in:self.
   112     labelField := Label label:'l' in:self.
       
   113     textField := EditField in:self.
       
   114 
       
   115     labelField resize.
    65     labelField level:0.
   116     labelField level:0.
    66     labelField origin:[margin @ (margin + textField margin)].
   117     labelField origin:(margin @ (margin + textField margin)).
    67 
   118 
    68     textField := EditField in:self.
       
    69     textField origin:[(labelField origin x + labelField width) @ level]
   119     textField origin:[(labelField origin x + labelField width) @ level]
    70 	      extent:[(self width 
   120 	      extent:[(self width 
    71 		      - margin - margin
   121 		      - margin - margin
    72 		      - labelField width) @ (textField heightIncludingBorder)].
   122 		      - labelField width) @ (textField heightIncludingBorder)].
    73 
   123 
    79     "
   129     "
    80      LabelledEnterField new realize
   130      LabelledEnterField new realize
    81     "
   131     "
    82 ! !
   132 ! !
    83 
   133 
       
   134 !LabelledEnterField methodsFor:'queries'!
       
   135 
       
   136 preferedExtent
       
   137     |p lx ly ix iy|
       
   138 
       
   139     p := labelField preferedExtent.
       
   140     lx := p x. ly := p y.
       
   141     p := textField preferedExtent.
       
   142     ix := p x. iy := p y.
       
   143     ^ (lx + ix) @ (ly max:iy)
       
   144 ! !
       
   145 
    84 !LabelledEnterField methodsFor:'accessing'!
   146 !LabelledEnterField methodsFor:'accessing'!
    85 
   147 
       
   148 labelView
       
   149     "return the label component"
       
   150 
       
   151     ^ labelField
       
   152 !
       
   153 
       
   154 inputField
       
   155     "return the input field component"
       
   156 
       
   157     ^ textField
       
   158 ! !
       
   159 
       
   160 !LabelledEnterField methodsFor:'accessing-behavior'!
       
   161 
    86 disable
   162 disable
    87    textField disable
   163     textField disable
    88 !
   164 !
       
   165 
       
   166 enable
       
   167     textField enable
       
   168 ! !
       
   169 
       
   170 !LabelledEnterField methodsFor:'accessing-mvc'!
       
   171 
       
   172 model:aModel
       
   173     textField model:aModel.
       
   174     labelField model:aModel
       
   175 !
       
   176 
       
   177 changeMessage:aSymbol
       
   178     textField changeMessage:aSymbol
       
   179 !
       
   180 
       
   181 aspect:aspectSymbol 
       
   182     textField aspect:aspectSymbol.
       
   183     labelField aspect:aspectSymbol
       
   184 !
       
   185 
       
   186 labelMessage:aSymbol 
       
   187     labelField labelMessage:aSymbol
       
   188 !
       
   189 
       
   190 addModelInterfaceTo:aDictionary
       
   191     labelField addModelInterfaceTo:aDictionary.
       
   192     textField addModelInterfaceTo:aDictionary
       
   193 ! !
       
   194 
       
   195 !LabelledEnterField methodsFor:'accessing-look'!
    89 
   196 
    90 label:aString
   197 label:aString
    91     labelField label:aString
   198     labelField label:aString
    92 !
   199 !
    93 
   200 
       
   201 editValue 
       
   202     ^ textField editValue 
       
   203 !
       
   204 
       
   205 editValue:something 
       
   206     textField editValue:something 
       
   207 !
       
   208 
    94 contents
   209 contents
    95     ^ textField contents
   210     ^ textField contents
    96 !
   211 !
    97 
   212 
    98 contents:aString
   213 contents:aString