author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 21 May 2015 21:14:57 +0100 | |
branch | jv |
changeset 4770 | 6634b540fea2 |
parent 4681 | b97620c35200 |
child 5010 | 48191c4158e8 |
permissions | -rw-r--r-- |
4770
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
1 |
" |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
3 |
All Rights Reserved |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
4 |
|
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
5 |
This software is furnished under a license and may be used |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
10 |
hereby transferred. |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
11 |
" |
3650 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
4770
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
15 |
|
3650 | 16 |
Button subclass:#LinkButton |
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
17 |
instanceVariableNames:'labelsAndActions' |
3662 | 18 |
classVariableNames:'DefaultLinkColor' |
3650 | 19 |
poolDictionaries:'' |
20 |
category:'Views-Layout' |
|
21 |
! |
|
22 |
||
23 |
!LinkButton class methodsFor:'documentation'! |
|
24 |
||
4770
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
25 |
copyright |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
26 |
" |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
28 |
All Rights Reserved |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
29 |
|
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
30 |
This software is furnished under a license and may be used |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
35 |
hereby transferred. |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
36 |
" |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
37 |
! |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4681
diff
changeset
|
38 |
|
3650 | 39 |
documentation |
40 |
" |
|
41 |
Looks like a Label, but behaves like a button with individually clickable text components. |
|
4071 | 42 |
Can be used to create html-page-look-alike links in a view. |
3650 | 43 |
|
44 |
[author:] |
|
45 |
cg (cg@CG-VOSTRO) |
|
46 |
||
47 |
[instance variables:] |
|
48 |
||
49 |
[class variables:] |
|
50 |
||
51 |
[see also:] |
|
52 |
||
53 |
" |
|
54 |
! |
|
55 |
||
56 |
examples |
|
57 |
" |
|
4071 | 58 |
[exBegin] |
3650 | 59 |
|v l| |
60 |
||
61 |
v := StandardSystemView new. |
|
62 |
l := LinkButton in:v. |
|
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
63 |
l label: |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
64 |
(('Hello' actionForAll:[ Transcript showCR:'Hello Clicked']) |
4071 | 65 |
, ' ' |
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
66 |
, ('World' actionForAll:[ Transcript showCR:'World Clicked'])). |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
67 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
68 |
v open |
4071 | 69 |
[exEnd] |
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
70 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
71 |
|
4071 | 72 |
[exBegin] |
73 |
|v l| |
|
74 |
||
75 |
v := StandardSystemView new. |
|
76 |
l := LinkButton in:v. |
|
77 |
l label: |
|
78 |
((('Hello' actionForAll:[ Transcript showCR:'Hello Clicked']) colorizeAllWith:(Color blue)) |
|
79 |
, ' ' |
|
80 |
, ('World' actionForAll:[ Transcript showCR:'World Clicked'])). |
|
81 |
||
82 |
v open |
|
83 |
[exEnd] |
|
84 |
||
85 |
||
86 |
[exBegin] |
|
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
87 |
|v l| |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
88 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
89 |
v := StandardSystemView new. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
90 |
l := LinkButton in:v. |
3650 | 91 |
l labelsAndActions:{ |
3662 | 92 |
'Hello' -> [ Transcript showCR:'Hello Clicked']. |
3650 | 93 |
' ' -> nil. |
3662 | 94 |
'World' -> [ Transcript showCR:'World Clicked']. |
3650 | 95 |
}. |
96 |
l foregroundColor:Color blue. |
|
97 |
v open |
|
4071 | 98 |
[exEnd] |
3668 | 99 |
|
100 |
||
4071 | 101 |
[exBegin] |
3668 | 102 |
|v l| |
103 |
||
104 |
v := StandardSystemView new. |
|
105 |
l := LinkButton in:v. |
|
106 |
l labelsAndActions:{ |
|
107 |
'Hello' -> nil. |
|
108 |
' ' -> nil. |
|
109 |
'World' -> [ Transcript showCR:'World Clicked']. |
|
110 |
}. |
|
111 |
l foregroundColor:Color blue. |
|
112 |
v open |
|
4071 | 113 |
[exEnd] |
3650 | 114 |
" |
115 |
! ! |
|
116 |
||
3662 | 117 |
!LinkButton class methodsFor:'defaults'! |
118 |
||
119 |
updateStyleCache |
|
120 |
"extract values from the styleSheet and cache them in class variables" |
|
121 |
||
122 |
<resource: #style ( #'linkButton.linkColor' )> |
|
123 |
||
124 |
DefaultLinkColor := StyleSheet colorAt:#'linkButton.linkColor' default:Color blue. |
|
125 |
! ! |
|
126 |
||
3650 | 127 |
!LinkButton methodsFor:'accessing'! |
128 |
||
129 |
labelsAndActions |
|
130 |
"returns the collection of label->action associations. |
|
131 |
For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to). |
|
132 |
When clicked on a string, the corresponding action is called" |
|
133 |
||
134 |
^ labelsAndActions |
|
135 |
! |
|
136 |
||
137 |
labelsAndActions:aCollectionOfAssociations |
|
138 |
"set the collection of label->action associations. |
|
139 |
For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to). |
|
140 |
When clicked on a string, the corresponding action is called" |
|
141 |
||
142 |
labelsAndActions := aCollectionOfAssociations. |
|
143 |
self label:((aCollectionOfAssociations collect:[:assoc | assoc key]) asStringWith:'') |
|
144 |
! ! |
|
145 |
||
146 |
!LinkButton methodsFor:'initialization'! |
|
147 |
||
4677 | 148 |
allViewBackground:something if:condition |
149 |
"set the viewBackground to something, a color, image or form, |
|
150 |
in myself and recursively in all of my subviews" |
|
151 |
||
152 |
self viewBackground:something if:condition. |
|
153 |
self backgroundColor:something. |
|
154 |
! |
|
155 |
||
3650 | 156 |
defaultControllerClass |
157 |
^ LinkButtonController |
|
3662 | 158 |
! |
159 |
||
160 |
initStyle |
|
161 |
super initStyle. |
|
162 |
||
163 |
level := enterLevel := leaveLevel := onLevel := offLevel := 0. |
|
4681 | 164 |
self borderWidth: 0. |
3662 | 165 |
DefaultLinkColor notNil ifTrue:[ |
4508 | 166 |
|color| |
167 |
self paint:(color := DefaultLinkColor onDevice:self graphicsDevice). |
|
168 |
self foreground:color. |
|
3662 | 169 |
]. |
4681 | 170 |
enteredFgColor := nil. |
171 |
enteredBgColor := nil. |
|
4071 | 172 |
|
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
173 |
"/ activeFgColor := enteredFgColor := foreground. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
174 |
"/ activeBgColor := enteredBgColor := viewBackground. |
4071 | 175 |
|
176 |
"Modified: / 07-09-2011 / 04:29:29 / cg" |
|
3662 | 177 |
! |
178 |
||
179 |
initialize |
|
180 |
super initialize. |
|
181 |
self enableMotionEvents |
|
182 |
! ! |
|
183 |
||
184 |
!LinkButton methodsFor:'redrawing'! |
|
185 |
||
186 |
actionAt:aPoint |
|
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
187 |
|pressAction emphasis| |
3664 | 188 |
|
4572 | 189 |
pressAction := self pressAction ifNil:[ self releaseAction ]. |
190 |
pressAction isNil ifTrue:[ |
|
191 |
pressAction := self pressChannel ifNil:[ self releaseChannel ]. |
|
192 |
]. |
|
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
193 |
labelsAndActions isNil ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
194 |
"take action from logo, which is normally a text" |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
195 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
196 |
emphasis := logo emphasisAtPoint:aPoint on:self. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
197 |
(emphasis isNil or:[emphasis isSymbol]) ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
198 |
^ pressAction. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
199 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
200 |
emphasis isAssociation ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
201 |
emphasis key == #actionBlock ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
202 |
^ emphasis value. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
203 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
204 |
^ pressAction. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
205 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
206 |
emphasis do:[:eachElement| |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
207 |
eachElement isAssociation ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
208 |
eachElement key == #actionBlock ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
209 |
^ eachElement value. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
210 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
211 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
212 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
213 |
^ pressAction. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
214 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
215 |
|
3662 | 216 |
self labelsAndActionsWithPositionsDo:[:lbl :action :leftX :rightX | |
217 |
(aPoint x between:leftX and:rightX) ifTrue:[ |
|
3664 | 218 |
^ labelsAndActions notNil ifTrue:action ifFalse:pressAction |
3662 | 219 |
]. |
220 |
]. |
|
221 |
^ nil |
|
222 |
! |
|
223 |
||
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
224 |
actionEmphasisIn:aText atPoint:aPoint |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
225 |
"check for a actionBlock emphasis in aString at aPoint. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
226 |
Answer an Array with the whole emphasis and the actionBlock, |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
227 |
or nil" |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
228 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
229 |
|emphasis| |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
230 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
231 |
emphasis := aText emphasisAtPoint:aPoint on:self. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
232 |
(emphasis isNil or:[emphasis isSymbol]) ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
233 |
^ #(nil nil). |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
234 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
235 |
emphasis isAssociation ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
236 |
emphasis key == #actionBlock ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
237 |
^ Array with:emphasis with:emphasis value. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
238 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
239 |
^ #(nil nil). |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
240 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
241 |
emphasis detect:[:eachElement| |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
242 |
eachElement isAssociation ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
243 |
eachElement key == #actionBlock ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
244 |
^ Array with:emphasis with:eachElement value. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
245 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
246 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
247 |
] ifNone:[]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
248 |
^ #(nil nil). |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
249 |
! |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
250 |
|
4680 | 251 |
drawFocusFrame |
252 |
"/ intentionally ignored |
|
253 |
^ self |
|
254 |
! |
|
255 |
||
3662 | 256 |
drawStringLogo:aString x:x y:y |
257 |
"redefined to draw the part under the mouse pointer with an underined emphasis" |
|
258 |
||
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
259 |
|str entered mousePoint start len emphasis| |
3662 | 260 |
|
261 |
mousePoint := controller lastMousePoint. |
|
262 |
entered := controller entered. |
|
263 |
||
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
264 |
labelsAndActions isNil ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
265 |
(entered not or:[mousePoint isNil]) ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
266 |
self displayString:aString x:x y:y. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
267 |
^ self. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
268 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
269 |
|
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
270 |
str := aString. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
271 |
emphasis := (self actionEmphasisIn:aString atPoint:mousePoint) first. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
272 |
emphasis notNil ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
273 |
start := 1. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
274 |
aString emphasisCollection runsDo:[:eachLen :eachEmphasis| |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
275 |
len isNil ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
276 |
eachEmphasis == emphasis ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
277 |
len := eachLen. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
278 |
] ifFalse:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
279 |
start := start + eachLen. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
280 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
281 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
282 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
283 |
len notNil ifTrue:[ |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
284 |
str := str deepCopy. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
285 |
str emphasisFrom:start to:start+len-1 add:#underline. |
4071 | 286 |
"/ str emphasisFrom:start to:start+len-1 add:(#color -> foreground). |
3670
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
287 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
288 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
289 |
self displayString:str x:x y:y. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
290 |
^ self. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
291 |
]. |
ccfd04be9736
Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents:
3668
diff
changeset
|
292 |
|
3662 | 293 |
self labelsAndActionsWithPositionsDo:[:lbl :action :leftX :rightX | |
294 |
|l| |
|
3668 | 295 |
|
3662 | 296 |
l := lbl. |
3668 | 297 |
action notNil ifTrue:[ |
298 |
(entered and:[mousePoint notNil and:[mousePoint x between:leftX and:rightX]]) ifTrue:[ |
|
299 |
l := l allUnderlined |
|
300 |
]. |
|
3662 | 301 |
]. |
302 |
self displayString:l x:leftX y:y. |
|
303 |
]. |
|
4071 | 304 |
|
305 |
"Modified: / 07-09-2011 / 04:47:13 / cg" |
|
3662 | 306 |
! |
307 |
||
4681 | 308 |
is3D |
309 |
^ false. |
|
310 |
! |
|
311 |
||
3662 | 312 |
labelsAndActionsWithPositionsDo:aFourArgBlock |
3664 | 313 |
|leftX rightX w| |
3662 | 314 |
|
315 |
leftX := labelOriginX. |
|
3664 | 316 |
labelsAndActions isNil ifTrue:[ |
4508 | 317 |
w := (self font widthOf:logo on:self graphicsDevice). |
3664 | 318 |
rightX := leftX + w-1. |
319 |
aFourArgBlock |
|
320 |
value:logo |
|
321 |
value:self pressAction |
|
322 |
value:leftX |
|
323 |
value:rightX. |
|
324 |
^ self |
|
325 |
]. |
|
326 |
||
3662 | 327 |
labelsAndActions do:[:assoc | |
328 |
|lbl wEach| |
|
329 |
||
330 |
lbl := assoc key. |
|
4508 | 331 |
wEach := (self font widthOf:lbl on:self graphicsDevice). |
3662 | 332 |
rightX := leftX + wEach-1. |
333 |
aFourArgBlock |
|
334 |
value:assoc key |
|
335 |
value:assoc value |
|
336 |
value:leftX |
|
337 |
value:rightX. |
|
338 |
||
339 |
leftX := rightX+1. |
|
340 |
]. |
|
341 |
^ nil |
|
3650 | 342 |
! ! |
343 |
||
344 |
!LinkButton class methodsFor:'documentation'! |
|
345 |
||
346 |
version |
|
4681 | 347 |
^ '$Header: /cvs/stx/stx/libwidg2/LinkButton.st,v 1.13 2014-12-02 18:35:56 cg Exp $' |
348 |
! |
|
349 |
||
350 |
version_CVS |
|
351 |
^ '$Header: /cvs/stx/stx/libwidg2/LinkButton.st,v 1.13 2014-12-02 18:35:56 cg Exp $' |
|
3650 | 352 |
! ! |
4508 | 353 |