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