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