MenuPanel.st
author Claus Gittinger <cg@exept.de>
Tue, 17 Aug 1999 16:53:59 +0200
changeset 1474 bc9d6e39c2e7
parent 1473 1f62652f146e
child 1475 2eebc866712e
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     1
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
     3
	      All Rights Reserved
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     4
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    11
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    12
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    13
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
    14
SimpleView subclass:#MenuPanel
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    15
	instanceVariableNames:'adornment shadowView mapTime mustRearrange superMenu
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    16
		shortKeyInset selection items groupSizes receiver enableChannel
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    17
		menuHolder enabled onLevel offLevel fgColor activeFgColor
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    18
		lastActiveMenu activeBgColor disabledFgColor groupDividerSize
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
    19
		itemSpace fitFirstPanel rightArrow rightArrowShadow
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
    20
		selectionFrameBrightColor selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
    21
		buttonLightColor buttonShadowColor buttonHalfLightColor
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    22
		buttonHalfShadowColor lastButtonSelected enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    23
		buttonEnteredBgColor'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    24
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    25
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    26
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    27
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    28
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    29
		DefaultFitFirstPanel RightArrowForm RightArrowShadowForm
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    30
		SelectionFrameBrightColor SelectionFrameDarkColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    31
		ButtonActiveLevel ButtonPassiveLevel ButtonActiveBackgroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    32
		ButtonPassiveBackgroundColor ButtonLightColor ButtonShadowColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    33
		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle Images
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		LigthenedImages ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    35
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    36
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    37
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    38
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    39
Object subclass:#Item
729
18395718ec8e lighten the icon & image of a disabled LabelAndIcon if the
ca
parents: 728
diff changeset
    40
	instanceVariableNames:'layout menuPanel subMenu adornment rawLabel disabledRawLabel
18395718ec8e lighten the icon & image of a disabled LabelAndIcon if the
ca
parents: 728
diff changeset
    41
		enableChannel nameKey accessCharacterPosition value label
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
    42
		rawImage activeHelpKey submenuChannel startGroup isButton
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
    43
		isVisible'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    44
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    45
		VerticalButtonInset LabelRightOffset ShortcutKeyOffset
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
    46
		IndicatorOn IndicatorOff'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    47
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    48
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    49
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    50
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    51
Object subclass:#Adornment
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    52
	instanceVariableNames:'indication accessCharacterPosition shortcutKey argument choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    53
		choiceValue'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    54
	classVariableNames:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    55
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    56
	privateIn:MenuPanel::Item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    57
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    61
copyright
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    62
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    63
 COPYRIGHT (c) 1997 by eXept Software AG
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    64
	      All Rights Reserved
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    65
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    66
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    70
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    71
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    72
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    73
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    79
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    80
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    81
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    82
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    83
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    84
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    85
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    86
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    87
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
    [author:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    89
	Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
    [see also:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    92
	Menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    93
	MenuItem
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    94
	MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    95
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    96
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    97
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    98
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   100
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
    start as PullDownMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   103
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   105
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   107
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   108
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   110
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   114
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   122
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   126
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   127
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   130
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   132
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   138
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   140
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   141
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   142
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
    top open.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   144
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   146
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
    start as PopUpMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   148
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   149
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   151
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   152
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   153
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   155
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   156
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   157
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   158
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   159
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   160
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   161
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   162
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   163
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   164
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   165
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   166
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   167
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   168
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   169
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   170
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   171
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   172
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   173
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   174
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   175
    mview startUp
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   176
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   177
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   178
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   179
    start from menu spec
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   180
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   181
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   182
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   183
    menu := MenuPanel menu:
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   184
	#(#Menu #( #(#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   185
		    #label: 'File' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   186
		    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   187
		      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   188
				 (#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   189
				    #label: 'edit' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   190
				    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   191
				      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   192
						 #(#MenuItem #label: 'close' #value:#close)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   193
					       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   194
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   195
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   196
				       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   197
				  )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   198
				 #(#MenuItem #label: 'help' #value:#help )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   199
			       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   200
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   201
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   202
		       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   203
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   204
		#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   205
		#(#MenuItem #label: 'Bar' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   206
			    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   207
			       #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   208
					  #(#MenuItem #label: 'bar 2' #value:#bar2 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   209
					)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   210
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   211
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   212
				)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   213
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   214
	      ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   215
	      #( 2 )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   216
	      nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   217
	 ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   220
    Transcript showCR:(menu startUp).
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   221
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   222
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   223
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   224
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   225
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   226
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   227
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   229
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   230
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   231
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   232
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   233
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   234
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   235
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   236
    aSpec notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   237
	menu := Menu new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   238
	menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   239
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   240
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   241
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   243
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   244
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   245
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   246
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   247
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   251
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   252
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   253
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   254
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   261
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   262
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   263
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   264
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
    mview := self new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   274
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
    aReceiver notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   279
	mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   285
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   286
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   287
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   288
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   289
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   290
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   291
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   292
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   293
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   294
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   295
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   296
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   297
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   298
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   299
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   300
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   301
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   302
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   303
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   304
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   305
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   306
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   307
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   308
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   309
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   310
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   311
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   312
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   313
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   314
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   315
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   316
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   317
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   318
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   319
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   320
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   321
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   322
    |menuStyle style font|
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   323
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   324
"/    MenuView updateStyleCache.        
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   325
"/
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   326
"/    menuStyle := MenuView styleSheet.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   327
"/    menuStyle isNil ifTrue:[
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   328
"/        "make sure that style sheet is present"
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   329
"/        MenuView updateStyleCache.        
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   330
"/        menuStyle := MenuView styleSheet.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   331
"/    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   332
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   333
    menuStyle := StyleSheet.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   334
    style := menuStyle name.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   335
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   336
"/    DefaultForegroundColor := menuStyle colorAt:'pullDownMenu.foregroundColor'.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   337
"/    DefaultForegroundColor isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   338
	DefaultForegroundColor := menuStyle colorAt:#'menu.foregroundColor'
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   339
					    default:Color black.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   340
"/    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   341
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   342
    DefaultLevel := menuStyle at:#'pullDownMenu.level' default:0.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   343
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   344
    DefaultBackgroundColor := DefaultViewBackgroundColor.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   345
"/        DefaultBackgroundColor := menuStyle colorAt:'pullDownMenu.backgroundColor'.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   346
"/        DefaultBackgroundColor isNil ifTrue:[
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   347
    DefaultBackgroundColor := menuStyle colorAt:#'menu.backgroundColor' default:DefaultBackgroundColor.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   348
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   349
    menuStyle is3D ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   350
	DefaultHilightForegroundColor := DefaultForegroundColor.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   351
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   352
	DefaultHilightForegroundColor := DefaultBackgroundColor.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   353
    ].
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   354
"/        DefaultHilightForegroundColor := menuStyle colorAt:'pullDownMenu.hilightForegroundColor'.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   355
"/        DefaultHilightForegroundColor isNil ifTrue:[
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   356
    DefaultHilightForegroundColor := menuStyle colorAt:#'menu.hilightForegroundColor' default:DefaultHilightForegroundColor.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   357
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   358
    (style == #motif or:[style == #iris]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   359
	DefaultHilightLevel     := 2.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   360
	DefaultLevel           := DefaultLevel + 1.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   361
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   362
	(DefaultHilightLevel := menuStyle at:'pullDownMenu.hilightLevel') isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   363
	    DefaultHilightLevel := menuStyle at:'menu.hilightLevel' default:0.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   364
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   365
	menuStyle is3D ifTrue:[DefaultLevel := DefaultLevel + 1].
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   366
    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   367
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   368
    DefaultDisabledForegroundColor := menuStyle colorAt:#'menu.disabledForegroundColor'.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   369
    DefaultDisabledForegroundColor isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   370
	DefaultDisabledForegroundColor := menuStyle colorAt:#'button.disabledForegroundColor'
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   371
						    default:Color darkGray.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   372
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   373
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   374
    style == #motif ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   375
	DefaultHilightBackgroundColor := DefaultBackgroundColor
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   376
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   377
	DefaultHilightBackgroundColor := menuStyle is3D ifFalse:[DefaultForegroundColor] ifTrue:[DefaultBackgroundColor]
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   378
    ].
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   379
"/    DefaultHilightBackgroundColor := menuStyle colorAt:'pullDownMenu.hilightBackgroundColor'.
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   380
"/    DefaultHilightBackgroundColor isNil ifTrue:[
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   381
    DefaultHilightBackgroundColor := menuStyle colorAt:#'menu.hilightBackgroundColor' default:DefaultHilightBackgroundColor.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   382
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   383
    DefaultGroupDividerSize := menuStyle at:#'menu.groupDividerSize' default:6.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   384
    DefaultItemSpace        := menuStyle at:#'menu.itemSpace' default:0.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   385
    DefaultButtonItemSpace  := menuStyle at:#'menu.buttonItemSpace' default:0.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   386
    DefaultFitFirstPanel    := menuStyle at:#'menu.fitFirstPanel' default:true.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   387
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   388
    MenuView updateStyleCache.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   389
    DefaultFont := MenuView defaultFont.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   390
"/    font := menuStyle fontAt:'pullDownMenu.font'.
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   391
"/    font isNil ifTrue:[font := menuStyle fontAt:'menu.font'].
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   392
"/    DefaultFont := font.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   393
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   394
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   395
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   396
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   397
	RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   398
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   399
	RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   400
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   401
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   402
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   403
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   404
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   405
    ButtonActiveLevel            :=  menuStyle at:#'menu.buttonActiveLevel' 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
   406
    ButtonActiveLevel isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   407
	ButtonActiveLevel        :=  menuStyle at:#'button.activeLevel' default:(menuStyle is3D ifTrue:[-2] ifFalse:[0]).
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   408
    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   409
    ButtonPassiveLevel           :=  menuStyle at:#'menu.buttonPassiveLevel'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   410
    ButtonPassiveLevel isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   411
	ButtonPassiveLevel       :=  menuStyle at:#'button.passiveLevel' default:(menuStyle is3D ifTrue:[2] ifFalse:[0]).
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   412
    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   413
    ButtonActiveBackgroundColor  :=  menuStyle at:#'button.activeBackgroundColor' default: DefaultBackgroundColor.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   414
    ButtonPassiveBackgroundColor := (menuStyle at:#'button.backgroundColor') ? (menuStyle at:'viewBackground') ? DefaultBackgroundColor.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   415
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   416
    ButtonLightColor             := menuStyle at:#'button.lightColor'.
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   417
    ButtonLightColor isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   418
	ButtonLightColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) lightened. "/ Color white
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   419
    ].
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   420
    ButtonShadowColor            :=  menuStyle at:#'button.shadowColor'.
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   421
    ButtonShadowColor isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   422
	ButtonShadowColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened. "/ Color white
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   423
"/        (style == #next ifTrue:[
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   424
"/            ButtonShadowColor := Color black
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   425
"/        ] ifFalse:[
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   426
"/            ButtonShadowColor := Color gray
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   427
"/        ]
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   428
    ].
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   429
    ButtonHalfLightColor         :=  menuStyle at:#'button.halfLightColor'.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   430
    ButtonHalfShadowColor        :=  menuStyle at:#'button.halfShadowColor'.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   431
    ButtonEdgeStyle              :=  menuStyle at:#'button.edgeStyle'.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   432
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   433
    ButtonEnteredBackgroundColor := menuStyle colorAt:#'menu.buttonEnteredBackgroundColor'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   434
    ButtonEnteredBackgroundColor isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   435
	ButtonEnteredBackgroundColor := menuStyle colorAt:#'button.enteredBackgroundColor'
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   436
						  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   437
    ].
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
   438
    ButtonEnteredLevel := menuStyle at:#'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   439
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   440
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   441
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   442
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   443
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   444
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   445
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   446
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   447
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   448
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   449
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   450
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   451
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   452
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   453
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   454
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   455
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   456
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   457
    anImage device == aDevice ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   458
	^ anImage
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   459
    ].
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   460
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   461
    Images isNil ifTrue:[ Images := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   462
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   463
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   464
	Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   465
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   466
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   467
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   468
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   469
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   470
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   471
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   472
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   473
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   474
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   475
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   476
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   477
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   478
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   479
lightenedImage:anImage onDevice:aDevice
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
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   482
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   483
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   484
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   485
    LigthenedImages isNil ifTrue:[ LigthenedImages := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   486
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   487
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   488
	LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   489
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   490
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   491
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   492
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   493
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   494
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   495
    ((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   496
	image := anImage copy lightened onDevice:aDevice.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   497
	image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   498
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   499
	image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   500
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   501
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   502
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   503
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   504
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   505
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   506
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   507
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   508
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   509
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   510
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   511
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   512
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   513
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   514
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   515
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   516
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   517
!MenuPanel methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   518
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   519
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   520
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   521
    "
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   522
    ^ self accept:(self selection)
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   523
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   524
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   525
accept:anItem
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   526
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   527
    "
1293
5b3836bd4024 handle all exposes when hiding a popup,
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   528
    |value item tgState itemIdx recv panel masterGroup|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   529
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   530
    self superMenu notNil ifTrue:[
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   531
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   532
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
   533
    lastButtonSelected := nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   534
    self selection:nil.
420
ca
parents: 417
diff changeset
   535
    self forceUngrabMouseAndKeyboard.
ca
parents: 417
diff changeset
   536
ca
parents: 417
diff changeset
   537
    (anItem notNil and:[anItem canAccept]) ifTrue:[
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   538
        tgState := anItem toggleIndication.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   539
        panel   := anItem menuPanel.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   540
        itemIdx := panel findFirst:[:el| el == anItem ].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   541
        item    := anItem.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   542
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   543
    ].
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   544
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   545
    self isPopUpView ifFalse:[
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   546
        self do:[:el| el updateIndicators].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   547
        self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   548
    ] ifTrue:[
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   549
        self unmap.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   550
        "/ give expose event a chance to arrive
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   551
        [shown and:[realized]] whileTrue:[
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   552
            self windowGroup processExposeEventsFor:self
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   553
        ].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   554
        masterGroup := self windowGroup previousGroup.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   555
        self destroy.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   556
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   557
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   558
    value := self accept:item index:itemIdx toggle:tgState receiver:recv.
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
    self isPopUpView ifTrue:[
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   561
        self menuAdornmentAt:#value put:value.
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   562
        self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   563
    ].
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
   564
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   565
  ^ item.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   566
1212
9bd3220c9964 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1211
diff changeset
   567
    "Modified: / 22.2.1999 / 20:14:48 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   568
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   569
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   570
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   571
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   572
    "
1313
0d0a82851838 only send message to app (instead of view)
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
   573
    |value argument numArgs isKindOfValueModel rec arg2 app|
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
    anItem isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   576
	self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   577
      ^ nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   578
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   579
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   580
    self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   581
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   582
    (value := anItem value) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   583
	^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   584
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   585
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   586
    (argument := anItem argument) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   587
	argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   588
    ].
524
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
    value isSymbol ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   591
	numArgs := value perform:#numArgs ifNotUnderstood:0.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   592
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   593
	numArgs == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   594
	    value value
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   595
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   596
	    numArgs == 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   597
		value value:argument]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   598
	    ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   599
		value value:argument value:self
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   600
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   601
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   602
	self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   603
      ^ anIndex
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   604
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   605
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   606
    aReceiver isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   607
	^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   608
    ].
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   609
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   610
    isKindOfValueModel := aReceiver isValueModel.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   611
    isKindOfValueModel ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   612
	aReceiver value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   613
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   614
	rec := aReceiver.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   615
	arg2 := self.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   616
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   617
	"/ support for ST80 style applications
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   618
	"/ (expecting the message to go to the application
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   619
	"/  if not understood by the view)
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   620
	"/ These expect the controller to be passed as argument.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   621
	"/ sigh.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   622
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   623
	(aReceiver isView
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   624
	and:[(aReceiver respondsTo:value) not
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   625
	and:[(app := aReceiver application) ~~ aReceiver
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   626
	and:[app notNil]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   627
	    rec := app.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   628
	    arg2 := aReceiver controller "/ the Views controller
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   629
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   630
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   631
	(numArgs := value numArgs) == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   632
	    rec perform:value
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   633
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   634
	    numArgs == 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   635
		rec perform:value with:argument
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   636
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   637
		rec perform:value with:argument with:arg2
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   638
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   639
	]
420
ca
parents: 417
diff changeset
   640
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   641
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   642
    ^ value
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   643
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   644
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   645
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   646
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   647
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   648
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   649
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   650
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   651
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   652
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   653
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   654
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   655
"/    |top|
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   656
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   657
"/    top := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   658
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   659
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   660
"/        ^ self topMenu menuAdornmentAt:#value.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   661
"/    ].
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   662
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   663
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   664
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   665
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   666
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   667
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   668
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   669
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   670
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   671
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   672
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   673
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   674
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   675
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   676
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   677
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   678
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   679
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   681
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   682
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   683
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   684
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   685
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   686
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   687
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   688
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   689
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   690
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   691
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   692
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   693
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   694
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   695
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   696
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   697
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   698
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   699
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   700
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   701
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   702
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   703
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   704
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   705
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   706
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   707
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   708
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   709
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   710
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   711
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   712
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   713
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   714
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   715
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   716
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   717
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   718
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   719
    "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
   720
     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
   721
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   722
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   723
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   724
    "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
   725
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   726
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   727
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   728
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   729
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   730
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   731
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   732
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   733
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   734
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   735
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   736
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   737
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   738
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   739
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   740
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   741
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   742
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   743
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   744
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   745
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   746
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   747
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   748
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   749
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   750
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   751
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   752
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   753
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   754
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   755
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   756
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   757
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   758
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   759
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   760
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   761
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   762
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   763
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   764
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   765
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   766
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   767
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   768
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   769
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   770
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   771
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   772
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   773
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   774
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   775
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   776
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   777
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   778
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   779
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   780
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   781
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   782
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   783
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   784
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   785
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   786
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   787
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   788
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   789
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   790
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   791
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   792
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   793
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   794
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   795
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   796
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   797
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   798
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   799
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   800
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   801
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   802
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   803
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   804
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   805
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   806
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   807
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   808
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   809
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   810
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   811
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   812
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   813
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   814
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   815
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   816
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   817
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   818
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   819
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   820
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   821
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   822
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   823
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   824
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   825
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   826
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   827
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   828
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   829
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   830
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   831
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   832
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   833
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   834
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   835
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   836
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   837
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   838
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   839
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   840
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   841
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   842
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   843
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   844
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   845
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   846
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   847
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   848
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   849
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   850
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   851
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   852
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   853
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   854
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   855
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   856
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   857
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   858
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   859
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   860
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   861
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   862
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   863
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   864
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   865
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   866
!MenuPanel methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   867
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   868
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   869
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   870
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   871
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   872
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   873
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   874
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   875
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   876
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   877
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   878
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   879
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   880
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   881
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   882
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   883
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   884
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   885
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   886
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   887
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   888
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   889
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   890
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   891
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   892
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   893
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   894
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   895
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   896
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   897
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   898
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   899
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   900
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   901
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   902
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
   903
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   904
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   905
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   906
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
   907
    enabled == state ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   908
	^ self
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   909
    ].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   910
    enabled := state.
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   911
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   912
    self canDrawItem ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   913
	self do:[:anItem| anItem enabledStateOfMenuChangedTo:enabled]
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   914
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   915
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   916
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   917
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   918
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   919
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   920
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   921
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   922
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   923
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   924
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   925
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   926
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   927
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   928
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   929
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   930
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   931
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   932
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   933
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   934
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   935
!MenuPanel methodsFor:'accessing channels'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   936
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   937
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   938
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   939
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   940
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   941
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   942
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   943
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   944
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   945
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   946
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   947
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   948
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   949
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   950
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   951
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   952
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   953
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   954
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   955
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   956
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   957
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   958
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   959
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   960
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   961
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   962
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   963
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   964
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   965
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   966
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   967
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   968
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   969
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   970
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   971
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   972
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   973
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   974
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   975
!MenuPanel methodsFor:'accessing color & font'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   976
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   977
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   978
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   979
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   980
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   981
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   982
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   983
activeBackgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   984
    "set the background drawing color used to highlight selection. You should not 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   985
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   986
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   987
    activeBgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   988
	activeBgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   989
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   990
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   991
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   992
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   993
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   994
    "Modified: / 6.6.1998 / 19:49:46 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   995
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   996
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   997
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   998
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   999
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1000
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1001
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1002
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1003
activeForegroundColor:aColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1004
    "set the foreground color used to highlight selections; You should not
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1005
     use this method; instead leave the value as defined in the styleSheet.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1006
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1007
    activeFgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1008
	activeFgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1009
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1010
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1011
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1012
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1013
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1014
    "Modified: / 6.6.1998 / 19:50:01 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1015
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1016
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1017
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1018
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1019
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1020
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1021
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1022
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1023
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1024
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1025
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1026
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1027
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1028
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1029
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1030
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1031
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1032
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1033
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1034
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1035
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1036
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1037
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1038
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1039
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1040
    ^ButtonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1041
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1042
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1043
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1044
    "get the button edge style
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1045
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1046
    ^ButtonEdgeStyle
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
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1049
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1050
    "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
  1051
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1052
    ^ buttonEnteredBgColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1053
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1054
    "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
  1055
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1056
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1057
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1058
    "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
  1059
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1060
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1061
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1062
    "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
  1063
    "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
  1064
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1065
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1066
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1067
    "get the background drawing color used to half light button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1068
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1069
    ^buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1070
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1071
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1072
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1073
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1074
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1075
    ^buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1076
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1077
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1078
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1079
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1080
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1081
    ^buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1082
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1083
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1084
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1085
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1086
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1087
    ^ButtonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1088
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1089
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1090
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1091
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1092
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1093
    ^buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1094
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1095
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1096
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1097
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1098
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1099
  ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1100
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1101
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1102
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1103
disabledForegroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1104
    "set the foregroundColor drawing color used by disabled items. You should not
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1105
     use this method; instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1106
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1107
    disabledFgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1108
	disabledFgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1109
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1110
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1111
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1112
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1113
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1114
    "Modified: / 6.6.1998 / 19:50:17 / cg"
390
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
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1118
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1119
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1120
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1121
	super font:(aFont on:device).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1122
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1123
	superMenu notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1124
	    self extent:(self preferredExtent)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1125
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1126
	self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1127
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1128
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1129
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1130
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1131
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1132
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1133
  ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1134
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
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1139
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1140
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1141
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1142
    fgColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1143
	fgColor := aColor on:device.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1144
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1145
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1146
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1147
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1148
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1149
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1150
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1151
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1152
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1153
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1154
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1155
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1156
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1157
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1158
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1159
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1160
lightColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1161
    "set the light drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1162
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1163
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1164
    lightColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1165
	super lightColor:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1166
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1167
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1168
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1169
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1170
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1171
    "Modified: / 6.6.1998 / 19:50:39 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1172
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1173
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1174
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1175
    "get the selection frame bright color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1176
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1177
    ^selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1178
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1179
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1180
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1181
    "get the selection frame dark color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1182
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1183
    ^selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1184
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1185
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1186
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1187
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1188
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1189
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1190
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1191
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1192
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1193
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1194
shadowColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1195
    "set the shadow drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1196
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1197
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1198
    shadowColor ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1199
	super shadowColor:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1200
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1201
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1202
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1203
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1204
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1205
    "Modified: / 6.6.1998 / 19:50:32 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1206
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1207
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1208
!MenuPanel methodsFor:'accessing dimensions'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1209
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1210
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1211
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1212
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1213
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1214
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1215
    (explicitExtent ~~ true) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1216
	(item := self itemAt:1) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1217
	    self rearrangeItems.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1218
	  ^ item height
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1219
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1220
	^ 4 + (font height + (font descent * 2)).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1221
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1222
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1223
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1224
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1225
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1226
    "compute and returns my preferred extent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1227
    "
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1228
    |x y hasMenu shCtKey space hrzInset|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1229
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1230
    self numberOfItems == 0 ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1231
        ^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1232
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1233
    space := (items size + 1) * itemSpace.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1234
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1235
    self isFitPanel ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1236
        x := 0
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1237
    ] ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1238
        x := groupSizes size * groupDividerSize.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1239
    ].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  1240
    hrzInset := items first horizontalInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1241
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1242
    self verticalLayout ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1243
        "/ horizontal - add x-extents; take max of y-extents
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1244
        y := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1245
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1246
        self do:[:el| |elY elPref|
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1247
            el isVisible ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1248
                elPref := el preferredExtent.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1249
                x := x + elPref x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1250
                elY := elPref y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1251
                el isButton ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1252
                    elY := elY + (2 * DefaultButtonItemSpace).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1253
                    x := x + (2 * DefaultButtonItemSpace).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1254
                ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1255
                y := y max:elY.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1256
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1257
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1258
        x := x + space.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1259
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1260
        "/ vertical - add y-extents
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1261
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1262
        shCtKey := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1263
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1264
        x := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1265
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1266
        self do:[:el| |l e|
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1267
            el isVisible ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1268
                (l := el rawLabel) notNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1269
                    (e := l widthOn:self) > x ifTrue:[x := e].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1270
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1271
                    el hasSubmenu ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1272
                        hasMenu := true
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1273
                    ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1274
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1275
                    (     (l := el shortcutKeyAsString) notNil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1276
                     and:[(e := l widthOn:self) > shCtKey]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1277
                    ) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1278
                        shCtKey := e
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1279
                    ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1280
                ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1281
                y := y + el preferredExtent y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1282
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1283
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1284
        x := x + hrzInset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1285
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1286
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1287
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1288
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1289
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1290
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1291
                x := x + (Item shortcutKeyOffset) 
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1292
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1293
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1294
        y := y + space.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1295
        x := x + hrzInset.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
    ].
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  1297
    ^ (x @ y) + (margin + margin)
1095
44b55760239b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1093
diff changeset
  1298
44b55760239b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1093
diff changeset
  1299
    "Modified: / 24.8.1998 / 19:16:02 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1301
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1302
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1303
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1304
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1305
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1306
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1307
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1308
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1309
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1310
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1311
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1312
!MenuPanel methodsFor:'accessing items'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1313
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1314
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1315
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1316
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1317
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1318
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1319
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1320
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1321
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1322
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1323
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1324
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1325
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1326
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1327
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1328
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1329
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1330
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1331
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1332
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1333
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1334
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1335
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1336
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1337
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1338
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1339
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1340
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1341
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1342
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1343
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1344
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1345
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1346
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1347
    ^ items notNil ifTrue:[items at:anIndex ifAbsent:nil] ifFalse:[nil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1348
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1349
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1350
!MenuPanel methodsFor:'accessing look'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1351
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1352
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1353
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1354
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1355
    ^ButtonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1356
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1357
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1358
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1359
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1360
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1361
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1362
    ^ButtonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1363
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1364
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1365
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1366
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1367
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1368
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1369
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1370
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1371
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1372
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1373
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1374
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1375
     to the extent of its superView
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1376
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1377
    (fitFirstPanel == aState or:[self isPopUpView]) ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1378
	fitFirstPanel := aState.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1379
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1380
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1381
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1382
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1383
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1384
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1385
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1386
  ^ groupDividerSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1387
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1388
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1389
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1390
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1391
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1392
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1393
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1394
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1395
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1396
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1397
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1398
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1399
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1400
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1401
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1402
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1403
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1404
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1405
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1406
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1407
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1408
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1409
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1410
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1411
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1412
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1413
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1414
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1415
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1416
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1417
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1418
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1419
level:anInt
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1420
    super level:anInt.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1421
    mustRearrange := true
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1422
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1423
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1424
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1425
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1426
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1427
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1428
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1429
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1430
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1431
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1432
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1433
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1434
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1435
  ^ (self menuAdornmentAt:#showGroupDivider)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1436
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1437
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1438
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1439
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1440
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1441
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1442
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1443
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1444
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1445
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1446
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1447
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1448
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1449
  ^ (self menuAdornmentAt:#showSeparatingLines)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1450
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1451
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1452
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1453
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1454
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1455
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1456
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1457
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1458
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1459
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1460
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1461
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1462
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1463
  ^ (self menuAdornmentAt:#verticalLayout)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1464
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1465
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1466
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1467
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1468
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1469
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1470
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1471
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1472
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1473
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
!MenuPanel methodsFor:'accessing submenu'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1475
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1476
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1477
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1478
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1479
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1480
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1481
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1482
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1483
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1484
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1485
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1486
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1487
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1488
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1489
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1491
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1492
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1493
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1494
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1495
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1496
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1497
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1498
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1499
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1500
!MenuPanel methodsFor:'activation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1501
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1502
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1503
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1504
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1505
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1506
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1507
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1508
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1509
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1510
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1511
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1512
show
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1513
    "realize the view at its last position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1514
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1515
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1516
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1517
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1518
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1519
showAt:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1520
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1521
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1522
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1523
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1524
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1525
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1526
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1527
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1528
    "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
  1529
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1530
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1531
     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
  1532
     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
  1533
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1534
    "
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1535
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1536
    self initPopUpDependentStyle:true.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1537
    self rearrangeItemsIfItemVisibilityChanged.
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1538
"/    self rearrangeItems.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1539
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1540
    aBoolean ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1541
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1542
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1543
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1544
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1545
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1546
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1547
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1548
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1549
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1550
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1551
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1552
    ].
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1553
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1554
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1555
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1556
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1557
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1558
showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1559
    "realize the view at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1560
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1561
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1562
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1563
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1564
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1565
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1566
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1567
    "make myself visible at the screen center.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1568
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1569
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1570
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1571
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1572
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1573
    ^ 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
  1574
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1575
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1576
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1577
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1578
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1579
    "realize the menu at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1580
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1581
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1582
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1583
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1584
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1585
    "realize the menu at aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1586
    "
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1587
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1588
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1589
    "Created: / 21.5.1998 / 14:15:57 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1590
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1591
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1592
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1593
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1594
createAtIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1595
    "create an item and add this item to the index. In case of nil the item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1596
     is added to the end. If the index is not valid nil is returned otherwise
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1597
     the new created item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1598
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1599
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1600
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1601
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1602
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1603
    anIndexOrNil notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1604
	(anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1605
	    ^ nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1606
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1607
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
    items isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1609
	items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1610
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1611
	items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1612
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1613
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1615
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1616
	items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1617
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1618
	items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1619
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1620
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1621
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1622
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1623
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1624
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1625
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1626
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1627
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1629
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1630
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1631
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1632
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1633
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1634
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1635
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1636
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1637
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1638
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1639
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1640
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1641
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1642
	self selection:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1643
	groupSizes := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1644
	self do:[:el| el destroy ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1645
	items := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1646
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1647
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1649
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1650
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1651
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1652
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1653
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1654
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1655
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1656
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1657
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1658
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1659
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1660
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1661
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1662
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1663
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1664
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1665
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1666
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1667
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1668
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1669
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1670
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1671
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1672
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1673
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1674
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1675
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1676
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1677
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1678
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1679
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1681
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1682
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1683
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1684
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1685
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1686
    self disabledRedrawDo:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1687
	|menu newItems|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1688
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1689
	self removeAll.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1690
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1691
	(menu := aMenu) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1692
	    (aMenu isCollection) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1693
		menu := Menu new.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1694
		menu fromLiteralArrayEncoding:aMenu.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1695
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1696
		menu receiver notNil ifTrue:[receiver := menu receiver]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1697
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1698
	    (newItems := menu menuItems) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1699
		items := newItems collect:[:ni | 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1700
				|i|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1701
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1702
				i:= Item in:self.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1703
				i menuItem:ni.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1704
				i.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1705
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1706
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1707
	    self groupSizes:(menu groupSizes).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1708
	]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1709
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1710
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1711
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1712
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1713
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1714
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1715
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1716
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1717
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1718
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1719
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1720
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1721
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1722
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1723
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1729
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
  1730
    |shadow|
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1731
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1732
    styleSheet is3D ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1733
	^ self displayRectangle:layout.
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1734
    ].
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1735
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1736
    shadow := buttonShadowColor.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1737
"/
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1738
"/ never encountered ?
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1739
"/
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1740
"/    isSelected ifTrue:[
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1741
"/        buttonShadowColor == self buttonActiveBackgroundColor ifTrue:[
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1742
"/            shadow := buttonShadowColor darkened
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1743
"/        ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  1744
"/    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1745
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1746
    self drawEdgesForX: layout left y: layout top width: layout width height: layout height level: aLevel 
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1747
	shadow:      shadow 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1748
	light:       buttonLightColor
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1749
	halfShadow:  buttonHalfShadowColor 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1750
	halfLight:   buttonHalfLightColor
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1751
	style:       ButtonEdgeStyle
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  1752
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1753
    "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
  1754
    "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
  1755
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1756
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1757
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
  1758
    |level|
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1759
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1760
    level := selectedBool 
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1761
		ifTrue:[onLevel] 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1762
		ifFalse:[offLevel].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1763
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1764
    level ~~ 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1765
	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
  1766
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1767
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1768
    "Modified: / 20.8.1998 / 15:43:11 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1769
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1770
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1771
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1772
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1773
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1774
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1775
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1776
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1777
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1778
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1779
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1780
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1781
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1783
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1784
rearrangeGroups
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1785
    |layout
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1786
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1787
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1788
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1789
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1790
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1791
	^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1792
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1793
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1794
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1795
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1796
    (dltX := width "- margin" "- 2" - layout right) <= 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1797
	^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1798
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1799
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1800
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1801
    start == 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1802
	^ self  "/ no item detected
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1803
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1804
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1805
    "/ change layout
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1806
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1807
    items from:start do:[:anItem|
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1808
	anItem isVisible ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1809
	    layout := anItem layout.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1810
	    layout  left:(layout  left + dltX).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1811
	    layout right:(layout right + dltX).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1812
	]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1813
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1814
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1815
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1816
rearrangeItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1817
    "recompute layout of my items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1818
    "
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1819
    |expLast e grpDivSz layout isVert
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1820
     x  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1821
     y  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1822
     noItems "{ Class:SmallInteger }"
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1823
     f
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1824
    |
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1825
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1826
    mustRearrange ifFalse:[ ^ self ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1827
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1828
"/  fetch font from superMenu
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1829
    (superMenu notNil and:[(f := superMenu font) ~~ font]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1830
	super font:(f on:device)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1831
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1832
    (noItems := items size) == 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1833
	mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1834
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1835
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1836
    expLast  := false.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1837
    isVert   := self verticalLayout.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1838
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1839
    self hasGroupDividers ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1840
	self isFitPanel ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1841
	    grpDivSz := groupDividerSize
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1842
	] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1843
	    expLast := true.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1844
	    x := margin.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1845
	    e := self computeExtent.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1846
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1847
	    isVert ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1848
		items do:[:el | x := x + el preferredExtent y].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1849
		y := e y.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1850
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1851
		items do:[:el|x := x + el preferredExtent x].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1852
		y := e x.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1853
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1854
	    x := x + (noItems + 1 * itemSpace).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1855
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1856
	    (grpDivSz := (y - x) // (groupSizes size)) <= 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1857
		grpDivSz := nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1858
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1859
	    x > (width-margin) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1860
		grpDivSz := nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1861
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1862
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1863
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1864
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1865
    (self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1866
	e := self preferredExtent copy.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1867
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1868
	self isPopUpView ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1869
	    isVert ifTrue:[e y:1.0]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1870
		  ifFalse:[e x:1.0]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1871
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1872
	self extent:e
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1873
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1874
	e := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1875
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  1876
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1877
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1878
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1879
    isVert ifTrue:[y := y + itemSpace]
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1880
	  ifFalse:[x := x + itemSpace].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1881
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1882
    self keysAndValuesDo:[:anIndex :el| |org corn elPref|
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1883
	el isVisible ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1884
	    el isButton ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1885
		org := Point x:(x+DefaultButtonItemSpace) y:(y+DefaultButtonItemSpace).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1886
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1887
		org := Point x:x y:y.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1888
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1889
	    elPref := el preferredExtent.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1890
	    isVert ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1891
		y := y + elPref y.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1892
		corn := (e x - margin @ y).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1893
		el isButton ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1894
		    corn := corn - (DefaultButtonItemSpace @ 0).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1895
		    el layout:(Rectangle origin:org corner:corn).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1896
		    y := y + (2 * DefaultButtonItemSpace).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1897
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1898
		    el layout:(Rectangle origin:org corner:corn).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1899
		].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1900
		y := y + itemSpace.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1901
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1902
		x := x + elPref x.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1903
		el isButton ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1904
		    x := x + DefaultButtonItemSpace.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1905
		    corn := (x @ (e y - margin)).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1906
		    corn := corn - (0 @ DefaultButtonItemSpace).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1907
		    el layout:(Rectangle origin:org corner:corn).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1908
		    x := x + DefaultButtonItemSpace.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1909
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1910
		    corn := (x @ e y).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1911
		    el layout:(Rectangle origin:org corner:corn).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1912
		].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1913
		x := x + itemSpace.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1914
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1915
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1916
	    (grpDivSz notNil and:[self hasGroupDividerAt:anIndex]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1917
		isVert ifTrue:[y := y + grpDivSz]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1918
		      ifFalse:[x := x + grpDivSz]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1919
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1920
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1921
	    org := Point x:x y:y.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1922
	    el layout:(Rectangle origin:org corner:org)
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1923
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1924
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1925
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1926
    expLast ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1927
	e := items last.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1928
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1929
	e isVisible ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1930
	    layout := items last layout.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1931
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1932
	    isVert ifTrue:[layout bottom:((self extent y) + 1)]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1933
		  ifFalse:[layout  right:((self extent x) + 1)].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1934
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1935
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1936
    self rearrangeGroups.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1937
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1938
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1939
    "Modified: / 19.1.1999 / 16:00:14 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1940
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1941
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1942
rearrangeItemsIfItemVisibilityChanged
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1943
    "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
  1944
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1945
    items isNil ifTrue:[^ self].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1946
    items do:[:item |
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1947
        item canChangeVisibility ifTrue:[
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1948
            mustRearrange := true.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1949
            self rearrangeItems.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1950
            ^ self
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  1951
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1952
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1953
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  1954
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1955
redrawX:x y:y width:w height:h
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
    "redraw a rectangle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1957
    "
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1958
    |start end isVrt x1 x2 y1 y2 item layout lnSz hrzInset 
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1959
     prevClip didRearrange|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1960
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1961
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1962
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1963
    self  paint:(self backgroundColor).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1964
    self  clearRectangleX:x y:y width:w height:h.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1965
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1966
    isVrt := self verticalLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1967
    end   := items size.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1968
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1969
    (didRearrange := mustRearrange) ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1970
        self isPopUpView not ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1971
            explicitExtent := true
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1972
        ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1973
        self rearrangeItems.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1974
        start := 1
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1975
    ] ifFalse:[
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1976
        end == 0 ifTrue:[ ^ self ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1977
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1978
        isVrt ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1979
            start := self findFirst:[:el| (el layout bottom) >= y ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1980
            start == 0 ifTrue:[ ^ self ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1981
            end := y + h.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1982
            end := self findLast:[:el| (el layout top) < end ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1983
        ] ifFalse:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1984
            start := self findFirst:[:el| (el layout right) >= x ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1985
            start == 0 ifTrue:[ ^ self ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1986
            end := x + w.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1987
            end := self findLast:[:el| (el layout left) < end ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1988
        ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1989
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1990
        (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1991
            start := start - 1
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1992
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1993
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1994
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1995
    (     self hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1996
     and:[self showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1997
     and:[self isFitPanel not]]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1998
    ) ifTrue:[
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  1999
        lnSz := groupDividerSize // 2
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2000
    ].
1101
22eb87115477 level on default 1
ca
parents: 1097
diff changeset
  2001
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2002
    end == 0 ifTrue:[^ self ].
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2003
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2004
    hrzInset := items first horizontalInset.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2005
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2006
    didRearrange ifFalse:[
1388
e82976e15b92 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1387
diff changeset
  2007
        prevClip := clipRect.
e82976e15b92 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1387
diff changeset
  2008
        self clippingRectangle:(Rectangle left:x top:y width:w height:h).
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2009
    ].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  2010
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2011
    start to:end do:[:i|
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2012
        item := items at:i.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2013
        item redraw.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2014
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2015
        (lnSz notNil and:[self hasGroupDividerAt:i]) ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2016
            layout := item layout.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2017
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2018
            isVrt ifTrue:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2019
                x1 := layout left  + hrzInset.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2020
                x2 := layout right - hrzInset.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2021
                y1 := (layout bottom) + lnSz.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2022
                y2 := y1.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2023
            ] ifFalse:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2024
                x1 := (layout right) + lnSz.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2025
                x2 := x1.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2026
                y1 := layout top.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2027
                y2 := layout bottom.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2028
            ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2029
            self paint:(self shadowColor).
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2030
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2031
            self paint:(self lightColor).
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2032
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2033
            isVrt ifTrue:[y1 := y1 + 1. y2 := y1 ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2034
                 ifFalse:[x1 := x1 + 1. x2 := x1 ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2035
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2036
            self displayLineFromX:x1 y:y1 toX:x2 y:y2
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2037
        ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2038
    ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2039
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2040
    didRearrange ifFalse:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2041
        self clippingRectangle:prevClip
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2042
    ].
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2043
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2044
    "Modified: / 21.5.1999 / 20:14:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2045
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2046
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2047
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2048
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2049
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2050
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2051
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2052
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2053
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2054
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2055
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2056
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2057
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2058
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2059
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2060
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2061
    items notNil ifTrue:[ items do:aOneArgBlock ].
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
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2066
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2067
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2068
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2069
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2070
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2071
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2072
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2073
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2074
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2075
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2076
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2077
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2078
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2079
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2080
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2081
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2082
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2083
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2084
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2085
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2086
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2087
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2088
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2089
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2090
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2091
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2092
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2093
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2094
    i ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2095
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2096
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2097
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2098
    something isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2099
	i := self findFirst:[:el|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2100
				v := el value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2101
				v isSymbol and:[v == something]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2102
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2103
	i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2104
	    ^ i
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2105
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2106
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2107
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2108
    (something respondsTo:#string) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2109
	v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2110
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2111
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2112
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2113
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2115
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2116
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2117
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2118
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2119
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2120
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2121
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2122
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2123
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2124
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2125
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2126
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2127
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2128
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2129
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2130
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2131
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2132
    "
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2133
    |menu point sensor sel itm|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2134
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2135
    (    (sensor := self sensor) notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2136
     and:[sensor hasButtonMotionEventFor:nil]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2137
    ) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2138
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2139
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2140
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2141
    sensor anyButtonPressed ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2142
	"/ TODO: remember item over which pointer is
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2143
	"/ (for enteredFG/enteredBG/enteredLevel handling)
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2144
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2145
        
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2146
	(buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2147
	or:[ButtonEnteredLevel ~~ ButtonPassiveLevel]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2148
	    (self containsPointX:x y:y) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2149
		((sel := self itemAtX:x y:y) notNil 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2150
		and:[sel isButton 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2151
		and:[superMenu isNil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2152
		and:[sel canSelect]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2153
		    itm := sel.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2154
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2155
		    itm := nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2156
		].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2157
		self itemEntered:itm.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2158
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2159
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2160
	^ self
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2161
    ].
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
    "/ ok, a button is pressed.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2164
    (buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2165
    or:[ButtonEnteredLevel ~~ ButtonPassiveLevel]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2166
	self itemEntered:nil.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2167
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2168
1044
3584c06b9e44 add button behaviour:
ca
parents: 1039
diff changeset
  2169
    lastButtonSelected notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2170
	^ self
1044
3584c06b9e44 add button behaviour:
ca
parents: 1039
diff changeset
  2171
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2172
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2173
    (self containsPointX:x y:y) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2174
	((sel := self itemAtX:x y:y) notNil 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2175
	and:[sel isButton 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2176
	and:[superMenu isNil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2177
	and:[sel canSelect]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2178
	    lastButtonSelected := sel
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2179
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2180
	^ self selection:sel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2181
    ].
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2182
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2183
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2184
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2185
    menu isNil ifTrue:[
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2186
       ^ self selection:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2187
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2188
    point := self translatePoint:(x@y) to:menu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2189
    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
  2190
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  2191
    "Modified: / 22.8.1998 / 12:51:17 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2192
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2193
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2194
buttonPress:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2195
    "any button pressed; open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2196
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2197
    |menu point item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2198
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2199
    menu := self superMenuAtX:x y:y.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2200
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2201
    menu isNil ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2202
        menu := self topMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2203
    ] ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2204
        point := self translatePoint:(x@y) to:menu.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2205
        item  := menu itemAtX:(point x) y:(point y)
1255
f18c03dc613f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2206
    ].
f18c03dc613f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2207
    menu selection:item.
f18c03dc613f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2208
f18c03dc613f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2209
    self requestFocus
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
buttonRelease:button x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
    "button release action; accept selection and close all views
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2214
    "
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2215
    |menu item|
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2216
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2217
    menu := self topMenu activeMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2218
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2219
    (    menu selection notNil
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2220
     or:[menu isPopUpView not
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2221
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2222
                                and:(menu mapTime)) > 200]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2223
    ) ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2224
        item := nil.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2225
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2226
        (     (menu := self superMenuAtX:x y:y) notNil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2227
         and:[(item := menu selection) notNil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2228
         and:[item hasSubmenu]]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2229
        ) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2230
            menu selection:nil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2231
        ] ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2232
            (    lastButtonSelected isNil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2233
             or:[item isNil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2234
             or:[(menu itemAtX:x y:y) == lastButtonSelected]]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2235
            ) ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2236
                item := nil
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2237
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2238
            self topMenu accept:item
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2239
        ]
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2240
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2241
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2242
    "Modified: / 27.2.1998 / 17:41:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2243
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2244
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2245
cursorPressed:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2246
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2247
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2248
    |next submenu item
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2249
     n     "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2250
     idx   "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2251
     first "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2252
    |
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2253
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2254
    (self selection isNil 
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2255
    and:[superMenu notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2256
	^ superMenu cursorPressed:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2257
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2259
    self verticalLayout ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2260
	aKey == #CursorLeft  ifTrue:[^ self selection:nil].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2261
	aKey ~~ #CursorRight ifTrue:[next := aKey == #CursorDown].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2262
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2263
	aKey == #CursorUp ifTrue:[^ self selection:nil].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2264
	aKey ~~ #CursorDown ifTrue:[next := aKey == #CursorRight].        
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2265
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2266
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2267
    next isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2268
	(item := self selection) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2269
	    (submenu := item submenu) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2270
		idx := submenu findFirst:[:el| el canSelect ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2271
	      ^ submenu selectionIndex:idx
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2272
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2273
	  ^ self selection:nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2274
	].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2275
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2276
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2277
    first := self findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2278
    first == 0 ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2279
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2280
    idx := self selectionIndex.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2281
    n   := 1 + (self sensor compressKeyPressEventsWithKey:aKey).
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2282
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2283
    n timesRepeat:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2284
	next ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2285
	    [((idx := idx + 1) <= items size and:[(items at:idx) canSelect not])
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2286
	    ] whileTrue.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2287
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2288
	    idx > items size ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2289
		idx := first
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2290
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2291
	] ifFalse:[    
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2292
	    [((idx := idx - 1) > 0  and:[(items at:idx) canSelect not])
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2293
	    ] whileTrue.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2294
            
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2295
	    idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2296
	]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2297
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2298
    self selectionIndex:idx.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2299
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2300
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2301
1199
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2302
handleFocusNext
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2303
    "handle focus next key
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2304
    "
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2305
    |idx|
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2306
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2307
    (self isPopUpView or:[items isNil]) ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2308
	idx := self selectionIndex.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2309
	idx := items findFirst:[:el|el canSelect] startingAt:(1 + idx).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2310
	idx ~~ 0 ifTrue:[ ^ self selectionIndex:idx ]
1199
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2311
    ].
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2312
    self selection:nil.
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2313
    self windowGroup focusNextFrom:self.
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2314
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2315
!
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2316
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2317
handleFocusPrevious
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2318
    "handle focus previous
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
    |idx sel|
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2321
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2322
    (self isPopUpView or:[items isNil]) ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2323
	sel := self selectionIndex.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2324
	idx := sel == 0 ifTrue:[self numberOfItems]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2325
		       ifFalse:[sel - 1].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2326
	idx := items findLast:[:el|el canSelect] startingAt:idx.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2327
	idx ~~ 0 ifTrue:[ ^ self selectionIndex:idx ]
1199
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
    self selection:nil.
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2330
    self windowGroup focusPreviousFrom:self.
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2331
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
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2334
itemEntered:anItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2335
    |prevEnteredItem|
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2336
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2337
    anItem == enteredItem ifTrue:[^ self].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2338
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2339
    prevEnteredItem := enteredItem.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2340
    enteredItem := anItem.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2341
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2342
    prevEnteredItem notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2343
	prevEnteredItem redraw
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2344
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2345
    enteredItem notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2346
	enteredItem redraw
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2347
    ].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2348
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2349
    "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
  2350
    "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
  2351
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2352
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2353
keyPress:key x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2354
    "any key is pressed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2355
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2356
    |listOfItems item menu idx cIdx upperKey lowerKey rawKey|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2357
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2358
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2359
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2360
    [ menu shown ] whileFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2361
	(menu := superMenu) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2362
	    ^ self
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2363
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2364
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2365
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2366
    key == #Return ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2367
	^ menu accept
1199
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2368
    ].
73c48a823430 add focusNext/focusPrevious
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  2369
1250
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2370
    "/ cg: must hide the active menu ...
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2371
    key == #Escape ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2372
	menu isPopUpView ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2373
	    menu hide
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2374
	]
1250
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2375
    ].
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2376
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2377
"/    (key == #Tab or:[key == #FocusNext]) ifTrue:[
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2378
"/        ^ self topMenu handleFocusNext
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2379
"/    ].
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2380
"/    key == #FocusPrevious ifTrue:[
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2381
"/        ^ self topMenu handleFocusPrevious
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2382
"/    ].
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2383
    "/ CG: the old code above prevented
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2384
    "/ tabbing to the next view ...
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2385
    (key == #Tab 
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2386
    or:[key == #FocusNext
021204b5bde5 hide menu on ESC;
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  2387
    or:[key == #FocusPrevious]]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2388
	"/ if there is a menu open, hide it ...
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2389
	self isPopUpView ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2390
	    ^ super keyPress:key x:x y:y
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2391
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2392
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2393
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2394
    (     key == #CursorDown or:[key == #CursorUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2395
      or:[key == #CursorLeft or:[key == #CursorRight]]]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2396
    ) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2397
	^ menu cursorPressed:key
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2398
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2399
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2400
    rawKey := device keyboardMap keyAtValue:key ifAbsent:key.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2401
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2402
    listOfItems := self selectItemsForShortcutKey:rawKey.
1240
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2403
    (listOfItems isNil and:[key ~~ rawKey]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2404
	listOfItems := self selectItemsForShortcutKey:key.
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2405
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2406
    listOfItems notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2407
	item := listOfItems first.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2408
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2409
	item hasSubmenu ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2410
	    ^ menu accept:item
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2411
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2412
	^ self openMenusFromItems:listOfItems
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2413
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2414
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2415
    (self selection isNil and:[superMenu notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2416
	(superMenu containsPoint:(self translatePoint:(x@y) to:superMenu)) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2417
	    menu := superMenu
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2418
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2419
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2420
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2421
    cIdx := menu selectionIndex.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2422
    cIdx isNil ifTrue:[cIdx := 0].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2423
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2424
    upperKey := key asUppercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2425
    lowerKey := key asLowercase.
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  2426
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2427
    menu keysAndValuesDo:[:anIndex :el| |c l|
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2428
	(el canSelect and:[(l := el textLabel) notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2429
	    l size ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2430
		(c := el accessCharacter) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2431
		    (c == upperKey or:[c == lowerKey]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2432
			^ menu selection:el
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2433
		    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2434
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2435
		    ((c := l first) == upperKey or:[c == lowerKey]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2436
			anIndex > cIdx ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2437
			    ^ menu selection:el
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2438
			] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2439
			    idx isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2440
				idx := anIndex
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2441
			    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2442
				anIndex > idx ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2443
				    anIndex ~~ cIdx ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2444
					idx := anIndex
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2445
				    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2446
				]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2447
			    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2448
			]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2449
                        
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2450
		    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2451
		]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2452
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2453
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2454
    ].
417
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2455
    (item := menu itemAt:idx) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2456
	menu selection isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2457
	    (menu := menu superMenu) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2458
		^ super keyPress:key x:x y:y
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2459
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2460
	]
417
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2461
    ].
5b6e4e3b44dd focusSequence no longer used; in SimpleView
ca
parents: 416
diff changeset
  2462
    menu selection:item.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2463
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2464
    "Modified: / 8.8.1998 / 13:38:36 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2465
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2466
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2467
pointerLeave:state
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2468
    self itemEntered:nil.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2469
    super pointerLeave:state
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2470
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2471
    "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
  2472
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2473
1240
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2474
processShortcutKeyEventInMenuBar:event
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2475
    "an event as forwarded from the keyboardProcessor -
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2476
     if there is a short-key for that character, process it
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2477
     and return true. Otherwise, return false."
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2478
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2479
    |key rawKey listOfItems item|
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2480
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2481
    key := event key.
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2482
    rawKey := device keyboardMap keyAtValue:key ifAbsent:key.
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2483
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2484
    listOfItems := self selectItemsForShortcutKey:rawKey.
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2485
    (listOfItems isNil and:[key ~~ rawKey]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2486
	listOfItems := self selectItemsForShortcutKey:key.
1240
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2487
    ].
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2488
    listOfItems notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2489
	item := listOfItems first.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2490
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2491
	item hasSubmenu ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2492
	    self accept:item
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2493
	] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2494
	    self openMenusFromItems:listOfItems.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2495
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2496
	^ true.
1240
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2497
    ].
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2498
    ^ false
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2499
!
167fcc9bd9de prepared for shortKey processing (via keyboardProcessor)
Claus Gittinger <cg@exept.de>
parents: 1222
diff changeset
  2500
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2501
sizeChanged:how
1367
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2502
    "redraw #right groups
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2503
    "
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2504
    |index layout invRect w right|
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2505
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2506
    mustRearrange ifTrue:[
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2507
        ^ super sizeChanged:how
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2508
    ].
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2509
1367
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2510
    index := self findFirst:[:anItem| anItem startGroup == #right ].
3213704f7ca2 sizeChanged:
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  2511
    index ~~ 0 ifTrue:[
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2512
        (shown not or:[index == 1]) ifTrue:[
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2513
            self mustRearrange.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2514
        ] ifFalse:[
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2515
            layout := (items at:(index -1)) layout.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2516
            right  := 1 + layout right.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2517
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2518
            (w := width - right) > margin ifTrue:[
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2519
                invRect := Rectangle left:right top:0 width:w height:height.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2520
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2521
                items from:index do:[:anItem|
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2522
                    anItem isVisible ifTrue:[
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2523
                        layout := anItem layout.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2524
                        layout setLeft:right.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2525
                        right := layout right.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2526
                    ]
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2527
                ].
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2528
                self rearrangeGroups.
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2529
                self invalidate:invRect
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2530
            ]
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2531
        ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2532
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2533
    super sizeChanged:how
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2534
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2536
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2537
420
ca
parents: 417
diff changeset
  2538
forceUngrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2539
    "ungrab resources (mouse and keyboard)
420
ca
parents: 417
diff changeset
  2540
    "
ca
parents: 417
diff changeset
  2541
    |sensor|
ca
parents: 417
diff changeset
  2542
ca
parents: 417
diff changeset
  2543
    device ungrabPointer.
ca
parents: 417
diff changeset
  2544
ca
parents: 417
diff changeset
  2545
    (sensor := self sensor) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2546
	"/ make certain all X events have been received
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2547
	device sync.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2548
	"/ now all events have been received.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2549
	"/ now, flush all pointer events
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2550
	sensor flushKeyboardFor:nil
420
ca
parents: 417
diff changeset
  2551
    ].
ca
parents: 417
diff changeset
  2552
    device ungrabKeyboard.
ca
parents: 417
diff changeset
  2553
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2554
    "Modified: / 2.2.1998 / 09:24:48 / stefan"
420
ca
parents: 417
diff changeset
  2555
!
ca
parents: 417
diff changeset
  2556
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2557
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2558
    "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
  2559
     Only used for popUp menus."
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2560
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2561
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2562
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2563
    realized ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2564
	sensor := self sensor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2565
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2566
	device activePointerGrab ~~ self ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2567
	    sensor notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2568
		sensor flushMotionEventsFor:nil.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2569
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2570
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2571
	    (device grabPointerInView:self) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2572
		Delay waitForSeconds:0.1.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2573
		(device grabPointerInView:self) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2574
		    "give up"
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2575
		    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2576
		    self unmap
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2577
		]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2578
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2579
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2580
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2581
	device activeKeyboardGrab ~~ self ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2582
	    sensor notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2583
		device sync.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2584
		sensor flushKeyboardFor:nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2585
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2586
	    device grabKeyboardInView:self.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2587
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2588
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2589
	superMenu notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2590
	    self requestFocus.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2591
	    self getKeyboardFocus
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2592
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2593
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2594
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2595
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  2596
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2597
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2598
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2599
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2600
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2601
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2602
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2603
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2604
    device activePointerGrab == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2605
	device ungrabPointer.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2606
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2607
    device activeKeyboardGrab == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2608
	sensor := self sensor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2609
	sensor notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2610
	    "/ make certain all X events have been received
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2611
	    device sync.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2612
	    "/ now all events have been received.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2613
	    "/ now, flush all pointer events
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2614
	    sensor flushKeyboardFor:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2615
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2616
	device ungrabKeyboard.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2617
    ].
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2618
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2619
    "Modified: / 2.2.1998 / 10:27:12 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2620
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2621
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2622
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2623
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2624
helpText
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2625
    "return the helpText for the currently selected item (empty if none)"
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2626
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2627
    |appl item key|
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2628
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2629
    (item := self selection) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2630
	(key := item activeHelpKey) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2631
	    (appl := self application) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2632
		^ (appl helpTextForKey:key) ? ''.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2633
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2634
	]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2635
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2636
    ^ '' "/ nil.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2637
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2638
    "Modified: / 31.7.1998 / 03:15:17 / cg"
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2639
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2640
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2641
helpTextAt:aPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2642
    "return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2643
     If there is a selection, that items helpText is used (ignoreing the given point).
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2644
     "
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2645
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2646
    |menu point item key appl|
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2647
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2648
    selection notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2649
	^ self helpText
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2650
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2651
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2652
    (self containsPoint:aPoint) ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2653
	superMenu notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2654
	    ^ superMenu helptext
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2655
	]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2656
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2657
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2658
    menu := self superMenuAtX:aPoint x y:aPoint y.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2659
    menu isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2660
	^ ''
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2661
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2662
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2663
    point := self translatePoint:aPoint to:menu.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2664
    item  := menu itemAtX:(point x) y:(point y).
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2665
    item  notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2666
	(key := item activeHelpKey) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2667
	    (appl := self application) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2668
		^ (appl helpTextForKey:key) ? ''.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2669
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2670
	]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2671
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2672
"/    'nil item' printCR.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2673
    ^ '' "/ nil.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2674
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2675
    "Modified: / 31.7.1998 / 03:15:07 / cg"
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2676
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2677
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2678
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2679
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2680
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2681
    "returns image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2682
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2683
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2684
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2685
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2686
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2687
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2688
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2689
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2690
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2691
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2692
!MenuPanel methodsFor:'initialize / release'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2693
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2694
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2695
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2696
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2697
    ^self
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2698
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2699
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2700
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2701
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2702
    "
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2703
    |style bw lwl|
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
  2704
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2705
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2706
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2707
    self isPopUpView ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2708
	PopUpView shadows ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2709
	    shadowView isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2710
		shadowView := (ShadowView onDevice:device) for:self
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2711
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2712
		self saveUnder:true.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2713
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2714
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2715
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2716
	explicitExtent == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2717
	    (self width) == (superView width) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2718
		self verticalLayout:false
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2719
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2720
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2721
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2722
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2723
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2724
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2725
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2726
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2727
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2728
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2729
    self clearLastActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2730
    self do:[:el|el destroy].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2731
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2732
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2733
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2734
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2735
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2736
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2737
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2738
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2739
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2740
    "Modified: / 27.2.1998 / 17:41:25 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2741
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2742
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2743
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2744
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2745
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2746
    |style|
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2747
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2748
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2749
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2750
    style := styleSheet name.
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2751
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2752
    "/ 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
  2753
    "/ (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
  2754
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2755
    onLevel := styleSheet at:#'menu.hilightLevel' default:0.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2756
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2757
    superMenu isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2758
	fgColor                   := DefaultForegroundColor         onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2759
	activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2760
	activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2761
	disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2762
	rightArrow                := RightArrowForm                 onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2763
	selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2764
	selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2765
	buttonLightColor          := ButtonLightColor               onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2766
	buttonShadowColor         := ButtonShadowColor              onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2767
	ButtonHalfLightColor notNil ifTrue: [
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2768
	    buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2769
	ButtonHalfShadowColor notNil ifTrue: [
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2770
	    buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2771
	buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2772
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2773
	(rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2774
	    rightArrowShadow := rightArrowShadow onDevice:device
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2775
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2776
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2777
	fgColor                   := superMenu foregroundColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2778
	activeBgColor             := superMenu activeBackgroundColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2779
	activeFgColor             := superMenu activeForegroundColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2780
	disabledFgColor           := superMenu disabledForegroundColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2781
	rightArrow                := superMenu rightArrow.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2782
	rightArrowShadow          := superMenu rightArrowShadow.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2783
	selectionFrameBrightColor := superMenu selectionFrameBrightColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2784
	selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2785
	buttonLightColor          := superMenu buttonLightColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2786
	buttonShadowColor         := superMenu buttonShadowColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2787
	buttonHalfLightColor      := superMenu buttonHalfLightColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2788
	buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2789
	buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2790
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2791
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2792
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2793
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2794
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2795
initPopUpDependentStyle:isPopUp
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2796
    "/ stupid - must be invoked explicit, since, 
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2797
    "/ #isPopUpView does not return a correct value at initStyle time
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2798
    "/ (thinks that all are popup views) ...
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2799
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2800
    |bw lvl|
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2801
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2802
    isPopUp ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2803
	bw := styleSheet at:#'popup.borderWidth' default:1.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2804
	lvl := styleSheet at:#'popup.level' default:0.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2805
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2806
	bw := (styleSheet is3D ifFalse:[1] ifTrue:[0]).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2807
	lvl := DefaultLevel.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2808
    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2809
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2810
    bw notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2811
	self borderWidth:bw
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2812
    ].
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2813
    lvl notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2814
	self level:lvl
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2815
    ]
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2816
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2817
!
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2818
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2819
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2820
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2821
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2822
    |style bw lwl|
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2823
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2824
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2825
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  2826
    viewBackground := DefaultBackgroundColor.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2827
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2828
    onLevel   := DefaultHilightLevel.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2829
    offLevel  := 0. "/ DefaultLevel.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2830
    itemSpace := DefaultItemSpace.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2831
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2832
    groupDividerSize := DefaultGroupDividerSize.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2833
    fitFirstPanel := DefaultFitFirstPanel.
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2834
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2835
    style := styleSheet name.
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2836
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2837
    "/ for now, assume not popUp (since superMenu is always nil at this time)
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2838
    self initPopUpDependentStyle:false.  
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2839
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2840
    font := MenuView defaultFont.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2841
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2842
    "Modified: / 15.9.1998 / 12:50:14 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2843
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2844
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2845
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2846
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2847
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2848
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2849
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2850
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2851
    enabled := true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2852
    originChanged  := extentChanged := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2853
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2854
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2855
    mustRearrange  := false.
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  2856
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2857
    "Modified: / 15.9.1998 / 12:49:51 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2858
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2859
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2860
mapped
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2861
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2862
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2863
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2864
    |anItemList|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2865
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2866
    self enableMotionEvents.
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2867
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  2868
    lastButtonSelected := nil.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2869
    self becomesActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2870
    super mapped.
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  2871
    self do:[:anItem| anItem fetchImages ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2872
1257
79a40d3f8c2f Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1255
diff changeset
  2873
    anItemList := InitialSelectionQuerySignal query.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2874
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2875
    self isPopUpView ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2876
	self grabMouseAndKeyboard
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2877
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2878
	super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2879
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2880
    self do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2881
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2882
    anItemList size > 0 ifTrue:[
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2883
"/        self invalidateRepairNow:false.
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2884
	self redrawX:0 y:0 width:width height:height.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2885
	self openMenusFromItems:anItemList.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2886
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2887
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  2888
    "Modified: / 19.11.1998 / 12:59:00 / cg"
1257
79a40d3f8c2f Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1255
diff changeset
  2889
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2890
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2891
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2892
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2893
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2894
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2895
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2896
    self isPopUpView ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2897
        "Because of #saveUnder of ShadowView the order of realize is significant:
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2898
         shadowView must be realized before self"
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2899
        self hiddenOnRealize:true.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2900
        super realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2901
        self resize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2902
        self makeFullyVisible.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2903
        shadowView notNil ifTrue:[
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2904
            shadowView realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2905
        ].
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2906
        super map.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2907
        self raise.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2908
    ] ifFalse:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2909
        super realize.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2910
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2911
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2912
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2913
recreate
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2914
    "this is called after a snapin. If the image was saved with an active menu,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2915
     hide the menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2916
    "
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  2917
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2918
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2919
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2920
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2921
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2922
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2923
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2924
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2925
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2926
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2927
    self fetchDeviceResources.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2928
    items notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2929
	items do:[:anItem |
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2930
	    anItem reinitSubmenuStyle
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2931
	]
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2932
    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2933
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2934
    "Created: / 10.9.1998 / 21:37:05 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2935
    "Modified: / 11.9.1998 / 13:20:57 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2936
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  2937
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2938
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  2939
    "unmap the view - the view stays created (but invisible), and can be remapped again later.
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  2940
     If we have a popup supermenu, it will get all keyboard and mouse events."
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2941
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2942
    self clearLastActiveMenu.
879
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  2943
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2944
    "/
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2945
    "/ Kludge for X11: after grabbing and ungrabbing other views may get buttonMotionEvents
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2946
    "/ 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
  2947
    "/ (Move from upperMenuPanel of NewLauncher to lowerMenuPanel)
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  2948
    "/
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2949
    (superMenu notNil 
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2950
    and:[superMenu shown 
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2951
    and:[superMenu isPopUpView 
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2952
	 or:[superMenu sensor anyButtonPressed]]]) 
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2953
    ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2954
	superMenu grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2955
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2956
	self ungrabMouseAndKeyboard.
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2957
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2958
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2959
    shadowView notNil ifTrue:[shadowView unmap].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2960
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2961
    "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
  2962
    "Modified: / 27.2.1998 / 17:41:24 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2963
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2964
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2965
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2966
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2967
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2968
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2969
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2970
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2971
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  2972
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2973
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2974
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2975
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2976
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2977
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2978
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2979
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2980
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2981
superMenu:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2982
    "set the supermenu starting from
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2983
    "
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2984
    |prev|
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2985
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2986
    prev := superMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2987
    superMenu := aSuperMenu.
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2988
    (prev isNil and:[superMenu notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2989
	self initPopUpDependentStyle:(self isPopUpView)
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2990
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2991
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2992
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2993
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2994
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2995
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2996
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2997
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2998
    top := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2999
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3000
    [ top superMenu notNil ] whileTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3001
	top := top superMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3002
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3003
  ^ top
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3004
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3005
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3006
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3007
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3008
!MenuPanel methodsFor:'printing'!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3009
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3010
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3011
    "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
  3012
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3013
    |string label|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3014
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3015
    string := 'Menu:'.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3016
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3017
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3018
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3019
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3020
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3021
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3022
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3023
    "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
  3024
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3025
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3026
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3027
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3028
application
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3029
    |appl|
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3030
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3031
    superMenu notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3032
	^ superMenu application
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3033
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3034
    (appl := super application) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3035
	windowGroup notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3036
	    appl := windowGroup mainGroup topViews first application
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3037
	]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3038
    ].
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3039
  ^ appl
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3040
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3041
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3042
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3043
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3044
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3045
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3046
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3047
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3048
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3049
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3050
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3051
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3052
    "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
  3053
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3054
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3055
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3056
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3057
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3058
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3059
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3060
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3061
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3062
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3063
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3064
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3065
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3066
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3067
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3068
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3069
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3070
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3071
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3072
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3073
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3074
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3075
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3077
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3078
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3079
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3080
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3081
openMenusFromItems:anItemList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3082
    "open all menus derived from sequence of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3083
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3084
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3085
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3086
    (anItemList isNil or:[anItemList isEmpty]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3087
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3088
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3089
    item := anItemList removeLast.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3090
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3091
    item enabled ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3092
	^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3093
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3094
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3095
    InitialSelectionQuerySignal answer:anItemList do:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3096
	self selection:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3097
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3098
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3099
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3100
selectItemsForShortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3101
    "get sequence of items up to the item providing the key (inclusive). The
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3102
     first entry into the collection is the item providing the key, the last
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3103
     entry is the item in the topMenu( reverse )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3104
    "
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3105
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3106
    "/ 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
  3107
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3108
    ^ self selectItemsForShortcutKey:aKey maxDepth:10
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3109
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3110
    "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
  3111
!
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3112
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3113
selectItemsForShortcutKey:aKey maxDepth:maxDepth
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3114
    "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
  3115
     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
  3116
     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
  3117
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3118
    |seq menu|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3119
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3120
    maxDepth <= 0 ifTrue:[^ nil].
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3121
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3122
    self do:[:anItem|
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3123
        anItem isEnabled ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3124
            anItem shortcutKey = aKey ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3125
                seq := OrderedCollection new.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3126
            ] ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3127
                (menu := anItem submenu) notNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3128
                    seq := menu selectItemsForShortcutKey:aKey maxDepth:maxDepth-1
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3129
                ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3130
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3131
            seq notNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3132
                seq add:anItem.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3133
              ^ seq
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3134
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3135
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3136
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3137
  ^ nil
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3138
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3139
    "Created: / 19.1.1999 / 16:00:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3140
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3141
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3142
translatePoint:aPoint to:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3143
    "translate a point into a views point; in case of no view nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3144
    "
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  3145
    aView == self ifTrue:[^ aPoint].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3146
    aView notNil ifTrue:[
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3147
      ^ device translatePoint:aPoint from:(self id) to:(aView id)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3148
    ].
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  3149
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3150
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3151
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3152
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3153
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3154
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3155
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3156
    "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
  3157
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3158
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3159
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3160
    "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
  3161
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3162
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3163
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3164
    "set the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3165
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3166
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3167
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3168
    "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
  3169
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3170
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3171
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3172
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3173
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3174
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3175
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3176
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3177
    "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
  3178
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3179
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3180
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3181
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3182
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3183
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3184
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3185
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3186
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3187
    top activeMenu == self ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3188
	top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3189
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3190
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3191
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3192
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3193
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3194
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3195
    "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
  3196
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3197
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3198
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3199
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3200
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3201
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3202
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3203
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3204
itemAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3205
    "returns item at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3206
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3207
    self do:[:el| (el containsPointX:x y:y) ifTrue:[^el] ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3208
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3209
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3210
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3211
superMenuAtX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3212
    "returns supermenu at a point or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3213
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3214
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3215
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3216
    (self containsPointX:x y:y) ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3217
    menu := self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3218
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3219
    [ (menu := menu superMenu) notNil ] whileTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3220
	(menu containsPoint:(self translatePoint:(x@y) to:menu)) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3221
	    ^ menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3222
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3223
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3224
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3225
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3226
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3227
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3229
canDrawItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3230
    "returns true if an item could be drawn otherwise false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3231
    "
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3232
    ^ (mustRearrange not and:[shown])
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3233
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3234
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3235
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3236
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3237
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3238
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3239
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3240
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3241
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3242
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3243
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3244
    ^ (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
  3245
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  3246
"/    |ext|
837cee20fdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 878
diff changeset
  3247
"/
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3248
"/    (x >= 0 and:[y >= 0]) ifTrue:[
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3249
"/        ext := self computeExtent.
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3250
"/      ^ (x < ext x and:[y < ext y])
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3251
"/    ].
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3252
"/    ^ false
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3253
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3254
    "Modified: / 29.1.1998 / 16:46:10 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3255
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3256
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3257
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3258
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3259
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3260
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3261
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3262
    groupSizes size ~~ 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3263
	i := 0.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3264
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3265
	groupSizes do:[:t|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3266
	    (i := i + t) == anIndex ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3267
		^ true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3268
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3269
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3270
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3271
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3272
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3273
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3274
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3275
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3276
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3277
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3278
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3279
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3280
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3281
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3282
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3283
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3284
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3285
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3286
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3287
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3288
    "returns true if the panel is the first in the menu hierarchy in must
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3289
     be fit to the extent of its superView
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3290
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3291
    ^ self isPopUpView ifTrue:[false] ifFalse:[fitFirstPanel]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3292
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3293
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3294
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3295
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3296
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3297
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3298
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3299
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3300
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3301
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3302
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3303
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3304
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3305
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3306
  ^ self verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3307
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3308
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3309
!
c05874084d4c implement
ca
parents: 407
diff changeset
  3310
c05874084d4c implement
ca
parents: 407
diff changeset
  3311
type
428
ca
parents: 427
diff changeset
  3312
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3313
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3314
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3315
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3316
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3317
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3318
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3319
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3320
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3321
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3322
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3323
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3324
isValidSelection:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3325
    "returns true if something could be selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3326
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3327
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3328
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3329
    enabled ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3330
	(item := self itemAt:something) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3331
	    ^ item canSelect
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3332
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3333
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3334
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3335
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3336
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3337
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3338
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3339
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3340
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3341
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3342
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3343
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3344
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3345
selection:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3346
    "change selection to an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3347
    "
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3348
    |item newSel hlp|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3349
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3350
    selection isNumber ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3351
	newSel := self itemAt:anItemOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3352
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3353
	(anItemOrNil notNil and:[anItemOrNil canSelect]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3354
	    newSel := anItemOrNil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3355
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3356
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3357
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3358
    selection == newSel ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3359
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3360
    (item := selection) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3361
	selection := nil.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3362
	item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3363
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3364
    newSel notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3365
	selection := newSel.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3366
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3367
	ActiveHelp isActive ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3368
	    hlp := ActiveHelp currentHelpListener.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3369
	    hlp initiateHelpFor:self atX:nil y:nil now:true.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3370
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3371
	selection selected:true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3372
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3373
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3374
    "Modified: / 2.2.1998 / 10:13:46 / stefan"
1039
faa24ee79e12 fixed invalid help text display.
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  3375
    "Modified: / 31.7.1998 / 03:14:18 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3376
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3377
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3378
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3379
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3380
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3381
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3382
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3383
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3384
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3385
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3386
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3387
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3388
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3389
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3390
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3391
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3392
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3393
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3394
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3395
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3396
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3397
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3398
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3399
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3400
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3401
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3402
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3403
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3404
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3405
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3406
shortcutKeyOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3407
    ^ ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3408
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3409
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3410
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3411
    ^ VerticalInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3412
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3413
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3414
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3415
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3416
separatorSize:aType
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3417
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3418
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3419
    aType == #doubleLine ifTrue:[^ 10 ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3420
    aType == #singleLine ifTrue:[^ 10 ].
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  3421
  ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3422
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3423
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3424
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3425
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3426
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3427
    "
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3428
    HorizontalInset       := 4.
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3429
    VerticalInset         := 3.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3430
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3431
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3432
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3433
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3434
    LabelRightOffset      := 15.
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3435
    ShortcutKeyOffset     := 5.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3436
1110
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3437
    IndicatorOn  := self checkedImage.
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3438
    IndicatorOff := self uncheckedImage.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3439
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3440
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3441
!MenuPanel::Item class methodsFor:'image specs'!
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3442
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3443
checkOffIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3444
    "This resource specification was automatically generated
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3445
     by the ImageEditor of ST/X."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3446
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3447
    "Do not manually edit this!! If it is corrupted,
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3448
     the ImageEditor may not be able to read the specification."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3449
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3450
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3451
     self checkOffIcon inspect
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3452
     ImageEditor openOnClass:self andSelector:#checkOffIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3453
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3454
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3455
    <resource: #image>
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3456
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3457
    ^Icon
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3458
	constantNamed:#'MenuPanel::Item checkOffIcon'
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3459
	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
  3460
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3461
checkOnIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3462
    "This resource specification was automatically generated
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3463
     by the ImageEditor of ST/X."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3464
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3465
    "Do not manually edit this!! If it is corrupted,
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3466
     the ImageEditor may not be able to read the specification."
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3467
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3468
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3469
     self checkOnIcon inspect
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3470
     ImageEditor openOnClass:self andSelector:#checkOnIcon
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3471
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3472
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3473
    <resource: #image>
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3474
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3475
    ^Icon
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3476
	constantNamed:#'MenuPanel::Item checkOnIcon'
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3477
	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
  3478
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3479
checkedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3480
    "This resource specification was automatically generated
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3481
     by the ImageEditor of ST/X."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3482
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3483
    "Do not manually edit this!! If it is corrupted,
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3484
     the ImageEditor may not be able to read the specification."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3485
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3486
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3487
     self checkedImage inspect
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3488
     ImageEditor openOnClass:self andSelector:#checkedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3489
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3490
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3491
    <resource: #image>
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3492
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3493
    ^Icon
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3494
	constantNamed:#'MenuPanel::Item checkedImage'
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3495
	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]
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3496
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3497
    "Modified: / 6.9.1998 / 22:29:58 / cg"
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3498
!
1110
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3499
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3500
uncheckedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3501
    "This resource specification was automatically generated
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3502
     by the ImageEditor of ST/X."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3503
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3504
    "Do not manually edit this!! If it is corrupted,
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3505
     the ImageEditor may not be able to read the specification."
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3506
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3507
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3508
     self uncheckedImage inspect
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3509
     ImageEditor openOnClass:self andSelector:#uncheckedImage
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3510
    "
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3511
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3512
    <resource: #image>
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3513
eac7291cc4bb draw real checks in check icons
tz
parents: 1108
diff changeset
  3514
    ^Icon
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3515
	constantNamed:#'MenuPanel::Item uncheckedImage'
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3516
	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]
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3517
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3518
    "Modified: / 6.9.1998 / 22:24:24 / cg"
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3519
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3520
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3521
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3522
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3523
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3524
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3525
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3526
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3527
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3528
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3529
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3530
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3531
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3532
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3533
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3534
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3535
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3536
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3537
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3538
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3539
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3540
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3541
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3542
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3543
!MenuPanel::Item methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3544
420
ca
parents: 417
diff changeset
  3545
canAccept
ca
parents: 417
diff changeset
  3546
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  3547
    "
ca
parents: 417
diff changeset
  3548
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3549
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3550
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3551
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3552
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3553
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3554
    |arg|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3555
723
4f05cbdcaede once again some corrections for button press indication
tz
parents: 720
diff changeset
  3556
    self hasIndication ifTrue:[    
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3557
	arg := self indicationValue not.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3558
	self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3559
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3560
	self hasChoice ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3561
	    arg := self choiceValue.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3562
	    self choice value:arg.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3563
	    arg := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3564
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3565
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3566
    ^ arg
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3567
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3568
    "Modified: / 14.8.1998 / 16:13:37 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3569
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3570
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3571
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3572
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3573
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3574
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3575
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3576
    accessCharacterPosition isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3577
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3578
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3579
  ^ (rawLabel string) at:accessCharacterPosition ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3580
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3581
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3582
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3583
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3584
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3585
  ^ accessCharacterPosition
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
accessCharacterPosition:anIndex
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3589
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3590
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3591
    accessCharacterPosition ~~ anIndex ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3592
	accessCharacterPosition := anIndex.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3593
	self updateRawLabel.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3594
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3595
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3596
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3597
activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3598
    ^ activeHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3599
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3600
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3601
activeHelpKey:aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3602
    activeHelpKey := aHelpKey
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3603
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3604
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3605
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3606
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3607
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3608
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3609
  ^ adornment argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3610
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3611
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3612
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3613
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3614
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3615
    self argument ~~ anArgument ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3616
	self adornment argument:anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3617
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3618
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3619
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3620
compareAccessCharacterWith:aKey
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3621
    "returns true if key is my access character
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3622
    "
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3623
    ^ self accessCharacter == aKey
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  3624
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3625
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3626
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3627
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3628
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3630
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3631
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3632
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3633
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3634
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3635
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3636
    "
475
b604babd1f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  3637
    |i rest s|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3638
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3639
    accessCharacterPosition := nil.
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3640
    label := aLabel value.
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3641
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3642
    (label isString and:[(s := label size) > 1]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3643
	i := 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3644
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3645
	[((i := label indexOf:$& startingAt:i) ~~ 0 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3646
	and:[i < s])] whileTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3647
	    rest := label copyFrom:(i+1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3648
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3649
	    i == 1 ifTrue:[label := rest]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3650
		  ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3651
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3652
	    (label at:i) == $& ifTrue:[i := i + 1]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3653
			      ifFalse:[accessCharacterPosition := i].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3654
	    s := s - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3655
	]
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3656
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3657
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3658
    self updateRawLabel
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  3659
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  3660
    "Modified: / 31.7.1998 / 00:52:26 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3661
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3662
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3663
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3664
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3665
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3666
    ^ menuPanel
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
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3670
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3672
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3673
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3674
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3675
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3676
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3677
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3678
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3679
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3681
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3682
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3683
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3684
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3685
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3686
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3687
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3688
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3689
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3690
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3691
    adornment isNil ifTrue:[^ nil ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3692
  ^ adornment shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3693
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3694
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3695
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3696
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3697
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3698
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3699
    self shortcutKey ~~ aKey ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3700
	self adornment shortcutKey:aKey.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3701
	self redraw.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3702
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3703
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3704
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3705
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3706
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3707
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3708
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3709
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3710
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3711
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3712
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3713
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3714
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3715
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3716
    (startGroup isNil or:[startGroup == #right]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3717
	startGroup := aSymbol
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3718
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3719
	self warn:('not supported group: ', aSymbol printString ).
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3720
    ]
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3721
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3722
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3723
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3724
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3725
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3726
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3727
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3728
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3729
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3730
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3731
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3732
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3733
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3734
    "
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3735
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3736
    (aSubMenu notNil 
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3737
     and:[(aSubMenu isView or:[aSubMenu isKindOf:Menu]) not]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3738
	^ self submenuChannel:aSubMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3739
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3740
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3741
    (subMenu := aSubMenu) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3742
	aSubMenu class == Menu ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3743
	    subMenu := MenuPanel new.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3744
	    menuPanel notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3745
		subMenu receiver:menuPanel receiver.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3746
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3747
	    subMenu menu:aSubMenu.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3748
	    subMenu superMenu:menuPanel.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3749
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3750
	    subMenu isView ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3751
		subMenu superMenu:menuPanel.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3752
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3753
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3754
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3755
1068
155168a813ad oops - subMenu must be an instance of MenuPanel
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
  3756
    "Modified: / 10.8.1998 / 13:26:28 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3757
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3758
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3759
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3760
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3761
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3762
    (rawLabel respondsTo:#string) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3763
	^ rawLabel string
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3764
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3765
  ^ nil
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3766
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3767
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3768
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3769
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3770
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3771
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3772
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3773
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3774
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3775
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3776
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3777
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3778
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3779
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3780
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3781
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3782
    "
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3783
    self value:aValue.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  3784
    self argument:anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3785
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3786
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3787
!MenuPanel::Item methodsFor:'accessing behavior'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3788
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3789
choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3790
    "get choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3791
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3792
    adornment isNil ifTrue:[^ nil].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3793
  ^ adornment choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3794
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3795
    "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
  3796
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3797
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3798
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3799
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3800
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3801
    |old new|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3802
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3803
    old := self choice.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3804
    old == something ifTrue:[^ self].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3805
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3806
    (self isKindOfValueHolder:old) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3807
	old removeDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3808
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3809
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3810
    new := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3811
    new isSymbol ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3812
	new := self aspectAt:new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3813
	new isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3814
	    new := something
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3815
	]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3816
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3817
    (self isKindOfValueHolder:new) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3818
	new addDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3819
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3820
    self adornment choice:new.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3821
    self updateRawLabel.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3822
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3823
    "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
  3824
    "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
  3825
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3826
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3827
choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3828
    "get choice value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3829
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3830
    adornment isNil ifTrue:[^ nil].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3831
  ^ adornment choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3832
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3833
    "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
  3834
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3835
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3836
choiceValue:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3837
    "set choice value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3838
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3839
    self adornment choiceValue:something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3840
    self updateRawLabel.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3841
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3842
    "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
  3843
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3844
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3845
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3846
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3847
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3848
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3849
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3850
    menuPanel enabled ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3851
	enableChannel isSymbol ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3852
	    state := self aspectAt:enableChannel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3853
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3854
	    (self isKindOfValueHolder:state) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3855
		enableChannel := state.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3856
		enableChannel addDependent:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3857
		state := enableChannel value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3858
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3859
		state := state value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3860
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3861
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3862
	    state := enableChannel value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3863
	].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3864
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  3865
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3866
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3867
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3868
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3869
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3870
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3871
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3872
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3873
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3874
    enableChannel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3875
	oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3876
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3877
	oldState := enableChannel value.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3878
	(self isKindOfValueHolder:enableChannel) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3879
	    enableChannel removeDependent:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3880
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3881
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3882
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3883
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3884
    enableChannel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3885
	menuPanel shown ifFalse:[^ self].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3886
	newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3887
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3888
	(self isKindOfValueHolder:enableChannel) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3889
	    enableChannel addDependent:self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3890
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3891
	    enableChannel isSymbol ifTrue:[^ self]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3892
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3893
	menuPanel shown ifFalse:[^ self].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3894
	newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3895
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3896
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3897
    newState ~~ oldState ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3898
	(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3899
	    self drawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3900
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3901
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3902
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3903
    "Modified: / 27.10.1997 / 16:13:42 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3904
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3905
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3906
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3907
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3908
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3909
    adornment isNil ifTrue:[^ nil].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3910
  ^ adornment indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3911
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3912
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3913
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3914
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3915
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3916
    |old|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3917
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3918
    old := self indication.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3919
    old == something ifTrue:[^ self].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3920
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3921
    (self isKindOfValueHolder:old) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3922
	old removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3923
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3924
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3925
    (self isKindOfValueHolder:something) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3926
	something addDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3927
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3928
    self adornment indication:something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3929
    self updateRawLabel.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3930
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3931
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3932
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3933
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3934
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3935
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3936
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3937
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3938
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3939
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3940
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3941
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3942
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3943
    layout notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3944
	self redrawAsButton
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3945
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3946
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3947
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3948
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3949
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3950
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3951
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3952
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3953
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3954
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3955
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3956
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3957
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3958
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3959
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3960
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3961
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3962
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3963
!MenuPanel::Item methodsFor:'accessing dimension'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3964
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3965
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3966
    "gets height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3967
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3968
    layout isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3969
	^ self preferredExtent y
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3970
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  3971
    ^ layout height
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3972
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3973
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3974
horizontalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3975
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3976
    isButton ifTrue: [^menuPanel buttonPassiveLevel + HorizontalButtonInset].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3977
    ^HorizontalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3978
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3979
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3980
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3981
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3982
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3983
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3984
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3985
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3986
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3987
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3988
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3989
    layout := aLayout.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3990
    self redraw.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3991
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3992
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3993
verticalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3994
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  3995
    isButton ifTrue: [^menuPanel buttonPassiveLevel + VerticalButtonInset].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3996
    ^VerticalInset
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3997
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3998
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3999
width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4000
    "gets width
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4001
    "
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4002
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4003
    layout isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4004
	^ self preferredExtent x
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4005
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  4006
    ^ layout width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4007
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4008
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4009
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4010
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4011
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4012
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4013
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4014
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4015
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4016
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4017
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  4018
    (appl isValueModel) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4019
	^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4020
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4021
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4022
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4023
	Object messageNotUnderstoodSignal handle:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4024
	    ex parameter selector == aKey ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4025
		ex reject
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4026
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4027
	] do:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4028
	    (appl isKindOf:ApplicationModel) 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4029
		ifTrue:[value := appl aspectFor:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4030
		ifFalse:[value := appl perform:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4031
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4032
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4033
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4034
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4035
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4036
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4037
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4038
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4039
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4040
choiceChanged
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4041
    "called when the choice changed
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4042
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4043
    |indicator|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4044
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4045
    isButton ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4046
	indicator := self choiceForm.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4047
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4048
	indicator = rawLabel icon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4049
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4050
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4051
	rawLabel icon:indicator.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4052
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4053
	disabledRawLabel notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4054
	    disabledRawLabel icon:indicator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4055
	]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4056
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4057
    self redraw
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4058
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4059
    "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
  4060
    "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
  4061
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4062
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4063
enabledStateOfMenuChangedTo:aState
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4064
    "enabled state of menu changed to aState
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4065
    "
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4066
    rawLabel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4067
	self drawLabel
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4068
    ].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4069
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4070
!
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4071
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4072
indicationChanged
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4073
    "called when the indication changed
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4074
    "
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4075
    |indicator|
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4076
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4077
    isButton ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4078
	indicator := self indicatorForm.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4079
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4080
	indicator = rawLabel icon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4081
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4082
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4083
	rawLabel icon:indicator.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4084
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4085
	disabledRawLabel notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4086
	    disabledRawLabel icon:indicator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4087
	]
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4088
    ].
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4089
    self redraw
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4090
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4091
    "Modified: / 14.8.1998 / 17:19:38 / cg"
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4092
!
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4093
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4094
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4095
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4096
    changedObject == self indication ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4097
	^ self indicationChanged
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4098
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4099
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4100
    changedObject == self choice ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4101
	^ self choiceChanged
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4102
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4103
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4104
    changedObject == enableChannel ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4105
	(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4106
	    self drawLabel
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4107
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4108
	^ self
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4109
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4110
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4111
    changedObject == isVisible ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4112
	menuPanel mustRearrange.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4113
	menuPanel rearrangeItems.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4114
	^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4115
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4116
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4117
    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
  4118
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4119
    "Modified: / 14.8.1998 / 16:13:41 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4120
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4121
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4122
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4123
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4124
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4125
    |indicator| 
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4126
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4127
    (indicator := self indication) notNil ifTrue:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4128
"/        (isButton and:[menuPanel isPopUpView]) ifFalse:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4129
"/            (self isKindOfValueHolder:indicator) ifTrue:[
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4130
"/                ^ self
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4131
"/            ]
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4132
"/        ].
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4133
	self indicationChanged
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4134
    ]
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4135
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4136
    "Modified: / 14.8.1998 / 15:19:38 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4137
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4138
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4139
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4140
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4141
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4142
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4143
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4144
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4145
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4146
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4147
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4148
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4149
    label isImage ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4150
        rcv := ResourceRetriever new.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4151
        rcv className:#MenuEditor.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4152
        rcv selector:#iconUnknown.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4153
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4154
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4155
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4156
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4157
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4158
    enableChannel notNil ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4159
        item enabled:(enableChannel value)
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4160
    ].
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4161
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4162
    item accessCharacterPosition:(self accessCharacterPosition).
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4163
    item startGroup:(self startGroup).
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4164
    item argument:(self argument).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4165
    item nameKey:(self nameKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4166
    item shortcutKeyCharacter:(self shortcutKey).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4167
    item value:(value value).
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4168
    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
  4169
    item choice:(self choice value).
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4170
    item choiceValue:(self choiceValue).
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4171
    item isVisible:(self isVisible).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4172
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4173
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4174
    submenuChannel isSymbol ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4175
        item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4176
    ] ifFalse:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4177
        subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4178
            item submenu:(subMenu asMenu)
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4179
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4180
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4181
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4182
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4183
    "Modified: / 14.8.1998 / 15:47:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4184
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4185
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4186
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4187
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4188
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4189
    |var lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4190
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4191
    menuPanel disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4192
	label := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4193
	activeHelpKey := aMenuItem activeHelpKey.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4194
	self enabled:(aMenuItem enabled).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4195
	self nameKey:(aMenuItem nameKey).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4196
	self indication:(aMenuItem indication).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4197
	self choice:(aMenuItem choice).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4198
	self choiceValue:(aMenuItem choiceValue).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4199
	self isButton:(aMenuItem isButton).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4200
	self startGroup:(aMenuItem startGroup).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4201
	self isVisible:(aMenuItem isVisible).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4202
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4203
	(var := aMenuItem accessCharacterPosition) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4204
	    self accessCharacterPosition:var.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4205
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4206
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4207
	(lbl := aMenuItem labelImage value) isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4208
	    lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4209
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4210
	self label:lbl.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4211
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4212
	self shortcutKey:(aMenuItem shortcutKeyCharacter).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4213
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4214
	(var := aMenuItem argument) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4215
	    self argument:var.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4216
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4217
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4218
	submenuChannel := aMenuItem submenuChannel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4219
	self submenu:(aMenuItem submenu).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4220
	self value:(aMenuItem value).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4221
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  4222
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4223
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4224
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4225
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4226
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4227
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4228
drawLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4229
    "draw label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4230
    "
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4231
    |y x h l t scKey cLb cLa img fg asc arrow hrzInset 
1267
10577a2ca319 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1257
diff changeset
  4232
     buttonLevel isSelected|
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4233
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4234
    self isVisible ifFalse:[^ self].
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4235
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4236
    img := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4237
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4238
    asc := menuPanel font ascent.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4239
    h   := layout height.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4240
    l   := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4241
    t   := layout top.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4242
    hrzInset := self horizontalInset.
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4243
    isSelected := self drawSelected.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4244
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4245
    self enabled ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4246
        fg := isSelected ifTrue:[self activeForegroundColor]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4247
                        ifFalse:[menuPanel foregroundColor].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4248
    ] ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4249
        fg := menuPanel disabledForegroundColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4250
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4251
        (img := disabledRawLabel) isNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4252
            img := self disabledRawLabel
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4253
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4254
    ].
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4255
    menuPanel paint:fg.
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4256
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4257
    "/ t := t + menuPanel level.
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4258
    y := t + ((h - (img heightOn:menuPanel)) // 2).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4259
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4260
    (self textLabel) notNil ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4261
        y := y + asc.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4262
    ].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4263
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4264
    isButton ifTrue:[   
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4265
        (isSelected or:[self indicationValue == true]) ifTrue:
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4266
        [   
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4267
            img displayOn:menuPanel x:(l + hrzInset) + 1 y: y + 1.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4268
            buttonLevel := menuPanel buttonActiveLevel.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4269
        ] ifFalse:[   
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4270
            img displayOn:menuPanel x:(l + hrzInset) y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4271
            self isEntered ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4272
                buttonLevel := menuPanel buttonEnteredLevel
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4273
            ] ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4274
                buttonLevel := menuPanel buttonPassiveLevel
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4275
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4276
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4277
        buttonLevel ~~ 0 ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4278
            menuPanel 
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4279
                drawButtonEdgesInLayout:layout 
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4280
                withLevel:buttonLevel
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4281
                selected:isSelected.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4282
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4283
        ^ self
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4284
    ].
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4285
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4286
"/ 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
  4287
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4288
    img displayOn:menuPanel x:(l + hrzInset) y:y.
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4289
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4290
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4291
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4292
    MenuView showAcceleratorKeys == true ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4293
        menuPanel isVerticalLayout ifTrue:[ "/ only for vertical menus ...
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4294
            (scKey:= self shortcutKeyAsString) notNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4295
                (x := menuPanel shortKeyInset) == 0 ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4296
                    x := hrzInset + LabelRightOffset + (img widthOn:menuPanel)
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4297
                ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4298
                x := l + x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4299
                y := t + ((h - (scKey heightOn:menuPanel)) // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4300
                y := y + asc.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4301
                scKey displayOn:menuPanel x:x y:y. 
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4302
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4303
        ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4304
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  4305
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4306
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4307
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4308
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4309
        arrow := menuPanel rightArrow.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4310
        x := layout right - arrow width - hrzInset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4311
        y := t + (h - arrow height // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4312
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4313
        (menuPanel styleSheet is3D not
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4314
        or:[(img := menuPanel rightArrowShadow) isNil]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4315
            ^ menuPanel displayForm:arrow x:x y:y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4316
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4317
        cLa := menuPanel shadowColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4318
        cLb := menuPanel lightColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4319
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4320
        isSelected ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4321
            fg  := cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4322
            cLa := cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4323
            cLb := fg
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4324
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4325
        menuPanel paint:cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4326
        menuPanel displayForm:arrow x:x y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4327
        menuPanel paint:cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4328
        menuPanel displayForm:img x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4329
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  4330
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4331
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4332
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4333
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4334
drawSelected
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4335
    "return true if item is selected or if item implements
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4336
     a toggle in a radio group which is selected
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4337
    "
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4338
    |holder|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4339
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4340
    self isSelected ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4341
	^ true
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4342
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4343
    isButton ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4344
	^ ((holder := self choice) notNil and:[holder value = self choiceValue])
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4345
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4346
    ^ false
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4347
!
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4348
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4349
redraw
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4350
    "redraw item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4351
    "
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4352
    |isSelected ownBgCol showItemSep type paint lgCol shCol
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4353
     h  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4354
     w  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4355
     l  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4356
     t  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4357
     r  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4358
     b  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4359
     x  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4360
     y  "{ Class:SmallInteger }"
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4361
     hrzInset "{ Class:SmallInteger }"
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4362
     isEntered
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4363
    |
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4364
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4365
    (self isVisible and:[menuPanel canDrawItem]) ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4366
	^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4367
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4368
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4369
    isSelected := self drawSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4370
    isEntered := self isEntered.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4371
    hrzInset   := self horizontalInset.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4372
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4373
    isSelected ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4374
	(isButton and:[isEntered]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4375
	    paint := self buttonEnteredBackgroundColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4376
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4377
	    paint := self backgroundColor
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4378
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4379
    ] ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4380
	paint := self activeBackgroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4381
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4382
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4383
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4384
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4385
    b := layout bottom.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4386
    h := layout height.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4387
    w := layout width.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4388
    (ownBgCol := self backgroundColorFromLabel) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4389
	menuPanel paint:paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4390
	menuPanel fillRectangle:layout.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4391
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4392
	self hasIndication ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4393
	    menuPanel paint:ownBgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4394
	    menuPanel fillRectangle:layout.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4395
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4396
	    menuPanel paint:paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4397
	    x := (rawLabel icon width) + hrzInset + 4.
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 fillRectangleX:l y:t width:x height:h.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4400
	    menuPanel paint:ownBgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4401
	    menuPanel fillRectangleX:(l + x) y:t width:(w - x) height:h.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4402
	    ownBgCol := nil.
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4403
       ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4404
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4405
    lgCol       := menuPanel lightColor.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4406
    shCol       := menuPanel shadowColor.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4407
    showItemSep := menuPanel showSeparatingLines.
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4408
    type        := self separatorType.
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4409
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4410
    type notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4411
	type == #blankLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4412
	    ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4413
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4414
	"/ draw separator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4415
	menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4416
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4417
	menuPanel verticalLayout ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4418
	    l := l + hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4419
	    r := r - hrzInset.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4420
	    y := t - 1 + (h // 2).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4421
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4422
	    type == #doubleLine ifTrue:[y := y - 2].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4423
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4424
	    menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4425
	    menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4426
	    y := y + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4427
	    menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4428
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4429
	    type == #doubleLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4430
		y := y + 3.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4431
		menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4432
		menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4433
		menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4434
		y := y + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4435
		menuPanel displayLineFromX:l y:y toX:r y:y.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4436
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4437
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4438
	    x := l - 1 + (w // 2).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4439
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4440
	    type == #doubleLine ifTrue:[x := x - 2].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4441
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4442
	    menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4443
	    menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4444
	    x := x + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4445
	    menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4446
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4447
	    type == #doubleLine ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4448
		x := x + 3.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4449
		menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4450
		menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4451
		menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4452
		x := x + 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4453
		menuPanel displayLineFromX:x y:t toX:x y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4454
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4455
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4456
	^ self
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4457
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4458
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4459
    isButton ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4460
	^ self drawLabel
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4461
    ].
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4462
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4463
    showItemSep ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4464
	|col index item lfSep rtSep|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4465
	col := menuPanel paint.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4466
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4467
	index := menuPanel indexOfItem:self.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4468
	item  := menuPanel itemAtIndex:(index - 1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4469
	lfSep := item notNil and:[item isButton not].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4470
	item  := menuPanel itemAtIndex:(index + 1).
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4471
	rtSep := item notNil and:[item isButton not].
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
	menuPanel paint:lgCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4474
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4475
	menuPanel verticalLayout ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4476
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4477
		menuPanel displayLineFromX:l y:t - 1 toX:r y:t - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4478
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4479
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4480
		menuPanel displayLineFromX:l y:b - 1 toX:r y:b - 1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4481
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4482
	    menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4483
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4484
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4485
		menuPanel displayLineFromX:l y:t - 2 toX:r y:t - 2.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4486
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4487
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4488
		menuPanel displayLineFromX:l y:b - 2 toX:r y:b - 2.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4489
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4490
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4491
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4492
		menuPanel displayLineFromX:l - 1 y:t toX:l - 1 y:b
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4493
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4494
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4495
		menuPanel displayLineFromX:r - 1 y:t toX:r - 1 y:b.
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
	    menuPanel paint:shCol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4498
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4499
	    lfSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4500
		menuPanel displayLineFromX:l - 2 y:t toX:l - 2 y:b
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4501
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4502
	    rtSep ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4503
		menuPanel displayLineFromX:r - 2 y:t toX:r - 2 y:b.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4504
	    ] 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4505
	]
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4506
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4507
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4508
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4509
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4510
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4511
	ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4512
				 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4513
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4514
	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
  4515
	menuPanel displayRectangleX:(l + 2) y:(t + 2) width:(w - 4) height:(h - 4).  
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4516
    ].
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4517
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4518
    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
  4519
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4520
    "Modified: / 20.8.1998 / 15:11:33 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4521
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4522
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4523
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4524
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4525
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4526
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4527
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4528
    |channel|
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4529
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4530
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4531
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4532
    (enableChannel notNil and:[self isKindOfValueHolder:enableChannel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4533
	enableChannel removeDependent:self
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4534
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4535
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4536
    (isVisible notNil and:[self isKindOfValueHolder:isVisible]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4537
	isVisible removeDependent:self
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4538
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4539
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4540
    channel := self indication.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4541
    (channel notNil and:[self isKindOfValueHolder:channel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4542
	channel removeDependent:self
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4543
    ].
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4544
    channel := self choice.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4545
    (channel notNil and:[self isKindOfValueHolder:channel]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4546
	channel removeDependent:self
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4547
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4548
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4549
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4550
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4551
    "Modified: / 14.8.1998 / 14:37:57 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4552
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4553
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4554
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4555
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4556
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4557
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4558
    isButton  := false.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4559
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4560
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4561
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4562
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4563
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4564
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4565
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4566
    disabledRawLabel isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4567
	(     rawImage notNil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4568
	 and:[(rawImage respondsTo:#colorMap)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4569
	 and:[rawImage colorMap notNil]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4570
	) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4571
	    disabledRawLabel := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4572
	] ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4573
	    disabledRawLabel := menuPanel lightenedImageOnDevice:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4574
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4575
	    rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4576
		(isButton
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4577
		  or:[((self indication notNil or:[self choice notNil])
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4578
		 and:[label class == LabelAndIcon])]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4579
		) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4580
		    disabledRawLabel := LabelAndIcon form:(rawLabel icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4581
						    image:disabledRawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4582
						   string:(rawLabel string)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4583
		] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4584
		    disabledRawLabel := LabelAndIcon form:disabledRawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4585
						    image:(rawLabel image)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4586
						   string:(rawLabel string)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4587
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4588
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4589
	]
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4590
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4591
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4592
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4593
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4594
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4595
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4596
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4597
    |icon|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4598
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4599
    rawImage notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4600
	rawLabel isImage ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4601
	    rawLabel := menuPanel imageOnDevice:rawImage
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4602
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4603
	    rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4604
		(icon := rawLabel image) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4605
		    rawLabel image:(menuPanel imageOnDevice:icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4606
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4607
		(icon := rawLabel icon) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4608
		    (self indication isNil and:[self choice isNil]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4609
			rawLabel icon:(menuPanel imageOnDevice:icon)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4610
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4611
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4612
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4613
	]
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4614
    ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4615
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4616
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4617
updateRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4618
    "recreate rawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4619
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4620
    |char size form|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4621
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4622
    label isNil ifTrue:[        "/ not yet initialized
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4623
	^ self
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4624
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4625
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4626
    (form := self indicatorForm) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4627
	form := self choiceForm
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4628
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4629
    rawImage         := nil.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4630
    disabledRawLabel := nil.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4631
    rawLabel         := label value.
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4632
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4633
    rawLabel isString ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4634
	rawLabel isText ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4635
	    rawLabel := rawLabel withoutSeparators
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
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4638
	form isNil ifTrue:[                             "/ check for separator
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4639
	    rawLabel isEmpty ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4640
		  rawLabel := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4641
		^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4642
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4643
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4644
	    rawLabel size == 1 ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4645
		char := rawLabel first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4646
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4647
		(char == $- or:[char == $=]) ifTrue:[   "/ other line separators
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4648
		    label := String new:1.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4649
		    label at:1 put:char.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4650
		    rawLabel := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4651
		  ^ self
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4652
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4653
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4654
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4655
	rawLabel isEmpty ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4656
	    rawLabel := label value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4657
	].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4658
	size := self accessCharacterPosition.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4659
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4660
	(size notNil and:[size <= rawLabel size]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4661
	    rawLabel isText ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4662
		rawLabel := Text string:rawLabel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4663
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4664
	    rawLabel emphasisAt:size add:#underline
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4665
	]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4666
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4667
    rawLabel isImage ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4668
	rawImage := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4669
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4670
	form notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4671
	    isButton ifTrue:[form := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4672
	    rawLabel := LabelAndIcon form:form image:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4673
	]
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4674
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4675
	rawLabel class == LabelAndIcon ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4676
	    rawImage := rawLabel icon.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4677
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4678
	    (form notNil and:[isButton not]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4679
		rawLabel image:rawImage.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4680
		rawLabel icon:form
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4681
	    ]                
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4682
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4683
	    rawImage := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4684
	    rawLabel isNil ifTrue:[rawLabel := ''].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4685
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4686
	    (form notNil and:[isButton not]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4687
		rawLabel := LabelAndIcon icon:form string:rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4688
	    ] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4689
		disabledRawLabel := rawLabel.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4690
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4691
	].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4692
    ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4693
    menuPanel shown ifTrue:[ self fetchImages ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4694
    menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4695
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4696
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4697
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4698
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4699
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4700
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4701
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4702
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4703
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4704
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4705
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4706
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4707
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4708
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4709
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4710
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4711
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4712
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4713
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4714
adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4715
    "returns adornment; if not existing yet a new instance
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4716
     is created
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4717
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4718
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4719
	adornment := Adornment new
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4720
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4721
  ^ adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4722
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4723
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4724
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4725
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4726
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4727
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4728
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4729
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4730
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4731
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4732
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4733
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4734
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4735
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4736
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4737
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4738
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4739
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4740
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4741
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4742
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4743
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4744
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4745
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4746
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4747
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4748
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4749
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4750
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4751
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4752
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4753
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4754
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4755
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4756
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4757
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4758
    "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
  4759
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4760
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4761
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4762
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4763
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4764
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4765
    "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
  4766
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4767
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4768
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4769
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4770
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4771
    |holder|
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4772
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4773
    (holder := self choice) isNil ifTrue:[^ nil].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4774
1107
0ace8de67a4e better styled round choice images + test choice values only for #=
tz
parents: 1101
diff changeset
  4775
    holder value = self choiceValue ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4776
	^ self class checkOnIcon
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4777
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4778
    ^ self class checkOffIcon
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4779
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4780
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4781
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4782
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4783
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4784
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4785
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4786
890
28c4470c6858 dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  4787
    |subm argument sel|
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4788
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4789
    subm := nil.
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4790
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4791
    aRecv notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4792
	submenuChannel last ~~ $: ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4793
	    Object messageNotUnderstoodSignal handle:[:ex|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4794
		|selector|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4795
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4796
		((selector := ex parameter selector) == submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4797
		or:[selector == #aspectFor:]) ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4798
		    ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4799
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4800
	    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4801
		subm := aRecv aspectFor:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4802
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4803
	    subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4804
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4805
		    ex parameter selector == submenuChannel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4806
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4807
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4808
	    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4809
		    subm := aRecv perform:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4810
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4811
	    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4812
	    subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4813
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4814
		    ex parameter selector == submenuChannel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4815
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4816
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4817
		] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4818
		    subm := aRecv class perform:submenuChannel
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4819
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4820
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4821
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4822
	    (argument := self argument) notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4823
		sel := submenuChannel asSymbol.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4824
		Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4825
		    ex parameter selector == sel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4826
			ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4827
		    ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4828
		] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4829
		    subm := aRecv perform:sel with:argument
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4830
		].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4831
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4832
		subm isNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4833
		    Object messageNotUnderstoodSignal handle:[:ex| 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4834
			ex parameter selector == sel ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4835
			    ex reject
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4836
			].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4837
		    ] do:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4838
			subm := aRecv class perform:sel with:argument
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4839
		    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4840
		]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4841
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4842
	]
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4843
    ].
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4844
    ^ subm
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4845
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  4846
    "Modified: / 4.8.1998 / 17:40:09 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4847
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  4848
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4849
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4850
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4851
    "
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4852
    |indication numArgs sel recv|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4853
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4854
    (indication := self indication) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4855
	^ nil                                           "/ has no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4856
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4857
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4858
    indication isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4859
	(numArgs := indication numArgs) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4860
	    numArgs == 2 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4861
		recv := menuPanel receiver.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4862
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4863
		(recv isValueModel) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4864
		    (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4865
			sel := indication copyFrom:1 to:(indication indexOf:$:).
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4866
			indication := nil.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4867
			sel := sel asSymbol.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4868
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4869
			Object messageNotUnderstoodSignal handle:[:ex| 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4870
			    ex parameter selector == sel ifFalse:[
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4871
"/                                Transcript showCR:'no indication for: ' , sel.
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4872
				ex reject
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4873
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4874
			] do:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4875
			    indication := recv perform:sel with:self argument
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4876
			]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4877
		    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4878
		].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4879
		^ indication value == true
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4880
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4881
	    indication := (indication copyWithoutLast:1) asSymbol
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4882
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4883
	indication := self aspectAt:indication.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4884
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4885
	(self isKindOfValueHolder:indication) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4886
	    self adornment indication:indication.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4887
	    indication addDependent:self.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4888
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4889
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4890
    ^ indication value == true
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4891
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4892
    "Modified: / 8.8.1998 / 02:15:15 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4893
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4894
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4895
indicationValue:aValue
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4896
    "set the indication value
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4897
    "
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4898
    |numArgs indication recv|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4899
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4900
    (indication := self indication) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4901
	^ self                                          "/ has no indication
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4902
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4903
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4904
    indication isSymbol ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4905
	(indication respondsTo:#value:) ifTrue:[        "/ valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4906
	    indication value:aValue
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4907
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4908
	^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4909
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4910
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4911
    recv := menuPanel receiver.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4912
    recv isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4913
	recv := menuPanel application.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4914
	recv isNil ifTrue:[^ self].
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4915
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4916
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  4917
    (numArgs := indication numArgs) ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4918
	Object messageNotUnderstoodSignal handle:[:ex| 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4919
	    (ex parameter selector ~~ indication) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4920
		ex reject
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4921
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4922
	] do:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4923
	    numArgs == 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4924
		recv perform:indication with:aValue
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4925
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4926
		recv perform:indication with:(self argument ? self) with:aValue
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4927
	    ]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4928
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4929
    ].
1026
29bd433b27d3 dont catch too many errors - it makes debugging so hard.
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
  4930
29bd433b27d3 dont catch too many errors - it makes debugging so hard.
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
  4931
    "Modified: / 28.7.1998 / 20:47:08 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4932
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4933
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4934
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4935
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4936
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4937
    |value|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4938
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4939
    (value := self indicationValue) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4940
	^ nil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4941
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4942
  ^ 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
  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 / 15:53:53 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4945
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4946
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4947
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4948
    "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
  4949
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4950
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4951
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4952
    "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
  4953
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4954
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4955
reinitSubmenuStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4956
    "returns my submenu or nil
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4957
    "
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4958
    subMenu notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4959
	subMenu reinitStyle
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4960
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4961
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4962
    "Created: / 10.9.1998 / 21:36:09 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4963
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4964
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4965
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4966
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4967
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4968
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4969
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4970
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4971
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4972
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4973
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4974
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4975
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4976
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4977
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4978
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4979
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4980
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4981
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4982
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4983
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4984
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4985
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4986
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4987
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4988
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4989
    submenuChannel notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4990
	submenuChannel isSymbol ifFalse:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4991
	    subm := submenuChannel
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4992
	] ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4993
	    appl := menuPanel application.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4994
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4995
	    (subm := self findSubMenuIn:appl) isNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4996
		(recv := menuPanel receiver) ~~ appl ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4997
		    subm := self findSubMenuIn:recv
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4998
		]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4999
	    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5000
	].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5001
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5002
	(subm := subm value) isArray ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5003
	    subm := Menu new fromLiteralArrayEncoding:subm.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5004
	    "/ cg: linked menus also may contain translations ...
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5005
	    subm notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5006
		appl notNil ifTrue:[
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5007
		    subm findGuiResourcesIn:appl.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5008
		]                
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5009
	    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5010
	].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5011
	self submenu:subm.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5012
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5013
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5014
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5015
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5016
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5017
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5018
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5019
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5020
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5021
canChangeVisibility
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5022
    "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
  5023
    "
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5024
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5025
    ^ isVisible notNil and:[isVisible ~~ true]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5026
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5027
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5028
canSelect
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5029
    "returns true if item is selectable
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5030
    "
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5031
    |holder|
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5032
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5033
    (self isVisible and:[self enabled and:[rawLabel notNil]]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5034
	((holder := self choice) isNil or:[holder value ~= self choiceValue]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5035
	    ^ true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5036
	].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5037
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5038
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5039
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5040
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5041
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5042
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5043
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5044
    (self isVisible and:[layout notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5045
	^ (     (x >= layout left)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5046
	    and:[x <  layout right
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5047
	    and:[y >  layout top
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5048
	    and:[y <= layout bottom]]]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5049
	  )
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5050
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5051
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5052
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5053
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5054
hasChoice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5055
    "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
  5056
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5057
  ^ self choice notNil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5058
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5059
    "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
  5060
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5061
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5062
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5063
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5064
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5065
  ^ self indication notNil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5066
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5067
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5068
hasSubmenu
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5069
    "returns true if the item is configured as an subMenu entry
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5070
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5071
    ^ subMenu notNil or:[submenuChannel notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5072
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5073
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5074
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5075
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5076
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5077
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5078
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5079
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5080
isKindOfValueHolder:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5081
    "returns true if something is kind of vlaue holder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5082
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5083
    ^ ((something respondsTo:#value:) and:[something isBlock not])
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5084
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5085
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5086
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5087
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5088
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5089
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5090
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5091
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5092
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5093
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5094
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5095
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5096
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5097
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5098
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5099
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5100
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5101
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5102
    isVisible isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5103
	state := self aspectAt:isVisible.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5104
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5105
	(self isKindOfValueHolder:state) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5106
	    isVisible := state.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5107
	    isVisible addDependent:self.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5108
	    state := isVisible.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5109
	]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5110
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5111
	state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5112
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5113
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5114
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5115
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5116
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5117
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5118
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5119
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5120
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5121
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5122
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5123
    isVisible isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5124
	oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5125
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5126
	oldState := isVisible value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5127
	(self isKindOfValueHolder:isVisible) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5128
	    isVisible removeDependent:self
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5129
	]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5130
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5131
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5132
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5133
    isVisible isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5134
	newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5135
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5136
	(self isKindOfValueHolder:isVisible) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5137
	    isVisible addDependent:self
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5138
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5139
	    isVisible isSymbol ifTrue:[^ self]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5140
	].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5141
	menuPanel shown ifFalse:[^ self].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5142
	newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5143
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5144
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5145
    newState ~~ oldState ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5146
	menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5147
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5148
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5149
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5150
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5151
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5152
preferredExtent
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5153
    "compute my preferred extent
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5154
    "
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5155
    |x y s isVertical sepSize|
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5156
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5157
    self isVisible ifFalse:[^ (0 @ 0) ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5158
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5159
    x := self horizontalInset * 2.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5160
    y := self verticalInset * 2.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5161
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5162
    isVertical := menuPanel verticalLayout.
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5163
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5164
    self isSeparator ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5165
        x := x + (rawLabel widthOn:menuPanel).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5166
        y := y + (rawLabel heightOn:menuPanel).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5167
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5168
        MenuView showAcceleratorKeys == true ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5169
            isVertical ifTrue:[ "/ only for vertical menus ...
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5170
                (s := self shortcutKeyAsString) notNil ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5171
                    x := x + LabelRightOffset + (s widthOn:menuPanel)
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5172
                ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5173
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5174
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5175
        (isVertical and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5176
            x := x + menuPanel subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5177
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5178
            s notNil ifTrue:[x := x + ShortcutKeyOffset]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5179
                    ifFalse:[x := x + LabelRightOffset]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5180
        ].
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5181
    ] ifTrue:[
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5182
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5183
        sepSize := (self class separatorSize:(self separatorType)).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5184
        isVertical ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5185
            x := x max:sepSize.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5186
            y := y + (menuPanel font height)
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5187
        ] ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5188
            y := y max:sepSize
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5189
        ].
1096
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5190
    ].
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5191
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5192
    ^ (x @ y)
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5193
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5194
    "Modified: / 8.8.1998 / 01:38:26 / cg"
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5195
!
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5196
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5197
preferredExtentX
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5198
    "compute my preferred extent x
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5199
    "
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5200
    ^ self preferredExtent x
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5201
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5202
!
6ab44a6939bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  5203
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5204
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5205
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5206
    "
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5207
    |nm key prefix|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5208
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5209
    (key := self shortcutKey) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5210
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5211
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5212
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5213
    key isCharacter ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5214
	nm := key asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5215
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5216
	"/ this is somewhat complicated: we have the symbolic key at hand,
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5217
	"/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5218
	"/ Ask the devices keyboardMap for the backtranslation.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5219
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5220
	nm := menuPanel device keyboardMap keyAtValue:key ifAbsent:key.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5221
	"/
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5222
	"/ some modifier-key combination ?
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5223
	"/
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5224
	(nm startsWith:#Cmd) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5225
	    prefix := #Cmd.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5226
	] ifFalse:[(nm startsWith:#Alt) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5227
	    prefix := #Alt.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5228
	] ifFalse:[(nm startsWith:#Meta) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5229
	    prefix := #Meta.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5230
	] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5231
	    prefix := #Ctrl.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5232
	]]]].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5233
	prefix notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5234
	    nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5235
	] ifFalse:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5236
	    nm := nm asString
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5237
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5238
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5239
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5240
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5241
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5242
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5243
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5244
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5245
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5246
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5247
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5248
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5249
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5250
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5251
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5252
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5253
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5254
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5255
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5256
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5257
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5258
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5259
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5260
hideSubmenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5261
    "hide submenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5262
    "
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5263
    |id|
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5264
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5265
    subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5266
        subMenu realized ifFalse:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5267
            (id := subMenu id) notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5268
                menuPanel device unmapWindow:id
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5269
            ]
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5270
        ] ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5271
           subMenu hide
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5272
        ].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5273
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5274
        subMenu windowGroup:nil.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5275
        menuPanel windowGroup removeView:subMenu.
1474
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5276
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5277
        "/ release menu if derived from channel
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5278
        submenuChannel notNil ifTrue:[
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5279
            subMenu := nil
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5280
        ]
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5281
     ].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5282
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5283
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5284
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5285
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5286
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5287
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5288
    ^ menuPanel selection == self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5289
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5290
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5291
selected:aState
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5292
    "change selection to a state. Dependant on the state open or hide an existing
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5293
     submenu and perform a redraw
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5294
    "
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5295
    |p d subMenu top windowGrp|
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5296
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5297
    aState ifFalse:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5298
        self redraw.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5299
        self hideSubmenu.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5300
      ^ self
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5301
    ].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5302
    menuPanel shown ifFalse:[^ self].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5303
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5304
    (self hasIndication not or:[isButton not]) ifTrue: [self redraw].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5305
1474
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5306
    (subMenu := self setupSubmenu) isNil ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5307
        menuPanel isPopUpView ifTrue:[menuPanel grabMouseAndKeyboard].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5308
      ^ self.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5309
    ].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5310
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5311
    menuPanel verticalLayout ifTrue:[p := (layout right - 4) @ (layout top)]
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5312
                            ifFalse:[p := (layout left)  @ (layout bottom)].
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5313
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5314
    d := menuPanel device.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5315
    p := d translatePoint:p from:(menuPanel id) to:(d rootWindowId).
407
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
    windowGrp := menuPanel topMenu windowGroup.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5318
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  5319
    subMenu font:(menuPanel topMenu font).
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  5320
    subMenu becomesActiveMenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5321
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5322
    windowGrp notNil ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5323
        subMenu windowGroup:windowGrp.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5324
        windowGrp addTopView:subMenu.
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5325
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5326
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5327
    "/ 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
  5328
    "/ 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
  5329
    "/       (since I react correctly on valueHolder changes)
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5330
    subMenu rearrangeItemsIfItemVisibilityChanged.
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5331
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5332
    subMenu fixSize.
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5333
    subMenu origin:p.
680
a4220a7a79c4 grab & ungrab: bug fix
ca
parents: 671
diff changeset
  5334
    top := menuPanel topMenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5335
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5336
    subMenu realized ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5337
        subMenu realize. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5338
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5339
        top device mapWindow:subMenu id.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5340
    ].
816
8f8f8e19d983 implement button behaviour
ca
parents: 798
diff changeset
  5341
    subMenu makeFullyVisible.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5342
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5343
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5344
!MenuPanel::Item::Adornment methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5345
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5346
accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5347
    "get the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5348
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5349
    ^ accessCharacterPosition
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5350
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5351
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5352
accessCharacterPosition:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5353
    "set the index of the access character in the label text or string, or nil if none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5354
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5355
    accessCharacterPosition := anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5356
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5357
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5358
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5359
    "ST/X goody; get argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5360
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5361
  ^ argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5362
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5363
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5364
argument:anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5365
    "ST/X goody; set argunment to a selector or block
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5366
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5367
    argument := anArgumentOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5368
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5369
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5370
choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5371
    "get has choice indicator value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5372
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5373
  ^ choice
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5374
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5375
    "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
  5376
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5377
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5378
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5379
    "set choice indicator value
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5380
    "
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5381
    choice := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5382
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5383
    "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
  5384
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5385
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5386
choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5387
    "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
  5388
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5389
    ^ choiceValue
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5390
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5391
    "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
  5392
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5393
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5394
choiceValue:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5395
    "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
  5396
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5397
    choiceValue := something.
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5398
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5399
    "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
  5400
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5401
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5402
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5403
    "get has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5404
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5405
  ^ indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5406
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5408
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5409
    "set has on/off indicator value
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5410
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5411
    indication := something.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5412
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5413
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5414
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5415
    "get the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5416
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5417
  ^ shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5418
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5419
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5420
shortcutKey:aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5421
    "set the character that is used as a shortcut key for this item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5422
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5423
    shortcutKey := aKeyOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5424
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5425
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5426
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5427
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5428
version
1474
bc9d6e39c2e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
  5429
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.172 1999-08-17 14:53:59 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5430
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5431
MenuPanel initialize!