TextBox.st
changeset 3956 32c277e2d606
parent 3571 15340c832dd7
child 4466 7b936f52873d
equal deleted inserted replaced
3955:94fb4a47d108 3956:32c277e2d606
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
    13 
    13 
    14 EnterBox subclass:#TextBox
    14 EnterBox subclass:#TextBox
    15 	instanceVariableNames:'textView'
    15 	instanceVariableNames:'textViewClass textView'
    16 	classVariableNames:''
    16 	classVariableNames:''
    17 	poolDictionaries:''
    17 	poolDictionaries:''
    18 	category:'Views-DialogBoxes'
    18 	category:'Views-DialogBoxes'
    19 !
    19 !
    20 
    20 
   112     ^ returnValue.
   112     ^ returnValue.
   113 
   113 
   114     "
   114     "
   115      TextBox openOn:'hello' title:'hi there'
   115      TextBox openOn:'hello' title:'hi there'
   116     "
   116     "
       
   117 !
       
   118 
       
   119 openOn:someText title:titleString readOnly:readOnly
       
   120     "open a textBox on some text, 
       
   121      return (the possibly modified) text if accepted; nil otherwise."
       
   122 
       
   123     |box returnValue|
       
   124 
       
   125     box := self basicNew.
       
   126     readOnly ifTrue:[ box textViewClass:TextView ].
       
   127     box initialize.
       
   128     box title:titleString.
       
   129     box initialText:someText.
       
   130     box action:[:text | returnValue := text].
       
   131     box readOnly:readOnly.
       
   132     box showAtPointer.
       
   133     ^ returnValue.
       
   134 
       
   135     "
       
   136      TextBox openOn:'hello' title:'hi there' readOnly:true
       
   137      TextBox openOn:'hello' title:'hi there' readOnly:false
       
   138     "
       
   139 
       
   140     "Created: / 29-10-2010 / 17:10:04 / cg"
   117 ! !
   141 ! !
   118 
   142 
   119 !TextBox class methodsFor:'defaults'!
   143 !TextBox class methodsFor:'defaults'!
   120 
   144 
   121 defaultExtent
   145 defaultExtent
   142     textView readOnly:aBoolean
   166     textView readOnly:aBoolean
   143 !
   167 !
   144 
   168 
   145 textView
   169 textView
   146     ^ textView
   170     ^ textView
       
   171 !
       
   172 
       
   173 textViewClass:something
       
   174     textViewClass := something.
   147 ! !
   175 ! !
   148 
   176 
   149 !TextBox methodsFor:'initialization'!
   177 !TextBox methodsFor:'initialization'!
   150 
   178 
   151 initialize
   179 initialize
   162      depend on it (extent blocks are not evaluated until view is realized)
   190      depend on it (extent blocks are not evaluated until view is realized)
   163      - avoid visible resizing when realized the first time"
   191      - avoid visible resizing when realized the first time"
   164 
   192 
   165     innerWidth := width - space2.
   193     innerWidth := width - space2.
   166 
   194 
   167     textView := HVScrollableView for:EditTextView miniScrollerH:true in:self.
   195     textView := HVScrollableView for:(textViewClass ? EditTextView) miniScrollerH:true in:self.
   168     textView origin:(ViewSpacing @ (space2 + labelField height))
   196     textView origin:(ViewSpacing @ (space2 + labelField height))
   169              extent:(innerWidth @ (height - ViewSpacing -
   197              extent:(innerWidth @ (height - ViewSpacing -
   170                                    labelField height - ViewSpacing -
   198                                    labelField height - ViewSpacing -
   171                                    buttonPanel height - space3) ).
   199                                    buttonPanel height - space3) ).
   172     textView origin:[ViewSpacing @ (space2 + labelField height)]
   200     textView origin:[ViewSpacing @ (space2 + labelField height)]
   175                                    buttonPanel height - space3) ].
   203                                    buttonPanel height - space3) ].
   176 
   204 
   177     self delegate:(KeyboardForwarder toView:textView scrolledView)
   205     self delegate:(KeyboardForwarder toView:textView scrolledView)
   178 
   206 
   179     "TextBox new showAtPointer"
   207     "TextBox new showAtPointer"
       
   208 
       
   209     "Modified: / 29-10-2010 / 17:14:49 / cg"
   180 ! !
   210 ! !
   181 
   211 
   182 !TextBox methodsFor:'queries'!
   212 !TextBox methodsFor:'queries'!
   183 
   213 
   184 preferredExtent
   214 preferredExtent
   214 ! !
   244 ! !
   215 
   245 
   216 !TextBox class methodsFor:'documentation'!
   246 !TextBox class methodsFor:'documentation'!
   217 
   247 
   218 version
   248 version
   219     ^ '$Header: /cvs/stx/stx/libwidg2/TextBox.st,v 1.20 2008-10-26 20:10:23 stefan Exp $'
   249     ^ '$Header: /cvs/stx/stx/libwidg2/TextBox.st,v 1.21 2010-10-29 15:16:22 cg Exp $'
   220 ! !
   250 !
       
   251 
       
   252 version_CVS
       
   253     ^ '$Header: /cvs/stx/stx/libwidg2/TextBox.st,v 1.21 2010-10-29 15:16:22 cg Exp $'
       
   254 ! !