MenuPanel.st
author ca
Mon, 21 Jul 1997 09:01:49 +0200
changeset 466 f025831cdae8
parent 465 67a0f3dd503a
child 467 e27d6c2533ef
permissions -rw-r--r--
pick a imaged label; create a ResourceRetriever
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     1
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     4
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    11
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    12
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    13
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
    14
SimpleView subclass:#MenuPanel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
    15
	instanceVariableNames:'style adornment shadowView mapTime mustRearrange superMenu
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
    16
		shortKeyInset selection items groupSizes receiver enableChannel'
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
    17
	classVariableNames:'InitialSelectionQuerySignal DefaultStyle DefaultAdornment
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
    18
		GroupDividerSize'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    19
	poolDictionaries:''
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    20
	category:'Views-Menus'
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    21
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    22
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    23
Object subclass:#Item
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
    24
	instanceVariableNames:'layout menuPanel subMenu adornment rawLabel enableChannel nameKey
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
    25
		accessCharacterPosition value label activeHelpKey submenuChannel'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    26
	classVariableNames:'HorizontalInset VerticalInset LabelRightOffset ShortcutKeyOffset
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
    27
		IndicatorOn IndicatorOff'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    28
	poolDictionaries:''
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    29
	privateIn:MenuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    30
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    31
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    32
Object subclass:#Adornment
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
    33
	instanceVariableNames:'indication accessCharacterPosition shortcutKey argument'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    34
	classVariableNames:''
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    35
	poolDictionaries:''
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    36
	privateIn:MenuPanel::Item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    37
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    38
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    39
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    40
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    41
copyright
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    42
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    43
 COPYRIGHT (c) 1997 by eXept Software AG
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    44
              All Rights Reserved
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    45
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    46
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    47
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    48
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    49
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    50
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    51
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    52
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    53
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    54
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    55
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    56
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    57
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    61
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    62
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    63
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    64
    [author:]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    65
        Claus Atzkern
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    66
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
    [see also:]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
        Menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
        MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    70
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    71
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    72
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    73
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
    start as PullDownMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
                                                                                [exBegin]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    79
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    80
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    81
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    82
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
    83
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    84
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    85
    labels := #( '\b foo' 'bar' 'baz' 'test' 'claus' ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    86
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    87
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    89
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'\b test' with:'ludwig \t'.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    92
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    93
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    94
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    95
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    96
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
    97
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    98
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   100
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   101
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   102
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   103
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   105
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   107
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   108
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   111
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   114
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   116
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    top extent:(400 @ (mview height)).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    top open.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
                                                                                [exEnd]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   122
    start as PopUpMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
                                                                                [exBegin]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   126
    mview := MenuPanel new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   127
    labels := #( '\b foo' 'bar' 'baz' ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   130
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'\b test'.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   134
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   135
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   138
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   140
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   141
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   144
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   146
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   148
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   149
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
    mview startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   151
                                                                                [exEnd]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   152
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   153
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
    start from menu spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   155
                                                                                [exBegin]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   156
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   157
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   158
    menu := MenuPanel menu:
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   159
        #(#Menu #( #(#MenuItem 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   160
                    #label: 'File' 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   161
                    #submenu:
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   162
                      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   163
                                 (#MenuItem 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   164
                                    #label: 'edit' 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   165
                                    #submenu:
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   166
                                      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   167
                                                 #(#MenuItem #label: 'close' #value:#close)     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   168
                                               )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   169
                                               nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   170
                                               nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   171
                                       )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   172
                                  )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   173
                                 #(#MenuItem #label: 'help' #value:#help )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   174
                               )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   175
                               nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   176
                               nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   177
                       )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   178
                 ) 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   179
                #(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   180
                #(#MenuItem #label: 'Bar' 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   181
                            #submenu:
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   182
                               #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   183
                                          #(#MenuItem #label: 'bar 2' #value:#bar2 )     
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   184
                                        )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   185
                                        nil
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   186
                                        nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   187
                                )     
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   188
                 ) 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   189
              ) 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   190
              #( 2 )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   191
              nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   192
         ) decodeAsLiteralArray.  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   193
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   194
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   195
    Transcript showCR:(menu startUp).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   196
                                                                                [exEnd]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   197
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   198
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   199
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   200
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   201
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   202
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   203
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   204
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   205
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   206
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   207
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   208
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   209
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   210
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   211
    aSpec notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   212
        menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   213
        menu fromLiteralArrayEncoding:aSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   214
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   215
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   216
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   217
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   220
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   221
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   222
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   223
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   224
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   225
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   226
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   227
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   229
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   230
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   231
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   232
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   233
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   234
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   235
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   236
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   237
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   238
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   239
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   240
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   241
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   243
    mview := self new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   244
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   245
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   246
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   247
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
    aReceiver notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
        mview receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   251
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   252
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   253
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   254
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   258
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
    InitialSelectionQuerySignal isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
        InitialSelectionQuerySignal := QuerySignal new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   261
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   262
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   263
    self updateStyleCache.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
    DefaultAdornment isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
        DefaultAdornment := IdentityDictionary new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
        DefaultAdornment at:#showSeparatingLines     put:false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   269
        DefaultAdornment at:#showGroupDivider        put:true.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   270
        DefaultAdornment at:#verticalLayout          put:true.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   271
        DefaultAdornment at:#item                    put:nil.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   272
        DefaultAdornment at:#value                   put:nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   273
        DefaultAdornment at:#menuHolder              put:nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   274
        DefaultAdornment at:#enableChannel           put:nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   278
DefaultStyle := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   279
DefaultAdornment := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
self initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
"
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   282
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   283
    "Modified: 4.7.1997 / 20:19:10 / cg"
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   284
!
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   285
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   286
updateStyleCache
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   287
    DefaultStyle := IdentityDictionary new.
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   288
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   289
    DefaultStyle at:#foregroundColor         put:(Color black).
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   290
    DefaultStyle at:#backgroundColor         put:(DefaultViewBackgroundColor ? (Color gray:50)).
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   291
    DefaultStyle at:#activeBackgroundColor   put:(Color white).
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   292
    DefaultStyle at:#disabledForegroundColor put:(Color gray:25).
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   293
    DefaultStyle at:#groupDividerSize        put:3.
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   294
    DefaultStyle at:#fitFirstPanel           put:true.
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   295
    DefaultStyle at:#horizontalSpace         put:0.
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   296
    DefaultStyle at:#borderWidth             put:1.
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   297
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   298
    "Created: 4.7.1997 / 20:18:45 / cg"
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   299
    "Modified: 4.7.1997 / 20:19:35 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   300
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   301
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   302
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   303
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   304
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   305
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   306
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   307
  ^ (MenuPanel new) menu:aSubMenu.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   308
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   309
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   310
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   311
!MenuPanel class methodsFor:'tests'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   312
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   313
st80test
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   314
"
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   315
MenuPanel st80test
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   316
"
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   317
     |menu|
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   318
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   319
     menu := #(#Menu #( #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   320
                #rawLabel: '&File' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   321
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   322
                    #(#MenuItem 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   323
                            #rawLabel: '&Save As...'
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   324
                            #indication: true
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   325
                            #value: #imageSaveAs ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   326
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   327
                            #rawLabel: '&Perm Save As...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   328
                            #value: #filePermSaveAs ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   329
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   330
                            #rawLabel: 'Perm &Undo As...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   331
                            #value: #filePermUndoAs ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   332
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   333
                            #rawLabel: '&Collect Garbage' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   334
                            #value: #collectGarbage ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   335
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   336
                            #rawLabel: 'Collect All &Garbage' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   337
                            #value: #collectAllGarbage ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   338
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   339
                            #rawLabel: 'Se&ttings' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   340
                            #value: #visualWorksSettings ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   341
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   342
                            #rawLabel: 'E&xit VisualWorks...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   343
                            #value: #visualWorksExit ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   344
                ) #(3 2 1 1 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   345
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   346
                #rawLabel: '&Browse' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   347
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   348
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   349
                            #rawLabel: '&All Classes' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   350
                            #value: #browseAllClasses 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   351
                            #labelImage: #(#ResourceRetriever nil #allClassesIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   352
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   353
                            #rawLabel: 'Class &Named...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   354
                            #value: #browseClassNamed ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   355
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   356
                            #rawLabel: '&Resources' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   357
                            #value: #browseApplications 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   358
                            #labelImage: #(#ResourceRetriever nil #finderIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   359
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   360
                            #rawLabel: 'References &To...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   361
                            #value: #browseSendersOf ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   362
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   363
                            #rawLabel: '&Implementors Of...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   364
                            #value: #browseImplementorsOf )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   365
                ) #(3 2 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   366
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   367
                #rawLabel: '&Tools' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   368
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   369
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   370
                            #rawLabel: '&File List' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   371
                            #value: #openFileList 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   372
                            #labelImage: #(#ResourceRetriever nil #fileListIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   373
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   374
                            #rawLabel: 'File &Editor...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   375
                            #value: #openFileEditor ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   376
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   377
                            #rawLabel: '&Workspace' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   378
                            #value: #toolsNewWorkspace 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   379
                            #labelImage: #(#ResourceRetriever nil #workspaceIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   380
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   381
                            #rawLabel: 'Parcel &List' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   382
                            #value: #openParcelList ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   383
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   384
                            #rawLabel: '&New Canvas' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   385
                            #value: #toolsNewCanvas 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   386
                            #labelImage: #(#ResourceRetriever nil #newCanvasIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   387
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   388
                            #rawLabel: '&Palette' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   389
                            #value: #toolsPalette ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   390
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   391
                            #rawLabel: '&Canvas Tool' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   392
                            #value: #toolsCanvasTool ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   393
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   394
                            #rawLabel: '&Image Editor' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   395
                            #value: #toolsMaskEditor ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   396
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   397
                            #rawLabel: '&Menu Editor' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   398
                            #value: #toolsMenuEditor ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   399
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   400
                            #rawLabel: '&Advanced' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   401
                            #nameKey: #advanced ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   402
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   403
                            #rawLabel: '&DLL and C Connect' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   404
                            #nameKey: #dllcc 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   405
                            #value: #openExternalFinder 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   406
                            #labelImage: #(#ResourceRetriever nil #extFinderIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   407
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   408
                            #rawLabel: 'System &Transcript' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   409
                            #nameKey: #transcript 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   410
                            #value: #toggleSystemTranscript 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   411
                            #indication: true )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   412
                ) #(4 5 2 1 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   413
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   414
                #rawLabel: '&Changes' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   415
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   416
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   417
                            #rawLabel: 'Open Change &List' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   418
                            #value: #changesOpenChangeList ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   419
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   420
                            #rawLabel: '&File Out Changes...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   421
                            #value: #changesFileOutChanges ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   422
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   423
                            #rawLabel: '&Empty Changes...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   424
                            #value: #changesEmptyChanges ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   425
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   426
                            #rawLabel: 'Changed &Methods' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   427
                            #value: #changesChangedMethods ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   428
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   429
                            #rawLabel: 'Inspect &ChangeSet' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   430
                            #value: #changesInspectChangeSet ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   431
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   432
                            #rawLabel: 'Open &Project' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   433
                            #value: #changesOpenProject ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   434
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   435
                            #rawLabel: 'E&xit Project' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   436
                            #value: #changesExitProject )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   437
                ) #(1 4 2 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   438
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   439
                #rawLabel: '&Database' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   440
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   441
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   442
                            #rawLabel: 'Ad Hoc &SQL' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   443
                            #nameKey: #adHoc 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   444
                            #value: #openAdHocQuery ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   445
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   446
                            #rawLabel: 'Data &Modeler' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   447
                            #nameKey: #dataModeler 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   448
                            #value: #openDataModelBrowser 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   449
                            #labelImage: #(#ResourceRetriever nil #dbToolIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   450
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   451
                            #rawLabel: 'Canvas &Composer' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   452
                            #nameKey: #canvasComposer 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   453
                            #value: #openCanvasComposer ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   454
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   455
                            #rawLabel: 'New Data &Form...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   456
                            #nameKey: #dataForm 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   457
                            #value: #newDataForm ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   458
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   459
                            #rawLabel: 'New Database &Application...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   460
                            #nameKey: #dataBaseAp 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   461
                                #value: #newDataMain )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   462
                ) #(1 4 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   463
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   464
                #rawLabel: '&Window' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   465
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   466
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   467
                            #rawLabel: 'Re&fresh All' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   468
                            #value: #winRefreshAll ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   469
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   470
                            #rawLabel: '&Collapse All' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   471
                            #value: #winCollapseAll ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   472
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   473
                            #rawLabel: 'Re&store All' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   474
                            #value: #winRestoreAll ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   475
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   476
                            #rawLabel: '&Windows' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   477
                            #nameKey: #windowsMenu )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   478
                ) #(3 1 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   479
            #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   480
                #rawLabel: '&Help' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   481
                #submenu: #(#Menu #(
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   482
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   483
                            #rawLabel: 'Open Online &Documentation' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   484
                            #value: #openHelpBrowser 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   485
                            #labelImage: #(#ResourceRetriever nil #helpIcon ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   486
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   487
                            #rawLabel: '&Quick Start Guides...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   488
                            #value: #openGuidingDialog ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   489
                    #(#MenuItem 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   490
                            #rawLabel: 'About &VisualWorks...' 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   491
                            #value: #helpAbout )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   492
                ) #(2 1 ) nil ) ) 
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   493
      ) #(7 ) nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   494
    )
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   495
    decodeAsLiteralArray.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   496
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   497
    Transcript showCR:(menu startUp).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   498
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   499
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   500
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   501
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   502
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   503
test
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   504
"
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   505
self test
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   506
"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   507
    |top subView mview desc s1 s2 s3 img lbs labels|
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   508
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   509
    top := StandardSystemView new.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   510
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   511
    mview := self in:top.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   512
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   513
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   514
    mview level:2.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   515
    mview verticalLayout:false.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   516
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   517
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   518
    mview labels:lbs.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   519
    mview shortcutKeyAt:2 put:#Cut.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   520
    mview accessCharacterPositionAt:1 put:1.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   521
    mview accessCharacterPositionAt:2 put:2.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   522
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   523
    mview enabledAt:5 put:false.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   524
    mview groupSizes:#( 2 2 ).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   525
    s1 := self labels:labels.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   526
    s1 accessCharacterPositionAt:1 put:1.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   527
    s1 accessCharacterPositionAt:2 put:2.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   528
    s1 groupSizes:#( 2 2 ).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   529
    s2 := self labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   530
    s3 := self labels:lbs.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   531
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   532
    s1 subMenuAt:2 put:s2.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   533
    s1 subMenuAt:3 put:(self labels:lbs).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   534
    s2 subMenuAt:3 put:s3.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   535
    s3 subMenuAt:3 put:(self labels:labels).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   536
    s3 shortcutKeyAt:3 put:$q.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   537
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   538
    mview subMenuAt:1 put:s1.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   539
    mview subMenuAt:4 put:(self labels:lbs).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   540
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   541
    s1 shortcutKeyAt:1 put:#Copy.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   542
    s1 shortcutKeyAt:3 put:#Paste.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   543
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   544
    mview subMenuAt:2 put:(self labels:labels).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   545
    top extent:(400 @ (mview height)).
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   546
    top open.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   547
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   548
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   549
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   550
!MenuPanel methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   551
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   552
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   553
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   554
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   555
    self accept:(self selection)
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   556
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   557
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   558
accept:anItem
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   559
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   560
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   561
    |value item topMenu|
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   562
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   563
    self superMenu notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   564
        ^ self topMenu accept:anItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   565
    ].
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   566
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   567
    self selection:nil.
420
ca
parents: 417
diff changeset
   568
    self forceUngrabMouseAndKeyboard.
ca
parents: 417
diff changeset
   569
ca
parents: 417
diff changeset
   570
    (anItem notNil and:[anItem canAccept]) ifTrue:[
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   571
        value := anItem accept.
420
ca
parents: 417
diff changeset
   572
        item  := anItem.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   573
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   574
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   575
    self isPopUpView ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   576
        self destroy
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   577
    ] ifFalse:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   578
        self do:[:el| el updateIndicators].
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   579
        self windowGroup processExposeEvents.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   580
    ].
420
ca
parents: 417
diff changeset
   581
ca
parents: 417
diff changeset
   582
    value isBlock ifTrue:[
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   583
        value := value value.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   584
        self menuAdornmentAt:#hasPerformed put:true.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   585
    ] ifFalse:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   586
        self menuAdornmentAt:#hasPerformed put:false
420
ca
parents: 417
diff changeset
   587
    ].
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   588
420
ca
parents: 417
diff changeset
   589
    self menuAdornmentAt:#value put:value.
ca
parents: 417
diff changeset
   590
    self menuAdornmentAt:#item  put:item.
ca
parents: 417
diff changeset
   591
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   592
  ^ item.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   593
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   594
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   595
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   596
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   597
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   598
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   599
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   600
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   601
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   602
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   603
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   604
    "
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   605
    |top|
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   606
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   607
    top := self topMenu.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   608
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   609
    (top menuAdornmentAt:#hasPerformed) ~~ true ifTrue:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   610
        ^ self topMenu menuAdornmentAt:#value.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   611
    ].
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   612
  ^ nil
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   613
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   614
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   615
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   616
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   617
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   618
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   619
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   620
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   621
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   622
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   623
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   624
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   625
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   626
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   627
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   628
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   629
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   630
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   631
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   632
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   633
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   634
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   635
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   636
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   637
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   638
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   639
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   640
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   641
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   642
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   643
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   644
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   645
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   646
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   647
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   648
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   649
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   650
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   651
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   652
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   653
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   654
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   655
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   656
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   657
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   658
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   659
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   660
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   661
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   662
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   663
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   664
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   665
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   666
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   667
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   668
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   669
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   670
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   671
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   672
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   673
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   674
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   675
    aGroupSizes = groupSizes ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   676
        groupSizes := aGroupSizes copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   677
        self mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   678
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   679
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   681
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   682
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   683
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   684
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   685
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   686
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   687
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   688
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   689
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   690
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   691
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   692
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   693
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   694
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   695
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   696
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   697
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   698
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   699
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   700
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   701
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   702
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   703
    self disabledRedrawDo:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   704
        self removeAll.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   705
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   706
        labels notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   707
            labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   708
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   709
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   710
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   711
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   712
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   713
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   714
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   715
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   716
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   717
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   718
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   719
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   720
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   721
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   722
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   723
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   724
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   725
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   726
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   727
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   728
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   729
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   730
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   731
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   732
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   733
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   734
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   735
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   736
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   737
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   738
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   739
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   740
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   741
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   742
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   743
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   744
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   745
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   746
    (receiver isNil and:[superMenu notNil]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   747
        ^ superMenu receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   748
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   749
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   750
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   751
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   752
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   753
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   754
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   755
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   756
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   757
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   758
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   759
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   760
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   761
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   762
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   763
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   764
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   765
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   766
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   767
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   768
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   769
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   770
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   771
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   772
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   773
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   774
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   775
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   776
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   777
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   778
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   779
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   780
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   781
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   782
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   783
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   784
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   785
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   786
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   787
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   788
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   789
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   790
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   791
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   792
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   793
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   794
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   795
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   796
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   797
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   798
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   799
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   800
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   801
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   802
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   803
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   804
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   805
!MenuPanel methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   806
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   807
disable
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   808
    "disable the menu and all its entries
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   809
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   810
    self enabled:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   811
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   812
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   813
disableAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   814
    "disable all items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   815
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   816
    self do:[:anItem| anItem enabled:false ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   817
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   818
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   819
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   820
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   821
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   822
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   823
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   824
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   825
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   826
enable
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   827
    "enable the menu and all its entries
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   828
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   829
    self enabled:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   830
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   831
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   832
enableAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   833
    "enable all items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   834
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   835
    self do:[:anItem| anItem enabled:true ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   836
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   837
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   838
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   839
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   840
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   841
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   842
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   843
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   844
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   845
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   846
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   847
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   848
    superMenu isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   849
        ^ (self findFirst:[:anItem|anItem enabled]) ~~ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   850
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   851
  ^ superMenu enabledAt:(superMenu findFirst:[:anItem|anItem submenu == self])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   852
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   853
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   854
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   855
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   856
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   857
    |idx state|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   858
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   859
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   860
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   861
    superMenu isNil ifTrue:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   862
        self do:[:anItem| anItem enabled:state ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   863
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   864
        idx := superMenu findFirst:[:anItem| anItem submenu == self ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   865
        superMenu enabledAt:idx put:state.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   866
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   867
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   868
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   869
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   870
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   871
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   872
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   873
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   874
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   875
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   876
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   877
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   878
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   879
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   880
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   881
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   882
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   883
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   884
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   885
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   886
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   887
!MenuPanel methodsFor:'accessing channels'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   888
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   889
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   890
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   891
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   892
    adornment isNil ifTrue:[^ nil].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   893
  ^ adornment at:#enableChannel ifAbsent:nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   894
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   895
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   896
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   897
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   898
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   899
    |enableChannel|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   900
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   901
    (enableChannel := self enableChannel) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   902
        enableChannel removeDependent:self
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   903
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   904
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   905
    aValueHolder notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   906
        adornment isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   907
            adornment := DefaultAdornment copy
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   908
        ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   909
        adornment at:#enableChannel put:aValueHolder.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   910
        aValueHolder addDependent:self.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   911
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   912
    self enabled:(aValueHolder value)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   913
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   914
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   915
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   916
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   917
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   918
    adornment isNil ifTrue:[^ nil].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   919
  ^ adornment at:#menuHolder ifAbsent:nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   920
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   921
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   922
menuHolder:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   923
    "set a menu holder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   924
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   925
    |menuHolder|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   926
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   927
    (menuHolder := self menuHolder) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   928
        menuHolder removeDependent:self
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   929
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   930
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   931
    aValueHolder notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   932
        adornment isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   933
            adornment := DefaultAdornment copy
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   934
        ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   935
        adornment at:#menuHolder put:aValueHolder.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   936
        aValueHolder addDependent:self.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   937
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   938
    self menu:(aValueHolder value)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   939
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   940
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   941
!MenuPanel methodsFor:'accessing color & font'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   942
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   943
activeBackgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   944
    "return the background color used to highlight selections
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   945
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   946
  ^ self styleAt:#activeBackgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   947
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   948
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   949
activeBackgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   950
    "set the background drawing color used to highlight selection. You should not 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   951
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   952
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   953
    self styleAt:#activeBackgroundColor put:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   954
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   955
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   956
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   957
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   958
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   959
    ^ self styleAt:#backgroundColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   960
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   961
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   962
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   963
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   964
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   965
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   966
    self styleAt:#backgroundColor put:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   967
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   968
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   969
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   970
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   971
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   972
  ^ self styleAt:#disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   973
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   974
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   975
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   976
disabledForegroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   977
    "set the foregroundColor drawing color used by disabled items. You should not
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   978
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   979
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   980
    self styleAt:#disabledForegroundColor put:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   981
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   982
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   983
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   984
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   985
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   986
    superMenu notNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   987
        self topMenu font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   988
    ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   989
        (aFont notNil and:[aFont ~~ font]) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   990
            super font:(aFont on:device).
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   991
            self mustRearrange.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   992
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   993
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   994
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   995
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   996
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   997
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   998
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   999
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1000
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1001
  ^ self styleAt:#foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1002
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1003
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1004
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1005
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1006
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1007
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1008
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1009
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1010
    self styleAt:#foregroundColor put:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1011
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1012
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1013
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1014
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1015
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1016
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1017
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1018
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1019
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1020
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1021
lightColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1022
    "set the light drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1023
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1024
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1025
    lightColor ~~ aColor ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1026
        super lightColor:aColor.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1027
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1028
        shown ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1029
            self invalidate 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1030
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1031
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1032
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1033
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1034
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1035
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1036
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1037
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1038
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1039
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1040
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1041
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1042
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1043
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1044
shadowColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1045
    "set the shadow drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1046
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1047
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1048
    shadowColor ~~ aColor ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1049
        super shadowColor:aColor.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1050
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1051
        shown ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1052
            self invalidate 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1053
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1054
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1055
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1056
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1057
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1058
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1059
!MenuPanel methodsFor:'accessing dimensions'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1061
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1062
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1063
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1064
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1065
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1066
    (explicitExtent ~~ true) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1067
        (item := self itemAt:1) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1068
            self rearrangeItems.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1069
          ^ item height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1070
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1071
        ^ 4 + (font height + (font descent * 2)).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1072
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1073
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1074
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1075
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1076
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1077
    "compute and returns my preferred extent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1078
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1079
    |x y hasMenu shCtKey|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1080
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1081
    self numberOfItems == 0 ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1082
        ^ 32 @ 32
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1083
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1084
    self isFitPanel ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1085
        x := 0
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1086
    ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1087
        x := groupSizes size * self groupDividerSize.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1088
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1089
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1090
    self verticalLayout ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1091
        y := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1092
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1093
        self do:[:el||z|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1094
            x := x + el preferredExtentX.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1095
            y < (z := el preferredExtentY) ifTrue:[y := z]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1096
        ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1097
        x := x + ((items size - 1) * self horizontalSpace).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1098
    ] ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1099
        hasMenu := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1100
        shCtKey := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1101
        y := x.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1102
        x := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1103
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1104
        self do:[:el| |l e|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1105
            (l := el rawLabel) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1106
                (e := l widthOn:self) > x ifTrue:[x := e].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1107
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1108
                el hasSubmenu ifTrue:[hasMenu := true].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1110
                (     (l := el shortcutKeyAsString) notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1111
                 and:[(e := l widthOn:self) > shCtKey]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1112
                ) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1113
                    shCtKey := e
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1114
                ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1115
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1116
            y := y + el preferredExtentY
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1117
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1118
        x := x + Item horizontalInset.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1120
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1121
            x := x + Item labelRightOffset + shCtKey + ((items at:1) rightArrow width).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1122
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1123
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1124
                x := x + (Item shortcutKeyOffset) 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1125
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1126
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1127
        x := x + Item horizontalInset.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1128
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1129
  ^ x @ y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1130
        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1132
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1133
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1134
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1135
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1136
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1137
  ^ shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1138
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1139
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1140
!MenuPanel methodsFor:'accessing items'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1141
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1142
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1143
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1144
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1145
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1146
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1147
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1148
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1149
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1150
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1151
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1152
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1153
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1154
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1155
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1156
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1157
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1158
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1159
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1160
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1161
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1162
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1163
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1164
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1165
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1166
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1167
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1168
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1169
  ^ exceptionBlock value
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1170
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1171
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1172
!MenuPanel methodsFor:'accessing look'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1173
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1174
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1175
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1176
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1177
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1178
  ^ self styleAt:#fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1179
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1180
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1181
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1182
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1183
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1184
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1185
    self styleAt:#fitFirstPanel put:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1186
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1187
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1188
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1189
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1190
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1191
  ^ self styleAt:#groupDividerSize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1192
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1193
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1194
groupDividerSize:aSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1195
    "set the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1196
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1197
    self styleAt:#groupDividerSize put:aSize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1198
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1199
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1200
horizontalSpace
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1201
    "get the horizontal space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1202
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1203
  ^ self styleAt:#horizontalSpace
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1204
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1205
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1206
horizontalSpace:aSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1207
    "set the horizontal space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1208
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1209
    self styleAt:#horizontalSpace put:aSize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1210
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1211
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1212
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1213
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1214
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1215
  ^ self menuAdornmentAt:#showGroupDivider
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1216
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1217
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1218
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1219
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1220
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1221
    self menuAdornmentAt:#showGroupDivider put:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1222
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1223
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1224
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1225
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1226
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1227
  ^ self menuAdornmentAt:#showSeparatingLines
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1228
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1229
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1230
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1231
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1232
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1233
    self menuAdornmentAt:#showSeparatingLines put:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1234
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1235
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1236
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1237
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1238
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1239
  ^ self menuAdornmentAt:#verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1240
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1241
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1242
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1243
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1244
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1245
    self menuAdornmentAt:#verticalLayout put:aState.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1246
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1247
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1248
!MenuPanel methodsFor:'accessing submenu'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1249
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1250
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1251
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1252
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1253
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1254
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1255
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1256
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1257
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1258
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1259
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1260
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1261
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1262
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1263
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1264
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1265
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1266
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1267
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1268
    (item := self selection) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1269
        ^ item submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1270
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1271
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1272
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1273
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1274
!MenuPanel methodsFor:'activation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1275
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1276
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1277
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1278
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1279
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1280
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1281
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1282
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1283
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1284
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1285
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1286
show
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1287
    "realize the view at its last position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1288
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1289
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1290
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1291
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1292
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1293
showAt:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1294
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1295
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1297
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1298
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1299
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1301
showAt:aPoint resizing:aBoolean
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1302
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1303
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1304
    self rearrangeItems.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1305
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1306
    aBoolean ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1307
        self fixSize.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1308
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1309
    self origin:aPoint.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1310
    self makeFullyVisible.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1311
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1312
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1313
  ^ self lastValueAccepted
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1314
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1315
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1316
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1317
showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1318
    "realize the view at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1319
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1320
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1321
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1322
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1323
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1324
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1325
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1326
    "make myself visible at the screen center.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1327
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1328
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1329
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1330
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1331
    top raise.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1332
  ^ self showAt:(top origin + (aView originRelativeTo:top) + (aView extent // 2) - (self extent // 2))
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1333
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1334
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1335
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1336
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1337
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1338
    "realize the menu at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1339
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1340
    ^ self showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1341
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1342
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1343
!MenuPanel methodsFor:'active help'!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1344
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1345
helpText
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1346
    |appl item key|
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1347
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1348
    (item := self selection) notNil ifTrue:[
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1349
        (key := item activeHelpKey) notNil ifTrue:[
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1350
            (appl := self application) notNil ifTrue:[
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1351
                ^ appl helpTextForKey:key
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1352
            ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1353
        ]
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1354
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1355
    ^ nil.
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1356
! !
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1357
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1358
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1359
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1360
createAtIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1361
    "create an item and add this item to the index. In case of nil the item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1362
     is added to the end. If the index is not valid nil is returned otherwise
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1363
     the new created item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1364
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1365
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1366
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1367
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1368
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1369
    anIndexOrNil notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1370
        (anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1371
            ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1372
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1373
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1374
    items isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1375
        items := OrderedCollection new
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1376
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1377
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1378
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1379
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1380
        items add:item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1381
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1382
        items add:item beforeIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1383
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1384
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1385
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1386
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1387
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1388
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1389
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1390
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1391
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1392
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1393
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1394
        items remove:item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1395
        item  destroy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1396
        items isEmpty ifTrue:[items := nil].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1397
        self mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1398
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1399
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1400
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1401
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1402
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1403
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1404
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1405
    self disabledRedrawDo:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1406
        self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1407
        groupSizes := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1408
        self do:[:el| el destroy ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1409
        items := nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1410
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1411
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1412
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1413
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1414
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1415
update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1416
    |channel|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1417
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1418
    channel := self menuHolder.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1419
    channel == changedObject ifTrue:[^ self menu:(channel value)].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1420
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1421
    channel := self enableChannel.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1422
    channel == changedObject ifTrue:[^ self enabled:(channel value)].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1423
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1424
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1425
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1426
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1427
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1428
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1429
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1430
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1431
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1432
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1433
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1434
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1435
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1436
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1437
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1438
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1439
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1440
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1441
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1442
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1443
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1444
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1445
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1446
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1447
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1448
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1449
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1450
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1451
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1452
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1453
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1454
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1455
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1456
    self disabledRedrawDo:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1457
        self removeAll.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1458
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1459
        (menu := aMenu) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1460
            (aMenu isCollection) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1461
                menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1462
                menu fromLiteralArrayEncoding:aMenu.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1463
            ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1464
                menu receiver notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1465
                    receiver := menu receiver
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1466
                ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1467
            ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1468
            menu menuItems notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1469
                menu menuItems do:[:anItem|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1470
                    (self createAtIndex:nil) menuItem:anItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1471
                ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1472
            ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1473
            self groupSizes:(menu groupSizes).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1475
    ]    
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1476
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1477
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1478
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1479
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1480
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1481
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1482
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1483
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1484
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1485
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1486
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1487
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1488
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1489
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1491
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1492
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1493
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1494
mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1495
    "returns true if layout of items must be recomputed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1496
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1497
    mustRearrange ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1498
        mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1499
        self invalidate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1500
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1501
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1502
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1503
rearrangeItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1504
    "recompute layout of my items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1505
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1506
    |expLast x y e grpDivSz hrzSpace layout|
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1507
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1508
    mustRearrange ifFalse:[ ^ self ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1509
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1510
"/  fetch font from superMenu
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1511
    (superMenu notNil and:[superMenu font ~~ font]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1512
        super font:(superMenu font on:device)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1513
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1514
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1515
    items isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1516
        mustRearrange := false.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1517
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1518
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1519
    hrzSpace := self horizontalSpace.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1520
    expLast  := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1521
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1522
    self hasGroupDividers ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1523
        self isFitPanel ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1524
            grpDivSz := self groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1525
        ] ifTrue:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1526
            expLast := true.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1527
            x := 0.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1528
            e := self computeExtent.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1529
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1530
            self verticalLayout ifTrue:[
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1531
                items do:[:el|x := x + el preferredExtentY].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1532
                y := e y.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1533
            ] ifFalse:[
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1534
                items do:[:el|x := x + el preferredExtentX].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1535
                x := x + ((items size - 1) * hrzSpace).
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1536
                y := e x.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1537
            ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1538
            (grpDivSz := (y - x) // (groupSizes size)) <= 0 ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1539
                grpDivSz := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1540
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1541
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1542
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1543
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1544
    (self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1545
        e := self preferredExtent.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1546
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1547
        self isPopUpView ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1548
            self verticalLayout ifTrue:[e y:1.0]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1549
                               ifFalse:[e x:1.0]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1550
        ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1551
        self extent:e
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1552
    ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1553
        e := self computeExtent
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1554
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1555
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1556
    x := 0.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1557
    y := 0.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1558
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1559
    self keysAndValuesDo:[:anIndex :el||org|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1560
        org := Point x:x y:y.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1561
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1562
        self verticalLayout ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1563
            y := y + el preferredExtentY.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1564
            el layout:(Rectangle origin:org corner:(e x @ y)).
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1565
        ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1566
            x := x + el preferredExtentX.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1567
            el layout:(Rectangle origin:org corner:(x @ e y)).
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1568
            x := x + hrzSpace.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1569
        ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1570
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1571
        (grpDivSz notNil and:[self hasGroupDividerAt:anIndex]) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1572
            self verticalLayout ifTrue:[y := y + grpDivSz]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1573
                               ifFalse:[x := x + grpDivSz]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1574
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1575
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1576
    expLast ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1577
        layout := items last layout.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1578
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1579
        self verticalLayout ifTrue:[layout bottom:((self extent y) + 1)]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1580
                           ifFalse:[layout right:((self extent x) + 1)].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1581
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1582
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1583
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1584
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1585
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1586
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1587
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1588
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1589
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1590
redrawX:x y:y width:w height:h
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1591
    "redraw a rectangle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1592
    "
433
ff676b8dd717 add inset to seperator line
ca
parents: 428
diff changeset
  1593
    |start end isVrt x1 x2 y1 y2 item layout lnSz hrzInset|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1594
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1595
    shown ifFalse:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1596
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1597
    super redrawX:x y:y width:w height:h.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1598
    self  paint:(self backgroundColor).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1599
    self  clearRectangleX:x y:y width:w height:h.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1600
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1601
    isVrt := self verticalLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1602
    end   := items size.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1603
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1604
    mustRearrange ifTrue:[
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1605
        self isPopUpView not ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1606
            explicitExtent := true
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1607
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
        self rearrangeItems.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1609
        start := 1
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1610
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1611
        end == 0 ifTrue:[ ^ self ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1612
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1613
        isVrt ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
            start := self findFirst:[:el| (el layout bottom) >= y ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1615
            start == 0 ifTrue:[ ^ self ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1616
            end := y + h.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1617
            end := self findLast:[:el| (el layout top) < end ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1618
        ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1619
            start := self findFirst:[:el| (el layout right) >= x ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1620
            start == 0 ifTrue:[ ^ self ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1621
            end := x + w.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1622
            end := self findLast:[:el| (el layout left) < end ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1623
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1624
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1625
        (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1626
            start := start - 1
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1627
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1629
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1630
    (     self hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1631
     and:[self showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1632
     and:[self isFitPanel not]]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1633
    ) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1634
        lnSz := self groupDividerSize // 2
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1635
    ].
433
ff676b8dd717 add inset to seperator line
ca
parents: 428
diff changeset
  1636
    hrzInset := Item horizontalInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1637
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1638
    start to:end do:[:i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1639
        item := items at:i.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1640
        item redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1641
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1642
        (lnSz notNil and:[self hasGroupDividerAt:i]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1643
            layout := item layout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1644
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1645
            isVrt ifTrue:[
433
ff676b8dd717 add inset to seperator line
ca
parents: 428
diff changeset
  1646
                x1 := layout left  + hrzInset.
ff676b8dd717 add inset to seperator line
ca
parents: 428
diff changeset
  1647
                x2 := layout right - hrzInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
                y1 := (layout bottom) + lnSz.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1649
                y2 := y1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1650
            ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1651
                x1 := (layout right) + lnSz.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1652
                x2 := x1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1653
                y1 := layout top.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1654
                y2 := layout bottom.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1655
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1656
            self paint:(self shadowColor).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1657
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1658
            self paint:(self lightColor).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1659
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1660
            isVrt ifTrue:[y1 := y1 + 1. y2 := y1 ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1661
                 ifFalse:[x1 := x1 + 1. x2 := x1 ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1662
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1663
            self displayLineFromX:x1 y:y1 toX:x2 y:y2
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1664
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1665
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1666
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1667
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1668
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1669
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1670
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1671
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1672
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1673
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1674
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1675
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1676
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1677
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1678
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1679
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1681
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1682
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1683
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1684
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1685
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1686
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1687
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1688
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1689
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1690
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1691
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1692
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1693
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1694
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1695
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1696
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1697
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1698
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1699
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1700
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1701
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1702
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1703
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1704
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1705
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1706
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1707
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1708
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1709
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1710
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1711
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1712
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1713
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1714
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1715
    i := self findFirst:[:el|el nameKey = something].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1716
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1717
    i ~~ 0 ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1718
        ^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1719
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1720
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1721
    something isSymbol ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1722
        i := self findFirst:[:el|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1723
            v := el value.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1724
            v isSymbol and:[v == something]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1725
        ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1726
        i ~~ 0 ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1727
            ^ i
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1728
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1729
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1730
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1731
    (something respondsTo:#string) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1732
        v := something string.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1733
      ^ self findFirst:[:el|el textLabel = v].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1734
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1735
  ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1736
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1737
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1738
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1739
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1740
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1741
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1742
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1743
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1744
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1745
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1746
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1747
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1748
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1749
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1750
    |menu point sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1751
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1752
    (    (sensor := self sensor) notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1753
     and:[sensor hasButtonMotionEventFor:nil]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1754
    ) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1755
        ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1756
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1757
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1758
    (self containsPointX:x y:y) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1759
        ^ self selection:(self itemAtX:x y:y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1760
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1761
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1762
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1763
    menu isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1764
        ^ self selection:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1765
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1766
    point := self translatePoint:(x@y) to:menu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1767
    menu selection:(menu itemAtX:(point x) y:(point y))
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1768
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1769
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1770
buttonPress:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1771
    "any button pressed; open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1772
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1773
    |menu point item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1774
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1775
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1776
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1777
    menu isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1778
        menu := self topMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1779
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1780
        point := self translatePoint:(x@y) to:menu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1781
        item  := menu itemAtX:(point x) y:(point y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1783
    menu selection:item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1784
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1785
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1786
buttonRelease:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1787
    "button release action; accept selection and close all views
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1788
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1789
    ( self hasSelection or:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1790
        (OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1791
                                    and:mapTime) > 200]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1792
    ) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1793
        self accept
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1794
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1795
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1796
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1797
cursorPressed:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1798
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1799
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1800
    |idx next first submenu item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1801
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1802
    (self hasSelection not and:[superMenu notNil]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1803
        ^ superMenu cursorPressed:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1804
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1805
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1806
    self verticalLayout ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1807
        aKey == #CursorLeft  ifTrue:[^ self selection:nil].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1808
        aKey ~~ #CursorRight ifTrue:[next := aKey == #CursorDown].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1809
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1810
        aKey == #CursorUp ifTrue:[^ self selection:nil].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1811
        aKey ~~ #CursorDown ifTrue:[next := aKey == #CursorRight].        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1812
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1813
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1814
    next isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1815
        (item := self selection) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1816
            (submenu := item submenu) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1817
                idx := submenu findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1818
              ^ submenu selectionIndex:idx
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1819
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1820
          ^ self selection:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1821
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1822
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1823
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1824
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1825
    first := self findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1826
    first == 0 ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1827
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1828
    idx := self selectionIndex.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1829
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1830
    next ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1831
        [((idx := idx + 1) <= items size and:[(items at:idx) canSelect not])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1832
        ] whileTrue.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1833
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1834
        idx > items size ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1835
            idx := first
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1836
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1837
    ] ifFalse:[    
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1838
        [((idx := idx - 1) > 0  and:[(items at:idx) canSelect not])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1839
        ] whileTrue.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1840
        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1841
        idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1842
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1843
    self selectionIndex:idx
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1844
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1845
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1846
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1847
keyPress:key x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1848
    "any key is pressed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1849
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1850
    |listOfItems item menu idx cIdx upperKey lowerKey|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1851
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1852
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1853
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1854
    [ menu shown ] whileFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1855
        (menu := superMenu) isNil ifTrue:[^ self]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1856
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1857
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1858
    key == #Return ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1859
        ^ menu accept
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1860
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1861
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1862
    (     key == #CursorDown or:[key == #CursorUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1863
      or:[key == #CursorLeft or:[key == #CursorRight]]]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1864
    ) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1865
        ^ menu cursorPressed:key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1866
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1867
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1868
    listOfItems := self selectItemsForShortcutKey:key.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1869
    listOfItems notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1870
        item := listOfItems first.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1871
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1872
        item hasSubmenu ifFalse:[
441
91230b4c4844 bug fix
ca
parents: 436
diff changeset
  1873
            ^ menu accept:item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1874
        ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1875
      ^ self openMenusFromItems:listOfItems
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1876
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1877
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1878
    (self hasSelection not and:[superMenu notNil]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1879
        (superMenu containsPoint:(self translatePoint:(x@y) to:superMenu)) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1880
            menu := superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1881
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1882
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1883
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1884
    cIdx := menu selectionIndex.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1885
    cIdx isNil ifTrue:[cIdx := 0].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1886
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1887
    upperKey := key asUppercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1888
    lowerKey := key asLowercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1889
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1890
    menu keysAndValuesDo:[:anIndex :el| |c l|
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1891
        (el canSelect and:[(l := el textLabel) notNil]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1892
            l size ~~ 0 ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1893
                (c := el accessCharacter) notNil ifTrue:[
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1894
                    (c == upperKey or:[c == lowerKey]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1895
                        ^ menu selection:el
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1896
                    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1897
                ] ifFalse:[
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1898
                    ((c := l first) == upperKey or:[c == lowerKey]) ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1899
                        anIndex > cIdx ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1900
                            ^ menu selection:el
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1901
                        ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1902
                            idx isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1903
                                idx := anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1904
                            ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1905
                                anIndex > idx ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1906
                                    anIndex ~~ cIdx ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1907
                                        idx := anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1908
                                    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1909
                                ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1910
                            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1911
                        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1912
                        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1913
                    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1914
                ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1915
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1916
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1917
    ].
417
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1918
    (item := menu itemAt:idx) isNil ifTrue:[
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1919
        menu hasSelection ifFalse:[
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1920
            (menu := menu superMenu) isNil ifTrue:[
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1921
                ^ super keyPress:key x:x y:y
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1922
            ]
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1923
        ]
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1924
    ].
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  1925
    menu selection:item.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1926
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1927
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1928
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1929
sizeChanged:how
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1930
    self isFitPanel ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1931
        self mustRearrange.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1932
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1933
    super sizeChanged:how
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1934
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1935
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1936
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1937
420
ca
parents: 417
diff changeset
  1938
forceUngrabMouseAndKeyboard
ca
parents: 417
diff changeset
  1939
    "ungrap resources( mouse and keyboard )
ca
parents: 417
diff changeset
  1940
    "
ca
parents: 417
diff changeset
  1941
    |sensor|
ca
parents: 417
diff changeset
  1942
ca
parents: 417
diff changeset
  1943
    device ungrabPointer.
ca
parents: 417
diff changeset
  1944
ca
parents: 417
diff changeset
  1945
    (sensor := self sensor) notNil ifTrue:[
ca
parents: 417
diff changeset
  1946
        "/ make certain all X events have been received
ca
parents: 417
diff changeset
  1947
        device sync.
ca
parents: 417
diff changeset
  1948
        "/ now all events have been received.
ca
parents: 417
diff changeset
  1949
        "/ now, flush all pointer events
ca
parents: 417
diff changeset
  1950
        sensor flushKeyboardFor:nil
ca
parents: 417
diff changeset
  1951
    ].
ca
parents: 417
diff changeset
  1952
    device ungrabKeyboard.
ca
parents: 417
diff changeset
  1953
ca
parents: 417
diff changeset
  1954
!
ca
parents: 417
diff changeset
  1955
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
grabMouseAndKeyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1957
    "get exclusive access to pointer and keyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1958
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1959
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1960
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1961
    realized ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1962
        sensor := self sensor.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1963
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1964
        device activePointerGrab ~~ self ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1965
            sensor notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1966
                sensor flushMotionEventsFor:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1967
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1968
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1969
            (device grabPointerInView:self) ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1970
                Delay waitForSeconds:0.1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1971
                (device grabPointerInView:self) ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1972
                    "give up"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1973
                    'PopUpView [warning]: could not grab pointer' errorPrintCR.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1974
                    self unmap
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1975
                ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1976
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1977
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1978
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1979
        device activeKeyboardGrab ~~ self ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1980
            sensor notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1981
                device sync.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1982
                sensor flushKeyboardFor:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1983
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1984
            device grabKeyboardInView:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1985
            self getKeyboardFocus
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1986
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1987
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1988
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1989
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1990
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1991
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1992
ungrabMouseAndKeyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1993
    "ungrap resources( mouse and keyboard )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1994
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1995
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1996
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1997
    device activePointerGrab == self ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1998
        device ungrabPointer.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1999
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2000
    device activeKeyboardGrab == self ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2001
        (sensor := self sensor) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2002
            "/ make certain all X events have been received
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2003
            device sync.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2004
            "/ now all events have been received.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2005
            "/ now, flush all pointer events
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2006
            sensor flushKeyboardFor:self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2007
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2008
        device ungrabKeyboard.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2009
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2010
    (superMenu notNil and:[superMenu shown and:[superMenu isPopUpView]]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2011
        superMenu grabMouseAndKeyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2012
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2013
        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2014
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2015
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2016
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2017
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2018
!MenuPanel methodsFor:'initialize / release'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2019
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2020
create
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2021
    "create the shadow view for a none contained submenu; see initStyle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2022
    "
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2023
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2024
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2025
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2026
    self isPopUpView ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2027
        shadowView isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2028
            shadowView := (ShadowView onDevice:device) for:self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2029
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2030
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2031
        explicitExtent == true ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2032
            (self extent x) == (superView extent x) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2033
                self verticalLayout:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2034
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2035
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2036
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2037
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2038
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2039
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2040
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2041
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2042
    |channel|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2043
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2044
    self do:[:el|el destroy].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2045
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2046
    (channel := self menuHolder)    notNil ifTrue:[ channel removeDependent:self].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2047
    (channel := self enableChannel) notNil ifTrue:[ channel removeDependent:self].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2048
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2049
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2050
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2051
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2052
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2053
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2054
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2055
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2056
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2057
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2058
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2059
    super initialize.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2060
    font := font on:device.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2061
    self origin:0.0@0.0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2062
    originChanged  := extentChanged := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2063
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2064
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2065
    mustRearrange  := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2066
    self level:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2067
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2068
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2069
mapped
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2070
    "grab the pointer here, when visible (but not control is already lost). 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2071
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2072
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2073
    |anItemList|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2074
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2075
    mapTime := Time millisecondClockValue.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2076
    super mapped.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2077
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2078
    anItemList := InitialSelectionQuerySignal raise.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2079
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2080
    self isPopUpView ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2081
        self grabMouseAndKeyboard
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2082
    ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2083
        super viewBackground:(self backgroundColor)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2084
.   ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2085
    self do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2086
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2087
    anItemList size > 0 ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2088
        self redrawX:0 y:0 width:10000 height:10000.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2089
        self openMenusFromItems:anItemList.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2090
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2091
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2092
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2093
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2094
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2095
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2096
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2097
    |bsz|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2098
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2099
    self isPopUpView ifTrue:[
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2100
        self resize.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2101
        shadowView isNil ifTrue:[
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2102
            shadowView := (ShadowView onDevice:device) for:self
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2103
        ].
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2104
        bsz := self styleAt:#borderWidth.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2105
        bsz ~~ self borderWidth ifTrue:[
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2106
            self borderWidth:bsz
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2107
        ].
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2108
        shadowView realize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2109
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2110
    super realize.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2111
    self raise.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2112
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2113
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2116
recreate
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2117
    "this is called after a snapin. If the image was saved with an active menu,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2118
     hide the menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2119
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2120
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2121
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2122
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2123
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2124
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2125
unmap
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2126
    "unmap view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2127
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2128
    self ungrabMouseAndKeyboard.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2129
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2130
    shadowView notNil ifTrue:[shadowView unmap].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2132
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2133
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2134
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2135
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2136
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2137
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2138
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2139
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2140
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2141
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2142
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2143
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2144
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2145
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2146
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2147
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2148
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2149
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2150
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2151
superMenu:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2152
    "set the supermenu starting from
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2153
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2154
    superMenu := aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2155
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2156
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2157
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2158
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2159
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2160
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2161
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2162
    top := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2163
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2164
    [ top superMenu notNil ] whileTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2165
        top := top superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2166
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2167
  ^ top
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2168
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2169
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2170
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2171
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2172
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2173
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2174
application
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2175
    |appl|
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2176
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2177
    superMenu notNil ifTrue:[
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2178
        ^ superMenu application
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2179
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2180
    (appl := super application) isNil ifTrue:[
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2181
        windowGroup notNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2182
            appl := windowGroup mainGroup topViews first application
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2183
        ]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2184
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2185
  ^ appl
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2186
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2187
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2188
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2189
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2190
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2191
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2192
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2193
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2194
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2195
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2196
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2197
menuAdornmentAt:aSymbol put:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2198
    "sets a value for the specific menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2199
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2200
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2201
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2202
    (self menuAdornmentAt:aSymbol) ~~ something ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2203
        adornment isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2204
            adornment := DefaultAdornment copy
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2205
        ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2206
        adornment at:aSymbol put:something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2207
        self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2208
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2209
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2210
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2211
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2212
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2214
    |size|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2215
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2216
    aList isCollection ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2217
        items size >= aList size ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2218
            aList keysAndValuesDo:[:anIndex :anArg|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2219
                (items at:anIndex) perform:aSelector with:anArg
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2220
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2221
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2222
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2223
        self do:[:anItem| anItem perform:aSelector with:aList ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2224
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2225
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2226
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2227
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2229
openMenusFromItems:anItemList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2230
    "open all menus derived from sequence of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2231
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2232
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2233
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2234
    (anItemList isNil or:[anItemList isEmpty]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2235
        ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2236
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2237
    item := anItemList removeLast.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2238
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2239
    item enabled ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2240
        ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2241
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2243
    InitialSelectionQuerySignal answer:anItemList do:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2244
        self selection:item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2245
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2246
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2247
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2248
selectItemsForShortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2249
    "get sequence of items up to the item providing the key (inclusive). The
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2250
     first entry into the collection is the item providing the key, the last
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2251
     entry is the item in the topMenu( reverse )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2252
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2253
    |seq|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2254
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2255
    self do:[:anItem|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2256
        anItem isEnabled ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2257
            anItem shortcutKey = aKey ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2258
                seq := OrderedCollection new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2259
            ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2260
                anItem hasSubmenu ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2261
                    seq := anItem submenu selectItemsForShortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2262
                ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2263
            ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2264
            seq notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2265
                seq add:anItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2266
              ^ seq
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2267
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2268
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2269
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2270
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2271
        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2272
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2273
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2274
styleAt:aSymbol
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2275
    "gets a value derived from the style in the topMenu
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2276
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2277
    |aStyle|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2278
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2279
    superMenu isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2280
        aStyle := style ? DefaultStyle.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2281
      ^ aStyle at:aSymbol ifAbsent:nil
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2282
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2283
  ^ superMenu styleAt:aSymbol
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2284
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2285
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2286
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2287
styleAt:aSymbol put:aValue
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2288
    "sets a value derived from the style in the topMenu
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2289
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2290
    |aStyle|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2291
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2292
    superMenu isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2293
        aStyle := style ? DefaultStyle.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2294
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2295
        (aStyle at:aSymbol ifAbsent:nil) ~~ aValue ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2296
            style isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2297
                style := DefaultStyle copy.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2298
            ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2299
            style at:aSymbol put:aValue.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2300
        ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2301
    ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2302
        superMenu styleAt:aSymbol put:aValue
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2303
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2304
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2305
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2306
translatePoint:aPoint to:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2307
    "translate a point into a views point; in case of no view nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2308
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2309
    aView notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2310
        aView == self ifTrue:[^ aPoint].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2311
      ^ device translatePoint:aPoint from:(self id) to:(aView id)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2312
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2313
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2314
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2315
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2316
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2317
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2318
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2319
itemAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2320
    "returns item at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2321
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2322
    self do:[:el| (el containsPointX:x y:y) ifTrue:[^el] ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2323
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2324
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2325
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2326
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2327
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2328
superMenuAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2329
    "returns supermenu at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2330
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2331
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2332
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2333
    (self containsPointX:x y:y) ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2334
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2335
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2336
    [ (menu := menu superMenu) notNil ] whileTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2337
        (menu containsPoint:(self translatePoint:(x@y) to:menu)) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2338
            ^ menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2339
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2340
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2341
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2342
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2343
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2344
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2345
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2346
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2347
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2348
canDrawItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2349
    "returns true if an item could be drawn otherwise false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2350
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2351
    ^ (mustRearrange not and:[self shown])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2352
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2353
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2354
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2355
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2356
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2357
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2358
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2359
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2360
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2361
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2362
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2363
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2364
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2365
    |ext|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2366
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2367
    (x >= 0 and:[y >= 0]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2368
        ext := self computeExtent.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2369
      ^ (x < ext x and:[y < ext y])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2370
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2371
    ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2372
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2373
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2374
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2375
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2376
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2377
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2378
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2379
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2380
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2381
    groupSizes size ~~ 0 ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2382
        i := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2383
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2384
        groupSizes do:[:t|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2385
            (i := i + t) == anIndex ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2386
                ^ true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2387
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2388
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2389
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2390
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2391
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2392
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2393
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2394
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2395
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2396
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2397
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2398
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2399
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2400
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2401
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2402
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2403
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2404
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2405
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2406
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2407
    "returns true if the panel is the first in the menu hierarchy in must
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2408
     be fit to the extent of its superView
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2409
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2410
    superView isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2411
        ^ false
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2412
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2413
  ^ self styleAt:#fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2414
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2415
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2416
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2417
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2418
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2419
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2420
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2421
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2422
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2423
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2424
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2425
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2426
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2427
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2428
  ^ self verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2429
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2430
416
c05874084d4c implement
ca
parents: 407
diff changeset
  2431
!
c05874084d4c implement
ca
parents: 407
diff changeset
  2432
c05874084d4c implement
ca
parents: 407
diff changeset
  2433
type
428
ca
parents: 427
diff changeset
  2434
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  2435
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2436
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2437
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2438
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2439
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2440
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2441
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2442
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2443
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2444
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2445
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2446
isValidSelection:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2447
    "returns true if something could be selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2448
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2449
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2450
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2451
    (item := self itemAt:something) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2452
        ^ item canSelect
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2453
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2454
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2455
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2456
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2457
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2458
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2459
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2460
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2461
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2462
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2463
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2464
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2465
selection:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2466
    "change selection to an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2467
    "
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2468
    |item newSel hlp|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2469
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2470
    selection isNumber ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2471
        newSel := self itemAt:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2472
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2473
        (anItemOrNil notNil and:[anItemOrNil canSelect]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2474
            newSel := anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2475
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2476
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2477
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2478
    selection == newSel ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2479
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2480
    (item := selection) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2481
        selection := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2482
        item selected:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2483
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2484
    newSel isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2485
        self isPopUpView ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2486
            self ungrabMouseAndKeyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2487
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2488
        ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2489
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2490
    selection := newSel.
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2491
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2492
    ActiveHelp isActive ifTrue:[
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2493
        hlp := ActiveHelp currentHelpListener.
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2494
        hlp initiateHelpFor:self atX:1 y:1 now:true.
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2495
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2496
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2497
    selection selected:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2498
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2499
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2500
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2501
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2502
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2503
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2504
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2505
    (item := self selection) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2506
        ^ self findFirst:[:el| el == item ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2507
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2508
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2509
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2510
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2511
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2512
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2513
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2514
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2515
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2516
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2517
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2518
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2519
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2520
horizontalInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2521
    ^ HorizontalInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2522
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2523
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2524
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2525
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2526
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2527
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2528
shortcutKeyOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2529
    ^ ShortcutKeyOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2530
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2531
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2532
verticalInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2533
    ^ VerticalInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2534
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2536
!MenuPanel::Item class methodsFor:'init style'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2537
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2538
initStyle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2539
    "setup defaults
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2540
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2541
    HorizontalInset   := 4.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2542
    VerticalInset     := 4.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2543
    LabelRightOffset  := 15.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2544
    ShortcutKeyOffset := 5.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2545
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2546
    IndicatorOn  := CheckToggle checkImageForStyle:#borderedFatcross.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2547
    IndicatorOff := CheckToggle checkImageForStyle:#border.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2548
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2549
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2550
self initStyle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2551
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2552
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2553
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2554
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2555
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2556
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2557
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2558
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2559
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2560
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2561
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2562
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2563
    HorizontalInset isNil ifTrue:[ self initStyle ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2564
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2565
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2566
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2567
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2568
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2569
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2570
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2571
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2572
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2573
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2574
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2575
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2576
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2577
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2578
!MenuPanel::Item methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2579
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2580
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2581
    "item accepted; perform action, ...
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2582
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2583
    |sel res rcv num arg tval|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2584
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2585
    self hasIndication ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2586
        tval := self indicationValue not.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2587
        self indicationValue:tval
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2588
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2589
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2590
    value isNil ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2591
        ^ menuPanel findFirst:[:el| el == self ]
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2592
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2593
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2594
    (arg := self argument) isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2595
        arg := tval
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2596
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2597
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2598
    value isSymbol ifFalse:[
420
ca
parents: 417
diff changeset
  2599
"/ receiver is a value holder or a block
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2600
        rcv := value.
396
433d9b5ecca9 bug fix in accept
ca
parents: 395
diff changeset
  2601
        (rcv respondsTo:#numArgs) ifFalse:[
433d9b5ecca9 bug fix in accept
ca
parents: 395
diff changeset
  2602
            ^ rcv
433d9b5ecca9 bug fix in accept
ca
parents: 395
diff changeset
  2603
        ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2604
        num := value numArgs.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2605
        res := menuPanel findFirst:[:el| el == self ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2606
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2607
        num == 0 ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2608
            sel := #value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2609
        ] ifFalse:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2610
            num == 1 ifTrue:[sel := #value:]
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2611
                    ifFalse:[sel := #value:value:]
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2612
        ]
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2613
    ] ifTrue:[
420
ca
parents: 417
diff changeset
  2614
"/ receiver should be an instance or nil
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2615
        (rcv := menuPanel receiver) isNil ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2616
            ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2617
        ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2618
        sel := value.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2619
        num := value numArgs.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2620
        res := value.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2621
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2622
420
ca
parents: 417
diff changeset
  2623
    num == 0 ifTrue:[ ^ [rcv perform:sel. res] ].
ca
parents: 417
diff changeset
  2624
    num == 1 ifTrue:[ ^ [rcv perform:sel with:arg. res] ].
ca
parents: 417
diff changeset
  2625
                      ^ [rcv perform:sel with:arg with:self. res]
ca
parents: 417
diff changeset
  2626
!
ca
parents: 417
diff changeset
  2627
ca
parents: 417
diff changeset
  2628
canAccept
ca
parents: 417
diff changeset
  2629
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  2630
    "
ca
parents: 417
diff changeset
  2631
  ^ (self enabled and:[self hasSubmenu not])
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2632
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2633
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2634
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2635
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2636
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2637
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2638
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2639
    accessCharacterPosition isNil ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2640
        ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2641
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2642
  ^ (rawLabel string) at:accessCharacterPosition
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2643
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2644
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2645
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2646
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2647
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2648
  ^ accessCharacterPosition
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2649
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2650
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2651
accessCharacterPosition:anIndex
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2652
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2653
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2654
    |idx lbl|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2655
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2656
    (      (accessCharacterPosition ~~ anIndex)
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2657
      and:[(lbl := self textLabel) notNil]
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2658
    ) ifTrue:[
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2659
        anIndex notNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2660
            (anIndex < 1 or:[anIndex > lbl size]) ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2661
                ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2662
            ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2663
        ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2664
        accessCharacterPosition := anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2665
        self updateRawLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2666
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2667
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2668
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2669
activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2670
    ^ activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2671
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2672
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2673
activeHelpKey:aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2674
    activeHelpKey := aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2675
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2676
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2677
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2678
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2679
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2680
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2681
  ^ adornment argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2682
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2683
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2684
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2685
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2686
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2687
    self argument ~~ anArgument ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2688
        self adornment argument:anArgument.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2689
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2690
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2691
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2692
compareAccessCharacterWith:aKey
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2693
    "returns true if key is my access character
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2694
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2695
    |s|
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2696
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2697
    accessCharacterPosition notNil ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2698
        s := (rawLabel string) at:accessCharacterPosition.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2699
        s == aKey ifTrue:[^ true ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2700
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2701
  ^ false
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2702
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2703
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2704
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2705
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2706
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2707
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2708
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2709
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2710
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2711
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2712
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2713
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2714
    |type form i rest s|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2715
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2716
    accessCharacterPosition := nil.
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2717
    label := aLabel value.
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2718
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2719
    (label isString and:[(s := label size) > 1]) ifTrue:[
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2720
        i := 1.
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2721
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2722
        [((i := label indexOf:$& startingAt:i) ~~ 0 and:[i < s])] whileTrue:[
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2723
            rest := label copyFrom:(i+1).
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2724
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2725
            i == 1 ifTrue:[label := rest]
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2726
                  ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2727
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2728
            (label at:i) == $& ifTrue:[i := i + 1]
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2729
                              ifFalse:[accessCharacterPosition := i].
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2730
            s := s - 1.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2731
        ]
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2732
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2733
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2734
    self updateRawLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2735
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2736
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2737
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2738
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2739
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  2740
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2741
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2742
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2743
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2744
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2745
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2746
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2747
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2748
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2749
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2750
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2751
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2752
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2753
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2754
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2755
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2756
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2757
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2758
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2759
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2760
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2761
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2762
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2763
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2764
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2765
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2766
  ^ adornment shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2767
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2768
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2769
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2770
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2771
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2772
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2773
    self shortcutKey ~~ aKey ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2774
        self adornment shortcutKey:aKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2775
        self redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2776
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2777
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2778
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2779
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2780
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2781
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2782
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2783
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2784
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2785
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2786
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2787
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2788
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2789
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2790
    subMenu notNil ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2791
        subMenu destroy
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2792
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2793
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2794
    (subMenu := aSubMenu) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2795
        aSubMenu class == Menu ifTrue:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2796
            subMenu := menuPanel class subMenu:aSubMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2797
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2798
        subMenu superMenu:menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2799
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2800
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2801
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2802
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2803
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2804
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2805
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2806
    (rawLabel respondsTo:#string) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2807
        ^ rawLabel string
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2808
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2809
  ^ nil
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2810
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2811
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2812
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2813
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2814
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2815
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2816
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2817
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2818
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2819
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2820
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2821
    value := something.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2822
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2823
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2824
!MenuPanel::Item methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2825
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2826
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2827
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2828
    "
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2829
    |appl state|
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2830
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2831
    enableChannel isSymbol ifTrue:[
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2832
        appl := menuPanel receiver.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2833
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2834
        (appl notNil and:[appl respondsTo:enableChannel]) ifTrue:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2835
            state := appl perform:enableChannel
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2836
        ] ifFalse:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2837
            (appl isNil and:[(appl := menuPanel application) notNil]) ifTrue:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2838
                Object messageNotUnderstoodSignal handle:[:ex|
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2839
                    state := true.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2840
                ] do:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2841
                    state := appl aspectFor:enableChannel.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2842
                ]
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2843
            ]                
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2844
        ].
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2845
        
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2846
        (self isKindOfValueHolder:state) ifTrue:[
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2847
            enableChannel := state.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2848
            enableChannel addDependent:self.
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  2849
            state := enableChannel value.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2850
        ]
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2851
    ] ifFalse:[
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2852
        state := enableChannel value
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2853
    ].
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2854
  ^ state ~~ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2855
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2856
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2857
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2858
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2859
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2860
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2861
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2862
    enableChannel isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2863
        oldState := true
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2864
    ] ifFalse:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2865
        oldState := enableChannel value.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2866
        (self isKindOfValueHolder:enableChannel) ifTrue:[
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2867
            enableChannel removeDependent:self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2868
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2869
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2870
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2871
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2872
    enableChannel isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2873
        newState := true
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2874
    ] ifFalse:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2875
        (self isKindOfValueHolder:enableChannel) ifTrue:[
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2876
            enableChannel addDependent:self
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  2877
        ] ifFalse:[
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2878
            enableChannel isSymbol ifTrue:[^ self]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2879
        ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2880
        newState := enableChannel value.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2881
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2882
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2883
    newState ~~ oldState ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2884
        self redraw
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2885
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2886
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2887
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2888
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2889
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2890
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2891
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2892
    adornment isNil ifTrue:[^ nil].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2893
  ^ adornment indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2894
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2895
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2896
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2897
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2898
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2899
    |old|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2900
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2901
    old := self indication.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2902
    old == something ifTrue:[^ self].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2903
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2904
    (self isKindOfValueHolder:old) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2905
        old removeDependent:self
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2906
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2907
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2908
    (self isKindOfValueHolder:something) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2909
        something addDependent:self
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2910
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2911
    self adornment indication:something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2912
    self updateRawLabel.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2913
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2914
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2915
setupSubmenu
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2916
    |appl subm|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2917
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2918
    submenuChannel notNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2919
        submenuChannel isSymbol ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2920
            subm := submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2921
        ] ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2922
            appl := menuPanel application.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2923
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2924
            appl notNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2925
                Object messageNotUnderstoodSignal handle:[:ex|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2926
                    subm := nil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2927
                ] do:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2928
                    subm := appl aspectFor:submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2929
                ]
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2930
            ]
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2931
        ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2932
        (subm := subm value) isArray ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2933
            subm := Menu new fromLiteralArrayEncoding:subm.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2934
        ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2935
        self submenu:subm.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2936
    ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2937
  ^ subMenu
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2938
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2939
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2940
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2941
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2942
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2943
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2944
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2945
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2946
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2947
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2948
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2949
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2950
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2951
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2952
!MenuPanel::Item methodsFor:'accessing dimension'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2953
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2954
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2955
    "gets height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2956
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2957
    layout isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2958
        ^ self preferredExtentY
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2959
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2960
  ^ layout height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2961
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2962
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2963
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2964
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2965
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2966
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2967
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2968
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2969
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2970
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2971
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2972
    layout := aLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2973
    self redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2974
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2975
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2976
preferredExtentX
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2977
    "compute my preferred extent x
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2978
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2979
    |x s|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2980
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2981
    x := HorizontalInset + HorizontalInset.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2982
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2983
    rawLabel notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2984
        x := x + (rawLabel widthOn:menuPanel).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2985
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2986
        (s := self shortcutKeyAsString) notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2987
            x := x + LabelRightOffset + (s widthOn:menuPanel)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2988
        ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2989
        menuPanel verticalLayout ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2990
            self hasSubmenu ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2991
                x := x + self rightArrow width.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2992
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2993
                s notNil ifTrue:[x := x + ShortcutKeyOffset]
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2994
                        ifFalse:[x := x + LabelRightOffset]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2995
            ]
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2996
        ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2997
    ] ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2998
        menuPanel verticalLayout ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  2999
            ^ x max:(self preferredSeperatorSize)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3000
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3001
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3002
  ^ x
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3003
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3004
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3005
preferredExtentY
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3006
    "compute my preferred extent y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3007
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3008
    |s y|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3009
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3010
    y := VerticalInset + VerticalInset.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3011
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3012
    rawLabel notNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3013
        ^ y + (rawLabel heightOn:menuPanel)
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3014
    ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3015
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3016
    menuPanel verticalLayout ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3017
        ^ y max:(self preferredSeperatorSize)
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3018
    ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3019
  ^ y + (menuPanel font height)
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3020
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3021
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3022
preferredSeperatorSize
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3023
    "returns preferred extent x or y of a separator
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3024
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3025
    |type|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3026
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3027
    type := self separatorType.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3028
    type == #doubleLine ifTrue:[^ 10 ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3029
    type == #singleLine ifTrue:[^  6 ].
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  3030
  ^ 20
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3031
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3032
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3033
width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3034
    "gets width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3035
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3036
    layout isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3037
        ^ self preferredExtentX
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3038
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3039
  ^ layout width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3040
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3041
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3042
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3043
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3044
update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3045
    changedObject == self indication ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3046
        rawLabel icon:(self indicator)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3047
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3048
    self redraw
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3049
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3050
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3051
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3052
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3053
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3054
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3055
    |indicator| 
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3056
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3057
    (indicator := self indicator) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3058
        indicator = rawLabel icon ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3059
            rawLabel icon:indicator.
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
  3060
          ^ self redraw.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3061
        ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3062
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3063
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3064
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3065
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3066
!MenuPanel::Item methodsFor:'constants'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3067
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3068
rightArrow
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3069
    "arrow used for submenu indication
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3070
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3071
    ^ SelectionInListView rightArrowFormOn:(menuPanel device)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3072
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3073
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3074
rightArrowShadow
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3075
    "shadow arrow used for submenu indication
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3077
  ^ SelectionInListView rightArrowShadowFormOn:(menuPanel device)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3078
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3079
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3080
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3081
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3082
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3083
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3084
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3085
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3086
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3087
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3088
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3089
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3090
    label isImage ifTrue:[
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3091
        rcv := ResourceRetriever new.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3092
        rcv className:#MenuEditor.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3093
        rcv selector:#iconUnknown.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3094
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3095
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3096
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3097
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3098
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3099
    enableChannel notNil ifTrue:[
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3100
        item enabled:(enableChannel value)
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3101
    ].
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3102
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3103
    item accessCharacterPosition:(self accessCharacterPosition).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3104
    item nameKey:(self nameKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3105
    item shortcutKeyCharacter:(self shortcutKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3106
    item value:(value value).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3107
    item indication:(self indication value).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3108
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3109
    submenuChannel isSymbol ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3110
        item submenuChannel:submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3111
    ] ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3112
        self submenu notNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3113
            item submenu:(self submenu asMenu)
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3114
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3115
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3116
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3117
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3118
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3120
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3121
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3122
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3123
    |acp lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3124
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3125
    menuPanel disabledRedrawDo:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3126
        label := nil.
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3127
        activeHelpKey := aMenuItem activeHelpKey.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3128
        self enabled:(aMenuItem enabled).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3129
        self nameKey:(aMenuItem nameKey).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3130
        self indication:(aMenuItem indication).
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3131
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3132
        (lbl := aMenuItem labelImage value) isNil ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3133
            lbl := aMenuItem label.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3134
        ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3135
        self label:lbl.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3136
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3137
        self shortcutKey:(aMenuItem shortcutKeyCharacter).
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3138
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3139
        (acp := aMenuItem accessCharacterPosition) notNil ifTrue:[
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3140
            self accessCharacterPosition:acp.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3141
        ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3142
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3143
        submenuChannel := aMenuItem submenuChannel.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3144
        self submenu:(aMenuItem submenu).
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3145
        self value:(aMenuItem value).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3146
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3147
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3148
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3149
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3150
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3151
drawLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3152
    "draw label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3153
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3154
    |y img|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3155
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3156
    img := rawLabel.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3157
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3158
    self enabled ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3159
        menuPanel paint:(menuPanel foregroundColor)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3160
    ] ifFalse:[
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3161
        menuPanel paint:(menuPanel disabledForegroundColor).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3162
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3163
        ((img respondsTo:#colorMap) and:[img colorMap notNil]) ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3164
            img := img lightened
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3165
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3166
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3167
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3168
    y := (layout top) + (((layout height) - (img heightOn:menuPanel)) // 2).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3169
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3170
    (self textLabel) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3171
        y := y + menuPanel font ascent.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3172
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3173
    img displayOn:menuPanel x:((layout left) + HorizontalInset) y:y.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3174
    self drawShortcutKey.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3175
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3176
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3177
drawSeparatingLines
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3178
    "draw separating lines
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3179
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3180
    |l r t b|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3181
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3182
    menuPanel showSeparatingLines ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3183
        l := layout left.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3184
        r := layout right.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3185
        t := layout top.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3186
        b := layout bottom.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3187
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3188
        menuPanel paint:(menuPanel lightColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3189
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3190
        menuPanel verticalLayout ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3191
            b := b - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3192
            t := t - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3193
            menuPanel displayLineFromX:l y:b toX:r y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3194
            menuPanel displayLineFromX:l y:t toX:r y:t.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3195
            b := b - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3196
            t := t - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3197
            menuPanel paint:(menuPanel shadowColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3198
            menuPanel displayLineFromX:l y:b toX:r y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3199
            menuPanel displayLineFromX:l y:t toX:r y:t.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3200
        ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3201
            r := r - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3202
            l := l - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3203
            menuPanel displayLineFromX:r y:t toX:r y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3204
            menuPanel displayLineFromX:l y:t toX:l y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3205
            r := r - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3206
            l := l - 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3207
            menuPanel paint:(menuPanel shadowColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3208
            menuPanel displayLineFromX:r y:t toX:r y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3209
            menuPanel displayLineFromX:l y:t toX:l y:b.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3210
        ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3211
    ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3212
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3213
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3214
drawSeparator
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3215
    "draw line separator
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3216
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3217
    |type l r t b x y|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3218
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3219
    type := self separatorType.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3220
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3221
    (type notNil and:[type ~~ #blankLine]) ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3222
        ^ self
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3223
    ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3224
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3225
    l := layout left.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3226
    t := layout top.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3227
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3228
    menuPanel paint:(menuPanel shadowColor).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3229
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3230
    menuPanel verticalLayout ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3231
        l := l + HorizontalInset.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3232
        r := (layout right) - HorizontalInset.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3233
        y := t - 1 + ((layout height) // 2).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3234
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3235
        type == #doubleLine ifTrue:[y := y - 2].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3236
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3237
        menuPanel displayLineFromX:l y:y toX:r y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3238
        menuPanel paint:(menuPanel lightColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3239
        y := y + 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3240
        menuPanel displayLineFromX:l y:y toX:r y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3241
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3242
        type == #doubleLine ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3243
            y := y + 3.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3244
            menuPanel paint:(menuPanel shadowColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3245
            menuPanel displayLineFromX:l y:y toX:r y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3246
            menuPanel paint:(menuPanel lightColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3247
            y := y + 1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3248
            menuPanel displayLineFromX:l y:y toX:r y:y.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3249
        ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3250
    ] ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3251
        b := layout bottom.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3252
        x := l - 1 + ((layout width) // 2).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3253
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3254
        type == #doubleLine ifTrue:[x := x - 2].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3255
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3256
        menuPanel displayLineFromX:x y:t toX:x y:b.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3257
        menuPanel paint:(menuPanel lightColor).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3258
        x := x + 1.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3259
        menuPanel displayLineFromX:x y:t toX:x y:b.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3260
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3261
        type == #doubleLine ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3262
            x := x + 3.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3263
            menuPanel paint:(menuPanel shadowColor).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3264
            menuPanel displayLineFromX:x y:t toX:x y:b.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3265
            menuPanel paint:(menuPanel lightColor).
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3266
            x := x + 1.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3267
            menuPanel displayLineFromX:x y:t toX:x y:b.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3268
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3269
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3270
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3271
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3272
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3273
drawShortcutKey
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3274
    "draw the shorcutKey
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3275
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3276
    |string x y|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3277
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3278
    (string:= self shortcutKeyAsString) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3279
        (x := menuPanel shortKeyInset) == 0 ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3280
            x := LabelRightOffset + (rawLabel widthOn:menuPanel)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3281
        ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3282
        x := (layout left) + x.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3283
        y := (layout top) + (((layout height) - (string heightOn:menuPanel)) // 2).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3284
        y := y + menuPanel font ascent.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3285
        string displayOn:menuPanel x:x y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3286
    ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3287
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3288
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3289
drawSubmenuIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3290
    "draw an arrow in case of having a submenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3291
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3292
    |form x y col|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3293
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3294
    (self submenu notNil and:[menuPanel verticalLayout]) ifTrue:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3295
        form := self rightArrow.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3296
        x    := (layout right) - form width - HorizontalInset.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3297
        y    := layout top + ((layout height - (form heightOn:menuPanel)) // 2).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3298
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3299
        self isSelected ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3300
            menuPanel paint:(menuPanel shadowColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3301
            col := menuPanel lightColor.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3302
        ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3303
            menuPanel paint:(menuPanel lightColor).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3304
            col := menuPanel shadowColor.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3305
        ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3306
        menuPanel displayForm:form x:x y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3307
        menuPanel paint:col.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3308
        menuPanel displayForm:(self rightArrowShadow) x:x y:y.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3309
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3310
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3311
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3312
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3313
redraw
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3314
    "redraw item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3315
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3316
    |ownBgCol x y paint|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3317
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3318
    menuPanel canDrawItem ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3319
        ^ self
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3320
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3321
    self isSelected ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3322
        paint := menuPanel backgroundColor
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3323
    ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3324
        paint := menuPanel activeBackgroundColor
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3325
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3326
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3327
    (ownBgCol := self backgroundColorFromLabel) isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3328
        menuPanel paint:paint.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3329
        menuPanel fillRectangle:layout.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3330
    ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3331
        self hasIndication ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3332
            menuPanel paint:ownBgCol.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3333
            menuPanel fillRectangle:layout.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3334
        ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3335
            menuPanel paint:paint.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3336
            x := (rawLabel icon width) + HorizontalInset + 4.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3337
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3338
            menuPanel fillRectangleX:(layout left)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3339
                                   y:(layout top)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3340
                               width:x
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3341
                              height:(layout height).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3342
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3343
            menuPanel paint:ownBgCol.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3344
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3345
            menuPanel fillRectangleX:(layout left + x)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3346
                                   y:(layout top)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3347
                               width:(layout width - x)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3348
                              height:(layout height).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3349
            ownBgCol := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3350
       ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3351
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3352
    self drawSeparatingLines.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3353
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3354
    rawLabel notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3355
        self drawLabel.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3356
        self drawSubmenuIndication.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3357
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3358
        (ownBgCol notNil and:[self isSelected]) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3359
            x := Color black.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3360
            y := Color white.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3361
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3362
            ownBgCol brightness > 0.5 ifTrue:[menuPanel paint:(Color black)]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3363
                                     ifFalse:[menuPanel paint:(Color white)].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3364
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3365
            menuPanel displayRectangleX:(layout left   + 1)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3366
                                      y:(layout top    + 1)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3367
                                  width:(layout width  - 2)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3368
                                 height:(layout height - 2).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3369
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3370
            menuPanel displayRectangleX:(layout left   + 2)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3371
                                      y:(layout top    + 2)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3372
                                  width:(layout width  - 4)
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3373
                                 height:(layout height - 4).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3374
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3375
    ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3376
        self drawSeparator
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3377
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3378
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3379
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3380
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3381
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3382
destroy
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3383
    "destroy submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3384
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3385
    self submenu:nil.           "/ destroy submenus
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3386
    self enabled:nil.           "/ remove dependencies
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3387
    self indication:nil.        "/ remove dependencies
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3388
    menuPanel := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3389
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3390
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3391
in:aPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3392
    "create item in a menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3393
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3394
    menuPanel := aPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3395
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3396
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3397
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3398
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3399
adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3400
    "returns adornment; if not existing yet a new instance
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3401
     is created
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3402
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3403
    adornment isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3404
        adornment := Adornment new
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3405
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3406
  ^ adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3407
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3408
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3409
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3410
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3411
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3412
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3413
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3414
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3415
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3416
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3417
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3418
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3419
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3420
    run size == 0 ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3421
        (run value isColor and:[run key == #backgroundColor]) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3422
            ^ run value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3423
        ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3424
    ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3425
        run do:[:r|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3426
            (r value isColor and:[r key == #backgroundColor]) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3427
                ^ r value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3428
            ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3429
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3430
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3431
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3432
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3433
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3434
indicationValue
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3435
    "returns indication value or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3436
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3437
    |idct rcv setGet|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3438
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3439
    (idct := self indication) isNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3440
        ^ nil          "/ no indicator
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3441
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3442
    idct isSymbol ifFalse:[ ^ idct value == true ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3443
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3444
    setGet := (idct last) == $:.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3445
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3446
    (rcv := menuPanel receiver) isNil ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3447
        (rcv := menuPanel application) isNil ifTrue:[^ false].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3448
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3449
        setGet ifFalse:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3450
            Object messageNotUnderstoodSignal handle:[:ex|idct := false]
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3451
                                                  do:[idct := rcv aspectFor:idct].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3452
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3453
            (self isKindOfValueHolder:idct) ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3454
                self adornment indication:idct.
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3455
                idct addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3456
            ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3457
          ^ idct value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3458
        ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3459
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3460
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3461
    setGet ifTrue:[
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3462
        idct := (idct copyWithoutLast:1) asSymbol
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3463
    ].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3465
    Object messageNotUnderstoodSignal handle:[:ex| idct := false]
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3466
                                          do:[ idct := (rcv perform:idct) == true].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3467
  ^ idct
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3468
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3469
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3470
indicationValue:aValue
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3471
    "returns indication value or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3472
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3473
    |indication rcv|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3474
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3475
    (indication := self indication) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3476
        indication isSymbol ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3477
            indication last == $: ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3478
                (rcv := menuPanel receiver) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3479
                    rcv perform:indication with:aValue
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3480
                ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3481
            ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3482
        ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3483
            (self isKindOfValueHolder:indication) ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3484
                indication value:aValue
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3485
            ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3486
        ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3487
    ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3488
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3489
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3490
indicator
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3491
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3492
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3493
    |value|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3494
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3495
    (value := self indicationValue) isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3496
        ^ nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3497
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3498
  ^ value ifTrue:[IndicatorOn] ifFalse:[IndicatorOff]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3499
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3500
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3501
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3502
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3503
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3504
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3505
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3506
    rawLabel isNil ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3507
        ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3508
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3509
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3510
    (lbl := label value) isNil ifTrue:[
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3511
        ^ #singleLine
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3512
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3513
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3514
    lbl size == 1 ifTrue:[
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3515
        c := lbl first.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3516
        c == $- ifTrue:[^ #singleLine].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3517
        c == $= ifTrue:[^ #doubleLine].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3518
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3519
  ^ #blankLine
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3520
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3521
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3522
updateRawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3523
    "recreate rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3524
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3525
    |char size indicator|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3526
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3527
    (rawLabel := label value) isString ifFalse:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3528
        ^ menuPanel mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3529
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3530
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3531
    rawLabel isText ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3532
        rawLabel := rawLabel withoutSeparators
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3533
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3534
    size := rawLabel size.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3535
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3536
    (indicator := self indicator) isNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3537
        size == 0 ifTrue:[
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3538
              rawLabel := nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3539
            ^ menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3540
        ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3541
            
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3542
        size == 1 ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3543
            char := rawLabel first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3544
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3545
            (char == $- or:[char == $=]) ifTrue:[   "/ other line separators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3546
                label := String new:1.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3547
                label at:1 put:char.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3548
                rawLabel := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3549
              ^ menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3550
            ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3551
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3552
    ] ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3553
        size == 0 ifTrue:[rawLabel := label value]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3554
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3555
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3556
    rawLabel isText ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3557
        rawLabel := Text string:rawLabel emphasis:#bold
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3558
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3559
    size := self accessCharacterPosition.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3560
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3561
    (size notNil and:[size <= rawLabel size]) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3562
        rawLabel emphasisAt:size add:#underline
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3563
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3564
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3565
    (indicator := self indicator) notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3566
        rawLabel := LabelAndIcon icon:indicator string:rawLabel.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3567
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3568
    menuPanel mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3569
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3570
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3571
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3572
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3573
canSelect
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3574
    "returns true if item is selectable
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3575
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3576
    ^ (self enabled and:[rawLabel notNil])
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3577
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3578
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3579
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3580
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3581
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3582
    ^ (     (x >= layout left)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3583
        and:[x <  layout right
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3584
        and:[y >  layout top
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3585
        and:[y <= layout bottom]]]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3586
      )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3587
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3588
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3589
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3590
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3591
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3592
  ^ self indication notNil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3593
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3594
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3595
hasSubmenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3596
    "returns true if a submenu exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3597
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3598
    ^ self submenu notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3599
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3600
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3601
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3602
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3603
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3604
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3605
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3606
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3607
isKindOfValueHolder:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3608
    "returns true if something is kind of vlaue holder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3609
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3610
    ^ ((something respondsTo:#value:) and:[something isBlock not])
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3611
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3612
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3613
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3614
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3615
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3616
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3617
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3618
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3619
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3620
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3621
    |nm x key|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3622
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3623
    "/ this is somewhat complicated: we have the symbolic key at hand,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3624
    "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3625
    "/
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3626
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3627
    (key := self shortcutKey) isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3628
        ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3630
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3631
    key isCharacter ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3632
        nm := key asString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3633
    ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3634
        nm := menuPanel device keyboardMap keyAtValue:key ifAbsent:key.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3635
        "/
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3636
        "/ some modifier-key combination ?
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3637
        "/
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3638
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3639
        (nm startsWith:#Cmd) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3640
            nm := (self shortcutKeyPrefixFor:#Cmd) , (nm copyFrom:4)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3641
        ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3642
            nm := (self shortcutKeyPrefixFor:#Alt) , (nm copyFrom:4)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3643
        ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3644
            nm := (self shortcutKeyPrefixFor:#Meta), (nm copyFrom:5)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3645
        ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3646
        ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3647
            nm := (self shortcutKeyPrefixFor:#Ctrl), (nm copyFrom:5)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3648
        ] ifFalse:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3649
            nm := nm asString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3650
        ]]]]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3651
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3652
    ^ Text string:nm emphasis:#bold
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3653
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3654
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3655
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3656
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3657
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3658
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3659
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3660
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3661
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3662
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3663
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3664
    m notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3665
        ^ m , '-'
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3666
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3667
    ^ aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3668
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3669
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3670
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3672
hideSubmenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3673
    "hide submenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3674
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3675
    |windowGrp subMenu|
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3676
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3677
    subMenu := self submenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3678
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3679
    subMenu realized ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3680
        menuPanel device unmapWindow:subMenu id
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3681
    ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3682
       subMenu hide
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3683
    ]
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3684
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3685
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3686
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3687
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3688
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3689
    ^ menuPanel selection == self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3690
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3691
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3692
openSubmenuAt:aPoint
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3693
    "open submenu at a point
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3694
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3695
    |windowGrp subMenu|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3696
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3697
    windowGrp := menuPanel topMenu windowGroup.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3698
    subMenu   := self setupSubmenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3699
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3700
    windowGrp notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3701
        subMenu windowGroup:windowGrp.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3702
        windowGrp addTopView:subMenu.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3703
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3704
    subMenu fixSize.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3705
    subMenu origin:aPoint.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3706
    subMenu makeFullyVisible.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3707
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3708
    subMenu realized ifFalse:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3709
        subMenu realize. 
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3710
    ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3711
        menuPanel topMenu device mapWindow:subMenu id.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3712
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3713
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3714
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3715
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3716
selected:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3717
    "change selection to a state. Dependant on the state open or hide an existing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3718
     submenu and perform a redraw
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3719
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3720
    |p d subMenu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3721
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3722
    subMenu := self submenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3723
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3724
    aState ifFalse:[
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3725
        self redraw.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3726
        subMenu notNil ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3727
            self hideSubmenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3728
        ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3729
      ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3730
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3731
    menuPanel shown ifFalse:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3732
    self redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3733
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3734
    subMenu isNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3735
        ^ menuPanel grabMouseAndKeyboard
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3736
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3737
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3738
    menuPanel verticalLayout ifTrue:[p := (layout right) @ (layout top)]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3739
                            ifFalse:[p := (layout left)  @ (layout bottom)].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3740
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3741
    d := menuPanel device.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3742
    p := d translatePoint:p from:(menuPanel id) to:(d rootWindowId).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3743
    self openSubmenuAt:p.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3744
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3745
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3746
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3747
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3748
!MenuPanel::Item::Adornment methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3749
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3750
accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3751
    "get the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3752
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3753
    ^ accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3754
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3755
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3756
accessCharacterPosition:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3757
    "set the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3758
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3759
    accessCharacterPosition := anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3760
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3761
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3762
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3763
    "ST/X goody; get argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3764
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3765
  ^ argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3766
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3767
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3768
argument:anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3769
    "ST/X goody; set argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3770
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3771
    argument := anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3772
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3773
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3774
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3775
    "get has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3776
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3777
  ^ indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3778
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3779
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3780
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3781
    "set has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3782
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3783
    indication := something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3784
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3785
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3786
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3787
    "get the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3788
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3789
  ^ shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3790
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3791
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3792
shortcutKey:aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3793
    "set the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3794
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3795
    shortcutKey := aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3796
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3797
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3798
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3799
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3800
version
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3801
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.22 1997-07-21 07:01:49 ca Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3802
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3803
MenuPanel initialize!