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