author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jun 2018 10:54:35 +0200 | |
changeset 5816 | 7876c07931a7 |
parent 5428 | 31afef66bfb5 |
child 5947 | eb55c8df142a |
permissions | -rw-r--r-- |
56 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
62 | 3 |
All Rights Reserved |
56 | 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 |
" |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
13 |
|
5428 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
56 | 16 |
SimpleView subclass:#Separator |
157 | 17 |
instanceVariableNames:'orientation' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Layout' |
|
56 | 21 |
! |
22 |
||
23 |
!Separator class methodsFor:'documentation'! |
|
24 |
||
71 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
! |
|
39 |
||
95 | 40 |
documentation |
41 |
" |
|
42 |
a simple widget for a separating line. |
|
43 |
To be placed between groups of other widgets. |
|
44 |
||
45 |
See examples. |
|
46 |
||
157 | 47 |
[See also:] |
48 |
FramedBox VariableVerticalPanel VariableHorizontalPanel |
|
49 |
||
50 |
[author:] |
|
51 |
Claus Gittinger |
|
95 | 52 |
" |
53 |
! |
|
54 |
||
56 | 55 |
examples |
56 |
" |
|
57 |
a separator between two button-panels: |
|
160 | 58 |
[exBegin] |
56 | 59 |
|top p1 p2 sep| |
60 |
||
61 |
top := StandardSystemView new. |
|
62 |
top extent:300@300. |
|
63 |
||
64 |
p1 := VerticalPanelView origin:0.0@0.0 corner:1.0@0.5 in:top. |
|
65 |
p1 bottomInset:5; borderWidth:0. |
|
66 |
p2 := VerticalPanelView origin:0.0@0.5 corner:1.0@1.0 in:top. |
|
67 |
p2 topInset:5; borderWidth:0. |
|
68 |
||
69 |
(Button label:'one' in:p1) width:0.2. |
|
70 |
(Button label:'two' in:p1) width:0.2. |
|
71 |
(Button label:'three' in:p1) width:0.2. |
|
72 |
||
73 |
sep := Separator in:top. |
|
74 |
sep orientation:#horizontal. |
|
75 |
sep origin:0.0@0.5 extent:1.0@10. |
|
76 |
sep topInset:-5; bottomInset:-5. |
|
77 |
||
78 |
(Button label:'four' in:p2) width:0.2. |
|
79 |
(Button label:'five' in:p2) width:0.2. |
|
80 |
(Button label:'six' in:p2) width:0.2. |
|
81 |
||
82 |
top open |
|
160 | 83 |
[exEnd] |
56 | 84 |
|
85 |
||
86 |
vertical: |
|
160 | 87 |
[exBegin] |
56 | 88 |
|top p1 p2 sep| |
89 |
||
90 |
top := StandardSystemView new. |
|
91 |
top extent:300@300. |
|
92 |
||
93 |
p1 := VerticalPanelView origin:0.0@0.0 corner:0.5@1.0 in:top. |
|
94 |
p1 rightInset:5; borderWidth:0. |
|
95 |
p2 := VerticalPanelView origin:0.5@0.0 corner:1.0@1.0 in:top. |
|
96 |
p2 leftInset:5; borderWidth:0. |
|
97 |
||
98 |
(Button label:'one' in:p1) width:0.4. |
|
99 |
(Button label:'two' in:p1) width:0.4. |
|
100 |
(Button label:'three' in:p1) width:0.4. |
|
101 |
||
102 |
sep := Separator in:top. |
|
103 |
sep orientation:#vertical. |
|
104 |
sep origin:0.5@0.0 extent:10@1.0. |
|
105 |
sep leftInset:-5; rightInset:-5. |
|
106 |
||
107 |
(Button label:'four' in:p2) width:0.4. |
|
108 |
(Button label:'five' in:p2) width:0.4. |
|
109 |
(Button label:'six' in:p2) width:0.4. |
|
110 |
||
111 |
top open |
|
160 | 112 |
[exEnd] |
56 | 113 |
|
114 |
||
115 |
with multiple horizontal seps in a panel: |
|
160 | 116 |
[exBegin] |
56 | 117 |
|top p sep| |
118 |
||
119 |
top := StandardSystemView new. |
|
120 |
top extent:300@300. |
|
121 |
||
122 |
p := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
123 |
p verticalLayout:#spreadSpace. |
|
124 |
p horizontalLayout:#center. |
|
125 |
||
126 |
(Button label:'one' in:p). |
|
127 |
(Button label:'two' in:p). |
|
128 |
(Button label:'three' in:p). |
|
129 |
||
130 |
sep := Separator in:p. |
|
131 |
sep orientation:#horizontal. |
|
132 |
sep extent:0.9@10. |
|
133 |
||
134 |
(Button label:'four' in:p). |
|
135 |
(Button label:'five' in:p). |
|
136 |
||
137 |
sep := Separator in:p. |
|
138 |
sep orientation:#horizontal. |
|
139 |
sep extent:0.9@10. |
|
140 |
||
141 |
(Button label:'six' in:p). |
|
142 |
||
143 |
top open |
|
160 | 144 |
[exEnd] |
56 | 145 |
" |
95 | 146 |
! ! |
147 |
||
148 |
!Separator methodsFor:'accessing'! |
|
149 |
||
150 |
orientation |
|
151 |
"return the orientation (one of #horizontal or #vertical)" |
|
152 |
||
153 |
^ orientation |
|
56 | 154 |
! |
155 |
||
95 | 156 |
orientation:aSymbol |
157 |
"set the orientation to one of #horizontal or #vertical" |
|
62 | 158 |
|
316
f6214d6f484d
redraw if orientation changes
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
159 |
orientation := aSymbol. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
160 |
self invalidate |
316
f6214d6f484d
redraw if orientation changes
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
161 |
|
f6214d6f484d
redraw if orientation changes
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
162 |
"Modified: 28.2.1997 / 21:24:38 / cg" |
56 | 163 |
! ! |
164 |
||
165 |
!Separator methodsFor:'drawing'! |
|
166 |
||
3286 | 167 |
redrawX:x y:y width:w height:h |
168 |
|vCenter hCenter is3D bgColor| |
|
169 |
||
170 |
(shown and:[superView notNil]) ifFalse:[^ self]. |
|
171 |
||
172 |
bgColor := superView viewBackground. |
|
56 | 173 |
|
3286 | 174 |
bgColor isColor ifTrue:[ |
5428 | 175 |
gc paint:(superView viewBackground). |
176 |
gc fillRectangleX:x y:y width:w height:h. |
|
3286 | 177 |
] ifFalse:[ |
5428 | 178 |
gc clearRectangleX:x y:y width:w height:h. |
3286 | 179 |
]. |
62 | 180 |
is3D := styleSheet is3D. |
56 | 181 |
|
5428 | 182 |
gc paint:shadowColor. |
56 | 183 |
orientation == #vertical ifTrue:[ |
3286 | 184 |
hCenter := self width // 2. |
5428 | 185 |
gc displayLineFromX:hCenter y:0 toX:hCenter y:height-1. |
3286 | 186 |
is3D ifTrue:[ |
5428 | 187 |
gc paint:lightColor. |
188 |
gc displayLineFromX:hCenter+1 y:0 toX:hCenter+1 y:height-1. |
|
3286 | 189 |
] |
56 | 190 |
] ifFalse:[ |
3286 | 191 |
vCenter := self height // 2. |
5428 | 192 |
gc displayLineFromX:0 y:vCenter toX:width-1 y:vCenter. |
3286 | 193 |
is3D ifTrue:[ |
5428 | 194 |
gc paint:lightColor. |
195 |
gc displayLineFromX:0 y:vCenter+1 toX:width-1 y:vCenter+1. |
|
3286 | 196 |
] |
56 | 197 |
] |
864
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
198 |
! |
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
199 |
|
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
200 |
sizeChanged:how |
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
201 |
super sizeChanged:how. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
202 |
self invalidate |
864
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
203 |
|
d84a7a02f037
sizeChange must clear (try to resize ...)
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
204 |
"Created: / 18.4.1998 / 02:36:42 / cg" |
865 | 205 |
"Modified: / 18.4.1998 / 14:10:05 / cg" |
56 | 206 |
! ! |
207 |
||
1280
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
208 |
!Separator methodsFor:'focus handling'! |
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
209 |
|
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
210 |
wantsFocusWithButtonPress |
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
211 |
"no, do not catch the keyboard focus on button click" |
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
212 |
|
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
213 |
^ false |
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
214 |
|
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
215 |
|
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
216 |
! ! |
8836fc202970
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
217 |
|
56 | 218 |
!Separator methodsFor:'initialization'! |
219 |
||
220 |
initialize |
|
221 |
super initialize. |
|
3821 | 222 |
self borderWidth:0. |
315
eab866497e0e
orientation instVar was undefined.
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
223 |
orientation := #horizontal. |
eab866497e0e
orientation instVar was undefined.
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
224 |
|
eab866497e0e
orientation instVar was undefined.
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
225 |
"Modified: 28.2.1997 / 21:23:02 / cg" |
56 | 226 |
! ! |
95 | 227 |
|
292 | 228 |
!Separator methodsFor:'queries'! |
229 |
||
323 | 230 |
preferredExtent |
231 |
|e| |
|
232 |
||
3574
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
233 |
"/ If I have an explicit preferredExtent.. |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
234 |
explicitExtent notNil ifTrue:[ |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
235 |
^ explicitExtent |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
236 |
]. |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
237 |
|
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
238 |
"/ If I have a cached preferredExtent value.. |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
239 |
preferredExtent notNil ifTrue:[ |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
240 |
^ preferredExtent |
b841099afab3
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3286
diff
changeset
|
241 |
]. |
323 | 242 |
|
243 |
e := super preferredExtent. |
|
244 |
orientation == #horizontal ifTrue:[ |
|
245 |
^ e x @ 5 |
|
246 |
]. |
|
247 |
^ 5 @ e y |
|
248 |
||
249 |
"Created: 17.3.1997 / 10:37:42 / cg" |
|
250 |
! |
|
251 |
||
292 | 252 |
specClass |
602 | 253 |
"redefined, since the name of my specClass is nonStandard (i.e. not SeparatorSpec)" |
254 |
||
292 | 255 |
self class == Separator ifTrue:[^ DividerSpec]. |
300 | 256 |
^ super specClass |
292 | 257 |
|
602 | 258 |
"Modified: / 31.10.1997 / 19:48:40 / cg" |
292 | 259 |
! ! |
260 |
||
100 | 261 |
!Separator class methodsFor:'documentation'! |
262 |
||
316
f6214d6f484d
redraw if orientation changes
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
263 |
version |
5428 | 264 |
^ '$Header$' |
3819
298b060a5257
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3574
diff
changeset
|
265 |
! |
298b060a5257
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3574
diff
changeset
|
266 |
|
298b060a5257
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3574
diff
changeset
|
267 |
version_CVS |
5428 | 268 |
^ '$Header$' |
100 | 269 |
! ! |
5428 | 270 |