eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'LabelAndIcon':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: LabelAndIcon


Inheritance:

   Object
   |
   +--ListEntry
      |
      +--ModelListEntry
         |
         +--LabelAndIcon
            |
            +--LabelAndTwoIcons

Package:
stx:libwidg2
Category:
Views-Support
Version:
rev: 1.51 date: 2019/03/09 14:43:39
user: cg
file: LabelAndIcon.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Gittinger

Description:


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.


Related information:

    ListEntry
    Text
    String
    Icon
    ListView
    SelectionInListView

Class protocol:

instance creation
o  form: aForm image: anImage
return an instance consisting of a form and an icon (on the left)

o  form: aForm image: anImage string: aString
return an instance consisting of two images (both on the left)
and a string

o  icon: anIcon string: aString
return an instance consisting of a label-string
and an icon (on the left)

o  label: aString icon: anIcon
return an instance consisting of a label-string
and an icon (on the left)

o  new
(comment from inherited method)
return an instance of myself without indexed variables

o  string: aString
return an instance consisting of a string only

o  string: aString image: image
return an instance consisting of a label-string
and an image (on the right)


Instance protocol:

accessing
o  beCheckMark
self icon:(CheckToggle checkFormOn:Screen current)

o  form: aForm image: anImage string: aString

o  gap
return the spacing between the icon and the labelString.
The default is 4

o  gap: pixels
set the spacing between the icon and the labelString.
The default is 4.

o  icon
return my icon part

o  icon: anIcon
set the icon image

o  icon: anIcon string: aString
set both iconImage and the labelString

o  image
return my image

o  image: anImage
set the image

o  imagePosition: aSymbol
controls if the image is to be shown at #left or #right.
Default is #left.

o  offset
set the left offset (i.e. spacing to the left of the icon).
The default is 0.

o  offset: pixels
set the left offset (i.e. spacing to the left of the icon).
The default is 0.

o  xOfString
returns the x position of the string

comparing
o  = aStringOrLabelAndIcon

o  sameStringAndEmphasisAs: someStringOrLabelAndIcon

displaying
o  displayOn: aGC x: x y: y opaque: opaque
display the receiver on a GC

o  on: aDevice

o  onDevice: aDevice
return with both icon and image onDevice:aDevice

initialization
o  initialize
(comment from inherited method)
just to ignore initialize to objects which do not need it

queries
o  hasIcon

o  hasImage

o  heightOn: aGC
return the height of the receiver, if it is to be displayed on aGC

o  widthOn: aGC
return the width of the receiver, if it is to be displayed on aGC

testing
o  isLabelAndIcon

text compatibility
o  withoutAnyColorEmphasis

o  withoutBackgroundColorEmphasis

o  withoutForegroundColorEmphasis


Examples:


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.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Sat, 20 Apr 2024 09:36:49 GMT