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