MenuPanel.st
author Claus Gittinger <cg@exept.de>
Thu, 19 Nov 1998 13:04:55 +0100
changeset 1177 cfd7f71639f3
parent 1164 e6e9633abf48
child 1181 97ee0869b374
permissions -rw-r--r--
checkin from browser
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
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
     3
	      All Rights Reserved
388
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
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    22
		buttonHalfShadowColor lastButtonSelected enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    23
		buttonEnteredBgColor'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    24
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    25
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    26
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    27
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    28
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    29
		DefaultFitFirstPanel RightArrowForm RightArrowShadowForm
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    30
		SelectionFrameBrightColor SelectionFrameDarkColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    31
		ButtonActiveLevel ButtonPassiveLevel ButtonActiveBackgroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    32
		ButtonPassiveBackgroundColor ButtonLightColor ButtonShadowColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    33
		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle Images
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		LigthenedImages ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    35
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    36
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    37
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    38
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    39
Object subclass:#Item
729
18395718ec8e lighten the icon & image of a disabled LabelAndIcon if the
ca
parents: 728
diff changeset
    40
	instanceVariableNames:'layout menuPanel subMenu adornment rawLabel disabledRawLabel
18395718ec8e lighten the icon & image of a disabled LabelAndIcon if the
ca
parents: 728
diff changeset
    41
		enableChannel nameKey accessCharacterPosition value label
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
    42
		rawImage activeHelpKey submenuChannel startGroup isButton
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
    43
		isVisible'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    44
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    45
		VerticalButtonInset LabelRightOffset ShortcutKeyOffset
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
    46
		IndicatorOn IndicatorOff'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    47
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    48
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    49
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    50
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    51
Object subclass:#Adornment
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    52
	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
    53
		choiceValue'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    54
	classVariableNames:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    55
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    56
	privateIn:MenuPanel::Item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    57
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    61
copyright
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    62
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    63
 COPYRIGHT (c) 1997 by eXept Software AG
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    64
	      All Rights Reserved
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    65
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    66
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    70
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    71
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    72
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    73
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    79
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    80
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    81
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    82
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    83
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    84
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    85
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    86
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    87
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
    [author:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    89
	Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
    [see also:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    92
	Menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    93
	MenuItem
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    94
	MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    95
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    96
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    97
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    98
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   100
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
    start as PullDownMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   103
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   105
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   107
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   108
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   110
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   114
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   122
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   126
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   127
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   130
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   132
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   138
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   140
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   141
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   142
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
    top open.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   144
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   146
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
    start as PopUpMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   148
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   149
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   151
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   152
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   153
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   155
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   156
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   157
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   158
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   159
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   160
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   161
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   162
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   163
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   164
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   165
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   166
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   167
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   168
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   169
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   170
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   171
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   172
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   173
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   174
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   175
    mview startUp
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   176
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   177
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   178
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   179
    start from menu spec
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   180
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   181
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   182
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   183
    menu := MenuPanel menu:
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   184
	#(#Menu #( #(#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   185
		    #label: 'File' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   186
		    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   187
		      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   188
				 (#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   189
				    #label: 'edit' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   190
				    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   191
				      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   192
						 #(#MenuItem #label: 'close' #value:#close)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   193
					       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   194
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   195
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   196
				       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   197
				  )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   198
				 #(#MenuItem #label: 'help' #value:#help )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   199
			       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   200
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   201
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   202
		       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   203
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   204
		#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   205
		#(#MenuItem #label: 'Bar' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   206
			    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   207
			       #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   208
					  #(#MenuItem #label: 'bar 2' #value:#bar2 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   209
					)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   210
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   211
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   212
				)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   213
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   214
	      ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   215
	      #( 2 )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   216
	      nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   217
	 ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   220
    Transcript showCR:(menu startUp).
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   221
										[exEnd]
388
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
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   226
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   227
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   229
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   230
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   231
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   232
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   233
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   234
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   235
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   236
    aSpec notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   237
	menu := Menu new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   238
	menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   239
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   240
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   241
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   243
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   244
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   245
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   246
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   247
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   251
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   252
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   253
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   254
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   261
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   262
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   263
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   264
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
    mview := self new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   274
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
    aReceiver notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   279
	mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   285
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   286
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   287
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   288
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   289
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   290
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   291
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   292
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   293
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   294
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   295
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   296
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   297
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   298
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   299
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   300
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   301
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   302
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   303
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   304
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   305
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   306
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   307
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   308
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   309
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   310
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   311
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   312
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   313
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   314
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   315
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   316
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   317
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   318
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   319
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   320
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   321
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   322
    |menuStyle style font|
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   323
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   324
    MenuView updateStyleCache.        
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   325
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   326
    menuStyle := MenuView styleSheet.
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   327
    menuStyle isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   328
        "make sure that style sheet is present"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   329
        MenuView updateStyleCache.        
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   330
        menuStyle := MenuView styleSheet.
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   331
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   332
    style := menuStyle name.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   333
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   334
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   335
    DefaultForegroundColor := menuStyle colorAt:'pullDownMenu.foregroundColor'.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   336
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   337
    DefaultForegroundColor isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   338
        DefaultForegroundColor := menuStyle colorAt:'menu.foregroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   339
                                            default:Color black.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   340
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   341
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   342
    (style == #motif or:[style == #iris]) ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   343
        DefaultBackgroundColor        := DefaultViewBackgroundColor.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   344
        DefaultHilightForegroundColor := DefaultForegroundColor.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   345
        DefaultHilightLevel     := 2.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   346
        DefaultLevel            := 0.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   347
    ] ifFalse:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   348
        (DefaultHilightLevel := menuStyle at:'pullDownMenu.hilightLevel') isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   349
            DefaultHilightLevel := menuStyle at:'menu.hilightLevel' default:0.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   350
        ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   351
        DefaultLevel           := menuStyle at:'pullDownMenu.level' default:1.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   352
        DefaultBackgroundColor := menuStyle colorAt:'pullDownMenu.backgroundColor'.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   353
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   354
        DefaultBackgroundColor isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   355
            DefaultBackgroundColor := menuStyle colorAt:'menu.backgroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   356
                                                default:DefaultViewBackgroundColor.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   357
        ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   358
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   359
        DefaultHilightForegroundColor := menuStyle colorAt:'pullDownMenu.hilightForegroundColor'.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   360
        DefaultHilightForegroundColor isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   361
            DefaultHilightForegroundColor := menuStyle colorAt:'menu.hilightForegroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   362
                                                       default:DefaultBackgroundColor
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   363
        ].
601
b0c2644b5982 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   364
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   365
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   366
    DefaultDisabledForegroundColor := menuStyle colorAt:'menu.disabledForegroundColor'.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   367
    DefaultDisabledForegroundColor isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   368
        DefaultDisabledForegroundColor := menuStyle colorAt:'button.disabledForegroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   369
                                                    default:Color darkGray.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   370
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   371
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   372
    style == #motif ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   373
        DefaultHilightBackgroundColor := DefaultBackgroundColor
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   374
    ] ifFalse:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   375
        DefaultHilightBackgroundColor := menuStyle colorAt:'pullDownMenu.hilightBackgroundColor'.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   376
        DefaultHilightBackgroundColor isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   377
            DefaultHilightBackgroundColor := menuStyle colorAt:'menu.hilightBackgroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   378
                                                       default:(menuStyle is3D ifFalse:[DefaultForegroundColor] ifTrue:[DefaultBackgroundColor]).
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   379
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   380
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   381
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   382
    DefaultGroupDividerSize := menuStyle at:'menu.groupDividerSize' default:6.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   383
    DefaultItemSpace        := menuStyle at:'menu.itemSpace' default:0.
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
   384
    DefaultButtonItemSpace  := menuStyle at:'menu.buttonItemSpace' default:0.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   385
    DefaultFitFirstPanel    := menuStyle at:'menu.fitFirstPanel' default:true.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   386
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   387
    MenuView updateStyleCache.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   388
    DefaultFont := MenuView defaultFont.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   389
"/    font := menuStyle fontAt:'pullDownMenu.font'.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   390
"/    font isNil ifTrue:[font := menuStyle fontAt:'menu.font'].
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   391
"/    DefaultFont := font.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   392
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   393
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   394
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   395
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   396
        RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   397
    ] ifFalse:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   398
        RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   399
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   400
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   401
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   402
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   403
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   404
    ButtonActiveLevel            :=  menuStyle at:'menu.buttonActiveLevel' default:(menuStyle is3D ifTrue:[-2] ifFalse:[0]).
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   405
    ButtonActiveLevel isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   406
        ButtonActiveLevel        :=  menuStyle at:'button.activeLevel' default:(menuStyle is3D ifTrue:[-2] ifFalse:[0]).
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   407
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   408
    ButtonPassiveLevel           :=  menuStyle at:'menu.buttonPassiveLevel'.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   409
    ButtonPassiveLevel isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   410
        ButtonPassiveLevel       :=  menuStyle at:'button.passiveLevel' default:(menuStyle is3D ifTrue:[2] ifFalse:[0]).
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   411
    ].
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   412
    ButtonActiveBackgroundColor  :=  menuStyle at:'button.activeBackgroundColor' default: DefaultBackgroundColor.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
   413
    ButtonPassiveBackgroundColor := (menuStyle at:'button.backgroundColor') ? (menuStyle at:'viewBackground') ? DefaultBackgroundColor.
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   414
    ButtonLightColor             := (menuStyle at:'button.lightColor') ? Color white.
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
   415
    ButtonShadowColor            := menuStyle at:'button.shadowColor' default:(style == #next ifTrue:[Color black] ifFalse:[Color gray]).
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   416
    ButtonHalfLightColor         :=  menuStyle at:'button.halfLightColor'.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   417
    ButtonHalfShadowColor        :=  menuStyle at:'button.halfShadowColor'.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   418
    ButtonEdgeStyle              :=  menuStyle at:'button.edgeStyle'.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
   419
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   420
    ButtonEnteredBackgroundColor := menuStyle colorAt:'menu.buttonEnteredBackgroundColor'.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   421
    ButtonEnteredBackgroundColor isNil ifTrue:[
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   422
        ButtonEnteredBackgroundColor := menuStyle colorAt:'button.enteredBackgroundColor'
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   423
                                                  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   424
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   425
    ButtonEnteredLevel := menuStyle at:'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   426
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   427
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   428
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   429
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   430
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   431
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   432
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   433
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   434
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   435
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   436
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   437
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   438
image:anImage onDevice:aDevice
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
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   441
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   442
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   443
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   444
    anImage device == aDevice ifTrue:[
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   445
        ^ anImage
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   446
    ].
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   447
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   448
    Images isNil ifTrue:[ Images := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   449
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   450
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   451
        Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   452
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   453
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   454
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   455
        ^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   456
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   457
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   458
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   459
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   460
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   461
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   462
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   463
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
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
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   467
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   468
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   469
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   470
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   471
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   472
    LigthenedImages isNil ifTrue:[ LigthenedImages := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   473
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   474
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   475
	LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   476
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   477
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   478
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   479
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   480
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   481
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   482
    ((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   483
	image := anImage copy lightened onDevice:aDevice.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   484
	image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   485
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   486
	image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   487
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   488
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   489
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   490
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   491
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   492
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   493
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   494
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   495
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   496
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   497
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   498
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   499
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   500
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   501
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   502
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   503
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   504
!MenuPanel methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   505
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   506
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   507
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   508
    "
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   509
    ^ self accept:(self selection)
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   510
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   511
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   512
accept:anItem
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   513
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   514
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   515
    |value item tgState itemIdx recv|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   516
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   517
    self superMenu notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   518
	^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   519
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
   520
    lastButtonSelected := nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   521
    self selection:nil.
420
ca
parents: 417
diff changeset
   522
    self forceUngrabMouseAndKeyboard.
ca
parents: 417
diff changeset
   523
ca
parents: 417
diff changeset
   524
    (anItem notNil and:[anItem canAccept]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   525
	tgState := anItem toggleIndication.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   526
	itemIdx := anItem menuPanel findFirst:[:el| el == anItem ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   527
	item    := anItem.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   528
	recv    := anItem menuPanel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   529
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   530
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   531
    self isPopUpView ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   532
	self do:[:el| el updateIndicators].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   533
	self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   534
    ] ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   535
	self destroy
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   536
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   537
    value := self accept:item index:itemIdx toggle:tgState receiver:recv.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   538
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   539
    self isPopUpView ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   540
	self menuAdornmentAt:#value put:value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   541
	self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   542
    ].
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
   543
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   544
  ^ item.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   545
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
   546
    "Modified: / 14.8.1998 / 16:10:02 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   547
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   548
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   549
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   550
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   551
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
   552
    |value argument numArgs isKindOfValueModel|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   553
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   554
    anItem isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   555
	self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   556
      ^ nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   557
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   558
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   559
    self menuAdornmentAt:#hasPerformed put:(aReceiver isKindOf:ValueModel).
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   560
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   561
    (value := anItem value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   562
	^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   563
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   564
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   565
    (argument := anItem argument) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   566
	argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   567
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   568
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   569
    value isSymbol ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   570
	(value respondsTo:#numArgs) ifTrue:[numArgs := value numArgs]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   571
				   ifFalse:[numArgs := 0].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   572
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   573
	numArgs == 0 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   574
	    value value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   575
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   576
	    numArgs == 1 ifTrue:[value value:argument]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   577
			ifFalse:[value value:argument value:self]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   578
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   579
	self menuAdornmentAt:#hasPerformed put:true.
524
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
    aReceiver isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   584
	^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   585
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   586
    isKindOfValueModel := aReceiver isKindOf:ValueModel.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   587
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   588
    (numArgs := value numArgs) == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   589
	isKindOfValueModel ifFalse:[aReceiver perform:value]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   590
			    ifTrue:[aReceiver value:value]
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   591
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   592
	numArgs == 1 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   593
	    isKindOfValueModel ifFalse:[aReceiver perform:value with:argument]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   594
				ifTrue:[aReceiver value:value value:argument]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   595
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   596
	    isKindOfValueModel ifFalse:[aReceiver perform:value with:argument with:self]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   597
				ifTrue:[aReceiver value:value value:argument value:self]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   598
	]
420
ca
parents: 417
diff changeset
   599
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   600
    self menuAdornmentAt:#hasPerformed put:true.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   601
  ^ value
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   602
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   603
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   604
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   605
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   606
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   607
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   608
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   609
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   610
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   611
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   612
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   613
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   614
"/    |top|
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   615
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   616
"/    top := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   617
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   618
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   619
"/        ^ self topMenu menuAdornmentAt:#value.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   620
"/    ].
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   621
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   622
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   623
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   624
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   625
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   626
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   627
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   628
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   629
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   630
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   631
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   632
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   633
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   634
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   635
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   636
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   637
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   638
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   639
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   640
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   641
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   642
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   643
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   644
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   645
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   646
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   647
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   648
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   649
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   650
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   651
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   652
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   653
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   654
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   655
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   656
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   657
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   658
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   659
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   660
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   661
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   662
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   663
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   664
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   665
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   666
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   667
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   668
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   669
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   670
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   671
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   672
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   673
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   674
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   675
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   676
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   677
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   678
    "return the item over which the mouse pointer is located;
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   679
     nil if the mouse is not over any item"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   680
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   681
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   682
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   683
    "Created: / 20.8.1998 / 13:12:34 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   684
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   685
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   686
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   687
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   688
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   689
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   690
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   691
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   692
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   693
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   694
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   695
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   696
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   697
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   698
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   699
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   700
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   701
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   702
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   703
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   704
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   705
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   706
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   707
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   708
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   709
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   710
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   711
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   712
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   713
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   714
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   715
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   716
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   717
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   718
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   719
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   720
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   721
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   722
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   723
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   724
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   725
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   726
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   727
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   728
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   729
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   730
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   731
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   732
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   733
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   734
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   735
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   736
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   737
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   738
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   739
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   740
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   741
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   742
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   743
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   744
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   745
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   746
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   747
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   748
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   749
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   750
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   751
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   752
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   753
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   754
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   755
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   756
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   757
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   758
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   759
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   760
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   761
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   762
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   763
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   764
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   765
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   766
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   767
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   768
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   769
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   770
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   771
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   772
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   773
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   774
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   775
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   776
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   777
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   778
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   779
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   780
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   781
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   782
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   783
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   784
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   785
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   786
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   787
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   788
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   789
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   790
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   791
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   792
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   793
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   794
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   795
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   796
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   797
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   798
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   799
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   800
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   801
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   802
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   803
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   804
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   805
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   806
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   807
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   808
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   809
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   810
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   811
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   812
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   813
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   814
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   815
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   816
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   817
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   818
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   819
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   820
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   821
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   822
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   823
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   824
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   825
!MenuPanel methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   826
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   827
disable
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   828
    "disable the menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   829
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   830
    self enabled:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   831
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   832
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   833
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   834
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   835
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   836
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   837
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   838
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   839
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   840
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   841
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   842
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   843
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   844
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   845
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   846
enable
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   847
    "enable the menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   848
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   849
    self enabled:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   850
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   851
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   852
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   853
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   854
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   855
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   856
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   857
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   858
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   859
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   860
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   861
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   862
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   863
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   864
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   865
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   866
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   867
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   868
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   869
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   870
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   871
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   872
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   873
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
   874
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   875
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   876
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   877
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   878
    self enabled == state ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   879
	^ self
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   880
    ].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   881
    enabled := state.
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   882
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   883
    self canDrawItem ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   884
	self do:[:anItem| anItem enabledStateOfMenuChangedTo:enabled]
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   885
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   886
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   887
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   888
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   889
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   890
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   891
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   892
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   893
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   894
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   895
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   896
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   897
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   898
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   899
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   900
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   901
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   902
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   903
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   904
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   905
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   906
!MenuPanel methodsFor:'accessing channels'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   907
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   908
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   909
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   910
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   911
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   912
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   913
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   914
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   915
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   916
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   917
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   918
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   919
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   920
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   921
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   922
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   923
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   924
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   925
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   926
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   927
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   928
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   929
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   930
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   931
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   932
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   933
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   934
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   935
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   936
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   937
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   938
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   939
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   940
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   941
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   942
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   943
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   944
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   945
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   946
!MenuPanel methodsFor:'accessing color & font'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   947
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   948
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   949
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   950
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   951
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   952
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   953
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   954
activeBackgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   955
    "set the background drawing color used to highlight selection. You should not 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   956
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   957
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   958
    activeBgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   959
	activeBgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   960
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   961
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   962
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   963
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   964
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   965
    "Modified: / 6.6.1998 / 19:49:46 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   966
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   967
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   968
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   969
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   970
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   971
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   972
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   973
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   974
activeForegroundColor:aColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   975
    "set the foreground color used to highlight selections; You should not
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   976
     use this method; instead leave the value as defined in the styleSheet.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   977
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   978
    activeFgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   979
	activeFgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   980
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   981
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   982
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   983
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   984
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   985
    "Modified: / 6.6.1998 / 19:50:01 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   986
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   987
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   988
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   989
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   990
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   991
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   992
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   993
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   994
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   995
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   996
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   997
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   998
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   999
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1000
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1001
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1002
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1003
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1004
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1005
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1006
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1007
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1008
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1009
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1010
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1011
    ^ButtonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1012
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1013
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1014
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1015
    "get the button edge style
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1016
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1017
    ^ButtonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1018
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1019
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1020
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1021
    "get the background drawing color used to highlight entered button items
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1022
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1023
    ^ buttonEnteredBgColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1024
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1025
    "Created: / 20.8.1998 / 13:53:37 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1026
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1027
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1028
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1029
    "get the 3D-level used to highlight entered button items
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1030
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1031
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1032
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1033
    "Created: / 20.8.1998 / 13:53:46 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1034
    "Modified: / 20.8.1998 / 15:49:32 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1035
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1036
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1037
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1038
    "get the background drawing color used to half light button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1039
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1040
    ^buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1041
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1042
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1043
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1044
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1045
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1046
    ^buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1047
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1048
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1049
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1050
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1051
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1052
    ^buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1053
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1054
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1055
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1056
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1057
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1058
    ^ButtonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1059
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1060
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1061
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1062
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1063
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1064
    ^buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1065
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1066
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1067
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1068
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1069
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1070
  ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1071
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1072
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1073
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1074
disabledForegroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1075
    "set the foregroundColor drawing color used by disabled items. You should not
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1076
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1077
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1078
    disabledFgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1079
	disabledFgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1080
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1081
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1082
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1083
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1084
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1085
    "Modified: / 6.6.1998 / 19:50:17 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1086
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1087
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1088
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1089
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1090
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1091
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1092
	super font:(aFont on:device).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1093
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1094
	superMenu notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1095
	    self extent:(self preferredExtent)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1096
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1097
	self mustRearrange.
390
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
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1102
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1103
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1104
  ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1105
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1106
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1107
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1108
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1109
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1110
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1111
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1112
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1113
    fgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1114
	fgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1115
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1116
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1117
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1118
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1119
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1120
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1121
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1122
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1123
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1124
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1125
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1126
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1127
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1128
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1129
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1130
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1131
lightColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1132
    "set the light drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1133
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1134
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1135
    lightColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1136
	super lightColor:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1137
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1138
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1139
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1140
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1141
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1142
    "Modified: / 6.6.1998 / 19:50:39 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1143
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1144
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1145
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1146
    "get the selection frame bright color
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
    ^selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1149
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1150
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1151
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1152
    "get the selection frame dark color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1153
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1154
    ^selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1155
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1156
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1157
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1158
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1159
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1160
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1161
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1162
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1163
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1164
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1165
shadowColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1166
    "set the shadow drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1167
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1168
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1169
    shadowColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1170
	super shadowColor:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1171
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1172
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1173
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1174
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1175
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1176
    "Modified: / 6.6.1998 / 19:50:32 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1177
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1178
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1179
!MenuPanel methodsFor:'accessing dimensions'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1180
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1181
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1182
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1183
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1184
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1185
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1186
    (explicitExtent ~~ true) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1187
	(item := self itemAt:1) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1188
	    self rearrangeItems.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1189
	  ^ item height
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1190
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1191
	^ 4 + (font height + (font descent * 2)).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1192
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1193
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1194
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1195
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1196
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1197
    "compute and returns my preferred extent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1198
    "
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1199
    |x y hasMenu shCtKey space hrzInset|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1200
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1201
    self numberOfItems == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1202
	^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1203
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1204
    space := (items size + 1) * itemSpace.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1205
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1206
    self isFitPanel ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1207
	x := 0
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1208
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1209
	x := groupSizes size * groupDividerSize.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1210
    ].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1211
    hrzInset := items first horizontalInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1212
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1213
    self verticalLayout ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1214
	"/ horizontal - add x-extents; take max of y-extents
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1215
	y := 0.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1216
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1217
	self do:[:el| |elY elPref|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1218
	    el isVisible ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1219
		elPref := el preferredExtent.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1220
		x := x + elPref x.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1221
		elY := elPref y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1222
		el isButton ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1223
		    elY := elY + (2 * DefaultButtonItemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1224
		    x := x + (2 * DefaultButtonItemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1225
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1226
		y := y max:elY.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1227
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1228
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1229
	x := x + space.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1230
    ] ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1231
	"/ vertical - add y-extents
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1232
	hasMenu := false.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1233
	shCtKey := 0.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1234
	y := x.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1235
	x := 0.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1236
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1237
	self do:[:el| |l e|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1238
	    el isVisible ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1239
		(l := el rawLabel) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1240
		    (e := l widthOn:self) > x ifTrue:[x := e].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1241
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1242
		    (el hasSubmenu or:[el submenuChannel notNil]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1243
			hasMenu := true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1244
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1245
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1246
		    (     (l := el shortcutKeyAsString) notNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1247
		     and:[(e := l widthOn:self) > shCtKey]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1248
		    ) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1249
			shCtKey := e
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1250
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1251
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1252
		y := y + el preferredExtent y
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1253
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1254
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1255
	x := x + hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1256
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1257
	(hasMenu or:[shCtKey ~~ 0]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1258
	    shortKeyInset := x + Item labelRightOffset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1259
	    x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1260
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1261
	    (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1262
		x := x + (Item shortcutKeyOffset) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1263
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1264
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1265
	y := y + space.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1266
	x := x + hrzInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1267
    ].
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  1268
    ^ (x @ y) + (margin + margin)
1095
44b55760239b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1093
diff changeset
  1269
44b55760239b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1093
diff changeset
  1270
    "Modified: / 24.8.1998 / 19:16:02 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1271
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1272
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1273
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1274
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1275
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1276
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1277
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1278
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1279
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1280
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1281
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1282
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1283
!MenuPanel methodsFor:'accessing items'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1285
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1286
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1287
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1288
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1289
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1290
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1291
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1292
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1293
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1294
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1295
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1297
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1298
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1299
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1301
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1302
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1303
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1304
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1305
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1306
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1307
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1308
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1309
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1310
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1311
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1312
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1313
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1314
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1315
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1316
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1317
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1318
    ^ items notNil ifTrue:[items at:anIndex ifAbsent:nil] ifFalse:[nil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1319
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1320
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1321
!MenuPanel methodsFor:'accessing look'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1322
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1323
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1324
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1325
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1326
    ^ButtonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1327
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1328
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1329
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1330
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1331
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1332
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1333
    ^ButtonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1334
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1335
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1336
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1337
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1338
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1339
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1340
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1341
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1342
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1343
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1344
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1345
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1346
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1347
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1348
    (fitFirstPanel == aState or:[self isPopUpView]) ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1349
	fitFirstPanel := aState.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1350
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1351
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1352
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1353
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1354
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1355
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1356
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1357
  ^ groupDividerSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1358
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1359
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1360
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1361
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1362
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1363
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1364
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1365
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1366
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1367
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1368
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1369
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1370
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1371
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1372
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1373
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1374
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1375
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1376
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1377
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1378
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1379
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1380
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1381
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1382
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1383
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1384
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1385
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1386
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1387
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1388
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1389
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1390
level:anInt
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1391
    super level:anInt.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1392
    mustRearrange := true
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1393
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1394
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1395
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1396
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1397
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1398
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1399
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1400
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1401
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1402
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1403
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1404
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1405
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1406
  ^ self menuAdornmentAt:#showGroupDivider
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1407
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1408
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1409
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1410
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1411
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1412
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1413
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1414
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1415
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1416
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1417
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1418
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1419
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1420
  ^ self menuAdornmentAt:#showSeparatingLines
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1421
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1422
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1423
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1424
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1425
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1426
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1427
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1428
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1429
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1430
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1431
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1432
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1433
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1434
  ^ self menuAdornmentAt:#verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1435
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1436
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1437
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1438
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1439
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1440
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1441
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1442
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1443
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1444
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1445
!MenuPanel methodsFor:'accessing submenu'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1446
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1447
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1448
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1449
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1450
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1451
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1452
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1453
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1454
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1455
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1456
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1457
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1458
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1459
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1460
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1461
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1462
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1463
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1464
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1465
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1466
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1467
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1468
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1469
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1470
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1471
!MenuPanel methodsFor:'activation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1472
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1473
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1475
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1476
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1477
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1478
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1479
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1480
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1481
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1482
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1483
show
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1484
    "realize the view at its last position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1485
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1486
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1487
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1488
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1489
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
showAt:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1491
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1492
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1493
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1494
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1495
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1496
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1497
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1498
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1499
    "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
  1500
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1501
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1502
     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
  1503
     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
  1504
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1505
    "
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1506
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1507
    self rearrangeItems.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1508
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1509
    aBoolean ifTrue:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1510
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1511
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1512
    self origin:aPoint.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1513
    self makeFullyVisible.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1514
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1515
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1516
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1517
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1518
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1519
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1520
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1521
    ].
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1522
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1523
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1524
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1525
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1526
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1527
showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1528
    "realize the view at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1529
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1530
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1531
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1532
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1533
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1534
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1535
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1536
    "make myself visible at the screen center.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1537
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1538
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1539
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1540
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1541
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1542
    ^ self showAt:(top origin + (aView originRelativeTo:top) + (aView extent // 2) - (self extent // 2))
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1543
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1544
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1545
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1546
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1547
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1548
    "realize the menu at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1549
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1550
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1551
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1552
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1553
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1554
    "realize the menu at aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1555
    "
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1556
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1557
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1558
    "Created: / 21.5.1998 / 14:15:57 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1559
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1560
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1561
!MenuPanel methodsFor:'active help'!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1562
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1563
helpText
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1564
    |appl item key|
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1565
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1566
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1567
	(key := item activeHelpKey) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1568
	    (appl := self application) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1569
		^ appl helpTextForKey:key.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1570
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1571
	]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1572
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1573
    ^ nil.
1039
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  1574
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  1575
    "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
  1576
!
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1577
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1578
helpTextAt:aPoint
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1579
    |menu point item key appl|
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1580
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1581
    menu := self superMenuAtX:aPoint x y:aPoint y.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1582
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1583
    menu isNil ifTrue:[
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1584
"/        'nil menu' printCR.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1585
	^ ''
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1586
    ].
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1587
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1588
    point := self translatePoint:aPoint to:menu.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1589
    item  := menu itemAtX:(point x) y:(point y).
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1590
    item  notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1591
	(key := item activeHelpKey) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1592
	    (appl := self application) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1593
		^ appl helpTextForKey:key.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1594
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1595
	]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1596
    ].
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1597
"/    'nil item' printCR.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1598
    ^ nil.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  1599
1039
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  1600
    "Modified: / 31.7.1998 / 03:15:07 / cg"
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1601
! !
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  1602
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1603
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1604
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1605
createAtIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1606
    "create an item and add this item to the index. In case of nil the item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1607
     is added to the end. If the index is not valid nil is returned otherwise
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
     the new created item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1609
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1610
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1611
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1612
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1613
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
    anIndexOrNil notNil ifTrue:[
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1615
        (anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1616
            ^ nil
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1617
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1618
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1619
    items isNil ifTrue:[
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1620
        items := OrderedCollection new
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1621
    ] ifFalse:[
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1622
        items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1623
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1624
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1625
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1626
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1627
        items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
    ] ifFalse:[
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1629
        items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1630
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1631
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1632
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1633
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1634
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1635
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1636
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1637
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1638
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1639
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1640
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1641
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1642
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1643
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1644
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1645
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1646
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1647
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1649
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1650
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1651
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1652
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1653
	self selection:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1654
	groupSizes := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1655
	self do:[:el| el destroy ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1656
	items := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1657
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1658
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1659
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1660
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1661
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1662
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1663
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1664
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1665
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1666
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1667
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1668
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1669
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1670
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1671
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1672
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1673
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1674
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1675
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1676
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1677
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1678
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1679
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1680
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1681
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1682
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1683
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1684
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1685
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1686
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1687
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1688
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1689
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1690
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1691
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1692
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1693
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1694
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1695
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1696
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1697
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1698
	|menu newItems|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1699
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1700
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1701
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1702
	(menu := aMenu) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1703
	    (aMenu isCollection) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1704
		menu := Menu new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1705
		menu fromLiteralArrayEncoding:aMenu.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1706
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1707
		menu receiver notNil ifTrue:[receiver := menu receiver]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1708
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1709
	    (newItems := menu menuItems) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1710
		items := newItems collect:[:ni | 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1711
				|i|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1712
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1713
				i:= Item in:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1714
				i menuItem:ni.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1715
				i.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1716
			    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1717
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1718
	    self groupSizes:(menu groupSizes).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1719
	]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1720
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1721
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1722
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1723
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1729
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1730
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1731
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1732
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1733
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1734
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1735
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1736
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1737
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1738
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1739
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1740
drawButtonEdgesInLayout: layout withLevel: aLevel selected:isSelected
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1741
    |shadow|
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1742
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1743
    styleSheet is3D ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1744
	^ self displayRectangle:layout.
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1745
    ].
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1746
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1747
    shadow := buttonShadowColor.
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1748
    isSelected ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1749
	buttonShadowColor == self buttonActiveBackgroundColor ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1750
	    shadow := self buttonActiveBackgroundColor darkened
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1751
	].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1752
    ].
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1753
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1754
    self drawEdgesForX: layout left y: layout top width: layout width height: layout height level: aLevel 
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1755
	shadow:      shadow 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1756
	light:       buttonLightColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1757
	halfShadow:  buttonHalfShadowColor 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1758
	halfLight:   buttonHalfLightColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1759
	style:       ButtonEdgeStyle
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1760
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1761
    "Created: / 20.8.1998 / 15:43:38 / cg"
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1762
    "Modified: / 20.8.1998 / 19:09:05 / cg"
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1763
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1764
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1765
drawEdgesForX:x y:y width:w height:height isSelected:selectedBool isEntered:enteredBool
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1766
    |level|
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1767
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1768
    level := selectedBool 
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1769
		ifTrue:[onLevel] 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1770
		ifFalse:[offLevel].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1771
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1772
    level ~~ 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1773
	self drawEdgesForX:x y:y width:w height:height level:level
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1774
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1775
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1776
    "Modified: / 20.8.1998 / 15:43:11 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1777
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1778
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1779
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1780
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1781
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1782
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1783
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1784
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1785
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1786
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1787
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1788
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1789
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1790
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1791
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1792
rearrangeGroups
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1793
    |layout
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1794
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1795
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1796
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1797
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1798
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1799
	^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1800
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1801
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1802
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1803
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1804
    (dltX := width - margin "- 2" - layout right) <= 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1805
	^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1806
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1807
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1808
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1809
    start == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1810
	^ self  "/ no item detected
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1811
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1812
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1813
    "/ change layout
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1814
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1815
    items from:start do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1816
	anItem isVisible ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1817
	    layout := anItem layout.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1818
	    layout  left:(layout  left + dltX).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1819
	    layout right:(layout right + dltX).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1820
	]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1821
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1822
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1823
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1824
rearrangeItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1825
    "recompute layout of my items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1826
    "
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1827
    |expLast e grpDivSz layout isVert
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1828
     x  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1829
     y  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1830
     noItems "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1831
    |
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1832
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1833
    mustRearrange ifFalse:[ ^ self ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1834
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1835
"/  fetch font from superMenu
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1836
    (superMenu notNil and:[superMenu font ~~ font]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1837
	super font:(superMenu font on:device)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1838
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1839
    (noItems := items size) == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1840
	mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1841
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1842
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1843
    expLast  := false.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1844
    isVert   := self verticalLayout.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1845
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1846
    self hasGroupDividers ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1847
	self isFitPanel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1848
	    grpDivSz := groupDividerSize
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1849
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1850
	    expLast := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1851
	    x := margin.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1852
	    e := self computeExtent.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1853
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1854
	    isVert ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1855
		items do:[:el | x := x + el preferredExtent y].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1856
		y := e y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1857
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1858
		items do:[:el|x := x + el preferredExtent x].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1859
		y := e x.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1860
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1861
	    x := x + (noItems + 1 * itemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1862
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1863
	    (grpDivSz := (y - x) // (groupSizes size)) <= 0 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1864
		grpDivSz := nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1865
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1866
	    x > (width-margin) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1867
		grpDivSz := nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1868
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1869
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1870
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1871
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1872
    (self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1873
	e := self preferredExtent copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1874
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1875
	self isPopUpView ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1876
	    isVert ifTrue:[e y:1.0]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1877
		  ifFalse:[e x:1.0]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1878
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1879
	self extent:e
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1880
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1881
	e := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1882
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1883
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1884
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1885
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1886
    isVert ifTrue:[y := y + itemSpace]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1887
	  ifFalse:[x := x + itemSpace].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1888
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1889
    self keysAndValuesDo:[:anIndex :el| |org corn elPref|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1890
	el isVisible ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1891
	    el isButton ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1892
		org := Point x:(x+DefaultButtonItemSpace) y:(y+DefaultButtonItemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1893
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1894
		org := Point x:x y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1895
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1896
	    elPref := el preferredExtent.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1897
	    isVert ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1898
		y := y + elPref y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1899
		corn := (e x - margin @ y).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1900
		el isButton ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1901
		    corn := corn - (DefaultButtonItemSpace @ 0).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1902
		    el layout:(Rectangle origin:org corner:corn).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1903
		    y := y + (2 * DefaultButtonItemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1904
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1905
		    el layout:(Rectangle origin:org corner:corn).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1906
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1907
		y := y + itemSpace.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1908
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1909
		x := x + elPref x.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1910
		el isButton ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1911
		    x := x + DefaultButtonItemSpace.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1912
		    corn := (x @ (e y - margin)).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1913
		    corn := corn - (0 @ DefaultButtonItemSpace).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1914
		    el layout:(Rectangle origin:org corner:corn).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1915
		    x := x + DefaultButtonItemSpace.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1916
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1917
		    corn := (x @ e y).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1918
		    el layout:(Rectangle origin:org corner:corn).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1919
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1920
		x := x + itemSpace.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1921
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1922
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1923
	    (grpDivSz notNil and:[self hasGroupDividerAt:anIndex]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1924
		isVert ifTrue:[y := y + grpDivSz]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1925
		      ifFalse:[x := x + grpDivSz]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1926
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1927
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1928
	    org := Point x:x y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1929
	    el layout:(Rectangle origin:org corner:org)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1930
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1931
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1932
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1933
    expLast ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1934
	e := items last.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1935
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1936
	e isVisible ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1937
	    layout := items last layout.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1938
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1939
	    isVert ifTrue:[layout bottom:((self extent y) + 1)]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1940
		  ifFalse:[layout  right:((self extent x) + 1)].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1941
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1942
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1943
    self rearrangeGroups.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1944
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1945
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1946
    "Modified: / 20.8.1998 / 19:34:41 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1947
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1948
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1949
redrawX:x y:y width:w height:h
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1950
    "redraw a rectangle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1951
    "
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1952
    |start end isVrt x1 x2 y1 y2 item layout lnSz hrzInset prevClipArea|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1953
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1954
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1955
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
    self  paint:(self backgroundColor).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1957
    self  clearRectangleX:x y:y width:w height:h.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1958
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1959
    isVrt := self verticalLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1960
    end   := items size.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1961
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1962
    mustRearrange ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1963
	self isPopUpView not ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1964
	    explicitExtent := true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1965
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1966
	self rearrangeItems.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1967
	start := 1
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1968
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1969
	end == 0 ifTrue:[ ^ self ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1970
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1971
	isVrt ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1972
	    start := self findFirst:[:el| (el layout bottom) >= y ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1973
	    start == 0 ifTrue:[ ^ self ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1974
	    end := y + h.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1975
	    end := self findLast:[:el| (el layout top) < end ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1976
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1977
	    start := self findFirst:[:el| (el layout right) >= x ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1978
	    start == 0 ifTrue:[ ^ self ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1979
	    end := x + w.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1980
	    end := self findLast:[:el| (el layout left) < end ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1981
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1982
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1983
	(start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1984
	    start := start - 1
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1985
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1986
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1987
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1988
    (     self hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1989
     and:[self showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1990
     and:[self isFitPanel not]]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1991
    ) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1992
	lnSz := groupDividerSize // 2
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1993
    ].
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  1994
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1995
    end == 0 ifTrue:[^ self ].
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1996
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1997
    hrzInset := items first horizontalInset.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1998
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1999
    prevClipArea   := clipRect.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2000
    clipRect       := nil.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2001
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2002
    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
  2003
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2004
    start to:end do:[:i|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2005
	item := items at:i.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2006
	item redraw.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2007
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2008
	(lnSz notNil and:[self hasGroupDividerAt:i]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2009
	    layout := item layout.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2010
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2011
	    isVrt ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2012
		x1 := layout left  + hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2013
		x2 := layout right - hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2014
		y1 := (layout bottom) + lnSz.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2015
		y2 := y1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2016
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2017
		x1 := (layout right) + lnSz.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2018
		x2 := x1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2019
		y1 := layout top.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2020
		y2 := layout bottom.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2021
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2022
	    self paint:(self shadowColor).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2023
	    self displayLineFromX:x1 y:y1 toX:x2 y:y2.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2024
	    self paint:(self lightColor).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2025
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2026
	    isVrt ifTrue:[y1 := y1 + 1. y2 := y1 ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2027
		 ifFalse:[x1 := x1 + 1. x2 := x1 ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2028
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2029
	    self displayLineFromX:x1 y:y1 toX:x2 y:y2
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2030
	]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2031
    ].
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2032
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2033
    clipRect := nil.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2034
    prevClipArea isNil ifTrue:[device noClipIn:drawableId  gc:gcId]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2035
		      ifFalse:[self clippingRectangle:prevClipArea].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2036
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2037
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2038
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2039
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2040
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2041
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2042
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2043
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2044
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2045
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2046
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2047
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2048
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2049
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2050
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2051
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2052
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2053
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2054
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2055
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2056
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2057
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2058
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2059
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2060
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2061
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2062
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2063
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2064
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2065
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2066
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2067
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2068
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2069
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2070
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2071
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2072
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2073
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2074
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2075
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2076
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2077
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2078
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2079
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2080
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2081
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2082
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2083
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2084
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2085
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2086
    i := self findFirst:[:el|(el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2087
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2088
    i ~~ 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2089
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2090
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2091
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2092
    something isSymbol ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2093
	i := self findFirst:[:el|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2094
	    v := el value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2095
	    v isSymbol and:[v == something]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2096
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2097
	i ~~ 0 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2098
	    ^ i
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2099
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2100
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2101
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2102
    (something respondsTo:#string) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2103
	v := something string.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2104
      ^ self findFirst:[:el|el textLabel = v].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2105
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2106
  ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2107
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2108
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2109
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2110
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2111
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2112
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2113
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2114
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2116
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2117
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2118
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2120
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2121
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2122
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2123
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2124
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2125
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2126
    "
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2127
    |menu point sensor sel|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2128
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2129
    (    (sensor := self sensor) notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2130
     and:[sensor hasButtonMotionEventFor:nil]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2131
    ) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2132
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2133
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2134
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2135
    sensor anyButtonPressed ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2136
	"/ TODO: remember item over which pointer is
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2137
	"/ (for enteredFG/enteredBG/enteredLevel handling)
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2138
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2139
        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2140
	(buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2141
	or:[ButtonEnteredLevel ~~ ButtonPassiveLevel]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2142
	    (self containsPointX:x y:y) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2143
		((sel := self itemAtX:x y:y) notNil 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2144
		and:[sel isButton 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2145
		and:[superMenu isNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2146
		and:[sel canSelect]]]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2147
		    self itemEntered:sel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2148
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2149
		    self itemEntered:nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2150
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2151
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2152
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2153
	^ self
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2154
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2155
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2156
    "/ ok, a button is pressed.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2157
    (buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2158
    or:[ButtonEnteredLevel ~~ ButtonPassiveLevel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2159
	self itemEntered:nil.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2160
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2161
1044
3584c06b9e44 add button behaviour:
ca
parents: 1039
diff changeset
  2162
    lastButtonSelected notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2163
	^ self
1044
3584c06b9e44 add button behaviour:
ca
parents: 1039
diff changeset
  2164
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2165
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2166
    (self containsPointX:x y:y) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2167
	((sel := self itemAtX:x y:y) notNil and:[sel isButton and:[superMenu isNil]]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2168
	    sel canSelect ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2169
		lastButtonSelected := sel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2170
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2171
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2172
	^ self selection:sel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2173
    ].
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2174
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2175
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2176
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2177
    menu isNil ifTrue:[
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2178
       ^ self selection:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2179
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2180
    point := self translatePoint:(x@y) to:menu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2181
    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
  2182
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  2183
    "Modified: / 22.8.1998 / 12:51:17 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2184
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2185
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2186
buttonPress:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2187
    "any button pressed; open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2188
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2189
    |menu point item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2190
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2191
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2192
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2193
    menu isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2194
	menu := self topMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2195
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2196
	point := self translatePoint:(x@y) to:menu.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2197
	item  := menu itemAtX:(point x) y:(point y)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2198
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2199
    menu selection:item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2200
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2201
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2202
buttonRelease:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2203
    "button release action; accept selection and close all views
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2204
    "
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2205
    |menu item|
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2206
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2207
    menu := self topMenu activeMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2208
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2209
    (    menu hasSelection
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2210
     or:[menu isPopUpView not
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2211
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2212
				and:(menu mapTime)) > 200]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
    ) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2214
	item := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2215
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2216
	(     (menu := self superMenuAtX:x y:y) notNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2217
	 and:[(item := menu selection) notNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2218
	 and:[item submenu notNil]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2219
	) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2220
	    menu selection:nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2221
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2222
	    (    lastButtonSelected isNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2223
	     or:[item isNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2224
	     or:[(menu itemAtX:x y:y) == lastButtonSelected]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2225
	    ) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2226
		item := nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2227
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2228
	    self topMenu accept:item
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2229
	]
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2230
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2231
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2232
    "Modified: / 27.2.1998 / 17:41:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2233
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2234
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2235
cursorPressed:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2236
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2237
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2238
    |next submenu item
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2239
     n     "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2240
     idx   "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2241
     first "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2242
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2243
    (self hasSelection not and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2244
	^ superMenu cursorPressed:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2245
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2246
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2247
    self verticalLayout ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2248
	aKey == #CursorLeft  ifTrue:[^ self selection:nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2249
	aKey ~~ #CursorRight ifTrue:[next := aKey == #CursorDown].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2250
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2251
	aKey == #CursorUp ifTrue:[^ self selection:nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2252
	aKey ~~ #CursorDown ifTrue:[next := aKey == #CursorRight].        
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2253
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2254
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2255
    next isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2256
	(item := self selection) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2257
	    (submenu := item submenu) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2258
		idx := submenu findFirst:[:el| el canSelect ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2259
	      ^ submenu selectionIndex:idx
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2260
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2261
	  ^ self selection:nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2262
	].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2263
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2264
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2265
    first := self findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2266
    first == 0 ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2267
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2268
    idx := self selectionIndex.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2269
    n   := 1 + (self sensor compressKeyPressEventsWithKey:aKey).
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2270
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2271
    n timesRepeat:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2272
	next ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2273
	    [((idx := idx + 1) <= items size and:[(items at:idx) canSelect not])
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2274
	    ] whileTrue.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2275
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2276
	    idx > items size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2277
		idx := first
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2278
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2279
	] ifFalse:[    
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2280
	    [((idx := idx - 1) > 0  and:[(items at:idx) canSelect not])
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2281
	    ] whileTrue.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2282
            
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2283
	    idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2284
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2285
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2286
    self selectionIndex:idx
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2287
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2288
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2289
itemEntered:anItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2290
    |prevEnteredItem|
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2291
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2292
    anItem == enteredItem ifTrue:[^ self].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2293
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2294
    prevEnteredItem := enteredItem.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2295
    enteredItem := anItem.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2296
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2297
    prevEnteredItem notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2298
	prevEnteredItem redraw
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2299
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2300
    enteredItem notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2301
	enteredItem redraw
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2302
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2303
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2304
    "Created: / 20.8.1998 / 13:18:23 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2305
    "Modified: / 20.8.1998 / 14:03:55 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2306
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2307
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2308
keyPress:key x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2309
    "any key is pressed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2310
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2311
    |listOfItems item menu idx cIdx upperKey lowerKey rawKey|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2312
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2313
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2314
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2315
    [ menu shown ] whileFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2316
	(menu := superMenu) isNil ifTrue:[^ self]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2317
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2318
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2319
    key == #Return ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2320
	^ menu accept
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2321
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2322
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2323
    (     key == #CursorDown or:[key == #CursorUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2324
      or:[key == #CursorLeft or:[key == #CursorRight]]]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2325
    ) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2326
	^ menu cursorPressed:key
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2327
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2328
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2329
    rawKey := device keyboardMap keyAtValue:key ifAbsent:key.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2330
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2331
    listOfItems := self selectItemsForShortcutKey:rawKey.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2332
    listOfItems isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2333
	listOfItems := self selectItemsForShortcutKey:key.
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2334
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2335
    listOfItems notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2336
	item := listOfItems first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2337
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2338
	item hasSubmenu ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2339
	    ^ menu accept:item
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2340
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2341
	^ self openMenusFromItems:listOfItems
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2342
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2343
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2344
    (self hasSelection not and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2345
	(superMenu containsPoint:(self translatePoint:(x@y) to:superMenu)) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2346
	    menu := superMenu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2347
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2348
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2349
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2350
    cIdx := menu selectionIndex.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2351
    cIdx isNil ifTrue:[cIdx := 0].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2352
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2353
    upperKey := key asUppercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2354
    lowerKey := key asLowercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2355
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2356
    menu keysAndValuesDo:[:anIndex :el| |c l|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2357
	(el canSelect and:[(l := el textLabel) notNil]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2358
	    l size ~~ 0 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2359
		(c := el accessCharacter) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2360
		    (c == upperKey or:[c == lowerKey]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2361
			^ menu selection:el
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2362
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2363
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2364
		    ((c := l first) == upperKey or:[c == lowerKey]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2365
			anIndex > cIdx ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2366
			    ^ menu selection:el
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2367
			] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2368
			    idx isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2369
				idx := anIndex
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2370
			    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2371
				anIndex > idx ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2372
				    anIndex ~~ cIdx ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2373
					idx := anIndex
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2374
				    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2375
				]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2376
			    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2377
			]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2378
                        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2379
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2380
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2381
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2382
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2383
    ].
417
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2384
    (item := menu itemAt:idx) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2385
	menu hasSelection ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2386
	    (menu := menu superMenu) isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2387
		^ super keyPress:key x:x y:y
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2388
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2389
	]
417
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2390
    ].
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2391
    menu selection:item.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2392
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2393
    "Modified: / 8.8.1998 / 13:38:36 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2394
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2395
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2396
pointerLeave:state
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2397
    self itemEntered:nil.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2398
    super pointerLeave:state
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2399
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2400
    "Created: / 20.8.1998 / 14:04:29 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2401
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2402
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2403
sizeChanged:how
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2404
    self isFitPanel ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2405
	self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2406
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2407
    super sizeChanged:how
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2408
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2409
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2410
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2411
420
ca
parents: 417
diff changeset
  2412
forceUngrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2413
    "ungrab resources (mouse and keyboard)
420
ca
parents: 417
diff changeset
  2414
    "
ca
parents: 417
diff changeset
  2415
    |sensor|
ca
parents: 417
diff changeset
  2416
ca
parents: 417
diff changeset
  2417
    device ungrabPointer.
ca
parents: 417
diff changeset
  2418
ca
parents: 417
diff changeset
  2419
    (sensor := self sensor) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2420
	"/ make certain all X events have been received
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2421
	device sync.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2422
	"/ now all events have been received.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2423
	"/ now, flush all pointer events
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2424
	sensor flushKeyboardFor:nil
420
ca
parents: 417
diff changeset
  2425
    ].
ca
parents: 417
diff changeset
  2426
    device ungrabKeyboard.
ca
parents: 417
diff changeset
  2427
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2428
    "Modified: / 2.2.1998 / 09:24:48 / stefan"
420
ca
parents: 417
diff changeset
  2429
!
ca
parents: 417
diff changeset
  2430
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2431
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2432
    "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
  2433
     Only used for popUp menus."
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2434
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2435
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2436
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2437
    realized ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2438
	sensor := self sensor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2439
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2440
	device activePointerGrab ~~ self ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2441
	    sensor notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2442
		sensor flushMotionEventsFor:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2443
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2444
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2445
	    (device grabPointerInView:self) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2446
		Delay waitForSeconds:0.1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2447
		(device grabPointerInView:self) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2448
		    "give up"
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2449
		    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2450
		    self unmap
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2451
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2452
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2453
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2454
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2455
	device activeKeyboardGrab ~~ self ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2456
	    sensor notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2457
		device sync.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2458
		sensor flushKeyboardFor:nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2459
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2460
	    device grabKeyboardInView:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2461
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2462
	    superMenu notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2463
		self getKeyboardFocus
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2464
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2465
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2466
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2467
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2468
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2469
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2470
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2471
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2472
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2473
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2474
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2475
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2476
    device activePointerGrab == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2477
	device ungrabPointer.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2478
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2479
    device activeKeyboardGrab == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2480
	sensor := self sensor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2481
	sensor notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2482
	    "/ make certain all X events have been received
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2483
	    device sync.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2484
	    "/ now all events have been received.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2485
	    "/ now, flush all pointer events
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2486
	    sensor flushKeyboardFor:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2487
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2488
	device ungrabKeyboard.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2489
    ].
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2490
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2491
    "Modified: / 2.2.1998 / 10:27:12 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2492
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2493
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2494
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2495
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2496
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2497
    "returns image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2498
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2499
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2500
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2501
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2502
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2503
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2504
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2505
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2506
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2507
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2508
!MenuPanel methodsFor:'initialize / release'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2509
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2510
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2511
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2512
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2513
    ^self
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2514
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2515
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2516
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2517
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2518
    "
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2519
    |style|
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2520
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2521
    self isPopUpView ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2522
	style := styleSheet name.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2523
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2524
	(style ~~ #normal and:[style ~~ #mswindows]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2525
	    self borderWidth:1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2526
	]
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2527
    ].
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2528
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2529
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2530
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2531
    self isPopUpView ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2532
	(PopUpView styleSheet at:'popup.shadow' default:false) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2533
	    shadowView isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2534
		shadowView := (ShadowView onDevice:device) for:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2535
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2536
		self saveUnder:true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2537
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2538
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2539
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2540
	explicitExtent == true ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2541
	    (self width) == (superView width) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2542
		self verticalLayout:false
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2543
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2544
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2545
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2546
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2547
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2548
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2549
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2550
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2551
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2552
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2553
    self clearLastActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2554
    self do:[:el|el destroy].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2555
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2556
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2557
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2558
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2559
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2560
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2561
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2562
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2563
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2564
    "Modified: / 27.2.1998 / 17:41:25 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2565
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2566
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2567
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2568
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2569
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2570
    |style|
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2571
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2572
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2573
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2574
    style := styleSheet name.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2575
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2576
    "/ thats a kludge - will be replaced by values from the styleSheet ...
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2577
    "/ (i.e. read menu.buttonActiveLevel & menu.buttonPassiveLevel)
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2578
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2579
    self isPopUpView ifFalse:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2580
        (style == #motif or:[style == #iris]) ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2581
            self topView == self superView ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2582
                self level:2
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2583
            ]
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2584
        ]
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2585
    ] ifTrue:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2586
        (style == #next or:[style == #normal]) ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2587
            onLevel := offLevel := 0
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2588
        ] ifFalse:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2589
            style == #openwin ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2590
                offLevel := 0.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2591
            ]
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2592
        ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2593
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2594
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2595
    superMenu isNil ifTrue:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2596
        fgColor                   := DefaultForegroundColor         onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2597
        activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2598
        activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2599
        disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2600
        rightArrow                := RightArrowForm                 onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2601
        selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2602
        selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2603
        buttonLightColor          := ButtonLightColor               onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2604
        buttonShadowColor         := ButtonShadowColor              onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2605
        ButtonHalfLightColor notNil ifTrue: [
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2606
            buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2607
        ButtonHalfShadowColor notNil ifTrue: [
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2608
            buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2609
        buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2610
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2611
        (rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2612
            rightArrowShadow := rightArrowShadow onDevice:device
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2613
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2614
    ] ifFalse:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2615
        fgColor                   := superMenu foregroundColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2616
        activeBgColor             := superMenu activeBackgroundColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2617
        activeFgColor             := superMenu activeForegroundColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2618
        disabledFgColor           := superMenu disabledForegroundColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2619
        rightArrow                := superMenu rightArrow.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2620
        rightArrowShadow          := superMenu rightArrowShadow.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2621
        selectionFrameBrightColor := superMenu selectionFrameBrightColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2622
        selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2623
        buttonLightColor          := superMenu buttonLightColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2624
        buttonShadowColor         := superMenu buttonShadowColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2625
        buttonHalfLightColor      := superMenu buttonHalfLightColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2626
        buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2627
        buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2628
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2629
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2630
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2631
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2632
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2633
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2634
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2635
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2636
    |style|
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2637
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2638
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2639
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2640
    self viewBackground:DefaultBackgroundColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2641
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2642
    onLevel   := DefaultHilightLevel.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2643
    offLevel  := DefaultLevel.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2644
    itemSpace := DefaultItemSpace.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2645
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2646
    groupDividerSize := DefaultGroupDividerSize.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2647
    fitFirstPanel := DefaultFitFirstPanel.
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2648
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2649
    style := styleSheet name.
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2650
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2651
"/    style == #st80 ifTrue:[
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2652
"/        self level:0
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2653
"/    ] ifFalse:[
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2654
        self level:1.
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2655
"/    ].
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2656
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2657
    styleSheet is3D ifFalse:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2658
        self borderWidth:1
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2659
    ] ifTrue:[
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2660
        self borderWidth:0.
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2661
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2662
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2663
    "Modified: / 15.9.1998 / 12:50:14 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2664
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2665
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2666
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2667
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2668
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2669
    |style|
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2670
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2671
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2672
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2673
    enabled := true.
1083
934218c3acfe level setting fixed.
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  2674
"/    self origin:0.0@0.0.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2675
    originChanged  := extentChanged := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2676
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2677
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2678
    mustRearrange  := false.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2679
"/    self borderWidth:0.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2680
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  2681
    font := MenuView defaultFont.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  2682
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2683
    "Modified: / 15.9.1998 / 12:49:51 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2684
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2685
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2686
mapped
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2687
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2688
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2689
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2690
    |anItemList|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2691
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2692
    self enableMotionEvents.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2693
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2694
    lastButtonSelected := nil.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2695
    self becomesActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2696
    super mapped.
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  2697
    self do:[:anItem| anItem fetchImages ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2698
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2699
    anItemList := InitialSelectionQuerySignal raise.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2700
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2701
    self isPopUpView ifTrue:[
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2702
        self grabMouseAndKeyboard
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2703
    ] ifFalse:[
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2704
"/        styleSheet is3D ifTrue:[self borderWidth:0].
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2705
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2706
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2707
    self do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2708
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2709
    anItemList size > 0 ifTrue:[
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2710
"/        self invalidateRepairNow:false.
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2711
        self redrawX:0 y:0 width:width height:height.
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2712
        self openMenusFromItems:anItemList.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2713
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2714
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2715
    "Modified: / 2.2.1998 / 09:27:21 / stefan"
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2716
    "Modified: / 19.11.1998 / 12:59:00 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2717
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2718
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2719
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2720
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2721
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2722
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2723
    self isPopUpView ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2724
	"Because of #saveUnder of ShadowView the order of realize is significant:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2725
	 shadowView must be realized before self"
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2726
	self hiddenOnRealize:true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2727
	super realize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2728
	self resize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2729
	shadowView notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2730
	    shadowView realize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2731
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2732
	super map.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2733
	self raise.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2734
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2735
	super realize.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2736
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2737
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2738
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2739
recreate
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2740
    "this is called after a snapin. If the image was saved with an active menu,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2741
     hide the menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2742
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2743
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2744
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2745
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2746
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2747
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2748
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2749
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2750
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2751
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2752
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2753
    self fetchDeviceResources.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2754
    items notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2755
        items do:[:anItem |
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2756
            anItem reinitSubmenuStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2757
        ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2758
    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2759
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2760
    "Created: / 10.9.1998 / 21:37:05 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2761
    "Modified: / 11.9.1998 / 13:20:57 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2762
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2763
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2764
unmap
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2765
    "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
  2766
     mouse events.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2767
    "
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2768
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2769
    self clearLastActiveMenu.
879
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  2770
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2771
    "/
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2772
    "/ Kludge for X11: after grabbing and ungrabbing other views may get buttonMotionEvents
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2773
    "/ 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
  2774
    "/ (Move from upperMenuPanel of NewLauncher to lowerMenuPanel)
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2775
    "/
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2776
    (superMenu notNil and:[superMenu shown and:[superMenu isPopUpView 
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2777
     or:[superMenu sensor anyButtonPressed]]]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2778
	superMenu grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2779
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2780
	self ungrabMouseAndKeyboard.
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2781
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2782
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2783
    shadowView notNil ifTrue:[shadowView unmap].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2784
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2785
    "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
  2786
    "Modified: / 27.2.1998 / 17:41:24 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2787
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2788
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2789
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2790
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2791
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2792
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2793
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2794
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2795
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2796
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2797
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2798
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2799
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2800
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2801
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2802
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2803
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2804
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2805
superMenu:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2806
    "set the supermenu starting from
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2807
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2808
    superMenu := aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2809
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2810
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2811
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2812
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2813
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2814
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2815
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2816
    top := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2817
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2818
    [ top superMenu notNil ] whileTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2819
	top := top superMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2820
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2821
  ^ top
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2822
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2823
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2824
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2825
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2826
!MenuPanel methodsFor:'printing'!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2827
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2828
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2829
    "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
  2830
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2831
    |string label|
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
    string := 'Menu:'.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2834
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2835
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2836
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2837
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2838
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2839
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2840
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2841
    "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
  2842
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2843
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2844
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2845
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2846
application
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2847
    |appl|
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2848
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2849
    superMenu notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2850
	^ superMenu application
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2851
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2852
    (appl := super application) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2853
	windowGroup notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2854
	    appl := windowGroup mainGroup topViews first application
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2855
	]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2856
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2857
  ^ appl
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2858
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  2859
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2860
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2861
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2862
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2863
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2864
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2865
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2866
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2867
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2868
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2869
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2870
    "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
  2871
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2872
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2873
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2874
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2875
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2876
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2877
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2878
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2879
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  2880
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2881
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2882
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2883
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2884
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2885
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2886
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2887
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2888
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2889
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2890
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2891
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2892
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2893
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2894
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2895
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2896
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2897
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2898
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2899
openMenusFromItems:anItemList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2900
    "open all menus derived from sequence of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2901
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2902
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2903
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2904
    (anItemList isNil or:[anItemList isEmpty]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2905
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2906
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2907
    item := anItemList removeLast.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2908
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2909
    item enabled ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2910
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2911
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2912
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2913
    InitialSelectionQuerySignal answer:anItemList do:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2914
	self selection:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2915
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2916
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2917
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2918
selectItemsForShortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2919
    "get sequence of items up to the item providing the key (inclusive). The
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2920
     first entry into the collection is the item providing the key, the last
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2921
     entry is the item in the topMenu( reverse )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2922
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2923
    |seq|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2924
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2925
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2926
	anItem isEnabled ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2927
	    anItem shortcutKey = aKey ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2928
		seq := OrderedCollection new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2929
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2930
		anItem hasSubmenu ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2931
		    seq := anItem submenu selectItemsForShortcutKey:aKey
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2932
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2933
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2934
	    seq notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2935
		seq add:anItem.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2936
	      ^ seq
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2937
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2938
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2939
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2940
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2941
        
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2942
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2943
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2944
translatePoint:aPoint to:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2945
    "translate a point into a views point; in case of no view nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2946
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2947
    aView notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2948
	aView == self ifTrue:[^ aPoint].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2949
      ^ device translatePoint:aPoint from:(self id) to:(aView id)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2950
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2951
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2952
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2953
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2954
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2955
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2956
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2957
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2958
    "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
  2959
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2960
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2961
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2962
    "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
  2963
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2964
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2965
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2966
    "set the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2967
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2968
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2969
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2970
    "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
  2971
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2972
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2973
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2974
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2975
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2976
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2977
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2978
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2979
    "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
  2980
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2981
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2982
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2983
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2984
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2985
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2986
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2987
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2988
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2989
    top activeMenu == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2990
	top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2991
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2992
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2993
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2994
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2995
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2996
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2997
    "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
  2998
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2999
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3000
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3001
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3002
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3003
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3004
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3005
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3006
itemAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3007
    "returns item at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3008
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3009
    self do:[:el| (el containsPointX:x y:y) ifTrue:[^el] ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3010
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3011
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3012
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3013
superMenuAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3014
    "returns supermenu at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3015
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3016
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3017
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3018
    (self containsPointX:x y:y) ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3019
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3020
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3021
    [ (menu := menu superMenu) notNil ] whileTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3022
	(menu containsPoint:(self translatePoint:(x@y) to:menu)) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3023
	    ^ menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3024
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3025
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3026
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3027
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3028
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3029
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3030
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3031
canDrawItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3032
    "returns true if an item could be drawn otherwise false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3033
    "
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3034
    ^ (mustRearrange not and:[shown])
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3035
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3036
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3037
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3038
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3039
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3040
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3041
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3042
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3043
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3044
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3045
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3046
    ^ (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
  3047
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  3048
"/    |ext|
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  3049
"/
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3050
"/    (x >= 0 and:[y >= 0]) ifTrue:[
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3051
"/        ext := self computeExtent.
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3052
"/      ^ (x < ext x and:[y < ext y])
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3053
"/    ].
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3054
"/    ^ false
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3055
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3056
    "Modified: / 29.1.1998 / 16:46:10 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3057
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3058
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3059
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3060
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3061
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3062
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3063
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3064
    groupSizes size ~~ 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3065
	i := 0.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3066
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3067
	groupSizes do:[:t|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3068
	    (i := i + t) == anIndex ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3069
		^ true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3070
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3071
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3072
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3073
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3074
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3075
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3077
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3078
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3079
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3080
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3081
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3082
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3083
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3084
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3085
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3086
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3087
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3088
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3089
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3090
    "returns true if the panel is the first in the menu hierarchy in must
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3091
     be fit to the extent of its superView
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3092
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3093
    ^ self isPopUpView ifTrue:[false] ifFalse:[fitFirstPanel]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3094
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3095
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3096
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3097
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3098
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3099
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3100
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3101
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3102
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3103
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3104
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3105
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3106
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3107
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3108
  ^ self verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3110
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3111
!
c05874084d4c implement
ca
parents: 407
diff changeset
  3112
c05874084d4c implement
ca
parents: 407
diff changeset
  3113
type
428
ca
parents: 427
diff changeset
  3114
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3115
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3116
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3117
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3118
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3120
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3121
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3122
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3123
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3124
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3125
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3126
isValidSelection:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3127
    "returns true if something could be selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3128
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3129
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3130
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3131
    enabled ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3132
	(item := self itemAt:something) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3133
	    ^ item canSelect
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3134
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3135
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3136
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3137
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3138
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3139
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3140
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3141
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3142
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3143
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3144
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3145
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3146
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3147
selection:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3148
    "change selection to an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3149
    "
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3150
    |item newSel hlp|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3151
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3152
    selection isNumber ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3153
	newSel := self itemAt:anItemOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3154
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3155
	(anItemOrNil notNil and:[anItemOrNil canSelect]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3156
	    newSel := anItemOrNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3157
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3158
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3159
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3160
    selection == newSel ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3161
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3162
    (item := selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3163
	selection := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3164
	item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3165
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3166
    newSel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3167
	selection := newSel.
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3168
1039
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3169
"/ 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
  3170
"/ but not the selected one ...
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3171
"/        ActiveHelp isActive ifTrue:[
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3172
"/            hlp := ActiveHelp currentHelpListener.
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3173
"/            hlp initiateHelpFor:self atX:1 y:1 now:true.
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3174
"/        ].
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3175
	selection selected:true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3176
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3177
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3178
    "Modified: / 2.2.1998 / 10:13:46 / stefan"
1039
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3179
    "Modified: / 31.7.1998 / 03:14:18 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3180
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3181
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3182
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3183
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3184
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3185
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3186
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3187
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3188
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3189
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3190
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3191
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3192
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3193
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3194
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3195
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3196
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3197
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3198
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3199
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3200
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3201
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3202
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3203
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3204
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3205
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3206
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3207
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3208
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3209
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3210
shortcutKeyOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3211
    ^ ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3212
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3213
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3214
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3215
    ^ VerticalInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3216
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3217
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3218
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3219
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3220
separatorSize:aType
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3221
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3222
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3223
    aType == #doubleLine ifTrue:[^ 10 ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3224
    aType == #singleLine ifTrue:[^ 10 ].
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  3225
  ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3226
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3227
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3228
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3229
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3230
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3231
    "
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3232
    HorizontalInset       := 4.
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3233
    VerticalInset         := 3.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3234
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3235
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3236
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3237
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3238
    LabelRightOffset      := 15.
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3239
    ShortcutKeyOffset     := 5.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3240
1110
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3241
    IndicatorOn  := self checkedImage.
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3242
    IndicatorOff := self uncheckedImage.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3243
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3244
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3245
!MenuPanel::Item class methodsFor:'image specs'!
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3246
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3247
checkOffIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3248
    "This resource specification was automatically generated
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3249
     by the ImageEditor of ST/X."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3250
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3251
    "Do not manually edit this!! If it is corrupted,
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3252
     the ImageEditor may not be able to read the specification."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3253
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3254
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3255
     self checkOffIcon inspect
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3256
     ImageEditor openOnClass:self andSelector:#checkOffIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3257
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3258
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3259
    <resource: #image>
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3260
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3261
    ^Icon
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3262
	constantNamed:#'MenuPanel::Item checkOffIcon'
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3263
	ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DO?Y@D_?>(AO??;AO???LS???3D???<1O???LS???3A_??3@Z??<0A+?00@C@C0@@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?:??+?>/?:??)?=G?4O< HL@_@') ; yourself); yourself]!
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3264
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3265
checkOnIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3266
    "This resource specification was automatically generated
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3267
     by the ImageEditor of ST/X."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3268
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3269
    "Do not manually edit this!! If it is corrupted,
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3270
     the ImageEditor may not be able to read the specification."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3271
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3272
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3273
     self checkOnIcon inspect
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3274
     ImageEditor openOnClass:self andSelector:#checkOnIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3275
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3276
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3277
    <resource: #image>
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3278
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3279
    ^Icon
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3280
	constantNamed:#'MenuPanel::Item checkOnIcon'
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3281
	ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DO?Y@D]@^(AL@@;AM@@GLS@@@3D0@@L1L@@CLSP@A3A\@@3@Z4A<0A+?00@C@C0@@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?:??+?>/?:??)?=G?4O< HL@_@') ; yourself); yourself]!
1110
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3282
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3283
checkedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3284
    "This resource specification was automatically generated
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3285
     by the ImageEditor of ST/X."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3286
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3287
    "Do not manually edit this!! If it is corrupted,
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3288
     the ImageEditor may not be able to read the specification."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3289
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3290
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3291
     self checkedImage inspect
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3292
     ImageEditor openOnClass:self andSelector:#checkedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3293
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3294
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3295
    <resource: #image>
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3296
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3297
    ^Icon
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3298
        constantNamed:#'MenuPanel::Item checkedImage'
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3299
        ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'****$H@@@MBEUUWP!!UUU4HUUT]BEUTGP!!ETA4HPTA]BD@AWP!!PAU4HUAU]BEUUWP/???4EUUUU@b') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??3??O?<??3??O?<??3??O?<??3??O?<??3??@@a') ; yourself); yourself]
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3300
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3301
    "Modified: / 6.9.1998 / 22:29:58 / cg"
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3302
!
1110
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3303
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3304
uncheckedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3305
    "This resource specification was automatically generated
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3306
     by the ImageEditor of ST/X."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3307
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3308
    "Do not manually edit this!! If it is corrupted,
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3309
     the ImageEditor may not be able to read the specification."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3310
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3311
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3312
     self uncheckedImage inspect
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3313
     ImageEditor openOnClass:self andSelector:#uncheckedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3314
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3315
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3316
    <resource: #image>
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3317
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3318
    ^Icon
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3319
        constantNamed:#'MenuPanel::Item uncheckedImage'
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3320
        ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUPG???8A0@@B@\@@@ G@@@HA0@@B@\@@@ G@@@HA0@@B@\@@@ G@@@HA0@@B@Z*** @@@@@@b') ; colorMapFromArray:#[255 255 255 127 127 127 170 170 170 0 0 0]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??3??O?<??3??O?<??3??O?<??3??O?<??3??@@a') ; yourself); yourself]
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3321
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3322
    "Modified: / 6.9.1998 / 22:24:24 / cg"
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3323
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3324
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3325
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3326
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3327
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3328
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3329
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3330
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3331
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3332
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3333
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3334
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3335
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3336
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3337
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3338
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3339
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3340
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3341
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3342
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3343
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3344
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3345
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3346
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3347
!MenuPanel::Item methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3348
420
ca
parents: 417
diff changeset
  3349
canAccept
ca
parents: 417
diff changeset
  3350
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  3351
    "
ca
parents: 417
diff changeset
  3352
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3353
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3354
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3355
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3356
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3357
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3358
    |arg|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3359
723
4f05cbdcaede once again some corrections for button press indication
tz
parents: 720
diff changeset
  3360
    self hasIndication ifTrue:[    
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3361
	arg := self indicationValue not.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3362
	self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3363
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3364
	self hasChoice ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3365
	    arg := self choiceValue.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3366
	    self choice value:arg.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3367
	    arg := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3368
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3369
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3370
    ^ arg
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3371
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3372
    "Modified: / 14.8.1998 / 16:13:37 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3373
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3374
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3375
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3376
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3377
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3378
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3379
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3380
    accessCharacterPosition isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3381
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3382
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3383
  ^ (rawLabel string) at:accessCharacterPosition ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3384
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3385
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3386
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3387
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3388
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3389
  ^ accessCharacterPosition
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3390
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3391
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3392
accessCharacterPosition:anIndex
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3393
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3394
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3395
    accessCharacterPosition ~~ anIndex ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3396
	accessCharacterPosition := anIndex.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3397
	self updateRawLabel.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3398
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3399
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3400
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3401
activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3402
    ^ activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3403
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3404
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3405
activeHelpKey:aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3406
    activeHelpKey := aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3407
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3408
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3409
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3410
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3411
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3412
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3413
  ^ adornment argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3414
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3415
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3416
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3417
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3418
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3419
    self argument ~~ anArgument ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3420
	self adornment argument:anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3421
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3422
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3423
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3424
compareAccessCharacterWith:aKey
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3425
    "returns true if key is my access character
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3426
    "
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3427
    ^ self accessCharacter == aKey
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3428
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3429
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3430
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3431
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3432
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3433
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3434
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3435
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3436
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3437
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3438
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3439
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3440
    "
475
b604babd1f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  3441
    |i rest s|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3442
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3443
    accessCharacterPosition := nil.
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3444
    label := aLabel value.
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3445
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3446
    (label isString and:[(s := label size) > 1]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3447
	i := 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3448
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3449
	[((i := label indexOf:$& startingAt:i) ~~ 0 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3450
	and:[i < s])] whileTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3451
	    rest := label copyFrom:(i+1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3452
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3453
	    i == 1 ifTrue:[label := rest]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3454
		  ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3455
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3456
	    (label at:i) == $& ifTrue:[i := i + 1]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3457
			      ifFalse:[accessCharacterPosition := i].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3458
	    s := s - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3459
	]
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3460
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3461
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3462
    self updateRawLabel
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  3463
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  3464
    "Modified: / 31.7.1998 / 00:52:26 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3465
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3466
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3467
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3468
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3469
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3470
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3471
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3472
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3473
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3474
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3475
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3476
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3477
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3478
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3479
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3480
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3481
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3482
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3483
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3484
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3485
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3486
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3487
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3488
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3489
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3490
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3491
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3492
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3493
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3494
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3495
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3496
  ^ adornment shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3497
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3498
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3499
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3500
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3501
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3502
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3503
    self shortcutKey ~~ aKey ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3504
	self adornment shortcutKey:aKey.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3505
	self redraw.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3506
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3507
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3508
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3509
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3510
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3511
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3512
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3513
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3514
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3515
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3516
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3517
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3518
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3519
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3520
    (startGroup isNil or:[startGroup == #right]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3521
	startGroup := aSymbol
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3522
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3523
	self warn:('not supported group: ', aSymbol printString ).
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3524
    ]
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3525
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3526
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3527
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3528
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3529
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3530
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3531
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3532
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3533
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3534
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3535
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3536
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3537
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3538
    "
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3539
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3540
    (aSubMenu notNil 
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3541
     and:[(aSubMenu isView or:[aSubMenu isKindOf:Menu]) not]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3542
	^ self submenuChannel:aSubMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3543
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3544
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3545
    (subMenu := aSubMenu) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3546
	aSubMenu class == Menu ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3547
	    subMenu := MenuPanel new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3548
	    menuPanel notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3549
		subMenu receiver:menuPanel receiver.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3550
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3551
	    subMenu menu:aSubMenu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3552
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3553
	(subMenu notNil and:[subMenu isView]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3554
	    subMenu superMenu:menuPanel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3555
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3556
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3557
1068
155168a813ad oops - subMenu must be an instance of MenuPanel
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
  3558
    "Modified: / 10.8.1998 / 13:26:28 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3559
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3560
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3561
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3562
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3563
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3564
    (rawLabel respondsTo:#string) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3565
	^ rawLabel string
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3566
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3567
  ^ nil
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3568
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3569
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3570
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3571
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3572
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3573
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3574
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3575
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3576
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3577
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3578
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3579
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3580
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3581
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3582
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3583
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3584
    "
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3585
    self value:aValue.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3586
    self argument:anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3587
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3588
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3589
!MenuPanel::Item methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3590
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3591
choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3592
    "get choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3593
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3594
    adornment isNil ifTrue:[^ nil].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3595
  ^ adornment choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3596
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3597
    "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
  3598
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3599
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3600
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3601
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3602
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3603
    |old new|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3604
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3605
    old := self choice.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3606
    old == something ifTrue:[^ self].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3607
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3608
    (self isKindOfValueHolder:old) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3609
	old removeDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3610
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3611
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3612
    new := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3613
    new isSymbol ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3614
	new := self aspectAt:new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3615
	new isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3616
	    new := something
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3617
	]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3618
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3619
    (self isKindOfValueHolder:new) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3620
	new addDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3621
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3622
    self adornment choice:new.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3623
    self updateRawLabel.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3624
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3625
    "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
  3626
    "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
  3627
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3628
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3629
choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3630
    "get choice value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3631
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3632
    adornment isNil ifTrue:[^ nil].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3633
  ^ adornment choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3634
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3635
    "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
  3636
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3637
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3638
choiceValue:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3639
    "set choice value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3640
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3641
    |old|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3642
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3643
    self adornment choiceValue:something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3644
    self updateRawLabel.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3645
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3646
    "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
  3647
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3648
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3649
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3650
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3651
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3652
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3653
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3654
    menuPanel enabled ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3655
	enableChannel isSymbol ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3656
	    state := self aspectAt:enableChannel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3657
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3658
	    (self isKindOfValueHolder:state) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3659
		enableChannel := state.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3660
		enableChannel addDependent:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3661
		state := enableChannel value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3662
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3663
		state := state value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3664
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3665
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3666
	    state := enableChannel value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3667
	].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3668
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3669
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3670
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3672
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3673
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3674
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3675
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3676
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3677
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3678
    enableChannel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3679
	oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3680
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3681
	oldState := enableChannel value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3682
	(self isKindOfValueHolder:enableChannel) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3683
	    enableChannel removeDependent:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3684
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3685
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3686
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3687
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3688
    enableChannel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3689
	menuPanel shown ifFalse:[^ self].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3690
	newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3691
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3692
	(self isKindOfValueHolder:enableChannel) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3693
	    enableChannel addDependent:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3694
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3695
	    enableChannel isSymbol ifTrue:[^ self]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3696
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3697
	menuPanel shown ifFalse:[^ self].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3698
	newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3699
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3700
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3701
    newState ~~ oldState ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3702
	(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3703
	    self drawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3704
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3705
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3706
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3707
    "Modified: / 27.10.1997 / 16:13:42 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3708
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3709
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3710
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3711
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3712
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3713
    adornment isNil ifTrue:[^ nil].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3714
  ^ adornment indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3715
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3716
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3717
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3718
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3719
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3720
    |old|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3721
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3722
    old := self indication.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3723
    old == something ifTrue:[^ self].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3724
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3725
    (self isKindOfValueHolder:old) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3726
	old removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3727
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3728
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3729
    (self isKindOfValueHolder:something) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3730
	something addDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3731
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3732
    self adornment indication:something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3733
    self updateRawLabel.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3734
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3735
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3736
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3737
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3738
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3739
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3740
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3741
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3742
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3743
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3744
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3745
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3746
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3747
    layout notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3748
	self redrawAsButton
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3749
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3750
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3751
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3752
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3753
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3754
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3755
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3756
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3757
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3758
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3759
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3760
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3761
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3762
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3763
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3764
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3765
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3766
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3767
!MenuPanel::Item methodsFor:'accessing dimension'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3768
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3769
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3770
    "gets height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3771
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3772
    layout isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3773
	^ self preferredExtent y
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3774
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3775
    ^ layout height
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3776
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3777
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3778
horizontalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3779
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3780
    isButton ifTrue: [^menuPanel buttonPassiveLevel + HorizontalButtonInset].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3781
    ^HorizontalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3782
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3783
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3784
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3785
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3786
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3787
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3788
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3789
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3790
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3791
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3792
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3793
    layout := aLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3794
    self redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3795
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3796
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3797
verticalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3798
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3799
    isButton ifTrue: [^menuPanel buttonPassiveLevel + VerticalButtonInset].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3800
    ^VerticalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3801
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3802
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3803
width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3804
    "gets width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3805
    "
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3806
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3807
    layout isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3808
	^ self preferredExtent x
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3809
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3810
    ^ layout width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3811
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3812
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3813
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3814
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3815
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3816
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3817
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3818
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3819
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3820
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3821
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3822
    (appl isKindOf:ValueModel) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3823
	^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3824
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3825
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3826
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3827
	Object messageNotUnderstoodSignal handle:[:ex|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3828
	    ex parameter selector == aKey ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3829
		ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3830
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3831
	] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3832
	    (appl isKindOf:ApplicationModel) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3833
		ifTrue:[value := appl aspectFor:aKey]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3834
		ifFalse:[value := appl perform:aKey]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3835
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3836
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3837
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  3838
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  3839
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3840
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3841
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3842
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3843
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3844
choiceChanged
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3845
    "called when the choice changed
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3846
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3847
    |indicator|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3848
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3849
    isButton ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3850
	indicator := self choiceForm.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3851
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3852
	indicator = rawLabel icon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3853
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3854
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3855
	rawLabel icon:indicator.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3856
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3857
	disabledRawLabel notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3858
	    disabledRawLabel icon:indicator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3859
	]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3860
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3861
    self redraw
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3862
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3863
    "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
  3864
    "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
  3865
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3866
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3867
enabledStateOfMenuChangedTo:aState
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3868
    "enabled state of menu changed to aState
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3869
    "
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3870
    rawLabel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3871
	self drawLabel
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3872
    ].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3873
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3874
!
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3875
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3876
indicationChanged
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3877
    "called when the indication changed
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3878
    "
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3879
    |indicator|
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3880
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3881
    isButton ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3882
	indicator := self indicatorForm.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3883
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3884
	indicator = rawLabel icon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3885
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3886
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3887
	rawLabel icon:indicator.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3888
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3889
	disabledRawLabel notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3890
	    disabledRawLabel icon:indicator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3891
	]
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3892
    ].
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3893
    self redraw
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3894
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3895
    "Modified: / 14.8.1998 / 17:19:38 / cg"
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3896
!
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3897
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3898
update:something with:aParameter from:changedObject
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3899
    |indicator|
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3900
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3901
    changedObject == self indication ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3902
	^ self indicationChanged
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3903
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3904
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3905
    changedObject == self choice ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3906
	^ self choiceChanged
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3907
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3908
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3909
    changedObject == enableChannel ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3910
	(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3911
	    self drawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3912
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3913
	^ self
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3914
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  3915
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  3916
    changedObject == isVisible ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3917
	^ menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  3918
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  3919
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3920
    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
  3921
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3922
    "Modified: / 14.8.1998 / 16:13:41 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3923
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3924
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3925
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3926
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3927
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3928
    |indicator| 
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3929
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3930
    (indicator := self indication) notNil ifTrue:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3931
"/        (isButton and:[menuPanel isPopUpView]) ifFalse:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3932
"/            (self isKindOfValueHolder:indicator) ifTrue:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3933
"/                ^ self
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3934
"/            ]
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3935
"/        ].
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3936
	self indicationChanged
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3937
    ]
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3938
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3939
    "Modified: / 14.8.1998 / 15:19:38 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3940
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3941
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3942
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3943
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3944
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3945
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3946
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3947
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3948
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3949
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3950
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3951
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3952
    label isImage ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3953
	rcv := ResourceRetriever new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3954
	rcv className:#MenuEditor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3955
	rcv selector:#iconUnknown.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3956
	item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3957
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  3958
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3959
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3960
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3961
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3962
	item enabled:(enableChannel value)
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3963
    ].
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3964
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3965
    item accessCharacterPosition:(self accessCharacterPosition).
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3966
    item startGroup:(self startGroup).
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3967
    item argument:(self argument).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3968
    item nameKey:(self nameKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3969
    item shortcutKeyCharacter:(self shortcutKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3970
    item value:(value value).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3971
    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
  3972
    item choice:(self choice value).
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3973
    item choiceValue:(self choiceValue).
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  3974
    item isVisible:(self isVisible).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3975
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3976
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3977
    submenuChannel isSymbol ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3978
	item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3979
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3980
	self submenu notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3981
	    item submenu:(self submenu asMenu)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3982
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3983
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3984
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3985
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3986
    "Modified: / 14.8.1998 / 15:47:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3987
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3988
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3989
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3990
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3991
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3992
    |var lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3993
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3994
    menuPanel disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3995
	label := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3996
	activeHelpKey := aMenuItem activeHelpKey.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3997
	self enabled:(aMenuItem enabled).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3998
	self nameKey:(aMenuItem nameKey).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3999
	self indication:(aMenuItem indication).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4000
	self choice:(aMenuItem choice).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4001
	self choiceValue:(aMenuItem choiceValue).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4002
	self isButton:(aMenuItem isButton).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4003
	self startGroup:(aMenuItem startGroup).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4004
	self isVisible:(aMenuItem isVisible).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4005
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4006
	(var := aMenuItem accessCharacterPosition) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4007
	    self accessCharacterPosition:var.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4008
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4009
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4010
	(lbl := aMenuItem labelImage value) isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4011
	    lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4012
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4013
	self label:lbl.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4014
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4015
	self shortcutKey:(aMenuItem shortcutKeyCharacter).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4016
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4017
	(var := aMenuItem argument) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4018
	    self argument:var.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4019
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4020
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4021
	submenuChannel := aMenuItem submenuChannel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4022
	self submenu:(aMenuItem submenu).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4023
	self value:(aMenuItem value).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4024
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  4025
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4026
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4027
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4028
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4029
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4030
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4031
drawLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4032
    "draw label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4033
    "
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4034
    |y x h l t scKey cLb cLa img fg asc arrow hrzInset 
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4035
     buttonLevel isSelected clr|
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4036
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4037
    self isVisible ifFalse:[^ self].
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4038
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4039
    img := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4040
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4041
    asc := menuPanel font ascent.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4042
    h   := layout height.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4043
    l   := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4044
    t   := layout top.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4045
    hrzInset := self horizontalInset.
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4046
    isSelected := self drawSelected.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4047
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4048
    self enabled ifTrue:[
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4049
        fg := isSelected ifTrue:[self activeForegroundColor]
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4050
                        ifFalse:[menuPanel foregroundColor].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4051
    ] ifFalse:[
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4052
        fg := menuPanel disabledForegroundColor.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4053
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4054
        (img := disabledRawLabel) isNil ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4055
            img := self disabledRawLabel
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4056
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4057
    ].
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4058
    menuPanel paint:fg.
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4059
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4060
    "/ t := t + menuPanel level.
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4061
    y := t + ((h - (img heightOn:menuPanel)) // 2).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4062
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4063
    (self textLabel) notNil ifTrue:[
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4064
        y := y + asc.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4065
    ].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4066
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4067
    isButton ifTrue:[   
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4068
        (isSelected or:[self indicationValue == true]) ifTrue:
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4069
        [   
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4070
            img displayOn:menuPanel x:(l + hrzInset) + 1 y: y + 1.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4071
            buttonLevel := menuPanel buttonActiveLevel.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4072
        ] ifFalse:[   
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4073
            img displayOn:menuPanel x:(l + hrzInset) y:y.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4074
            self isEntered ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4075
                buttonLevel := menuPanel buttonEnteredLevel
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4076
            ] ifFalse:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4077
                buttonLevel := menuPanel buttonPassiveLevel
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4078
            ]
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4079
        ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4080
        buttonLevel ~~ 0 ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4081
            menuPanel 
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4082
                drawButtonEdgesInLayout:layout 
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4083
                withLevel:buttonLevel
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4084
                selected:isSelected.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4085
        ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4086
        ^ self
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4087
    ].
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4088
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4089
"/ 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
  4090
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4091
    img displayOn:menuPanel x:(l + hrzInset) y:y.
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4092
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4093
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4094
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4095
    MenuView showAcceleratorKeys == true ifTrue:[
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4096
        menuPanel isVerticalLayout ifTrue:[ "/ only for vertical menus ...
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4097
            (scKey:= self shortcutKeyAsString) notNil ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4098
                (x := menuPanel shortKeyInset) == 0 ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4099
                    x := hrzInset + LabelRightOffset + (img widthOn:menuPanel)
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4100
                ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4101
                x := l + x.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4102
                y := t + ((h - (scKey heightOn:menuPanel)) // 2).
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4103
                y := y + asc.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4104
                scKey displayOn:menuPanel x:x y:y. 
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4105
            ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4106
        ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4107
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  4108
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4109
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4110
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4111
    (menuPanel isVerticalLayout and:[self submenu notNil]) ifTrue:[
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4112
        arrow := menuPanel rightArrow.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4113
        x := layout right - arrow width - hrzInset.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4114
        y := t + (h - arrow height // 2).
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4115
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4116
        (menuPanel styleSheet is3D not
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4117
        or:[(img := menuPanel rightArrowShadow) isNil]) ifTrue:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4118
            ^ menuPanel displayForm:arrow x:x y:y
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4119
        ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4120
        cLa := menuPanel shadowColor.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4121
        cLb := menuPanel lightColor.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4122
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4123
        isSelected ifFalse:[
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4124
            fg  := cLa.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4125
            cLa := cLb.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4126
            cLb := fg
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4127
        ].
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4128
        menuPanel paint:cLa.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4129
        menuPanel displayForm:arrow x:x y:y.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4130
        menuPanel paint:cLb.
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4131
        menuPanel displayForm:img x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4132
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  4133
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4134
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4135
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4136
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4137
drawSelected
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4138
    "return true if item is selected or if item implements
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4139
     a toggle in a radio group which is selected
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4140
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4141
    |holder|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4142
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4143
    self isSelected ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4144
	^ true
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4145
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4146
    isButton ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4147
	^ ((holder := self choice) notNil and:[holder value = self choiceValue])
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4148
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4149
    ^ false
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4150
!
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4151
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4152
redraw
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4153
    "redraw item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4154
    "
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4155
    |isSelected ownBgCol showItemSep type paint lgCol shCol
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4156
     h  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4157
     w  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4158
     l  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4159
     t  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4160
     r  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4161
     b  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4162
     x  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4163
     y  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4164
     hrzInset "{ Class:SmallInteger }"
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4165
     isEntered
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4166
    |
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4167
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4168
    (self isVisible and:[menuPanel canDrawItem]) ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4169
	^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4170
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4171
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4172
    isSelected := self drawSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4173
    isEntered := self isEntered.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4174
    hrzInset   := self horizontalInset.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4175
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4176
    isSelected ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4177
	(isButton and:[isEntered]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4178
	    paint := self buttonEnteredBackgroundColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4179
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4180
	    paint := self backgroundColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4181
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4182
    ] ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4183
	paint := self activeBackgroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4184
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4185
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4186
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4187
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4188
    b := layout bottom.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4189
    h := layout height.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4190
    w := layout width.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4191
    (ownBgCol := self backgroundColorFromLabel) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4192
	menuPanel paint:paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4193
	menuPanel fillRectangle:layout.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4194
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4195
	self hasIndication ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4196
	    menuPanel paint:ownBgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4197
	    menuPanel fillRectangle:layout.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4198
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4199
	    menuPanel paint:paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4200
	    x := (rawLabel icon width) + hrzInset + 4.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4201
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4202
	    menuPanel fillRectangleX:l y:t width:x height:h.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4203
	    menuPanel paint:ownBgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4204
	    menuPanel fillRectangleX:(l + x) y:t width:(w - x) height:h.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4205
	    ownBgCol := nil.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4206
       ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4207
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4208
    lgCol       := menuPanel lightColor.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4209
    shCol       := menuPanel shadowColor.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4210
    showItemSep := menuPanel showSeparatingLines.
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4211
    type        := self separatorType.
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4212
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4213
    type notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4214
	type == #blankLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4215
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4216
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4217
	"/ draw separator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4218
	menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4219
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4220
	menuPanel verticalLayout ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4221
	    l := l + hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4222
	    r := r - hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4223
	    y := t - 1 + (h // 2).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4224
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4225
	    type == #doubleLine ifTrue:[y := y - 2].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4226
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4227
	    menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4228
	    menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4229
	    y := y + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4230
	    menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4231
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4232
	    type == #doubleLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4233
		y := y + 3.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4234
		menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4235
		menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4236
		menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4237
		y := y + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4238
		menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4239
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4240
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4241
	    x := l - 1 + (w // 2).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4242
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4243
	    type == #doubleLine ifTrue:[x := x - 2].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4244
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4245
	    menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4246
	    menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4247
	    x := x + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4248
	    menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4249
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4250
	    type == #doubleLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4251
		x := x + 3.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4252
		menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4253
		menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4254
		menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4255
		x := x + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4256
		menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4257
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4258
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4259
	^ self
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4260
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4261
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4262
    isButton ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4263
	^ self drawLabel
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4264
    ].
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4265
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4266
    showItemSep ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4267
	|col index item lfSep rtSep|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4268
	col := menuPanel paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4269
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4270
	index := menuPanel indexOfItem:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4271
	item  := menuPanel itemAtIndex:(index - 1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4272
	lfSep := item notNil and:[item isButton not].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4273
	item  := menuPanel itemAtIndex:(index + 1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4274
	rtSep := item notNil and:[item isButton not].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4275
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4276
	menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4277
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4278
	menuPanel verticalLayout ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4279
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4280
		menuPanel displayLineFromX:l y:t - 1 toX:r y:t - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4281
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4282
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4283
		menuPanel displayLineFromX:l y:b - 1 toX:r y:b - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4284
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4285
	    menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4286
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4287
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4288
		menuPanel displayLineFromX:l y:t - 2 toX:r y:t - 2.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4289
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4290
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4291
		menuPanel displayLineFromX:l y:b - 2 toX:r y:b - 2.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4292
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4293
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4294
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4295
		menuPanel displayLineFromX:l - 1 y:t toX:l - 1 y:b
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4296
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4297
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4298
		menuPanel displayLineFromX:r - 1 y:t toX:r - 1 y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4299
	    ]. 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4300
	    menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4301
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4302
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4303
		menuPanel displayLineFromX:l - 2 y:t toX:l - 2 y:b
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4304
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4305
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4306
		menuPanel displayLineFromX:r - 2 y:t toX:r - 2 y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4307
	    ] 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4308
	]
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4309
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4310
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4311
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4312
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4313
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4314
	ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4315
				 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4316
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4317
	menuPanel displayRectangleX:(l + 1) y:(t + 1) width:(w - 2) height:(h - 2).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4318
	menuPanel displayRectangleX:(l + 2) y:(t + 2) width:(w - 4) height:(h - 4).  
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4319
    ].
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4320
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4321
    menuPanel drawEdgesForX:l y:t width:w height:h isSelected:isSelected isEntered:isEntered.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4322
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4323
    "Modified: / 20.8.1998 / 15:11:33 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4324
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4325
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4326
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4327
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4328
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4329
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4330
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4331
    |channel|
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4332
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4333
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4334
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4335
    (enableChannel notNil and:[self isKindOfValueHolder:enableChannel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4336
	enableChannel removeDependent:self
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4337
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4338
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4339
    (isVisible notNil and:[self isKindOfValueHolder:isVisible]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4340
	isVisible removeDependent:self
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4341
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4342
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4343
    channel := self indication.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4344
    (channel notNil and:[self isKindOfValueHolder:channel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4345
	channel removeDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4346
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4347
    channel := self choice.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4348
    (channel notNil and:[self isKindOfValueHolder:channel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4349
	channel removeDependent:self
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4350
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4351
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4352
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4353
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4354
    "Modified: / 14.8.1998 / 14:37:57 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4355
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4356
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4357
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4358
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4359
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4360
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4361
    isButton  := false.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4362
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4363
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4364
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4365
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4366
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4367
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4368
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4369
    disabledRawLabel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4370
	(     rawImage notNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4371
	 and:[(rawImage respondsTo:#colorMap)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4372
	 and:[rawImage colorMap notNil]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4373
	) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4374
	    disabledRawLabel := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4375
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4376
	    disabledRawLabel := menuPanel lightenedImageOnDevice:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4377
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4378
	    rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4379
		(isButton
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4380
		  or:[((self indication notNil or:[self choice notNil])
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4381
		 and:[label class == LabelAndIcon])]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4382
		) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4383
		    disabledRawLabel := LabelAndIcon form:(rawLabel icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4384
						    image:disabledRawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4385
						   string:(rawLabel string)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4386
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4387
		    disabledRawLabel := LabelAndIcon form:disabledRawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4388
						    image:(rawLabel image)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4389
						   string:(rawLabel string)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4390
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4391
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4392
	]
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4393
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4394
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4395
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4396
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4397
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4398
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4399
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4400
    |icon|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4401
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4402
    rawImage notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4403
	rawLabel isImage ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4404
	    rawLabel := menuPanel imageOnDevice:rawImage
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4405
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4406
	    rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4407
		(icon := rawLabel image) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4408
		    rawLabel image:(menuPanel imageOnDevice:icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4409
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4410
		(icon := rawLabel icon) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4411
		    (self indication isNil and:[self choice isNil]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4412
			rawLabel icon:(menuPanel imageOnDevice:icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4413
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4414
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4415
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4416
	]
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4417
    ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4418
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4419
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4420
updateRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4421
    "recreate rawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4422
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4423
    |char size form|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4424
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4425
    label isNil ifTrue:[        "/ not yet initialized
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4426
	^ self
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4427
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4428
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4429
    (form := self indicatorForm) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4430
	form := self choiceForm
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4431
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4432
    rawImage         := nil.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4433
    disabledRawLabel := nil.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4434
    rawLabel         := label value.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4435
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4436
    rawLabel isString ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4437
	rawLabel isText ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4438
	    rawLabel := rawLabel withoutSeparators
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4439
	].        
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4440
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4441
	form isNil ifTrue:[                             "/ check for separator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4442
	    rawLabel isEmpty ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4443
		  rawLabel := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4444
		^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4445
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4446
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4447
	    rawLabel size == 1 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4448
		char := rawLabel first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4449
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4450
		(char == $- or:[char == $=]) ifTrue:[   "/ other line separators
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4451
		    label := String new:1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4452
		    label at:1 put:char.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4453
		    rawLabel := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4454
		  ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4455
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4456
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4457
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4458
	rawLabel isEmpty ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4459
	    rawLabel := label value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4460
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4461
	size := self accessCharacterPosition.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4462
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4463
	(size notNil and:[size <= rawLabel size]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4464
	    rawLabel isText ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4465
		rawLabel := Text string:rawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4466
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4467
	    rawLabel emphasisAt:size add:#underline
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4468
	]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4469
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4470
    rawLabel isImage ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4471
	rawImage := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4472
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4473
	form notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4474
	    isButton ifTrue:[form := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4475
	    rawLabel := LabelAndIcon form:form image:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4476
	]
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4477
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4478
	rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4479
	    rawImage := rawLabel icon.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4480
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4481
	    (form notNil and:[isButton not]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4482
		rawLabel image:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4483
		rawLabel icon:form
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4484
	    ]                
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4485
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4486
	    rawImage := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4487
	    rawLabel isNil ifTrue:[rawLabel := ''].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4488
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4489
	    (form notNil and:[isButton not]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4490
		rawLabel := LabelAndIcon icon:form string:rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4491
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4492
		disabledRawLabel := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4493
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4494
	].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4495
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4496
    menuPanel shown ifTrue:[ self fetchImages ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4497
    menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4498
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4499
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4500
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4501
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4502
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4503
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4504
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4505
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4506
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4507
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4508
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4509
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4510
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4511
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4512
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4513
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4514
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4515
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4516
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4517
adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4518
    "returns adornment; if not existing yet a new instance
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4519
     is created
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4520
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4521
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4522
	adornment := Adornment new
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4523
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4524
  ^ adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4525
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4526
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4527
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4528
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4529
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4530
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4531
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4532
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4533
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4534
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4535
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4536
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4537
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4538
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4539
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4540
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4541
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4542
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4543
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4544
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4545
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4546
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4547
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4548
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4549
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4550
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4551
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4552
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4553
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4554
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4555
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4556
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4557
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4558
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4559
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4560
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4561
    "returns the background color to use when thhe mouse has entered 
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4562
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4563
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4564
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4565
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4566
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4567
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4568
    "Created: / 20.8.1998 / 13:56:10 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4569
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4570
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4571
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4572
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4573
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4574
    |holder|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4575
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4576
    (holder := self choice) isNil ifTrue:[^ nil].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4577
1107
0ace8de67a4e better styled round choice images + test choice values only for #=
tz
parents: 1101
diff changeset
  4578
    holder value = self choiceValue ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4579
	^ self class checkOnIcon
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4580
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4581
    ^ self class checkOffIcon
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4582
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4583
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4584
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4585
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4586
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4587
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4588
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4589
890
28c4470c6858 dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  4590
    |subm argument sel|
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4591
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4592
    subm := nil.
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4593
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4594
    aRecv notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4595
	submenuChannel last ~~ $: ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4596
	    Object messageNotUnderstoodSignal handle:[:ex|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4597
		|selector|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4598
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4599
		((selector := ex parameter selector) == submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4600
		or:[selector == #aspectFor:]) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4601
		    ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4602
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4603
	    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4604
		subm := aRecv aspectFor:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4605
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4606
	    subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4607
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4608
		    ex parameter selector == submenuChannel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4609
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4610
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4611
	    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4612
		    subm := aRecv perform:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4613
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4614
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4615
	    subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4616
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4617
		    ex parameter selector == submenuChannel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4618
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4619
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4620
		] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4621
		    subm := aRecv class perform:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4622
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4623
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4624
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4625
	    (argument := self argument) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4626
		sel := submenuChannel asSymbol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4627
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4628
		    ex parameter selector == sel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4629
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4630
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4631
		] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4632
		    subm := aRecv perform:sel with:argument
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4633
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4634
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4635
		subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4636
		    Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4637
			ex parameter selector == sel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4638
			    ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4639
			].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4640
		    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4641
			subm := aRecv class perform:sel with:argument
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4642
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4643
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4644
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4645
	]
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4646
    ].
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4647
    ^ subm
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4648
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4649
    "Modified: / 4.8.1998 / 17:40:09 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4650
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4651
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4652
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4653
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4654
    "
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4655
    |indication numArgs sel recv|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4656
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4657
    (indication := self indication) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4658
	^ nil                                           "/ has no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4659
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4660
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4661
    indication isSymbol ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4662
	(numArgs := indication numArgs) ~~ 0 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4663
	    numArgs == 2 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4664
		recv := menuPanel receiver.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4665
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4666
		(recv isKindOf:ValueModel) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4667
		    (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4668
			sel := indication copyFrom:1 to:(indication indexOf:$:).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4669
			indication := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4670
			sel := sel asSymbol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4671
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4672
			Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4673
			    ex parameter selector == sel ifFalse:[
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4674
"/                                Transcript showCR:'no indication for: ' , sel.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4675
				ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4676
			    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4677
			] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4678
			    indication := recv perform:sel with:self argument
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4679
			]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4680
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4681
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4682
		^ indication value == true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4683
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4684
	    indication := (indication copyWithoutLast:1) asSymbol
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4685
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4686
	indication := self aspectAt:indication.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4687
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4688
	(self isKindOfValueHolder:indication) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4689
	    self adornment indication:indication.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4690
	    indication addDependent:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4691
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4692
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4693
    ^ indication value == true
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4694
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4695
    "Modified: / 8.8.1998 / 02:15:15 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4696
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4697
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4698
indicationValue:aValue
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4699
    "returns indication value or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4700
    "
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4701
    |numArgs indication recv|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4702
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4703
    (indication := self indication) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4704
	^ self                                          "/ has no indication
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4705
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4706
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4707
    indication isSymbol ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4708
	(self isKindOfValueHolder:indication) ifTrue:[  "/ is value holder
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4709
	    indication value:aValue
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4710
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4711
	^ self
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4712
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4713
    recv := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4714
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4715
    (recv isKindOf:ValueModel) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4716
	recv value:indication value:aValue.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4717
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4718
	(      (numArgs := indication numArgs) ~~ 0
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4719
	  and:[recv notNil or:[(recv := menuPanel application) notNil]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4720
	) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4721
	    Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4722
		(ex parameter selector ~~ indication) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4723
		    ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4724
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4725
	    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4726
		numArgs == 1 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4727
		    recv perform:indication with:aValue
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4728
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4729
		    recv perform:indication with:(self argument ? self) with:aValue
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4730
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4731
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4732
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4733
    ].
1026
29bd433b27d3 dont catch too many errors - it makes debugging so hard.
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
  4734
29bd433b27d3 dont catch too many errors - it makes debugging so hard.
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
  4735
    "Modified: / 28.7.1998 / 20:47:08 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4736
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4737
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4738
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4739
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4740
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4741
    |value|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4742
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4743
    (value := self indicationValue) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4744
	^ nil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4745
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4746
  ^ 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
  4747
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4748
    "Created: / 14.8.1998 / 15:53:53 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4749
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4750
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4751
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4752
    "returns true if the mouse pointer is over the item
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4753
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4754
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4755
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4756
    "Created: / 20.8.1998 / 13:11:50 / cg"
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4757
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4758
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4759
reinitSubmenuStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4760
    "returns my submenu or nil
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4761
    "
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4762
    subMenu notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4763
        subMenu reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4764
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4765
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4766
    "Created: / 10.9.1998 / 21:36:09 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4767
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4768
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4769
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4770
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4771
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4772
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4773
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4774
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4775
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4776
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4777
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4778
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4779
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4780
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4781
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4782
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4783
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4784
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4785
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4786
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4787
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4788
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4789
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4790
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4791
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4792
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4793
    submenuChannel notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4794
	submenuChannel isSymbol ifFalse:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4795
	    subm := submenuChannel
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4796
	] ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4797
	    appl := menuPanel application.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4798
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4799
	    (subm := self findSubMenuIn:appl) isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4800
		(recv := menuPanel receiver) ~~ appl ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4801
		    subm := self findSubMenuIn:recv
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4802
		]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4803
	    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4804
	].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4805
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4806
	(subm := subm value) isArray ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4807
	    subm := Menu new fromLiteralArrayEncoding:subm.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4808
	    "/ cg: linked menus also may contain translations ...
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4809
	    subm notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4810
		appl notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4811
		    subm findGuiResourcesIn:appl.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4812
		]                
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4813
	    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4814
	].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4815
	self submenu:subm.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4816
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4817
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4818
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4819
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4820
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4821
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4822
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4823
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4824
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4825
canSelect
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4826
    "returns true if item is selectable
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4827
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4828
    |holder|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4829
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4830
    (self isVisible and:[self enabled and:[rawLabel notNil]]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4831
	((holder := self choice) isNil or:[holder value ~= self choiceValue]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4832
	    ^ true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4833
	].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4834
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4835
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4836
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4837
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4838
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4839
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4840
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4841
    (self isVisible and:[layout notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4842
	^ (     (x >= layout left)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4843
	    and:[x <  layout right
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4844
	    and:[y >  layout top
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4845
	    and:[y <= layout bottom]]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4846
	  )
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  4847
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  4848
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4849
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4850
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4851
hasChoice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4852
    "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
  4853
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4854
  ^ self choice notNil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4855
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4856
    "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
  4857
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4858
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4859
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4860
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4861
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4862
  ^ self indication notNil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4863
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4864
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4865
hasSubmenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4866
    "returns true if a submenu exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4867
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4868
    ^ self submenu notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4869
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4870
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4871
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4872
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4873
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4874
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4875
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4876
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4877
isKindOfValueHolder:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4878
    "returns true if something is kind of vlaue holder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4879
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4880
    ^ ((something respondsTo:#value:) and:[something isBlock not])
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4881
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4882
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4883
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4884
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4885
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
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4888
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4889
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4890
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4891
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4892
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4893
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4894
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4895
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4896
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4897
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4898
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4899
    isVisible isSymbol ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4900
        state := self aspectAt:isVisible.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4901
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4902
        (self isKindOfValueHolder:state) ifTrue:[
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4903
            isVisible := state.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4904
            isVisible addDependent:self.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4905
            state := isVisible.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4906
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4907
    ] ifFalse:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4908
        state := isVisible
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4909
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4910
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4911
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4912
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4913
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4914
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4915
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4916
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4917
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4918
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4919
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4920
    isVisible isNil ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4921
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4922
    ] ifFalse:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4923
        oldState := isVisible value.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4924
        (self isKindOfValueHolder:isVisible) ifTrue:[
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4925
            isVisible removeDependent:self
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4926
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4927
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4928
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4929
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4930
    isVisible isNil ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4931
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4932
    ] ifFalse:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4933
        (self isKindOfValueHolder:isVisible) ifTrue:[
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4934
            isVisible addDependent:self
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4935
        ] ifFalse:[
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4936
            isVisible isSymbol ifTrue:[^ self]
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4937
        ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4938
        menuPanel shown ifFalse:[^ self].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4939
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4940
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4941
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4942
    newState ~~ oldState ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4943
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4944
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4945
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  4946
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4947
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4948
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4949
preferredExtent
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4950
    "compute my preferred extent
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4951
    "
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4952
    |x y s isVertical sepSize|
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4953
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4954
    self isVisible ifFalse:[^ (0 @ 0) ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4955
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4956
    x := self horizontalInset * 2.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4957
    y := self verticalInset * 2.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4958
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4959
    isVertical := menuPanel verticalLayout.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4960
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4961
    self isSeparator ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4962
	x := x + (rawLabel widthOn:menuPanel).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4963
	y := y + (rawLabel heightOn:menuPanel).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4964
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4965
	MenuView showAcceleratorKeys == true ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4966
	    isVertical ifTrue:[ "/ only for vertical menus ...
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4967
		(s := self shortcutKeyAsString) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4968
		    x := x + LabelRightOffset + (s widthOn:menuPanel)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4969
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4970
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4971
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4972
	(isVertical and:[self hasSubmenu or:[submenuChannel notNil]]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4973
	    x := x + menuPanel subMenuIndicationWidth.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4974
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4975
	    s notNil ifTrue:[x := x + ShortcutKeyOffset]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4976
		    ifFalse:[x := x + LabelRightOffset]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4977
	].
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4978
    ] ifTrue:[
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4979
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4980
	sepSize := (self class separatorSize:(self separatorType)).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4981
	isVertical ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4982
	    x := x max:sepSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4983
	    y := y + (menuPanel font height)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4984
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4985
	    y := y max:sepSize
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4986
	].
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4987
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4988
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4989
    ^ (x @ y)
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4990
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4991
    "Modified: / 8.8.1998 / 01:38:26 / cg"
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4992
!
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4993
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4994
preferredExtentX
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4995
    "compute my preferred extent x
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4996
    "
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4997
    ^ self preferredExtent x
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4998
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4999
!
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5000
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5001
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5002
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5003
    "
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5004
    |nm key prefix|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5005
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5006
    (key := self shortcutKey) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5007
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5008
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5009
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5010
    key isCharacter ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5011
	nm := key asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5012
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5013
	"/ this is somewhat complicated: we have the symbolic key at hand,
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5014
	"/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5015
	"/ Ask the devices keyboardMap for the backtranslation.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5016
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5017
	nm := menuPanel device keyboardMap keyAtValue:key ifAbsent:key.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5018
	"/
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5019
	"/ some modifier-key combination ?
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5020
	"/
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5021
	(nm startsWith:#Cmd) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5022
	    prefix := #Cmd.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5023
	] ifFalse:[(nm startsWith:#Alt) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5024
	    prefix := #Alt.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5025
	] ifFalse:[(nm startsWith:#Meta) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5026
	    prefix := #Meta.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5027
	] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5028
	    prefix := #Ctrl.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5029
	]]]].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5030
	prefix notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5031
	    nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5032
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5033
	    nm := nm asString
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5034
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5035
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5036
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5037
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5038
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5039
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5040
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5041
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5042
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5043
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5044
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5045
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5046
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5047
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5048
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5049
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5050
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5051
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5052
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5053
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5054
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5055
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5056
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5057
hideSubmenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5058
    "hide submenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5059
    "
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  5060
    |subMenu id|
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5061
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5062
    subMenu := self submenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5063
    subMenu realized ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5064
	(id := subMenu id) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5065
	    menuPanel device unmapWindow:id
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5066
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5067
    ] ifTrue:[
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5068
       subMenu hide
1076
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5069
    ].
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5070
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5071
    subMenu windowGroup:nil.
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5072
    menuPanel windowGroup removeView:subMenu.
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5073
1bd7e9b6fee8 remove submenu from windowGroup when hiding
Claus Gittinger <cg@exept.de>
parents: 1074
diff changeset
  5074
    "Modified: / 14.8.1998 / 17:36:01 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5075
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5076
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5077
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5078
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5079
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5080
    ^ menuPanel selection == self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5081
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5082
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5083
openSubmenuAt:aPoint
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5084
    "open submenu at a point
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5085
    "
680
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5086
    |top windowGrp subMenu|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5087
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5088
    windowGrp := menuPanel topMenu windowGroup.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5089
    subMenu   := self setupSubmenu.
890
28c4470c6858 dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  5090
    subMenu isNil ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5091
        ^ self
890
28c4470c6858 dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  5092
    ].
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  5093
    subMenu font:(menuPanel topMenu font).
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  5094
    subMenu becomesActiveMenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5095
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5096
    windowGrp notNil ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5097
        subMenu windowGroup:windowGrp.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5098
        windowGrp addTopView:subMenu.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5099
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5100
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5101
    "/ Q&D kludge - if any visibility attributes are blocks;
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5102
    "/ TODO: only invoke mustRearrange if any are blocks
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5103
    "/       (since I react correctly on valueodler changes)
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5104
    subMenu mustRearrange.
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5105
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5106
    subMenu fixSize.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5107
    subMenu origin:aPoint.
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  5108
"/    subMenu makeFullyVisible.
680
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5109
    top := menuPanel topMenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5110
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5111
    subMenu realized ifFalse:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5112
        subMenu realize. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5113
    ] ifTrue:[
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5114
        top device mapWindow:subMenu id.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5115
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  5116
    subMenu makeFullyVisible.
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  5117
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5118
680
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5119
"/    (top styleSheet at:'menu.autoSelectFirst') ifTrue:[
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5120
"/        subMenu selectionIndex:1
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5121
"/    ]
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5122
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5123
    "Modified: / 5.10.1998 / 12:16:27 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5124
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5125
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5126
selected:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5127
    "change selection to a state. Dependant on the state open or hide an existing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5128
     submenu and perform a redraw
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5129
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5130
    |p d subMenu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5132
    subMenu := self submenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5133
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5134
    aState ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5135
	self redraw.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5136
	subMenu notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5137
	    self hideSubmenu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5138
	].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5139
      ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5140
    ].
720
7187e69c300b some corrections for button press indication
tz
parents: 718
diff changeset
  5141
    menuPanel shown ifFalse:[^ self].  
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5142
    (self hasIndication not or: [isButton not]) ifTrue: [self redraw].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5143
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5144
    subMenu isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5145
	menuPanel isPopUpView ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5146
	    menuPanel grabMouseAndKeyboard.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5147
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5148
	^ self.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5149
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5150
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  5151
    menuPanel verticalLayout ifTrue:[p := (layout right - 4) @ (layout top)]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5152
			    ifFalse:[p := (layout left)  @ (layout bottom)].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5153
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5154
    d := menuPanel device.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5155
    p := d translatePoint:p from:(menuPanel id) to:(d rootWindowId).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5156
    self openSubmenuAt:p.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5157
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  5158
    "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
  5159
    "Modified: / 5.8.1998 / 00:15:36 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5160
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5161
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5162
!MenuPanel::Item::Adornment methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5163
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5164
accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5165
    "get the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5166
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5167
    ^ accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5168
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5169
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5170
accessCharacterPosition:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5171
    "set the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5172
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5173
    accessCharacterPosition := anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5174
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5175
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5176
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5177
    "ST/X goody; get argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5178
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5179
  ^ argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5180
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5181
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5182
argument:anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5183
    "ST/X goody; set argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5184
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5185
    argument := anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5186
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5187
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5188
choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5189
    "get has choice indicator value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5190
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5191
  ^ choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5192
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5193
    "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
  5194
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5195
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5196
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5197
    "set choice indicator value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5198
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5199
    choice := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5200
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5201
    "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
  5202
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5203
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5204
choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5205
    "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
  5206
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5207
    ^ choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5208
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5209
    "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
  5210
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5211
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5212
choiceValue:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5213
    "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
  5214
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5215
    choiceValue := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5216
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5217
    "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
  5218
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5219
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5220
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5221
    "get has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5222
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5223
  ^ indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5224
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5225
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5226
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5227
    "set has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5228
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5229
    indication := something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5230
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5231
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5232
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5233
    "get the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5234
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5235
  ^ shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5236
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5237
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5238
shortcutKey:aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5239
    "set the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5240
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5241
    shortcutKey := aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5242
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5243
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5244
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5245
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5246
version
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  5247
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.132 1998-11-19 12:04:55 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5248
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5249
MenuPanel initialize!