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