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