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