0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
26
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
EnterBox subclass:#TextBox
|
26
|
14 |
instanceVariableNames:'textView'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-DialogBoxes'
|
0
|
18 |
!
|
|
19 |
|
13
|
20 |
!TextBox class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
26
|
25 |
All Rights Reserved
|
13
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
0
|
35 |
|
13
|
36 |
version
|
184
|
37 |
^ '$Header: /cvs/stx/stx/libwidg2/TextBox.st,v 1.13 1996-05-18 15:43:33 cg Exp $'
|
13
|
38 |
!
|
|
39 |
|
|
40 |
documentation
|
|
41 |
"
|
|
42 |
this class implements a pop-up box to enter some text with 2 buttons,
|
|
43 |
one to cancel, another to start some action.
|
|
44 |
It is basically an enterBox, but allows entering of more than one line
|
|
45 |
of text.
|
26
|
46 |
"
|
|
47 |
!
|
13
|
48 |
|
26
|
49 |
examples
|
|
50 |
"
|
13
|
51 |
Example:
|
|
52 |
|
26
|
53 |
|t|
|
13
|
54 |
|
26
|
55 |
t := TextBox new.
|
|
56 |
t title:'enter some text'.
|
184
|
57 |
t action:[:text | Transcript showCR:('the entered text was:\' , text) withCRs].
|
26
|
58 |
t showAtPointer
|
13
|
59 |
"
|
|
60 |
! !
|
0
|
61 |
|
|
62 |
!TextBox class methodsFor:'defaults'!
|
|
63 |
|
|
64 |
defaultExtent
|
|
65 |
^ (Display pixelPerMillimeter * (120 @ 90)) rounded
|
|
66 |
! !
|
|
67 |
|
|
68 |
!TextBox methodsFor:'initialization'!
|
|
69 |
|
|
70 |
initialize
|
|
71 |
|space2 space3 innerWidth|
|
|
72 |
|
|
73 |
super initialize.
|
|
74 |
|
|
75 |
space2 := 2 * ViewSpacing.
|
|
76 |
space3 := 3 * ViewSpacing.
|
|
77 |
|
|
78 |
"kludge: preset extent to something useful since other subviews
|
|
79 |
depend on it (extent blocks are not evaluated until view is realized)
|
|
80 |
- avoid visible resizing when realized the first time"
|
|
81 |
|
|
82 |
innerWidth := width - space2.
|
|
83 |
|
46
|
84 |
textView := HVScrollableView for:EditTextView miniScrollerH:true in:self.
|
0
|
85 |
textView origin:(ViewSpacing @ (space2 + labelField height))
|
26
|
86 |
extent:(innerWidth @ (height - ViewSpacing -
|
|
87 |
labelField height - ViewSpacing -
|
|
88 |
buttonPanel height - space3) ).
|
0
|
89 |
textView origin:[ViewSpacing @ (space2 + labelField height)]
|
26
|
90 |
extent:[(width - space2) @ (height - ViewSpacing -
|
|
91 |
labelField height - ViewSpacing -
|
|
92 |
buttonPanel height - space3) ].
|
0
|
93 |
|
54
|
94 |
self delegate:(KeyboardForwarder toView:textView scrolledView)
|
0
|
95 |
|
|
96 |
"TextBox new showAtPointer"
|
|
97 |
! !
|
|
98 |
|
26
|
99 |
!TextBox methodsFor:'queries'!
|
0
|
100 |
|
62
|
101 |
preferredExtent
|
26
|
102 |
"return the extent needed to make everything visible"
|
0
|
103 |
|
|
104 |
|wWanted hWanted wPanel|
|
|
105 |
|
|
106 |
wWanted := labelField width + ViewSpacing + ViewSpacing.
|
|
107 |
(wWanted > width) ifFalse:[
|
26
|
108 |
wWanted := width
|
0
|
109 |
].
|
|
110 |
wPanel := ViewSpacing * 3.
|
|
111 |
buttonPanel subViews do:[:aView |
|
26
|
112 |
wPanel := wPanel + aView width + ViewSpacing
|
0
|
113 |
].
|
|
114 |
wPanel > wWanted ifTrue:[
|
26
|
115 |
wWanted := wPanel
|
0
|
116 |
].
|
|
117 |
hWanted := ViewSpacing + labelField height +
|
26
|
118 |
ViewSpacing + textView height +
|
62
|
119 |
(ViewSpacing * 6) + buttonPanel preferredExtent y +
|
26
|
120 |
ViewSpacing.
|
|
121 |
^ (wWanted @ hWanted)
|
0
|
122 |
! !
|
|
123 |
|
|
124 |
!TextBox methodsFor:'accessing'!
|
|
125 |
|
|
126 |
initialText:aString
|
|
127 |
"define the initial text in the enterfield"
|
|
128 |
|
|
129 |
textView contents:aString
|
|
130 |
!
|
|
131 |
|
47
|
132 |
textView
|
|
133 |
^ textView
|
|
134 |
!
|
|
135 |
|
0
|
136 |
contents
|
|
137 |
"return my contents"
|
|
138 |
|
|
139 |
^ textView contents
|
|
140 |
! !
|