MenuPanel.st
author ca
Wed, 15 Mar 2000 07:18:18 +0100
changeset 1735 941d5de7372c
parent 1734 26397f903766
child 1737 c18896a7cb50
permissions -rw-r--r--
fix some warnings durring compilation
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
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
    22
		buttonHalfShadowColor enteredItem buttonEnteredBgColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
    23
		prevFocusView previousPointerGrab previousKeyboardGrab
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    24
		relativeGrabOrigin hasImplicitGrap iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    25
		iconIndicationOn iconRadioGroupOff iconRadioGroupOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    26
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    27
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    28
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    29
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    30
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
    31
		DefaultEnteredLevel DefaultSelectionFollowsMouse
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    32
		DefaultFitFirstPanel RightArrowForm RightArrowShadowForm
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    33
		SelectionFrameBrightColor SelectionFrameDarkColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		ButtonActiveLevel ButtonPassiveLevel ButtonActiveBackgroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    35
		ButtonPassiveBackgroundColor ButtonLightColor ButtonShadowColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    36
		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle Images
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    37
		LigthenedImages ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    38
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    39
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    40
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    41
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    42
Object subclass:#Item
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    43
	instanceVariableNames:'layout menuPanel subMenu rawLabel rawLabelExtent disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    44
		enableChannel nameKey value label activeHelpKey activeHelpText
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    45
		submenuChannel startGroup isButton isVisible hideMenuOnActivated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    46
		indication accessCharacterPosition shortcutKey argument choice
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
    47
		choiceValue showBusyCursorWhilePerforming accessCharacter font'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    48
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    49
		VerticalButtonInset LabelRightOffset'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    50
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    51
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    52
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    53
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    54
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    55
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    56
copyright
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    57
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
 COPYRIGHT (c) 1997 by eXept Software AG
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    59
	      All Rights Reserved
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    61
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    62
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    63
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    64
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    65
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    66
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    70
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    71
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    72
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    73
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    79
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    80
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    81
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    82
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    83
    [author:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    84
	Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    85
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    86
    [see also:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    87
	Menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    88
	MenuItem
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    89
	MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    92
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    93
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    94
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    95
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    96
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    97
    start as PullDownMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    98
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   100
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   103
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   105
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   107
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   108
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   109
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   114
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   117
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   121
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   122
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   125
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   126
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   127
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   130
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   131
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   137
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   138
    top open.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   139
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   140
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   141
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
    start as PopUpMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   143
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   144
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   146
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   147
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   148
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   149
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   151
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   152
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   153
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   154
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   155
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   156
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   157
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   158
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   159
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   160
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   161
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   162
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   163
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   164
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   165
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   166
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   167
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   168
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   169
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   170
    mview startUp
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   171
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   172
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   173
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   174
    start from menu spec
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   175
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   176
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   177
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   178
    menu := MenuPanel menu:
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   179
	#(#Menu #( #(#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   180
		    #label: 'File' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   181
		    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   182
		      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   183
				 (#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   184
				    #label: 'edit' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   185
				    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   186
				      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   187
						 #(#MenuItem #label: 'close' #value:#close)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   188
					       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   189
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   190
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   191
				       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   192
				  )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   193
				 #(#MenuItem #label: 'help' #value:#help )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   194
			       )
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
			       nil
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
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   199
		#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   200
		#(#MenuItem #label: 'Bar' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   201
			    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   202
			       #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   203
					  #(#MenuItem #label: 'bar 2' #value:#bar2 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   204
					)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   205
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   206
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   207
				)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   208
		 ) 
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
	      #( 2 )
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
	 ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   213
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   214
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   215
    Transcript showCR:(menu startUp).
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   216
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   217
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   220
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   221
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   222
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   223
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   224
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   225
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   226
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   227
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   228
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   229
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   230
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   231
    aSpec notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   232
	menu := Menu new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   233
	menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   234
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   235
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   236
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   237
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   238
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   239
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   240
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   241
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   242
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   243
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   244
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   245
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   246
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   247
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   251
    mview nameKeys:nameKeys.
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
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   256
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   257
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   258
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   259
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   261
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   262
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   263
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
    mview := self new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
    aReceiver notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   274
	mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   279
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   283
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   284
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   285
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   286
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   287
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   288
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   289
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   290
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   291
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   292
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   293
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   294
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   295
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   296
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   297
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   298
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   299
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   300
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   301
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   302
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   303
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   304
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   305
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   306
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   307
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   308
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   309
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   310
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   311
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   312
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   313
!MenuPanel class methodsFor:'default icons'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   314
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   315
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   316
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   317
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   318
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   319
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   320
     the ImageEditor may not be able to read the specification."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   321
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   322
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   323
     self iconIndicationOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   324
     ImageEditor openOnClass:self andSelector:#iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   325
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   326
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   327
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   328
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   329
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   330
        constantNamed:#'MenuPanel iconIndicationOff'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   331
        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]!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   332
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   333
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   334
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   335
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   336
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   337
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   338
     the ImageEditor may not be able to read the specification."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   339
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   340
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   341
     self iconIndicationOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   342
     ImageEditor openOnClass:self andSelector:#iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   343
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   344
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   345
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   346
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   347
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   348
        constantNamed:#'MenuPanel iconIndicationOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   349
        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]!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   350
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   351
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   352
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   353
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   354
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   355
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   356
     the ImageEditor may not be able to read the specification."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   357
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   358
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   359
     self iconRadioGroupOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   360
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   361
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   362
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   363
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   364
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   365
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   366
        constantNamed:#'MenuPanel iconRadioGroupOff'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   367
        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]!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   368
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   369
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   370
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   371
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   372
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   373
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   374
     the ImageEditor may not be able to read the specification."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   375
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   376
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   377
     self iconRadioGroupOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   378
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   379
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   380
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   381
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   382
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   383
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   384
        constantNamed:#'MenuPanel iconRadioGroupOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   385
        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]! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   386
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   387
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   388
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   389
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   390
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   391
    <resource: #style (#'menu.foregroundColor' #'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   392
                       #'menu.hilightForegroundColor' #'menu.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   393
                       #'menu.hilightBackgroundColor' #'menu.buttonEnteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   394
                       #'menu.hilightLevel' #'menu.groupDividerSize'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   395
                       #'menu.itemSpace' #'menu.buttonItemSpace'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   396
                       #'menu.fitFirstPanel' #'menu.buttonActiveLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   397
                       #'menu.buttonPassiveLevel' #'menu.buttonEnteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   398
                       #'menu.selectionFollowsMouse' #'menu.enteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   399
                       #'viewBackground'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   400
                       #'pullDownMenu.level' #'pullDownMenu.hilightLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   401
                       #'button.disabledForegroundColor' #'button.enteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   402
                       #'button.activeBackgroundColor' #'button.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   403
                       #'button.lightColor' #'button.shadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   404
                       #'button.halfLightColor' #'button.halfShadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   405
                       #'button.passiveLevel' #'button.activeLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   406
                       #'button.edgeStyle')>
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   407
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   408
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   409
    |style styleSheet|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   410
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   411
    styleSheet := StyleSheet.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   412
    style      := styleSheet name.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   413
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   414
    DefaultForegroundColor := styleSheet colorAt:#'menu.foregroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   415
                                         default:Color black.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   416
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   417
    DefaultBackgroundColor := styleSheet colorAt:#'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   418
                                         default:DefaultViewBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   419
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   420
    DefaultHilightForegroundColor := styleSheet colorAt:#'menu.hilightForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   421
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   422
    DefaultHilightForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   423
        styleSheet is3D ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   424
            DefaultHilightForegroundColor := DefaultForegroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   425
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   426
            DefaultHilightForegroundColor := DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   427
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   428
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   429
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   430
    DefaultDisabledForegroundColor := styleSheet colorAt:#'menu.disabledForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   431
    DefaultDisabledForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   432
        DefaultDisabledForegroundColor := styleSheet colorAt:#'button.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   433
                                                     default:Color darkGray.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   434
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   435
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   436
    DefaultHilightBackgroundColor := styleSheet colorAt:#'menu.hilightBackgroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   437
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   438
    DefaultHilightBackgroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   439
        style == #motif ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   440
            DefaultHilightBackgroundColor := DefaultBackgroundColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   441
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   442
            DefaultHilightBackgroundColor := styleSheet is3D ifFalse:[DefaultForegroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   443
                                                              ifTrue:[DefaultBackgroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   444
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   445
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   446
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   447
    DefaultLevel := styleSheet at:#'pullDownMenu.level' default:0.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   448
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   449
    (style == #motif or:[style == #iris]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   450
        DefaultHilightLevel := 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   451
        DefaultLevel        := DefaultLevel + 1.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   452
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   453
        (DefaultHilightLevel    := styleSheet at:'pullDownMenu.hilightLevel') isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   454
            DefaultHilightLevel := styleSheet at:'menu.hilightLevel' default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   455
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   456
        styleSheet is3D ifTrue:[DefaultLevel := DefaultLevel + 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   457
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   458
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   459
    DefaultGroupDividerSize := styleSheet at:#'menu.groupDividerSize' default:6.
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
   460
    DefaultItemSpace        := styleSheet at:#'menu.itemSpace' default:2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   461
    DefaultButtonItemSpace  := styleSheet at:#'menu.buttonItemSpace' default:0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   462
    DefaultFitFirstPanel    := styleSheet at:#'menu.fitFirstPanel' default:true.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   463
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   464
    MenuView updateStyleCache.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   465
    DefaultFont    := MenuView defaultFont.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   466
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   467
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   468
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   469
        RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   470
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   471
        RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   472
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   473
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   474
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   475
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   476
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   477
    ButtonActiveLevel            :=  styleSheet at:#'menu.buttonActiveLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   478
    ButtonActiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   479
        ButtonActiveLevel        :=  styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   480
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   481
    ButtonPassiveLevel           :=  styleSheet at:#'menu.buttonPassiveLevel'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   482
    ButtonPassiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   483
        ButtonPassiveLevel       :=  styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   484
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   485
    ButtonActiveBackgroundColor  :=  styleSheet at:#'button.activeBackgroundColor' default: DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   486
    ButtonPassiveBackgroundColor := (styleSheet at:#'button.backgroundColor') ? (styleSheet at:'viewBackground') ? DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   487
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   488
    ButtonLightColor             := styleSheet at:#'button.lightColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   489
    ButtonLightColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   490
        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
   491
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   492
    ButtonShadowColor            :=  styleSheet at:#'button.shadowColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   493
    ButtonShadowColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   494
        ButtonShadowColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened. "/ Color white
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   495
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   496
    ButtonHalfLightColor         :=  styleSheet at:#'button.halfLightColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   497
    ButtonHalfShadowColor        :=  styleSheet at:#'button.halfShadowColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   498
    ButtonEdgeStyle              :=  styleSheet at:#'button.edgeStyle'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   499
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   500
    ButtonEnteredBackgroundColor := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   501
    ButtonEnteredBackgroundColor isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   502
        ButtonEnteredBackgroundColor := styleSheet colorAt:#'button.enteredBackgroundColor'
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   503
                                                  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   504
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   505
    ButtonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   506
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   507
    DefaultSelectionFollowsMouse := styleSheet at:#'menu.selectionFollowsMouse' default:false.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   508
    DefaultEnteredLevel          := styleSheet at:#'menu.enteredLevel'          default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   509
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   510
    ShortcutKeyOffset            := 5.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   511
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   512
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   513
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   514
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   515
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   516
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   517
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   518
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   519
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   520
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   521
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   522
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   523
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   524
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   525
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   526
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   527
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   528
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   529
    anImage device == aDevice ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   530
	^ anImage
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   531
    ].
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   532
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   533
    Images isNil ifTrue:[ Images := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   534
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   535
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   536
	Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   537
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   538
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   539
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   540
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   541
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   542
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   543
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   544
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   545
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   546
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   547
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   548
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   549
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   550
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   551
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   552
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   553
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   554
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   555
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   556
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   557
    LigthenedImages isNil ifTrue:[ LigthenedImages := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   558
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   559
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   560
	LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   561
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   562
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   563
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   564
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   565
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   566
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   567
    ((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   568
	image := anImage copy lightened onDevice:aDevice.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   569
	image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   570
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   571
	image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   572
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   573
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   574
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   575
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   576
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   577
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   578
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   579
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   580
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   581
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   582
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   583
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   584
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   585
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   586
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   587
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   588
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   589
!MenuPanel methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   590
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   591
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   592
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   593
    "
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   594
    ^ self acceptItem:(self selection) inMenu:self
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   595
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   596
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   597
accept:anItem
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   598
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   599
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   600
    |value item tgState itemIdx recv panel masterGroup winGrp|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
   601
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   602
    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
   603
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   604
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   605
    self selection:nil.
420
ca
parents: 417
diff changeset
   606
ca
parents: 417
diff changeset
   607
    (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
   608
        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
   609
        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
   610
        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
   611
        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
   612
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   613
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   614
    self doUngrab:true.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   615
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   616
    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
   617
        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
   618
        self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   619
    ] 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
   620
        self unmap.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   621
        (winGrp := self windowGroup) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   622
            "/ give expose event a chance to arrive
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   623
            [shown and:[realized]] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   624
                winGrp processExposeEventsFor:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   625
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   626
            masterGroup := winGrp previousGroup.
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   627
        ].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   628
        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
   629
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   630
    ].
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   631
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   632
    (item notNil 
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   633
    and:[item showBusyCursorWhilePerforming
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   634
    and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]])
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   635
    ifTrue:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   636
        winGrp withWaitCursorDo:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   637
            value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   638
        ]
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   639
    ] ifFalse:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   640
        value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   641
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   642
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   643
    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
   644
        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
   645
        self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   646
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   647
    ^ item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   648
1212
9bd3220c9964 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1211
diff changeset
   649
    "Modified: / 22.2.1999 / 20:14:48 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   650
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   651
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   652
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   653
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   654
    "
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   655
    |value argument numArgs isKindOfValueModel rec args arg2 
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   656
     app master fallBack|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   657
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   658
    anItem isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   659
        self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   660
      ^ nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   661
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   662
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   663
    self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   664
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   665
    (value := anItem value) isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   666
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   667
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   668
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   669
    (argument := anItem argument) isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   670
        argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   671
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   672
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   673
    value isSymbol ifFalse:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   674
        "/ a valueHolder or block
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   675
        (value respondsTo:#valueWithArguments:) ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   676
             ^ value
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   677
        ].
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   678
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   679
        numArgs := value perform:#numArgs ifNotUnderstood:0.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   680
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   681
        numArgs == 0 ifTrue:[
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   682
            args := nil
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   683
        ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   684
            numArgs == 1 ifTrue:[
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   685
                args := Array with:argument
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   686
            ] ifFalse:[
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   687
                args := Array with:argument with:self
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   688
            ]
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   689
        ].
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   690
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   691
        value valueWithArguments:args.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   692
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   693
        self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   694
      ^ anIndex
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   695
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   696
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   697
    aReceiver isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   698
        ^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   699
    ].
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   700
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   701
    isKindOfValueModel := aReceiver isValueModel.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   702
    isKindOfValueModel ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   703
        aReceiver value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   704
    ] ifFalse:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   705
        rec := aReceiver.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   706
        arg2 := self.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   707
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   708
        "/ support for ST80 style applications
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   709
        "/ (expecting the message to go to the application
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   710
        "/  if not understood by the view)
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   711
        "/ These expect the controller to be passed as argument.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   712
        "/ sigh.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   713
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   714
        (aReceiver isView
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   715
        and:[(aReceiver respondsTo:value) not
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   716
        and:[(app := aReceiver application) ~~ aReceiver
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   717
        and:[app notNil]]]) ifTrue:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   718
            rec := app.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   719
            arg2 := aReceiver controller "/ the Views controller
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   720
        ].
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   721
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   722
        (numArgs := value numArgs) == 0 ifTrue:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   723
            args := nil
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   724
        ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   725
            numArgs == 1 ifTrue:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   726
                args := Array with:argument
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   727
            ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   728
                args := Array with:argument with:arg2
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   729
            ]
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   730
        ].
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   731
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   732
        fallBack := 
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   733
            [
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   734
                "/ mhmh - the receiver did not respond to that message;
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   735
                "/ if there is a master-application, try that one
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   736
                "/ (recursive)
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   737
                master := rec perform:#masterApplication ifNotUnderstood:nil.
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   738
                master notNil ifTrue:[
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   739
                    rec := master.
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   740
                    rec perform:value withArguments:args ifNotUnderstood:fallBack
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   741
                ] ifFalse:[
1715
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   742
                    self 
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   743
                        error:'unimplemented menu message: ' , value
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   744
                        mayProceed:true
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   745
                ].
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   746
            ].
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   747
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   748
        rec perform:value withArguments:args ifNotUnderstood:fallBack.
420
ca
parents: 417
diff changeset
   749
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   750
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   751
    ^ value
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   752
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   753
    "Modified: / 19.2.2000 / 11:08:22 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   754
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   755
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   756
acceptItem:anItem inMenu:aMenu
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   757
    |tgState|
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   758
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   759
    (anItem isNil or:[anItem hideMenuOnActivated or:[aMenu isPopUpView not]]) ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   760
        self topMenu accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   761
    ] ifFalse:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   762
        anItem canAccept ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   763
            tgState := anItem toggleIndication.
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   764
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   765
            self accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   766
                  index:(aMenu selectionIndex)
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   767
                 toggle:tgState 
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   768
               receiver:(aMenu receiver).
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   769
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   770
            aMenu do:[:el| el updateIndicators].
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   771
        ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   772
    ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   773
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   774
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   775
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   776
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   777
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   778
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   779
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   780
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   781
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   782
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   783
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   784
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   785
"/    |top|
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   786
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   787
"/    top := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   788
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   789
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   790
"/        ^ self topMenu menuAdornmentAt:#value.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   791
"/    ].
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   792
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   793
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   794
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   795
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   796
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   797
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   798
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   799
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   800
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   801
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   802
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   803
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   804
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   805
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   806
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   807
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   808
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   809
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   810
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   811
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   812
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   813
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   814
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   815
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   816
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   817
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   818
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   819
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   820
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   821
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   822
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   823
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   824
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   825
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   826
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   827
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   828
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   829
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   830
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   831
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   832
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   833
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   834
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   835
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   836
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   837
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   838
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   839
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   840
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   841
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   842
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   843
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   844
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   845
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   846
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   847
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   848
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   849
    "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
   850
     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
   851
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   852
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   853
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   854
    "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
   855
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   856
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   857
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   858
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   859
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   860
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   861
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   862
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   863
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   864
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   865
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   866
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   867
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   868
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   869
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   870
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   871
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   872
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   873
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   874
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   875
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   876
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   877
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   878
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   879
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   880
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   881
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   882
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   883
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   884
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   885
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   886
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   887
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   888
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   889
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   890
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   891
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   892
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   893
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   894
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   895
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   896
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   897
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   898
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   899
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   900
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   901
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   902
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   903
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   904
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   905
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   906
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   907
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   908
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   909
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   910
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   911
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   912
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   913
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   914
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   915
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   916
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   917
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   918
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   919
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   920
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   921
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   922
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   923
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   924
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   925
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   926
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   927
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   928
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   929
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   930
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   931
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   932
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   933
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   934
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   935
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   936
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   937
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   938
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   939
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   940
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   941
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   942
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   943
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   944
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   945
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   946
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   947
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   948
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   949
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   950
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   951
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   952
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   953
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   954
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   955
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   956
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   957
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   958
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   959
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   960
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   961
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   962
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   963
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   964
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   965
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   966
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   967
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   968
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   969
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   970
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   971
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   972
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   973
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   974
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   975
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   976
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   977
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   978
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   979
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   980
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   981
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   982
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   983
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   984
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   985
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   986
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   987
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   988
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   989
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   990
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   991
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   992
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   993
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   994
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   995
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   996
!MenuPanel methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   997
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   998
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
   999
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1000
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1001
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1002
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1003
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1004
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1005
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1006
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1007
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1008
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1009
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1010
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1011
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1012
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1013
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1014
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1015
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1016
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1017
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1018
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1019
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1020
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1021
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1022
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1023
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1024
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1025
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1026
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1027
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1028
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1029
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1030
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1031
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1032
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  1033
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1034
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1035
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1036
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1037
    enabled ~~ state ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1038
        enabled := state.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1039
        self invalidate.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1040
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1041
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1042
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1043
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1044
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1045
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1046
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1047
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1048
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1049
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1050
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1051
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1052
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1053
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1054
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1055
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1056
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1057
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1058
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1059
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1061
!MenuPanel methodsFor:'accessing-channels'!
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1062
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1063
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1064
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1065
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1066
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1067
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1068
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1069
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1070
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1071
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1072
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1073
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1074
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1075
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1076
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1077
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1078
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1079
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1080
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1081
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1082
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1083
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1084
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1085
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1086
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1087
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1088
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1089
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1090
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1091
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1092
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1093
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1094
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1095
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1096
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1097
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1098
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1099
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1100
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1101
!MenuPanel methodsFor:'accessing-color & font'!
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1102
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1103
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1104
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1105
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1106
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1107
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1108
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1109
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1110
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1111
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1112
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1113
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1114
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1115
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1116
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1117
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1118
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1119
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1120
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1121
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1122
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1123
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1124
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1125
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1126
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1127
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1128
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1129
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1130
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1131
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1132
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1133
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1134
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1135
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1136
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1137
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1138
    ^ButtonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1139
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1140
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1141
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1142
    "get the button edge style
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1143
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1144
    ^ButtonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1145
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1146
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1147
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1148
    "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
  1149
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1150
    ^ buttonEnteredBgColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1151
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1152
    "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
  1153
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1154
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1155
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1156
    "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
  1157
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1158
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1159
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1160
    "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
  1161
    "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
  1162
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1163
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1164
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1165
    "get the background drawing color used to half light button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1166
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1167
    ^buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1168
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1169
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1170
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1171
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1172
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1173
    ^buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1174
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1175
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1176
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1177
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1178
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1179
    ^buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1180
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1181
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1182
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1183
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1184
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1185
    ^ButtonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1186
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1187
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1188
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1189
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1190
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1191
    ^buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1192
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1193
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1194
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1195
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1196
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1197
  ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1198
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1199
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1200
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1201
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1202
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1203
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1204
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1205
        super font:(aFont onDevice:device).
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1206
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1207
        superMenu notNil ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1208
            self extent:(self preferredExtent)
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1209
        ].
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1210
        self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1211
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1212
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1213
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1214
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1215
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1216
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1217
  ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1218
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1219
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1220
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1221
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1222
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1223
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1224
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1225
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1226
    fgColor ~~ aColor ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1227
        fgColor := aColor onDevice:device.
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1228
        shown ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1229
            self invalidate "/ RepairNow:true
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1230
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1231
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1232
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1233
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1234
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1235
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1236
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1237
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1238
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1239
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1240
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1241
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1242
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1243
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1244
maxAbsoluteButtonLevel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1245
    "returns the maximum absolute button level; used to compute the preferred
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1246
     extent of a button
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1247
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1248
    |level|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1249
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1250
    level := (ButtonActiveLevel abs) max:(ButtonEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1251
  ^ level max:(ButtonPassiveLevel abs)
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1252
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1253
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1254
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1255
    "get the selection frame bright color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1256
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1257
    ^selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1258
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1259
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1260
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1261
    "get the selection frame dark color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1262
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1263
    ^selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1264
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1265
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1266
setFont:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1267
    "set the font derived from item; if unchanged nil is returned otherwise the old font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1268
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1269
    |currentFont|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1270
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1271
    (aFont notNil and:[aFont ~= font]) ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1272
        currentFont := font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1273
        super font:aFont.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1274
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1275
    ^ currentFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1276
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1277
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1278
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1279
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1280
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1281
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1282
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1283
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1284
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1285
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1286
!MenuPanel methodsFor:'accessing-dimensions'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1287
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1288
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1289
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1290
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1291
    (explicitExtent ~~ true) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1292
        ^ self preferredExtent y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1293
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1294
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1295
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1297
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1298
    "compute and returns my preferred extent
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1299
        !!!!!! changes have influence on method #rearrangeItems !!!!!!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1301
    |hasMenu shCtKey extent showAcc sck
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1302
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1303
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1304
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1305
     buttonInset "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1306
     labelInset  "{ Class:SmallInteger }"
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1307
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1308
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1309
    (size := items size) == 0 ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1310
        ^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1311
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1312
    buttonInset := 2 * (DefaultButtonItemSpace abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1313
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1314
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1315
        labelInset := 2 * (DefaultEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1316
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1317
        labelInset := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1318
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1319
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1320
    x := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1321
    y := 0.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1322
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1323
    self verticalLayout ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1324
        "/ HORIZONTAL LAYOUT
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1325
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1326
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1327
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1328
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1329
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1330
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1331
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1332
                
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1333
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1334
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1335
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1336
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1337
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1338
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1339
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1340
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1341
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1342
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1343
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1344
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1345
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1346
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1347
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1348
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1349
                x := eX + x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1350
                y := eY max:y.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1351
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1352
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1353
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1354
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1355
        shCtKey := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1356
        showAcc := MenuView showAcceleratorKeys == true.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1357
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1358
        x := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1359
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1360
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1361
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1362
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1363
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1364
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1365
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1366
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1367
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1368
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1369
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1370
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1371
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1372
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1373
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1374
                hasMenu ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1375
                    hasMenu := el hasSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1376
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1377
                (showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1378
                    shCtKey := shCtKey max:(sck widthOn:self)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1379
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1380
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1381
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1382
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1383
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1384
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1385
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1386
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1387
                y := eY + y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1388
                x := eX max:x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1389
            ].
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1390
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1391
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1392
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1393
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1394
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1395
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1396
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1397
                x := x + ShortcutKeyOffset 
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1398
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1399
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1400
"/ to have a small inset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1401
        y := y + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1402
"/        x := x + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1403
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1404
    x := x + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1405
    y := y + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1406
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1407
  ^ x @ y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1408
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1409
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1410
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1411
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1412
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1413
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1414
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1415
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1416
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1417
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1418
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1419
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1420
!MenuPanel methodsFor:'accessing-interactors'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1421
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1422
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1423
    iconIndicationOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1424
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1425
            iconIndicationOff := superMenu iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1426
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1427
            iconIndicationOff := self registerImageOnDevice:(self class iconIndicationOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1428
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1429
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1430
    ^ iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1431
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1432
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1433
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1434
    iconIndicationOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1435
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1436
            iconIndicationOn := superMenu iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1437
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1438
            iconIndicationOn := self registerImageOnDevice:(self class iconIndicationOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1439
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1440
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1441
    ^ iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1442
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1443
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1444
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1445
    iconRadioGroupOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1446
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1447
            iconRadioGroupOff := superMenu iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1448
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1449
            iconRadioGroupOff := self registerImageOnDevice:(self class iconRadioGroupOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1450
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1451
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1452
    ^ iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1453
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1454
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1455
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1456
    iconRadioGroupOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1457
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1458
            iconRadioGroupOn := superMenu iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1459
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1460
            iconRadioGroupOn := self registerImageOnDevice:(self class iconRadioGroupOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1461
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1462
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1463
    ^ iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1464
! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1465
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1466
!MenuPanel methodsFor:'accessing-items'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1467
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1468
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1469
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1470
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1471
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1472
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1473
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1475
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1476
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1477
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1478
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1479
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1480
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1481
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1482
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1483
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1484
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1485
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1486
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1487
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1488
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1489
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1491
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1492
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1493
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1494
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1495
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1496
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1497
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1498
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1499
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1500
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1501
    ^ items notNil ifTrue:[items at:anIndex ifAbsent:nil] ifFalse:[nil]
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1502
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1503
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1504
items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1505
    "returns list of items or nil
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1506
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1507
    ^ items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1508
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1509
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1510
!MenuPanel methodsFor:'accessing-look'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1511
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1512
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1513
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1514
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1515
    ^ButtonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1516
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1517
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1518
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1519
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1520
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1521
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1522
    ^ButtonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1523
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1524
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1525
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1526
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1527
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1528
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1529
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1530
     NOT SUPPORTED
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1531
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1532
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1533
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1534
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1535
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1536
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1537
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1538
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1539
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1540
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1541
    fitFirstPanel := aState.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1542
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1543
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1544
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1545
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1546
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1547
  ^ groupDividerSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1548
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1549
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1550
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1551
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1552
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1553
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1554
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1555
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1556
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1557
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1558
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1559
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1560
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1561
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1562
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1563
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1564
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1565
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1566
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1567
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1568
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1569
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1570
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1571
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1572
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1573
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1574
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1575
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1576
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1577
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1578
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1579
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1580
level:anInt
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1581
    super level:anInt.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1582
    mustRearrange := true
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1583
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1584
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1585
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1586
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1587
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1588
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1589
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1590
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1591
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1592
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1593
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1594
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1595
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1596
  ^ (self menuAdornmentAt:#showGroupDivider)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1597
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1598
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1599
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1600
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1601
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1602
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1603
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1604
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1605
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1606
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1607
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1609
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1610
  ^ (self menuAdornmentAt:#showSeparatingLines)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1611
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1612
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1613
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1615
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1616
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1617
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1618
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1619
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1620
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1621
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1622
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1623
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1624
    superMenu notNil ifTrue:[^ true].
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1625
  ^ (self menuAdornmentAt:#verticalLayout)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1626
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1627
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1629
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1630
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1631
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1632
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1633
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1634
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1635
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1636
!MenuPanel methodsFor:'accessing-submenu'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1637
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1638
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1639
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1640
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1641
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1642
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1643
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1644
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1645
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1646
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1647
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1649
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1650
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1651
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1652
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1653
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1654
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1655
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1656
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1657
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1658
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1659
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1660
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1661
1698
8d29156bab20 category rename
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1662
!MenuPanel methodsFor:'activation / deactivation'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1663
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1664
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1665
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1666
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1667
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1668
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1669
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1670
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1671
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1672
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1673
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1674
show
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1675
    "realize the view at its last position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1676
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1677
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1678
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1679
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1681
showAt:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1682
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1683
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1684
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1685
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1686
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1687
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1688
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1689
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1690
    "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
  1691
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1692
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1693
     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
  1694
     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
  1695
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1696
    "
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1697
    self rearrangeItemsIfItemVisibilityChanged.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1698
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1699
    aBoolean ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1700
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1701
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1702
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1703
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1704
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1705
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1706
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1707
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1708
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1709
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1710
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1711
    ].
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1712
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1713
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1714
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1715
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1716
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1717
showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1718
    "realize the view at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1719
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1720
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1721
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1722
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1723
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
    "make myself visible at the screen center.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1729
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1730
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1731
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1732
    ^ 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
  1733
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1734
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1735
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1736
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1737
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1738
    "realize the menu at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1739
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1740
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1741
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1742
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1743
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1744
    "realize the menu at aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1745
    "
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1746
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1747
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1748
    "Created: / 21.5.1998 / 14:15:57 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1749
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1750
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1751
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1752
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1753
createAtIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1754
    "create an item and add this item to the index. In case of nil the item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1755
     is added to the end. If the index is not valid nil is returned otherwise
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1756
     the new created item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1757
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1758
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1759
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1760
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1761
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1762
    anIndexOrNil notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1763
	(anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1764
	    ^ nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1765
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1766
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1767
    items isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1768
	items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1769
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1770
	items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1771
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1772
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1773
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1774
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1775
	items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1776
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1777
	items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1778
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1779
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1780
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1781
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1783
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1784
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1785
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1786
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1787
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1788
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1789
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1790
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1791
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1792
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1793
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1794
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1795
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1796
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1797
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1798
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1799
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1800
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1801
	self selection:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1802
	groupSizes := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1803
	self do:[:el| el destroy ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1804
	items := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1805
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1806
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1807
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1808
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1809
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1810
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1811
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1812
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1813
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1814
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1815
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1816
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1817
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1818
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1819
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1820
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1821
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1822
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1823
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1824
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1825
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1826
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1827
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1828
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1829
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1830
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1831
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1832
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1833
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1834
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1835
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1836
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1837
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1838
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1839
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1840
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1841
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1842
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1843
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1844
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1845
    self disabledRedrawDo:[
1666
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1846
        |menu newItems|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1847
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1848
        self removeAll.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1849
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1850
        (menu := aMenu) notNil ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1851
            (aMenu isCollection) ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1852
                menu := Menu new.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1853
                menu fromLiteralArrayEncoding:aMenu.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1854
            ] ifFalse:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1855
                menu receiver notNil ifTrue:[receiver := menu receiver]
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1856
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1857
            (newItems := menu menuItems) size > 0 ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1858
                items := newItems collect:[:ni | 
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1859
                                |i|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1860
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1861
                                i:= Item in:self.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1862
                                i menuItem:ni.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1863
                                i.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1864
                            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1865
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1866
            self groupSizes:(menu groupSizes).
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1867
        ]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1868
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1869
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1870
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1871
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1872
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1873
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1874
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1875
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1876
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1877
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1878
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1879
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1880
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1881
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1882
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1883
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1884
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1885
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1886
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1887
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1888
drawButtonEdgesFor:anItem level:aLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1889
    |layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1890
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1891
    aLevel ~~ 0 ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1892
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1893
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1894
        styleSheet is3D ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1895
            self displayRectangle:layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1896
        ] ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1897
            self drawEdgesForX:(layout left)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1898
                             y:(layout top)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1899
                         width:(layout width)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1900
                        height:(layout height)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1901
                         level:aLevel 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1902
                        shadow:buttonShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1903
                         light:buttonLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1904
                    halfShadow:buttonHalfShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1905
                     halfLight:buttonHalfLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1906
                         style:ButtonEdgeStyle
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1907
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1908
    ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1909
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1910
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1911
drawLabelEdgeFor:anItem selected:isSelected
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1912
    |level layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1913
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1914
    isSelected ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1915
        level := onLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1916
    ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1917
        anItem == enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1918
            level := DefaultEnteredLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1919
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1920
            level := offLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1921
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1922
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1923
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1924
    level ~~ 0 ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1925
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1926
1691
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1927
        self drawEdgesForX:(layout left)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1928
                         y:(layout top)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1929
                     width:(layout width)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1930
                    height:(layout height)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1931
                     level:level
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1932
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1933
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1934
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1935
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1936
invalidateItem:anItem repairNow:aBool
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1937
    "an item changed; invalidate the items layout
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1938
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1939
    (mustRearrange not and:[shown]) ifTrue:[
1728
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1940
        self invalidate:(anItem layout copy insetBy:-1) repairNow:aBool
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1941
    ].
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1942
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1943
    "Modified: / 29.2.2000 / 11:28:59 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1944
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1945
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1946
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1947
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1948
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1949
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1950
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1951
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1952
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1953
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1954
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1955
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1956
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1957
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1958
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1959
rearrangeGroups
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1960
    "implements the groupIdentifier #right in a horizontal menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1961
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1962
    |layout point
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1963
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1964
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1965
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1966
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1967
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1968
        ^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1969
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1970
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1971
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1972
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1973
    (dltX := width - margin - layout right) <= 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1974
        ^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1975
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1976
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1977
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1978
    start == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1979
        ^ self  "/ no item detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1980
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1981
    point := dltX @ 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1982
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1983
    "/ move items layout to right
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1984
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1985
    items from:start do:[:anItem|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1986
        anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1987
            anItem layout moveBy:point.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1988
        ]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1989
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1990
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1991
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1992
rearrangeItems
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1993
    "recompute the layout of each item
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1994
        !!!!!! changes have influence on method #preferredExtent !!!!!!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1995
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1996
    |isVertical extent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1997
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1998
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1999
     x0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2000
     y0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2001
     x1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2002
     y1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2003
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2004
     inset       "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2005
     labelInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2006
     buttonInset "{ Class:SmallInteger }"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2007
    |
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2008
    (mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2009
        mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2010
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2011
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2012
    isVertical  := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2013
    buttonInset := DefaultButtonItemSpace abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2014
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2015
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2016
        labelInset := DefaultEnteredLevel abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2017
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2018
        labelInset := 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2019
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2020
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2021
    (self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2022
        extent := self preferredExtent copy.
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2023
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2024
        self isPopUpView ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2025
            isVertical ifTrue:[extent y:1.0] ifFalse:[extent x:1.0]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2026
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2027
        self extent:extent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2028
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2029
        extent := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2030
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2031
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2032
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2033
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2034
    isVertical ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2035
        y0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2036
        y1 := extent y - margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2037
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2038
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2039
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2040
                el layout:(Rectangle left:x top:y0 right:x bottom:y1)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2041
            ] ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2042
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2043
                    inset := DefaultButtonItemSpace
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2044
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2045
                    inset := labelInset
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2046
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2047
                x0 := x  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2048
                x1 := x0 + el preferredExtent x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2049
                el layout:(Rectangle left:x0 top:(y0 + inset) right:x1 bottom:(y1 - inset)).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2050
                x := x1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2051
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2052
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2053
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2054
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2055
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2056
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2057
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2058
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2059
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2060
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2061
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2062
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2063
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2064
        x0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2065
        x1 := extent x - margin.  "/ -1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2066
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2067
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2068
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2069
                el layout:(Rectangle left:x0 top:y right:x1 bottom:y)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2070
            ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2071
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2072
                    inset := DefaultButtonItemSpace
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2073
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2074
                    inset := labelInset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2075
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2076
                y0 := y  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2077
                y1 := y0 + el preferredExtent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2078
                el layout:(Rectangle left:(x0 + inset) top:y0 right:(x1 - inset) bottom:y1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2079
                y := y1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2080
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2081
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2082
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2083
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2084
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2085
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2086
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2087
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2088
            ]
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2089
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2090
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2091
    self rearrangeGroups.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2092
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2093
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2094
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2095
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2096
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2097
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2098
rearrangeItemsIfItemVisibilityChanged
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2099
    "check for items which can change its visibility;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2100
     if at least one item exists, rearrange all items
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2101
    "
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2102
    items isNil ifTrue:[^ self].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2103
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2104
    items do:[:item |
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2105
        item canChangeVisibility ifTrue:[
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2106
            mustRearrange := true.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2107
            self rearrangeItems.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2108
            ^ self
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2109
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2110
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2111
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2112
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2113
redrawX:x y:y width:w height:h
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
    "redraw a rectangle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2116
    |isVertical item layout prevClip
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2117
     x1             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2118
     x2             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2119
     y1             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2120
     y2             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2121
     start          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2122
     stop           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2123
     size           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2124
     groupDivInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2125
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2126
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2127
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2128
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2129
    mustRearrange ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2130
        self isPopUpView not ifTrue:[explicitExtent := true].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2131
        self rearrangeItems.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2132
      ^ self invalidate
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2133
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2134
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2135
    self paint:(self backgroundColor).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2136
    self clearRectangleX:x y:y width:w height:h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2137
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2138
    (size := items size) == 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2139
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2140
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2141
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2142
    isVertical := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2143
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2144
    isVertical ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2145
        start := items findFirst:[:el| el layout bottom > y ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2146
        start == 0 ifTrue:[ ^ self ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2147
        y1 := y + h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2148
        stop := items findFirst:[:el| el layout top > y1 ] startingAt:(start + 1).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2149
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2150
        start := items findFirst:[:el| el layout right > x ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2151
        start == 0 ifTrue:[ ^ self ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2152
        x1  := x + w.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2153
        stop := items findFirst:[:el| el layout left > x1] startingAt:(start + 1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2154
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2155
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2156
    stop == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2157
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2158
    (groupSizes size ~~ 0 and:[self showGroupDivider]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2159
        groupDivInset := groupDividerSize // 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2160
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2161
        groupDivInset ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2162
            (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2163
                start := start - 1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2164
            ]
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2165
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2166
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2167
        groupDivInset := 0
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2168
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2169
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2170
    prevClip := clipRect.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2171
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2172
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2173
    start to:stop do:[:i|
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2174
        item := items at:i.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2175
        item redraw.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2176
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2177
        (groupDivInset ~~ 0 and:[i ~~ size and:[self hasGroupDividerAt:i]]) ifTrue:[
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2178
            layout := item layout.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2179
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2180
            isVertical ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2181
                x1 := layout left.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2182
                x2 := layout right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2183
                y1 := layout bottom + groupDivInset.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2184
                y2 := y1.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2185
            ] ifFalse:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2186
                y1 := layout top.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2187
                y2 := layout bottom.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2188
                x1 := layout right + groupDivInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2189
                x2 := x1.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2190
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2191
            self paint:shadowColor.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2192
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2193
            self paint:lightColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2194
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2195
            isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2196
                      ifFalse:[x1 := x1 + 1. x2 := x1 ].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2197
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2198
            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
  2199
        ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2200
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2201
    self clippingRectangle:prevClip.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2202
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2203
    "Modified: / 21.5.1999 / 20:14:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2204
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2205
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2206
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2207
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2208
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2209
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2210
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2211
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2212
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2214
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2215
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2216
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2217
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2218
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2219
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2220
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2221
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2222
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2223
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2224
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2225
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2226
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2227
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2228
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2229
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2230
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2231
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2232
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2233
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2234
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2235
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2236
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2237
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2238
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2239
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2240
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2241
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2242
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2243
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2244
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2245
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2246
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2247
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2248
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2249
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2250
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2251
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2252
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2253
    i ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2254
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2255
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2256
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2257
    something isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2258
	i := self findFirst:[:el|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2259
				v := el value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2260
				v isSymbol and:[v == something]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2261
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2262
	i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2263
	    ^ i
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2264
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2265
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2266
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2267
    (something respondsTo:#string) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2268
	v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2269
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2270
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2271
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2272
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2273
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2274
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2275
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2276
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2277
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2278
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2279
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2280
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2281
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2282
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2283
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2285
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2286
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2287
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2288
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2289
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2290
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2291
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2292
    |menue point sensor|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2293
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2294
    sensor := self sensor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2295
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2296
    (sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2297
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2298
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2299
    menue := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2300
    point := menue translateGrabPoint:(x@y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2301
    menue handleButtonMotion:state x:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2302
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2303
    (self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2304
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2305
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2306
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2307
    (selection notNil and:[selection currentSubmenu isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2308
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2309
        (self containsPointX:x y:y) ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2310
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2311
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2312
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2313
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  2314
    "Modified: / 2.3.2000 / 21:51:16 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2315
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2316
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2317
buttonPress:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2318
    "any button pressed; open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2319
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2320
    |srcPoint dstMenu dstPoint dstItem|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2321
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2322
    srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2323
    dstMenu  := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2324
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2325
    dstMenu isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2326
        ^ self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2327
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2328
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2329
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2330
    dstItem  := dstMenu itemAtX:(dstPoint x) y:(dstPoint y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2331
    dstMenu selection:dstItem.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2332
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2333
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2334
buttonRelease:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2335
    "button release action; accept selection and close all views
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2336
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2337
    |topMenu dstMenu item srcPoint dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2338
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2339
    topMenu := self topMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2340
    dstMenu := topMenu activeMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2341
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2342
    (    dstMenu selection notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2343
     or:[dstMenu isPopUpView not
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2344
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2345
         and:(dstMenu mapTime)) > 400]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2346
    ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2347
        srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2348
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2349
        (     (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2350
         and:[(item    := dstMenu selection) notNil]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2351
        ) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2352
            item currentSubmenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2353
                dstMenu selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2354
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2355
                (selection isNil and:[self isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2356
                    self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2357
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2358
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2359
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2360
            dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2361
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2362
            (dstMenu itemAtX:(dstPoint x) y:(dstPoint y)) == dstMenu selection ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2363
                item := nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2364
            ].
1704
2aecaa179ced support of hideMenuOnActivated in the correct way
ca
parents: 1703
diff changeset
  2365
            ^ topMenu acceptItem:item inMenu:dstMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2366
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2367
        (selection notNil and:[dstMenu == self]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2368
            selection currentSubmenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2369
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2370
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2371
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2372
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2373
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2374
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2375
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2376
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2377
keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2378
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2379
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2380
    |menu point|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2381
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2382
       (key == #Tab 
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2383
    or:[key == #FocusNext
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2384
    or:[key == #FocusPrevious]]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2385
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2386
      ^ super keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2387
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2388
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2389
    menu := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2390
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2391
    key == #Escape ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2392
        "/ must hide the active menu
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2393
        ((menu := menu superMenu) notNil and:[menu ~~ self]) ifTrue:[
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2394
            "/ hide active menu but keep the grab
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2395
            menu selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2396
        ] ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2397
            "/ hide active menu and ungrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2398
            self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2399
        ].
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2400
        ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2401
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2402
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2403
    [   menu shown ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2404
            point := menu translateGrabPoint:(x@y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2405
            menu handleKeyPress:key x:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2406
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2407
            selection isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2408
                self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2409
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2410
          ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2411
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2412
        (menu := menu superMenu) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2413
    ] whileTrue.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2414
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2415
    self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2416
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2417
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2418
pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2419
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2420
    self detectGrabMenu handlePointerLeave:state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2421
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2422
    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2423
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2424
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2425
    (selection notNil and:[selection currentSubmenu isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2426
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2427
        self sensor anyButtonPressed ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2428
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2429
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2430
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2431
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2432
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2433
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2434
processShortcutKeyEventInMenuBar:event
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2435
    "an event as forwarded from the keyboardProcessor -
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2436
     if there is a short-key for that character, process it
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2437
     and return true. Otherwise, return false.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2438
    "
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2439
    |key winGroup|
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2440
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2441
    key := event key.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2442
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2443
    (self processShortcutKeyInMenuBar:key) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2444
        (selection notNil and:[(winGroup := self windowGroup) notNil]) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2445
            winGroup focusView:self
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2446
        ].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2447
        ^ true
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2448
    ].
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2449
    ^ false
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2450
!
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2451
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2452
sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2453
    "redraw #right groups
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2454
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2455
    |index layout invRect w right|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2456
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2457
    (mustRearrange or:[self isPopUpView]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2458
        ^ super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2459
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2460
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2461
    index := self findFirst:[:anItem| anItem startGroup == #right ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2462
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2463
    index ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2464
        (shown not or:[index == 1]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2465
            self mustRearrange.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2466
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2467
            layout := (items at:(index -1)) layout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2468
            right  := 1 + layout right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2469
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2470
            (w := width - right) > margin ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2471
                invRect := Rectangle left:right top:0 width:w height:height.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2472
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2473
                items from:index do:[:anItem|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2474
                    anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2475
                        layout := anItem layout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2476
                        layout setLeft:right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2477
                        right := layout right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2478
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2479
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2480
                self rearrangeGroups.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2481
                self invalidate:invRect
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2482
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2483
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2484
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2485
    super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2486
! !
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2487
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2488
!MenuPanel methodsFor:'event handling processing'!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2489
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2490
handleButtonMotion:state x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2491
    "open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2492
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2493
    |menu point sel|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2494
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2495
    self sensor anyButtonPressed ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2496
        "/ highlight enterItem if no selection exists
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2497
        selection isNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2498
            (self containsPointX:x y:y) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2499
                ((sel := self itemAtX:x y:y) isNil or:[sel canSelect not]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2500
                    ^ self pointerEntersItem:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2501
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2502
                (DefaultSelectionFollowsMouse and:[superMenu notNil]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2503
                    self selection:sel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2504
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2505
                    self pointerEntersItem:sel
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2506
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2507
                ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2508
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2509
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2510
        self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2511
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2512
        (DefaultSelectionFollowsMouse and:[(menu := self superMenuAtX:x y:y) notNil]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2513
            point := self translatePoint:(x@y) to:menu.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2514
            sel   := menu itemAtX:(point x) y:(point y).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2515
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2516
            (sel notNil and:[sel canSelect]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2517
                menu selection:sel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2518
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2519
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2520
      ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2521
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2522
    self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2523
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2524
    (menu := self superMenuAtX:x y:y) isNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2525
        self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2526
            self selection:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2527
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2528
        ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2529
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2530
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2531
    menu == self ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2532
        (sel := self itemAtX:x y:y) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2533
            self selection:sel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2534
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2535
    ] ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2536
        point := self translatePoint:(x@y) to:menu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2537
        sel   := menu itemAtX:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2538
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2539
        (sel isNil and:[menu isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2540
            sel := menu selection.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2541
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2542
        menu selection:sel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2543
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2544
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2545
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2546
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2547
handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2548
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2549
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2550
    |next submenu item
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2551
     n     "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2552
     idx   "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2553
     first "{ Class:SmallInteger }"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2554
     size  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2555
    |
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2556
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2557
    (selection isNil and:[superMenu notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2558
        ^ superMenu handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2559
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2560
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2561
    self verticalLayout ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2562
        aKey == #CursorLeft ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2563
            ^ self selection:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2564
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2565
        aKey ~~ #CursorRight ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2566
            next := aKey == #CursorDown
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2567
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2568
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2569
        aKey == #CursorUp ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2570
            ^ self selection:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2571
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2572
        aKey ~~ #CursorDown ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2573
            next := aKey == #CursorRight
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2574
        ].        
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2575
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2576
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2577
    next isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2578
        (item := self selection) notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2579
            (submenu := item currentSubmenu) notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2580
                idx := submenu findFirst:[:el| el canSelect ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2581
              ^ submenu selectionIndex:idx
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2582
            ].
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2583
            ^ self selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2584
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2585
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2586
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2587
    first := self findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2588
    first == 0 ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2589
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2590
    idx := self selectionIndex.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2591
    n   := 1 + (self sensor compressKeyPressEventsWithKey:aKey).
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2592
    size := items size.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2593
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2594
    n timesRepeat:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2595
        next ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2596
            [((idx := idx + 1) <= size and:[(items at:idx) canSelect not])
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2597
            ] whileTrue.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2598
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2599
            idx > size ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2600
                idx := first
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2601
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2602
        ] ifFalse:[    
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2603
            [((idx := idx - 1) > 0  and:[(items at:idx) canSelect not])
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2604
            ] whileTrue.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2605
            
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2606
            idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2607
        ]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2608
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2609
    self selectionIndex:idx.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2610
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  2611
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2612
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2613
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2614
handleKeyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2615
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2616
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2617
    |item|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2618
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2619
    (key == #Return or:[key == Character space]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2620
        ^ self accept.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2621
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2622
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2623
    key isCharacter ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2624
        (     key == #CursorDown or:[key == #CursorUp
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2625
          or:[key == #CursorLeft or:[key == #CursorRight]]]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2626
        ) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2627
            self handleCursorKey:key
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2628
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2629
            self processShortcutKeyInMenuBar:key
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2630
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2631
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2632
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2633
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2634
    (item := self detectItemForKey:key) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2635
        self selection:item.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2636
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2637
        superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2638
            item := superMenu detectItemForKey:key.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2639
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2640
            (item notNil or:[superMenu superMenu notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2641
                superMenu selection:item
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2642
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2643
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2644
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2645
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2646
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2647
handlePointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2648
    self  pointerEntersItem:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2649
    super pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2650
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2651
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2652
pointerEntersItem:anItemOrNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2653
    "the pointer moves over an item or nil; restore the old item and
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2654
     redraw the new item highlighted.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2655
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2656
    |oldItem newItem|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2657
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2658
    (     anItemOrNil notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2659
     and:[anItemOrNil canSelect
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2660
     and:[selection isNil
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2661
     and:[self isPopUpView not]]]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2662
        anItemOrNil isButton ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2663
            (    buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2664
             or:[ButtonEnteredLevel   ~~ ButtonPassiveLevel]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2665
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2666
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2667
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2668
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2669
            DefaultEnteredLevel ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2670
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2671
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2672
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2673
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2674
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2675
    newItem ~~ enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2676
        oldItem     := enteredItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2677
        enteredItem := newItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2678
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2679
        oldItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2680
            self invalidateItem:oldItem repairNow:(enteredItem isNil).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2681
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2682
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2683
        enteredItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2684
            self invalidateItem:enteredItem repairNow:true.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2685
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2686
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2687
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2688
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2689
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2690
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2691
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2692
doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2693
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2694
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2695
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2696
        superMenu doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2697
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2698
        hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2699
            self grabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2700
            hasImplicitGrap := true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2701
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2702
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2703
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2704
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2705
doUngrab:forceDo
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2706
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2707
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2708
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2709
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2710
        forceDo ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2711
            superMenu doUngrab:true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2712
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2713
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2714
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2715
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2716
    hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2717
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2718
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2719
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2720
    forceDo ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2721
        (selection notNil or:[prevFocusView == self]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2722
            ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2723
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2724
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2725
    self ungrabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2726
    self selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2727
    hasImplicitGrap := nil.
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2728
    prevFocusView   := nil.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2729
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2730
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2731
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2732
grabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2733
    "grap the keyboard; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2734
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2735
    previousKeyboardGrab := device activeKeyboardGrab.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2736
  ^ super grabKeyboard
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2737
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2738
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2739
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2740
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2741
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2742
    "get exclusive access to pointer and keyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2743
    "
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2744
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2745
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2746
    realized ifTrue:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2747
        prevFocusView := self windowGroup focusView.
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  2748
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2749
        sensor := self sensor.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2750
        device activePointerGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2751
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2752
                sensor flushMotionEventsFor:nil.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2753
            ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2754
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2755
            (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2756
                Delay waitForSeconds:0.1.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2757
                (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2758
                    "give up"
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2759
                    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2760
                    self unmap
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2761
                ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2762
            ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2763
        ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2764
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2765
        device activeKeyboardGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2766
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2767
                device sync.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2768
                sensor flushKeyboardFor:nil
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2769
            ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2770
            self grabKeyboard.
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2771
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2772
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2773
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2774
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  2775
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2776
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2777
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2778
grabPointerWithCursor:aCursorOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2779
    "grap the pointer; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2780
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2781
    previousPointerGrab := device activePointerGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2782
    hasImplicitGrap := true.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2783
  ^ super grabPointerWithCursor:aCursorOrNil
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2784
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2785
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2786
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2787
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2788
ungrabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2789
    "ungrap the keyboard; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2790
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2791
    super ungrabKeyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2792
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2793
    previousKeyboardGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2794
        device grabKeyboardInView:previousKeyboardGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2795
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2796
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2797
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2798
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2799
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2800
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2801
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2802
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2803
    self ungrabPointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2804
    self ungrabKeyboard.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2805
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2806
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2807
ungrabPointer
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2808
    "ungrap the pointer; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2809
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2810
    super ungrabPointer.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2811
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2812
    previousPointerGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2813
        device grabPointerInView:previousPointerGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2814
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2815
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2816
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2817
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2818
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2819
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2820
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2821
helpText
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2822
    "return the helpText for the currently selected item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2823
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2824
    ^ self helpTextForItem:selection
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2825
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2826
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2827
helpTextAt:srcPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2828
    "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
  2829
     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
  2830
     "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2831
    |dstMenu dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2832
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2833
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2834
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2835
    dstMenu isNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2836
        ^ ''
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2837
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2838
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2839
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2840
  ^ dstMenu helpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)).
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2841
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2842
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2843
helpTextForItem:anItem
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2844
    "returns the helpText for an item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2845
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2846
    |key val app|
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2847
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2848
    anItem isNil ifTrue:[^ ''].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2849
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2850
    (val := anItem activeHelpText) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2851
        (     (key := anItem activeHelpKey) notNil
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2852
         and:[(app := self application) notNil]
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2853
        ) ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2854
            val := app helpTextForKey:key.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2855
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2856
        anItem activeHelpText:(val ? '').
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2857
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2858
    ^ val
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2859
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2860
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2861
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2862
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2863
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2864
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2865
    "returns image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2866
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2867
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2868
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2869
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2870
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2871
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2872
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2873
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2874
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2875
1688
271829d6a2e4 category changes
Claus Gittinger <cg@exept.de>
parents: 1679
diff changeset
  2876
!MenuPanel methodsFor:'initialization & release'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2877
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2878
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2879
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2880
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2881
    ^self
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2882
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2883
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2884
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2885
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2886
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2887
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2888
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2889
    self isPopUpView ifTrue:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2890
        (PopUpView shadowsOnDevice:device) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2891
            shadowView isNil ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2892
                shadowView := (ShadowView onDevice:device) for:self
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2893
            ] ifFalse:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2894
                self saveUnder:true.
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2895
            ].
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2896
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2897
    ] ifFalse:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2898
        explicitExtent == true ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2899
            (self width) == (superView width) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2900
                self verticalLayout:false
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2901
            ]
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2902
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2903
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2904
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2905
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2906
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2907
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2908
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2909
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2910
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2911
    self clearLastActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2912
    self do:[:el|el destroy].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2913
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2914
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2915
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2916
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2917
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2918
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2919
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2920
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2921
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2922
    "Modified: / 27.2.1998 / 17:41:25 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2923
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2924
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2925
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2926
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2927
1735
941d5de7372c fix some warnings durring compilation
ca
parents: 1734
diff changeset
  2928
    |bw lvl|
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2929
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2930
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2931
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2932
    "/ 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
  2933
    "/ (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
  2934
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2935
    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
  2936
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2937
    self isPopUpView ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2938
        bw  := styleSheet at:#'popup.borderWidth' default:1.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2939
        lvl := styleSheet at:#'popup.level'       default:0.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2940
    ] ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2941
        bw  := styleSheet is3D ifFalse:[1] ifTrue:[0].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2942
        lvl := 1.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2943
    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2944
    self borderWidth:bw.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2945
    self level:lvl.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2946
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2947
    superMenu isNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2948
        fgColor                   := DefaultForegroundColor         onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2949
        activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2950
        activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2951
        disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2952
        rightArrow                := RightArrowForm                 onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2953
        selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2954
        selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2955
        buttonLightColor          := ButtonLightColor               onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2956
        buttonShadowColor         := ButtonShadowColor              onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2957
        ButtonHalfLightColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2958
            buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2959
        ButtonHalfShadowColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2960
            buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2961
        buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2962
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2963
        (rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2964
            rightArrowShadow := rightArrowShadow onDevice:device
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2965
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2966
    ] ifFalse:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2967
        fgColor                   := superMenu foregroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2968
        activeBgColor             := superMenu activeBackgroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2969
        activeFgColor             := superMenu activeForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2970
        disabledFgColor           := superMenu disabledForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2971
        rightArrow                := superMenu rightArrow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2972
        rightArrowShadow          := superMenu rightArrowShadow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2973
        selectionFrameBrightColor := superMenu selectionFrameBrightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2974
        selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2975
        buttonLightColor          := superMenu buttonLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2976
        buttonShadowColor         := superMenu buttonShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2977
        buttonHalfLightColor      := superMenu buttonHalfLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2978
        buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2979
        buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2980
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2981
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2982
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2983
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2984
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2985
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2986
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2987
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2988
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2989
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  2990
    viewBackground := DefaultBackgroundColor.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2991
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2992
    onLevel          := DefaultHilightLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2993
    offLevel         := 0. "/ DefaultLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2994
    itemSpace        := DefaultItemSpace.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2995
    groupDividerSize := DefaultGroupDividerSize.
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2996
    fitFirstPanel    := false.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2997
    font             := MenuView defaultFont.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2998
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2999
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3000
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3001
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3002
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3003
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3004
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3005
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3006
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3007
    self enableMotionEvents.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3008
    enabled := true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3009
    originChanged  := extentChanged := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3010
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3011
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3012
    mustRearrange  := false.
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  3013
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3014
    "Modified: / 2.3.2000 / 21:50:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3015
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3016
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3017
map
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3018
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3019
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3020
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3021
    |anItemList|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3022
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3023
    enteredItem := nil.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3024
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3025
    self enableMotionEvents.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3026
    self becomesActiveMenu.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3027
    super map.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3028
1257
79a40d3f8c2f Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1255
diff changeset
  3029
    anItemList := InitialSelectionQuerySignal query.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3030
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3031
    self do:[:anItem| anItem fetchImages ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3032
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3033
    self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3034
        self doGrab
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3035
    ] ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3036
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3037
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3038
    self do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3039
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3040
    anItemList size > 0 ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3041
        self redrawX:0 y:0 width:width height:height.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3042
        self openMenusFromItems:anItemList.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3043
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3044
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  3045
    "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
  3046
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3047
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3048
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3049
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3050
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3051
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3052
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3053
    self isPopUpView ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3054
        "Because of #saveUnder of ShadowView the order of realize is significant:
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3055
         shadowView must be realized before self"
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3056
        self hiddenOnRealize:true.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3057
        super realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3058
        self resize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3059
        self makeFullyVisible.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3060
        shadowView notNil ifTrue:[
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3061
            shadowView realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3062
        ].
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3063
        self raise.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3064
        self map.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3065
    ] ifFalse:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3066
        super realize.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3067
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3068
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3069
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3070
recreate
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3071
    "this is called after a snapin. If the image was saved with an active menu,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3072
     hide the menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3073
    "
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  3074
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3075
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3077
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3078
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3079
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3080
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3081
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3082
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3083
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3084
    self fetchDeviceResources.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3085
    items notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3086
	items do:[:anItem |
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3087
	    anItem reinitSubmenuStyle
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3088
	]
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3089
    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3090
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3091
    "Created: / 10.9.1998 / 21:37:05 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3092
    "Modified: / 11.9.1998 / 13:20:57 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3093
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3094
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3095
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  3096
    "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
  3097
     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
  3098
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3099
    self clearLastActiveMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3100
    self doUngrab:(superMenu isNil).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3101
"/    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3102
"/         self doUngrab:(superMenu isNil)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3103
"/    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3104
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3105
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3106
    shadowView notNil ifTrue:[shadowView unmap].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3107
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3108
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3109
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3110
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3111
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3112
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3113
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3114
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3115
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3116
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3117
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3118
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3119
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3120
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3121
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3122
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3123
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3124
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3125
superMenu:aSuperMenu
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3126
    "set my supermenu from which i'am activated
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3127
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3128
    (superMenu := aSuperMenu) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3129
        super font:(superMenu font)
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3130
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3131
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3132
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3133
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3134
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3135
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3136
    ^ superMenu isNil ifTrue:[self]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3137
                     ifFalse:[superMenu topMenu]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3138
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3139
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3140
!MenuPanel methodsFor:'printing'!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3141
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3142
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3143
    "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
  3144
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3145
    |string label|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3146
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3147
    string := 'Menu:'.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3148
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3149
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3150
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3151
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3152
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3153
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3154
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3155
    "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
  3156
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3157
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3158
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3159
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3160
application
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3161
    "optimize access to retrive the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3162
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3163
    |appl akey|
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3164
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3165
    superMenu notNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3166
        ^ superMenu application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3167
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3168
    akey := #appl.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3169
    appl := self menuAdornmentAt:akey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3170
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3171
    appl isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3172
        (appl := super application) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3173
            windowGroup isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3174
                ^ nil   "/ RETRY LATER
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3175
            ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3176
            appl := (windowGroup mainGroup topViews first application) ? akey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3177
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3178
        self menuAdornmentAt:akey put:appl
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3179
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3180
    ^ appl ~~ akey ifTrue:[appl] ifFalse:[nil]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3181
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3182
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3183
detectItemForKey:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3184
    "returns the item assigned to a key, accessCharacter or starts with.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3185
     if no item is detected nil is returned.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3186
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3187
    |cIdx uKey lKey item|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3188
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3189
    items isNil ifTrue:[^ nil].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3190
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3191
    cIdx := self selectionIndex.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3192
    uKey := aKey asUppercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3193
    lKey := aKey asLowercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3194
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3195
    items keysAndValuesDo:[:anIndex :anItem| |char label|
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3196
        (     anIndex ~~ cIdx
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3197
         and:[anItem canSelect
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3198
         and:[(label := anItem textLabel) notNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3199
         and:[label size ~~ 0]]]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3200
        ) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3201
            (char := anItem accessCharacter) notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3202
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3203
                    ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3204
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3205
            ] ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3206
                char := label at:1.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3207
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3208
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3209
                    anIndex > cIdx ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3210
                        ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3211
                    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3212
                    item isNil ifTrue:[item := anItem]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3213
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3214
            ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3215
        ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3216
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3217
    ^ item
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3218
!
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3219
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3220
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3221
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3222
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3223
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3224
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3225
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3226
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3227
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3228
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3229
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3230
    "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
  3231
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3232
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3233
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3234
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3235
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3236
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3237
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3238
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3239
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3240
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3241
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3243
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3244
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3245
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3246
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3247
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3248
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3249
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3250
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3251
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3252
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3253
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3254
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3255
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3256
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3257
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3259
openMenusFromItems:anItemList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3260
    "open all menus derived from sequence of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3261
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3262
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3263
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3264
    anItemList size == 0 ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3265
        ^ self
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3266
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3267
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3268
    item := anItemList removeFirst.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3269
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3270
    item enabled ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3271
        ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3272
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3273
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3274
    InitialSelectionQuerySignal answer:anItemList do:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3275
        self selection:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3276
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3277
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3278
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3279
processShortcutKeyInMenuBar:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3280
    "if there is a short-key for that character, process it
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3281
     and return true. Otherwise, return false.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3282
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3283
    |rawKey loItems item maxDepth menu|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3284
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3285
    superMenu notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3286
        "/ must start from topMenu
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3287
        ^ self topMenu processShortcutKeyInMenuBar:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3288
    ].
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3289
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3290
    "/ check whether the key can be a shortCutKey
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3291
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3292
    aKey isCharacter ifTrue:[^ false].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3293
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3294
    ( #(
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3295
        #Meta_L      #Meta_R
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3296
        #Control_R   #Control_L
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3297
        #Shift_R     #Shift_L
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3298
        #CursorUp    #CursorDown
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3299
        #CursorLeft  #CursorRight
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3300
        #Return      #Tab
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3301
        #FocusNext   #FocusPrevious
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3302
        #Escape
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3303
       ) includesIdentical:aKey
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3304
    ) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3305
        ^ false
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3306
    ].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3307
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3308
    "/ 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
  3309
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3310
    maxDepth := 10.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3311
    rawKey   := device keyboardMap keyAtValue:aKey ifAbsent:aKey.
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3312
    loItems  := self selectItemsForShortcutKey:aKey rawKey:rawKey maxDepth:maxDepth.
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3313
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3314
    loItems size == 0 ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3315
        ^ false
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3316
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3317
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3318
    item := loItems last.
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3319
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3320
    item hasSubmenu ifFalse:[
1574
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3321
        self accept:item.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3322
      ^ true
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3323
    ].
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3324
    menu := self.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3325
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3326
    [menu selection == (loItems at:1)] whileTrue:[
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3327
        loItems removeFirst.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3328
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3329
        loItems isEmpty ifTrue:[
1610
8684ca8df70c checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1609
diff changeset
  3330
          ^ false
1574
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3331
        ].
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3332
        menu := selection submenu.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3333
    ].
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3334
    menu openMenusFromItems:loItems.
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3335
    ^ true.
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3336
!
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3337
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3338
registerImageOnDevice:anImage
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3339
    |image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3340
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3341
    (image := anImage) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3342
        image device ~~ device ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3343
            image := image copy.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3344
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3345
        image := image on:device.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3346
        image := image clearMaskedPixels.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3347
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3348
    ^ image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3349
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3350
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3351
selectItemsForShortcutKey:aKey rawKey:aRawKey maxDepth:maxDepth
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3352
    "get sequence of items up to the item providing the key (inclusive). The
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3353
     last entry into the collection is the item providing the key, the first
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3354
     entry is the item in the topMenu
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3355
    "
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3356
    |seq menu key|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3357
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3358
    maxDepth <= 0 ifTrue:[^ nil].
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3359
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3360
    self do:[:anItem|
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3361
        anItem isEnabled ifTrue:[
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3362
            (    (key := anItem shortcutKey) notNil
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3363
             and:[(key == aKey or:[key == aRawKey])]
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3364
            ) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3365
                seq := OrderedCollection new
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3366
            ] ifFalse:[
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3367
                (menu := anItem submenu) notNil ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3368
                    seq := menu selectItemsForShortcutKey:aKey rawKey:aRawKey maxDepth:maxDepth-1
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3369
                ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3370
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3371
            seq notNil ifTrue:[
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3372
                seq addFirst:anItem.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3373
              ^ seq
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3374
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3375
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3376
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3377
  ^ nil
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3378
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3379
    "Created: / 19.1.1999 / 16:00:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3380
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3381
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3382
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3383
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3384
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3385
    "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
  3386
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3387
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3388
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3389
    "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
  3390
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3391
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3392
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3393
    "set the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3394
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3395
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3396
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3397
    "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
  3398
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3399
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3400
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3401
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3402
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3403
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3404
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3405
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3406
    "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
  3407
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3408
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3409
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3410
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3411
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3412
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3413
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3414
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3415
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3416
    prevFocusView notNil ifTrue:[
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3417
        self windowGroup focusView:prevFocusView.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3418
        prevFocusView := nil.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3419
    ].
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3420
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3421
    top activeMenu == self ifTrue:[
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3422
        top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3423
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3424
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3425
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3426
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3427
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3428
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3429
    "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
  3430
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3431
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3432
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3433
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3434
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3435
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3436
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3437
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3438
detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3439
    "returns the menu which is responsible for the grap; the last opened menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3440
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3441
    |subMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3442
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3443
    selection notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3444
        (subMenu := selection currentSubmenu) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3445
            ^ subMenu detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3446
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3447
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3448
    ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3449
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3450
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3451
detectMenuAtGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3452
    "returns the menu which contains the grab-point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3453
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3454
    |dstMenu dstPoint firstMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3455
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3456
    dstPoint := self translateGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3457
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3458
    ((dstPoint x between:0 and:width) and:[dstPoint y between:0 and:height]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3459
        firstMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3460
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3461
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3462
    (selection isNil or:[(dstMenu := selection currentSubmenu) isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3463
        ^ firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3464
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3465
    dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3466
  ^ dstMenu ? firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3467
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3468
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3469
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3470
itemAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3471
    "returns the item at a point x@y or nil if none detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3472
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3473
    items notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3474
        ^ items detect:[:el| el containsPointX:x y:y] ifNone:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3475
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3476
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3477
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3478
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3479
superMenuAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3480
    "returns the superMenu which contains the point x@y or nil if none detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3481
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3482
    |grabPoint superMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3483
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3484
    (self containsPointX:x y:y) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3485
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3486
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3487
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3488
    grabPoint := (x@y) - (self translateGrabPoint:0@0).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3489
    superMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3490
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3491
    [ (superMenu := superMenu superMenu) notNil ] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3492
        (superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3493
            ^ superMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3494
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3495
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3496
  ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3497
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3498
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3499
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3500
translateGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3501
    "translate the grab point into self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3502
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3503
    superMenu isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3504
        "I am the grapView"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3505
        ^ aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3506
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3507
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3508
    relativeGrabOrigin isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3509
        relativeGrabOrigin := device translatePoint:0@0 from:(self topMenu id) to:(self id).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3510
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3511
    ^ relativeGrabOrigin + aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3512
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3513
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3514
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3515
translatePoint:aPoint to:aMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3516
    "translate a point into another menu its point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3517
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3518
    |grapPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3519
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3520
    aMenu == self ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3521
        ^ aPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3522
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3523
    grapPoint := aPoint - (self translateGrabPoint:0@0).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3524
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3525
  ^ aMenu translateGrabPoint:grapPoint
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3526
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3527
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3528
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3529
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3530
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3531
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3532
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3533
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3534
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3536
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3537
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3538
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3539
    ^ (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
  3540
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3541
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3542
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3543
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3544
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3545
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3546
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3547
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3548
    groupSizes size ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3549
        i := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3550
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3551
        groupSizes do:[:t|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3552
            (i := i + t) == anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3553
                ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3554
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3555
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3556
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3557
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3558
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3559
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3560
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3561
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3562
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3563
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3564
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3565
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3566
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3567
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3568
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3569
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3570
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3571
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3572
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3573
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3574
    "returns true if the panel is the first in the menu hierarchy in must
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3575
     be fit to the extent of its superView;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3576
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3577
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3578
    ^ false
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3579
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3580
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3581
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3582
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3583
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3584
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3585
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3586
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3587
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3588
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3589
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3590
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3591
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3592
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3593
    ^ self verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3594
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3595
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3596
!
c05874084d4c implement
ca
parents: 407
diff changeset
  3597
c05874084d4c implement
ca
parents: 407
diff changeset
  3598
type
428
ca
parents: 427
diff changeset
  3599
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3600
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3601
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3602
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3603
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3604
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3605
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3606
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3607
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3608
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3609
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3610
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3611
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3612
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3613
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3614
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3615
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3616
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3617
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3618
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3619
selection:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3620
    "change selection to an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3621
    "
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3622
    |item newSel hlp|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3623
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3624
    (newSel := anItemOrNil) isNumber ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3625
        newSel := self itemAt:anItemOrNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3626
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3627
    (newSel notNil and:[newSel canSelect]) ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3628
        newSel := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3630
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3631
    selection == newSel ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3632
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3633
    (item := selection) notNil ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3634
        selection := nil.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3635
        item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3636
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3637
    newSel notNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3638
        newSel == enteredItem ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3639
            enteredItem := nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3640
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3641
            self pointerEntersItem:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3642
        ].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3643
        selection := newSel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3644
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3645
        ActiveHelp isActive ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3646
            hlp := ActiveHelp currentHelpListener.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3647
            hlp initiateHelpFor:self atX:nil y:nil now:true.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3648
        ].
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3649
        realized ifTrue:[self rearrangeItems].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3650
        selection selected:true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3651
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3652
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3653
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3654
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3655
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3656
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3657
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3658
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3659
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3660
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3661
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3662
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3663
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3664
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3665
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3666
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3667
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3668
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3669
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3670
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3672
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3673
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3674
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3675
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3676
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3677
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3678
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3679
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3680
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3681
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3682
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3683
    ^ VerticalInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3684
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3685
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3686
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3687
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3688
separatorSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3689
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3690
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3691
    ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3692
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3693
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3694
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3695
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3696
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3697
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3698
    HorizontalInset       := 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3699
    VerticalInset         := 2.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3700
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3701
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3702
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3703
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3704
    LabelRightOffset      := 15.
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3705
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3706
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3707
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3708
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3709
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3710
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3711
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3712
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3713
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3714
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3715
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3716
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3717
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3718
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3719
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3720
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3721
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3722
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3723
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3724
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3725
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3726
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3727
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3728
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3729
!MenuPanel::Item methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3730
420
ca
parents: 417
diff changeset
  3731
canAccept
ca
parents: 417
diff changeset
  3732
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  3733
    "
ca
parents: 417
diff changeset
  3734
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3735
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3736
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3737
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3738
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3739
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3740
    |arg|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3741
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3742
    indication notNil ifTrue:[    
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3743
        arg := self indicationValue not.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3744
        self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3745
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3746
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3747
            choice value:choiceValue.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3748
          ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3749
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3750
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3751
    ^ arg
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3752
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3753
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3754
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3755
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3756
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3757
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3758
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3759
    ^ accessCharacter
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3760
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3761
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3762
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3763
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3764
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3765
    ^ accessCharacterPosition
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3766
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3767
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3768
accessCharacterPosition:anIndex 
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3769
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3770
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3771
    accessCharacterPosition := anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3772
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3773
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3774
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3775
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3776
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3777
    ^ argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3778
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3779
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3780
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3781
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3782
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3783
    argument := anArgument.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3784
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3785
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3786
currentSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3787
    "returns the current submenu or nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3788
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3789
    ^ subMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3790
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3791
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3792
font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3793
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3794
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3795
    ^ font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3796
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3797
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3798
font:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3799
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3800
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3801
    aFont ~= font ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3802
        font := aFont notNil ifTrue:[aFont onDevice:(menuPanel device)]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3803
                            ifFalse:[nil].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3804
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3805
        rawLabel notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3806
            "have to recompute the extent"
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3807
            self label:label
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3808
        ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3809
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3810
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3811
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3812
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3813
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3814
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3815
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3816
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3817
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3818
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3819
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3820
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3821
    "
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3822
    |size char lbl mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3823
     h "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3824
     w "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3825
    |
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3826
    accessCharacter := rawLabelExtent := disabledRawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3827
    label    := aLabel value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3828
    rawLabel := label value ? ''.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3829
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3830
    rawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3831
        "CHECK FOR SEPARATOR"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3832
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3833
        (isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3834
            size := rawLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3835
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3836
            size == 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3837
                rawLabel := nil.                        "blank separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3838
              ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3839
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3840
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3841
            size == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3842
                char := rawLabel first.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3843
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3844
                (char == $- or:[char == $=]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3845
                    label    := rawLabel.               "line separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3846
                    rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3847
                  ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3848
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3849
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3850
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3851
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3852
        rawLabel isCollection ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3853
            rawLabel := rawLabel asArray.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3854
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3855
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3856
    mfont := menuPanel setFont:font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3857
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3858
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3859
        w := h := 0.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3860
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3861
        rawLabel keysAndValuesDo:[:i :el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3862
            el notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3863
                lbl := self updateAccessCharacterFor:el.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3864
                rawLabel at:i put:lbl.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3865
                w := w max:(lbl widthOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3866
                h := h + 1 + (lbl heightOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3867
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3868
                h := h + 3
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3869
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3870
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3871
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3872
        rawLabel := self updateAccessCharacterFor:rawLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3873
        w := rawLabel  widthOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3874
        h := rawLabel heightOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3875
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3876
    rawLabelExtent := w@h.
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3877
    menuPanel setFont:mfont.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3878
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3879
    menuPanel shown ifTrue:[ self fetchImages ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3880
    menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3881
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3882
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3883
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3884
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3885
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3886
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3887
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3888
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3889
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3890
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3891
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3892
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3893
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3894
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3895
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3896
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3897
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3898
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3899
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3900
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3901
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3902
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3903
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3904
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3905
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3906
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3907
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3908
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3909
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3910
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3911
    ^ shortcutKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3912
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3913
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3914
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3915
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3916
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3917
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3918
    shortcutKey ~~ aKey ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3919
        shortcutKey := aKey.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3920
        self invalidate.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3921
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3922
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3923
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3924
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3925
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3926
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3927
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3928
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3929
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3930
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3931
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3932
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3933
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3934
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3935
    startGroup := aSymbol.
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3936
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3937
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3938
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3939
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3940
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3941
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3942
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3943
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3944
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3945
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3946
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3947
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3948
    "
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3949
    (aSubMenu notNil 
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3950
     and:[(aSubMenu isView or:[aSubMenu isKindOf:Menu]) not]) ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3951
        ^ self submenuChannel:aSubMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3952
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3953
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3954
    (subMenu := aSubMenu) notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3955
        aSubMenu class == Menu ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3956
            subMenu := MenuPanel new.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3957
            menuPanel notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3958
                subMenu receiver:menuPanel receiver.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3959
            ].
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3960
            subMenu superMenu:menuPanel.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3961
            subMenu menu:aSubMenu.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3962
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3963
            subMenu isView ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3964
                subMenu superMenu:menuPanel.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3965
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3966
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3967
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3968
1068
155168a813ad oops - subMenu must be an instance of MenuPanel
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
  3969
    "Modified: / 10.8.1998 / 13:26:28 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3970
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3971
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3972
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3973
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3974
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3975
    |txt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3976
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3977
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3978
        rawLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3979
            ^ rawLabel perform:#string ifNotUnderstood:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3980
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3981
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3982
        rawLabel do:[:el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3983
            (txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3984
                ^ txt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3985
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3986
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3987
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3988
    ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3989
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3990
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3991
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3992
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3993
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3994
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3995
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3996
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3997
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3998
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3999
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4000
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4001
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4002
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4003
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4004
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4005
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4006
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4007
    value    := aValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4008
    argument := anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4009
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4010
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4011
!MenuPanel::Item methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4012
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4013
choice
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4014
    "implements a radio group; the field
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4015
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4016
    ^ choice
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4017
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4018
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4019
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4020
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4021
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4022
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4023
    choice == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4024
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4025
    choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4026
        choice removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4027
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4028
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4029
    (choice := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4030
        choice isSymbol ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4031
            (choice := self aspectAt:choice) isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4032
                choice := something
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4033
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4034
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4035
        choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4036
            choice addDependent:self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4037
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4038
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4039
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4040
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4041
choiceValue
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4042
    "implements a radio group; the value writen to the choice if selected
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4043
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4044
    ^ choiceValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4045
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4046
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4047
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4048
choiceValue:something
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4049
    "implements a radio group; the value writen to the choice if selected
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4050
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4051
    choiceValue ~= something ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4052
        choiceValue := something.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4053
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4054
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4055
            self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4056
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4057
    ].
1074
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
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4060
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4061
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4062
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4063
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4064
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4065
    menuPanel enabled ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4066
        enableChannel isSymbol ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4067
            state := self aspectAt:enableChannel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4068
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4069
            state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4070
                enableChannel := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4071
                enableChannel addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4072
                state := enableChannel value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4073
            ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4074
                state := state value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4075
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4076
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4077
            state := enableChannel value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4078
        ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4079
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4080
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4081
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4082
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4083
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4084
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4085
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4086
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4087
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4088
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4089
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4090
        oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4091
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4092
        oldState := enableChannel value.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4093
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4094
            enableChannel removeDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4095
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4096
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4097
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4098
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4099
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4100
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4101
        newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4102
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4103
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4104
            enableChannel addDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4105
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4106
            enableChannel isSymbol ifTrue:[^ self]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4107
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4108
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4109
        newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4110
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4111
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4112
    newState ~~ oldState ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4113
        self invalidate
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4114
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4115
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4116
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4117
hideMenuOnActivated
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4118
    "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4119
    "
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4120
    ^ hideMenuOnActivated ? true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4121
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4122
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4123
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4124
hideMenuOnActivated:aBool
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4125
   "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4126
   "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4127
   hideMenuOnActivated := aBool.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4128
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4129
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4130
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4131
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4132
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4133
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4134
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4135
    ^ indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4136
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4137
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4138
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4139
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4140
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4141
    indication == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4142
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4143
    indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4144
        indication removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4145
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4146
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4147
    (indication := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4148
        indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4149
            indication addDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4150
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4151
            "/ to force an update of the value
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4152
            self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4153
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4154
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4155
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4156
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4157
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4158
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4159
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4160
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4161
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4162
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4163
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4164
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4165
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4166
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4167
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4168
    layout notNil ifTrue:[
1731
89932327a6f8 redrawAsButton no longer exists; call invalidate
ca
parents: 1730
diff changeset
  4169
        self invalidate.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4170
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4171
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4172
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4173
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4174
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4175
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4176
showBusyCursorWhilePerforming
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4177
    "get the flag which controls if a busy cursor is to be shown
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4178
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4179
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4180
    ^ showBusyCursorWhilePerforming ? false
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4181
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4182
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4183
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4184
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4185
showBusyCursorWhilePerforming:aBoolean
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4186
    "set/clear the flag which controls if a busy cursor is to be shown
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4187
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4188
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4189
    showBusyCursorWhilePerforming := aBoolean.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4190
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4191
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4192
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4193
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4194
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4195
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4196
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4197
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4198
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4199
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4200
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4201
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4202
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4203
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4204
!MenuPanel::Item methodsFor:'accessing-dimension'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4205
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4206
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4207
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4208
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4209
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4210
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4211
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4212
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4213
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4214
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4215
    layout := aLayout.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4216
    self invalidate.
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  4217
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4218
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4219
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4220
preferredExtent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4221
    "compute my preferred extent excluding the shortCutKey and the menu identifier
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4222
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4223
    |isVertical
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4224
     x "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4225
     y "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4226
     s "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4227
    |
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4228
    self isVisible ifFalse:[^ 0@0 ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4229
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4230
    isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4231
        s := menuPanel maxAbsoluteButtonLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4232
        x := s + HorizontalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4233
        y := s + VerticalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4234
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4235
        x  := HorizontalInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4236
        y  := VerticalInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4237
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4238
    x := x * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4239
    y := y * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4240
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4241
    isVertical := menuPanel verticalLayout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4242
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4243
    rawLabel isNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4244
        "SEPARATOR"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4245
        s := self class separatorSize.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4246
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4247
        "width of doubleSeparator is 5 !!!!"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4248
        isVertical ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4249
            x := x max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4250
            y := y + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4251
        ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4252
            y := y max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4253
            x := x + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4254
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4255
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4256
        x := x + rawLabelExtent x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4257
        y := y + rawLabelExtent y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4258
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4259
        isButton ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4260
            menuPanel showSeparatingLines ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4261
                "width of separator is 2 plus right offset 1 := 3"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4262
                isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4263
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4264
            (indication notNil or:[choice notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4265
                x := x + 2 + menuPanel iconIndicationOff width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4266
            ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4267
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4268
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4269
    ^ x@y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4270
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4271
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4272
!MenuPanel::Item methodsFor:'accessing-help'!
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4273
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4274
activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4275
    "get the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4276
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4277
    ^ activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4278
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4279
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4280
activeHelpKey:aHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4281
    "set the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4282
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4283
    activeHelpKey ~~ aHelpKey ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4284
        activeHelpKey  := aHelpKey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4285
        activeHelpText := nil.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4286
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4287
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4288
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4289
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4290
activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4291
    "get the active helpText or nil if not yet resolved
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4292
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4293
    ^ activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4294
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4295
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4296
activeHelpText:aText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4297
    "set the active helpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4298
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4299
    activeHelpText := aText.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4300
! !
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4301
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4302
!MenuPanel::Item methodsFor:'activation / deactivation'!
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4303
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4304
hideSubmenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4305
    "hide submenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4306
    "
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4307
    |id|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4308
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4309
    subMenu notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4310
        subMenu realized ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4311
            (id := subMenu id) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4312
                menuPanel device unmapWindow:id
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4313
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4314
        ] ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4315
           subMenu hide
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4316
        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4317
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4318
        subMenu windowGroup:nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4319
        menuPanel windowGroup removeView:subMenu.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4320
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4321
        "/ release menu if derived from channel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4322
        submenuChannel notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4323
            subMenu := nil
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4324
        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4325
     ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4326
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4327
!
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4328
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4329
openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4330
    "opens the submenu; make sure, that the submenu and the menPanel
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4331
     is fully visible by shifting it into the visible screen area if
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4332
     nescessary.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4333
    "
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4334
    |p o device isVertical topMenu windGrp prefExtent
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4335
     devBot   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4336
     devRight "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4337
     width    "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4338
     height   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4339
     top      "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4340
     left     "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4341
    |
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4342
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4343
    (subMenu notNil and:[subMenu shown not and:[self isSelected and:[menuPanel shown]]]) ifFalse:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4344
        ^ self
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4345
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4346
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4347
    topMenu := menuPanel topMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4348
    windGrp := topMenu windowGroup.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4349
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4350
    subMenu superMenu:menuPanel.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4351
    subMenu becomesActiveMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4352
    subMenu cursor:Cursor hand.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4353
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4354
    windGrp notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4355
        subMenu windowGroup:windGrp.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4356
        windGrp addTopView:subMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4357
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4358
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4359
    " Q&D kludge - if any visibility attributes are blocks;
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4360
      TODO: only invoke mustRearrange if any are blocks
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4361
            (since I react correctly on valueHolder changes)
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4362
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4363
    subMenu rearrangeItemsIfItemVisibilityChanged.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4364
    subMenu fixSize.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4365
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4366
    "compute origin of subMenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4367
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4368
    isVertical := menuPanel verticalLayout.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4369
    device     := menuPanel device.
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4370
    prefExtent := subMenu preferredExtent.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4371
    height     := prefExtent y.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4372
    width      := prefExtent x.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4373
    devBot     := device  usableHeight.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4374
    devRight   := device  usableWidth.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4375
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4376
    p := isVertical ifTrue:[layout topRight - 2] ifFalse:[layout bottomLeft].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4377
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4378
    menuPanel isPopUpView ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4379
        o := menuPanel origin + p
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4380
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4381
        o := device translatePoint:p from:(menuPanel id) to:(device rootWindowId).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4382
    ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4383
    left := o x.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4384
    top  := o y.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4385
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4386
    left + width > devRight ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4387
        left := isVertical ifTrue:[left - layout width - width]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4388
                          ifFalse:[devRight - width]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4389
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4390
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4391
    top + height > devBot ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4392
        top := isVertical ifTrue:[devBot - height]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4393
                         ifFalse:[top - layout height - height]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4394
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4395
    top  := top  max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4396
    left := left max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4397
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4398
    subMenu origin:(left@top).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4399
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4400
    subMenu realized ifFalse:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4401
        subMenu realize. 
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4402
    ] ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4403
        topMenu device mapWindow:(subMenu id).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4404
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4405
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4406
! !
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4407
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4408
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4409
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4410
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4411
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4412
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4413
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4414
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4415
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4416
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  4417
    (appl isValueModel) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4418
	^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4419
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4420
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4421
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4422
	Object messageNotUnderstoodSignal handle:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4423
	    ex parameter selector == aKey ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4424
		ex reject
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4425
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4426
	] do:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4427
	    (appl isKindOf:ApplicationModel) 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4428
		ifTrue:[value := appl aspectFor:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4429
		ifFalse:[value := appl perform:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4430
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4431
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4432
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4433
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4434
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4435
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4436
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4437
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4438
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4439
update:something with:aParameter from:changedObject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4440
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4441
    |form rect|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4442
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4443
    (menuPanel isNil or:[layout isNil]) ifTrue:[^ self].        "/ not yet realized or computed
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4444
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4445
    self isSeparator ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4446
        "/ NOT A SEPARATOR
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4447
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4448
        menuPanel shown ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4449
            changedObject == enableChannel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4450
                ^ self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4451
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4452
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4453
            (changedObject == indication or:[changedObject == choice]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4454
                isButton ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4455
                    self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4456
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4457
                    "/ invalidate the interactor only
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4458
                    "/ take any interactor; interactors has the same extent
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4459
                    form := menuPanel iconIndicationOff.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4460
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4461
                    rect := Rectangle left:(layout left + HorizontalInset)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4462
                                       top:(layout top)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4463
                                     width:(form width)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4464
                                    height:(layout height).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4465
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4466
                    menuPanel invalidate:rect repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4467
                ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4468
                ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4469
            ].
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  4470
        ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4471
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4472
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4473
    changedObject == isVisible ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4474
        menuPanel mustRearrange.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4475
        menuPanel rearrangeItems.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4476
      ^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4477
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4478
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4479
    super update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4480
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4481
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4482
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4483
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4484
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4485
    (indication notNil and:[indication isSymbol]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4486
        " indication is a selector otherwise a change notification
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4487
          is raised from the model !!!!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4488
        "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4489
        self update:nil with:nil from:indication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4490
    ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4491
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4492
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4493
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4494
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4495
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4496
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4497
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4498
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4499
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4500
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4501
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4502
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4503
    label isImage ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4504
        rcv := ResourceRetriever new.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4505
        rcv className:#MenuEditor.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4506
        rcv selector:#iconUnknown.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4507
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4508
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4509
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4510
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4511
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4512
    enableChannel notNil ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4513
        item enabled:(enableChannel value)
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4514
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4515
    item font:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4516
    item accessCharacterPosition:accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4517
    item startGroup:startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4518
    item argument:argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4519
    item nameKey:nameKey.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  4520
    item shortcutKeyCharacter:shortcutKey.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4521
    item value:(value value).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4522
    item indication:(indication value).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4523
    item choice:(choice value).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4524
    item choiceValue:choiceValue.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4525
    item isVisible:(self isVisible).
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4526
    item hideMenuOnActivated:(self hideMenuOnActivated).
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4527
    item showBusyCursorWhilePerforming:(self showBusyCursorWhilePerforming).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4528
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4529
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4530
    submenuChannel isSymbol ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4531
        item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4532
    ] ifFalse:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4533
        subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4534
            item submenu:(subMenu asMenu)
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4535
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4536
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4537
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4538
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4539
    "Modified: / 14.8.1998 / 15:47:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4540
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4541
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4542
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4543
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4544
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4545
    |lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4546
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4547
    menuPanel disabledRedrawDo:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4548
        label := rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4549
        accessCharacterPosition       := aMenuItem accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4550
        argument                      := aMenuItem argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4551
        choiceValue                   := aMenuItem choiceValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4552
        showBusyCursorWhilePerforming := aMenuItem showBusyCursorWhilePerforming.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4553
        hideMenuOnActivated           := aMenuItem hideMenuOnActivated.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4554
        isButton                      := aMenuItem isButton ? false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4555
        nameKey                       := aMenuItem nameKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4556
        startGroup                    := aMenuItem startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4557
        shortcutKey                   := aMenuItem shortcutKeyCharacter.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4558
        value                         := aMenuItem value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4559
        activeHelpKey                 := aMenuItem activeHelpKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4560
        activeHelpText                := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4561
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4562
        self font:(aMenuItem font).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4563
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4564
        self    enabled:(aMenuItem enabled).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4565
        self indication:(aMenuItem indication).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4566
        self     choice:(aMenuItem choice).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4567
        self  isVisible:(aMenuItem isVisible).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4568
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4569
        (lbl := aMenuItem labelImage value) isNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4570
            lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4571
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4572
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4573
        self label:lbl.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4574
        submenuChannel := aMenuItem submenuChannel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4575
        self submenu:(aMenuItem submenu).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4576
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  4577
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4578
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4579
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4580
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4581
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4582
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4583
drawButton
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4584
    "draw as button
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4585
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4586
    |drawObject fg level isSelected bg ownBgCol
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4587
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4588
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4589
    drawObject := rawLabel.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4590
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4591
    "COMPUTE COLORS"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4592
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4593
        bg := self activeBackgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4594
        fg := self activeForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4595
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4596
        self isEntered ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4597
            bg := self buttonEnteredBackgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4598
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4599
            bg := self backgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4600
        ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4601
        self enabled ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4602
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4603
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4604
            fg := menuPanel disabledForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4605
            drawObject := self disabledRawLabel
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4606
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4607
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4608
1708
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4609
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4610
        bg := ownBgCol
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4611
    ].
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4612
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4613
    "DRAW BACKGROUND"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4614
    bg ~= menuPanel backgroundColor ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4615
        menuPanel paint:bg.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4616
        menuPanel fillRectangle:layout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4617
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4618
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4619
    x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4620
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4621
    isSelected ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4622
        "check whether button should be drawn selected; indicator or radio button"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4623
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4624
        indication notNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4625
            "button is indicator and set"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4626
            isSelected := self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4627
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4628
            isSelected := (choice notNil and:[choice value = choiceValue]).
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4629
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4630
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4631
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4632
    isSelected ifTrue:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4633
        level := menuPanel buttonActiveLevel.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4634
        x     := x + level abs.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4635
    ] ifFalse:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4636
        level := self isEntered ifTrue:[menuPanel buttonEnteredLevel]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4637
                               ifFalse:[menuPanel buttonPassiveLevel].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4638
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4639
    self drawRawLabel:drawObject atX:x paint:fg.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4640
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4641
    level ~~ 0 ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4642
        menuPanel drawButtonEdgesFor:self level:level
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4643
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4644
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4645
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4646
drawLabel
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4647
    "draw a labeled entry; no button, no separator.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4648
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4649
    |scKey cLb cLa drawObject fg arrow 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4650
     isSelected form
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4651
     h "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4652
     y "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4653
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4654
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4655
    |
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4656
    drawObject := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4657
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4658
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4659
        fg := self activeForegroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4660
    ] ifFalse:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4661
        self enabled ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4662
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4663
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4664
            fg  := menuPanel disabledForegroundColor.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4665
            drawObject := self disabledRawLabel
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4666
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4667
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4668
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4669
    h := layout height.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4670
    x := layout left + HorizontalInset.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4671
    t := layout top.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4672
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4673
    ((form := self indicatorForm) notNil or:[(form := self choiceForm) notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4674
        y := t + ((h - form height) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4675
        form displayOn:menuPanel x:x y:y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4676
        x := x + 2 + form width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4677
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4678
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4679
    self drawRawLabel:drawObject atX:x paint:fg.
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4680
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4681
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4682
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4683
    (     shortcutKey notNil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4684
     and:[(x := menuPanel shortKeyInset) ~~ 0
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4685
     and:[(scKey:= self shortcutKeyAsString) notNil]]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4686
    ) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4687
        x := layout left + x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4688
        y := t + ((h - (scKey heightOn:menuPanel)) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4689
        y := y + menuPanel font ascent.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4690
        scKey displayOn:menuPanel x:x y:y. 
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4691
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  4692
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4693
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4694
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4695
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4696
        arrow := menuPanel rightArrow.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4697
        x := layout right - arrow width - HorizontalInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4698
        y := t + (h - arrow height // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4699
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4700
        (menuPanel styleSheet is3D not
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4701
        or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4702
            ^ menuPanel displayForm:arrow x:x y:y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4703
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4704
        cLa := menuPanel shadowColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4705
        cLb := menuPanel lightColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4706
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4707
        isSelected ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4708
            fg  := cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4709
            cLa := cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4710
            cLb := fg
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4711
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4712
        menuPanel paint:cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4713
        menuPanel displayForm:arrow x:x y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4714
        menuPanel paint:cLb.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4715
        menuPanel displayForm:drawObject x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4716
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  4717
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4718
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4719
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4720
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4721
drawRawLabel:aLabel atX:x paint:fg
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4722
    "draw a labeled entry; no button, no separator.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4723
    "
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4724
    |mfont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4725
     y  "{ Class:SmallInteger }"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4726
     y0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4727
     x0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4728
    |
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4729
    mfont := menuPanel setFont:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4730
    menuPanel paint:fg.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4731
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4732
    y := layout top + (layout height - rawLabelExtent y // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4733
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4734
    aLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4735
        aLabel isImageOrForm ifFalse:[
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4736
            y := y + menuPanel font ascent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4737
        ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4738
        aLabel displayOn:menuPanel x:x y:y.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4739
    ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4740
        aLabel do:[:el|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4741
            el notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4742
                el isImageOrForm ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4743
                    y0 := y + menuPanel font ascent
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4744
                ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4745
                    y0 := y
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4746
                ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4747
                x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4748
                el displayOn:menuPanel x:x0 y:y0.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4749
                y := y + 1 + (el heightOn:menuPanel)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4750
            ] ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4751
                y := y + 3   "/ see #label:
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4752
            ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4753
        ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4754
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4755
    menuPanel setFont:mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4756
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4757
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4758
drawSeparatingLines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4759
    "draw separating lines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4760
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4761
    |index item lfSep rtSep items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4762
     l "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4763
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4764
     r "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4765
     b "{ Class:SmallInteger }"
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4766
    |
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4767
    items := menuPanel items.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4768
    index := items identityIndexOf:self.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4769
    item  := items at:(index - 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4770
    lfSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4771
    item  := items at:(index + 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4772
    rtSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4773
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4774
    (lfSep isNil and:[rtSep]) isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4775
        ^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4776
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4777
    menuPanel paint:(menuPanel lightColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4778
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4779
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4780
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4781
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4782
    b := layout bottom.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4783
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4784
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4785
        lfSep ifTrue:[menuPanel displayLineFromX:l y:t-1 toX:r y:t-1].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4786
        rtSep ifTrue:[menuPanel displayLineFromX:l y:b-1 toX:r y:b-1].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4787
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4788
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4789
        lfSep ifTrue:[menuPanel displayLineFromX:l y:t-2 toX:r y:t-2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4790
        rtSep ifTrue:[menuPanel displayLineFromX:l y:b-2 toX:r y:b-2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4791
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4792
        lfSep ifTrue:[menuPanel displayLineFromX:l-1 y:t toX:l-1 y:b].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4793
        rtSep ifTrue:[menuPanel displayLineFromX:r-1 y:t toX:r-1 y:b].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4794
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4795
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4796
        lfSep ifTrue:[menuPanel displayLineFromX:l-2 y:t toX:l-2 y:b].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4797
        rtSep ifTrue:[menuPanel displayLineFromX:r-2 y:t toX:r-2 y:b]. 
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4798
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4799
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4800
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4801
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4802
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4803
drawSeparator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4804
    "draw as separator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4805
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4806
    |type lightColor isDouble
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4807
     x0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4808
     x1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4809
     y0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4810
     y1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4811
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4812
    type := self separatorType.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4813
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4814
    (type isNil or:[type == #blankLine]) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4815
        ^ self
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4816
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4817
    isDouble   := type == #doubleLine.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4818
    lightColor := menuPanel lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4819
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4820
    menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4821
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4822
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4823
        x0 := layout left  + HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4824
        x1 := layout right - HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4825
        y0 := layout top   - 1 + (layout height // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4826
        isDouble ifTrue:[y0 := y0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4827
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4828
                         menuPanel displayLineFromX:x0 y:y0   toX:x1 y:y0.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4829
        isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+4 toX:x1 y:y0+4].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4830
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4831
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4832
                         menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4833
        isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+5 toX:x1 y:y0+5].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4834
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4835
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4836
        y1 := layout bottom.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4837
        x0 := layout left - 1 + (layout width // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4838
        y0 := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4839
        isDouble ifTrue:[x0 := x0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4840
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4841
                         menuPanel displayLineFromX:x0   y:y0 toX:x0   y:y1.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4842
        isDouble ifTrue:[menuPanel displayLineFromX:x0+4 y:y0 toX:x0+4 y:y1].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4843
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4844
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4845
                         menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4846
        isDouble ifTrue:[menuPanel displayLineFromX:x0+5 y:y0 toX:x0+5 y:y1].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4847
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4848
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4849
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4850
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4851
invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4852
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4853
    (rawLabel notNil and:[menuPanel notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4854
        menuPanel invalidateItem:self repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4855
    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4856
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4857
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4858
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4859
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4860
redraw
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4861
    "redraw item
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4862
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4863
    |isSelected ownBgCol paint bgColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4864
     x  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4865
     y  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4866
     w  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4867
     h  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4868
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4869
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4870
    self isVisible ifFalse:[^ self].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4871
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4872
    rawLabel isNil  ifTrue:[^ self drawSeparator].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4873
    isButton        ifTrue:[^ self drawButton].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4874
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4875
    "/ DRAW A LABELED ENTRY; no button, no separator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4876
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4877
    isSelected := self isSelected.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4878
    bgColor    := menuPanel backgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4879
    paint      := isSelected ifTrue:[self activeBackgroundColor] ifFalse:[bgColor].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4880
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4881
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4882
        paint := ownBgCol
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4883
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4884
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4885
    paint ~= bgColor ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4886
        menuPanel paint:paint.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4887
        menuPanel fillRectangle:layout.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4888
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4889
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4890
    menuPanel showSeparatingLines ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4891
        self drawSeparatingLines
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4892
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4893
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4894
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4895
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4896
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4897
        ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4898
                                 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4899
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4900
        x := layout left.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4901
        y := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4902
        w := layout width.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4903
        h := layout height.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4904
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4905
        menuPanel displayRectangleX:(x + 1) y:(y + 1) width:(w - 2) height:(h - 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4906
        menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4).  
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4907
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4908
    menuPanel drawLabelEdgeFor:self selected:isSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4909
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4910
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4911
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4912
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4913
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4914
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4915
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4916
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4917
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4918
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4919
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4920
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4921
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4922
    enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4923
    isVisible     isValueModel  ifTrue:[isVisible    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4924
    indication    isValueModel ifTrue:[indication    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4925
    choice        isValueModel ifTrue:[choice        removeDependent:self].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4926
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4927
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4928
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4929
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4930
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4931
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4932
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4933
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4934
    isButton  := false.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4935
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4936
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4937
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4938
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4939
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4940
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4941
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4942
    |block form image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4943
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4944
    disabledRawLabel notNil ifTrue:[^ disabledRawLabel].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4945
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4946
    disabledRawLabel := rawLabel ? ''.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4947
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4948
    disabledRawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4949
        ^ disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4950
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4951
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4952
    block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4953
        (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4954
            el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4955
                el colorMap notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4956
                    rslt := menuPanel lightenedImageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4957
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4958
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4959
                el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4960
                    ((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4961
                        form := menuPanel lightenedImageOnDevice:form
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4962
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4963
                    ((image := el image) notNil and:[image colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4964
                        image := menuPanel lightenedImageOnDevice:image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4965
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4966
                    rslt := LabelAndIcon form:form image:image string:(el string).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4967
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4968
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4969
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4970
        rslt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4971
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4972
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4973
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4974
        disabledRawLabel := Array new:(rawLabel size).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4975
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4976
        rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4977
            disabledRawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4978
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4979
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4980
        disabledRawLabel := block value:rawLabel
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4981
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4982
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4983
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4984
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4985
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4986
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4987
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4988
    |icon block|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4989
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4990
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4991
        block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4992
            (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4993
                el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4994
                    rslt := menuPanel imageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4995
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4996
                    el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4997
                        (icon := el image) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4998
                            el image:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4999
                        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5000
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5001
                        (icon := el icon) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5002
                            el icon:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5003
                        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5004
                    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5005
                ]
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5006
            ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5007
            rslt
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5008
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5009
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5010
        rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5011
            rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5012
                rawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5013
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5014
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5015
            rawLabel := block value:rawLabel
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5016
        ]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5017
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5018
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5019
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5020
updateAccessCharacterFor:aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5021
    |s i rest label pos|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5022
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5023
    (accessCharacter notNil or:[aLabel isNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5024
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5025
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5026
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5027
    aLabel isString ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5028
        aLabel class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5029
            aLabel string:(self updateAccessCharacterFor:(aLabel string))
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5030
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5031
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5032
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5033
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5034
    s := aLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5035
    i := 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5036
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5037
    label := aLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5038
    pos := accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5039
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5040
    [((i := label indexOf:$& startingAt:i) ~~ 0 and:[i < s])] whileTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5041
        rest := label copyFrom:(i+1).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5042
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5043
        i == 1 ifTrue:[label := rest]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5044
              ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5045
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5046
        (label at:i) == $& ifTrue:[i := i + 1] ifFalse:[pos := i].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5047
        s := s - 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5048
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5049
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5050
    (pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5051
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5052
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5053
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5054
    label isText ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5055
        label := Text string:label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5056
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5057
    label emphasisAt:pos add:#underline.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5058
  ^ label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5059
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5060
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5061
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5062
!MenuPanel::Item methodsFor:'printing & storing'!
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5063
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5064
displayString
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5065
    ^ self class name, '[', label printString, ']'
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5066
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5067
! !
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5068
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5069
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5070
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5071
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5072
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5073
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5074
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5075
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5076
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5077
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5078
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5079
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5080
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5081
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5082
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5083
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5084
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5085
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5086
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5087
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5088
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5089
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5090
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5091
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5092
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5093
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5094
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5095
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5096
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5097
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5098
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5099
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5100
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5101
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5102
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5103
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5104
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5105
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5106
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5107
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5108
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5109
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5110
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5111
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5112
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5113
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5114
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5115
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5116
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5117
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5118
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5119
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5120
    "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
  5121
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5122
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5123
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5124
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5125
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5126
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5127
    "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
  5128
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5129
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5130
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5131
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5132
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5133
    choice isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5134
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5135
    ^ choice value = choiceValue ifTrue:[menuPanel iconRadioGroupOn]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5136
                                ifFalse:[menuPanel iconRadioGroupOff]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5137
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5138
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5139
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5140
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5141
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5142
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5143
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5144
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5145
    |subm sel|
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5146
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5147
    subm := nil.
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5148
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5149
    aRecv notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5150
        submenuChannel last ~~ $: ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5151
            Object messageNotUnderstoodSignal handle:[:ex|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5152
                |selector|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5153
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5154
                ((selector := ex parameter selector) == submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5155
                or:[selector == #aspectFor:]) ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5156
                    ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5157
                ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5158
            ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5159
                subm := aRecv aspectFor:submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5160
            ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5161
            subm isNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5162
                Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5163
                    ex parameter selector == submenuChannel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5164
                        ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5165
                    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5166
            ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5167
                    subm := aRecv perform:submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5168
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5169
            ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5170
            subm isNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5171
                Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5172
                    ex parameter selector == submenuChannel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5173
                        ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5174
                    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5175
                ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5176
                    subm := aRecv class perform:submenuChannel.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5177
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5178
                    "/ menu provided by class; thus it will not be changed
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5179
                    subm notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5180
                        submenuChannel := nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5181
                    ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5182
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5183
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5184
        ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5185
            argument notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5186
                sel := submenuChannel asSymbol.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5187
                Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5188
                    ex parameter selector == sel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5189
                        ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5190
                    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5191
                ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5192
                    subm := aRecv perform:sel with:argument
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5193
                ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5194
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5195
                subm isNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5196
                    Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5197
                        ex parameter selector == sel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5198
                            ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5199
                        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5200
                    ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5201
                        subm := aRecv class perform:sel with:argument.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5202
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5203
                        "/ menu provided by class; thus it will not be changed
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5204
                        subm notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5205
                            submenuChannel := nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5206
                        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5207
                    ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5208
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5209
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5210
        ]
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5211
    ].
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5212
    ^ subm
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5213
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5214
    "Modified: / 4.8.1998 / 17:40:09 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5215
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5216
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5217
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5218
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5219
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5220
    |numArgs sel recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5221
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5222
    indication isNil ifTrue:[^ nil].                                    "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5223
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5224
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5225
        ^ indication value == true                                      "block or model"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5226
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5227
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5228
    (numArgs := indication numArgs) == 2 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5229
        recv := menuPanel receiver.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5230
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5231
        (recv isValueModel) ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5232
            (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5233
                sel := indication copyFrom:1 to:(indication indexOf:$:).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5234
                sel := sel asSymbol.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5235
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5236
                Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5237
                    ex parameter selector == sel ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5238
                        ex reject
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5239
                    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5240
                ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5241
                    sel := recv perform:sel with:argument
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5242
                ]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5243
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5244
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5245
        ^ sel value == true
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5246
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5247
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5248
    numArgs ~~ 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5249
        sel := (indication copyWithoutLast:1) asSymbol
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5250
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5251
        sel := indication
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5252
    ].    
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5253
    sel := self aspectAt:sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5254
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5255
    sel isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5256
        indication := sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5257
        indication addDependent:self.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5258
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5259
    ^ sel value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5260
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5261
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5262
indicationValue:aValue
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5263
    "set the indication value
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5264
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5265
    |numArgs recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5266
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5267
    indication isNil ifTrue:[^ self].                                   "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5268
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5269
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5270
        indication perform:#value: with:aValue ifNotUnderstood:nil.     "block or model"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5271
      ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5272
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5273
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5274
    (numArgs := indication numArgs) == 0 ifTrue:[                       "no arguments to selector; cannot set"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5275
        ^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5276
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5277
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5278
    recv := menuPanel receiver.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5279
    recv isValueModel ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5280
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5281
    recv isNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5282
        recv := menuPanel application.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5283
        recv isNil ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5284
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5285
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5286
    Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5287
        (ex parameter selector ~~ indication) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5288
            ex reject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5289
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5290
    ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5291
        numArgs == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5292
            recv perform:indication with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5293
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5294
            recv perform:indication with:(argument ? self) with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5295
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5296
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5297
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5298
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5299
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5300
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5301
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5302
    indication isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5303
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5304
  ^ self indicationValue == true ifTrue:[menuPanel iconIndicationOn]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5305
                                ifFalse:[menuPanel iconIndicationOff]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5306
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5307
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5308
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5309
    "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
  5310
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5311
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5312
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5313
    "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
  5314
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5315
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5316
reinitSubmenuStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5317
    "returns my submenu or nil
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5318
    "
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5319
    subMenu notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5320
	subMenu reinitStyle
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5321
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5322
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5323
    "Created: / 10.9.1998 / 21:36:09 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5324
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5325
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5326
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5327
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5328
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5329
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5330
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5331
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5332
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5333
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5334
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5335
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5336
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5337
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5338
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5339
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5340
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5341
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5342
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5343
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5344
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5345
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5346
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5347
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5348
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5349
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5350
    submenuChannel notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5351
        submenuChannel isSymbol ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5352
            subm := submenuChannel
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5353
        ] ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5354
            appl := menuPanel application.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5355
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5356
            (subm := self findSubMenuIn:appl) isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5357
                (recv := menuPanel receiver) ~~ appl ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5358
                    subm := self findSubMenuIn:recv
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5359
                ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5360
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5361
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5362
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5363
        (subm := subm value) isArray ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5364
            subm := Menu new fromLiteralArrayEncoding:subm.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5365
            "/ cg: linked menus also may contain translations ...
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5366
            subm notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5367
                appl notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5368
                    subm findGuiResourcesIn:appl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5369
                ]                
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5370
            ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5371
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5372
        self submenu:subm.
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5373
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5374
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5375
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5376
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5377
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5378
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5379
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5380
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5381
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5382
canChangeVisibility
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5383
    "return true if I am not always visible; can only be changed by a selector
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5384
     otherwise there is a change notification raised if the model changed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5385
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5386
    ^ isVisible isSymbol
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5387
"/  ^ isVisible notNil and:[isVisible ~~ true]
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5388
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5389
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5390
canSelect
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5391
    "returns true if item is selectable; no separator, visible and enabled.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5392
     in case of a choice (RadioButton) i have to check for the choiceValue
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5393
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5394
    (rawLabel notNil and:[self isVisible and:[self enabled]]) ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5395
        (choice isNil or:[choice value ~= choiceValue]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5396
            ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5397
        ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5398
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5399
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5400
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5401
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5402
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5403
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5404
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5405
    (self isVisible and:[layout notNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5406
        ^ layout containsPointX:x y:y
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5407
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5408
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5409
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5410
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5411
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5412
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5413
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5414
    ^ indication notNil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5415
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5416
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5417
hasSubmenu
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5418
    "returns true if the item is configured as an subMenu entry
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5419
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5420
    ^ subMenu notNil or:[submenuChannel notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5421
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5422
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5423
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5424
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5425
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5426
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5427
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5428
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5429
isLabeledItem
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5430
    "returns true if the item is no button and no separator
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5431
    "
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5432
    ^ rawLabel notNil and:[isButton not]
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5433
!
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5434
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5435
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5436
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5437
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5438
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5439
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5440
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5441
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5442
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5443
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5444
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5445
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5446
    isVisible isSymbol ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5447
        state := self aspectAt:isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5448
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5449
        state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5450
            isVisible := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5451
            isVisible addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5452
            state := isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5453
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5454
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5455
        state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5456
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5457
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5458
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5459
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5460
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5461
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5462
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5463
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5464
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5465
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5466
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5467
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5468
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5469
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5470
        oldState := isVisible value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5471
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5472
            isVisible removeDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5473
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5474
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5475
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5476
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5477
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5478
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5479
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5480
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5481
            isVisible addDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5482
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5483
            isVisible isSymbol ifTrue:[^ self]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5484
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5485
        menuPanel shown ifFalse:[^ self].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5486
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5487
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5488
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5489
    newState ~~ oldState ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5490
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5491
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5492
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5493
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5494
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5495
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5496
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5497
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5498
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5499
    |nm prefix|
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5500
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5501
    shortcutKey isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5502
        ^ nil
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5503
    ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5504
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5505
    shortcutKey isCharacter ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5506
        nm := shortcutKey asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5507
    ] ifFalse:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5508
        "/ this is somewhat complicated: we have the symbolic key at hand,
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5509
        "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5510
        "/ Ask the devices keyboardMap for the backtranslation.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5511
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5512
        nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5513
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5514
        "/ some modifier-key combination ?
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5515
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5516
        (nm startsWith:#Cmd) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5517
            prefix := #Cmd.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5518
        ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5519
            prefix := #Alt.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5520
        ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5521
            prefix := #Meta.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5522
        ] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5523
            prefix := #Ctrl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5524
        ]]]].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5525
        prefix notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5526
            nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5527
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5528
            nm := nm asString
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5529
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5530
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5531
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5532
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5533
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5534
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5536
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5537
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5538
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5539
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5540
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5541
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5542
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5543
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5544
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5545
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5546
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5547
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5548
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5549
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5550
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5551
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5552
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5553
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5554
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5555
    ^ menuPanel selection == self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5556
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5557
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5558
selected:isSelected
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5559
    "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
  5560
     submenu and perform a redraw
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5561
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5562
    menuPanel isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5563
        ^ self hideSubmenu
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5564
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5565
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5566
    isSelected ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5567
        self invalidate.
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5568
        self hideSubmenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5569
    ] ifTrue:[
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5570
        menuPanel realized ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5571
            (indication isNil or:[isButton not]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5572
                self invalidate
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5573
            ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5574
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5575
            (subMenu := self setupSubmenu) notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5576
                self openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5577
            ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5578
        ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5579
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5580
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5581
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5582
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5583
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5584
version
1735
941d5de7372c fix some warnings durring compilation
ca
parents: 1734
diff changeset
  5585
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.216 2000-03-15 06:18:18 ca Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5586
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5587
MenuPanel initialize!