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