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 |
'From Smalltalk/X, Version:2.10.5 on 15-may-1995 at 8:03:34 am'!
|
|
14 |
|
|
15 |
ListEntry subclass:#ColoredListEntry
|
|
16 |
instanceVariableNames:'color string'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Support'
|
|
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 |
version
|
|
39 |
"
|
73
|
40 |
$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.3 1995-09-09 02:32:00 claus Exp $
|
58
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
documentation
|
|
45 |
"
|
|
46 |
Instances of ColoredListEntry can be used in place of strings
|
|
47 |
as entries of the list in a ListView or SelectionInListView.
|
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
examples
|
|
52 |
"
|
|
53 |
putting colored entries into a SelectionInListView
|
|
54 |
(instead of strings)'
|
|
55 |
|
|
56 |
|v e myList tabs|
|
|
57 |
|
|
58 |
myList := OrderedCollection new.
|
|
59 |
|
|
60 |
myList add:(ColoredListEntry string:'red' color:Color red).
|
|
61 |
myList add:(ColoredListEntry string:'green' color:Color green).
|
|
62 |
myList add:(ColoredListEntry string:'blue' color:Color blue).
|
|
63 |
myList add:(ColoredListEntry string:'white' color:Color white).
|
|
64 |
myList add:(ColoredListEntry string:'black' color:Color black).
|
|
65 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow).
|
|
66 |
|
|
67 |
v := SelectionInListView new.
|
|
68 |
v setList:myList expandTabs:false.
|
|
69 |
v open
|
|
70 |
|
|
71 |
|
60
|
72 |
in a popUpList (sorry, Labels do not (yet) know how to display
|
|
73 |
non-strings.
|
58
|
74 |
|
|
75 |
|v e myList selList tabs|
|
|
76 |
|
|
77 |
myList := OrderedCollection new.
|
|
78 |
|
|
79 |
myList add:(ColoredListEntry string:'red' color:Color red).
|
|
80 |
myList add:(ColoredListEntry string:'green' color:Color green).
|
|
81 |
myList add:(ColoredListEntry string:'blue' color:Color blue).
|
|
82 |
myList add:(ColoredListEntry string:'white' color:Color white).
|
|
83 |
myList add:(ColoredListEntry string:'black' color:Color black).
|
|
84 |
myList add:(ColoredListEntry string:'yellow' color:Color yellow).
|
|
85 |
|
|
86 |
selList := SelectionInList new list:myList.
|
|
87 |
|
|
88 |
v := PopUpList on:selList.
|
|
89 |
v open
|
|
90 |
"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!ColoredListEntry class methodsFor:'instance creation'!
|
|
94 |
|
|
95 |
string:aString color:aColor
|
|
96 |
^ self new string:aString color:aColor
|
|
97 |
! !
|
|
98 |
|
|
99 |
!ColoredListEntry methodsFor:'drawing'!
|
|
100 |
|
|
101 |
displayOn:aGC x:x y:y
|
|
102 |
"display the receiver on a GC"
|
|
103 |
|
73
|
104 |
|savedPaint|
|
|
105 |
|
|
106 |
savedPaint := aGC paint.
|
58
|
107 |
aGC paint:color.
|
|
108 |
aGC displayString:string x:x y:y.
|
73
|
109 |
aGC paint:savedPaint
|
58
|
110 |
! !
|
|
111 |
|
|
112 |
!ColoredListEntry methodsFor:'accessing'!
|
|
113 |
|
|
114 |
string:aString color:aColor
|
|
115 |
string := aString.
|
|
116 |
color := aColor
|
|
117 |
! !
|
|
118 |
|
|
119 |
!ColoredListEntry methodsFor:'converting'!
|
|
120 |
|
|
121 |
string
|
|
122 |
^ string
|
|
123 |
!
|
|
124 |
|
|
125 |
asString
|
|
126 |
^ string
|
|
127 |
! !
|
|
128 |
|
|
129 |
!ColoredListEntry methodsFor:'queries'!
|
|
130 |
|
|
131 |
widthIn:aGC
|
|
132 |
"return the width of the receiver when displayed in aGC"
|
|
133 |
|
|
134 |
^ aGC font widthOf:string
|
|
135 |
! !
|