ColoredListEntry.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 02 Sep 2022 11:25:39 +0100
branchjv
changeset 6261 9b7eb7159d29
parent 4770 6634b540fea2
permissions -rw-r--r--
Fix loong standing bug with some menus not being translated / resolved This has happened with browser "View" menu when sometimes it had the slice resolved and sometimes not. It turned out that it was because the code disabled resources (and therefore slices) resolution when processing shortcuts, so the menu was created and cached unresolved. This fixes the issue. eXept apparently run into the same problem.
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
"
4770
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3150
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
58
claus
parents:
diff changeset
    13
4770
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3150
diff changeset
    14
"{ NameSpace: Smalltalk }"
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    15
58
claus
parents:
diff changeset
    16
ListEntry subclass:#ColoredListEntry
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    17
	instanceVariableNames:'color string bgColor'
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    18
	classVariableNames:''
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    19
	poolDictionaries:''
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    20
	category:'Views-Support'
58
claus
parents:
diff changeset
    21
!
claus
parents:
diff changeset
    22
claus
parents:
diff changeset
    23
!ColoredListEntry class methodsFor:'documentation'!
claus
parents:
diff changeset
    24
claus
parents:
diff changeset
    25
copyright
claus
parents:
diff changeset
    26
"
claus
parents:
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
    28
	      All Rights Reserved
claus
parents:
diff changeset
    29
claus
parents:
diff changeset
    30
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    35
 hereby transferred.
claus
parents:
diff changeset
    36
"
claus
parents:
diff changeset
    37
!
claus
parents:
diff changeset
    38
claus
parents:
diff changeset
    39
documentation
claus
parents:
diff changeset
    40
"
claus
parents:
diff changeset
    41
    Instances of ColoredListEntry can be used in place of strings
claus
parents:
diff changeset
    42
    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
    43
170
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
    44
    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
    45
	    was not available.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    46
	    Please do no longer use it (use Text right away).
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    47
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    48
    [author:]
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    49
	Claus Gittinger
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    50
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    51
    [see also:]
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    52
	Text
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    53
	ListView
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    54
	ListEntry
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    55
	String Color
58
claus
parents:
diff changeset
    56
"
claus
parents:
diff changeset
    57
!
claus
parents:
diff changeset
    58
claus
parents:
diff changeset
    59
examples
claus
parents:
diff changeset
    60
"
claus
parents:
diff changeset
    61
     putting colored entries into a SelectionInListView
claus
parents:
diff changeset
    62
     (instead of strings)'
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    63
									[exBegin]
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    64
	|v e myList tabs|
58
claus
parents:
diff changeset
    65
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    66
	myList := OrderedCollection new.
58
claus
parents:
diff changeset
    67
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    68
	myList add:(ColoredListEntry string:'red' color:Color red).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    69
	myList add:(ColoredListEntry string:'green' color:Color green).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    70
	myList add:(ColoredListEntry string:'blue' color:Color blue).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    71
	myList add:(ColoredListEntry string:'white' color:Color white).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    72
	myList add:(ColoredListEntry string:'black' color:Color black).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    73
	myList add:(ColoredListEntry string:'yellow' color:Color yellow).
58
claus
parents:
diff changeset
    74
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    75
	v := SelectionInListView new.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    76
	v setList:myList expandTabs:false.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    77
	v open
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    78
									[exEnd]
58
claus
parents:
diff changeset
    79
claus
parents:
diff changeset
    80
60
claus
parents: 58
diff changeset
    81
     in a popUpList (sorry, Labels do not (yet) know how to display
claus
parents: 58
diff changeset
    82
     non-strings.
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    83
									[exBegin]
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    84
	|v e myList selList tabs|
58
claus
parents:
diff changeset
    85
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    86
	myList := OrderedCollection new.
58
claus
parents:
diff changeset
    87
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    88
	myList add:(ColoredListEntry string:'red' color:Color red).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    89
	myList add:(ColoredListEntry string:'green' color:Color green).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    90
	myList add:(ColoredListEntry string:'blue' color:Color blue).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    91
	myList add:(ColoredListEntry string:'white' color:Color white).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    92
	myList add:(ColoredListEntry string:'black' color:Color black).
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    93
	myList add:(ColoredListEntry string:'yellow' color:Color yellow).
58
claus
parents:
diff changeset
    94
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    95
	selList := SelectionInList new list:myList.
58
claus
parents:
diff changeset
    96
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    97
	v := PopUpList on:selList.
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    98
	v open
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
    99
									[exEnd]
58
claus
parents:
diff changeset
   100
"
claus
parents:
diff changeset
   101
! !
claus
parents:
diff changeset
   102
claus
parents:
diff changeset
   103
!ColoredListEntry class methodsFor:'instance creation'!
claus
parents:
diff changeset
   104
claus
parents:
diff changeset
   105
string:aString color:aColor
170
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   106
    self obsoleteMethodWarning:'use Text>>string:color:'.
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
    ^ Text string:aString color:aColor
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   109
"/    ^ self new string:aString color:aColor
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   110
f8609c3cff24 docu update
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   111
    "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
   112
!
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   113
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   114
string:aString foregroundColor:fgColor backgroundColor:bgColor
171
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   115
    self obsoleteMethodWarning:'use Text>>emphasis:'.
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   116
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   117
    ^ Text
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   118
	string:aString
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   119
	emphasis:(Array with:(#color->fgColor)
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   120
			with:(#backgroundColor->bgColor))
171
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   121
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   122
"/    ^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   123
a5b9435e3bee obsoleted by Text
Claus Gittinger <cg@exept.de>
parents: 170
diff changeset
   124
    "Modified: 12.5.1996 / 19:48:27 / cg"
58
claus
parents:
diff changeset
   125
! !
claus
parents:
diff changeset
   126
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   127
!ColoredListEntry methodsFor:'accessing'!
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
string:aString color:aColor
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   130
    string := aString.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   131
    color := aColor
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
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   134
string:aString foregroundColor:fg backgroundColor:bg
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   135
    string := aString.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   136
    color := fg.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   137
    bgColor := bg.
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
    "Created: 16.11.1995 / 16:53:17 / cg"
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
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   142
!ColoredListEntry methodsFor:'converting'!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   143
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   144
asString
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   145
    ^ string
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
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
    ^ string
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   150
! !
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 93
diff changeset
   151
58
claus
parents:
diff changeset
   152
!ColoredListEntry methodsFor:'drawing'!
claus
parents:
diff changeset
   153
108
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   154
displayOn:aGC x:x y:y opaque:opaque
58
claus
parents:
diff changeset
   155
    "display the receiver on a GC"
claus
parents:
diff changeset
   156
88
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   157
    |savedPaint savedBgPaint|
73
claus
parents: 60
diff changeset
   158
claus
parents: 60
diff changeset
   159
    savedPaint := aGC paint.
88
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   160
    bgColor notNil ifTrue:[
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   161
	savedBgPaint := aGC backgroundPaint.
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   162
	aGC paint:color on:bgColor.
93
f3158d8e67d0 handle tabs in strings
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   163
	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
   164
	aGC paint:savedPaint on:savedBgPaint
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   165
    ] ifFalse:[
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   166
	aGC paint:color.
108
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   167
	opaque ifTrue:[
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   168
	    aGC displayOpaqueString:(string withTabsExpanded) x:x y:y.
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   169
	] ifFalse:[
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   170
	    aGC displayString:(string withTabsExpanded) x:x y:y.
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   171
	].
88
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   172
	aGC paint:savedPaint
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   173
    ]
d591b16c8f46 allow for background (i.e. opaque strings)
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   174
93
f3158d8e67d0 handle tabs in strings
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   175
    "Modified: 16.11.1995 / 16:54:40 / cg"
58
claus
parents:
diff changeset
   176
! !
claus
parents:
diff changeset
   177
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   178
!ColoredListEntry class methodsFor:'documentation'!
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   179
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   180
version
3150
e3a55f15ef7e package information
Claus Gittinger <cg@exept.de>
parents: 171
diff changeset
   181
    ^ '$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
   182
! !
4770
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3150
diff changeset
   183