author | Claus Gittinger <cg@exept.de> |
Mon, 15 Jul 2019 15:37:46 +0200 | |
changeset 6085 | 3855043eac71 |
parent 3150 | e3a55f15ef7e |
child 4770 | 6634b540fea2 |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
3 |
All Rights Reserved |
1 | 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 |
||
3150 | 13 |
"{ Package: 'stx:libwidg2' }" |
14 |
||
1 | 15 |
Button subclass:#RoundButton |
1232 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Interactors' |
|
1 | 20 |
! |
21 |
||
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
22 |
!RoundButton class methodsFor:'documentation'! |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
23 |
|
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
24 |
copyright |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
25 |
" |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
27 |
All Rights Reserved |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
28 |
|
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
29 |
This software is furnished under a license and may be used |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
30 |
only in accordance with the terms of that license and with the |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
31 |
inclusion of the above copyright notice. This software may not |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
32 |
be provided or otherwise made available to, or used by, any |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
33 |
other person. No title to or ownership of the software is |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
34 |
hereby transferred. |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
35 |
" |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
36 |
! |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
37 |
|
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
38 |
documentation |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
39 |
" |
1232 | 40 |
this is not finished - please do not look at it |
41 |
and do not use it (i.e. simply ignore it ;-). |
|
42 |
||
43 |
Notice - this only works under graphic displays which |
|
44 |
support arbitrary shaped views (i.e. XWindow). |
|
45 |
||
46 |
Under Win32, you will see a rectanglular view instead. |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
47 |
" |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
48 |
! |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
49 |
|
1232 | 50 |
examples |
51 |
" |
|
52 |
|top b| |
|
53 |
||
54 |
top := StandardSystemView extent:300@300. |
|
55 |
b := RoundButton label:'hello' in:top. |
|
56 |
top open |
|
57 |
" |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
58 |
! ! |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
59 |
|
1 | 60 |
!RoundButton methodsFor:'drawing'! |
61 |
||
62 |
drawWith:fg and:bg |
|
63 |
self paint:bg. |
|
64 |
self fillRectangleX:0 y:0 width:width height:height. |
|
65 |
super drawWith:fg and:bg |
|
66 |
! ! |
|
67 |
||
68 |
!RoundButton methodsFor:'private'! |
|
69 |
||
70 |
roundCornerFormWidth:width height:height offset:off |
|
7 | 71 |
|form wCorn hCorn wCornHalf wCornHalfRest hCornHalf hCornHalfRest |
1 | 72 |
left top right bot w h| |
73 |
||
74 |
"compute a shape form" |
|
75 |
form := Form width:width height:height. |
|
76 |
form fill:(Color colorId:0). |
|
77 |
||
78 |
left := off. right := width-(off*2)-1. |
|
79 |
top := off. bot := height-(2*off)-1. |
|
80 |
||
81 |
w := width - off - off. |
|
82 |
h := height - off - off. |
|
83 |
||
84 |
wCorn := (w * 0.33) rounded asInteger. |
|
85 |
hCorn := (h * 0.75) rounded asInteger. |
|
86 |
wCornHalf := wCorn // 2. |
|
87 |
hCornHalf := hCorn // 2. |
|
88 |
wCorn odd ifTrue:[ |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
89 |
wCornHalfRest := 1 |
1 | 90 |
] ifFalse:[ |
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
91 |
wCornHalfRest := 0 |
1 | 92 |
]. |
93 |
hCorn odd ifTrue:[ |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
94 |
hCornHalfRest := 1 |
1 | 95 |
] ifFalse:[ |
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
96 |
hCornHalfRest := 0 |
1 | 97 |
]. |
98 |
||
99 |
form paint:(Color colorId:1). |
|
100 |
||
101 |
form fillArcX:left y:top w:wCorn h:hCorn from:0 angle:360. |
|
102 |
||
3150 | 103 |
form fillRectangleX:(left + wCornHalf) y:top |
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
104 |
width:(w - wCorn + wCornHalfRest) height:hCornHalf. |
1 | 105 |
|
106 |
"top right arc" |
|
107 |
form fillArcX:(right - wCorn) y:top w:wCorn h:hCorn from:0 angle:90. |
|
108 |
||
109 |
"big middle rect" |
|
110 |
form fillRectangleX:left y:(top + hCornHalf) |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
111 |
width:w height:(h - hCorn + hCornHalfRest). |
1 | 112 |
|
113 |
"bottom left arc" |
|
114 |
form fillArcX:left y:(bot - hCorn) w:wCorn h:hCorn from:180 angle:90. |
|
115 |
||
116 |
"bottom rect" |
|
117 |
form fillRectangleX:(left + wCornHalf) y:(bot - hCornHalf) |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
7
diff
changeset
|
118 |
width:(w - wCorn + wCornHalfRest) height:hCornHalf. |
1 | 119 |
|
120 |
"bottom right arc" |
|
121 |
form fillArcX:(right - wCorn) y:(bot - hCorn) w:wCorn h:hCorn from:270 angle:90. |
|
122 |
||
123 |
^ form |
|
124 |
! ! |
|
1232 | 125 |
|
126 |
!RoundButton methodsFor:'window events'! |
|
127 |
||
128 |
sizeChanged:how |
|
129 |
|shapeForm borderForm| |
|
130 |
||
131 |
super sizeChanged:how. |
|
132 |
||
133 |
"compute a new shape form" |
|
134 |
||
3150 | 135 |
borderForm := self roundCornerFormWidth:width+(borderWidth * 2) |
1232 | 136 |
height:height+(borderWidth * 2) |
137 |
offset:0. |
|
3150 | 138 |
shapeForm := self roundCornerFormWidth:width+(borderWidth * 2) |
1232 | 139 |
height:height+(borderWidth * 2) |
140 |
offset:borderWidth. |
|
141 |
||
142 |
self borderShape:borderForm. |
|
143 |
self viewShape:shapeForm |
|
144 |
! ! |
|
145 |
||
146 |
!RoundButton class methodsFor:'documentation'! |
|
147 |
||
148 |
version |
|
3150 | 149 |
^ '$Header: /cvs/stx/stx/libwidg2/RoundButton.st,v 1.5 2006-11-13 16:11:31 cg Exp $' |
1232 | 150 |
! ! |