author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 19:33:23 +0200 | |
changeset 158 | 431e38dfc5ab |
parent 108 | b228b94be590 |
child 161 | 5b6e284959a4 |
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 |
|
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
41 |
Notice: this is a temporary kludge class which will be made obsolete, |
158 | 42 |
once full-attributed strings are available. |
43 |
||
44 |
[author:] |
|
45 |
Claus Gittinger |
|
46 |
||
47 |
[see also:] |
|
48 |
ListView |
|
58 | 49 |
" |
50 |
! |
|
51 |
||
52 |
examples |
|
53 |
" |
|
54 |
putting colored entries into a SelectionInListView |
|
55 |
(instead of strings)' |
|
56 |
||
57 |
|v e myList tabs| |
|
58 |
||
59 |
myList := OrderedCollection new. |
|
60 |
||
61 |
myList add:(ColoredListEntry string:'red' color:Color red). |
|
62 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
63 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
64 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
65 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
66 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
67 |
||
68 |
v := SelectionInListView new. |
|
69 |
v setList:myList expandTabs:false. |
|
70 |
v open |
|
71 |
||
72 |
||
60 | 73 |
in a popUpList (sorry, Labels do not (yet) know how to display |
74 |
non-strings. |
|
58 | 75 |
|
76 |
|v e myList selList tabs| |
|
77 |
||
78 |
myList := OrderedCollection new. |
|
79 |
||
80 |
myList add:(ColoredListEntry string:'red' color:Color red). |
|
81 |
myList add:(ColoredListEntry string:'green' color:Color green). |
|
82 |
myList add:(ColoredListEntry string:'blue' color:Color blue). |
|
83 |
myList add:(ColoredListEntry string:'white' color:Color white). |
|
84 |
myList add:(ColoredListEntry string:'black' color:Color black). |
|
85 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow). |
|
86 |
||
87 |
selList := SelectionInList new list:myList. |
|
88 |
||
89 |
v := PopUpList on:selList. |
|
90 |
v open |
|
91 |
" |
|
92 |
! ! |
|
93 |
||
94 |
!ColoredListEntry class methodsFor:'instance creation'! |
|
95 |
||
96 |
string:aString color:aColor |
|
97 |
^ self new string:aString color:aColor |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
98 |
! |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
99 |
|
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
100 |
string:aString foregroundColor:fgColor backgroundColor:bgColor |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
101 |
^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor |
58 | 102 |
! ! |
103 |
||
97 | 104 |
!ColoredListEntry methodsFor:'accessing'! |
105 |
||
106 |
string:aString color:aColor |
|
107 |
string := aString. |
|
108 |
color := aColor |
|
109 |
! |
|
110 |
||
111 |
string:aString foregroundColor:fg backgroundColor:bg |
|
112 |
string := aString. |
|
113 |
color := fg. |
|
114 |
bgColor := bg. |
|
115 |
||
116 |
"Created: 16.11.1995 / 16:53:17 / cg" |
|
117 |
! ! |
|
118 |
||
119 |
!ColoredListEntry methodsFor:'converting'! |
|
120 |
||
121 |
asString |
|
122 |
^ string |
|
123 |
! |
|
124 |
||
125 |
string |
|
126 |
^ string |
|
127 |
! ! |
|
128 |
||
58 | 129 |
!ColoredListEntry methodsFor:'drawing'! |
130 |
||
108 | 131 |
displayOn:aGC x:x y:y opaque:opaque |
58 | 132 |
"display the receiver on a GC" |
133 |
||
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
134 |
|savedPaint savedBgPaint| |
73 | 135 |
|
136 |
savedPaint := aGC paint. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
137 |
bgColor notNil ifTrue:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
138 |
savedBgPaint := aGC backgroundPaint. |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
139 |
aGC paint:color on:bgColor. |
93 | 140 |
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
|
141 |
aGC paint:savedPaint on:savedBgPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
142 |
] ifFalse:[ |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
143 |
aGC paint:color. |
108 | 144 |
opaque ifTrue:[ |
145 |
aGC displayOpaqueString:(string withTabsExpanded) x:x y:y. |
|
146 |
] ifFalse:[ |
|
147 |
aGC displayString:(string withTabsExpanded) x:x y:y. |
|
148 |
]. |
|
88
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
149 |
aGC paint:savedPaint |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
150 |
] |
d591b16c8f46
allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
151 |
|
93 | 152 |
"Modified: 16.11.1995 / 16:54:40 / cg" |
58 | 153 |
! ! |
154 |
||
155 |
!ColoredListEntry methodsFor:'queries'! |
|
156 |
||
157 |
widthIn:aGC |
|
158 |
"return the width of the receiver when displayed in aGC" |
|
159 |
||
93 | 160 |
^ aGC font widthOf:(string withTabsExpanded) |
58 | 161 |
! ! |
97 | 162 |
|
98 | 163 |
!ColoredListEntry class methodsFor:'documentation'! |
164 |
||
165 |
version |
|
158 | 166 |
^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.10 1996-04-25 17:31:23 cg Exp $' |
98 | 167 |
! ! |