ColoredListEntry.st
author Claus Gittinger <cg@exept.de>
Fri, 15 Jun 2018 10:54:35 +0200
changeset 5816 7876c07931a7
parent 3150 e3a55f15ef7e
child 4770 6634b540fea2
permissions -rw-r--r--
#DOCUMENTATION by cg class: ComboListView class comment/format in: #documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
     3
	      All Rights Reserved
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
claus
parents:
diff changeset
    12
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    13
"{ Package: 'stx:libwidg2' }"
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    14
58
claus
parents:
diff changeset
    15
ListEntry subclass:#ColoredListEntry
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    16
	instanceVariableNames:'color string bgColor'
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    17
	classVariableNames:''
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    18
	poolDictionaries:''
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    19
	category:'Views-Support'
58
claus
parents:
diff changeset
    20
!
claus
parents:
diff changeset
    21
claus
parents:
diff changeset
    22
!ColoredListEntry class methodsFor:'documentation'!
claus
parents:
diff changeset
    23
claus
parents:
diff changeset
    24
copyright
claus
parents:
diff changeset
    25
"
claus
parents:
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
    27
	      All Rights Reserved
claus
parents:
diff changeset
    28
claus
parents:
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    34
 hereby transferred.
claus
parents:
diff changeset
    35
"
claus
parents:
diff changeset
    36
!
claus
parents:
diff changeset
    37
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    Instances of ColoredListEntry can be used in place of strings
claus
parents:
diff changeset
    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
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
    43
    Notice: this is a historic leftOver from times when the Text class
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    44
	    was not available.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    45
	    Please do no longer use it (use Text right away).
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    46
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    47
    [author:]
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    48
	Claus Gittinger
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    49
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    50
    [see also:]
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    51
	Text
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    52
	ListView
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    53
	ListEntry
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    54
	String Color
58
claus
parents:
diff changeset
    55
"
claus
parents:
diff changeset
    56
!
claus
parents:
diff changeset
    57
claus
parents:
diff changeset
    58
examples
claus
parents:
diff changeset
    59
"
claus
parents:
diff changeset
    60
     putting colored entries into a SelectionInListView
claus
parents:
diff changeset
    61
     (instead of strings)'
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    62
									[exBegin]
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    63
	|v e myList tabs|
58
claus
parents:
diff changeset
    64
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    65
	myList := OrderedCollection new.
58
claus
parents:
diff changeset
    66
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    67
	myList add:(ColoredListEntry string:'red' color:Color red).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    68
	myList add:(ColoredListEntry string:'green' color:Color green).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    69
	myList add:(ColoredListEntry string:'blue' color:Color blue).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    70
	myList add:(ColoredListEntry string:'white' color:Color white).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    71
	myList add:(ColoredListEntry string:'black' color:Color black).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    72
	myList add:(ColoredListEntry string:'yellow' color:Color yellow).
58
claus
parents:
diff changeset
    73
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    74
	v := SelectionInListView new.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    75
	v setList:myList expandTabs:false.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    76
	v open
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    77
									[exEnd]
58
claus
parents:
diff changeset
    78
claus
parents:
diff changeset
    79
60
claus
parents: 58
diff changeset
    80
     in a popUpList (sorry, Labels do not (yet) know how to display
claus
parents: 58
diff changeset
    81
     non-strings.
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    82
									[exBegin]
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    83
	|v e myList selList tabs|
58
claus
parents:
diff changeset
    84
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    85
	myList := OrderedCollection new.
58
claus
parents:
diff changeset
    86
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    87
	myList add:(ColoredListEntry string:'red' color:Color red).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    88
	myList add:(ColoredListEntry string:'green' color:Color green).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    89
	myList add:(ColoredListEntry string:'blue' color:Color blue).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    90
	myList add:(ColoredListEntry string:'white' color:Color white).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    91
	myList add:(ColoredListEntry string:'black' color:Color black).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    92
	myList add:(ColoredListEntry string:'yellow' color:Color yellow).
58
claus
parents:
diff changeset
    93
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    94
	selList := SelectionInList new list:myList.
58
claus
parents:
diff changeset
    95
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    96
	v := PopUpList on:selList.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    97
	v open
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    98
									[exEnd]
58
claus
parents:
diff changeset
    99
"
claus
parents:
diff changeset
   100
! !
claus
parents:
diff changeset
   101
claus
parents:
diff changeset
   102
!ColoredListEntry class methodsFor:'instance creation'!
claus
parents:
diff changeset
   103
claus
parents:
diff changeset
   104
string:aString color:aColor
170
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   105
    self obsoleteMethodWarning:'use Text>>string:color:'.
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   106
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   107
    ^ Text string:aString color:aColor
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   108
"/    ^ self new string:aString color:aColor
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   109
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   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
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   114
    self obsoleteMethodWarning:'use Text>>emphasis:'.
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   115
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   116
    ^ Text
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   117
	string:aString
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   118
	emphasis:(Array with:(#color->fgColor)
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   119
			with:(#backgroundColor->bgColor))
171
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   120
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   121
"/    ^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   122
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   123
    "Modified: 12.5.1996 / 19:48:27 / cg"
58
claus
parents:
diff changeset
   124
! !
claus
parents:
diff changeset
   125
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   126
!ColoredListEntry methodsFor:'accessing'!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   127
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   128
string:aString color:aColor
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   129
    string := aString.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   130
    color := aColor
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   131
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   132
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   133
string:aString foregroundColor:fg backgroundColor:bg
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   134
    string := aString.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   135
    color := fg.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   136
    bgColor := bg.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   137
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   138
    "Created: 16.11.1995 / 16:53:17 / cg"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   139
! !
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   140
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   141
!ColoredListEntry methodsFor:'converting'!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   142
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   143
asString
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   144
    ^ string
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   145
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   146
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   147
string
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   148
    ^ string
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   149
! !
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   150
58
claus
parents:
diff changeset
   151
!ColoredListEntry methodsFor:'drawing'!
claus
parents:
diff changeset
   152
108
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   153
displayOn:aGC x:x y:y opaque:opaque
58
claus
parents:
diff changeset
   154
    "display the receiver on a GC"
claus
parents:
diff changeset
   155
88
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   156
    |savedPaint savedBgPaint|
73
claus
parents: 60
diff changeset
   157
claus
parents: 60
diff changeset
   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
f3158d8e67d0 handle tabs in strings
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   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
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   166
	opaque ifTrue:[
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   167
	    aGC displayOpaqueString:(string withTabsExpanded) x:x y:y.
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   168
	] ifFalse:[
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   169
	    aGC displayString:(string withTabsExpanded) x:x y:y.
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   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
f3158d8e67d0 handle tabs in strings
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   174
    "Modified: 16.11.1995 / 16:54:40 / cg"
58
claus
parents:
diff changeset
   175
! !
claus
parents:
diff changeset
   176
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   177
!ColoredListEntry class methodsFor:'documentation'!
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   178
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   179
version
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   180
    ^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.14 2006-11-13 16:11:29 cg Exp $'
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   181
! !