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