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