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