author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:30:31 +0100 | |
changeset 86 | 4d7dbb5f1719 |
parent 73 | 2ee590cb9714 |
child 88 | d591b16c8f46 |
permissions | -rw-r--r-- |
58 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
'From Smalltalk/X, Version:2.10.5 on 15-may-1995 at 8:03:34 am'! |
|
14 |
||
15 |
ListEntry subclass:#ColoredListEntry |
|
16 |
instanceVariableNames:'color string' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Support' |
|
20 |
! |
|
21 |
||
22 |
!ColoredListEntry class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
version |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
73
diff
changeset
|
39 |
^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.4 1995-11-11 16:28:53 cg Exp $' |
58 | 40 |
! |
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
Instances of ColoredListEntry can be used in place of strings |
|
45 |
as entries of the list in a ListView or SelectionInListView. |
|
46 |
" |
|
47 |
! |
|
48 |
||
49 |
examples |
|
50 |
" |
|
51 |
putting colored entries into a SelectionInListView |
|
52 |
(instead of strings)' |
|
53 |
||
54 |
|v e myList tabs| |
|
55 |
||
56 |
myList := OrderedCollection new. |
|
57 |
||
58 |
myList add:(ColoredListEntry string:'red' color:Color red). |
|
59 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
60 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
61 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
62 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
63 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
64 |
||
65 |
v := SelectionInListView new. |
|
66 |
v setList:myList expandTabs:false. |
|
67 |
v open |
|
68 |
||
69 |
||
60 | 70 |
in a popUpList (sorry, Labels do not (yet) know how to display |
71 |
non-strings. |
|
58 | 72 |
|
73 |
|v e myList selList tabs| |
|
74 |
||
75 |
myList := OrderedCollection new. |
|
76 |
||
77 |
myList add:(ColoredListEntry string:'red' color:Color red). |
|
78 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
79 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
80 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
81 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
82 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
83 |
||
84 |
selList := SelectionInList new list:myList. |
|
85 |
||
86 |
v := PopUpList on:selList. |
|
87 |
v open |
|
88 |
" |
|
89 |
! ! |
|
90 |
||
91 |
!ColoredListEntry class methodsFor:'instance creation'! |
|
92 |
||
93 |
string:aString color:aColor |
|
94 |
^ self new string:aString color:aColor |
|
95 |
! ! |
|
96 |
||
97 |
!ColoredListEntry methodsFor:'drawing'! |
|
98 |
||
99 |
displayOn:aGC x:x y:y |
|
100 |
"display the receiver on a GC" |
|
101 |
||
73 | 102 |
|savedPaint| |
103 |
||
104 |
savedPaint := aGC paint. |
|
58 | 105 |
aGC paint:color. |
106 |
aGC displayString:string x:x y:y. |
|
73 | 107 |
aGC paint:savedPaint |
58 | 108 |
! ! |
109 |
||
110 |
!ColoredListEntry methodsFor:'accessing'! |
|
111 |
||
112 |
string:aString color:aColor |
|
113 |
string := aString. |
|
114 |
color := aColor |
|
115 |
! ! |
|
116 |
||
117 |
!ColoredListEntry methodsFor:'converting'! |
|
118 |
||
119 |
string |
|
120 |
^ string |
|
121 |
! |
|
122 |
||
123 |
asString |
|
124 |
^ string |
|
125 |
! ! |
|
126 |
||
127 |
!ColoredListEntry methodsFor:'queries'! |
|
128 |
||
129 |
widthIn:aGC |
|
130 |
"return the width of the receiver when displayed in aGC" |
|
131 |
||
132 |
^ aGC font widthOf:string |
|
133 |
! ! |