author | Claus Gittinger <cg@exept.de> |
Sat, 24 Feb 1996 17:35:36 +0100 | |
changeset 392 | 81343306d796 |
parent 391 | b52dfc7728d9 |
child 416 | ac9754b3df67 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 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 |
View subclass:#Label |
|
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
14 |
instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust |
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
15 |
hSpace vSpace bgColor fgColor fixSize labelMsg converter |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
16 |
labelChannel foregroundChannel backgroundChannel' |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
17 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor' |
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
18 |
poolDictionaries:'' |
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
19 |
category:'Views-Layout' |
0 | 20 |
! |
21 |
||
3 | 22 |
!Label class methodsFor:'documentation'! |
23 |
||
38 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
38 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
3 | 38 |
documentation |
39 |
" |
|
38 | 40 |
This class implements labels, which are views to display a string or image. |
41 |
The Label will try to do its best to make its contents fit into the |
|
42 |
view. The contents can be a String, a collection of Strings (i.e. |
|
118 | 43 |
a StringCollection) or a Form/Image. |
63 | 44 |
|
45 |
The contents is drawn in fgColor/bgColor, which can be changed using: |
|
46 |
||
59 | 47 |
aLabel foregroundColor:aColor |
48 |
aLabel backgroundColor:aColor |
|
3 | 49 |
|
38 | 50 |
When a label is assigned a contents, it will resize itself to fit |
51 |
the required size. This resizing can be suppressed by setting the |
|
52 |
fixsize attribute to true using: |
|
63 | 53 |
|
59 | 54 |
aLabel sizeFixed:true |
3 | 55 |
|
38 | 56 |
This can be used, if resizing of the label is not wanted. |
63 | 57 |
However, in this case you have to make certain that the size is big enough |
118 | 58 |
to hold any changed logos later. (usually, you create the label first with |
59 |
the longest string first to have it compute its size, then set the fixSize |
|
60 |
attribute to avoid resizing later). |
|
125 | 61 |
Be careful when placing self-resizing labels into panels - by default, |
62 |
panels do not react on the size change - leading to ugly looking geometry. |
|
63 |
(but you can tell the panel to watch for changes with #elementsCHangeSize:) |
|
38 | 64 |
|
65 |
The placement of the contents within the label is controlled by |
|
63 | 66 |
the adjust attribute, it can be set with: |
67 |
||
59 | 68 |
aLabel adjust:how |
3 | 69 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
70 |
where how is one of the symbols left, #right, #center, #centerLeft, |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
71 |
#centerRight, #leftRight or #rightLeft (see the comment in Label>>adjust:). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
72 |
The default is #center. |
3 | 73 |
|
145 | 74 |
model-less operation (ok for static labels): |
118 | 75 |
if no model is set, the labels contents is set with: |
76 |
||
77 |
aLabel label:aStringOrImage |
|
78 |
||
79 |
and stays constant unless changed by new calls to #label:. |
|
80 |
||
81 |
||
145 | 82 |
model operation (ST-80 style): |
118 | 83 |
labels with a model, aspectMsg and labelMsg react to |
84 |
changes of the aspect, and send a labelMsg-message |
|
85 |
to the model in order to aquire a new labelString or image. |
|
86 |
The model should send 'self changed:aspectMsg' if it thinks the label |
|
87 |
should change and return a string or image from the labelMsg-message. |
|
88 |
||
89 |
label model:aModel. |
|
90 |
label aspect:aspectSymbol. |
|
91 |
label labelMessage:labelSymbol. |
|
92 |
||
93 |
model sends #changed:aspectSymbol |
|
94 |
---> label will redraw its label from value of model perform:labelSymbol |
|
95 |
||
96 |
Having a labelSymbol different from the aspectSymbol allows for two labels |
|
97 |
to react on the same aspect-change, but use different messages when asking |
|
98 |
the model for a new label contents. By default, the labelMsg is nil, |
|
99 |
so the label does NOT update its shown contents. |
|
100 |
The aspectMsg defaults to #value. |
|
101 |
||
125 | 102 |
|
145 | 103 |
|
104 |
channel operation (new ST/X style): |
|
105 |
||
106 |
the label will react on changes of the token found in the |
|
107 |
channels: foregroundChannel, backgroundChannel and labelChannel. |
|
108 |
These are valueHolders and can be shared between labels. |
|
109 |
||
110 |
||
111 |
||
38 | 112 |
Instance variables: |
3 | 113 |
|
59 | 114 |
logo <Object> the logo, can be a Form, String or Text |
115 |
labelWidth <Integer> the width of the logo in device units |
|
116 |
labelHeight <Integer> the height of the logo in device units |
|
117 |
labelOriginX <Integer> the x-position of the logo withing the Label |
|
118 |
labelOriginY <Integer> the y-position of the logo withing the Label |
|
119 |
adjust <Symbol> controls how the logo is positioned within the |
|
120 |
label. Can be one of:#left,#right,#center, |
|
121 |
#centerLeft or #centerRight (see comment in adjust:) |
|
122 |
hSpace <Integer> number of horizontal pixels around logo |
|
123 |
vSpace <Integer> number of vertical pixels around logo |
|
3 | 124 |
|
59 | 125 |
bgColor <Color> background color |
126 |
fgColor <Color> foreground color |
|
38 | 127 |
|
59 | 128 |
fixSize <Boolean> if true, a change of the logo change will not |
129 |
resize the label; otherwise, its size is adjusted. |
|
130 |
default:false. |
|
50 | 131 |
|
118 | 132 |
labelMsg <Symbol> if non-nil, this is sent to the model to |
133 |
aquire the labelString or labelImage. |
|
134 |
If nil, the label stays as is |
|
113 | 135 |
|
118 | 136 |
styleSheet parameters: |
50 | 137 |
|
118 | 138 |
labelForegroundColor <Color> color to draw foreground pixels (i.e. the string) |
139 |
labelBackgroundColor <Color> color to draw background pixels |
|
140 |
labelFont <Font> font to use for textual labels |
|
3 | 141 |
" |
63 | 142 |
! |
143 |
||
144 |
examples |
|
145 |
" |
|
146 |
Notice, that Buttons and others inherit from Label; |
|
147 |
therefore, the following geometry examples apply to all subclasses too. |
|
148 |
||
149 |
||
113 | 150 |
simple (default position is 0@0): |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
151 |
|top l| |
63 | 152 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
153 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
154 |
top extent:(200 @ 200). |
63 | 155 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
156 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
157 |
l label:'hello world'. |
63 | 158 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
159 |
top open |
63 | 160 |
|
113 | 161 |
|
162 |
there is also a creation message which sets the label: |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
163 |
|top l| |
113 | 164 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
165 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
166 |
top extent:(200 @ 200). |
113 | 167 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
168 |
l := Label label:'hello world' in:top. |
113 | 169 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
170 |
top open |
113 | 171 |
|
172 |
||
63 | 173 |
placement: |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
174 |
|top l| |
63 | 175 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
176 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
177 |
top extent:(200 @ 200). |
63 | 178 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
179 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
180 |
l label:'hello world'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
181 |
l origin:50@100. |
63 | 182 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
183 |
top open |
63 | 184 |
|
113 | 185 |
|
63 | 186 |
level: |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
187 |
|top l| |
63 | 188 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
189 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
190 |
top extent:(200 @ 200). |
63 | 191 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
192 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
193 |
l level:5. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
194 |
l label:'hello world'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
195 |
l origin:50@100. |
63 | 196 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
197 |
top open |
63 | 198 |
|
113 | 199 |
|
63 | 200 |
another level: |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
201 |
|top l| |
63 | 202 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
203 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
204 |
top extent:(200 @ 200). |
63 | 205 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
206 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
207 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
208 |
l label:'hello world'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
209 |
l origin:50@100. |
63 | 210 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
211 |
top open |
63 | 212 |
|
113 | 213 |
|
118 | 214 |
colors & font: |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
215 |
|top l| |
118 | 216 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
217 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
218 |
top extent:(200 @ 200). |
118 | 219 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
220 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
221 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
222 |
l font:(Font family:'Times' size:18). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
223 |
l foregroundColor:Color yellow. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
224 |
l backgroundColor:Color red. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
225 |
l label:'hello world'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
226 |
l origin:50@100. |
118 | 227 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
228 |
top open |
118 | 229 |
|
230 |
||
63 | 231 |
border & colors: |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
232 |
|top l| |
63 | 233 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
234 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
235 |
top extent:(200 @ 200). |
63 | 236 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
237 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
238 |
l level:0. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
239 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
240 |
l borderColor:Color red. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
241 |
l foregroundColor:Color green darkened. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
242 |
l backgroundColor:Color green lightened. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
243 |
l label:'hello world'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
244 |
l origin:50@100. |
63 | 245 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
246 |
top open |
63 | 247 |
|
113 | 248 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
249 |
different adjusts (resize to see): |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
250 |
|top l| |
63 | 251 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
252 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
253 |
top extent:(300 @ 250). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
254 |
top label:'make me smaller'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
255 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
256 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
257 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
258 |
l label:'default - #centered'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
259 |
l origin:0.1@40. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
260 |
l width:0.8. |
63 | 261 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
262 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
263 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
264 |
l adjust:#left. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
265 |
l label:'#left adjust'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
266 |
l origin:0.1@70. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
267 |
l width:0.8. |
63 | 268 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
269 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
270 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
271 |
l adjust:#right. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
272 |
l label:'#right adjust'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
273 |
l origin:0.1@100. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
274 |
l width:0.8. |
118 | 275 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
276 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
277 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
278 |
l adjust:#centerLeft. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
279 |
l label:'#centerLeft adjust with a long text'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
280 |
l origin:0.1@130. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
281 |
l width:0.8. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
282 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
283 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
284 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
285 |
l adjust:#centerRight. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
286 |
l label:'#centerRight adjust with a long text'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
287 |
l origin:0.1@160. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
288 |
l width:0.8. |
63 | 289 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
290 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
291 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
292 |
l adjust:#leftRight. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
293 |
l label:'#leftRight adjust with a long text'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
294 |
l origin:0.1@190. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
295 |
l width:0.8. |
63 | 296 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
297 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
298 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
299 |
l adjust:#rightLeft. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
300 |
l label:'#rightLeft adjust with a long text'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
301 |
l origin:0.1@220. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
302 |
l width:0.8. |
118 | 303 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
304 |
top open |
63 | 305 |
|
113 | 306 |
|
131 | 307 |
fitting-adjust (resize to see): |
308 |
Warning: #fit is experimental and should not be used. |
|
309 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
310 |
|top l| |
131 | 311 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
312 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
313 |
top extent:(200 @ 200). |
131 | 314 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
315 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
316 |
l label:'stretch'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
317 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
318 |
l adjust:#fit. |
131 | 319 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
320 |
top open |
131 | 321 |
|
322 |
or: |
|
323 |
Warning: #fit is experimental and should not be used. |
|
324 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
325 |
|top l| |
131 | 326 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
327 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
328 |
top extent:(200 @ 200). |
131 | 329 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
330 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
331 |
l label:(Image fromFile:'bitmaps/SBrowser.xbm'). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
332 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
333 |
l adjust:#fit. |
131 | 334 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
335 |
top open |
131 | 336 |
|
337 |
||
63 | 338 |
just a reminder, that instead of doing placement manually |
113 | 339 |
as in ...: |
118 | 340 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
341 |
|top l| |
63 | 342 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
343 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
344 |
top extent:(200 @ 200). |
63 | 345 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
346 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
347 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
348 |
l label:'default - centered'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
349 |
l origin:0.1@70. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
350 |
l width:0.8. |
63 | 351 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
352 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
353 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
354 |
l adjust:#left. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
355 |
l label:'left adjust'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
356 |
l origin:0.1@100. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
357 |
l width:0.8. |
63 | 358 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
359 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
360 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
361 |
l adjust:#right. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
362 |
l label:'right adjust'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
363 |
l origin:0.1@130. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
364 |
l width:0.8. |
63 | 365 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
366 |
top open |
63 | 367 |
|
113 | 368 |
|
369 |
... it is much easier, to use a geometry handler, such as |
|
63 | 370 |
a VerticalPanel. Try: |
113 | 371 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
372 |
|top panel l| |
63 | 373 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
374 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
375 |
top extent:(200 @ 200). |
63 | 376 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
377 |
panel := VerticalPanelView |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
378 |
origin:0.1 @ 0.0 |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
379 |
corner:0.9 @ 1.0 |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
380 |
in:top. |
63 | 381 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
382 |
panel horizontalLayout:#fit. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
383 |
panel verticalLayout:#center. |
63 | 384 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
385 |
l := Label in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
386 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
387 |
l label:'default - centered'. |
63 | 388 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
389 |
l := Label in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
390 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
391 |
l adjust:#left. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
392 |
l label:'left adjust'. |
63 | 393 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
394 |
l := Label in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
395 |
l borderWidth:1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
396 |
l adjust:#right. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
397 |
l label:'right adjust'. |
63 | 398 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
399 |
top open |
63 | 400 |
|
113 | 401 |
|
63 | 402 |
labels with bitmaps or images: |
403 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
404 |
|top l| |
63 | 405 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
406 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
407 |
top extent:(200 @ 200). |
63 | 408 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
409 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
410 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
411 |
l label:((Image fromFile:'bitmaps/garfield.gif') magnifyBy:0.2 @ 0.2). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
412 |
l origin:50@100. |
63 | 413 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
414 |
top open |
113 | 415 |
|
416 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
417 |
that even works with #fit: |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
418 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
419 |
|top l| |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
420 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
421 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
422 |
top extent:(200 @ 200). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
423 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
424 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
425 |
l adjust:#fit. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
426 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
427 |
l label:(Image fromFile:'bitmaps/garfield.gif'). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
428 |
l origin:0.2@0.2 corner:0.8@0.8. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
429 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
430 |
top open |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
431 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
432 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
433 |
notice, that Buttons inherit from Label; thus: |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
434 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
435 |
|top b| |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
436 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
437 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
438 |
top extent:(200 @ 200). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
439 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
440 |
b := Button in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
441 |
b adjust:#fit. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
442 |
b label:(Image fromFile:'bitmaps/garfield.gif'). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
443 |
b origin:0.2@0.2 corner:0.8@0.8. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
444 |
b action:[Transcript showCr:'wow']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
445 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
446 |
top open |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
447 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
448 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
449 |
Channel operation (controlling gf, bg and labelText via ValueHolders) |
145 | 450 |
----------------- |
451 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
452 |
|top panel logoChannel fgChannel bgChannel l b| |
145 | 453 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
454 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
455 |
top extent:(450 @ 200). |
145 | 456 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
457 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
145 | 458 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
459 |
l := Label in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
460 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
461 |
l label:'change my colors'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
462 |
l origin:50@100. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
463 |
l sizeFixed:true. |
145 | 464 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
465 |
fgChannel := Color blue asValue. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
466 |
bgChannel := Color grey asValue. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
467 |
logoChannel := 'change me' asValue. |
145 | 468 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
469 |
b := Toggle label:'change fg' in:panel. b showLamp:false; onLevel:-2. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
470 |
b pressAction:[fgChannel value:Color red]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
471 |
b releaseAction:[fgChannel value:Color blue]. |
145 | 472 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
473 |
b := Toggle label:'change bg' in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
474 |
b pressAction:[bgChannel value:Color yellow]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
475 |
b releaseAction:[bgChannel value:Color grey]. |
145 | 476 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
477 |
b := Toggle label:'change text' in:panel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
478 |
b pressAction:[logoChannel value:'wow']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
479 |
b releaseAction:[logoChannel value:'not bad' ]. |
145 | 480 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
481 |
l labelChannel:logoChannel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
482 |
l foregroundChannel:fgChannel. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
483 |
l backgroundChannel:bgChannel. |
145 | 484 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
485 |
top open |
145 | 486 |
|
487 |
||
146 | 488 |
multiple labels on one channel: |
489 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
490 |
|l1 l2 b conv| |
146 | 491 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
492 |
l1 := Label label:'label1'. |
146 | 493 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
494 |
l2 := Label label:'label2'. |
146 | 495 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
496 |
b := Button label:'change'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
497 |
conv := (ConvertedValue new |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
498 |
conversion:[:input | |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
499 |
input ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
500 |
Color red |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
501 |
] ifFalse:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
502 |
Color blue |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
503 |
]]). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
504 |
conv value:false. |
146 | 505 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
506 |
b controller pressChannel:conv. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
507 |
l1 foregroundChannel:conv. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
508 |
l2 foregroundColor:Color white; backgroundChannel:conv. |
146 | 509 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
510 |
b open. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
511 |
l1 open. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
512 |
l2 open. |
146 | 513 |
|
514 |
||
125 | 515 |
MVC operation |
145 | 516 |
------------- |
517 |
||
125 | 518 |
model provides the label): |
519 |
(have to use a plug to simulate a model which responds to |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
520 |
the #someAspect message): |
113 | 521 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
522 |
|top l model| |
113 | 523 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
524 |
model := Plug new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
525 |
model respondTo:#someAspect with:['models labelString']. |
113 | 526 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
527 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
528 |
top extent:(200 @ 200). |
113 | 529 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
530 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
531 |
l model:model; labelMessage:#someAspect. |
113 | 532 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
533 |
top open |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
534 |
... |
118 | 535 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
536 |
model changed:#someAspect |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
537 |
... |
113 | 538 |
|
539 |
||
118 | 540 |
concrete example (track a counters value): |
125 | 541 |
(here, the default aspect #value is used both to notify the label about |
542 |
changes and to aquire a new value from the model). |
|
113 | 543 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
544 |
|top l model| |
113 | 545 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
546 |
model := ValueHolder new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
547 |
model value:'0'. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
548 |
[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
549 |
1 to:20 do:[:i | |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
550 |
(Delay forSeconds:1) wait. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
551 |
model value:i printString |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
552 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
553 |
top destroy |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
554 |
] fork. |
113 | 555 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
556 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
557 |
top extent:(200 @ 200). |
113 | 558 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
559 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
560 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
561 |
l model:model; labelMessage:#value. |
118 | 562 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
563 |
top open |
118 | 564 |
|
565 |
||
133 | 566 |
with a printConverter: |
567 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
568 |
|top l model| |
133 | 569 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
570 |
model := Date today asValue. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
571 |
[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
572 |
1 to:50 do:[:i | |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
573 |
(Delay forSeconds:1) wait. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
574 |
model value:(model value addDays:1) |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
575 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
576 |
top destroy |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
577 |
] fork. |
133 | 578 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
579 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
580 |
top extent:(200 @ 200). |
133 | 581 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
582 |
l := Label in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
583 |
l level:-1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
584 |
l converter:(PrintConverter new initForDate). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
585 |
l model:model; labelMessage:#value. |
133 | 586 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
587 |
top open |
133 | 588 |
|
589 |
||
125 | 590 |
model changes aspect after a while; two labels on the same model: |
118 | 591 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
592 |
|top l model| |
118 | 593 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
594 |
model := Plug new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
595 |
model respondTo:#labelValue1 with:['models labelString1']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
596 |
model respondTo:#labelValue2 with:['models labelString2']. |
118 | 597 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
598 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
599 |
top extent:(200 @ 200). |
118 | 600 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
601 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
602 |
l model:model; aspect:#someAspect; labelMessage:#labelValue1. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
603 |
l := Label origin:0.0@0.5 corner:1.0@1.0 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
604 |
l model:model; aspect:#someAspect; labelMessage:#labelValue2. |
113 | 605 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
606 |
top open. |
118 | 607 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
608 |
(Delay forSeconds:5) wait. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
609 |
model respondTo:#labelValue1 with:['new string1']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
610 |
model respondTo:#labelValue2 with:['new string2']. |
118 | 611 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
612 |
model changed:#someAspect |
118 | 613 |
|
614 |
||
125 | 615 |
plugged MVC operation (getBlock returns the label): |
118 | 616 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
617 |
|top l model| |
118 | 618 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
619 |
model := PluggableAdaptor new |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
620 |
getBlock:[:m | 'hello'] |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
621 |
putBlock:nil |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
622 |
updateBlock:nil. |
118 | 623 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
624 |
top := StandardSystemView new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
625 |
top extent:(200 @ 200). |
118 | 626 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
627 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
628 |
l model:model; labelMessage:#value. |
118 | 629 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
630 |
top open. |
125 | 631 |
|
632 |
||
633 |
use different label-selectors to access fields of a complex model: |
|
634 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
635 |
|top panel model| |
125 | 636 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
637 |
model := Plug new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
638 |
model respondTo:#field1 with:['value1']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
639 |
model respondTo:#field2 with:['value2']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
640 |
model respondTo:#field3 with:['value3']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
641 |
model respondTo:#field4 with:['value4']. |
125 | 642 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
643 |
top := StandardSystemView new. |
125 | 644 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
645 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
646 |
panel elementsChangeSize:true. |
125 | 647 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
648 |
panel addSubView:((Label on:model) labelMessage:#field1). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
649 |
panel addSubView:((Label on:model) labelMessage:#field2). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
650 |
panel addSubView:((Label on:model) labelMessage:#field3). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
651 |
panel addSubView:((Label on:model) labelMessage:#field4). |
125 | 652 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
653 |
top extent:(200 @ 200). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
654 |
top open. |
125 | 655 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
656 |
(Delay forSeconds:5) wait. |
125 | 657 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
658 |
model respondTo:#field2 with:['new value2']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
659 |
model changed:#value |
125 | 660 |
|
661 |
||
662 |
same as above, using default aspects in the label, and an adaptor |
|
663 |
to translate aspects: |
|
664 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
665 |
|top panel model v1| |
125 | 666 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
667 |
model := Plug new. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
668 |
model respondTo:#field1 with:[v1]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
669 |
model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
670 |
model respondTo:#field2 with:['value2']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
671 |
model respondTo:#field2: with:[:arg |]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
672 |
model respondTo:#field3 with:['value3']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
673 |
model respondTo:#field3: with:[:arg |]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
674 |
model respondTo:#field4 with:['value4']. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
675 |
model respondTo:#field4: with:[:arg |]. |
125 | 676 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
677 |
top := StandardSystemView new. |
125 | 678 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
679 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
680 |
panel elementsChangeSize:true. |
125 | 681 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
682 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
683 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
684 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
685 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value). |
125 | 686 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
687 |
top extent:(200 @ 200). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
688 |
top open. |
125 | 689 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
690 |
(Delay forSeconds:5) wait. |
125 | 691 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
692 |
model field1:'new value1'. |
125 | 693 |
|
694 |
||
695 |
use an adapter to access fields of a complex model: |
|
696 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
697 |
|top l panel model| |
125 | 698 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
699 |
model := #('one' 'two' 'three') asValue. |
125 | 700 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
701 |
top := StandardSystemView new. |
125 | 702 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
703 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
704 |
panel elementsChangeSize:true. |
125 | 705 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
706 |
panel addSubView:((Label on:(ProtocolAdaptor |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
707 |
subjectChannel:model |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
708 |
accessPath:#(1))) labelMessage:#value). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
709 |
panel addSubView:((Label on:(ProtocolAdaptor |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
710 |
subjectChannel:model |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
711 |
accessPath:#(2))) labelMessage:#value). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
712 |
panel addSubView:((Label on:(ProtocolAdaptor |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
713 |
subjectChannel:model |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
714 |
accessPath:#(3))) labelMessage:#value). |
125 | 715 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
716 |
top extent:(200 @ 200). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
717 |
top open. |
125 | 718 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
719 |
(Delay forSeconds:5) wait. |
125 | 720 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
721 |
model value:#('oneone' 'twotwo' 'threethree'). |
63 | 722 |
" |
3 | 723 |
! ! |
724 |
||
105 | 725 |
!Label class methodsFor:'instance creation'! |
726 |
||
727 |
form:aForm |
|
118 | 728 |
"return a new Label showing a form. |
729 |
OBSOLETE: you should now use #label: for both text and bitmap labels." |
|
105 | 730 |
|
131 | 731 |
^ (self on:Screen current) form:aForm |
105 | 732 |
! |
733 |
||
734 |
form:aForm in:aView |
|
118 | 735 |
"return a new Label showing a form. |
736 |
OBSOLETE: you should now use #label:in: for both text and bitmap labels." |
|
105 | 737 |
|
738 |
^ (self in:aView) form:aForm |
|
739 |
! ! |
|
740 |
||
0 | 741 |
!Label class methodsFor:'defaults'! |
742 |
||
743 |
defaultExtent |
|
3 | 744 |
"return default extent" |
0 | 745 |
|
746 |
^ 16 @ 16 |
|
59 | 747 |
! |
748 |
||
749 |
updateStyleCache |
|
77 | 750 |
DefaultForegroundColor := StyleSheet colorAt:'labelForegroundColor'. |
751 |
DefaultForegroundColor isNil ifTrue:[ |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
752 |
DefaultForegroundColor := StyleSheet colorAt:'foregroundColor' default:Black. |
77 | 753 |
]. |
60 | 754 |
DefaultBackgroundColor := StyleSheet colorAt:'labelBackgroundColor'. |
77 | 755 |
DefaultBackgroundColor isNil ifTrue:[ |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
756 |
DefaultBackgroundColor := StyleSheet colorAt:'backgroundColor'. |
77 | 757 |
]. |
60 | 758 |
DefaultFont := StyleSheet fontAt:'labelFont'. |
759 |
||
760 |
" |
|
761 |
self updateStyleCache |
|
762 |
" |
|
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
763 |
|
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
764 |
"Modified: 14.12.1995 / 14:33:55 / cg" |
0 | 765 |
! ! |
766 |
||
202 | 767 |
!Label methodsFor:'accessing-channels'! |
105 | 768 |
|
260 | 769 |
backgroundChannel |
770 |
^ backgroundChannel. |
|
771 |
||
772 |
"Created: 16.12.1995 / 15:50:08 / cg" |
|
773 |
! |
|
774 |
||
202 | 775 |
backgroundChannel:aValueHolder |
776 |
|prev| |
|
105 | 777 |
|
202 | 778 |
prev := backgroundChannel. |
779 |
backgroundChannel := aValueHolder. |
|
780 |
self setupChannel:aValueHolder for:#backgroundChannelChanged withOld:prev |
|
781 |
! |
|
145 | 782 |
|
260 | 783 |
foregroundChannel |
784 |
^ foregroundChannel. |
|
785 |
||
786 |
"Created: 16.12.1995 / 15:50:01 / cg" |
|
787 |
! |
|
788 |
||
145 | 789 |
foregroundChannel:aValueHolder |
146 | 790 |
|prev| |
791 |
||
792 |
prev := foregroundChannel. |
|
145 | 793 |
foregroundChannel := aValueHolder. |
146 | 794 |
self setupChannel:aValueHolder for:#foregroundChannelChanged withOld:prev |
145 | 795 |
! |
796 |
||
260 | 797 |
labelChannel |
798 |
^ labelChannel. |
|
799 |
||
800 |
"Created: 16.12.1995 / 15:50:18 / cg" |
|
801 |
! |
|
802 |
||
145 | 803 |
labelChannel:aValueHolder |
146 | 804 |
|prev| |
805 |
||
806 |
prev := labelChannel. |
|
145 | 807 |
labelChannel := aValueHolder. |
146 | 808 |
self setupChannel:aValueHolder for:#labelChannelChanged withOld:prev |
145 | 809 |
! ! |
810 |
||
202 | 811 |
!Label methodsFor:'accessing-colors'! |
125 | 812 |
|
202 | 813 |
backgroundColor |
814 |
"return the background color" |
|
125 | 815 |
|
202 | 816 |
^ bgColor |
125 | 817 |
! |
818 |
||
202 | 819 |
backgroundColor:aColor |
820 |
"set the background color" |
|
125 | 821 |
|
263 | 822 |
aColor ~~ bgColor ifTrue:[ |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
823 |
bgColor := aColor on:device. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
824 |
shown ifTrue:[self redraw] |
263 | 825 |
] |
826 |
||
827 |
"Modified: 17.12.1995 / 15:09:03 / cg" |
|
105 | 828 |
! |
829 |
||
830 |
foregroundColor |
|
831 |
"return the foreground color" |
|
832 |
||
833 |
^ fgColor |
|
834 |
! |
|
835 |
||
202 | 836 |
foregroundColor:aColor |
837 |
"set the foreground color" |
|
105 | 838 |
|
263 | 839 |
aColor ~~ fgColor ifTrue:[ |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
840 |
fgColor := aColor on:device. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
841 |
shown ifTrue:[self redraw] |
263 | 842 |
]. |
843 |
||
844 |
"Modified: 17.12.1995 / 15:09:15 / cg" |
|
105 | 845 |
! |
846 |
||
847 |
foregroundColor:fg backgroundColor:bg |
|
848 |
"set the colors to be used for drawing" |
|
849 |
||
850 |
fgColor := fg on:device. |
|
851 |
bgColor := bg on:device. |
|
131 | 852 |
shown ifTrue:[self redraw] |
133 | 853 |
! ! |
854 |
||
855 |
!Label methodsFor:'accessing-contents'! |
|
0 | 856 |
|
202 | 857 |
form:aForm |
858 |
"set the labels form; adjust extent if not already realized. |
|
859 |
OBSOLETE: you should now use #label: for both strings and images" |
|
118 | 860 |
|
202 | 861 |
self label:aForm |
862 |
! |
|
863 |
||
864 |
label |
|
865 |
"return the labels string or image" |
|
866 |
||
867 |
^ logo |
|
118 | 868 |
! |
105 | 869 |
|
118 | 870 |
label:aStringOrFormOrImage |
871 |
"set the labelString or image; adjust extent if not already realized and |
|
872 |
not fixedSize" |
|
873 |
||
874 |
(aStringOrFormOrImage ~~ logo) ifTrue:[ |
|
875 |
"/ |
|
876 |
"/ avoid recompute of size, if its an image with |
|
877 |
"/ the same size |
|
878 |
"/ |
|
879 |
aStringOrFormOrImage isImageOrForm ifTrue:[ |
|
880 |
logo notNil ifTrue:[ |
|
881 |
logo isImageOrForm ifTrue:[ |
|
882 |
logo extent = aStringOrFormOrImage extent ifTrue:[ |
|
883 |
logo := aStringOrFormOrImage. |
|
884 |
^ self |
|
885 |
] |
|
105 | 886 |
] |
887 |
] |
|
118 | 888 |
] ifFalse:[ |
889 |
(logo = aStringOrFormOrImage) ifTrue:[ |
|
890 |
^ self |
|
891 |
] |
|
105 | 892 |
]. |
118 | 893 |
logo := aStringOrFormOrImage. |
105 | 894 |
self newLayout |
895 |
] |
|
896 |
! |
|
0 | 897 |
|
202 | 898 |
labelString:aString |
899 |
"for ST-80 compatibility: same as #label: |
|
900 |
set the label-string; adjust extent if not already realized and not fixedSize" |
|
118 | 901 |
|
202 | 902 |
self label:aString |
903 |
! |
|
904 |
||
905 |
labelWidth |
|
906 |
"return the logos width in pixels" |
|
907 |
||
908 |
^ labelWidth |
|
118 | 909 |
! |
910 |
||
911 |
logo:something |
|
912 |
"set the labels form or string. |
|
913 |
OBSOLETE: the old version used #form: for images and #label: for strings. |
|
914 |
you should now use #label: for any." |
|
915 |
||
916 |
self label:something |
|
133 | 917 |
! ! |
918 |
||
919 |
!Label methodsFor:'accessing-layout'! |
|
920 |
||
202 | 921 |
adjust |
922 |
"return the adjust symbol" |
|
0 | 923 |
|
202 | 924 |
^ adjust |
125 | 925 |
! |
926 |
||
105 | 927 |
adjust:how |
928 |
"set the adjust, how which must be one of |
|
0 | 929 |
|
105 | 930 |
#left -> left adjust logo |
931 |
#right -> right adjust logo |
|
932 |
#center -> center logo |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
933 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
934 |
#centerRight -> center logo if it fits; |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
935 |
if it does not fit, right adjust |
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
936 |
(use with filenames, where the interesting part is |
118 | 937 |
at the right if the label is too small) |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
938 |
#centerLeft -> center logo if it fits; |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
939 |
if it does not fit, left adjust it |
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
940 |
(use with strings where the interesting part is at the |
118 | 941 |
left if the label is too small) |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
942 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
943 |
#leftRight -> left adjust logo if it fits |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
944 |
if it does not fit, right adjust |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
945 |
(use with filenames, where the interesting part is |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
946 |
at the right if the label is too small) |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
947 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
948 |
#rightLeft -> right adjust logo if it fits |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
949 |
if it does not fit, left adjust |
105 | 950 |
" |
118 | 951 |
|
105 | 952 |
(adjust ~~ how) ifTrue:[ |
953 |
adjust := how. |
|
954 |
self newLayout |
|
955 |
] |
|
956 |
! |
|
957 |
||
202 | 958 |
font:aFont |
959 |
"set the font - if I'm not realized and not fixedSize, adjust my size" |
|
125 | 960 |
|
202 | 961 |
(aFont ~~ font) ifTrue:[ |
962 |
super font:(aFont on:device). |
|
963 |
self newLayout |
|
964 |
] |
|
133 | 965 |
! |
966 |
||
967 |
horizontalSpace:aNumber |
|
968 |
"set the number of pixels by which the logo |
|
969 |
is horizontally inset from the border" |
|
970 |
||
162 | 971 |
hSpace := aNumber. |
972 |
self newLayout |
|
133 | 973 |
! |
974 |
||
202 | 975 |
layout |
976 |
"for protocol compatibility: alias for #adjust. |
|
977 |
Please use #adjust, since #layout conflicts with a method |
|
978 |
in VW (which has a completely different meaning). |
|
979 |
In future versions of ST/X, #layout will behave the VW way." |
|
980 |
||
981 |
self obsoleteMethodWarning:'use #adjust'. |
|
982 |
^ self adjust |
|
983 |
! |
|
984 |
||
985 |
layout:something |
|
986 |
"OBSOLETE compatibility interface. Will vanish. |
|
987 |
for protocol compatibility: alias for #adjust:. |
|
988 |
Please use #adjust:, since #layout: conflicts with a method |
|
989 |
in VW (which has a completely different meaning). |
|
990 |
In future versions of ST/X, #layout: will behave the VW way. |
|
991 |
In the meantime, try to figure out what is meant ... a kludge" |
|
992 |
||
993 |
something isLayout ifTrue:[^ super layout:something]. |
|
994 |
||
995 |
self obsoleteMethodWarning:'use #adjust:'. |
|
996 |
self adjust:something |
|
997 |
||
998 |
"Modified: 31.8.1995 / 23:08:13 / claus" |
|
999 |
! |
|
1000 |
||
1001 |
sizeFixed |
|
1002 |
"return the fix-size attribute" |
|
1003 |
||
1004 |
^ fixSize |
|
1005 |
! |
|
1006 |
||
1007 |
sizeFixed:aBoolean |
|
1008 |
"set/clear the fix-size attribute. |
|
1009 |
If true, the receiver will not change its size when the labelString/logo |
|
1010 |
changes. If false (the default), it will resize itself to make the logo |
|
1011 |
fit." |
|
1012 |
||
1013 |
fixSize := aBoolean |
|
1014 |
! |
|
1015 |
||
1016 |
verticalSpace:aNumber |
|
1017 |
"set the number of pixels by which the logo |
|
1018 |
is vertically inset from the border" |
|
1019 |
||
1020 |
vSpace := aNumber. |
|
1021 |
self newLayout |
|
1022 |
! ! |
|
1023 |
||
1024 |
!Label methodsFor:'accessing-mvc'! |
|
1025 |
||
1026 |
addModelInterfaceTo:aDictionary |
|
1027 |
"see comment in View>>modelInterface" |
|
1028 |
||
1029 |
super addModelInterfaceTo:aDictionary. |
|
1030 |
aDictionary at:#labelMessage put:labelMsg |
|
1031 |
! |
|
1032 |
||
1033 |
converter:aConverter |
|
1034 |
"set the printConverter; |
|
1035 |
that one is asked to convert the models value to a printed |
|
1036 |
representation (if non-nil). If nil, the model is supposed to |
|
1037 |
return a string or bitmap image." |
|
1038 |
||
1039 |
converter := aConverter |
|
1040 |
! |
|
105 | 1041 |
|
202 | 1042 |
labelMessage |
1043 |
"return the symbol used to aquire the labelString/image from the model |
|
1044 |
when the aspect changes. |
|
1045 |
The default is nil, which means: leave the label unchanged." |
|
1046 |
||
1047 |
^ labelMsg |
|
1048 |
! |
|
1049 |
||
1050 |
labelMessage:aSymbol |
|
1051 |
"set the symbol used to aquire the labelString/image from the model. |
|
1052 |
The default is nil, which means: leave the label unchanged." |
|
1053 |
||
1054 |
labelMsg ~~ aSymbol ifTrue:[ |
|
1055 |
labelMsg := aSymbol. |
|
1056 |
self getLabelFromModel |
|
1057 |
] |
|
1058 |
! |
|
1059 |
||
1060 |
model:aModel |
|
1061 |
super model:aModel. |
|
1062 |
self getLabelFromModel. |
|
1063 |
! ! |
|
1064 |
||
1065 |
!Label methodsFor:'change & update'! |
|
1066 |
||
1067 |
backgroundChannelChanged |
|
1068 |
self backgroundColor:(backgroundChannel value) |
|
1069 |
! |
|
1070 |
||
1071 |
foregroundChannelChanged |
|
1072 |
self foregroundColor:(foregroundChannel value) |
|
1073 |
! |
|
1074 |
||
1075 |
labelChannelChanged |
|
1076 |
self label:(labelChannel value) |
|
1077 |
! |
|
1078 |
||
1079 |
update:something with:aParameter from:changedObject |
|
1080 |
"the MVC way of changing the label ..." |
|
1081 |
||
1082 |
changedObject == model ifTrue:[ |
|
1083 |
something == aspectMsg ifTrue:[ |
|
1084 |
self getLabelFromModel. |
|
1085 |
^ self. |
|
1086 |
] |
|
1087 |
]. |
|
1088 |
^ super update:something with:aParameter from:changedObject |
|
1089 |
! ! |
|
1090 |
||
1091 |
!Label methodsFor:'event handling'! |
|
1092 |
||
1093 |
sizeChanged:how |
|
1094 |
"sent whenever size is changed by someone else - recompute the |
|
1095 |
logos position within the View." |
|
1096 |
||
1097 |
|prevPosition| |
|
1098 |
||
1099 |
super sizeChanged:how. |
|
1100 |
prevPosition := labelOriginX. |
|
1101 |
self computeLabelOrigin |
|
1102 |
shown ifTrue:[ |
|
1103 |
(adjust == #fit |
|
1104 |
or:[labelOriginX ~~ prevPosition |
|
1105 |
or:[how ~~ #smaller]]) ifTrue:[ |
|
1106 |
"/ self clear. |
|
1107 |
self redraw. |
|
1108 |
self redrawEdges |
|
1109 |
] |
|
105 | 1110 |
] |
0 | 1111 |
! ! |
1112 |
||
1113 |
!Label methodsFor:'initialization'! |
|
1114 |
||
1115 |
initStyle |
|
1116 |
super initStyle. |
|
1117 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
1118 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
1119 |
|
59 | 1120 |
DefaultBackgroundColor notNil ifTrue:[ |
1121 |
bgColor := DefaultBackgroundColor on:device |
|
38 | 1122 |
] ifFalse:[ |
59 | 1123 |
bgColor := viewBackground on:device. |
1124 |
]. |
|
1125 |
DefaultForegroundColor notNil ifTrue:[ |
|
1126 |
fgColor := DefaultForegroundColor on:device |
|
1127 |
] ifFalse:[ |
|
1128 |
fgColor := Black on:device. |
|
38 | 1129 |
] |
0 | 1130 |
! |
1131 |
||
105 | 1132 |
initialize |
1133 |
super initialize. |
|
1134 |
||
1135 |
font := font on:device. |
|
1136 |
self height:(font height + font descent). |
|
1137 |
adjust := #center. |
|
118 | 1138 |
labelOriginX := labelOriginY := 0. |
1139 |
labelWidth := labelHeight := 0. |
|
105 | 1140 |
logo := nil. |
1141 |
fixSize := false. |
|
1142 |
hSpace := (self horizontalPixelPerMillimeter:0.5) rounded. |
|
131 | 1143 |
vSpace := (self verticalPixelPerMillimeter:0.25) rounded |
105 | 1144 |
! |
1145 |
||
0 | 1146 |
recreate |
1147 |
"after snapin, labels dimensions may have changed due to |
|
1148 |
different font parameters" |
|
1149 |
||
1150 |
super recreate. |
|
3 | 1151 |
font := font on:device. |
0 | 1152 |
self computeLabelSize. |
1153 |
self computeLabelOrigin |
|
1154 |
! ! |
|
1155 |
||
202 | 1156 |
!Label methodsFor:'private'! |
1157 |
||
1158 |
computeLabelOrigin |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1159 |
"(re)compute the origin of the label whenever label, font or view-size changes" |
202 | 1160 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1161 |
|x y a| |
202 | 1162 |
|
1163 |
labelHeight isNil ifTrue:[^ self]. |
|
1164 |
||
1165 |
adjust == #fit ifTrue:[ |
|
1166 |
labelOriginX := labelOriginY := margin. |
|
1167 |
^ self |
|
1168 |
]. |
|
1169 |
||
1170 |
"if it does not fit, should we make the origin visible, |
|
1171 |
or the center (for text, the center seems better. For images, |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1172 |
I dont really know which is better ... |
202 | 1173 |
The commented code below makes the origin visible |
1174 |
" |
|
1175 |
"/ (labelHeight < height) ifTrue:[ |
|
1176 |
"/ y := (height - labelHeight) // 2 |
|
1177 |
"/ ] ifFalse:[ |
|
1178 |
"/ y := 0 |
|
1179 |
"/ ]. |
|
1180 |
||
1181 |
"always center vertically" |
|
1182 |
y := (height - labelHeight) // 2. |
|
1183 |
||
1184 |
labelOriginY := y. |
|
1185 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1186 |
a := adjust. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1187 |
(width < labelWidth) ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1188 |
((adjust == #centerRight) or:[adjust == #leftRight]) ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1189 |
a := #right |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1190 |
] ifFalse:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1191 |
((adjust == #centerLeft) or:[adjust == #rightLeft]) ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1192 |
a := #left |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1193 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1194 |
] |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1195 |
] ifFalse:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1196 |
((adjust == #centerRight) or:[adjust == #centerLeft]) ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1197 |
a := #center |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1198 |
] ifFalse:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1199 |
adjust == #leftRight ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1200 |
a := #left |
202 | 1201 |
] ifFalse:[ |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1202 |
adjust == #rightLeft ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1203 |
a := #right |
202 | 1204 |
] |
1205 |
] |
|
1206 |
] |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1207 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1208 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1209 |
(a == #center) ifTrue:[ |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1210 |
" center text/form in button " |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1211 |
x := (width - labelWidth) // 2. |
202 | 1212 |
] ifFalse:[ |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1213 |
(a == #left) ifTrue:[ |
202 | 1214 |
x := margin |
1215 |
] ifFalse:[ |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1216 |
"/ #right |
202 | 1217 |
x := width - labelWidth - margin |
1218 |
] |
|
1219 |
]. |
|
1220 |
labelOriginX := x |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1221 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1222 |
"Modified: 4.2.1996 / 21:03:17 / cg" |
202 | 1223 |
! |
1224 |
||
1225 |
computeLabelSize |
|
1226 |
"compute the extent needed to hold the label; aForm or aString" |
|
1227 |
||
1228 |
|numberOfLines textHeight textWidth| |
|
1229 |
||
1230 |
logo isNil ifTrue:[^ self]. |
|
1231 |
||
1232 |
logo isImageOrForm ifTrue:[ |
|
1233 |
labelWidth := logo width. |
|
1234 |
labelHeight := logo height. |
|
1235 |
^ self |
|
1236 |
]. |
|
1237 |
||
1238 |
"must be a String or collection of strings" |
|
1239 |
logo isString ifTrue:[ |
|
1240 |
numberOfLines := 1 + (logo occurrencesOf:(Character cr)). |
|
1241 |
(numberOfLines ~~ 1) ifTrue:[ |
|
1242 |
logo := logo asStringCollection |
|
1243 |
] |
|
1244 |
] ifFalse:[ |
|
1245 |
numberOfLines := logo size. |
|
1246 |
(numberOfLines <= 1) ifTrue:[ |
|
1247 |
logo := logo asString |
|
1248 |
] |
|
1249 |
]. |
|
1250 |
||
1251 |
"/ textHeight := font height * numberOfLines + font descent. |
|
1252 |
textHeight := font height * numberOfLines. |
|
1253 |
textWidth := font widthOf:logo. |
|
1254 |
labelWidth := textWidth + (hSpace * 2) . |
|
1255 |
labelHeight := textHeight + (vSpace * 2) |
|
1256 |
! |
|
1257 |
||
1258 |
getLabelFromModel |
|
1259 |
"ask my model for the label to show. |
|
1260 |
Here, we use labelMsg (instead of aspectMsg). |
|
1261 |
This allows multiple labels to react on the same aspect, |
|
1262 |
but show different labels when changed |
|
1263 |
(also, since labelMsg defaults to nil, constant labels |
|
1264 |
which have a nil labelMsg will not try to aquire a labelString)." |
|
1265 |
||
1266 |
|val| |
|
1267 |
||
1268 |
(model notNil |
|
1269 |
and:[labelMsg notNil]) ifTrue:[ |
|
1270 |
val := model perform:labelMsg. |
|
1271 |
converter notNil ifTrue:[ |
|
1272 |
val := converter printStringFor:val |
|
1273 |
]. |
|
1274 |
self label:val. |
|
1275 |
]. |
|
1276 |
! |
|
1277 |
||
1278 |
newLayout |
|
1279 |
"recompute position/size after a change |
|
1280 |
- helper for form:/font: etc." |
|
1281 |
||
1282 |
self computeLabelSize. |
|
1283 |
fixSize ifFalse:[ |
|
1284 |
self resize |
|
1285 |
] ifTrue:[ |
|
1286 |
self computeLabelOrigin |
|
1287 |
]. |
|
1288 |
shown ifTrue:[ |
|
1289 |
self redraw |
|
1290 |
] |
|
1291 |
! ! |
|
1292 |
||
1293 |
!Label methodsFor:'queries'! |
|
1294 |
||
1295 |
preferredExtent |
|
1296 |
"return my preferred extent - this is the minimum size I would like to have" |
|
1297 |
||
1298 |
|extra| |
|
1299 |
||
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1300 |
fixSize ifTrue:[^ self extent]. |
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1301 |
|
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1302 |
logo isNil ifTrue:[ |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1303 |
self label:'' |
202 | 1304 |
]. |
1305 |
||
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1306 |
logo notNil ifTrue:[ |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1307 |
extra := margin * 2. |
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1308 |
^ (labelWidth + extra + hSpace) @ (labelHeight + extra + vSpace) |
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1309 |
]. |
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1310 |
|
202 | 1311 |
^ super preferredExtent |
1312 |
! ! |
|
1313 |
||
0 | 1314 |
!Label methodsFor:'redrawing'! |
1315 |
||
77 | 1316 |
clearInsideWith:bg |
1317 |
|cutOff mustClear| |
|
0 | 1318 |
|
1319 |
cutOff := margin * 2. |
|
1320 |
||
3 | 1321 |
mustClear := true. |
1322 |
||
87 | 1323 |
(logo notNil and:[logo isImageOrForm]) ifTrue:[ |
59 | 1324 |
(labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[ |
1325 |
logo width >= (width - cutOff) ifTrue:[ |
|
1326 |
logo height >= (height - cutOff) ifTrue:[ |
|
1327 |
"no need to clear before - avoid flicker" |
|
1328 |
mustClear := false |
|
1329 |
] |
|
1330 |
] |
|
1331 |
]. |
|
3 | 1332 |
]. |
1333 |
||
1334 |
mustClear ifTrue:[ |
|
59 | 1335 |
self paint:bg. |
1336 |
self fillRectangleX:margin y:margin |
|
1337 |
width:(width - cutOff) |
|
1338 |
height:(height - cutOff). |
|
3 | 1339 |
]. |
77 | 1340 |
! |
1341 |
||
1342 |
drawWith:fg and:bg |
|
1343 |
"redraw my label with fg/bg - this generic method is also used by subclasses |
|
1344 |
(especially Button) to redraw the logo in different colors." |
|
1345 |
||
132 | 1346 |
|x y scaleH scaleV nW nH hSep vSep m2| |
77 | 1347 |
|
1348 |
self clearInsideWith:bg. |
|
0 | 1349 |
|
1350 |
logo notNil ifTrue:[ |
|
59 | 1351 |
self paint:fg on:bg. |
131 | 1352 |
|
133 | 1353 |
m2 := margin * 2. |
1354 |
hSep := (hSpace*2). |
|
1355 |
vSep := (vSpace*2). |
|
1356 |
||
87 | 1357 |
logo isImageOrForm ifTrue:[ |
131 | 1358 |
x := labelOriginX. |
1359 |
y := labelOriginY. |
|
1360 |
||
1361 |
adjust == #fit ifTrue:[ |
|
1362 |
scaleH := ((width - hSep) / (logo width)) asFloat. |
|
1363 |
scaleV := ((height - vSep) / (logo height)) asFloat. |
|
1364 |
self scale:(scaleH @ scaleV). |
|
1365 |
x := transformation applyInverseScaleX:x. |
|
1366 |
y := transformation applyInverseScaleY:y. |
|
1367 |
]. |
|
1368 |
||
87 | 1369 |
logo := logo on:device. |
59 | 1370 |
"/ self background:bg. |
131 | 1371 |
self displayOpaqueForm:logo x:x y:y |
59 | 1372 |
] ifFalse:[ |
1373 |
x := labelOriginX + hSpace. |
|
1374 |
y := labelOriginY + (font ascent) + vSpace. |
|
0 | 1375 |
|
131 | 1376 |
adjust == #fit ifTrue:[ |
1377 |
scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat. |
|
1378 |
scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat. |
|
1379 |
self scale:(scaleH min: scaleV). |
|
1380 |
x := transformation applyInverseScaleX:x. |
|
1381 |
y := y - font ascent + (transformation applyScaleY:font ascent). |
|
1382 |
y := transformation applyInverseScaleY:y. |
|
1383 |
scaleH < scaleV ifTrue:[ |
|
1384 |
nH := labelHeight * scaleH. |
|
1385 |
"/ now, center vertically |
|
1386 |
y := y + ((height - nH - m2 - vSep) / scaleH / 2). |
|
1387 |
]. |
|
1388 |
scaleV < scaleH ifTrue:[ |
|
1389 |
"/ now, center horizontally |
|
1390 |
nW := labelWidth * scaleV. |
|
1391 |
x := x + ((width - nW - m2 - hSep) / scaleV / 2) |
|
1392 |
]. |
|
1393 |
]. |
|
1394 |
||
87 | 1395 |
logo isString ifTrue:[ |
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
1396 |
self displayOpaqueString:logo x:x y:y |
59 | 1397 |
] ifFalse:[ |
1398 |
logo do:[ :line | |
|
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
1399 |
self displayOpaqueString:(line printString) x:x y:y. |
59 | 1400 |
y := y + (font height) |
1401 |
] |
|
131 | 1402 |
]. |
1403 |
||
1404 |
]. |
|
1405 |
||
1406 |
adjust == #fit ifTrue:[ |
|
1407 |
self scale:1 |
|
1408 |
]. |
|
1409 |
||
0 | 1410 |
] |
1411 |
! |
|
1412 |
||
1413 |
redraw |
|
1414 |
"redraw my label" |
|
1415 |
||
1416 |
shown ifTrue:[ |
|
59 | 1417 |
self drawWith:fgColor and:bgColor |
0 | 1418 |
] |
1419 |
! ! |
|
105 | 1420 |
|
110 | 1421 |
!Label methodsFor:'resizing'! |
1422 |
||
1423 |
forceResize |
|
118 | 1424 |
"resize myself to make text fit into myself. Here, this is done even if |
1425 |
fixSize is set." |
|
110 | 1426 |
|
1427 |
logo notNil ifTrue:[ |
|
130 | 1428 |
self extent:self preferredExtent. |
110 | 1429 |
self computeLabelOrigin |
1430 |
] |
|
105 | 1431 |
! |
1432 |
||
1433 |
resize |
|
1434 |
"resize myself to make text fit into myself. |
|
118 | 1435 |
but only do so, if I am not fixedSize and I have NOT been |
1436 |
given a relative extent or an extend computation block." |
|
105 | 1437 |
|
110 | 1438 |
(logo notNil |
1439 |
and:[fixSize not |
|
1440 |
and:[relativeExtent isNil |
|
1441 |
and:[extentRule isNil |
|
1442 |
and:[relativeCorner isNil |
|
1443 |
and:[cornerRule isNil]]]]]) ifTrue:[ |
|
1444 |
self forceResize |
|
1445 |
] ifFalse:[ |
|
105 | 1446 |
self computeLabelOrigin |
1447 |
] |
|
1448 |
! ! |
|
1449 |
||
205 | 1450 |
!Label class methodsFor:'documentation'! |
1451 |
||
1452 |
version |
|
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
1453 |
^ '$Header: /cvs/stx/stx/libwidg/Label.st,v 1.48 1996-02-24 16:34:03 cg Exp $' |
205 | 1454 |
! ! |