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