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