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