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