|
Class: LabelAndIcon
Object
|
+--ListEntry
|
+--ModelListEntry
|
+--LabelAndIcon
|
+--LabelAndTwoIcons
- Package:
- stx:libwidg2
- Category:
- Views-Support
- Version:
- rev:
1.56
date: 2023/11/16 21:46:56
- user: stefan
- file: LabelAndIcon.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
an icon, an optional additional image and a string, all by side (from left to right).
Each may be nil (i.e. with a nil image, it's a Label-and-Icon proper (icon to the left of the string).
Usable as list entries in a listView (a fileList), as
popUpMenuItems or as Label/Button image.
Notice:
This is different from ST-80's LabelAndIcon class, which
inherits from Label. Therefore, things may change in the future.
copyrightCOPYRIGHT (c) 1996 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
instance creation
-
form: aForm image: anImage
-
return an instance consisting of a form and an icon (on the left)
-
form: aForm image: anImage string: aString
-
return an instance consisting of two images (both on the left)
and a string
-
icon: anIcon string: aString
-
return an instance consisting of a label-string
and an icon (on the left)
-
label: aString icon: anIcon
-
return an instance consisting of a label-string
and an icon (on the left)
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
-
string: aString
-
return an instance consisting of a string only
-
string: aString image: image
-
return an instance consisting of a label-string
and an image (on the right)
accessing
-
beCheckMark
-
self icon:(CheckToggle checkFormOn:Screen current)
-
form: aForm image: anImage string: aString
-
-
gap
-
return the spacing between the icon and the labelString.
The default is 4
-
gap: pixels
-
set the spacing between the icon and the labelString.
The default is 4.
-
icon
-
return my icon part
-
icon: anIcon
-
set the icon image
-
icon: anIcon string: aString
-
set both iconImage and the labelString
-
image
-
return my image
-
image: anImage
-
set the image
-
imagePosition: aSymbol
-
controls if the image is to be shown at #left or #right.
Default is #left.
-
label
-
-
label: aString
-
-
offset
-
set the left offset (i.e. spacing to the left of the icon).
The default is 0.
-
offset: pixels
-
set the left offset (i.e. spacing to the left of the icon).
The default is 0.
-
xOfString
-
returns the x position of the string
comparing
-
= aStringOrLabelAndIcon
-
(comment from inherited method)
behave like a string when comparing
-
sameStringAndEmphasisAs: someStringOrLabelAndIcon
-
converting
-
asDragAndDropDisplayObjectOn: aDevice
-
convert myself to something that can be display by the DragAndDropManager on aDevice
displaying
-
displayOn: aGC x: x y: y opaque: opaque
-
display the receiver on a GC
-
on: aDevice
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
onDevice: aDevice
-
return with both icon and image onDevice:aDevice
initialization
-
initialize
-
(comment from inherited method)
just to ignore initialize to objects which do not need it
queries
-
hasIcon
-
-
hasImage
-
-
heightOn: aGC
-
return the height of the receiver, if it is to be displayed on aGC
-
widthOn: aGC
-
return the width of the receiver, if it is to be displayed on aGC
testing
-
isLabelAndIcon
-
text compatibility
-
withoutAnyColorEmphasis
-
(comment from inherited method)
to be redefined in subclasses
-
withoutBackgroundColorEmphasis
-
-
withoutForegroundColorEmphasis
-
in a listView:
|top slv wrapper l fileImage dirImage|
fileImage := Image
width:16
height:16
depth:1
fromArray:#[2r00000000 2r00000000
2r00000000 2r00000000
2r00011111 2r11100000
2r00010000 2r00100000
2r00010000 2r00011000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00010000 2r00001000
2r00011111 2r11111000
2r00000000 2r00000000
2r00000000 2r00000000].
fileImage photometric:#whiteIs0.
dirImage := Image
width:16
height:16
depth:1
fromArray:#[2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r01111111 2r11110000
2r01000000 2r00001000
2r01000000 2r00000100
2r01000000 2r00000010
2r01000000 2r00000010
2r01000000 2r00000010
2r01000000 2r00000010
2r01000000 2r00000010
2r01000000 2r00000010
2r01111111 2r11111110
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000].
dirImage photometric:#whiteIs0.
l := OrderedCollection new.
Filename currentDirectory directoryContents do:[:s |
s asFilename isDirectory ifTrue:[
l add:(LabelAndIcon icon:dirImage string:s)
] ifFalse:[
l add:(LabelAndIcon icon:fileImage string:s)
]
].
slv := SelectionInListView new.
slv list:l.
wrapper := HVScrollableView forView:slv miniScrollerH:true.
top := StandardSystemView extent:150@200.
top add:wrapper in:(0.0@0.0 corner:1.0@1.0).
top open.
| in a selectionInListView:
|top slv wrapper l fileImage dirImage|
dirImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_dir.xpm'.
fileImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_text.xpm'.
l := OrderedCollection new.
Filename currentDirectory directoryContents do:[:s |
s asFilename isDirectory ifTrue:[
l add:(LabelAndIcon icon:dirImage string:s)
] ifFalse:[
l add:(LabelAndIcon icon:fileImage string:s)
]
].
slv := SelectionInListView new.
slv list:l.
wrapper := HVScrollableView forView:slv miniScrollerH:true.
top := StandardSystemView extent:150@200.
top add:wrapper in:(0.0@0.0 corner:1.0@1.0).
top open.
| in a menu:
|top l image1 image2|
image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/argentina.xpm'.
image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'.
l := OrderedCollection new.
l add:(LabelAndIcon icon:image1 string:'argentina').
l add:(LabelAndIcon icon:image2 string:'germany').
top := StandardSystemView new.
top middleButtonMenu:(PopUpMenu
labels:l
selectors:#(foo bar)).
top label:'Try the right-button menu'.
top extent:300@300.
top open.
| in a button/label:
|top l image|
image := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
l := (LabelAndIcon icon:image string:'brazil').
top := Button label:l.
top open.
| two images in a button/label:
|top l image1 image2|
image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'.
l := (LabelAndIcon form:image1 image:image2 string:'directory').
top := Button label:l.
top open.
|
|