MenuPanel.st
author Claus Gittinger <cg@exept.de>
Wed, 26 Apr 2000 15:41:20 +0200
changeset 1766 e3667c5b8b30
parent 1765 a003f417d6ad
child 1767 e6325bfd4fad
permissions -rw-r--r--
may not assign potential nil to a smallInt-typed variable
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
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
    15
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
    16
SimpleView subclass:#MenuPanel
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    17
	instanceVariableNames:'adornment shadowView mapTime mustRearrange superMenu
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    18
		shortKeyInset selection items groupSizes receiver enableChannel
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    19
		menuHolder enabled onLevel offLevel fgColor activeFgColor
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    20
		lastActiveMenu activeBgColor disabledFgColor groupDividerSize
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
    21
		itemSpace fitFirstPanel rightArrow rightArrowShadow
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
    22
		selectionFrameBrightColor selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
    23
		buttonLightColor buttonShadowColor buttonHalfLightColor
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
    24
		buttonHalfShadowColor enteredItem buttonEnteredBgColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
    25
		prevFocusView previousPointerGrab previousKeyboardGrab
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    26
		relativeGrabOrigin hasImplicitGrap iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    27
		iconIndicationOn iconRadioGroupOff iconRadioGroupOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    28
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    29
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    30
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    31
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    32
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
    33
		DefaultEnteredLevel DefaultSelectionFollowsMouse
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		DefaultFitFirstPanel RightArrowForm RightArrowShadowForm
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    35
		SelectionFrameBrightColor SelectionFrameDarkColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    36
		ButtonActiveLevel ButtonPassiveLevel ButtonActiveBackgroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    37
		ButtonPassiveBackgroundColor ButtonLightColor ButtonShadowColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    38
		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle Images
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    39
		LigthenedImages ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    40
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    41
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    42
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    43
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    44
Object subclass:#Item
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    45
	instanceVariableNames:'layout menuPanel subMenu rawLabel rawLabelExtent disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    46
		enableChannel nameKey value label activeHelpKey activeHelpText
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    47
		submenuChannel startGroup isButton isVisible hideMenuOnActivated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    48
		indication accessCharacterPosition shortcutKey argument choice
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
    49
		choiceValue showBusyCursorWhilePerforming accessCharacter font'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    50
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
    51
		VerticalButtonInset LabelRightOffset VerticalPopUpInset'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    52
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    53
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    54
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    55
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    56
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    57
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
copyright
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
 COPYRIGHT (c) 1997 by eXept Software AG
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    61
	      All Rights Reserved
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    62
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    63
 This software is furnished under a license and may be used
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    64
 only in accordance with the terms of that license and with the
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    65
 inclusion of the above copyright notice.   This software may not
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    66
 be provided or otherwise made available to, or used by, any
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
 other person.  No title to or ownership of the software is
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
 hereby transferred.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    70
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    71
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    72
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    73
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    79
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    80
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    81
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    82
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    83
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    84
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    85
    [author:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    86
	Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    87
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
    [see also:]
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    89
	Menu
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    90
	MenuItem
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
    91
	MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    92
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    93
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    94
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    95
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    96
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    97
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    98
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
    start as PullDownMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   100
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   103
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   105
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   107
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   108
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   111
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   114
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   119
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   122
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   123
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   124
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   126
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   127
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   129
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   130
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   133
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   136
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   138
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   139
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   140
    top open.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   141
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   144
    start as PopUpMenu
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   145
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   146
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   148
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   149
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   151
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   152
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   153
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   155
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   156
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   157
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   158
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   159
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   160
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   161
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   162
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   163
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   164
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   165
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   166
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   167
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   168
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   169
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   170
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   171
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   172
    mview startUp
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   173
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   174
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   175
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   176
    start from menu spec
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   177
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   178
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   179
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   180
    menu := MenuPanel menu:
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   181
	#(#Menu #( #(#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   182
		    #label: 'File' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   183
		    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   184
		      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   185
				 (#MenuItem 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   186
				    #label: 'edit' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   187
				    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   188
				      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   189
						 #(#MenuItem #label: 'close' #value:#close)     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   190
					       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   191
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   192
					       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   193
				       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   194
				  )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   195
				 #(#MenuItem #label: 'help' #value:#help )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   196
			       )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   197
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   198
			       nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   199
		       )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   200
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   201
		#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   202
		#(#MenuItem #label: 'Bar' 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   203
			    #submenu:
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   204
			       #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   205
					  #(#MenuItem #label: 'bar 2' #value:#bar2 )     
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   206
					)
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   207
					nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   208
					nil
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
		 ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   211
	      ) 
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   212
	      #( 2 )
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   213
	      nil
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   214
	 ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   215
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   216
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   217
    Transcript showCR:(menu startUp).
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   218
										[exEnd]
388
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
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   223
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   224
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   225
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   226
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   227
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   228
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   229
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   230
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   231
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   232
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   233
    aSpec notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   234
	menu := Menu new.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   235
	menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   236
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   237
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   238
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   239
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   240
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   241
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   242
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   243
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   244
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   245
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   246
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   247
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   251
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   252
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   253
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   254
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   258
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   259
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   260
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   261
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   262
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   263
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
    mview := self new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   274
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
    aReceiver notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   276
	mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   279
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   285
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   286
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   287
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   288
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   289
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   290
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   291
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   292
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   293
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   294
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   295
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   296
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   297
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   298
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   299
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   300
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   301
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   302
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   303
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   304
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   305
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   306
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   307
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   308
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   309
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   310
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   311
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   312
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   313
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   314
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   315
!MenuPanel class methodsFor:'default icons'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   316
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   317
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   318
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   319
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   320
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   321
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   322
     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
   323
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   324
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   325
     self iconIndicationOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   326
     ImageEditor openOnClass:self andSelector:#iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   327
    "
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
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   330
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   331
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   332
        constantNamed:#'MenuPanel iconIndicationOff'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   333
        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
   334
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   335
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   336
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   337
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   338
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   339
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   340
     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
   341
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   342
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   343
     self iconIndicationOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   344
     ImageEditor openOnClass:self andSelector:#iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   345
    "
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
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   348
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   349
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   350
        constantNamed:#'MenuPanel iconIndicationOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   351
        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
   352
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   353
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   354
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   355
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   356
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   357
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   358
     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
   359
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   360
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   361
     self iconRadioGroupOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   362
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   363
    "
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
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   366
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   367
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   368
        constantNamed:#'MenuPanel iconRadioGroupOff'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   369
        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
   370
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   371
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   372
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   373
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   374
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   375
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   376
     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
   377
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   378
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   379
     self iconRadioGroupOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   380
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   381
    "
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
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   384
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   385
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   386
        constantNamed:#'MenuPanel iconRadioGroupOn'
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   387
        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
   388
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   389
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   390
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   391
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   392
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   393
    <resource: #style (#'menu.foregroundColor' #'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   394
                       #'menu.hilightForegroundColor' #'menu.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   395
                       #'menu.hilightBackgroundColor' #'menu.buttonEnteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   396
                       #'menu.hilightLevel' #'menu.groupDividerSize'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   397
                       #'menu.itemSpace' #'menu.buttonItemSpace'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   398
                       #'menu.fitFirstPanel' #'menu.buttonActiveLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   399
                       #'menu.buttonPassiveLevel' #'menu.buttonEnteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   400
                       #'menu.selectionFollowsMouse' #'menu.enteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   401
                       #'viewBackground'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   402
                       #'pullDownMenu.level' #'pullDownMenu.hilightLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   403
                       #'button.disabledForegroundColor' #'button.enteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   404
                       #'button.activeBackgroundColor' #'button.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   405
                       #'button.lightColor' #'button.shadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   406
                       #'button.halfLightColor' #'button.halfShadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   407
                       #'button.passiveLevel' #'button.activeLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   408
                       #'button.edgeStyle')>
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   409
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   410
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   411
    |style styleSheet|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   412
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   413
    styleSheet := StyleSheet.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   414
    style      := styleSheet name.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   415
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   416
    DefaultForegroundColor := styleSheet colorAt:#'menu.foregroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   417
                                         default:Color black.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   418
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   419
    DefaultBackgroundColor := styleSheet colorAt:#'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   420
                                         default:DefaultViewBackgroundColor.
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 := styleSheet colorAt:#'menu.hilightForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   423
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   424
    DefaultHilightForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   425
        styleSheet is3D ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   426
            DefaultHilightForegroundColor := DefaultForegroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   427
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   428
            DefaultHilightForegroundColor := DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   429
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   430
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   431
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   432
    DefaultDisabledForegroundColor := styleSheet colorAt:#'menu.disabledForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   433
    DefaultDisabledForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   434
        DefaultDisabledForegroundColor := styleSheet colorAt:#'button.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   435
                                                     default:Color darkGray.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   436
    ].
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 := styleSheet colorAt:#'menu.hilightBackgroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   439
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   440
    DefaultHilightBackgroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   441
        style == #motif ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   442
            DefaultHilightBackgroundColor := DefaultBackgroundColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   443
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   444
            DefaultHilightBackgroundColor := styleSheet is3D ifFalse:[DefaultForegroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   445
                                                              ifTrue:[DefaultBackgroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   446
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   447
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   448
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   449
    DefaultLevel := styleSheet at:#'pullDownMenu.level' default:0.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   450
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   451
    (style == #motif or:[style == #iris]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   452
        DefaultHilightLevel := 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   453
        DefaultLevel        := DefaultLevel + 1.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   454
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   455
        (DefaultHilightLevel    := styleSheet at:'pullDownMenu.hilightLevel') isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   456
            DefaultHilightLevel := styleSheet at:'menu.hilightLevel' default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   457
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   458
        styleSheet is3D ifTrue:[DefaultLevel := DefaultLevel + 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   459
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   460
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   461
    DefaultGroupDividerSize := styleSheet at:#'menu.groupDividerSize' default:6.
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
   462
    DefaultItemSpace        := styleSheet at:#'menu.itemSpace' default:2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   463
    DefaultButtonItemSpace  := styleSheet at:#'menu.buttonItemSpace' default:0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   464
    DefaultFitFirstPanel    := styleSheet at:#'menu.fitFirstPanel' default:true.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   465
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   466
    MenuView updateStyleCache.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   467
    DefaultFont    := MenuView defaultFont.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   468
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   469
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   470
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   471
        RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   472
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   473
        RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   474
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   475
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   476
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   477
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   478
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   479
    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
   480
    ButtonActiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   481
        ButtonActiveLevel        :=  styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   482
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   483
    ButtonPassiveLevel           :=  styleSheet at:#'menu.buttonPassiveLevel'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   484
    ButtonPassiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   485
        ButtonPassiveLevel       :=  styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   486
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   487
    ButtonActiveBackgroundColor  :=  styleSheet at:#'button.activeBackgroundColor' default: DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   488
    ButtonPassiveBackgroundColor := (styleSheet at:#'button.backgroundColor') ? (styleSheet at:'viewBackground') ? DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   489
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   490
    ButtonLightColor             := styleSheet at:#'button.lightColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   491
    ButtonLightColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   492
        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
   493
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   494
    ButtonShadowColor            :=  styleSheet at:#'button.shadowColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   495
    ButtonShadowColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   496
        ButtonShadowColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened. "/ Color white
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   497
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   498
    ButtonHalfLightColor         :=  styleSheet at:#'button.halfLightColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   499
    ButtonHalfShadowColor        :=  styleSheet at:#'button.halfShadowColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   500
    ButtonEdgeStyle              :=  styleSheet at:#'button.edgeStyle'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   501
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   502
    ButtonEnteredBackgroundColor := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   503
    ButtonEnteredBackgroundColor isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   504
        ButtonEnteredBackgroundColor := styleSheet colorAt:#'button.enteredBackgroundColor'
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   505
                                                  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   506
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   507
    ButtonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   508
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   509
    DefaultSelectionFollowsMouse := styleSheet at:#'menu.selectionFollowsMouse' default:false.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   510
    DefaultEnteredLevel          := styleSheet at:#'menu.enteredLevel'          default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   511
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   512
    ShortcutKeyOffset            := 5.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   513
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   514
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   515
1081
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
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   518
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   519
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   520
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   521
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   522
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   523
!MenuPanel class methodsFor:'image registration'!
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
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   526
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   527
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   528
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   529
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   530
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   531
    anImage device == aDevice ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   532
	^ anImage
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   533
    ].
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   534
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   535
    Images isNil ifTrue:[ Images := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   536
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   537
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   538
	Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   539
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   540
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   541
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   542
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   543
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   544
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   545
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   546
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   547
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   548
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   549
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   550
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   551
!
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
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   554
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   555
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   556
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   557
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   558
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   559
    LigthenedImages isNil ifTrue:[ LigthenedImages := IdentityDictionary new ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   560
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   561
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   562
	LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   563
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   564
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   565
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   566
	^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   567
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   568
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   569
    ((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   570
	image := anImage copy lightened onDevice:aDevice.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   571
	image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   572
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   573
	image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   574
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   575
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   576
    ^ image
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
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   579
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   580
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   581
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   582
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   583
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   584
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   585
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   586
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   587
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   588
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   589
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   590
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   591
!MenuPanel methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   592
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   593
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   594
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   595
    "
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   596
    ^ self acceptItem:(self selection) inMenu:self
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   597
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   598
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   599
accept:anItem
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   600
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   601
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   602
    |value item tgState itemIdx recv panel masterGroup winGrp|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
   603
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   604
    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
   605
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   606
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   607
    self selection:nil.
420
ca
parents: 417
diff changeset
   608
ca
parents: 417
diff changeset
   609
    (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
   610
        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
   611
        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
   612
        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
   613
        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
   614
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   615
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   616
    self doUngrab:true.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   617
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   618
    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
   619
        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
   620
        self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   621
    ] 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
   622
        self unmap.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   623
        (winGrp := self windowGroup) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   624
            "/ give expose event a chance to arrive
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   625
            [shown and:[realized]] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   626
                winGrp processExposeEventsFor:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   627
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   628
            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
   629
        ].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   630
        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
   631
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   632
    ].
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   633
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   634
    (item notNil 
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   635
    and:[item showBusyCursorWhilePerforming
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   636
    and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]])
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   637
    ifTrue:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   638
        winGrp withWaitCursorDo:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   639
            value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   640
        ]
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   641
    ] ifFalse:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   642
        value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   643
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   644
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   645
    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
   646
        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
   647
        self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   648
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   649
    ^ item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   650
1212
9bd3220c9964 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1211
diff changeset
   651
    "Modified: / 22.2.1999 / 20:14:48 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   652
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   653
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   654
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   655
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   656
    "
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   657
    |value argument numArgs isKindOfValueModel rec args arg2 
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   658
     app master fallBack|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   659
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   660
    anItem isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   661
        self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   662
      ^ nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   663
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   664
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   665
    self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   666
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   667
    (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
   668
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   669
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   670
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   671
    (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
   672
        argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   673
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   674
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   675
    value isSymbol ifFalse:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   676
        "/ a valueHolder or block
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   677
        (value respondsTo:#valueWithArguments:) ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   678
             ^ value
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
   679
        ].
1679
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 := 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
   682
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   683
        numArgs == 0 ifTrue:[
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   684
            args := nil
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   685
        ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   686
            numArgs == 1 ifTrue:[
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   687
                args := Array with:argument
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   688
            ] ifFalse:[
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   689
                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
   690
            ]
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   691
        ].
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   692
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   693
        value valueWithArguments:args.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   694
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   695
        self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   696
      ^ anIndex
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   697
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   698
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   699
    aReceiver isNil ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   700
        ^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   701
    ].
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   702
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   703
    isKindOfValueModel := aReceiver isValueModel.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   704
    isKindOfValueModel ifTrue:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   705
        aReceiver value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   706
    ] ifFalse:[
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   707
        rec := aReceiver.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   708
        arg2 := self.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   709
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   710
        "/ 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
   711
        "/ (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
   712
        "/  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
   713
        "/ 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
   714
        "/ sigh.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   715
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   716
        (aReceiver isView
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   717
        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
   718
        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
   719
        and:[app notNil]]]) ifTrue:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   720
            rec := app.
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   721
            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
   722
        ].
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   723
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   724
        (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
   725
            args := nil
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   726
        ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   727
            numArgs == 1 ifTrue:[
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
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   729
            ] ifFalse:[
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   730
                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
   731
            ]
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   732
        ].
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   733
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   734
        fallBack := 
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   735
            [
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   736
                "/ mhmh - the receiver did not respond to that message;
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   737
                "/ 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
   738
                "/ (recursive)
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   739
                master := rec perform:#masterApplication ifNotUnderstood:nil.
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   740
                master notNil ifTrue:[
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   741
                    rec := master.
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   742
                    rec perform:value withArguments:args ifNotUnderstood:fallBack
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   743
                ] ifFalse:[
1715
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   744
                    self 
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   745
                        error:'unimplemented menu message: ' , value
c987686f5d37 unimpl. menu message error mayProceed
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   746
                        mayProceed:true
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   747
                ].
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   748
            ].
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   749
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   750
        rec perform:value withArguments:args ifNotUnderstood:fallBack.
420
ca
parents: 417
diff changeset
   751
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   752
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   753
    ^ value
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   754
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   755
    "Modified: / 19.2.2000 / 11:08:22 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   756
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   757
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   758
acceptItem:anItem inMenu:aMenu
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   759
    |tgState|
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   760
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   761
    (anItem isNil or:[anItem hideMenuOnActivated or:[aMenu isPopUpView not]]) ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   762
        self topMenu accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   763
    ] ifFalse:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   764
        anItem canAccept ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   765
            tgState := anItem toggleIndication.
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   766
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   767
            self accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   768
                  index:(aMenu selectionIndex)
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   769
                 toggle:tgState 
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   770
               receiver:(aMenu receiver).
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   771
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   772
            aMenu do:[:el| el updateIndicators].
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   773
        ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   774
    ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   775
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   776
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   777
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   778
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   779
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   780
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   781
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   782
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   783
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   784
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   785
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   786
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   787
"/    |top|
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 := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   790
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   791
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   792
"/        ^ self topMenu menuAdornmentAt:#value.
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
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   795
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   796
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   797
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   798
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   799
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   800
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   801
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   802
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   803
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   804
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   805
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   806
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   807
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   808
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   809
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   810
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   811
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   812
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   813
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   814
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   815
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   816
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   817
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   818
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   819
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   820
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   821
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   822
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   823
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   824
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   825
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   826
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   827
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   828
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   829
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   830
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   831
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   832
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   833
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   834
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   835
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   836
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   837
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   838
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   839
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   840
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   841
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   842
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   843
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   844
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   845
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   846
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   847
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   848
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   849
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   850
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   851
    "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
   852
     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
   853
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   854
    ^ enteredItem
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
    "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
   857
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   858
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   859
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   860
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   861
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   862
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   863
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   864
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   865
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   866
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   867
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   868
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   869
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   870
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   871
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   872
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   873
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   874
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   875
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   876
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   877
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   878
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   879
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   880
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   881
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   882
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   883
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   884
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   885
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   886
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   887
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   888
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   889
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   890
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   891
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   892
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   893
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   894
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   895
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   896
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   897
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   898
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   899
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   900
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   901
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   902
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   903
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   904
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   905
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   906
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   907
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   908
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   909
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   910
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   911
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   912
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   913
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   914
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   915
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   916
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   917
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   918
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   919
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   920
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   921
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   922
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   923
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   924
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   925
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   926
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   927
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   928
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   929
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   930
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   931
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   932
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   933
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   934
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   935
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   936
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   937
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   938
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   939
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   940
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   941
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   942
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   943
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   944
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   945
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   946
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   947
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   948
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   949
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   950
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   951
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   952
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   953
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   954
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   955
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   956
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   957
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   958
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   959
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   960
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   961
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   962
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   963
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   964
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   965
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   966
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   967
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   968
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   969
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   970
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   971
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   972
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   973
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   974
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   975
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   976
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   977
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   978
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   979
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   980
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   981
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   982
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   983
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   984
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   985
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   986
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   987
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   988
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   989
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   990
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   991
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   992
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   993
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   994
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   995
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   996
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   997
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   998
!MenuPanel methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   999
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1000
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1001
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1002
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1003
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1004
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1005
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1006
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1007
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1008
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1009
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1010
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1011
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1012
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1013
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1014
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1015
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1016
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1017
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1018
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1019
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1020
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1021
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1022
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1023
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1024
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1025
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1026
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1027
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1028
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1029
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1030
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1031
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1032
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1033
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1034
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  1035
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1036
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1037
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1038
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1039
    enabled ~~ state ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1040
        enabled := state.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1041
        self invalidate.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1042
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1043
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1044
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1045
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1046
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1047
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1048
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1049
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1050
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1051
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1052
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1053
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1054
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1055
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1056
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1057
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1058
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1059
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1061
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1062
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1063
!MenuPanel methodsFor:'accessing-channels'!
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1064
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1065
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1066
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1067
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1068
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1069
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1070
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1071
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1072
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1073
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1074
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1075
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1076
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1077
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1078
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1079
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1080
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1081
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1082
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1083
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1084
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1085
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1086
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1087
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1088
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1089
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1090
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1091
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1092
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1093
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1094
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1095
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1096
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1097
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1098
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1099
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1100
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1101
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1102
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1103
!MenuPanel methodsFor:'accessing-color & font'!
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1104
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1105
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1106
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1107
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1108
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1109
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1110
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1111
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1112
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1113
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1114
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1115
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1116
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1117
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1118
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1119
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1120
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1121
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1122
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1123
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1124
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1125
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1126
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1127
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1128
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1129
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1130
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1131
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1132
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1133
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1134
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1135
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1136
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1137
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1138
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1139
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1140
    ^ButtonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1141
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1142
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1143
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1144
    "get the button edge style
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
    ^ButtonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1147
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1148
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1149
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1150
    "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
  1151
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1152
    ^ buttonEnteredBgColor
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
    "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
  1155
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1156
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1157
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1158
    "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
  1159
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1160
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1161
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1162
    "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
  1163
    "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
  1164
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1165
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1166
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1167
    "get the background drawing color used to half light button frame
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
    ^buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1170
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1171
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1172
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1173
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1174
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1175
    ^buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1176
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1177
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1178
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1179
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1180
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1181
    ^buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1182
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1183
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1184
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1185
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1186
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1187
    ^ButtonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1188
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1189
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1190
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1191
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1192
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1193
    ^buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1194
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1195
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1196
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1197
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1198
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1199
  ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1200
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1201
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1202
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1203
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1204
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1205
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1206
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1207
        super font:(aFont onDevice:device).
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1208
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1209
        superMenu notNil ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1210
            self extent:(self preferredExtent)
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1211
        ].
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1212
        self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1213
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1214
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1215
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1216
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1217
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1218
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1219
  ^ fgColor
390
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
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1223
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1224
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1225
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1226
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1227
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1228
    fgColor ~~ aColor ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1229
        fgColor := aColor onDevice:device.
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1230
        shown ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1231
            self invalidate "/ RepairNow:true
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1232
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1233
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1234
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1235
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1236
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1237
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1238
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1239
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1240
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1241
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1242
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1243
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1244
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1245
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1246
maxAbsoluteButtonLevel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1247
    "returns the maximum absolute button level; used to compute the preferred
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1248
     extent of a button
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|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1251
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1252
    level := (ButtonActiveLevel abs) max:(ButtonEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1253
  ^ level max:(ButtonPassiveLevel abs)
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1254
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1255
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1256
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1257
    "get the selection frame bright color
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
    ^selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1260
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1261
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1262
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1263
    "get the selection frame dark color
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
    ^selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1266
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1267
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1268
setFont:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1269
    "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
  1270
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1271
    |currentFont|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1272
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1273
    (aFont notNil and:[aFont ~= font]) ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1274
        currentFont := font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1275
        super font:aFont.
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
    ^ currentFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1278
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1279
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1280
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1281
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1282
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1283
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1284
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1285
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1286
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1287
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1288
!MenuPanel methodsFor:'accessing-dimensions'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1289
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1290
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1291
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1292
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1293
    (explicitExtent ~~ true) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1294
        ^ self preferredExtent y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1295
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1297
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1298
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1299
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
    "compute and returns my preferred extent
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1301
        !!!!!! changes have influence on method #rearrangeItems !!!!!!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1302
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1303
    |hasMenu shCtKey extent showAcc sck
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1304
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1305
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1306
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1307
     buttonInset "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1308
     labelInset  "{ Class:SmallInteger }"
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1309
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1310
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1311
    (size := items size) == 0 ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1312
        ^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1313
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1314
    buttonInset := 2 * (DefaultButtonItemSpace abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1315
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1316
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1317
        labelInset := 2 * (DefaultEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1318
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1319
        labelInset := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1320
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1321
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1322
    x := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1323
    y := 0.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1324
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1325
    self verticalLayout ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1326
        "/ HORIZONTAL LAYOUT
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1327
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1328
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1329
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1330
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1331
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1332
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1333
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1334
                
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1335
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1336
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1337
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1338
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1339
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1340
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1341
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1342
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1343
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1344
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1345
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1346
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1347
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1348
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1349
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1350
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1351
                x := eX + x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1352
                y := eY max:y.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1353
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1354
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1355
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1356
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1357
        shCtKey := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1358
        showAcc := MenuView showAcceleratorKeys == true.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1359
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1360
        x := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1361
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1362
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1363
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1364
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1365
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1366
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1367
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1368
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1369
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1370
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1371
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1372
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1373
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1374
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1375
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1376
                hasMenu ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1377
                    hasMenu := el hasSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1378
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1379
                (showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1380
                    shCtKey := shCtKey max:(sck widthOn:self)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1381
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1382
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1383
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1384
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1385
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1386
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1387
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1388
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1389
                y := eY + y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1390
                x := eX max:x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1391
            ].
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1392
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1393
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1394
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1395
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1396
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1397
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1398
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1399
                x := x + ShortcutKeyOffset 
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1400
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1401
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1402
"/ to have a small inset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1403
        y := y + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1404
"/        x := x + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1405
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1406
    x := x + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1407
    y := y + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1408
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1409
  ^ x @ y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1410
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1411
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1412
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1413
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1414
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1415
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1416
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1417
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1418
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1419
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1420
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1421
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1422
!MenuPanel methodsFor:'accessing-interactors'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1423
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1424
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1425
    iconIndicationOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1426
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1427
            iconIndicationOff := superMenu iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1428
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1429
            iconIndicationOff := self registerImageOnDevice:(self class iconIndicationOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1430
        ].
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
    ^ iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1433
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1434
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1435
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1436
    iconIndicationOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1437
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1438
            iconIndicationOn := superMenu iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1439
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1440
            iconIndicationOn := self registerImageOnDevice:(self class iconIndicationOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1441
        ].
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
    ^ iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1444
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1445
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1446
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1447
    iconRadioGroupOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1448
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1449
            iconRadioGroupOff := superMenu iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1450
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1451
            iconRadioGroupOff := self registerImageOnDevice:(self class iconRadioGroupOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1452
        ].
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
    ^ iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1455
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1456
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1457
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1458
    iconRadioGroupOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1459
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1460
            iconRadioGroupOn := superMenu iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1461
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1462
            iconRadioGroupOn := self registerImageOnDevice:(self class iconRadioGroupOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1463
        ].
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
    ^ iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1466
! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1467
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1468
!MenuPanel methodsFor:'accessing-items'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1469
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1470
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1471
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1472
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1473
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1475
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1476
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1477
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1478
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1479
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1480
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1481
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1482
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1483
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1484
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1485
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1486
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1487
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1488
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1489
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1491
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1492
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1493
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1494
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1495
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1496
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1497
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1498
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1499
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1500
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1501
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1502
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1503
    ^ 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
  1504
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1505
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1506
items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1507
    "returns list of items or nil
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1508
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1509
    ^ items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1510
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1511
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1512
!MenuPanel methodsFor:'accessing-look'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1513
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1514
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1515
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1516
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1517
    ^ButtonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1518
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1519
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1520
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1521
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1522
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1523
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1524
    ^ButtonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1525
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1526
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1527
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1528
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1529
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1530
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1531
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1532
     NOT SUPPORTED
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1533
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1534
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1535
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1536
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1537
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1538
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1539
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1540
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1541
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1542
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1543
    fitFirstPanel := aState.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1544
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1545
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1546
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1547
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1548
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1549
  ^ groupDividerSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1550
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1551
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1552
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1553
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1554
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1555
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1556
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1557
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1558
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1559
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1560
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1561
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1562
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1563
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1564
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1565
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1566
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1567
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1568
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1569
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1570
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1571
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1572
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1573
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1574
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1575
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1576
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1577
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1578
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1579
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1580
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1581
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1582
level:anInt
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1583
    super level:anInt.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1584
    mustRearrange := true
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1585
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1586
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1587
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1588
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1589
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1590
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1591
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1592
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1593
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1594
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1595
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1596
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1597
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1598
  ^ (self menuAdornmentAt:#showGroupDivider)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1599
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1600
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1601
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1602
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1603
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1604
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1605
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1606
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1607
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1609
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1610
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1611
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1612
  ^ (self menuAdornmentAt:#showSeparatingLines)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1613
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1615
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1616
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1617
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1618
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1619
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1620
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1621
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1622
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1623
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1624
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1625
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1626
    superMenu notNil ifTrue:[^ true].
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1627
  ^ (self menuAdornmentAt:#verticalLayout)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1629
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1630
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1631
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1632
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1633
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1634
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1635
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1636
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1637
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1638
!MenuPanel methodsFor:'accessing-submenu'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1639
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1640
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1641
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1642
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1643
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1644
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1645
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1646
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1647
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1649
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1650
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1651
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1652
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1653
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1654
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1655
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1656
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1657
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1658
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1659
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1660
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1661
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1662
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1663
1698
8d29156bab20 category rename
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1664
!MenuPanel methodsFor:'activation / deactivation'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1665
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1666
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1667
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1668
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1669
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1670
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1671
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1672
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1673
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1674
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1675
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1676
show
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1677
    "realize the view at its last position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1678
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1679
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1680
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1681
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1682
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1683
showAt:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1684
    "realize the view at aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1685
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1686
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1687
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1688
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1689
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1690
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1691
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1692
    "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
  1693
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1694
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1695
     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
  1696
     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
  1697
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1698
    "
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1699
    self rearrangeItemsIfItemVisibilityChanged.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1700
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1701
    aBoolean ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1702
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1703
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1704
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1705
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1706
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1707
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1708
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1709
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1710
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1711
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1712
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1713
    ].
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1714
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1715
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1716
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1717
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1718
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1719
showAtPointer
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1720
    "realize the view at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1721
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1722
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1723
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
    "make myself visible at the screen center.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1729
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1730
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1731
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1732
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1733
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1734
    ^ 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
  1735
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1736
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1737
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1738
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1739
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1740
    "realize the menu at the current pointer position
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1741
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1742
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1743
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1744
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1745
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1746
    "realize the menu at 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
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1749
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  1750
    "Created: / 21.5.1998 / 14:15:57 / cg"
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1751
!
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1752
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1753
startUpOrNil
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1754
    "realize the menu at the current pointer position
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1755
    "
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  1756
    ^ self showAtPointer
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1757
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1758
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1759
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1760
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1761
createAtIndex:anIndexOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1762
    "create an item and add this item to the index. In case of nil the item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1763
     is added to the end. If the index is not valid nil is returned otherwise
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1764
     the new created item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1765
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1766
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1767
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1768
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1769
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1770
    anIndexOrNil notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1771
	(anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1772
	    ^ nil
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1773
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1774
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1775
    items isNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1776
	items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  1777
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1778
	items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1779
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1780
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1781
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1783
	items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1784
    ] ifFalse:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1785
	items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1786
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1787
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1788
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1789
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1790
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1791
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1792
     if found, remove and return it
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
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1797
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1798
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1799
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1800
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1801
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1802
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1803
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1804
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1805
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1806
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1807
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1808
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1809
	self selection:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1810
	groupSizes := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1811
	self do:[:el| el destroy ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1812
	items := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1813
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1814
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1815
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1816
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1817
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1818
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1819
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1820
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1821
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
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
    super update:something with:aParameter from:changedObject
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
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1826
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1827
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1828
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1829
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1830
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1831
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1832
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1833
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1834
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1835
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1836
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1837
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1838
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1839
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1840
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1841
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1842
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1843
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1844
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1845
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1846
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1847
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1848
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1849
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1850
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1851
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1852
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1853
    self disabledRedrawDo:[
1666
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1854
        |menu newItems|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1855
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1856
        self removeAll.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1857
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1858
        (menu := aMenu) notNil ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1859
            (aMenu isCollection) ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1860
                menu := Menu new.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1861
                menu fromLiteralArrayEncoding:aMenu.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1862
            ] ifFalse:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1863
                menu receiver notNil ifTrue:[receiver := menu receiver]
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
            (newItems := menu menuItems) size > 0 ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1866
                items := newItems collect:[:ni | 
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1867
                                |i|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1868
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1869
                                i:= Item in:self.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1870
                                i menuItem:ni.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1871
                                i.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1872
                            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1873
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1874
            self groupSizes:(menu groupSizes).
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  1875
        ]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1876
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1877
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1878
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1879
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1880
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1881
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1882
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1883
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1884
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1885
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1886
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1887
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1888
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1889
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1890
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1891
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1892
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1893
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1894
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1895
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1896
drawButtonEdgesFor:anItem level:aLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1897
    |layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1898
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1899
    aLevel ~~ 0 ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1900
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1901
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1902
        styleSheet is3D ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1903
            self displayRectangle:layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1904
        ] ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1905
            self drawEdgesForX:(layout left)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1906
                             y:(layout top)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1907
                         width:(layout width)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1908
                        height:(layout height)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1909
                         level:aLevel 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1910
                        shadow:buttonShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1911
                         light:buttonLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1912
                    halfShadow:buttonHalfShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1913
                     halfLight:buttonHalfLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1914
                         style:ButtonEdgeStyle
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1915
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1916
    ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1917
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1918
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1919
drawLabelEdgeFor:anItem selected:isSelected
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1920
    |level layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1921
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1922
    isSelected ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1923
        level := onLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1924
    ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1925
        anItem == enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1926
            level := DefaultEnteredLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1927
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1928
            level := offLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1929
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1930
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1931
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1932
    level ~~ 0 ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1933
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1934
1691
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1935
        self drawEdgesForX:(layout left)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1936
                         y:(layout top)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1937
                     width:(layout width)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  1938
                    height:(layout height)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1939
                     level:level
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1940
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1941
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1942
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1943
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1944
invalidateItem:anItem repairNow:aBool
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1945
    "an item changed; invalidate the items layout
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1946
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1947
    (mustRearrange not and:[shown]) ifTrue:[
1728
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1948
        self invalidate:(anItem layout copy insetBy:-1) repairNow:aBool
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1949
    ].
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1950
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1951
    "Modified: / 29.2.2000 / 11:28:59 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1952
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  1953
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1954
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1955
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1957
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1958
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1959
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1960
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1961
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1962
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1963
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1964
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1965
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1966
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1967
rearrangeGroups
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1968
    "implements the groupIdentifier #right in a horizontal menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1969
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1970
    |layout point
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1971
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1972
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1973
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1974
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1975
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1976
        ^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1977
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1978
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1979
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1980
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1981
    (dltX := width - margin - layout right) <= 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1982
        ^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1983
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1984
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1985
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1986
    start == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1987
        ^ self  "/ no item detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1988
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1989
    point := dltX @ 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1990
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1991
    "/ move items layout to right
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1992
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1993
    items from:start do:[:anItem|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1994
        anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1995
            anItem layout moveBy:point.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1996
        ]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1997
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1998
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  1999
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2000
rearrangeItems
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2001
    "recompute the layout of each item
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2002
        !!!!!! changes have influence on method #preferredExtent !!!!!!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2003
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2004
    |isVertical extent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2005
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2006
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2007
     x0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2008
     y0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2009
     x1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2010
     y1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2011
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2012
     inset       "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2013
     labelInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2014
     buttonInset "{ Class:SmallInteger }"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2015
    |
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2016
    (mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2017
        mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2018
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2019
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2020
    isVertical  := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2021
    buttonInset := DefaultButtonItemSpace abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2022
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2023
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2024
        labelInset := DefaultEnteredLevel abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2025
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2026
        labelInset := 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2027
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2028
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2029
    (self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2030
        extent := self preferredExtent copy.
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2031
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2032
        self isPopUpView ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2033
            isVertical ifTrue:[extent y:1.0] ifFalse:[extent x:1.0]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2034
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2035
        self extent:extent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2036
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2037
        extent := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2038
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2039
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2040
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2041
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2042
    isVertical ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2043
        y0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2044
        y1 := extent y - margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2045
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2046
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2047
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2048
                el layout:(Rectangle left:x top:y0 right:x bottom:y1)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2049
            ] ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2050
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2051
                    inset := DefaultButtonItemSpace
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2052
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2053
                    inset := labelInset
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2054
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2055
                x0 := x  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2056
                x1 := x0 + el preferredExtent x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2057
                el layout:(Rectangle left:x0 top:(y0 + inset) right:x1 bottom:(y1 - inset)).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2058
                x := x1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2059
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2060
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2061
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2062
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2063
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2064
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2065
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2066
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2067
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2068
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2069
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2070
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2071
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2072
        x0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2073
        x1 := extent x - margin.  "/ -1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2074
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2075
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2076
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2077
                el layout:(Rectangle left:x0 top:y right:x1 bottom:y)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2078
            ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2079
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2080
                    inset := DefaultButtonItemSpace
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2081
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2082
                    inset := labelInset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2083
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2084
                y0 := y  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2085
                y1 := y0 + el preferredExtent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2086
                el layout:(Rectangle left:(x0 + inset) top:y0 right:(x1 - inset) bottom:y1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2087
                y := y1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2088
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2089
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2090
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2091
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2092
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2093
"/                        y := y + itemSpace
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
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2096
            ]
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2097
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2098
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2099
    self rearrangeGroups.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2100
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2101
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2102
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2103
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2104
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2105
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2106
rearrangeItemsIfItemVisibilityChanged
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2107
    "check for items which can change its visibility;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2108
     if at least one item exists, rearrange all items
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2109
    "
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2110
    items isNil ifTrue:[^ self].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2111
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2112
    items do:[:item |
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2113
        item canChangeVisibility ifTrue:[
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2114
            mustRearrange := true.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2115
            self rearrangeItems.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2116
            ^ self
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2117
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2118
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2119
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2120
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2121
redrawX:x y:y width:w height:h
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2122
    "redraw a rectangle
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2123
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2124
    |isVertical item layout prevClip
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2125
     x1             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2126
     x2             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2127
     y1             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2128
     y2             "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2129
     start          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2130
     stop           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2131
     size           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2132
     groupDivInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2133
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2134
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2135
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2136
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2137
    mustRearrange ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2138
        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
  2139
        self rearrangeItems.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2140
      ^ self invalidate
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2141
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2142
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2143
    self paint:(self backgroundColor).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2144
    self clearRectangleX:x y:y width:w height:h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2145
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2146
    (size := items size) == 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2147
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2148
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2149
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2150
    isVertical := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2151
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2152
    isVertical ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2153
        start := items findFirst:[:el| el layout bottom > y ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2154
        start == 0 ifTrue:[ ^ self ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2155
        y1 := y + h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2156
        stop := items findFirst:[:el| el layout top > y1 ] startingAt:(start + 1).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2157
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2158
        start := items findFirst:[:el| el layout right > x ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2159
        start == 0 ifTrue:[ ^ self ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2160
        x1  := x + w.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2161
        stop := items findFirst:[:el| el layout left > x1] startingAt:(start + 1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2162
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2163
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2164
    stop == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2165
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2166
    (groupSizes size ~~ 0 and:[self showGroupDivider]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2167
        groupDivInset := groupDividerSize // 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2168
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2169
        groupDivInset ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2170
            (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2171
                start := start - 1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2172
            ]
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2173
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2174
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2175
        groupDivInset := 0
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2176
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2177
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2178
    prevClip := clipRect.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2179
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2180
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2181
    start to:stop do:[:i|
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2182
        item := items at:i.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2183
        item redraw.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2184
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2185
        (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
  2186
            layout := item layout.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2187
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2188
            isVertical ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2189
                x1 := layout left.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2190
                x2 := layout right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2191
                y1 := layout bottom + groupDivInset.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2192
                y2 := y1.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2193
            ] ifFalse:[
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2194
                y1 := layout top.
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2195
                y2 := layout bottom.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2196
                x1 := layout right + groupDivInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2197
                x2 := x1.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2198
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2199
            self paint:shadowColor.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2200
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2201
            self paint:lightColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2202
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2203
            isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2204
                      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
  2205
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2206
            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
  2207
        ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2208
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2209
    self clippingRectangle:prevClip.
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2210
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2211
    "Modified: / 21.5.1999 / 20:14:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2212
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2214
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2215
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2216
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2217
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2218
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2219
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2220
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2221
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2222
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2223
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2224
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2225
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2226
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2227
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2228
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2229
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2230
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2231
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2232
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2233
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2234
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2235
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2236
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2237
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2238
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2239
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2240
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2241
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2242
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2243
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2244
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2245
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2246
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2247
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2248
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2249
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2250
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2251
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2252
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2253
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2254
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2255
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2256
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2257
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2258
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2259
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2260
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2261
    i ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2262
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2263
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2264
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2265
    something isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2266
	i := self findFirst:[:el|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2267
				v := el value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2268
				v isSymbol and:[v == something]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2269
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2270
	i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2271
	    ^ i
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2272
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2273
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2274
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2275
    (something respondsTo:#string) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2276
	v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2277
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2278
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2279
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2280
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2281
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2282
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2283
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2284
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2285
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2286
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2287
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2288
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2289
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2290
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2291
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2292
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2293
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2294
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2295
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2296
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2297
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2298
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2299
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2300
    |menue point sensor|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2301
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2302
    sensor := self sensor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2303
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2304
    (sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2305
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2306
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2307
    menue := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2308
    point := menue translateGrabPoint:(x@y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2309
    menue handleButtonMotion:state x:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2310
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2311
    (self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2312
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2313
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2314
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2315
    (selection notNil and:[selection currentSubmenu isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2316
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2317
        (self containsPointX:x y:y) ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2318
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2319
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2320
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2321
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  2322
    "Modified: / 2.3.2000 / 21:51:16 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2323
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2324
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2325
buttonPress:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2326
    "any button pressed; open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2327
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2328
    |srcPoint dstMenu dstPoint dstItem|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2329
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2330
    srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2331
    dstMenu  := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2332
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2333
    dstMenu isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2334
        ^ self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2335
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2336
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2337
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2338
    dstItem  := dstMenu itemAtX:(dstPoint x) y:(dstPoint y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2339
    dstMenu selection:dstItem.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2340
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2341
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2342
buttonRelease:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2343
    "button release action; accept selection and close all views
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2344
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2345
    |topMenu dstMenu item srcPoint dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2346
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2347
    topMenu := self topMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2348
    dstMenu := topMenu activeMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2349
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2350
    (    dstMenu selection notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2351
     or:[dstMenu isPopUpView not
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2352
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2353
         and:(dstMenu mapTime)) > 400]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2354
    ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2355
        srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2356
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2357
        (     (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2358
         and:[(item    := dstMenu selection) notNil]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2359
        ) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2360
            item currentSubmenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2361
                dstMenu selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2362
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2363
                (selection isNil and:[self isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2364
                    self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2365
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2366
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2367
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2368
            dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2369
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2370
            (dstMenu itemAtX:(dstPoint x) y:(dstPoint y)) == dstMenu selection ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2371
                item := nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2372
            ].
1704
2aecaa179ced support of hideMenuOnActivated in the correct way
ca
parents: 1703
diff changeset
  2373
            ^ topMenu acceptItem:item inMenu:dstMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2374
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2375
        (selection notNil and:[dstMenu == self]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2376
            selection currentSubmenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2377
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2378
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2379
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2380
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2381
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2382
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2383
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2384
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2385
keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2386
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2387
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2388
    |menu point|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2389
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2390
       (key == #Tab 
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2391
    or:[key == #FocusNext
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2392
    or:[key == #FocusPrevious]]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2393
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2394
      ^ super keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2395
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2396
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2397
    menu := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2398
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2399
    key == #Escape ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2400
        "/ must hide the active menu
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2401
        ((menu := menu superMenu) notNil and:[menu ~~ self]) ifTrue:[
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2402
            "/ hide active menu but keep the grab
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2403
            menu selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2404
        ] ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2405
            "/ hide active menu and ungrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2406
            self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2407
        ].
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2408
        ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2409
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2410
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2411
    [   menu shown ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2412
            point := menu translateGrabPoint:(x@y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2413
            menu handleKeyPress:key x:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2414
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2415
            selection isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2416
                self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2417
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2418
          ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2419
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2420
        (menu := menu superMenu) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2421
    ] whileTrue.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2422
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2423
    self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2424
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2425
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2426
pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2427
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2428
    self detectGrabMenu handlePointerLeave:state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2429
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2430
    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2431
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2432
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2433
    (selection notNil and:[selection currentSubmenu isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2434
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2435
        self sensor anyButtonPressed ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2436
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2437
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2438
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2439
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2440
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2441
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2442
processShortcutKeyEventInMenuBar:event
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2443
    "an event as forwarded from the keyboardProcessor -
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2444
     if there is a short-key for that character, process it
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2445
     and return true. Otherwise, return false.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2446
    "
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2447
    |key winGroup|
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2448
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2449
    key := event key.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2450
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2451
    (self processShortcutKeyInMenuBar:key) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2452
        (selection notNil and:[(winGroup := self windowGroup) notNil]) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2453
            winGroup focusView:self
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2454
        ].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  2455
        ^ true
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2456
    ].
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2457
    ^ false
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2458
!
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2459
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2460
sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2461
    "redraw #right groups
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 layout invRect w right|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2464
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2465
    (mustRearrange or:[self isPopUpView]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2466
        ^ super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2467
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2468
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2469
    index := self findFirst:[:anItem| anItem startGroup == #right ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2470
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2471
    index ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2472
        (shown not or:[index == 1]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2473
            self mustRearrange.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2474
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2475
            layout := (items at:(index -1)) layout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2476
            right  := 1 + layout right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2477
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2478
            (w := width - right) > margin ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2479
                invRect := Rectangle left:right top:0 width:w height:height.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2480
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2481
                items from:index do:[:anItem|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2482
                    anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2483
                        layout := anItem layout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2484
                        layout setLeft:right.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2485
                        right := layout right.
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
                self rearrangeGroups.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2489
                self invalidate:invRect
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2490
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2491
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2492
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2493
    super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2494
! !
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2495
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2496
!MenuPanel methodsFor:'event handling processing'!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2497
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2498
handleButtonMotion:state x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2499
    "open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2500
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2501
    |menu point sel|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2502
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2503
    self sensor anyButtonPressed ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2504
        "/ highlight enterItem if no selection exists
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2505
        selection isNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2506
            (self containsPointX:x y:y) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2507
                ((sel := self itemAtX:x y:y) isNil or:[sel canSelect not]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2508
                    ^ self pointerEntersItem:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2509
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2510
                (DefaultSelectionFollowsMouse and:[superMenu notNil]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2511
                    self selection:sel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2512
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2513
                    self pointerEntersItem:sel
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2514
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2515
                ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2516
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2517
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2518
        self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2519
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2520
        (DefaultSelectionFollowsMouse and:[(menu := self superMenuAtX:x y:y) notNil]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2521
            point := self translatePoint:(x@y) to:menu.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2522
            sel   := menu itemAtX:(point x) y:(point y).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2523
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2524
            (sel notNil and:[sel canSelect]) ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2525
                menu selection:sel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2526
            ]
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
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2530
    self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2531
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2532
    (menu := self superMenuAtX:x y:y) isNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2533
        self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2534
            self selection:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2535
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2536
        ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2537
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2538
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2539
    menu == self ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2540
        (sel := self itemAtX:x y:y) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2541
            self selection:sel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2542
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2543
    ] ifFalse:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  2544
        point := self translatePoint:(x@y) to:menu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2545
        sel   := menu itemAtX:(point x) y:(point y).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2546
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2547
        (sel isNil and:[menu isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2548
            sel := menu selection.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2549
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2550
        menu selection:sel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2551
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2552
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2553
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2554
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2555
handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2556
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2557
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2558
    |next submenu item
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2559
     n     "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2560
     idx   "{ Class:SmallInteger }"
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2561
     first "{ Class:SmallInteger }"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2562
     size  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2563
    |
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2564
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2565
    (selection isNil and:[superMenu notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2566
        ^ superMenu handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2567
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2568
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2569
    self verticalLayout ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2570
        aKey == #CursorLeft ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2571
            ^ self selection:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2572
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2573
        aKey ~~ #CursorRight ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2574
            next := aKey == #CursorDown
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2575
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2576
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2577
        aKey == #CursorUp ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2578
            ^ self selection:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2579
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2580
        aKey ~~ #CursorDown ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2581
            next := aKey == #CursorRight
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2582
        ].        
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2583
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2584
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2585
    next isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2586
        (item := self selection) notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2587
            (submenu := item currentSubmenu) notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2588
                idx := submenu findFirst:[:el| el canSelect ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2589
              ^ submenu selectionIndex:idx
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2590
            ].
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2591
            ^ self selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2592
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2593
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2594
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2595
    first := self findFirst:[:el| el canSelect ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2596
    first == 0 ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2597
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2598
    idx := self selectionIndex.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2599
    n   := 1 + (self sensor compressKeyPressEventsWithKey:aKey).
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2600
    size := items size.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2601
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2602
    n timesRepeat:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2603
        next ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2604
            [((idx := idx + 1) <= size and:[(items at:idx) canSelect not])
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2605
            ] whileTrue.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2606
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2607
            idx > size ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2608
                idx := first
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2609
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2610
        ] ifFalse:[    
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2611
            [((idx := idx - 1) > 0  and:[(items at:idx) canSelect not])
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2612
            ] whileTrue.
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  2613
            
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2614
            idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2615
        ]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2616
    ].
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2617
    self selectionIndex:idx.
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2618
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  2619
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2620
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2621
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2622
handleKeyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2623
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2624
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2625
    |item|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2626
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2627
    (key == #Return or:[key == Character space]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2628
        ^ self accept.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2629
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2630
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2631
    key isCharacter ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2632
        (     key == #CursorDown or:[key == #CursorUp
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2633
          or:[key == #CursorLeft or:[key == #CursorRight]]]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2634
        ) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2635
            self handleCursorKey:key
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
            self processShortcutKeyInMenuBar:key
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2638
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2639
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2640
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2641
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2642
    (item := self detectItemForKey:key) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2643
        self selection:item.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2644
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2645
        superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2646
            item := superMenu detectItemForKey:key.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2647
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2648
            (item notNil or:[superMenu superMenu notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2649
                superMenu selection:item
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
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2653
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2654
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2655
handlePointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2656
    self  pointerEntersItem:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2657
    super pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2658
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2659
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2660
pointerEntersItem:anItemOrNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2661
    "the pointer moves over an item or nil; restore the old item and
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2662
     redraw the new item highlighted.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2663
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2664
    |oldItem newItem|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2665
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2666
    (     anItemOrNil notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2667
     and:[anItemOrNil canSelect
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2668
     and:[selection isNil
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2669
     and:[self isPopUpView not]]]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2670
        anItemOrNil isButton ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2671
            (    buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2672
             or:[ButtonEnteredLevel   ~~ ButtonPassiveLevel]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2673
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2674
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2675
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2676
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2677
            DefaultEnteredLevel ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2678
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2679
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2680
        ]
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
    newItem ~~ enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2684
        oldItem     := enteredItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2685
        enteredItem := newItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2686
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2687
        oldItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2688
            self invalidateItem:oldItem repairNow:(enteredItem isNil).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2689
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2691
        enteredItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2692
            self invalidateItem:enteredItem repairNow:true.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2693
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2694
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2695
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2696
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2697
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2698
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2699
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2700
doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2701
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2702
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2703
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2704
        superMenu doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2705
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2706
        hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2707
            self grabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2708
            hasImplicitGrap := true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2709
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2710
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2711
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2712
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2713
doUngrab:forceDo
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2714
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2715
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2716
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2717
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2718
        forceDo ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2719
            superMenu doUngrab:true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2720
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2721
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2722
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2723
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2724
    hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2725
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2726
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2727
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2728
    forceDo ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2729
        (selection notNil or:[prevFocusView == self]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2730
            ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2731
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2732
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2733
    self ungrabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2734
    self selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2735
    hasImplicitGrap := nil.
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2736
    prevFocusView   := nil.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2737
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2738
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2739
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2740
grabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2741
    "grap the keyboard; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2742
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2743
    previousKeyboardGrab := device activeKeyboardGrab.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2744
  ^ super grabKeyboard
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2745
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2746
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2747
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2748
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2749
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2750
    "get exclusive access to pointer and keyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2751
    "
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2752
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2753
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2754
    realized ifTrue:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2755
        prevFocusView := self windowGroup focusView.
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  2756
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2757
        sensor := self sensor.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2758
        device activePointerGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2759
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2760
                sensor flushMotionEventsFor:nil.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2761
            ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2762
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2763
            (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2764
                Delay waitForSeconds:0.1.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2765
                (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2766
                    "give up"
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2767
                    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2768
                    self unmap
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2769
                ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2770
            ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2771
        ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2772
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2773
        device activeKeyboardGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2774
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2775
                device sync.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2776
                sensor flushKeyboardFor:nil
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2777
            ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2778
            self grabKeyboard.
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  2779
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2780
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2781
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2782
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  2783
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2784
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2785
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2786
grabPointerWithCursor:aCursorOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2787
    "grap the pointer; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2788
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2789
    previousPointerGrab := device activePointerGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2790
    hasImplicitGrap := true.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2791
  ^ super grabPointerWithCursor:aCursorOrNil
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2792
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2793
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2794
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2795
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2796
ungrabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2797
    "ungrap the keyboard; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2798
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2799
    super ungrabKeyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2800
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2801
    previousKeyboardGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2802
        device grabKeyboardInView:previousKeyboardGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2803
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2804
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
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2808
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  2809
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2810
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2811
    self ungrabPointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2812
    self ungrabKeyboard.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2813
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2814
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2815
ungrabPointer
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2816
    "ungrap the pointer; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2817
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2818
    super ungrabPointer.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2819
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2820
    previousPointerGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2821
        device grabPointerInView:previousPointerGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2822
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2823
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  2824
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2825
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2826
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2827
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2828
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2829
helpText
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2830
    "return the helpText for the currently selected item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2831
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2832
    ^ self helpTextForItem:selection
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2833
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2834
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2835
helpTextAt:srcPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  2836
    "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
  2837
     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
  2838
     "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2839
    |dstMenu dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2840
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2841
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2842
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2843
    dstMenu isNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2844
        ^ ''
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2845
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2846
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2847
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2848
  ^ dstMenu helpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)).
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2849
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2850
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2851
helpTextForItem:anItem
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2852
    "returns the helpText for an item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2853
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2854
    |key val app|
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2855
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2856
    anItem isNil ifTrue:[^ ''].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2857
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2858
    (val := anItem activeHelpText) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2859
        (     (key := anItem activeHelpKey) notNil
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2860
         and:[(app := self application) notNil]
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2861
        ) ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2862
            val := app helpTextForKey:key.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2863
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2864
        anItem activeHelpText:(val ? '').
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2865
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2866
    ^ val
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  2867
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2868
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  2869
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2870
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2871
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2872
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2873
    "returns image registered on 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
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2876
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2877
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2878
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2879
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2880
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2881
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2882
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  2883
1688
271829d6a2e4 category changes
Claus Gittinger <cg@exept.de>
parents: 1679
diff changeset
  2884
!MenuPanel methodsFor:'initialization & release'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2885
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2886
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2887
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2888
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2889
    ^self
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2890
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  2891
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2892
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2893
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2894
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2895
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2896
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2897
    self isPopUpView ifTrue:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2898
        (PopUpView shadowsOnDevice:device) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2899
            shadowView isNil ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2900
                shadowView := (ShadowView onDevice:device) for:self
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2901
            ] ifFalse:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2902
                self saveUnder:true.
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2903
            ].
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2904
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2905
    ] ifFalse:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2906
        explicitExtent == true ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2907
            (self width) == (superView width) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2908
                self verticalLayout:false
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2909
            ]
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2910
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2911
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2912
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  2913
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2914
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2915
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2916
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2917
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2918
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2919
    self clearLastActiveMenu.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2920
    self do:[:el|el destroy].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2921
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2922
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2923
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2924
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2925
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2926
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2927
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2928
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2929
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  2930
    "Modified: / 27.2.1998 / 17:41:25 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2931
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2932
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2933
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2934
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2935
1735
941d5de7372c fix some warnings durring compilation
ca
parents: 1734
diff changeset
  2936
    |bw lvl|
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2937
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2938
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2939
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2940
    "/ 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
  2941
    "/ (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
  2942
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2943
    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
  2944
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2945
    self isPopUpView ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2946
        bw  := styleSheet at:#'popup.borderWidth' default:1.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2947
        lvl := styleSheet at:#'popup.level'       default:0.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2948
    ] ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2949
        bw  := styleSheet is3D ifFalse:[1] ifTrue:[0].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2950
        lvl := 1.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2951
    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2952
    self borderWidth:bw.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2953
    self level:lvl.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2954
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2955
    superMenu isNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2956
        fgColor                   := DefaultForegroundColor         onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2957
        activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2958
        activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2959
        disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2960
        rightArrow                := RightArrowForm                 onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2961
        selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2962
        selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2963
        buttonLightColor          := ButtonLightColor               onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2964
        buttonShadowColor         := ButtonShadowColor              onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2965
        ButtonHalfLightColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2966
            buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2967
        ButtonHalfShadowColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2968
            buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2969
        buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2970
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2971
        (rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2972
            rightArrowShadow := rightArrowShadow onDevice:device
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2973
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2974
    ] ifFalse:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2975
        fgColor                   := superMenu foregroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2976
        activeBgColor             := superMenu activeBackgroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2977
        activeFgColor             := superMenu activeForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2978
        disabledFgColor           := superMenu disabledForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2979
        rightArrow                := superMenu rightArrow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2980
        rightArrowShadow          := superMenu rightArrowShadow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2981
        selectionFrameBrightColor := superMenu selectionFrameBrightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2982
        selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2983
        buttonLightColor          := superMenu buttonLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2984
        buttonShadowColor         := superMenu buttonShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2985
        buttonHalfLightColor      := superMenu buttonHalfLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2986
        buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  2987
        buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2988
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2989
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2990
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2991
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2992
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2993
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2994
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2995
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  2996
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  2997
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  2998
    viewBackground := DefaultBackgroundColor.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2999
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3000
    onLevel          := DefaultHilightLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3001
    offLevel         := 0. "/ DefaultLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3002
    itemSpace        := DefaultItemSpace.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3003
    groupDividerSize := DefaultGroupDividerSize.
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3004
    fitFirstPanel    := false.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3005
    font             := MenuView defaultFont.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3006
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3007
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3008
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3009
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3010
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3011
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3012
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3013
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3014
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3015
    self enableMotionEvents.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3016
    enabled := true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3017
    originChanged  := extentChanged := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3018
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3019
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3020
    mustRearrange  := false.
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  3021
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3022
    "Modified: / 2.3.2000 / 21:50:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3023
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3024
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3025
map
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3026
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3027
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3028
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3029
    |anItemList|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3030
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3031
    enteredItem := nil.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3032
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3033
    self enableMotionEvents.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3034
    self becomesActiveMenu.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3035
    super map.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3036
1257
79a40d3f8c2f Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1255
diff changeset
  3037
    anItemList := InitialSelectionQuerySignal query.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3038
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3039
    self do:[:anItem| anItem fetchImages ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3040
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3041
    self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3042
        self doGrab
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3043
    ] ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3044
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3045
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3046
    self do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3047
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3048
    anItemList size > 0 ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3049
        self redrawX:0 y:0 width:width height:height.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3050
        self openMenusFromItems:anItemList.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3051
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3052
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  3053
    "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
  3054
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3055
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3056
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3057
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3058
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3059
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3060
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3061
    self isPopUpView ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3062
        "Because of #saveUnder of ShadowView the order of realize is significant:
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3063
         shadowView must be realized before self"
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3064
        self hiddenOnRealize:true.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3065
        super realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3066
        self resize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3067
        self makeFullyVisible.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3068
        shadowView notNil ifTrue:[
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3069
            shadowView realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3070
        ].
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3071
        self raise.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3072
        self map.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3073
    ] ifFalse:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3074
        super realize.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3075
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3077
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3078
recreate
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3079
    "this is called after a snapin. If the image was saved with an active menu,
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3080
     hide the menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3081
    "
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  3082
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3083
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3084
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3085
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3086
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3087
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3088
    "handle style change while being open (win32 only - for now)"
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
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3091
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3092
    self fetchDeviceResources.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3093
    items notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3094
	items do:[:anItem |
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3095
	    anItem reinitSubmenuStyle
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  3096
	]
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3097
    ]
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3098
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3099
    "Created: / 10.9.1998 / 21:37:05 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3100
    "Modified: / 11.9.1998 / 13:20:57 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3101
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3102
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3103
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  3104
    "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
  3105
     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
  3106
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3107
    self clearLastActiveMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3108
    self doUngrab:(superMenu isNil).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3109
"/    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3110
"/         self doUngrab:(superMenu isNil)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3111
"/    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3112
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3113
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3114
    shadowView notNil ifTrue:[shadowView unmap].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3115
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3116
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3117
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3118
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3119
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3120
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3121
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3122
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3123
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3124
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3125
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3126
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3127
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3128
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3129
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3130
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3131
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3132
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3133
superMenu:aSuperMenu
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3134
    "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
  3135
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3136
    (superMenu := aSuperMenu) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3137
        super font:(superMenu font)
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3138
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3139
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3140
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3141
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3142
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3143
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3144
    ^ superMenu isNil ifTrue:[self]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3145
                     ifFalse:[superMenu topMenu]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3146
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3147
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3148
!MenuPanel methodsFor:'printing'!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3149
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3150
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3151
    "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
  3152
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3153
    |string label|
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
    string := 'Menu:'.
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
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3158
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3159
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3160
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3161
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3162
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3163
    "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
  3164
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3165
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3166
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3167
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3168
application
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3169
    "optimize access to retrive the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3170
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3171
    |appl akey|
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3172
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3173
    superMenu notNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3174
        ^ superMenu application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3175
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3176
    akey := #appl.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3177
    appl := self menuAdornmentAt:akey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3178
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3179
    appl isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3180
        (appl := super application) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3181
            windowGroup isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3182
                ^ nil   "/ RETRY LATER
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3183
            ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3184
            appl := (windowGroup mainGroup topViews first application) ? akey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3185
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3186
        self menuAdornmentAt:akey put:appl
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3187
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3188
    ^ appl ~~ akey ifTrue:[appl] ifFalse:[nil]
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3189
!
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3190
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3191
detectItemForKey:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3192
    "returns the item assigned to a key, accessCharacter or starts with.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3193
     if no item is detected nil is returned.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3194
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3195
    |cIdx uKey lKey item|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3196
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3197
    items isNil ifTrue:[^ nil].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3198
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3199
    cIdx := self selectionIndex.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3200
    uKey := aKey asUppercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3201
    lKey := aKey asLowercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3202
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3203
    items keysAndValuesDo:[:anIndex :anItem| |char label|
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3204
        (     anIndex ~~ cIdx
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3205
         and:[anItem canSelect
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3206
         and:[(label := anItem textLabel) notNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3207
         and:[label size ~~ 0]]]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3208
        ) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3209
            (char := anItem accessCharacter) notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3210
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3211
                    ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3212
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3213
            ] ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3214
                char := label at:1.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3215
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3216
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3217
                    anIndex > cIdx ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3218
                        ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3219
                    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3220
                    item isNil ifTrue:[item := anItem]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3221
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3222
            ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3223
        ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3224
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3225
    ^ item
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3226
!
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3227
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3228
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3229
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3230
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3231
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3232
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3233
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3234
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3235
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3236
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3237
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3238
    "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
  3239
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3240
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3241
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3242
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3243
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3244
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3245
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3246
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3247
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3248
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3249
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3250
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3251
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3252
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3253
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3254
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3255
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3256
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3257
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3258
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3259
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3260
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3261
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3262
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3263
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3264
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3265
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3266
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3267
openMenusFromItems:anItemList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3268
    "open all menus derived from sequence of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3269
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3270
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3271
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3272
    anItemList size == 0 ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3273
        ^ self
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3274
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3275
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3276
    item := anItemList removeFirst.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3277
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3278
    item enabled ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3279
        ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3280
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3281
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3282
    InitialSelectionQuerySignal answer:anItemList do:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3283
        self selection:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3284
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3285
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3286
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3287
processShortcutKeyInMenuBar:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3288
    "if there is a short-key for that character, process it
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3289
     and return true. Otherwise, return false.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3290
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3291
    |rawKey loItems item maxDepth menu|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3292
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3293
    superMenu notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3294
        "/ must start from topMenu
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3295
        ^ self topMenu processShortcutKeyInMenuBar:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3296
    ].
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3297
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3298
    "/ check whether the key can be a shortCutKey
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3299
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3300
    aKey isCharacter ifTrue:[^ false].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3301
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3302
    ( #(
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3303
        #Meta_L      #Meta_R
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3304
        #Control_R   #Control_L
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3305
        #Shift_R     #Shift_L
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3306
        #CursorUp    #CursorDown
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3307
        #CursorLeft  #CursorRight
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3308
        #Return      #Tab
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3309
        #FocusNext   #FocusPrevious
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3310
        #Escape
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3311
       ) includesIdentical:aKey
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3312
    ) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3313
        ^ false
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3314
    ].
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3315
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3316
    "/ 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
  3317
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3318
    maxDepth := 10.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3319
    rawKey   := device keyboardMap keyAtValue:aKey ifAbsent:aKey.
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3320
    loItems  := self selectItemsForShortcutKey:aKey rawKey:rawKey maxDepth:maxDepth.
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3321
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3322
    loItems size == 0 ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3323
        ^ false
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3324
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3325
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3326
    item := loItems last.
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3327
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3328
    item hasSubmenu ifFalse:[
1574
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3329
        self accept:item.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3330
      ^ true
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 := self.
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 selection == (loItems at:1)] whileTrue:[
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3335
        loItems removeFirst.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3336
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3337
        loItems isEmpty ifTrue:[
1610
8684ca8df70c checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1609
diff changeset
  3338
          ^ false
1574
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3339
        ].
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3340
        menu := selection submenu.
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3341
    ].
4b9c4eb08dcb check whether menu already is open
ca
parents: 1573
diff changeset
  3342
    menu openMenusFromItems:loItems.
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3343
    ^ true.
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3344
!
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3345
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3346
registerImageOnDevice:anImage
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3347
    |image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3348
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3349
    (image := anImage) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3350
        image device ~~ device ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3351
            image := image copy.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3352
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3353
        image := image on:device.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3354
        image := image clearMaskedPixels.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3355
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3356
    ^ image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3357
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3358
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3359
selectItemsForShortcutKey:aKey rawKey:aRawKey maxDepth:maxDepth
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3360
    "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
  3361
     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
  3362
     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
  3363
    "
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3364
    |seq menu key|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3365
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3366
    maxDepth <= 0 ifTrue:[^ nil].
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3367
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3368
    self do:[:anItem|
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3369
        anItem isEnabled ifTrue:[
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3370
            (    (key := anItem shortcutKey) notNil
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3371
             and:[(key == aKey or:[key == aRawKey])]
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3372
            ) ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3373
                seq := OrderedCollection new
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3374
            ] ifFalse:[
1734
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3375
                (menu := anItem submenu) notNil ifTrue:[
26397f903766 enable handling shortcutKeys in linked menues; optimize algorithm
ca
parents: 1731
diff changeset
  3376
                    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
  3377
                ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3378
            ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3379
            seq notNil ifTrue:[
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3380
                seq addFirst:anItem.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3381
              ^ seq
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3382
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  3383
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3384
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3385
  ^ nil
1181
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3386
97ee0869b374 care for endless recursion with linked menus
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3387
    "Created: / 19.1.1999 / 16:00:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3388
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3389
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3390
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3391
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3392
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3393
    "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
  3394
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3395
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3396
798
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:15 / 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
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3401
    "set the current 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
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3404
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3405
    "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
  3406
!
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
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3409
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3410
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3411
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3412
    self topMenu activeMenu:self.
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
    "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
  3415
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3416
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3417
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3418
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3419
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3420
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3421
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3422
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3423
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3424
    prevFocusView notNil ifTrue:[
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3425
        self windowGroup focusView:prevFocusView.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3426
        prevFocusView := nil.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3427
    ].
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3428
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3429
    top activeMenu == self ifTrue:[
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3430
        top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3431
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3432
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3433
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3434
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3435
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3436
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3437
    "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
  3438
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3439
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3440
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3441
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3442
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3443
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3444
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3445
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3446
detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3447
    "returns the menu which is responsible for the grap; the last opened menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3448
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3449
    |subMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3450
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3451
    selection notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3452
        (subMenu := selection currentSubmenu) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3453
            ^ subMenu detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3454
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3455
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3456
    ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3457
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3458
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3459
detectMenuAtGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3460
    "returns the menu which contains the grab-point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3461
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3462
    |dstMenu dstPoint firstMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3463
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3464
    dstPoint := self translateGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3465
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3466
    ((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
  3467
        firstMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3468
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3469
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3470
    (selection isNil or:[(dstMenu := selection currentSubmenu) isNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3471
        ^ firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3472
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3473
    dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3474
  ^ dstMenu ? firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3475
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3476
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3477
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3478
itemAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3479
    "returns the item at a point x@y or nil if none detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3480
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3481
    items notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3482
        ^ items detect:[:el| el containsPointX:x y:y] ifNone:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3483
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3484
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3485
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3486
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3487
superMenuAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3488
    "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
  3489
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3490
    |grabPoint superMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3491
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3492
    (self containsPointX:x y:y) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3493
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3494
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3495
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3496
    grabPoint := (x@y) - (self translateGrabPoint:0@0).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3497
    superMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3498
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3499
    [ (superMenu := superMenu superMenu) notNil ] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3500
        (superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3501
            ^ superMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3502
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3503
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3504
  ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3505
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
translateGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3509
    "translate the grab point into self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3510
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3511
    superMenu isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3512
        "I am the grapView"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3513
        ^ aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3514
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3515
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3516
    relativeGrabOrigin isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3517
        relativeGrabOrigin := device translatePoint:0@0 from:(self topMenu id) to:(self id).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3518
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3519
    ^ relativeGrabOrigin + aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3520
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3521
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3522
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3523
translatePoint:aPoint to:aMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3524
    "translate a point into another menu its point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3525
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3526
    |grapPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3527
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3528
    aMenu == self ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3529
        ^ aPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3530
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3531
    grapPoint := aPoint - (self translateGrabPoint:0@0).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3532
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3533
  ^ aMenu translateGrabPoint:grapPoint
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3534
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3536
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3537
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3538
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3539
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3540
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3541
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3542
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3543
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3544
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3545
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3546
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  3547
    ^ (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
  3548
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3549
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3550
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3551
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3552
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3553
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3554
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3555
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3556
    groupSizes size ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3557
        i := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3558
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3559
        groupSizes do:[:t|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3560
            (i := i + t) == anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3561
                ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3562
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3563
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3564
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3565
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3566
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3567
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3568
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3569
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3570
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3571
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3572
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3573
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3574
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3575
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3576
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3577
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3578
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3579
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3580
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3581
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3582
    "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
  3583
     be fit to the extent of its superView;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3584
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3585
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3586
    ^ false
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3587
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3588
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3589
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3590
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3591
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3592
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3593
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3594
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3595
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3596
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3597
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3598
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3599
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3600
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3601
    ^ self verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3602
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3603
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3604
!
c05874084d4c implement
ca
parents: 407
diff changeset
  3605
c05874084d4c implement
ca
parents: 407
diff changeset
  3606
type
428
ca
parents: 427
diff changeset
  3607
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  3608
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3609
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3610
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3611
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3612
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3613
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3614
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3615
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3616
    ^ self selection notNil
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
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3620
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3621
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3622
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3623
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3624
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3625
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3626
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3627
selection:anItemOrNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3628
    "change selection to an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
    "
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3630
    |item newSel hlp|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3631
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3632
    (newSel := anItemOrNil) isNumber ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3633
        newSel := self itemAt:anItemOrNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3634
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3635
    (newSel notNil and:[newSel canSelect]) ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3636
        newSel := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3637
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3638
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3639
    selection == newSel ifTrue:[^ self].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3640
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3641
    (item := selection) notNil ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3642
        selection := nil.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3643
        item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3644
    ].
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3645
    newSel notNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3646
        newSel == enteredItem ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3647
            enteredItem := nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3648
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3649
            self pointerEntersItem:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3650
        ].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3651
        selection := newSel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3652
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3653
        ActiveHelp isActive ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3654
            hlp := ActiveHelp currentHelpListener.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3655
            hlp initiateHelpFor:self atX:nil y:nil now:true.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3656
        ].
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3657
        realized ifTrue:[self rearrangeItems].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3658
        selection selected:true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3659
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3660
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3661
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3662
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3663
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3664
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3665
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3666
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3667
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3668
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3669
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3670
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3672
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3673
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3674
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3675
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3676
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3677
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3678
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3679
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3680
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3681
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3682
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3683
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3684
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3685
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3686
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3687
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3688
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3689
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3690
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  3691
    ^ VerticalInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3692
!
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3693
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3694
verticalPopUpInset
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3695
    ^ VerticalPopUpInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3696
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3697
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3698
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3699
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3700
separatorSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3701
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3702
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3703
    ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3704
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3705
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3706
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3707
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  3708
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3709
    "
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3710
    <resource: #style (#'menuPanel.verticalInset')>
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3711
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3712
    HorizontalInset       := 2.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3713
    VerticalInset         := MenuPanel styleSheet at:#'menuPanel.verticalInset' default:2.
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3714
    VerticalPopUpInset    := 2.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3715
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3716
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3717
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  3718
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  3719
    LabelRightOffset      := 15.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3720
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  3721
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  3722
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  3723
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3724
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3725
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3726
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3727
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3728
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3729
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3730
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3731
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3732
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3733
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3734
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3735
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3736
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3737
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3738
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3739
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3740
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3741
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3742
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3743
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3744
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3745
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3746
!MenuPanel::Item methodsFor:'accept'!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3747
420
ca
parents: 417
diff changeset
  3748
canAccept
ca
parents: 417
diff changeset
  3749
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  3750
    "
ca
parents: 417
diff changeset
  3751
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3752
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3753
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3754
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3755
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3756
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3757
    |arg|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3758
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3759
    indication notNil ifTrue:[    
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3760
        arg := self indicationValue not.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3761
        self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  3762
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3763
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3764
            choice value:choiceValue.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3765
          ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3766
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3767
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  3768
    ^ arg
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3769
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3770
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3771
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3772
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3773
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3774
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3775
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3776
    ^ accessCharacter
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3777
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3778
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3779
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3780
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3781
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3782
    ^ accessCharacterPosition
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3783
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3784
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3785
accessCharacterPosition:anIndex 
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3786
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3787
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3788
    accessCharacterPosition := anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3789
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3790
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3791
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3792
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3793
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3794
    ^ argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3795
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3796
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3797
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3798
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3799
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3800
    argument := anArgument.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3801
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3802
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3803
currentSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3804
    "returns the current submenu or nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3805
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3806
    ^ subMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3807
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3808
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3809
font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3810
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3811
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3812
    ^ font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3813
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3814
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3815
font:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3816
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3817
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3818
    aFont ~= font ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3819
        font := aFont notNil ifTrue:[aFont onDevice:(menuPanel device)]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3820
                            ifFalse:[nil].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3821
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3822
        rawLabel notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3823
            "have to recompute the extent"
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3824
            self label:label
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3825
        ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3826
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3827
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3828
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3829
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3830
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3831
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3832
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3833
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3834
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3835
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3836
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3837
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3838
    "
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3839
    |size char lbl mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3840
     h "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3841
     w "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3842
    |
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3843
    accessCharacter := rawLabelExtent := disabledRawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3844
    label    := aLabel value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3845
    rawLabel := label value ? ''.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3846
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3847
    rawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3848
        "CHECK FOR SEPARATOR"
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
        (isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3851
            size := rawLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3852
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3853
            size == 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3854
                rawLabel := nil.                        "blank separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3855
              ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3856
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3857
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3858
            size == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3859
                char := rawLabel first.
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
                (char == $- or:[char == $=]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3862
                    label    := rawLabel.               "line separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3863
                    rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3864
                  ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3865
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3866
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3867
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3868
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3869
        rawLabel isCollection ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3870
            rawLabel := rawLabel asArray.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3871
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3872
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3873
    mfont := menuPanel setFont:font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3874
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3875
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3876
        w := h := 0.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3877
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3878
        rawLabel keysAndValuesDo:[:i :el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3879
            el notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3880
                lbl := self updateAccessCharacterFor:el.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3881
                rawLabel at:i put:lbl.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3882
                w := w max:(lbl widthOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3883
                h := h + 1 + (lbl heightOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3884
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3885
                h := h + 3
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3886
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3887
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3888
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3889
        rawLabel := self updateAccessCharacterFor:rawLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3890
        w := rawLabel  widthOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3891
        h := rawLabel heightOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3892
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3893
    rawLabelExtent := w@h.
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  3894
    menuPanel setFont:mfont.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3895
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3896
    menuPanel shown ifTrue:[ self fetchImages ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3897
    menuPanel mustRearrange
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3898
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3899
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3900
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3901
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3902
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  3903
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3904
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3905
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3906
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3907
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3908
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3909
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3910
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3911
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3912
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3913
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3914
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3915
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3916
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3917
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3918
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3919
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3920
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3921
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3922
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3923
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3924
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3925
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3926
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3927
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3928
    ^ shortcutKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3929
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3930
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3931
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3932
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3933
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3934
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3935
    shortcutKey ~~ aKey ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3936
        shortcutKey := aKey.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3937
        self invalidate.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3938
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3939
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3940
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3941
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3942
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3943
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3944
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3945
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3946
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3947
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3948
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3949
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3950
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3951
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3952
    startGroup := aSymbol.
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3953
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  3954
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3955
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3956
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3957
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3958
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  3959
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3960
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3961
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3962
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3963
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3964
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3965
    "
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3966
    (aSubMenu notNil 
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3967
     and:[(aSubMenu isView or:[aSubMenu isKindOf:Menu]) not]) ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3968
        ^ self submenuChannel:aSubMenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3969
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3970
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3971
    (subMenu := aSubMenu) notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3972
        aSubMenu class == Menu ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3973
            subMenu := MenuPanel new.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3974
            menuPanel notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3975
                subMenu receiver:menuPanel receiver.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3976
            ].
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3977
            subMenu superMenu:menuPanel.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3978
            subMenu menu:aSubMenu.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3979
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3980
            subMenu isView ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3981
                subMenu superMenu:menuPanel.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3982
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  3983
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3984
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3985
1068
155168a813ad oops - subMenu must be an instance of MenuPanel
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
  3986
    "Modified: / 10.8.1998 / 13:26:28 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3987
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  3988
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3989
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3990
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3991
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3992
    |txt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3993
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3994
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3995
        rawLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3996
            ^ rawLabel perform:#string ifNotUnderstood:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3997
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3998
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  3999
        rawLabel do:[:el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4000
            (txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4001
                ^ txt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4002
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4003
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4004
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4005
    ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4006
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4007
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4008
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4009
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4010
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4011
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4012
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4013
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4014
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4015
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4016
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4017
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4018
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4019
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4020
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4021
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4022
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  4023
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4024
    value    := aValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4025
    argument := anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4026
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4027
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4028
!MenuPanel::Item methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4029
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4030
choice
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4031
    "implements a radio group; the field
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4032
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4033
    ^ choice
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4034
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4035
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4036
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4037
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4038
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4039
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4040
    choice == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4041
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4042
    choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4043
        choice removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4044
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4045
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4046
    (choice := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4047
        choice isSymbol ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4048
            (choice := self aspectAt:choice) isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4049
                choice := something
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
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4052
        choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4053
            choice addDependent:self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4054
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4055
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4056
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4057
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4058
choiceValue
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4059
    "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
  4060
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4061
    ^ choiceValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4062
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4063
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4064
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4065
choiceValue:something
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4066
    "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
  4067
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4068
    choiceValue ~= something ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4069
        choiceValue := something.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4070
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4071
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4072
            self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4073
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4074
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4075
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4076
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4077
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4078
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4079
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4080
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4081
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4082
    menuPanel enabled ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4083
        enableChannel isSymbol ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4084
            state := self aspectAt:enableChannel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4085
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4086
            state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4087
                enableChannel := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4088
                enableChannel addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4089
                state := enableChannel value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4090
            ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4091
                state := state value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4092
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4093
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4094
            state := enableChannel value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4095
        ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4096
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4097
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4098
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4099
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4100
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4101
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4102
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4103
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4104
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4105
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4106
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4107
        oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4108
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4109
        oldState := enableChannel value.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4110
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4111
            enableChannel removeDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4112
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4113
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4114
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4115
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4116
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4117
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4118
        newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4119
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4120
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4121
            enableChannel addDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4122
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4123
            enableChannel isSymbol ifTrue:[^ self]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4124
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4125
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4126
        newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4127
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4128
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4129
    newState ~~ oldState ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4130
        self invalidate
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4131
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4132
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4133
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4134
hideMenuOnActivated
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4135
    "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4136
    "
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4137
    ^ hideMenuOnActivated ? true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4138
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4139
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4140
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4141
hideMenuOnActivated:aBool
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4142
   "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4143
   "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4144
   hideMenuOnActivated := aBool.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4145
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4146
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4147
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4148
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4149
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4150
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4151
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4152
    ^ indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4153
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4154
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4155
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4156
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4157
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4158
    indication == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4159
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4160
    indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4161
        indication removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4162
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4163
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4164
    (indication := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4165
        indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4166
            indication addDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4167
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4168
            "/ to force an update of the value
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4169
            self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4170
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4171
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4172
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4173
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4174
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4175
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4176
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4177
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4178
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4179
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4180
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4181
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4182
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4183
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4184
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4185
    layout notNil ifTrue:[
1731
89932327a6f8 redrawAsButton no longer exists; call invalidate
ca
parents: 1730
diff changeset
  4186
        self invalidate.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4187
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4188
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4189
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4190
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4191
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4192
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4193
showBusyCursorWhilePerforming
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4194
    "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
  4195
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4196
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4197
    ^ showBusyCursorWhilePerforming ? false
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4198
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4199
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4200
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4201
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4202
showBusyCursorWhilePerforming:aBoolean
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4203
    "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
  4204
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4205
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4206
    showBusyCursorWhilePerforming := aBoolean.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4207
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4208
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4209
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4210
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4211
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4212
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4213
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4214
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4215
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4216
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4217
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4218
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4219
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4220
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4221
!MenuPanel::Item methodsFor:'accessing-dimension'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4222
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4223
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4224
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4225
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4226
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4227
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4228
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4229
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4230
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4231
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4232
    layout := aLayout.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4233
    self invalidate.
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  4234
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4235
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4236
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4237
preferredExtent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4238
    "compute my preferred extent excluding the shortCutKey and the menu identifier
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4239
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4240
    |isVertical
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4241
     x "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4242
     y "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4243
     s "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4244
    |
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4245
    self isVisible ifFalse:[^ 0@0 ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4246
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4247
    isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4248
        s := menuPanel maxAbsoluteButtonLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4249
        x := s + HorizontalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4250
        y := s + VerticalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4251
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4252
        x  := HorizontalInset.
1766
e3667c5b8b30 may not assign potential nil to a smallInt-typed variable
Claus Gittinger <cg@exept.de>
parents: 1765
diff changeset
  4253
        y  := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4254
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4255
    x := x * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4256
    y := y * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4257
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4258
    isVertical := menuPanel verticalLayout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4259
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4260
    rawLabel isNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4261
        "SEPARATOR"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4262
        s := self class separatorSize.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4263
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4264
        "width of doubleSeparator is 5 !!!!"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4265
        isVertical ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4266
            x := x max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4267
            y := y + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4268
        ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4269
            y := y max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4270
            x := x + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4271
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4272
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4273
        x := x + rawLabelExtent x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4274
        y := y + rawLabelExtent y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4275
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4276
        isButton ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4277
            menuPanel showSeparatingLines ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4278
                "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
  4279
                isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4280
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4281
            (indication notNil or:[choice notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4282
                x := x + 2 + menuPanel iconIndicationOff width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4283
            ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4284
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4285
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4286
    ^ x@y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4287
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4288
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  4289
!MenuPanel::Item methodsFor:'accessing-help'!
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4290
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4291
activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4292
    "get the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4293
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4294
    ^ activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4295
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4296
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4297
activeHelpKey:aHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4298
    "set the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4299
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4300
    activeHelpKey ~~ aHelpKey ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4301
        activeHelpKey  := aHelpKey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4302
        activeHelpText := nil.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4303
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4304
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4305
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4306
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4307
activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4308
    "get the active helpText or nil if not yet resolved
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4309
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4310
    ^ activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4311
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4312
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4313
activeHelpText:aText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4314
    "set the active helpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4315
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4316
    activeHelpText := aText.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4317
! !
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4318
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4319
!MenuPanel::Item methodsFor:'activation / deactivation'!
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4320
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4321
hideSubmenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4322
    "hide submenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4323
    "
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4324
    |id|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4325
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4326
    subMenu notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4327
        subMenu realized ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4328
            (id := subMenu id) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4329
                menuPanel device unmapWindow:id
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4330
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4331
        ] ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4332
           subMenu hide
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4333
        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4334
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4335
        subMenu windowGroup:nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4336
        menuPanel windowGroup removeView:subMenu.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4337
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4338
        "/ release menu if derived from channel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4339
        submenuChannel notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4340
            subMenu := nil
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4341
        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4342
     ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  4343
!
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4344
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4345
openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4346
    "opens the submenu; make sure, that the submenu and the menPanel
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4347
     is fully visible by shifting it into the visible screen area if
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4348
     nescessary.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4349
    "
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4350
    |p o device isVertical topMenu windGrp prefExtent
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4351
     devBot   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4352
     devRight "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4353
     width    "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4354
     height   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4355
     top      "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4356
     left     "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4357
    |
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4358
1737
c18896a7cb50 replace shown by realized; when opening a submenue-submenue by shortcut key
ca
parents: 1735
diff changeset
  4359
    (subMenu notNil and:[subMenu shown not and:[self isSelected and:[menuPanel realized]]]) ifFalse:[
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4360
        ^ self
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4361
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4362
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4363
    topMenu := menuPanel topMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4364
    windGrp := topMenu windowGroup.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4365
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4366
    subMenu superMenu:menuPanel.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4367
    subMenu becomesActiveMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4368
    subMenu cursor:Cursor hand.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4369
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4370
    windGrp notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4371
        subMenu windowGroup:windGrp.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4372
        windGrp addTopView:subMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4373
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4374
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4375
    " Q&D kludge - if any visibility attributes are blocks;
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4376
      TODO: only invoke mustRearrange if any are blocks
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4377
            (since I react correctly on valueHolder changes)
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4378
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4379
    subMenu rearrangeItemsIfItemVisibilityChanged.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4380
    subMenu fixSize.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4381
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4382
    "compute origin of subMenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4383
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4384
    isVertical := menuPanel verticalLayout.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4385
    device     := menuPanel device.
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4386
    prefExtent := subMenu preferredExtent.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4387
    height     := prefExtent y.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  4388
    width      := prefExtent x.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4389
    devBot     := device  usableHeight.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4390
    devRight   := device  usableWidth.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4391
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4392
    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
  4393
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4394
    menuPanel isPopUpView ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4395
        o := menuPanel origin + p
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4396
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4397
        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
  4398
    ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4399
    left := o x.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4400
    top  := o y.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4401
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4402
    left + width > devRight ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4403
        left := isVertical ifTrue:[left - layout width - width]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4404
                          ifFalse:[devRight - width]
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
    top + height > devBot ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4408
        top := isVertical ifTrue:[devBot - height]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4409
                         ifFalse:[top - layout height - height]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4410
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4411
    top  := top  max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4412
    left := left max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4413
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4414
    subMenu origin:(left@top).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4415
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4416
    subMenu realized ifFalse:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4417
        subMenu realize. 
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4418
    ] ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4419
        topMenu device mapWindow:(subMenu id).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4420
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4421
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4422
! !
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  4423
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4424
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4425
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4426
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4427
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4428
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4429
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4430
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4431
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4432
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  4433
    (appl isValueModel) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4434
	^ appl value:aKey
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
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4437
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4438
	Object messageNotUnderstoodSignal handle:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4439
	    ex parameter selector == aKey ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4440
		ex reject
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4441
	    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4442
	] do:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4443
	    (appl isKindOf:ApplicationModel) 
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4444
		ifTrue:[value := appl aspectFor:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4445
		ifFalse:[value := appl perform:aKey]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  4446
	]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4447
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4448
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4449
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  4450
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4451
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4452
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4453
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4454
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4455
update:something with:aParameter from:changedObject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4456
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4457
    |form rect|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4458
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4459
    (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
  4460
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4461
    self isSeparator ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4462
        "/ NOT A SEPARATOR
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4463
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4464
        menuPanel shown ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4465
            changedObject == enableChannel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4466
                ^ self invalidate
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4469
            (changedObject == indication or:[changedObject == choice]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4470
                isButton ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4471
                    self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4472
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4473
                    "/ invalidate the interactor only
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4474
                    "/ take any interactor; interactors has the same extent
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4475
                    form := menuPanel iconIndicationOff.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4476
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4477
                    rect := Rectangle left:(layout left + HorizontalInset)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4478
                                       top:(layout top)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4479
                                     width:(form width)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4480
                                    height:(layout height).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4481
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4482
                    menuPanel invalidate:rect repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4483
                ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4484
                ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4485
            ].
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  4486
        ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4487
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4488
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4489
    changedObject == isVisible ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4490
        menuPanel mustRearrange.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4491
        menuPanel rearrangeItems.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4492
      ^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4493
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4494
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4495
    super update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4496
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4497
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4498
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4499
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4500
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4501
    (indication notNil and:[indication isSymbol]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4502
        " indication is a selector otherwise a change notification
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4503
          is raised from the model !!!!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4504
        "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4505
        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
  4506
    ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4507
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4508
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4509
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4510
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4511
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4512
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4513
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4514
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4515
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4516
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4517
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4518
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4519
    label isImage ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4520
        rcv := ResourceRetriever new.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4521
        rcv className:#MenuEditor.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4522
        rcv selector:#iconUnknown.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4523
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4524
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  4525
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4526
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4527
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4528
    enableChannel notNil ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4529
        item enabled:(enableChannel value)
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  4530
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4531
    item font:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4532
    item accessCharacterPosition:accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4533
    item startGroup:startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4534
    item argument:argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4535
    item nameKey:nameKey.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  4536
    item shortcutKeyCharacter:shortcutKey.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4537
    item value:(value value).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4538
    item indication:(indication value).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4539
    item choice:(choice value).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4540
    item choiceValue:choiceValue.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  4541
    item isVisible:(self isVisible).
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  4542
    item hideMenuOnActivated:(self hideMenuOnActivated).
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  4543
    item showBusyCursorWhilePerforming:(self showBusyCursorWhilePerforming).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4544
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4545
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4546
    submenuChannel isSymbol ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4547
        item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4548
    ] ifFalse:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4549
        subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4550
            item submenu:(subMenu asMenu)
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  4551
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4552
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4553
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4554
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4555
    "Modified: / 14.8.1998 / 15:47:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4556
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4557
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4558
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4559
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4560
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4561
    |lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4562
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4563
    menuPanel disabledRedrawDo:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4564
        label := rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4565
        accessCharacterPosition       := aMenuItem accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4566
        argument                      := aMenuItem argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4567
        choiceValue                   := aMenuItem choiceValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4568
        showBusyCursorWhilePerforming := aMenuItem showBusyCursorWhilePerforming.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4569
        hideMenuOnActivated           := aMenuItem hideMenuOnActivated.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4570
        isButton                      := aMenuItem isButton ? false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4571
        nameKey                       := aMenuItem nameKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4572
        startGroup                    := aMenuItem startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4573
        shortcutKey                   := aMenuItem shortcutKeyCharacter.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4574
        value                         := aMenuItem value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4575
        activeHelpKey                 := aMenuItem activeHelpKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4576
        activeHelpText                := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4577
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4578
        self font:(aMenuItem font).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4579
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4580
        self    enabled:(aMenuItem enabled).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4581
        self indication:(aMenuItem indication).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4582
        self     choice:(aMenuItem choice).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4583
        self  isVisible:(aMenuItem isVisible).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4584
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4585
        (lbl := aMenuItem labelImage value) isNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4586
            lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4587
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4588
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4589
        self label:lbl.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4590
        submenuChannel := aMenuItem submenuChannel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4591
        self submenu:(aMenuItem submenu).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4592
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  4593
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  4594
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4595
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4596
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4597
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4598
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4599
drawButton
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4600
    "draw as button
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4601
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4602
    |drawObject fg level isSelected bg ownBgCol
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4603
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4604
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4605
    drawObject := rawLabel.
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
    "COMPUTE COLORS"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4608
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4609
        bg := self activeBackgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4610
        fg := self activeForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4611
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4612
        self isEntered ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4613
            bg := self buttonEnteredBackgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4614
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4615
            bg := self backgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4616
        ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4617
        self enabled ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4618
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4619
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4620
            fg := menuPanel disabledForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4621
            drawObject := self disabledRawLabel
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4622
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4623
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4624
1708
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4625
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4626
        bg := ownBgCol
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4627
    ].
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  4628
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4629
    "DRAW BACKGROUND"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4630
    bg ~= menuPanel backgroundColor ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4631
        menuPanel paint:bg.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4632
        menuPanel fillRectangle:layout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4633
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4634
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4635
    x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4636
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4637
    isSelected ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4638
        "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
  4639
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4640
        indication notNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4641
            "button is indicator and set"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4642
            isSelected := self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4643
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4644
            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
  4645
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4646
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4647
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4648
    isSelected ifTrue:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4649
        level := menuPanel buttonActiveLevel.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4650
        x     := x + level abs.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4651
    ] ifFalse:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4652
        level := self isEntered ifTrue:[menuPanel buttonEnteredLevel]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4653
                               ifFalse:[menuPanel buttonPassiveLevel].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4654
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4655
    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
  4656
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4657
    level ~~ 0 ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4658
        menuPanel drawButtonEdgesFor:self level:level
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4659
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4660
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4661
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4662
drawLabel
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4663
    "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
  4664
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4665
    |scKey cLb cLa drawObject fg arrow 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4666
     isSelected form
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4667
     h "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4668
     y "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4669
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4670
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4671
    |
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4672
    drawObject := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  4673
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4674
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4675
        fg := self activeForegroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4676
    ] ifFalse:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4677
        self enabled ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4678
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4679
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4680
            fg  := menuPanel disabledForegroundColor.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4681
            drawObject := self disabledRawLabel
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4682
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4683
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4684
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4685
    h := layout height.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4686
    x := layout left + HorizontalInset.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4687
    t := layout top.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4688
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4689
    ((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
  4690
        y := t + ((h - form height) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4691
        form displayOn:menuPanel x:x y:y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4692
        x := x + 2 + form width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4693
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4694
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4695
    self drawRawLabel:drawObject atX:x paint:fg.
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  4696
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4697
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4698
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4699
    (     shortcutKey notNil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4700
     and:[(x := menuPanel shortKeyInset) ~~ 0
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4701
     and:[(scKey:= self shortcutKeyAsString) notNil]]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4702
    ) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4703
        x := layout left + x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4704
        y := t + ((h - (scKey heightOn:menuPanel)) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4705
        y := y + menuPanel font ascent.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4706
        scKey displayOn:menuPanel x:x y:y. 
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4707
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  4708
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4709
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4710
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4711
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4712
        arrow := menuPanel rightArrow.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4713
        x := layout right - arrow width - HorizontalInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4714
        y := t + (h - arrow height // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4715
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4716
        (menuPanel styleSheet is3D not
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4717
        or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4718
            ^ menuPanel displayForm:arrow x:x y:y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4719
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4720
        cLa := menuPanel shadowColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4721
        cLb := menuPanel lightColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4722
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4723
        isSelected ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4724
            fg  := cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4725
            cLa := cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4726
            cLb := fg
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4727
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4728
        menuPanel paint:cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4729
        menuPanel displayForm:arrow x:x y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  4730
        menuPanel paint:cLb.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4731
        menuPanel displayForm:drawObject x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4732
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  4733
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4734
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4735
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4736
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4737
drawRawLabel:aLabel atX:x paint:fg
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4738
    "draw a labeled entry; no button, no separator.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4739
    "
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4740
    |mfont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4741
     y  "{ Class:SmallInteger }"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4742
     y0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4743
     x0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4744
    |
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4745
    mfont := menuPanel setFont:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4746
    menuPanel paint:fg.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4747
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4748
    y := layout top + (layout height - rawLabelExtent y // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4749
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4750
    aLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4751
        aLabel isImageOrForm ifFalse:[
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4752
            y := y + menuPanel font ascent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4753
        ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4754
        aLabel displayOn:menuPanel x:x y:y.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4755
    ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4756
        aLabel do:[:el|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4757
            el notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4758
                el isImageOrForm ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4759
                    y0 := y + menuPanel font ascent
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4760
                ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4761
                    y0 := y
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4762
                ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4763
                x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4764
                el displayOn:menuPanel x:x0 y:y0.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4765
                y := y + 1 + (el heightOn:menuPanel)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4766
            ] ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4767
                y := y + 3   "/ see #label:
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4768
            ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4769
        ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4770
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4771
    menuPanel setFont:mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4772
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4773
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4774
drawSeparatingLines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4775
    "draw separating lines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4776
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4777
    |index item lfSep rtSep items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4778
     l "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4779
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4780
     r "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4781
     b "{ Class:SmallInteger }"
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  4782
    |
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4783
    items := menuPanel items.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4784
    index := items identityIndexOf:self.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4785
    item  := items at:(index - 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4786
    lfSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4787
    item  := items at:(index + 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4788
    rtSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4789
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4790
    (lfSep isNil and:[rtSep]) isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4791
        ^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4792
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4793
    menuPanel paint:(menuPanel lightColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4794
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4795
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4796
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4797
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4798
    b := layout bottom.
1707
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
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4801
        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
  4802
        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
  4803
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4804
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4805
        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
  4806
        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
  4807
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4808
        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
  4809
        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
  4810
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4811
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4812
        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
  4813
        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
  4814
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4815
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
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4818
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4819
drawSeparator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4820
    "draw as separator
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
    |type lightColor isDouble
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4823
     x0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4824
     x1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4825
     y0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4826
     y1  "{ Class:SmallInteger }"
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
    type := self separatorType.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4829
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4830
    (type isNil or:[type == #blankLine]) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4831
        ^ self
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4832
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4833
    isDouble   := type == #doubleLine.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4834
    lightColor := menuPanel lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4835
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4836
    menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4837
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4838
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4839
        x0 := layout left  + HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4840
        x1 := layout right - HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4841
        y0 := layout top   - 1 + (layout height // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4842
        isDouble ifTrue:[y0 := y0 - 2].
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 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
  4845
        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
  4846
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4847
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4848
                         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
  4849
        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
  4850
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4851
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4852
        y1 := layout bottom.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4853
        x0 := layout left - 1 + (layout width // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4854
        y0 := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4855
        isDouble ifTrue:[x0 := x0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4856
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4857
                         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
  4858
        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
  4859
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4860
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4861
                         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
  4862
        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
  4863
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4864
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4865
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4866
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4867
invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4868
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4869
    (rawLabel notNil and:[menuPanel notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4870
        menuPanel invalidateItem:self repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4871
    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4872
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4873
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4874
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4875
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4876
redraw
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4877
    "redraw item
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4878
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4879
    |isSelected ownBgCol paint bgColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4880
     x  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4881
     y  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4882
     w  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4883
     h  "{ Class:SmallInteger }"
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
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4886
    self isVisible ifFalse:[^ self].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4887
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4888
    rawLabel isNil  ifTrue:[^ self drawSeparator].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4889
    isButton        ifTrue:[^ self drawButton].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4890
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4891
    "/ 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
  4892
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4893
    isSelected := self isSelected.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4894
    bgColor    := menuPanel backgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4895
    paint      := isSelected ifTrue:[self activeBackgroundColor] ifFalse:[bgColor].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4896
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4897
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4898
        paint := ownBgCol
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4899
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4900
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4901
    paint ~= bgColor ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4902
        menuPanel paint:paint.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4903
        menuPanel fillRectangle:layout.
1707
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
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4906
    menuPanel showSeparatingLines ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4907
        self drawSeparatingLines
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4908
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  4909
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4910
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4911
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4912
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4913
        ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4914
                                 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4915
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4916
        x := layout left.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4917
        y := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4918
        w := layout width.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4919
        h := layout height.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4920
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4921
        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
  4922
        menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4).  
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4923
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4924
    menuPanel drawLabelEdgeFor:self selected:isSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4925
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4926
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4927
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  4928
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4929
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4930
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4931
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4932
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4933
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4934
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4935
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4936
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4937
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4938
    enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4939
    isVisible     isValueModel  ifTrue:[isVisible    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4940
    indication    isValueModel ifTrue:[indication    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4941
    choice        isValueModel ifTrue:[choice        removeDependent:self].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4942
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4943
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4944
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4945
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4946
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4947
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4948
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4949
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  4950
    isButton  := false.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4951
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4952
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4953
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4954
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4955
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4956
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4957
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4958
    |block form image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4959
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4960
    disabledRawLabel notNil ifTrue:[^ disabledRawLabel].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4961
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4962
    disabledRawLabel := rawLabel ? ''.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4963
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4964
    disabledRawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4965
        ^ disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4966
    ].
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
    block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4969
        (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4970
            el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4971
                el colorMap notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4972
                    rslt := menuPanel lightenedImageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4973
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4974
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4975
                el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4976
                    ((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4977
                        form := menuPanel lightenedImageOnDevice:form
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
                    ((image := el image) notNil and:[image colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4980
                        image := menuPanel lightenedImageOnDevice:image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4981
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4982
                    rslt := LabelAndIcon form:form image:image string:(el string).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4983
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4984
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4985
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4986
        rslt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4987
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4988
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4989
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4990
        disabledRawLabel := Array new:(rawLabel size).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4991
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4992
        rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4993
            disabledRawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4994
        ]
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
        disabledRawLabel := block value:rawLabel
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4997
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4998
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  4999
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  5000
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5001
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5002
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5003
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5004
    |icon block|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5005
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5006
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5007
        block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5008
            (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5009
                el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5010
                    rslt := menuPanel imageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5011
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5012
                    el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5013
                        (icon := el image) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5014
                            el image:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5015
                        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5016
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5017
                        (icon := el icon) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5018
                            el icon:(menuPanel imageOnDevice:icon)
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
                    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5021
                ]
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5022
            ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5023
            rslt
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5024
        ].
1726
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
        rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5027
            rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5028
                rawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5029
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5030
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5031
            rawLabel := block value:rawLabel
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5032
        ]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5033
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5034
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5035
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5036
updateAccessCharacterFor:aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5037
    |s i rest label pos|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5038
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5039
    (accessCharacter notNil or:[aLabel isNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5040
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5041
    ].
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
    aLabel isString ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5044
        aLabel class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5045
            aLabel string:(self updateAccessCharacterFor:(aLabel string))
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  5046
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5047
        ^ aLabel
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
    s := aLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5051
    i := 1.
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
    label := aLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5054
    pos := accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5055
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5056
    [((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
  5057
        rest := label copyFrom:(i+1).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5058
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5059
        i == 1 ifTrue:[label := rest]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5060
              ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5061
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5062
        (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
  5063
        s := s - 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5064
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5065
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5066
    (pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[
1762
840521c06b92 bugfix for && in label
ca
parents: 1750
diff changeset
  5067
        ^ label
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5068
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5069
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5070
    label isText ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5071
        label := Text string:label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5072
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5073
    label emphasisAt:pos add:#underline.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5074
  ^ label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5075
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5076
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5077
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5078
!MenuPanel::Item methodsFor:'printing & storing'!
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5079
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5080
displayString
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5081
    ^ self class name, '[', label printString, ']'
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5082
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5083
! !
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  5084
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5085
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5086
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5087
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5088
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5089
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5090
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5091
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5092
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5093
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5094
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5095
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5096
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5097
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5098
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5099
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5100
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5101
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5102
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5103
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5104
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5105
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5106
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5107
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5108
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5109
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5110
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5111
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5112
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5113
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5114
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5115
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5116
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5117
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5118
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5119
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5120
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5121
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5122
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5123
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5124
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5125
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5126
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5127
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5128
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5129
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5130
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5131
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5132
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5133
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5134
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5135
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5136
    "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
  5137
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5138
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5139
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5140
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5141
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5142
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5143
    "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
  5144
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5145
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5146
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5147
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5148
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5149
    choice isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5150
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5151
    ^ choice value = choiceValue ifTrue:[menuPanel iconRadioGroupOn]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5152
                                ifFalse:[menuPanel iconRadioGroupOff]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5153
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5154
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5155
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5156
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5157
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5158
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5159
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5160
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5161
    |subm sel|
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5162
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5163
    subm := nil.
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5164
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5165
    aRecv notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5166
        submenuChannel last ~~ $: ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5167
            Object messageNotUnderstoodSignal handle:[:ex|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5168
                |selector|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5169
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5170
                ((selector := ex parameter selector) == submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5171
                or:[selector == #aspectFor:]) ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5172
                    ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5173
                ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5174
            ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5175
                subm := aRecv aspectFor:submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5176
            ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5177
            subm isNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5178
                Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5179
                    ex parameter selector == submenuChannel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5180
                        ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5181
                    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5182
            ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5183
                    subm := aRecv perform:submenuChannel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5184
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5185
            ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5186
            subm isNil ifTrue:[
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 == submenuChannel 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 class perform:submenuChannel.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5193
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5194
                    "/ menu provided by class; thus it will not be changed
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5195
                    subm notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5196
                        submenuChannel := nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5197
                    ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5198
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5199
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5200
        ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5201
            argument notNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5202
                sel := submenuChannel asSymbol.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5203
                Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5204
                    ex parameter selector == sel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5205
                        ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5206
                    ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5207
                ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5208
                    subm := aRecv perform:sel with:argument
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5209
                ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5210
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5211
                subm isNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5212
                    Object messageNotUnderstoodSignal handle:[:ex| 
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5213
                        ex parameter selector == sel ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5214
                            ex reject
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5215
                        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5216
                    ] do:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5217
                        subm := aRecv class perform:sel with:argument.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5218
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5219
                        "/ menu provided by class; thus it will not be changed
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5220
                        subm notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5221
                            submenuChannel := nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5222
                        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5223
                    ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5224
                ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5225
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5226
        ]
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5227
    ].
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5228
    ^ subm
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5229
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  5230
    "Modified: / 4.8.1998 / 17:40:09 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5231
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  5232
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5233
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5234
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5235
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5236
    |numArgs sel recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5237
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5238
    indication isNil ifTrue:[^ nil].                                    "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5239
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5240
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5241
        ^ indication value == true                                      "block or model"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5242
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5243
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5244
    (numArgs := indication numArgs) == 2 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5245
        recv := menuPanel receiver.
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
        (recv isValueModel) ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5248
            (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5249
                sel := indication copyFrom:1 to:(indication indexOf:$:).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5250
                sel := sel asSymbol.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5251
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5252
                Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5253
                    ex parameter selector == sel ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5254
                        ex reject
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5255
                    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5256
                ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5257
                    sel := recv perform:sel with:argument
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5258
                ]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5259
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5260
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5261
        ^ sel value == true
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5262
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5263
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5264
    numArgs ~~ 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5265
        sel := (indication copyWithoutLast:1) asSymbol
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5266
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5267
        sel := indication
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
    sel := self aspectAt:sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5270
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5271
    sel isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5272
        indication := sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5273
        indication addDependent:self.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5274
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5275
    ^ sel value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5276
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5277
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5278
indicationValue:aValue
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5279
    "set the indication value
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5280
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5281
    |numArgs recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5282
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5283
    indication isNil ifTrue:[^ self].                                   "no indication specified"
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
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5286
        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
  5287
      ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5288
    ].
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
    (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
  5291
        ^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5292
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5293
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5294
    recv := menuPanel receiver.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5295
    recv isValueModel ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5296
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  5297
    recv isNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5298
        recv := menuPanel application.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5299
        recv isNil ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5300
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5301
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5302
    Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5303
        (ex parameter selector ~~ indication) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5304
            ex reject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5305
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5306
    ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5307
        numArgs == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5308
            recv perform:indication with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5309
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5310
            recv perform:indication with:(argument ? self) with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5311
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5312
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5313
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5314
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5315
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5316
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5317
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5318
    indication isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5319
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5320
  ^ self indicationValue == true ifTrue:[menuPanel iconIndicationOn]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5321
                                ifFalse:[menuPanel iconIndicationOff]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5322
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5323
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5324
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5325
    "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
  5326
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5327
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5328
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5329
    "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
  5330
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  5331
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5332
reinitSubmenuStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5333
    "returns my submenu or nil
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5334
    "
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5335
    subMenu notNil ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  5336
	subMenu reinitStyle
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5337
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5338
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5339
    "Created: / 10.9.1998 / 21:36:09 / cg"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5340
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5341
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5342
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5343
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5344
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5345
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5346
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5347
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5348
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5349
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5350
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5351
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5352
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5353
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5354
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5355
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5356
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5357
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5358
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5359
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5360
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5361
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5362
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5363
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5364
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5365
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5366
    submenuChannel notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5367
        submenuChannel isSymbol ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5368
            subm := submenuChannel
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5369
        ] ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5370
            appl := menuPanel application.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5371
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5372
            (subm := self findSubMenuIn:appl) isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5373
                (recv := menuPanel receiver) ~~ appl ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5374
                    subm := self findSubMenuIn:recv
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5375
                ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5376
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5377
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5378
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5379
        (subm := subm value) isArray ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5380
            subm := Menu new fromLiteralArrayEncoding:subm.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5381
            "/ cg: linked menus also may contain translations ...
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5382
            subm notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5383
                appl notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5384
                    subm findGuiResourcesIn:appl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5385
                ]                
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5386
            ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5387
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5388
        self submenu:subm.
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5389
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5390
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5391
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5392
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  5393
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5394
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5395
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5396
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5397
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5398
canChangeVisibility
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5399
    "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
  5400
     otherwise there is a change notification raised if the model changed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5401
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5402
    ^ isVisible isSymbol
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5403
"/  ^ isVisible notNil and:[isVisible ~~ true]
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5404
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  5405
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5406
canSelect
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5407
    "returns true if item is selectable; no separator, visible and enabled.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5408
     in case of a choice (RadioButton) i have to check for the choiceValue
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5409
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5410
    (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
  5411
        (choice isNil or:[choice value ~= choiceValue]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5412
            ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5413
        ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5414
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5415
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5416
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5417
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5418
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5419
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5420
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5421
    (self isVisible and:[layout notNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5422
        ^ layout containsPointX:x y:y
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5423
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  5424
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5425
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5426
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5427
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5428
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5429
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5430
    ^ indication notNil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5431
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5432
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5433
hasSubmenu
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5434
    "returns true if the item is configured as an subMenu entry
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5435
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5436
    ^ subMenu notNil or:[submenuChannel notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5437
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5438
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5439
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5440
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5441
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5442
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5443
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5444
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5445
isLabeledItem
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5446
    "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
  5447
    "
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5448
    ^ rawLabel notNil and:[isButton not]
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5449
!
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  5450
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5451
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5452
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5453
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5454
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5455
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5456
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5457
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5458
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5459
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5460
    |state|
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 isSymbol ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5463
        state := self aspectAt:isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5464
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5465
        state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5466
            isVisible := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5467
            isVisible addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5468
            state := isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5469
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5470
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5471
        state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5472
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5473
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5474
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5475
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5476
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5477
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5478
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5479
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5480
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5481
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5482
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5483
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5484
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5485
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5486
        oldState := isVisible value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5487
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5488
            isVisible removeDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5489
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5490
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5491
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5492
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5493
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5494
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5495
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5496
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5497
            isVisible addDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5498
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5499
            isVisible isSymbol ifTrue:[^ self]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5500
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5501
        menuPanel shown ifFalse:[^ self].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5502
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5503
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5504
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5505
    newState ~~ oldState ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5506
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5507
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5508
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  5509
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5510
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5511
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5512
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5513
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5514
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5515
    |nm prefix|
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5516
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5517
    shortcutKey isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5518
        ^ nil
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5519
    ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5520
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5521
    shortcutKey isCharacter ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5522
        nm := shortcutKey asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5523
    ] ifFalse:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5524
        "/ this is somewhat complicated: we have the symbolic key at hand,
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5525
        "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5526
        "/ Ask the devices keyboardMap for the backtranslation.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5527
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5528
        nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5529
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5530
        "/ some modifier-key combination ?
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5531
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5532
        (nm startsWith:#Cmd) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5533
            prefix := #Cmd.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5534
        ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5535
            prefix := #Alt.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5536
        ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5537
            prefix := #Meta.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5538
        ] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5539
            prefix := #Ctrl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5540
        ]]]].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5541
        prefix notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5542
            nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5543
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5544
            nm := nm asString
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5545
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5546
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5547
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5548
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5549
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5550
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5551
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5552
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5553
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5554
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5555
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5556
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5557
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5558
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  5559
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5560
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5561
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5562
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  5563
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5564
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5565
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5566
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5567
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5568
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5569
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5570
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5571
    ^ menuPanel selection == self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5572
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5573
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5574
selected:isSelected
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5575
    "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
  5576
     submenu and perform a redraw
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5577
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5578
    menuPanel isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5579
        ^ self hideSubmenu
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5580
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5581
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5582
    isSelected ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5583
        self invalidate.
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5584
        self hideSubmenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5585
    ] ifTrue:[
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5586
        menuPanel realized ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5587
            (indication isNil or:[isButton not]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5588
                self invalidate
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5589
            ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5590
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5591
            (subMenu := self setupSubmenu) notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5592
                self openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5593
            ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5594
        ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5595
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5596
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5597
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5598
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5599
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5600
version
1766
e3667c5b8b30 may not assign potential nil to a smallInt-typed variable
Claus Gittinger <cg@exept.de>
parents: 1765
diff changeset
  5601
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.221 2000-04-26 13:41:20 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5602
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5603
MenuPanel initialize!