author | Claus Gittinger <cg@exept.de> |
Sat, 02 May 2020 13:15:17 +0200 | |
changeset 6243 | 949681aaf3e4 |
parent 3150 | e3a55f15ef7e |
child 4770 | 6634b540fea2 |
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 |
||
3150 | 13 |
"{ Package: 'stx:libwidg2' }" |
14 |
||
58 | 15 |
ListEntry subclass:#ColoredListEntry |
158 | 16 |
instanceVariableNames:'color string bgColor' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Support' |
|
58 | 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 |
documentation |
|
39 |
" |
|
40 |
Instances of ColoredListEntry can be used in place of strings |
|
41 |
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
|
42 |
|
170 | 43 |
Notice: this is a historic leftOver from times when the Text class |
3150 | 44 |
was not available. |
45 |
Please do no longer use it (use Text right away). |
|
158 | 46 |
|
47 |
[author:] |
|
3150 | 48 |
Claus Gittinger |
158 | 49 |
|
50 |
[see also:] |
|
3150 | 51 |
Text |
52 |
ListView |
|
53 |
ListEntry |
|
54 |
String Color |
|
58 | 55 |
" |
56 |
! |
|
57 |
||
58 |
examples |
|
59 |
" |
|
60 |
putting colored entries into a SelectionInListView |
|
61 |
(instead of strings)' |
|
3150 | 62 |
[exBegin] |
63 |
|v e myList tabs| |
|
58 | 64 |
|
3150 | 65 |
myList := OrderedCollection new. |
58 | 66 |
|
3150 | 67 |
myList add:(ColoredListEntry string:'red' color:Color red). |
68 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
69 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
70 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
71 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
72 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
58 | 73 |
|
3150 | 74 |
v := SelectionInListView new. |
75 |
v setList:myList expandTabs:false. |
|
76 |
v open |
|
77 |
[exEnd] |
|
58 | 78 |
|
79 |
||
60 | 80 |
in a popUpList (sorry, Labels do not (yet) know how to display |
81 |
non-strings. |
|
3150 | 82 |
[exBegin] |
83 |
|v e myList selList tabs| |
|
58 | 84 |
|
3150 | 85 |
myList := OrderedCollection new. |
58 | 86 |
|
3150 | 87 |
myList add:(ColoredListEntry string:'red' color:Color red). |
88 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
89 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
90 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
91 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
92 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
58 | 93 |
|
3150 | 94 |
selList := SelectionInList new list:myList. |
58 | 95 |
|
3150 | 96 |
v := PopUpList on:selList. |
97 |
v open |
|
98 |
[exEnd] |
|
58 | 99 |
" |
100 |
! ! |
|
101 |
||
102 |
!ColoredListEntry class methodsFor:'instance creation'! |
|
103 |
||
104 |
string:aString color:aColor |
|
170 | 105 |
self obsoleteMethodWarning:'use Text>>string:color:'. |
106 |
||
107 |
^ Text string:aString color:aColor |
|
108 |
"/ ^ self new string:aString color:aColor |
|
109 |
||
110 |
"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
|
111 |
! |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
112 |
|
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
113 |
string:aString foregroundColor:fgColor backgroundColor:bgColor |
171 | 114 |
self obsoleteMethodWarning:'use Text>>emphasis:'. |
115 |
||
3150 | 116 |
^ Text |
117 |
string:aString |
|
118 |
emphasis:(Array with:(#color->fgColor) |
|
119 |
with:(#backgroundColor->bgColor)) |
|
171 | 120 |
|
121 |
"/ ^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor |
|
122 |
||
123 |
"Modified: 12.5.1996 / 19:48:27 / cg" |
|
58 | 124 |
! ! |
125 |
||
97 | 126 |
!ColoredListEntry methodsFor:'accessing'! |
127 |
||
128 |
string:aString color:aColor |
|
129 |
string := aString. |
|
130 |
color := aColor |
|
131 |
! |
|
132 |
||
133 |
string:aString foregroundColor:fg backgroundColor:bg |
|
134 |
string := aString. |
|
135 |
color := fg. |
|
136 |
bgColor := bg. |
|
137 |
||
138 |
"Created: 16.11.1995 / 16:53:17 / cg" |
|
139 |
! ! |
|
140 |
||
141 |
!ColoredListEntry methodsFor:'converting'! |
|
142 |
||
143 |
asString |
|
144 |
^ string |
|
145 |
! |
|
146 |
||
147 |
string |
|
148 |
^ string |
|
149 |
! ! |
|
150 |
||
58 | 151 |
!ColoredListEntry methodsFor:'drawing'! |
152 |
||
108 | 153 |
displayOn:aGC x:x y:y opaque:opaque |
58 | 154 |
"display the receiver on a GC" |
155 |
||
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
156 |
|savedPaint savedBgPaint| |
73 | 157 |
|
158 |
savedPaint := aGC paint. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
159 |
bgColor notNil ifTrue:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
160 |
savedBgPaint := aGC backgroundPaint. |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
161 |
aGC paint:color on:bgColor. |
93 | 162 |
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
|
163 |
aGC paint:savedPaint on:savedBgPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
164 |
] ifFalse:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
165 |
aGC paint:color. |
108 | 166 |
opaque ifTrue:[ |
167 |
aGC displayOpaqueString:(string withTabsExpanded) x:x y:y. |
|
168 |
] ifFalse:[ |
|
169 |
aGC displayString:(string withTabsExpanded) x:x y:y. |
|
170 |
]. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
171 |
aGC paint:savedPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
172 |
] |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
173 |
|
93 | 174 |
"Modified: 16.11.1995 / 16:54:40 / cg" |
58 | 175 |
! ! |
176 |
||
98 | 177 |
!ColoredListEntry class methodsFor:'documentation'! |
178 |
||
179 |
version |
|
3150 | 180 |
^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.14 2006-11-13 16:11:29 cg Exp $' |
98 | 181 |
! ! |