LabelAndIcon.st
author Claus Gittinger <cg@exept.de>
Fri, 28 Jun 2019 09:21:50 +0200
changeset 6078 08c9e2a47dc5
parent 6033 83fa7b6785ec
permissions -rw-r--r--
#OTHER by cg self class name -> self className
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
     1
"{ Encoding: utf8 }"
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
     2
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1996 by Claus Gittinger
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
1814
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
    15
4878
5928056755ab #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 4678
diff changeset
    16
"{ NameSpace: Smalltalk }"
5928056755ab #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 4678
diff changeset
    17
2197
7ad026a1ae93 Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents: 1977
diff changeset
    18
ModelListEntry subclass:#LabelAndIcon
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
    19
	instanceVariableNames:'icon gap image offset imagePosition'
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Views-Support'
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!LabelAndIcon class methodsFor:'documentation'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 1996 by Claus Gittinger
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
    44
    an icon, an optional additional image and a string, all by side (from left to right).
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
    45
    Each may be nil (i.e. with a nil image, it's a Label-and-Icon proper (icon to the left of the string).
3781
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
    46
178
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
    47
    Usable as list entries in a listView (a fileList), as
179
fccdac863996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    48
    popUpMenuItems or as Label/Button image.
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
179
fccdac863996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    50
    Notice:
fccdac863996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    51
        This is different from ST-80's LabelAndIcon class, which
fccdac863996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    52
        inherits from Label. Therefore, things may change in the future.
fccdac863996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    53
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    [author:]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        Claus Gittinger
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    [see also:]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        ListEntry Text String Icon
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        ListView SelectionInListView
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
examples
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    65
  in a listView:
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
                                                                        [exBegin]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    |top slv wrapper l fileImage dirImage|
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    fileImage := Image 
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
                   width:16 
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
                   height:16
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                   depth:1
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
                   fromArray:#[2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
                               2r00011111 2r11100000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
                               2r00010000 2r00100000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
                               2r00010000 2r00011000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
                               2r00010000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
                               2r00011111 2r11111000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
                               2r00000000 2r00000000].
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    fileImage photometric:#whiteIs0.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    dirImage := Image 
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
                   width:16 
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
                   height:16
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
                   depth:1
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
                   fromArray:#[2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
                               2r01111111 2r11110000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                               2r01000000 2r00001000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
                               2r01000000 2r00000100
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
                               2r01000000 2r00000010
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                               2r01111111 2r11111110
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
                               2r00000000 2r00000000
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
                               2r00000000 2r00000000].
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    dirImage photometric:#whiteIs0.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    l := OrderedCollection new.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    Filename currentDirectory directoryContents do:[:s |
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        s asFilename isDirectory ifTrue:[
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
            l add:(LabelAndIcon icon:dirImage string:s)
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        ] ifFalse:[
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
            l add:(LabelAndIcon icon:fileImage string:s)
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        ]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ].
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    slv := SelectionInListView new.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    slv list:l.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    wrapper := HVScrollableView forView:slv miniScrollerH:true.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    top := StandardSystemView extent:150@200.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    top add:wrapper in:(0.0@0.0 corner:1.0@1.0).
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    top open.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
                                                                        [exEnd]
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   131
  in a selectionInListView:
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
                                                                        [exBegin]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    |top slv wrapper l fileImage dirImage|
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   135
    dirImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_dir.xpm'.
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   136
    fileImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_text.xpm'.
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    l := OrderedCollection new.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    Filename currentDirectory directoryContents do:[:s |
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
        s asFilename isDirectory ifTrue:[
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
            l add:(LabelAndIcon icon:dirImage string:s)
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
        ] ifFalse:[
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
            l add:(LabelAndIcon icon:fileImage string:s)
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
        ]
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    ].
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    slv := SelectionInListView new.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    slv list:l.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    wrapper := HVScrollableView forView:slv miniScrollerH:true.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    top := StandardSystemView extent:150@200.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    top add:wrapper in:(0.0@0.0 corner:1.0@1.0).
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    top open.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                                                        [exEnd]
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   156
  in a menu:
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   157
                                                                        [exBegin]
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   158
    |top l image1 image2|
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   159
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   160
    image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/argentina.xpm'.
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   161
    image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'.
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   162
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   163
    l := OrderedCollection new.
4128
9782e35719f8 changed: #examples
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
   164
    l add:(LabelAndIcon icon:image1 string:'argentina').
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   165
    l add:(LabelAndIcon icon:image2 string:'germany').
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   166
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   167
    top := StandardSystemView new.
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   168
    top middleButtonMenu:(PopUpMenu 
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   169
                        labels:l
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   170
                        selectors:#(foo bar)).
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   171
    top label:'Try the right-button menu'.
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   172
    top extent:300@300.
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   173
    top open.
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   174
                                                                        [exEnd]
178
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   175
  in a button/label:
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   176
                                                                        [exBegin]
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   177
    |top l image|
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   178
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   179
    image := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   180
    l := (LabelAndIcon icon:image string:'brazil').
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   181
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   182
    top := Button label:l.
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   183
    top open.
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   184
                                                                        [exEnd]
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   185
  two images in a button/label:
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   186
                                                                        [exBegin]
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   187
    |top l image1 image2|
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   188
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   189
    image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   190
    image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'.
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   191
    l := (LabelAndIcon form:image1 image:image2 string:'directory').
178
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   192
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   193
    top := Button label:l.
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   194
    top open.
ba4f86aaa203 example
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   195
                                                                        [exEnd]
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
!LabelAndIcon class methodsFor:'instance creation'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   201
form:aForm image:anImage
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   202
    "return an instance consisting of a form and an icon (on the left)"
726
4b3a40124f6d center label, icon and image in the display routine
tz
parents: 719
diff changeset
   203
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   204
    ^self new form:aForm image:anImage string:''
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   205
!
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   206
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   207
form:aForm image:anImage string:aString
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   208
    "return an instance consisting of two images (both on the left) 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   209
     and a string"
726
4b3a40124f6d center label, icon and image in the display routine
tz
parents: 719
diff changeset
   210
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   211
    ^self new form:aForm image:anImage string:aString
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   212
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   213
    "Modified (comment): / 29-09-2018 / 18:27:59 / Claus Gittinger"
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   214
!
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   215
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
icon:anIcon string:aString
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   217
    "return an instance consisting of a label-string 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   218
     and an icon (on the left)"
726
4b3a40124f6d center label, icon and image in the display routine
tz
parents: 719
diff changeset
   219
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    ^ self new icon:anIcon string:aString
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   222
    "Created: / 12-05-1996 / 20:00:58 / cg"
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   223
    "Modified (comment): / 29-09-2018 / 18:28:03 / Claus Gittinger"
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
1977
e658f77f88b2 checkin from browser
tm
parents: 1975
diff changeset
   226
label:aString icon:anIcon
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   227
    "return an instance consisting of a label-string 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   228
     and an icon (on the left)"
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   229
1977
e658f77f88b2 checkin from browser
tm
parents: 1975
diff changeset
   230
    ^ self new icon:anIcon string:aString
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   231
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   232
    "Modified (comment): / 29-09-2018 / 18:28:07 / Claus Gittinger"
1977
e658f77f88b2 checkin from browser
tm
parents: 1975
diff changeset
   233
!
e658f77f88b2 checkin from browser
tm
parents: 1975
diff changeset
   234
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
new
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    ^ self basicNew initialize
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    "Created: 12.5.1996 / 20:00:58 / cg"
986
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   239
!
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   240
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   241
string:aString
3450
b0ce6b6fa2c6 comments and examples
Claus Gittinger <cg@exept.de>
parents: 3132
diff changeset
   242
    "return an instance consisting of a string only"
986
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   243
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   244
    ^ self new icon:nil string:aString
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   245
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   246
    "Created: / 21.6.1998 / 04:57:28 / cg"
3781
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   247
!
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   248
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   249
string:aString image:image
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   250
    "return an instance consisting of a label-string 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   251
     and an image (on the right)"
3781
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   252
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   253
    ^ self new 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   254
        imagePosition:#right;
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   255
        form:nil image:image string:aString
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   256
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   257
    "Modified: / 29-09-2018 / 18:34:03 / Claus Gittinger"
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
!LabelAndIcon methodsFor:'accessing'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
986
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   262
beCheckMark
1860
b4c0e45ad336 use a smaller check-icon
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
   263
    "/ self icon:(CheckToggle checkFormOn:Screen current)
b4c0e45ad336 use a smaller check-icon
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
   264
    self icon:((CheckToggle smallCheckImageForStyle:#borderedFatcross) onDevice:Screen current)
986
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   265
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   266
    "Created: / 21.6.1998 / 05:01:01 / cg"
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   267
    "Modified: / 21.6.1998 / 05:03:23 / cg"
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   268
!
ed6b89c43416 added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
   269
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   270
form:aForm image:anImage string:aString
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   271
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   272
    icon := aForm.
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   273
    image:= anImage.
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   274
    string := aString. 
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   275
!
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   276
1975
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   277
gap
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   278
    "return the spacing between the icon and the labelString.
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   279
     The default is 4"
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   280
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   281
    ^ gap
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   282
!
bad9d0302b03 added #gap
martin
parents: 1860
diff changeset
   283
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
gap:pixels
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    "set the spacing between the icon and the labelString.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
     The default is 4."
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    gap := pixels.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "Created: 12.5.1996 / 20:00:52 / cg"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
286
89cced571c0f add accessing method to get the icon
ca
parents: 258
diff changeset
   293
icon
89cced571c0f add accessing method to get the icon
ca
parents: 258
diff changeset
   294
    "return my icon part"
89cced571c0f add accessing method to get the icon
ca
parents: 258
diff changeset
   295
6033
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   296
    ^ icon value
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   297
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   298
    "Modified: / 09-03-2019 / 15:43:20 / Claus Gittinger"
286
89cced571c0f add accessing method to get the icon
ca
parents: 258
diff changeset
   299
!
89cced571c0f add accessing method to get the icon
ca
parents: 258
diff changeset
   300
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
icon:anIcon
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "set the icon image"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    icon := anIcon.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    "Created: 12.5.1996 / 20:00:52 / cg"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
icon:anIcon string:aString
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "set both iconImage and the labelString"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    icon := anIcon.
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    string := aString
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "Created: 12.5.1996 / 20:00:52 / cg"
175
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   316
!
44a363de85f5 examples
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   317
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   318
image
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   319
    "return my image"
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   320
6033
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   321
    ^ image value
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   322
83fa7b6785ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5912
diff changeset
   323
    "Modified: / 09-03-2019 / 15:43:14 / Claus Gittinger"
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   324
!
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   325
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   326
image:anImage
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   327
    "set the image"
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   328
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   329
    image := anImage
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   330
!
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   331
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   332
imagePosition:aSymbol
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   333
    "controls if the image is to be shown at #left or #right.
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   334
     Default is #left."
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   335
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   336
    imagePosition := aSymbol.
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   337
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   338
    "Created: / 29-09-2018 / 18:33:39 / Claus Gittinger"
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   339
!
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   340
3132
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   341
offset
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   342
    "set the left offset (i.e. spacing to the left of the icon).
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   343
     The default is 0."
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   344
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   345
    ^ offset
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   346
!
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   347
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   348
offset:pixels
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   349
    "set the left offset (i.e. spacing to the left of the icon).
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   350
     The default is 0."
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   351
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   352
    offset := pixels.
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   353
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   354
    "Created: / 21.6.1998 / 03:11:03 / cg"
3132
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   355
!
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   356
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   357
xOfString
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   358
    "returns the x position of the string"
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   359
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   360
    |x img|
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   361
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   362
    x := offset.
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   363
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   364
    (img := icon value) notNil ifTrue:[
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   365
        x := x + img width + gap
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   366
    ].
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   367
    (img := image value) notNil ifTrue:[
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   368
        x := x + img width + gap
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   369
    ].
9ee61ede263a *** empty log message ***
ca
parents: 2773
diff changeset
   370
    ^ x
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
1814
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   373
!LabelAndIcon methodsFor:'comparing'!
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   374
2657
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   375
= aStringOrLabelAndIcon
2674
e877ecb7d8b7 Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents: 2657
diff changeset
   376
e877ecb7d8b7 Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents: 2657
diff changeset
   377
    aStringOrLabelAndIcon isNil ifTrue:[^ false].
e877ecb7d8b7 Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents: 2657
diff changeset
   378
2657
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   379
    self hasIcon == aStringOrLabelAndIcon hasIcon ifFalse:[^ false].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   380
    aStringOrLabelAndIcon hasIcon ifTrue:[
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   381
        icon = aStringOrLabelAndIcon icon ifFalse:[^ false].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   382
    ].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   383
    self hasImage == aStringOrLabelAndIcon hasImage ifFalse:[^ false].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   384
    aStringOrLabelAndIcon hasImage ifTrue:[
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   385
        image = aStringOrLabelAndIcon image ifFalse:[^ false].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   386
    ].
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   387
    ^ super = aStringOrLabelAndIcon
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   388
!
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   389
1814
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   390
sameStringAndEmphasisAs:someStringOrLabelAndIcon
1817
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   391
    someStringOrLabelAndIcon class == self class ifTrue:[
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   392
        icon = someStringOrLabelAndIcon icon ifFalse:[^ false].
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   393
        image = someStringOrLabelAndIcon image ifFalse:[^ false].
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   394
        (string sameStringAndEmphasisAs:someStringOrLabelAndIcon string) ifFalse:[ ^ false].
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   395
        ^ true.        
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   396
    ].
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   397
1814
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   398
    (string sameStringAndEmphasisAs:someStringOrLabelAndIcon) ifFalse:[ ^ false].
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   399
    (icon isNil and:[image isNil]) ifTrue:[^ true].
1817
e639d2a9d605 tuned compare
Claus Gittinger <cg@exept.de>
parents: 1814
diff changeset
   400
    ^ false
1814
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   401
! !
a7697ca7f34f added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   402
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
!LabelAndIcon methodsFor:'displaying'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
displayOn:aGC x:x y:y opaque:opaque
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    "display the receiver on a GC"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   408
    |y1 x1 iconValue imageValue stringHeight maxHeight
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   409
     showImageAction|
180
c63c079dea01 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   410
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   411
    iconValue := icon value.
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   412
    imageValue := image value.
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   413
5020
6dd1826b889c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4878
diff changeset
   414
    "/ gapY := (device pixelPerMillimeter x) rounded.
3782
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   415
    "/ maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight.
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   416
    maxHeight := self heightOn:aGC.
729c0808727b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   417
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   418
    x1 := x + offset.
258
e46fadff344c added access to string
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   419
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   420
    iconValue notNil ifTrue:[
5020
6dd1826b889c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4878
diff changeset
   421
        y1 := y - aGC font ascent + ((maxHeight - iconValue height + 1) // 2).
5525
f6b38666c652 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5209
diff changeset
   422
        ((iconValue height ~~ 0) and:[iconValue width ~~ 0]) ifTrue:[
5526
1f7cf0ff5d7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
   423
            iconValue isImage ifTrue:[ icon := iconValue onDevice:aGC device ].
5525
f6b38666c652 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5209
diff changeset
   424
            (opaque and:[iconValue mask isNil]) ifTrue:[aGC displayOpaqueForm:iconValue x:x1 y:y1]
f6b38666c652 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5209
diff changeset
   425
                                                ifFalse:[aGC displayForm:iconValue x:x1 y:y1].
f6b38666c652 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5209
diff changeset
   426
            x1 := x1 + iconValue width + gap.
f6b38666c652 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5209
diff changeset
   427
        ].
258
e46fadff344c added access to string
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   428
    ].
e46fadff344c added access to string
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   429
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   430
    showImageAction := 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   431
        [
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   432
            imageValue notNil ifTrue:[
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   433
                y1 := y - aGC font ascent + ((maxHeight - imageValue height + 1) // 2).
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   434
                ((imageValue height ~~ 0) and:[imageValue width ~~ 0]) ifTrue:[
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   435
                    imageValue isImage ifTrue:[ image := imageValue onDevice:aGC device ].
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   436
                    (opaque and:[imageValue mask isNil]) ifTrue:[aGC displayOpaqueForm:imageValue x:x1 y:y1]
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   437
                                                        ifFalse:[aGC displayForm:imageValue x:x1 y:y1].
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   438
                    x1 := x1 + imageValue width + gap.
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   439
                ].
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   440
            ].
5526
1f7cf0ff5d7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
   441
        ].
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   442
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   443
    imagePosition == #left ifTrue:[
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   444
        showImageAction value.
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   445
    ].
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   446
    
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   447
    stringHeight := string size ~~ 0 
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   448
                        ifTrue:[string heightOn:aGC]    
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   449
                        ifFalse:[0].
726
4b3a40124f6d center label, icon and image in the display routine
tz
parents: 719
diff changeset
   450
    stringHeight ~~ 0 ifTrue:[
5020
6dd1826b889c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4878
diff changeset
   451
        y1 := y + ((maxHeight - stringHeight + 1) // 2).
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   452
        string displayOn:aGC x:x1 y:y1 opaque:opaque
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   453
    ].
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   454
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   455
    imagePosition == #right ifTrue:[
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   456
        stringHeight ~~ 0 ifTrue:[ x1 := x1 + (string widthOn:aGC) ].
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   457
        x1 := x1 + gap.
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   458
        showImageAction value.
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   459
    ].
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   460
5526
1f7cf0ff5d7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
   461
    "Modified: / 06-04-2017 / 13:12:31 / cg"
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   462
    "Modified: / 29-09-2018 / 18:34:48 / Claus Gittinger"
810
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   463
!
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   464
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   465
on:aDevice
4878
5928056755ab #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 4678
diff changeset
   466
    <resource: #obsolete>
5202
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   467
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   468
    self obsoleteFeatureWarning:'use onDevice:'.
1604
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   469
    ^ self onDevice:aDevice
810
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   470
!
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   471
847d7f52a2fd new methods:
ca
parents: 726
diff changeset
   472
onDevice:aDevice
5202
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   473
    "return with both icon and image onDevice:aDevice"
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   474
1604
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   475
    |form img|
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   476
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   477
    aDevice isNil ifTrue:[^ self].
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   478
    icon  notNil ifTrue:[form := icon  onDevice:aDevice].
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   479
    image notNil ifTrue:[img  := image onDevice:aDevice].
5202
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   480
    (icon == form and:[image == img]) ifTrue:[
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   481
        "nothing changed"
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   482
        ^ self.
e5be9c22174c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5020
diff changeset
   483
    ].
1604
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   484
2c15dd8fb3cf ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1479
diff changeset
   485
    ^ LabelAndIcon form:form image:img string:string
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
!LabelAndIcon methodsFor:'initialization'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
initialize
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   491
    gap := 4.
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   492
    offset := 0.
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   493
    imagePosition := #left.
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   494
5912
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   495
    "Modified: / 21-06-1998 / 03:10:19 / cg"
f09029085bb4 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   496
    "Modified: / 29-09-2018 / 18:33:47 / Claus Gittinger"
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
!LabelAndIcon methodsFor:'queries'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
2657
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   501
hasIcon
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   502
    ^ icon notNil
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   503
!
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   504
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   505
hasImage
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   506
    ^ image notNil
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   507
!
20d7ed550989 also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents: 2454
diff changeset
   508
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
heightOn:aGC
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
    "return the height of the receiver, if it is to be displayed on aGC"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   512
    |iconHeight imageHeight stringHeight oneMillimeter|
682
861e446e3b24 checkin from browser
ca
parents: 629
diff changeset
   513
5209
173846bc5b93 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5202
diff changeset
   514
    oneMillimeter := aGC device isNil ifTrue:[2] ifFalse:[aGC horizontalIntegerPixelPerMillimeter].
306
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   515
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   516
    icon notNil ifTrue:[
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   517
        iconHeight := icon value height + oneMillimeter
306
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   518
    ] ifFalse:[
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   519
        iconHeight := 0
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   520
    ].
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   521
    image notNil ifTrue:[
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   522
        imageHeight := image value height + oneMillimeter
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   523
    ] ifFalse:[
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   524
        imageHeight := 0   
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   525
    ].
5209
173846bc5b93 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5202
diff changeset
   526
    string size ~~ 0 ifTrue:[
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   527
        stringHeight := string heightOn:aGC
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   528
    ] ifFalse:[
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   529
        stringHeight := 0   
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   530
    ].
5209
173846bc5b93 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5202
diff changeset
   531
    ^ (iconHeight max: imageHeight) max: stringHeight
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
widthOn:aGC
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    "return the width of the receiver, if it is to be displayed on aGC"
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   537
    |width|
306
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   538
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   539
    width := offset.
306
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   540
    icon notNil ifTrue:[
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   541
        width := width + icon value width
306
f3954479c7e8 handle nil icons
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   542
    ].
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   543
    image notNil ifTrue:[
2773
ba1b2f93afee care for icon-blocks
Claus Gittinger <cg@exept.de>
parents: 2674
diff changeset
   544
        width := width + gap + image value width
629
4a2d83659f66 now with image support (-> menu builder)
tz
parents: 588
diff changeset
   545
    ].
5209
173846bc5b93 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5202
diff changeset
   546
    string size ~~ 0 ifTrue:[
719
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   547
        width := width + gap + (string widthOn:aGC)
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   548
    ].  
3a833ca1c54a better #widthOn: method
tz
parents: 682
diff changeset
   549
    ^width
981
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   550
b7558ca52e20 added an optional left-offset
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   551
    "Modified: / 21.6.1998 / 03:11:14 / cg"
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
! !
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
4678
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   554
!LabelAndIcon methodsFor:'testing'!
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   555
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   556
isLabelAndIcon
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   557
    ^ true
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   558
! !
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   559
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   560
!LabelAndIcon methodsFor:'text compatibility'!
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   561
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   562
withoutAnyColorEmphasis
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   563
    ^ self shallowCopy string:(string withoutAnyColorEmphasis)
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   564
!
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   565
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   566
withoutBackgroundColorEmphasis
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   567
    ^ self shallowCopy string:(string withoutBackgroundColorEmphasis)
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   568
!
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   569
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   570
withoutForegroundColorEmphasis
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   571
    ^ self shallowCopy string:(string withoutForegroundColorEmphasis)
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   572
! !
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   573
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
!LabelAndIcon class methodsFor:'documentation'!
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
version
4878
5928056755ab #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 4678
diff changeset
   577
    ^ '$Header$'
3781
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   578
!
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   579
715591d6adff added: #string:image:
Claus Gittinger <cg@exept.de>
parents: 3453
diff changeset
   580
version_CVS
4878
5928056755ab #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 4678
diff changeset
   581
    ^ '$Header$'
172
c30e1ff9f9dd intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
! !
4678
450244b6639f class: LabelAndIcon
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
   583