author | Claus Gittinger <cg@exept.de> |
Sun, 12 May 1996 17:07:05 +0200 | |
changeset 170 | f8609c3cff24 |
parent 161 | 5b6e284959a4 |
child 171 | a5b9435e3bee |
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 |
ListEntry subclass:#ColoredListEntry |
|
158 | 14 |
instanceVariableNames:'color string bgColor' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Support' |
|
58 | 18 |
! |
19 |
||
20 |
!ColoredListEntry class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
Instances of ColoredListEntry can be used in place of strings |
|
39 |
as entries of the list in a ListView or SelectionInListView. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
40 |
|
170 | 41 |
Notice: this is a historic leftOver from times when the Text class |
42 |
was not available. Please do no longer use it (use Text right away). |
|
43 |
However: Text does not (currently) handle background color settings. |
|
158 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
47 |
||
48 |
[see also:] |
|
170 | 49 |
Text |
158 | 50 |
ListView |
161 | 51 |
ListEntry |
52 |
String Color |
|
58 | 53 |
" |
54 |
! |
|
55 |
||
56 |
examples |
|
57 |
" |
|
58 |
putting colored entries into a SelectionInListView |
|
59 |
(instead of strings)' |
|
161 | 60 |
[exBegin] |
61 |
|v e myList tabs| |
|
58 | 62 |
|
161 | 63 |
myList := OrderedCollection new. |
58 | 64 |
|
161 | 65 |
myList add:(ColoredListEntry string:'red' color:Color red). |
66 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
67 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
68 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
69 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
70 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
58 | 71 |
|
161 | 72 |
v := SelectionInListView new. |
73 |
v setList:myList expandTabs:false. |
|
74 |
v open |
|
75 |
[exEnd] |
|
58 | 76 |
|
77 |
||
60 | 78 |
in a popUpList (sorry, Labels do not (yet) know how to display |
79 |
non-strings. |
|
161 | 80 |
[exBegin] |
81 |
|v e myList selList tabs| |
|
58 | 82 |
|
161 | 83 |
myList := OrderedCollection new. |
58 | 84 |
|
161 | 85 |
myList add:(ColoredListEntry string:'red' color:Color red). |
86 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
87 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
88 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
89 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
90 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
58 | 91 |
|
161 | 92 |
selList := SelectionInList new list:myList. |
58 | 93 |
|
161 | 94 |
v := PopUpList on:selList. |
95 |
v open |
|
96 |
[exEnd] |
|
58 | 97 |
" |
98 |
! ! |
|
99 |
||
100 |
!ColoredListEntry class methodsFor:'instance creation'! |
|
101 |
||
102 |
string:aString color:aColor |
|
170 | 103 |
self obsoleteMethodWarning:'use Text>>string:color:'. |
104 |
||
105 |
^ Text string:aString color:aColor |
|
106 |
"/ ^ self new string:aString color:aColor |
|
107 |
||
108 |
"Modified: 12.5.1996 / 17:06:12 / cg" |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
109 |
! |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
110 |
|
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
111 |
string:aString foregroundColor:fgColor backgroundColor:bgColor |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
112 |
^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor |
58 | 113 |
! ! |
114 |
||
97 | 115 |
!ColoredListEntry methodsFor:'accessing'! |
116 |
||
117 |
string:aString color:aColor |
|
118 |
string := aString. |
|
119 |
color := aColor |
|
120 |
! |
|
121 |
||
122 |
string:aString foregroundColor:fg backgroundColor:bg |
|
123 |
string := aString. |
|
124 |
color := fg. |
|
125 |
bgColor := bg. |
|
126 |
||
127 |
"Created: 16.11.1995 / 16:53:17 / cg" |
|
128 |
! ! |
|
129 |
||
130 |
!ColoredListEntry methodsFor:'converting'! |
|
131 |
||
132 |
asString |
|
133 |
^ string |
|
134 |
! |
|
135 |
||
136 |
string |
|
137 |
^ string |
|
138 |
! ! |
|
139 |
||
58 | 140 |
!ColoredListEntry methodsFor:'drawing'! |
141 |
||
108 | 142 |
displayOn:aGC x:x y:y opaque:opaque |
58 | 143 |
"display the receiver on a GC" |
144 |
||
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
145 |
|savedPaint savedBgPaint| |
73 | 146 |
|
147 |
savedPaint := aGC paint. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
148 |
bgColor notNil ifTrue:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
149 |
savedBgPaint := aGC backgroundPaint. |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
150 |
aGC paint:color on:bgColor. |
93 | 151 |
aGC displayOpaqueString:(string withTabsExpanded) x:x y:y. |
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
152 |
aGC paint:savedPaint on:savedBgPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
153 |
] ifFalse:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
154 |
aGC paint:color. |
108 | 155 |
opaque ifTrue:[ |
156 |
aGC displayOpaqueString:(string withTabsExpanded) x:x y:y. |
|
157 |
] ifFalse:[ |
|
158 |
aGC displayString:(string withTabsExpanded) x:x y:y. |
|
159 |
]. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
160 |
aGC paint:savedPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
161 |
] |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
162 |
|
93 | 163 |
"Modified: 16.11.1995 / 16:54:40 / cg" |
58 | 164 |
! ! |
165 |
||
166 |
!ColoredListEntry methodsFor:'queries'! |
|
167 |
||
168 |
widthIn:aGC |
|
169 |
"return the width of the receiver when displayed in aGC" |
|
170 |
||
93 | 171 |
^ aGC font widthOf:(string withTabsExpanded) |
58 | 172 |
! ! |
97 | 173 |
|
98 | 174 |
!ColoredListEntry class methodsFor:'documentation'! |
175 |
||
176 |
version |
|
170 | 177 |
^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.12 1996-05-12 15:07:05 cg Exp $' |
98 | 178 |
! ! |