MenuPanel.st
author Claus Gittinger <cg@exept.de>
Tue, 13 Nov 2001 14:19:27 +0100
changeset 2046 012798480de6
parent 2043 133a9674bcdf
child 2047 62de65e3a61b
permissions -rw-r--r--
code cleanup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     1
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     3
	      All Rights Reserved
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     4
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     5
 This software is furnished under a license and may be used
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     6
 only in accordance with the terms of that license and with the
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     9
 other person.  No title to or ownership of the software is
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    10
 hereby transferred.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    11
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    12
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
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
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
    27
		iconIndicationOn iconRadioGroupOff iconRadioGroupOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
    28
		iconIndicationDisabledOff iconIndicationDisabledOn
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    29
		iconRadioGroupDisabledOff iconRadioGroupDisabledOn scrolling'
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    30
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    31
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    32
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    33
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
    35
		DefaultEnteredLevel DefaultSelectionFollowsMouse
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    36
		DefaultOpenOnSelect DefaultFitFirstPanel RightArrowForm
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    37
		RightArrowShadowForm SelectionFrameBrightColor
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    38
		SelectionFrameDarkColor ButtonActiveLevel ButtonPassiveLevel
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    39
		ButtonActiveBackgroundColor ButtonPassiveBackgroundColor
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    40
		ButtonLightColor ButtonShadowColor ButtonHalfLightColor
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    41
		ButtonHalfShadowColor ButtonEdgeStyle Images LigthenedImages
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    42
		ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    43
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    44
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    45
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    46
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    47
Object subclass:#Item
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    48
	instanceVariableNames:'layout menuPanel subMenu rawLabel rawLabelExtent disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    49
		enableChannel nameKey value label activeHelpKey activeHelpText
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    50
		submenuChannel startGroup isButton isVisible hideMenuOnActivated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    51
		indication accessCharacterPosition shortcutKey argument choice
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
    52
		choiceValue showBusyCursorWhilePerforming accessCharacter font
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
    53
		keepLinkedMenu triggerOnDown'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    54
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
    55
		VerticalButtonInset LabelRightOffset VerticalPopUpInset'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    56
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    57
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    58
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    60
Object subclass:#Scrolling
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
    61
	instanceVariableNames:'semaLock activeMenu scrollTask direction icons'
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    62
	classVariableNames:''
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    63
	poolDictionaries:''
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    64
	privateIn:MenuPanel
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    65
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    66
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    67
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    69
copyright
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    70
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    71
 COPYRIGHT (c) 1997 by eXept Software AG
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    72
	      All Rights Reserved
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    73
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    74
 This software is furnished under a license and may be used
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    75
 only in accordance with the terms of that license and with the
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    76
 inclusion of the above copyright notice.   This software may not
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    77
 be provided or otherwise made available to, or used by, any
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    78
 other person.  No title to or ownership of the software is
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    79
 hereby transferred.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    80
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    81
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    82
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    83
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    84
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    85
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    86
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    87
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    89
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    92
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    93
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    94
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    95
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    96
DefaultSelectionFollowsMouse := true.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    97
DefaultSelectionFollowsMouse := false.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    98
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    99
    [author:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   100
        Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
    [see also:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   103
        Menu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   104
        MenuItem
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   105
        MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   107
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   108
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
    start as PullDownMenu
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   114
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   119
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   121
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   122
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   125
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   126
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   127
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   130
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   133
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   136
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   137
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   138
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   140
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   141
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   143
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   144
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   146
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   147
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   148
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   149
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   150
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   151
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   152
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   153
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
    top open.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   155
                                                                                [exEnd]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   156
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   157
                                                                                [exBegin]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   158
    |top menu view item|
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   159
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   160
    top  := StandardSystemView extent:240@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   161
    menu := MenuPanel in:top.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   162
    menu labels:#( 'foo' 'Application' 'Clock' ).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   163
    menu verticalLayout:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   164
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   165
    menu subMenuAt:1 put:(MenuPanel labels:#( 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   166
    menu subMenuAt:2 put:(MenuPanel labels:#( 'foo' 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   167
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   168
    view := ClockView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   169
    view preferredExtent:100@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   170
    item := menu itemAt:3.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   171
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   172
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   173
    view := SimpleView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   174
    view client:(CodingExamples_GUI::GUIDemoExtendedComboBox new).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   175
    view preferredExtent:(400@50).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   176
    item := menu itemAt:2.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   177
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   178
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   179
    menu origin:0@0 corner:1.0@30.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   180
    top open.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   181
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   182
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   183
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   184
    start as PopUpMenu
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   185
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   186
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   187
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   188
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   189
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   190
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   191
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   192
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   193
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   194
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   195
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   196
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   197
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   198
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   199
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   200
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   201
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   202
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   203
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   204
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   205
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   206
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   207
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   208
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   209
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   210
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   211
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   212
    mview startUp
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   213
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   214
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   215
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   216
    start from menu spec
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   217
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   220
    menu := MenuPanel menu:
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   221
        #(#Menu #( #(#MenuItem 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   222
                    #label: 'File' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   223
                    #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   224
                      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   225
                                 (#MenuItem 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   226
                                    #label: 'edit' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   227
                                    #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   228
                                      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   229
                                                 #(#MenuItem #label: 'close' #value:#close)     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   230
                                               )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   231
                                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   232
                                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   233
                                       )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   234
                                  )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   235
                                 #(#MenuItem #label: 'help' #value:#help )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   236
                               )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   237
                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   238
                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   239
                       )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   240
                 ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   241
                #(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   242
                #(#MenuItem #label: 'Bar' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   243
                            #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   244
                               #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   245
                                          #(#MenuItem #label: 'bar 2' #value:#bar2 )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   246
                                        )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   247
                                        nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   248
                                        nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   249
                                )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   250
                 ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   251
              ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   252
              #( 2 )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   253
              nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   254
         ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
    Transcript showCR:(menu startUp).
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   258
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   261
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   262
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   263
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
    aSpec notNil ifTrue:[
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   274
        menu := Menu new.
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   275
        menu receiver:aReceiver.
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   276
        menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   279
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   285
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   286
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   287
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   288
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   289
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   290
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   291
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   292
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   293
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   294
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   295
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   296
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   297
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   298
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   299
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   300
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   301
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   302
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   303
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   304
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   305
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   306
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   307
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   308
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   309
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   310
    mview := self new.
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   311
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   312
    (aMenu notNil and:[aMenu receiver isNil]) ifTrue:[
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   313
        "/ no receiver specified in the menu; thus set the receiver immediately
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   314
        mview receiver:aReceiver
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   315
    ].
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   316
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   317
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   318
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   319
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   320
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   321
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   322
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   323
    aReceiver notNil ifTrue:[
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   324
        mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   325
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   326
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   327
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   328
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   329
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   330
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   331
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   332
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   333
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   334
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   335
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   336
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   337
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   338
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   339
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   340
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   341
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   342
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   343
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   344
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   345
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   346
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   347
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   348
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   349
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   350
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   351
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   352
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   353
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   354
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   355
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   356
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   357
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   358
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   359
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   360
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   361
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   362
!MenuPanel class methodsFor:'default icons'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   363
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   364
iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   365
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   366
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   367
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   368
    "Do not manually edit this!! If it is corrupted,
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   369
     the ImageEditor may not be able to read the specification."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   370
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   371
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   372
     self iconIndicationDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   373
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   374
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   375
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   376
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   377
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   378
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   379
        constantNamed:#'MenuPanel iconIndicationDisabledOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   380
        ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUPG???8A:***@^*** G***(A:***@^*** G***(A:***@^*** G***(A:***@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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   381
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   382
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   383
iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   384
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   385
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   386
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   387
    "Do not manually edit this!! If it is corrupted,
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   388
     the ImageEditor may not be able to read the specification."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   389
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   390
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   391
     self iconIndicationDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   392
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   393
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   394
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   395
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   396
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   397
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   398
        constantNamed:#'MenuPanel iconIndicationDisabledOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   399
        ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'****$H@@@MBO???P#???4H??<=BO?<OP#O<C4H0<C=BL@C?P#0C?4H?C?=BO???P/???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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   400
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   401
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   402
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   403
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   404
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   405
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   406
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   407
     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
   408
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   409
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   410
     self iconIndicationOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   411
     ImageEditor openOnClass:self andSelector:#iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   412
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   413
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   414
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   415
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   416
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   417
        constantNamed:#'MenuPanel iconIndicationOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   418
        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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   419
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   420
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   421
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   422
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   423
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   424
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   425
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   426
     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
   427
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   428
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   429
     self iconIndicationOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   430
     ImageEditor openOnClass:self andSelector:#iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   431
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   432
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   433
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   434
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   435
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   436
        constantNamed:#'MenuPanel iconIndicationOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   437
        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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   438
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   439
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   440
iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   441
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   442
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   443
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   444
    "Do not manually edit this!! If it is corrupted,
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   445
     the ImageEditor may not be able to read the specification."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   446
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   447
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   448
     self iconRadioGroupDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   449
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   450
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   451
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   452
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   453
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   454
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   455
        constantNamed:#'MenuPanel iconRadioGroupDisabledOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   456
        ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DZ**(AJ**+AJ***LR***#D***(1J***LR***#AZ**#@Z**(0A** 0@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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   457
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   458
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   459
iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   460
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   461
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   462
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   463
    "Do not manually edit this!! If it is corrupted,
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   464
     the ImageEditor may not be able to read the specification."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   465
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   466
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   467
     self iconRadioGroupDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   468
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   469
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   470
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   471
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   472
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   473
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   474
        constantNamed:#'MenuPanel iconRadioGroupDisabledOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   475
        ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DY@Z(AH@@+AI@@FLR@@@#D @@H1H@@BLRP@A#AX@@#@Z$A(0A** 0@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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   476
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   477
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   478
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   479
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   480
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   481
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   482
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   483
     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
   484
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   485
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   486
     self iconRadioGroupOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   487
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   488
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   489
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   490
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   491
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   492
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   493
        constantNamed:#'MenuPanel iconRadioGroupOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   494
        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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   495
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   496
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   497
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   498
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   499
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   500
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   501
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   502
     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
   503
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   504
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   505
     self iconRadioGroupOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   506
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   507
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   508
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   509
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   510
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   511
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   512
        constantNamed:#'MenuPanel iconRadioGroupOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   513
        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]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   514
! !
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   515
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   516
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   517
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   518
mnemonicIdentifier
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   519
    "returns the identifier each mnemonic starts with;
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   520
     ex:
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   521
        &File   mnemonic := Cmdf
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   522
        F&ile   mnemonic := Cmdi
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   523
        .....
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   524
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   525
    ^ 'Cmd'
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   526
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   527
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   528
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   529
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   530
    <resource: #style (#'menu.foregroundColor' #'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   531
                       #'menu.hilightForegroundColor' #'menu.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   532
                       #'menu.hilightBackgroundColor' #'menu.buttonEnteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   533
                       #'menu.hilightLevel' #'menu.groupDividerSize'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   534
                       #'menu.itemSpace' #'menu.buttonItemSpace'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   535
                       #'menu.fitFirstPanel' #'menu.buttonActiveLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   536
                       #'menu.buttonPassiveLevel' #'menu.buttonEnteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   537
                       #'menu.selectionFollowsMouse' #'menu.enteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   538
                       #'viewBackground'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   539
                       #'pullDownMenu.level' #'pullDownMenu.hilightLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   540
                       #'button.disabledForegroundColor' #'button.enteredBackgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   541
                       #'button.activeBackgroundColor' #'button.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   542
                       #'button.lightColor' #'button.shadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   543
                       #'button.halfLightColor' #'button.halfShadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   544
                       #'button.passiveLevel' #'button.activeLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   545
                       #'button.edgeStyle')>
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   546
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   547
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   548
    |style styleSheet|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   549
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   550
    styleSheet := StyleSheet.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   551
    style      := styleSheet name.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   552
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   553
    DefaultForegroundColor := styleSheet colorAt:#'menu.foregroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   554
                                         default:Color black.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   555
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   556
    DefaultBackgroundColor := styleSheet colorAt:#'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   557
                                         default:DefaultViewBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   558
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   559
    DefaultHilightForegroundColor := styleSheet colorAt:#'menu.hilightForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   560
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   561
    DefaultHilightForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   562
        styleSheet is3D ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   563
            DefaultHilightForegroundColor := DefaultForegroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   564
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   565
            DefaultHilightForegroundColor := DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   566
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   567
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   568
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   569
    DefaultDisabledForegroundColor := styleSheet colorAt:#'menu.disabledForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   570
    DefaultDisabledForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   571
        DefaultDisabledForegroundColor := styleSheet colorAt:#'button.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   572
                                                     default:Color darkGray.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   573
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   574
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   575
    DefaultHilightBackgroundColor := styleSheet colorAt:#'menu.hilightBackgroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   576
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   577
    DefaultHilightBackgroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   578
        style == #motif ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   579
            DefaultHilightBackgroundColor := DefaultBackgroundColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   580
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   581
            DefaultHilightBackgroundColor := styleSheet is3D ifFalse:[DefaultForegroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   582
                                                              ifTrue:[DefaultBackgroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   583
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   584
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   585
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   586
    DefaultLevel := styleSheet at:#'pullDownMenu.level' default:0.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   587
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   588
    (style == #motif or:[style == #iris]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   589
        DefaultHilightLevel := 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   590
        DefaultLevel        := DefaultLevel + 1.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   591
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   592
        (DefaultHilightLevel    := styleSheet at:'pullDownMenu.hilightLevel') isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   593
            DefaultHilightLevel := styleSheet at:'menu.hilightLevel' default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   594
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   595
        styleSheet is3D ifTrue:[DefaultLevel := DefaultLevel + 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   596
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   597
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   598
    DefaultGroupDividerSize := styleSheet at:#'menu.groupDividerSize' default:6.
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
   599
    DefaultItemSpace        := styleSheet at:#'menu.itemSpace' default:2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   600
    DefaultButtonItemSpace  := styleSheet at:#'menu.buttonItemSpace' default:0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   601
    DefaultFitFirstPanel    := styleSheet at:#'menu.fitFirstPanel' default:true.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   602
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   603
    MenuView updateStyleCache.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   604
    DefaultFont    := MenuView defaultFont.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   605
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   606
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   607
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   608
        RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   609
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   610
        RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   611
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   612
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   613
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   614
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   615
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   616
    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
   617
    ButtonActiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   618
        ButtonActiveLevel        :=  styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   619
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   620
    ButtonPassiveLevel           :=  styleSheet at:#'menu.buttonPassiveLevel'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   621
    ButtonPassiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   622
        ButtonPassiveLevel       :=  styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   623
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   624
    ButtonActiveBackgroundColor  :=  styleSheet at:#'button.activeBackgroundColor' default: DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   625
    ButtonPassiveBackgroundColor := (styleSheet at:#'button.backgroundColor') ? (styleSheet at:'viewBackground') ? DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   626
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   627
    ButtonLightColor             := styleSheet at:#'button.lightColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   628
    ButtonLightColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   629
        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
   630
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   631
    ButtonShadowColor            :=  styleSheet at:#'button.shadowColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   632
    ButtonShadowColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   633
        ButtonShadowColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened. "/ Color white
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   634
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   635
    ButtonHalfLightColor         :=  styleSheet at:#'button.halfLightColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   636
    ButtonHalfShadowColor        :=  styleSheet at:#'button.halfShadowColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   637
    ButtonEdgeStyle              :=  styleSheet at:#'button.edgeStyle'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   638
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   639
    ButtonEnteredBackgroundColor := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   640
    ButtonEnteredBackgroundColor isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   641
        ButtonEnteredBackgroundColor := styleSheet colorAt:#'button.enteredBackgroundColor'
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   642
                                                  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   643
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   644
    ButtonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   645
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   646
    DefaultSelectionFollowsMouse := styleSheet at:#'menu.selectionFollowsMouse' default:false.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   647
    DefaultEnteredLevel          := styleSheet at:#'menu.enteredLevel'          default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   648
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   649
    ShortcutKeyOffset            := 5.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   650
    DefaultOpenOnSelect := styleSheet at:#'menu.openOnSelect' default:false.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   651
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   652
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   653
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   654
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   655
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   656
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   657
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   658
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   659
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   660
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   661
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   662
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   663
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   664
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   665
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   666
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   667
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   668
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   669
    anImage device == aDevice ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   670
        ^ anImage
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   671
    ].
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   672
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   673
    Images isNil ifTrue:[ Images := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   674
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   675
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   676
        Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   677
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   678
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   679
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   680
        ^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   681
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   682
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   683
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   684
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   685
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   686
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   687
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   688
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   689
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   690
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   691
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   692
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   693
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   694
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   695
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   696
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   697
    LigthenedImages isNil ifTrue:[ LigthenedImages := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   698
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   699
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   700
        LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   701
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   702
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   703
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   704
        ^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   705
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   706
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   707
    ((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   708
        image := anImage copy lightened onDevice:aDevice.
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   709
        image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   710
    ] ifFalse:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   711
        image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   712
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   713
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   714
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   715
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   716
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   717
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   718
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   719
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   720
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   721
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   722
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   723
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   724
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   725
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   726
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   727
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   728
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
   729
!MenuPanel methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   730
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   731
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   732
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   733
    "
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   734
    ^ self acceptItem:(self selection) inMenu:self
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   735
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   736
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
   737
accept:anItem 
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   738
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   739
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   740
    |value item tgState itemIdx recv panel masterGroup winGrp|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
   741
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   742
    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
   743
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   744
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
   745
    self scrolling stop.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   746
    self selection:nil.
420
ca
parents: 417
diff changeset
   747
ca
parents: 417
diff changeset
   748
    (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
   749
        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
   750
        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
   751
        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
   752
        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
   753
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   754
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   755
    self doUngrab:true.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   756
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   757
    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
   758
        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
   759
        self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   760
    ] 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
   761
        self unmap.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   762
        (winGrp := self windowGroup) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   763
            "/ give expose event a chance to arrive
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   764
            [shown and:[realized]] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   765
                winGrp processExposeEventsFor:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   766
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   767
            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
   768
        ].
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   769
        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
   770
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   771
    ].
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   772
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   773
    (item notNil 
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   774
    and:[item showBusyCursorWhilePerforming
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   775
    and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]])
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   776
    ifTrue:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   777
        winGrp withWaitCursorDo:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   778
            value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   779
        ]
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   780
    ] ifFalse:[
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   781
        value := self accept:item index:itemIdx toggle:tgState receiver:recv.
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   782
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   783
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   784
    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
   785
        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
   786
        self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   787
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   788
    ^ item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   789
1212
9bd3220c9964 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1211
diff changeset
   790
    "Modified: / 22.2.1999 / 20:14:48 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   791
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   792
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   793
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   794
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   795
    "
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   796
    |value argument numArgs isKindOfValueModel rec args arg2 
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   797
     app master fallBack|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   798
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   799
    anItem isNil ifTrue:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   800
	self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   801
      ^ nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   802
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   803
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   804
    self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   805
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   806
    (value := anItem value) isNil ifTrue:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   807
	^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   808
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   809
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   810
    (argument := anItem argument) isNil ifTrue:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   811
	argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   812
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   813
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   814
    value isSymbol ifFalse:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   815
	"/ a valueHolder or block
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   816
	(value respondsTo:#valueWithArguments:) ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   817
	     ^ value
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   818
	].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   819
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   820
	numArgs := value perform:#numArgs ifNotUnderstood:0.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   821
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   822
	numArgs == 0 ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   823
	    args := nil
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   824
	] ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   825
	    numArgs == 1 ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   826
		args := Array with:argument
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   827
	    ] ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   828
		args := Array with:argument with:self
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   829
	    ]
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   830
	].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   831
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   832
	value valueWithArguments:args.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   833
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   834
	self menuAdornmentAt:#hasPerformed put:true.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   835
      ^ anIndex
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   836
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   837
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   838
    aReceiver isNil ifTrue:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   839
	^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   840
    ].
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   841
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   842
    isKindOfValueModel := aReceiver isValueModel.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   843
    isKindOfValueModel ifTrue:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   844
	aReceiver value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   845
    ] ifFalse:[
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   846
	rec := aReceiver.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   847
	arg2 := self.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   848
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   849
	"/ support for ST80 style applications
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   850
	"/ (expecting the message to go to the application
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   851
	"/  if not understood by the view)
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   852
	"/ These expect the controller to be passed as argument.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   853
	"/ sigh.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   854
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   855
	(aReceiver isView
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   856
	and:[(aReceiver respondsTo:value) not
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   857
	and:[(app := aReceiver application) ~~ aReceiver
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   858
	and:[app notNil]]]) ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   859
	    rec := app.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   860
	    arg2 := aReceiver controller "/ the Views controller
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   861
	].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   862
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   863
	(numArgs := value numArgs) == 0 ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   864
	    args := nil
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   865
	] ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   866
	    numArgs == 1 ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   867
		args := Array with:argument
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   868
	    ] ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   869
		args := Array with:argument with:arg2
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   870
	    ]
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   871
	].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   872
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   873
	fallBack := 
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   874
	    [
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   875
		"/ mhmh - the receiver did not respond to that message;
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   876
		"/ if there is a master-application, try that one
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   877
		"/ (recursive)
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   878
		master := rec perform:#masterApplication ifNotUnderstood:nil.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   879
		master notNil ifTrue:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   880
		    rec := master.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   881
		    rec perform:value withArguments:args ifNotUnderstood:fallBack
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   882
		] ifFalse:[
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   883
		    self 
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   884
			error:'unimplemented (or error in) menu message: ' , value
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   885
			mayProceed:true
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   886
		].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   887
	    ].
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   888
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
   889
	rec perform:value withArguments:args ifNotUnderstood:fallBack.
420
ca
parents: 417
diff changeset
   890
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   891
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   892
    ^ value
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   893
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   894
    "Modified: / 19.2.2000 / 11:08:22 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   895
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   896
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   897
acceptItem:anItem inMenu:aMenu
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   898
    |tgState|
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   899
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
   900
    (anItem isNil or:[anItem hideMenuOnActivated]) ifTrue:[
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   901
        self topMenu accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   902
    ] ifFalse:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   903
        anItem canAccept ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   904
            tgState := anItem toggleIndication.
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   905
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   906
            self accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   907
                  index:(aMenu selectionIndex)
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   908
                 toggle:tgState 
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   909
               receiver:(aMenu receiver).
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   910
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   911
            aMenu do:[:el| el updateIndicators].
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   912
        ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   913
    ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   914
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   915
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   916
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   917
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   918
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   919
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   920
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   921
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   922
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   923
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   924
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   925
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   926
"/    |top|
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   927
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   928
"/    top := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   929
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   930
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   931
"/        ^ self topMenu menuAdornmentAt:#value.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   932
"/    ].
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   933
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   934
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   935
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   936
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   937
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   938
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   939
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   940
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   941
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   942
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   943
  ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   944
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   945
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   946
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   947
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   948
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   949
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   950
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   951
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   952
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   953
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   954
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   955
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   956
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   957
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   958
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   959
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   960
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   961
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   962
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   963
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   964
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   965
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   966
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   967
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   968
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   969
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   970
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   971
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   972
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   973
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   974
    self onEachPerform:#argument: 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
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   978
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   979
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   980
  ^ self itemAt:stringOrNumber do:[:el| el argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   981
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   982
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   983
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   984
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   985
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   986
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   987
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   988
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   989
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   990
    "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
   991
     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
   992
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   993
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   994
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   995
    "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
   996
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   997
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   998
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   999
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1000
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1001
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1002
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1003
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1004
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1005
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1006
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1007
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1008
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1009
	self mustRearrange.
388
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
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1014
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1015
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1016
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1017
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1018
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1019
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1020
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1021
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1022
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1023
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1024
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1025
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1026
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1027
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1028
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1029
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1030
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1031
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1032
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1033
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1034
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1035
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1036
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1037
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1038
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1039
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1040
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1041
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1042
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1043
1999
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1044
menuPerformer:anObject 
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1045
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1046
     from all submenus no specific receiver is defined ).
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1047
    "
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1048
    ^ self receiver:anObject
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1049
!
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1050
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1051
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1052
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1053
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1054
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1055
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1056
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1057
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1058
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1059
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1061
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1062
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1063
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1064
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1065
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1066
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1067
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1068
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1069
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1070
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1071
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1072
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1073
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1074
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1075
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1076
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1077
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1078
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1079
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1080
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1081
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1082
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1083
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1084
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1085
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1086
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1087
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1088
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1089
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1090
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1091
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1092
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1093
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1094
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1095
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1096
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1097
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1098
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1099
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1100
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1101
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1102
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1103
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1104
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1105
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1106
    "
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1107
    self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1108
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1110
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1111
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1112
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1113
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1114
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1115
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1116
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1117
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1118
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1119
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1120
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1121
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1122
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1123
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1124
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1125
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1126
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1127
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1128
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1129
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1130
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1131
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1132
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1133
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1134
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1135
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1136
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1137
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1138
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1139
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1140
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1141
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1142
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1143
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1144
!MenuPanel methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1145
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1146
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1147
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1148
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1149
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1150
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1151
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1152
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1153
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1154
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1155
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1156
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1157
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1158
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1159
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1160
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1161
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1162
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1163
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1164
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1165
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1166
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1167
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1168
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1169
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1170
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1171
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1172
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1173
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1174
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1175
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1176
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1177
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1178
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1179
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1180
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  1181
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1182
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1183
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1184
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1185
    enabled ~~ state ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1186
        enabled := state.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1187
        self invalidate.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1188
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1189
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1190
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1191
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1192
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1193
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1194
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1195
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1196
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1197
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1198
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1199
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1200
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1201
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1202
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1203
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1204
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1205
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1206
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1207
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1208
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1209
!MenuPanel methodsFor:'accessing-channels'!
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1210
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1211
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1212
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1213
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1214
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1215
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1216
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1217
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1218
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1219
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1220
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1221
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1222
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1223
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1224
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1225
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1226
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1227
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1228
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1229
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1230
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1231
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1232
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1233
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1234
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1235
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1236
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1237
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1238
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1239
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1240
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1241
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1242
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1243
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1244
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1245
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1246
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1247
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1248
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1249
!MenuPanel methodsFor:'accessing-color & font'!
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1250
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1251
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1252
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1253
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1254
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1255
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1256
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1257
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1258
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1259
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1260
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1261
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1262
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1263
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1264
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1265
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1266
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1267
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1268
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1269
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1270
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1271
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1272
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1273
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1274
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1275
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1276
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1277
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1278
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1279
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1280
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1281
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1282
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1283
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1284
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1285
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1286
    ^ButtonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1287
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1288
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1289
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1290
    "get the button edge style
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1291
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1292
    ^ButtonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1293
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1294
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1295
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1296
    "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
  1297
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1298
    ^ buttonEnteredBgColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1299
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1300
    "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
  1301
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1302
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1303
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1304
    "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
  1305
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1306
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1307
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1308
    "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
  1309
    "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
  1310
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1311
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1312
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1313
    "get the background drawing color used to half light button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1314
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1315
    ^buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1316
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1317
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1318
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1319
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1320
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1321
    ^buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1322
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1323
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1324
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1325
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1326
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1327
    ^buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1328
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1329
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1330
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1331
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1332
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1333
    ^ButtonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1334
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1335
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1336
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1337
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1338
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1339
    ^buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1340
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1341
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1342
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1343
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1344
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1345
  ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1346
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1347
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1348
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1349
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1350
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1351
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1352
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1353
        super font:(aFont onDevice:device).
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1354
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1355
        superMenu notNil ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1356
            self extent:(self preferredExtent)
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1357
        ].
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1358
        self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1359
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1360
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1361
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1362
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1363
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1364
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1365
  ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1366
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1367
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1368
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1369
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1370
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1371
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1372
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1373
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1374
    fgColor ~~ aColor ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1375
        fgColor := aColor onDevice:device.
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1376
        shown ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1377
            self invalidate "/ RepairNow:true
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1378
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1379
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1380
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1381
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1382
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1383
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1384
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1385
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1386
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1387
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1388
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1389
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1390
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1391
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1392
maxAbsoluteButtonLevel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1393
    "returns the maximum absolute button level; used to compute the preferred
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1394
     extent of a button
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1395
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1396
    |level|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1397
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1398
    level := (ButtonActiveLevel abs) max:(ButtonEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1399
  ^ level max:(ButtonPassiveLevel abs)
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1400
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1401
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1402
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1403
    "get the selection frame bright color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1404
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1405
    ^selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1406
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1407
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1408
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1409
    "get the selection frame dark color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1410
    "
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1411
    ^selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1412
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1413
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1414
setFont:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1415
    "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
  1416
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1417
    |currentFont|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1418
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1419
    (aFont notNil and:[aFont ~= font]) ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1420
        currentFont := font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1421
        super font:aFont.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1422
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1423
    ^ currentFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1424
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1425
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1426
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1427
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1428
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1429
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1430
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1431
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1432
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1433
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1434
!MenuPanel methodsFor:'accessing-dimensions'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1435
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1436
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1437
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1438
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1439
    (explicitExtent ~~ true) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1440
        ^ self preferredExtent y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1441
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1442
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1443
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1444
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1445
maxExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1446
    "CLAUS: returns the maximum extent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1447
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1448
    |x y|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1449
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1450
    device isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1451
        superMenu notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1452
            ^ superMenu maxExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1453
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1454
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1455
    y := device usableHeight - 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1456
    x := device usableWidth  - 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1457
  ^ x@y
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1458
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1459
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1460
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1461
    "compute and returns my preferred extent
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1462
    "
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1463
    |maxExtent usedExtent w|
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1464
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1465
    preferredExtent notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1466
        ^ preferredExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1467
    ].
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1468
    maxExtent  := self maxExtent.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1469
    usedExtent := self preferredExtentOfItems.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1470
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1471
    superView isNil ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1472
        "/ is standalone
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1473
        w := self menuAdornmentAt:#Width.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1474
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1475
        w notNil ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1476
            usedExtent x < w ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1477
                usedExtent := w @ usedExtent y.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1478
            ]
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1479
        ]
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1480
    ].
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1481
        
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1482
    ^ usedExtent min:maxExtent
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1483
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1484
    "Modified: / 10.10.2001 / 14:57:25 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1485
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1486
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1487
preferredExtentOfItems
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1488
    "compute and returns my preferred extent including all items
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1489
        !!!!!! changes have influence on method #rearrangeItems !!!!!!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1490
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1491
    |hasMenu shCtKey extent showAcc sck
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1492
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1493
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1494
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1495
     buttonInset "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1496
     labelInset  "{ Class:SmallInteger }"
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1497
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1498
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1499
    (size := items size) == 0 ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1500
        ^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1501
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1502
    buttonInset := 2 * (DefaultButtonItemSpace abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1503
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1504
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1505
        labelInset := 2 * (DefaultEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1506
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1507
        labelInset := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1508
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1509
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1510
    x := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1511
    y := 0.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1512
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1513
    self verticalLayout ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1514
        "/ HORIZONTAL LAYOUT
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1515
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1516
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1517
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1518
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1519
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1520
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1521
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1522
                
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1523
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1524
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1525
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1526
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1527
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1528
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1529
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1530
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1531
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1532
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1533
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1534
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1535
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1536
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1537
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1538
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1539
                x := eX + x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1540
                y := eY max:y.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1541
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1542
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1543
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1544
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1545
        shCtKey := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1546
        showAcc := MenuView showAcceleratorKeys == true.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1547
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1548
        x := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1549
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1550
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1551
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1552
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1553
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1554
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1555
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1556
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1557
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1558
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1559
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1560
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1561
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1562
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1563
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1564
                hasMenu ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1565
                    hasMenu := el hasSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1566
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1567
                (showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1568
                    shCtKey := shCtKey max:(sck widthOn:self)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1569
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1570
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1571
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1572
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1573
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1574
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1575
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1576
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1577
                y := eY + y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1578
                x := eX max:x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1579
            ].
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1580
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1581
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1582
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1583
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1584
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1585
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1586
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1587
                x := x + ShortcutKeyOffset 
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1588
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1589
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1590
"/ to have a small inset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1591
        y := y + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1592
"/        x := x + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1593
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1594
    x := x + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1595
    y := y + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1596
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1597
  ^ x @ y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1598
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1599
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1600
preferredWidth:aWidth
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1601
    self menuAdornmentAt:#Width put:aWidth.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1602
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1603
    "Created: / 10.10.2001 / 14:56:39 / cg"
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1604
!
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1605
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1606
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1607
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1608
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1609
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1610
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1611
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1612
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1613
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1614
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1615
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1616
!MenuPanel methodsFor:'accessing-interactors'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1617
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1618
iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1619
    iconIndicationDisabledOff isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1620
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1621
            iconIndicationDisabledOff := superMenu iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1622
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1623
            iconIndicationDisabledOff := self registerImageOnDevice:(self class iconIndicationDisabledOff)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1624
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1625
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1626
    ^ iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1627
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1628
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1629
iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1630
    iconIndicationDisabledOn isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1631
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1632
            iconIndicationDisabledOn := superMenu iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1633
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1634
            iconIndicationDisabledOn := self registerImageOnDevice:(self class iconIndicationDisabledOn)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1635
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1636
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1637
    ^ iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1638
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1639
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1640
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1641
    iconIndicationOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1642
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1643
            iconIndicationOff := superMenu iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1644
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1645
            iconIndicationOff := self registerImageOnDevice:(self class iconIndicationOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1646
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1647
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1648
    ^ iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1649
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1650
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1651
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1652
    iconIndicationOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1653
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1654
            iconIndicationOn := superMenu iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1655
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1656
            iconIndicationOn := self registerImageOnDevice:(self class iconIndicationOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1657
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1658
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1659
    ^ iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1660
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1661
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1662
iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1663
    iconRadioGroupDisabledOff isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1664
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1665
            iconRadioGroupDisabledOff := superMenu iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1666
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1667
            iconRadioGroupDisabledOff := self registerImageOnDevice:(self class iconRadioGroupDisabledOff)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1668
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1669
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1670
    ^ iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1671
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1672
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1673
iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1674
    iconRadioGroupDisabledOn isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1675
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1676
            iconRadioGroupDisabledOn := superMenu iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1677
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1678
            iconRadioGroupDisabledOn := self registerImageOnDevice:(self class iconRadioGroupDisabledOn)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1679
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1680
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1681
    ^ iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1682
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1683
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1684
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1685
    iconRadioGroupOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1686
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1687
            iconRadioGroupOff := superMenu iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1688
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1689
            iconRadioGroupOff := self registerImageOnDevice:(self class iconRadioGroupOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1690
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1691
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1692
    ^ iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1693
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1694
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1695
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1696
    iconRadioGroupOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1697
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1698
            iconRadioGroupOn := superMenu iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1699
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1700
            iconRadioGroupOn := self registerImageOnDevice:(self class iconRadioGroupOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1701
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1702
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1703
    ^ iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1704
! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1705
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1706
!MenuPanel methodsFor:'accessing-items'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1707
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1708
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1709
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1710
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1711
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1712
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1713
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1714
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1715
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1716
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1717
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1718
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1719
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1720
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1721
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1722
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1723
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1729
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1730
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1731
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1732
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1733
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1734
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1735
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1736
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1737
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1738
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1739
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1740
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1741
    ^ 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
  1742
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1743
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1744
items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1745
    "returns list of items or nil
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1746
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1747
    ^ items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1748
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1749
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1750
!MenuPanel methodsFor:'accessing-look'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1751
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1752
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1753
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1754
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1755
    ^ButtonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1756
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1757
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1758
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1759
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1760
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1761
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1762
    ^ButtonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1763
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1764
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1765
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1766
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1767
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1768
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1769
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1770
     NOT SUPPORTED
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1771
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1772
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1773
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1774
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1775
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1776
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1777
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1778
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1779
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1780
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1781
    fitFirstPanel := aState.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1783
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1784
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1785
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1786
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1787
  ^ groupDividerSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1788
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1789
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1790
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1791
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1792
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1793
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1794
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1795
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1796
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1797
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1798
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1799
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1800
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1801
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1802
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1803
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1804
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1805
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1806
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1807
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1808
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1809
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1810
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1811
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1812
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1813
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1814
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1815
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1816
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1817
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1818
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1819
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1820
level:anInt
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1821
    anInt ~~ level ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1822
        super level:anInt.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1823
        mustRearrange := true
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1824
    ]
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1825
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1826
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1827
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1828
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1829
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1830
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1831
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1832
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1833
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1834
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1835
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1836
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1837
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1838
  ^ (self menuAdornmentAt:#showGroupDivider)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1839
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1840
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1841
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1842
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1843
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1844
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1845
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1846
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1847
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1848
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1849
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1850
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1851
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1852
  ^ (self menuAdornmentAt:#showSeparatingLines)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1853
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1854
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1855
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1856
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1857
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1858
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1859
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1860
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1861
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1862
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1863
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1864
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1865
    "
1824
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1866
    |direction|
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1867
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1868
    direction := self menuAdornmentAt:#verticalLayout.
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1869
  ^ direction notNil ifTrue:[direction] ifFalse:[superMenu notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1870
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1871
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1872
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1873
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1874
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1875
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1876
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1877
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1878
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1879
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1880
!MenuPanel methodsFor:'accessing-submenu'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1881
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1882
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1883
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1884
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1885
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1886
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1887
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1888
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1889
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1890
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1891
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1892
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1893
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1894
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1895
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1896
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1897
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1898
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1899
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1900
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1901
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1902
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1903
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1904
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1905
1698
8d29156bab20 category rename
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1906
!MenuPanel methodsFor:'activation / deactivation'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1907
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1908
closeMenus
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1909
    "close all menus; operation is done; nothing accepted
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1910
    "
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1911
    self topMenu accept:nil.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1912
!
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1913
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1914
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1915
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1916
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1917
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1918
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1919
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1920
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1921
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1922
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1923
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1924
show
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1925
    "realize the view at its last position;
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1926
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1927
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1928
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1929
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1930
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1931
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1932
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1933
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1934
showAt:aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1935
    "realize the view at aPoint.
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1936
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1937
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1938
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1939
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1940
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1941
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1942
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1943
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1944
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1945
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1946
    "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
  1947
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1948
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1949
     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
  1950
     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
  1951
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1952
    "
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1953
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1954
    self rearrangeItemsIfItemVisibilityChanged.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1955
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
    aBoolean ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1957
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1958
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1959
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1960
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1961
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1962
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1963
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1964
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1965
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1966
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1967
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1968
    ].
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1969
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1970
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1971
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1972
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1973
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1974
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1975
showAtPointer
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1976
    "realize the view at the current pointer position.
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1977
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1978
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1979
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1980
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1981
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1982
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1983
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1984
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1985
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1986
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1987
    "make myself visible at the screen center.
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1988
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1989
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1990
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1991
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1992
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1993
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1994
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1995
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1996
    ^ 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
  1997
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1998
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1999
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2000
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2001
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2002
    "realize the menu at the current pointer position
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2003
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2004
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2005
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2006
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2007
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2008
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2009
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2010
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2011
    "realize the menu at aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2012
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2013
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2014
      to some performer)
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2015
    "
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2016
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2017
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2018
    "Created: / 21.5.1998 / 14:15:57 / cg"
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2019
!
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2020
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2021
startUpOrNil
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2022
    "realize the menu at the current pointer position
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2023
     return the value of the selectedItem or nil, of none was selected
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2024
     (unless the menu has already performed its action, by sending an appropriate message
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2025
      to some performer)
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2026
    "
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2027
    ^ self showAtPointer
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2028
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2029
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2030
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2031
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2032
createAtIndex:anIndexOrNil
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2033
    "create an item and add this item to the index. In case of nil, the item
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2034
     is added to the end. If the index is not valid nil is returned;
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2035
     otherwise the new created item is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2036
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2037
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2038
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2039
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2040
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2041
    anIndexOrNil notNil ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2042
        (anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2043
            ^ nil
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2044
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2045
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2046
    items isNil ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2047
        items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  2048
    ] ifFalse:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2049
        items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2050
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2051
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2052
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2053
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2054
        items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2055
    ] ifFalse:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2056
        items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2057
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2058
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2059
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2060
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2061
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2062
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2063
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2064
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2065
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2066
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2067
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2068
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2069
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2070
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2071
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2072
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2073
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2074
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2075
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2076
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2077
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2078
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2079
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2080
	self selection:nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2081
	groupSizes := nil.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2082
	self do:[:el| el destroy ].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2083
	items := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2084
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2085
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2086
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2087
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2088
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2089
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2090
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2091
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2092
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2093
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2094
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2095
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2096
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2097
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2098
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2099
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2100
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2101
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2102
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2103
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2104
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2105
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2106
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2107
  ^ menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2108
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2109
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2110
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2111
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2112
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2113
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2116
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2117
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2118
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2119
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2120
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2121
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2122
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2123
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2124
    self disabledRedrawDo:[
1666
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2125
        |menu newItems|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2126
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2127
        self removeAll.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2128
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2129
        (menu := aMenu) notNil ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2130
            (aMenu isCollection) ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2131
                menu := Menu new.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2132
                menu fromLiteralArrayEncoding:aMenu.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2133
            ] ifFalse:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2134
                menu receiver notNil ifTrue:[receiver := menu receiver]
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2135
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2136
            (newItems := menu menuItems) size > 0 ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2137
                items := newItems collect:[:ni | 
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2138
                                |i|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2139
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2140
                                i:= Item in:self.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2141
                                i menuItem:ni.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2142
                                i.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2143
                            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2144
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2145
            self groupSizes:(menu groupSizes).
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2146
        ]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2147
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2148
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2149
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2150
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2151
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2152
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2153
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2154
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2155
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2156
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2157
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2158
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2159
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2160
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2161
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2162
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2163
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2164
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2165
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2166
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2167
drawButtonEdgesFor:anItem level:aLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2168
    |layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2169
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2170
    aLevel ~~ 0 ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2171
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2172
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2173
        styleSheet is3D ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2174
            self displayRectangle:layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2175
        ] ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2176
            self drawEdgesForX:(layout left)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2177
                             y:(layout top)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2178
                         width:(layout width)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2179
                        height:(layout height)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2180
                         level:aLevel 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2181
                        shadow:buttonShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2182
                         light:buttonLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2183
                    halfShadow:buttonHalfShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2184
                     halfLight:buttonHalfLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2185
                         style:ButtonEdgeStyle
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2186
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2187
    ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2188
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2189
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2190
drawItemsX:x y:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2191
    "redraw items and groups in a damage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2192
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2193
    |isVertical item layout prevClip
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2194
     x1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2195
     x2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2196
     y1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2197
     y2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2198
     start          "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2199
     stop           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2200
     size           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2201
     groupDivInset  "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2202
    |
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2203
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2204
    size := items size.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2205
    isVertical := self verticalLayout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2206
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2207
    isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2208
        start := items findFirst:[:el| el layout bottom > y ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2209
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2210
        y1 := y + h.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2211
        stop := items findFirst:[:el| el layout top > y1 ] startingAt:(start + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2212
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2213
        start := items findFirst:[:el| el layout right > x ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2214
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2215
        x1  := x + w.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2216
        stop := items findFirst:[:el| el layout left > x1] startingAt:(start + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2217
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2218
    stop  == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2219
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2220
    (groupSizes size ~~ 0 and:[self showGroupDivider]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2221
        groupDivInset := groupDividerSize // 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2222
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2223
        groupDivInset ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2224
            (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2225
                start := start - 1
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2226
            ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2227
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2228
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2229
        groupDivInset := 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2230
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2231
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2232
    prevClip := clipRect.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2233
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2234
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2235
    start to:stop do:[:i|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2236
        item := items at:i.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2237
        item redraw.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2238
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2239
        (groupDivInset ~~ 0 and:[i ~~ size and:[self hasGroupDividerAt:i]]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2240
            layout := item layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2241
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2242
            isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2243
                x1 := layout left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2244
                x2 := layout right.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2245
                y1 := layout bottom + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2246
                y2 := y1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2247
            ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2248
                y1 := layout top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2249
                y2 := layout bottom.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2250
                x1 := layout right + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2251
                x2 := x1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2252
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2253
            self paint:shadowColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2254
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2255
            self paint:lightColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2256
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2257
            isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2258
                      ifFalse:[x1 := x1 + 1. x2 := x1 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2259
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2260
            self displayLineFromX:x1 y:y1 toX:x2 y:y2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2261
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2262
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2263
    self clippingRectangle:prevClip.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2264
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2265
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2266
drawLabelEdgeFor:anItem selected:isSelected
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2267
    |level layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2268
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2269
    isSelected ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2270
        level := onLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2271
    ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2272
        anItem == enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2273
            level := DefaultEnteredLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2274
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2275
            level := offLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2276
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2277
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2278
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2279
    level ~~ 0 ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2280
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2281
1691
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2282
        self drawEdgesForX:(layout left)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2283
                         y:(layout top)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2284
                     width:(layout width)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2285
                    height:(layout height)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2286
                     level:level
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2287
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2288
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2289
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2290
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2291
drawScrollerAt:aDirection bounds:bounds
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2292
    "draw a scroller
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2293
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2294
    |scrolling icon level x y w h|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2295
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2296
    x := bounds left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2297
    y := bounds top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2298
    w := bounds width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2299
    h := bounds height.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2300
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2301
    scrolling := self scrolling.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2302
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2303
    (scrolling activeMenu == self and:[scrolling direction == aDirection]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2304
        level := -2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2305
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2306
        level := 1
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2307
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2308
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2309
    level ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2310
        self drawEdgesForX:x y:y width:w height:h level:level.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2311
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2312
    icon := scrolling iconAt:aDirection on:self.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2313
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2314
    icon displayOn:self x:(x + (w - icon width  // 2))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2315
                        y:(y + (h - icon height // 2)).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2316
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2317
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2318
invalidateItem:anItem repairNow:aBool
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2319
    "an item changed; invalidate the items layout
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2320
    "
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2321
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2322
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2323
    (mustRearrange not and:[shown]) ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2324
        layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2325
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2326
        (layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2327
            self invalidate:(layout copy insetBy:-1) repairNow:aBool
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2328
        ]
1728
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2329
    ].
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2330
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2331
    "Modified: / 29.2.2000 / 11:28:59 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2332
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2333
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2334
invalidateX:x y:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2335
    "add a damage to redraw part of the view
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2336
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2337
    shown ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2338
        self invalidate:(Rectangle left:x top:y width:w height:h) 
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2339
              repairNow:false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2340
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2341
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2342
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2343
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  2344
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2345
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  2346
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2347
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2348
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2349
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2350
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2351
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  2352
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2353
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2354
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2355
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2356
rearrangeGroups
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2357
    "implements the groupIdentifier #right in a horizontal menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2358
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2359
    |layout point
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2360
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2361
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2362
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2363
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2364
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2365
        ^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2366
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2367
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2368
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2369
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2370
    (dltX := width - margin - layout right) <= 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2371
        ^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2372
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2373
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2374
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2375
    start == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2376
        ^ self  "/ no item detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2377
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2378
    point := dltX @ 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2379
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2380
    "/ move items layout to right
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2381
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2382
    items from:start do:[:anItem|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2383
        anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2384
            anItem layout moveBy:point.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2385
        ]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2386
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2387
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2388
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2389
rearrangeItems
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2390
    "recompute the layout of each item
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2391
        !!!!!! changes have influence on method #preferredExtentOfItems !!!!!!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2392
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2393
    |isVertical extent isPopUpMenu
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2394
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2395
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2396
     x0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2397
     y0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2398
     x1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2399
     y1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2400
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2401
     inset       "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2402
     labelInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2403
     buttonInset "{ Class:SmallInteger }"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2404
    |
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2405
    (mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2406
        mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2407
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2408
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2409
    mustRearrange := false.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2410
    isVertical  := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2411
    buttonInset := DefaultButtonItemSpace abs.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2412
    isPopUpMenu := self isPopUpView.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2413
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2414
    isPopUpMenu ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2415
        labelInset := DefaultEnteredLevel abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2416
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2417
        labelInset := 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2418
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2419
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2420
    (isPopUpMenu or:[explicitExtent ~~ true]) ifTrue:[ |savExt maxExt|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2421
        savExt := extent := self preferredExtent copy.
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2422
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2423
        isPopUpMenu ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2424
            isVertical ifTrue:[extent y:1.0] ifFalse:[extent x:1.0]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2425
        ] ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2426
            savExt := extent copy.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2427
            maxExt := self maxExtent.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2428
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2429
            isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2430
                extent y:(extent y min:(maxExt y))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2431
            ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2432
                extent x:(extent x min:(maxExt x))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2433
            ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2434
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2435
        self extent:extent.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2436
        extent := savExt.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2437
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2438
        extent := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2439
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2440
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2441
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2442
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2443
    isVertical ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2444
        y0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2445
        y1 := extent y - margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2446
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2447
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2448
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2449
                el layout:(Rectangle left:x top:y0 right:x bottom:y1)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2450
            ] ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2451
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2452
                    inset := DefaultButtonItemSpace
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2453
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2454
                    inset := labelInset
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2455
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2456
                x0 := x  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2457
                x1 := x0 + el preferredExtent x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2458
                el layout:(Rectangle left:x0 top:(y0 + inset) right:x1 bottom:(y1 - inset)).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2459
                x := x1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2460
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2461
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2462
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2463
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2464
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2465
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2466
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2467
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2468
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2469
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2470
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2471
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2472
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2473
        x0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2474
        x1 := extent x - margin.  "/ -1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2475
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2476
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2477
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2478
                el layout:(Rectangle left:x0 top:y right:x1 bottom:y)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2479
            ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2480
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2481
                    inset := DefaultButtonItemSpace
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2482
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2483
                    inset := labelInset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2484
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2485
                y0 := y  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2486
                y1 := y0 + el preferredExtent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2487
                el layout:(Rectangle left:(x0 + inset) top:y0 right:(x1 - inset) bottom:y1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2488
                y := y1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2489
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2490
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2491
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2492
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2493
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2494
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2495
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2496
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2497
            ]
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2498
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2499
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2500
    self rearrangeGroups.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2501
    self makeItemVisible:selection.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2502
    mustRearrange := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2503
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2504
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2505
rearrangeItemsIfItemVisibilityChanged
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2506
    "check for items which can change its visibility;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2507
     if at least one item exists, rearrange all items
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2508
    "
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2509
    items isNil ifTrue:[^ self].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2510
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2511
    items do:[:item |
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2512
        item canChangeVisibility ifTrue:[
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2513
            mustRearrange := true.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2514
            self rearrangeItems.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2515
            ^ self
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2516
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2517
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2518
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2519
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2520
redrawX:x y:y width:w height:h
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2521
    "redraw a damage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2522
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2523
    |y0 y1 x0 x1 bounds|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2524
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2525
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2526
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2527
    mustRearrange ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2528
        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
  2529
        self rearrangeItems.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2530
      ^ self invalidate
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2531
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2532
    self paint:(self backgroundColor).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2533
    self clearRectangleX:x y:y width:w height:h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2534
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2535
    items size == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2536
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2537
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2538
    y0 := y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2539
    y1 := y + h.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2540
    x0 := x.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2541
    x1 := x + w.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2542
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2543
    self hasScrollers ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2544
        (self hasScrollerAt:#PREV) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2545
            bounds := self scrollerBoundsAt:#PREV.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2546
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2547
            self verticalLayout ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2548
                bounds bottom > y ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2549
                    y0 := bounds bottom.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2550
                    self drawScrollerAt:#PREV bounds:bounds.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2551
                ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2552
            ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2553
                bounds right > x ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2554
                    x0 := bounds right.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2555
                    self drawScrollerAt:#PREV bounds:bounds.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2556
                ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2557
            ]
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2558
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2559
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2560
        (self hasScrollerAt:#NEXT) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2561
            bounds := self scrollerBoundsAt:#NEXT.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2562
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2563
            self verticalLayout ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2564
                bounds top < y1 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2565
                    y1 := bounds top.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2566
                    self drawScrollerAt:#NEXT bounds:bounds.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2567
                ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2568
            ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2569
                bounds left < x1 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2570
                    x1 := bounds left.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2571
                    self drawScrollerAt:#NEXT bounds:bounds.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2572
                ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2573
            ]
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2574
        ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2575
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2576
    (y1 > y0 and:[x1 > x0]) ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2577
        self drawItemsX:x0 y:y0 width:(x1 - x0) height:(y1 - y0)
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2578
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2579
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2580
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2581
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2582
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2583
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2584
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2585
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2586
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2587
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2588
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2589
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2590
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2591
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2592
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2593
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2594
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2595
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2596
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2597
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2598
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2599
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2600
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2601
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2602
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2603
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2604
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2605
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2606
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2607
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2608
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2609
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2610
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2611
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2612
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2613
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2614
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2615
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2616
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2617
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2618
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2619
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2620
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2621
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2622
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2623
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2624
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2625
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2626
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2627
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2628
    i ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2629
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2630
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2631
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2632
    something isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2633
	i := self findFirst:[:el|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2634
				v := el value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2635
				v isSymbol and:[v == something]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2636
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2637
	i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2638
	    ^ i
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2639
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2640
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2641
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2642
    (something respondsTo:#string) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2643
	v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2644
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2645
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2646
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2647
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2648
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2649
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2650
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2651
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2652
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2653
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2654
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2655
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2656
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2657
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2658
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2659
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2660
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2661
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2662
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2663
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2664
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2665
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2666
    "
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2667
    |menue motionPoint translatedPoint sensor|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2668
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2669
    self scrolling isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2670
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2671
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2672
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2673
    sensor := self sensor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2674
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2675
    (sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2676
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2677
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2678
    menue := self detectGrabMenu.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  2679
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2680
    motionPoint := x@y.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2681
    translatedPoint := menue translateGrabPoint:motionPoint.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2682
    menue handleButtonMotion:state x:(translatedPoint x) y:(translatedPoint y).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2683
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2684
    (self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2685
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2686
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2687
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2688
    (selection notNil and:[selection visibleSubmenu isNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2689
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2690
        (self containsPoint:motionPoint) ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2691
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2692
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2693
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2694
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2695
    "Modified: / 13.11.2001 / 14:00:33 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2696
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2697
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2698
buttonPress:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2699
    "any button pressed; open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2700
    "
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2701
    |menu point|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2702
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2703
    self scrolling stop.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2704
"/    self scrolling inspect.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2705
    point := x@y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2706
    menu  := self detectMenuAtGrabPoint:point.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2707
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2708
    menu isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2709
        self accept:nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2710
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2711
        point := menu translateGrabPoint:point.
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2712
        menu handleButtonPressAtPoint:point.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2713
    ]
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2714
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2715
    "Modified: / 13.11.2001 / 14:12:32 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2716
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2717
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2718
buttonRelease:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2719
    "button release action; accept selection and close all views
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2720
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2721
    |topMenu dstMenu item srcPoint dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2722
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2723
    self scrolling stop ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2724
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2725
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2726
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2727
    topMenu := self topMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2728
    dstMenu := topMenu activeMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2729
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2730
    (    dstMenu selection notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2731
     or:[dstMenu isPopUpView not
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2732
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2733
         and:(dstMenu mapTime)) > 400]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2734
    ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2735
        srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2736
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2737
        (     (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2738
         and:[(item    := dstMenu selection) notNil]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2739
        ) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2740
            item visibleSubmenu notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2741
                dstMenu selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2742
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2743
                (selection isNil and:[self isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2744
                    self accept:nil
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2745
                ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2746
            ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2747
                item currentSubmenu isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2748
                    dstPoint := dstMenu translateGrabPoint:srcPoint.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2749
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2750
                    (dstMenu itemAtX:(dstPoint x) y:(dstPoint y)) == dstMenu selection ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2751
                        item := nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2752
                    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2753
                    topMenu acceptItem:item inMenu:dstMenu.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2754
                ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2755
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2756
            ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2757
        ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2758
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2759
        (selection notNil and:[dstMenu == self]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2760
            selection visibleSubmenu notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2761
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2762
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2763
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2764
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2765
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2766
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2767
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2768
keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2769
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2770
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2771
    |menu rawKey|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2772
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2773
    self scrolling isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2774
        key ~~ #Escape ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2775
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2776
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2777
        self scrolling stop
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2778
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2779
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2780
       (key == #Tab 
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2781
    or:[key == #FocusNext
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2782
    or:[key == #FocusPrevious]]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2783
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2784
      ^ super keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2785
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2786
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2787
    menu := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2788
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2789
    key == #Escape ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2790
        "/ must hide the active menu
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2791
        ((menu := menu superMenu) notNil and:[menu ~~ self]) ifTrue:[
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2792
            "/ hide active menu but keep the grab
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2793
            menu selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2794
        ] ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2795
            "/ hide active menu and ungrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2796
            self accept:nil
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2797
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2798
    ] ifFalse:[
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2799
        menu isViewWrapper ifFalse:[
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2800
            self sensor compressKeyPressEventsWithKey:key.
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2801
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2802
            menu handleKeyPress:key.
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2803
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2804
"/            selection isNil ifTrue:[
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2805
"/                self accept:nil keepValue:true
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2806
"/            ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2807
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2808
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2809
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2810
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2811
pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2812
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2813
    self scrolling isActive ifTrue:[^ self].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2814
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2815
    self detectGrabMenu handlePointerLeave:state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2816
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2817
    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2818
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2819
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2820
    (selection notNil and:[selection hasSubmenu not]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2821
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2822
        self sensor anyButtonPressed ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2823
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2824
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2825
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2826
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2827
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2828
sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2829
    "redraw #right groups
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2830
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2831
    self isPopUpView ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2832
        mustRearrange := true.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2833
        shown ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2834
            self invalidate
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2835
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2836
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2837
    super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2838
! !
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2839
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2840
!MenuPanel methodsFor:'event handling processing'!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2841
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2842
clearImplicitGrab
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2843
    self menuAdornmentAt:#implicitGrabView put:nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2844
    self menuAdornmentAt:#lastPointerView  put:nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2845
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2846
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2847
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2848
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2849
dispatchEvent:ev withFocusOn:focusView delegate:doDelegate
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2850
    "dispatch and handle an event
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2851
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2852
    |view x y p syntheticEvent implicitGrabView lastPointerView menu|
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2853
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2854
    implicitGrabView := self menuAdornmentAt:#implicitGrabView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2855
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2856
    "/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2857
    "/ but never get the buttonRelease, since someone else (a popUp) grabbed the
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2858
    "/ pointer in the meantime, and has eaten the release event ... (double-sigh)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2859
    implicitGrabView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2860
        self sensor leftButtonPressed ifFalse:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2861
            self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2862
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2863
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2864
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2865
    ((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2866
        ^ super dispatchEvent:ev withFocusOn:focusView delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2867
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2868
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2869
    implicitGrabView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2870
        ev isButtonEvent ifTrue:[
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2871
            p := device translatePoint:(x@y) fromView:self toView:implicitGrabView.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2872
            ev view:implicitGrabView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2873
            ev arguments at:2 put:p x.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2874
            ev arguments at:3 put:p y.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2875
            implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2876
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2877
            ev isButtonReleaseEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2878
                self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2879
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2880
            ^ self
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2881
        ]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2882
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2883
    menu := self detectMenuAtGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2884
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2885
    (menu isNil or:[menu isViewWrapper not]) ifTrue:[
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2886
        self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2887
      ^ super dispatchEvent:ev withFocusOn:focusView delegate:false
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2888
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2889
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2890
    p    := menu translateGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2891
    view := self detectViewAtX:(p x) y:(p y) in:menu.
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2892
    p    := device translatePoint:(x@y) fromView:self toView:view.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2893
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2894
    ev isButtonPressEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2895
        (view wantsFocusWithButtonPress) ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2896
            view requestFocus.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2897
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2898
        view ~~ self ifTrue:[ "/ can this ever be self ?
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2899
            self menuAdornmentAt:#implicitGrabView put:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2900
        ]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2901
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2902
    lastPointerView := self menuAdornmentAt:#lastPointerView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2903
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2904
    ev isButtonMotionEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2905
        lastPointerView ~~ view ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2906
            "/ must generate enter/leave ... (sigh)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2907
            lastPointerView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2908
                syntheticEvent := WindowEvent inputEvent
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2909
                                     for:lastPointerView
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2910
                                     type:#pointerLeave:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2911
                                     arguments:(Array with:0).   "/ XXX: should be fixed
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2912
                lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2913
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2914
            view notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2915
                syntheticEvent := WindowEvent inputEvent
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2916
                                     for:view
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2917
                                     type:#pointerEnter:x:y:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2918
                                     arguments:(Array with:0 with:x with:y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2919
                view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2920
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2921
            self menuAdornmentAt:#lastPointerView put:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2922
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2923
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2924
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2925
    ev view:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2926
    ev x:p x.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2927
    ev y:p y.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2928
    view dispatchEvent:ev withFocusOn:focusView delegate:false.
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2929
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2930
    "Modified: / 10.10.2001 / 13:54:47 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2931
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2932
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2933
handleButtonMotion:state x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2934
    "open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2935
    "
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2936
    |motionPoint menu translatedPoint sel|
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2937
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2938
    motionPoint := x @ y.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2939
1910
119f91172b70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  2940
    (state == 0 or:[self sensor anyButtonPressed not]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2941
        "/ highlight enterItem if no selection exists
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2942
        selection isNil ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2943
            (self containsPoint:motionPoint) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2944
                ((sel := self itemAtPoint:motionPoint) isNil or:[sel canSelect not]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2945
                    ^ self pointerEntersItem:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2946
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2947
                (DefaultSelectionFollowsMouse and:[superMenu notNil]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2948
                    self openMenuOnSelect:true.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2949
                    self selection:sel.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2950
                    self openMenuOnSelect:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2951
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2952
                    self pointerEntersItem:sel
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2953
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2954
                ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2955
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2956
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2957
        self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2958
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2959
        (DefaultSelectionFollowsMouse and:[(menu := self superMenuAtX:x y:y) notNil]) ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2960
            translatedPoint := self translateMenuPoint:motionPoint toMenu:menu.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2961
            sel   := menu itemAtPoint:translatedPoint.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2962
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2963
            (sel notNil and:[sel canSelect]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2964
                menu openMenuOnSelect:true.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2965
                menu selection:sel.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2966
                menu openMenuOnSelect:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2967
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2968
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2969
      ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2970
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2971
    self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2972
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2973
    (menu := self superMenuAtX:x y:y) isNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2974
        self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2975
            self selection:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2976
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2977
        ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2978
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2979
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2980
    menu == self ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2981
        (sel := self itemAtPoint:motionPoint) notNil ifTrue:[
1787
9bc818c591a9 buttonMotion: open menu if button pressed
ca
parents: 1786
diff changeset
  2982
            self openMenuOnSelect:true.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2983
            self selection:sel.
1787
9bc818c591a9 buttonMotion: open menu if button pressed
ca
parents: 1786
diff changeset
  2984
            self openMenuOnSelect:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2985
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2986
    ] ifFalse:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2987
        translatedPoint := self translateMenuPoint:motionPoint toMenu:menu.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2988
        sel   := menu itemAtPoint:translatedPoint.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2989
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2990
        (sel isNil and:[menu isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2991
            sel := menu selection.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2992
        ].
1787
9bc818c591a9 buttonMotion: open menu if button pressed
ca
parents: 1786
diff changeset
  2993
        menu openMenuOnSelect:true.
9bc818c591a9 buttonMotion: open menu if button pressed
ca
parents: 1786
diff changeset
  2994
        menu selection:sel.
9bc818c591a9 buttonMotion: open menu if button pressed
ca
parents: 1786
diff changeset
  2995
        menu openMenuOnSelect:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2996
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2997
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2998
    "Modified: / 13.11.2001 / 14:04:26 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2999
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3000
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3001
handleButtonPressAtPoint:aPoint
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3002
    "a button pressed; open or close the corresponding submenus
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3003
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3004
    |item sensor yS direction|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3005
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3006
    item := self itemAtPoint:aPoint.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3007
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3008
    item notNil ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3009
        direction := self scrollerDirectionAtPoint:aPoint.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3010
        (self scrolling startAt:direction on:self) ifTrue:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  3011
            self pointerEntersItem:nil.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3012
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3013
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3014
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3015
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3016
    self openMenuOnSelect:true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3017
    self selection:item.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3018
    self openMenuOnSelect:nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3019
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3020
    (     item notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3021
     and:[item triggerOnDown
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3022
     and:[item canAccept
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3023
     and:[item == self selection]]]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3024
    ) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3025
        self invalidateItem:item repairNow:true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3026
        self acceptItem:item inMenu:self.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3027
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3028
        self selection == item ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3029
            (sensor := self sensor) notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3030
                [sensor anyButtonPressed] whileTrue:[ Delay waitForSeconds:0.1 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3031
                sensor flushUserEvents.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3032
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3033
            self selection:nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3034
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3035
    ].
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3036
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3037
    "Created: / 13.11.2001 / 14:12:04 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3038
    "Modified: / 13.11.2001 / 14:13:26 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3039
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3040
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3041
handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3042
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3043
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3044
    |next menu item isVrt backKey p1 p2
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3045
     idx   "{ Class:SmallInteger }"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3046
     size  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3047
    |
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3048
    (size  := items size) == 0 ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3049
        superMenu notNil ifTrue:[superMenu handleCursorKey:aKey].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3050
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3051
    ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3052
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3053
    isVrt := self verticalLayout.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3054
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3055
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3056
    (    (isVrt     and:[aKey == #CursorUp    or:[aKey == #CursorDown]])
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3057
     or:[(isVrt not and:[aKey == #CursorRight or:[aKey == #CursorLeft]])]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3058
    ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3059
        selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3060
            (superMenu notNil and:[superMenu verticalLayout == isVrt]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3061
                ^ superMenu handleCursorKey:aKey
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3062
            ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3063
            idx := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3064
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3065
            isVrt ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3066
                "/ used because of vertical scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3067
                idx := items findFirst:[:el| el layout top > 0 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3068
                idx ~~ 0 ifTrue:[idx := idx := idx - 1 ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3069
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3070
        ] ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3071
            idx := self indexOf:selection.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3072
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3073
        next := aKey == #CursorRight or:[aKey == #CursorDown].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3074
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3075
        size timesRepeat:[|el|
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3076
            next ifTrue:[(idx := idx + 1) > size ifTrue:[idx := 1]]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3077
                ifFalse:[(idx := idx - 1) < 1    ifTrue:[idx := size]].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3078
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3079
            (el := items at:idx ifAbsent:nil) notNil ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3080
                el canSelect ifTrue:[^ self selection:el].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3081
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3082
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3083
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3084
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3085
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3086
    superMenu notNil ifTrue:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3087
        p1 := self translateGrabPoint:0.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3088
        p2 := superMenu translateGrabPoint:0.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3089
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3090
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3091
    isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3092
        (superMenu notNil and:[p1 x > p2 x]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3093
            backKey := #CursorRight
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3094
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3095
            backKey := #CursorLeft.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3096
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3097
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3098
        (superMenu notNil and:[p1 y > p2 y]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3099
            backKey := #CursorDown
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3100
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3101
            backKey := #CursorUp.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3102
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3103
    ].    
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3104
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3105
    aKey == backKey ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3106
        superMenu isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3107
            self accept:nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3108
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3109
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3110
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3111
            ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3112
                superMenu selection hideSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3113
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3114
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3115
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3116
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3117
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3118
    selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3119
        superMenu isNil ifTrue:[^ self accept:nil].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3120
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3121
        superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3122
            superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3123
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3124
            (item := items findFirst:[:el| el canSelect]) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3125
                self selection:item
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3126
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3127
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3128
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3129
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3130
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3131
    selection hasSubmenu ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3132
        (menu := selection visibleSubmenu) isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3133
            selection toggleSubmenuVisibility
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3134
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3135
            menu selectionIndex:1
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3136
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3137
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3138
        superMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3139
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3140
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3141
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3142
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3143
            self accept:nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3144
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3145
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3146
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3147
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3148
handleKeyPress:key
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3149
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3150
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3151
    |item inMenu rawKey|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3152
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3153
    (key == #Return or:[key == Character space]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3154
        self handleReturnPressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3155
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3156
        key isCharacter ifTrue:[
1862
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3157
"/            selection notNil ifTrue:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3158
"/                inMenu := self
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3159
"/            ] ifFalse:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3160
"/                (inMenu := superMenu) isNil ifTrue:[^ self].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3161
"/            ].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3162
            inMenu := self.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3163
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3164
            (item := inMenu detectItemForKey:key) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3165
                inMenu selection:item
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3166
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3167
        ] ifFalse:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3168
            (     key == #CursorDown or:[key == #CursorUp
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3169
              or:[key == #CursorLeft or:[key == #CursorRight]]]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3170
            ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3171
                self handleCursorKey:key
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3172
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3173
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3174
    ]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3175
!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3176
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3177
handlePointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3178
    self  pointerEntersItem:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3179
    super pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3180
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3181
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3182
handleReturnPressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3183
    "any key is pressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3184
    "
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3185
    |sensor|
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3186
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3187
    selection isNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3188
        superMenu notNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3189
            superMenu selection toggleSubmenuVisibility
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3190
        ] ifFalse:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3191
            self accept
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3192
        ].
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3193
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3194
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3195
    selection hasSubmenu ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3196
        ^ selection toggleSubmenuVisibility
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3197
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3198
    self accept.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3199
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3200
    (selection notNil and:[selection triggerOnDown]) ifFalse:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3201
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3202
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3203
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3204
    (sensor := self sensor) isNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3205
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3206
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3207
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3208
    [   sensor flushKeyboardFor:nil.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3209
        Delay waitForSeconds:0.1.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3210
        sensor hasKeyPressEventFor:nil.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3211
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3212
    ] whileTrue.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3213
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3214
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3215
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3216
pointerEntersItem:anItemOrNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3217
    "the pointer moves over an item or nil; restore the old item and
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3218
     redraw the new item highlighted.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3219
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3220
    |oldItem newItem|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3221
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3222
    (     anItemOrNil notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3223
     and:[anItemOrNil canSelect
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3224
     and:[selection isNil
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3225
     and:[self isPopUpView not]]]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3226
        anItemOrNil isButton ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3227
            (    buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3228
             or:[ButtonEnteredLevel   ~~ ButtonPassiveLevel]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3229
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3230
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3231
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3232
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3233
            DefaultEnteredLevel ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3234
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3235
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3236
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3237
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3238
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3239
    newItem ~~ enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3240
        oldItem     := enteredItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3241
        enteredItem := newItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3242
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3243
        oldItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3244
            self invalidateItem:oldItem repairNow:(enteredItem isNil).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3245
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3246
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3247
        enteredItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3248
            self invalidateItem:enteredItem repairNow:true.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3249
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3250
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3251
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3252
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3253
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3254
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3255
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3256
doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3257
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3258
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3259
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3260
        superMenu doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3261
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3262
        hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3263
            self grabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3264
            hasImplicitGrap := true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3265
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3266
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3267
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3268
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3269
doUngrab:forceDo
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3270
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3271
    relativeGrabOrigin := nil.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3272
    self clearImplicitGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3273
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3274
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3275
        forceDo ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3276
            superMenu doUngrab:true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3277
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3278
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3279
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3280
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3281
    hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3282
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3283
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3284
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3285
    forceDo ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3286
        (selection notNil or:[prevFocusView == self]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3287
            ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3288
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3289
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3290
    self ungrabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3291
    self selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3292
    hasImplicitGrap := nil.
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3293
    prevFocusView   := nil.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3294
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3295
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3296
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3297
grabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3298
    "grap the keyboard; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3299
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3300
    previousKeyboardGrab := device activeKeyboardGrab.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3301
  ^ super grabKeyboard
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3302
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3303
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3304
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3305
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3306
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3307
    "get exclusive access to pointer and keyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3308
    "
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3309
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3310
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3311
    realized ifTrue:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3312
        prevFocusView := self windowGroup focusView.
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3313
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3314
        sensor := self sensor.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3315
        device activePointerGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3316
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3317
                sensor flushMotionEventsFor:nil.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3318
            ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3319
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3320
            (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3321
                Delay waitForSeconds:0.1.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3322
                (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3323
                    "give up"
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3324
                    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3325
                    self unmap
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3326
                ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3327
            ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3328
        ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3329
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3330
        device activeKeyboardGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3331
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3332
                device sync.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3333
                sensor flushKeyboardFor:nil
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3334
            ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3335
            self grabKeyboard.
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3336
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3337
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3338
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3339
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  3340
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3341
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3342
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3343
grabPointerWithCursor:aCursorOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3344
    "grap the pointer; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3345
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3346
    previousPointerGrab := device activePointerGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3347
    hasImplicitGrap := true.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3348
  ^ super grabPointerWithCursor:aCursorOrNil
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3349
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3350
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3351
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3352
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3353
ungrabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3354
    "ungrap the keyboard; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3355
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3356
    super ungrabKeyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3357
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3358
    previousKeyboardGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3359
        device grabKeyboardInView:previousKeyboardGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3360
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3361
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3362
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3363
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3364
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3365
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3366
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3367
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3368
    self ungrabPointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3369
    self ungrabKeyboard.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3370
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3371
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3372
ungrabPointer
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3373
    "ungrap the pointer; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3374
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3375
    super ungrabPointer.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3376
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3377
    previousPointerGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3378
        device grabPointerInView:previousPointerGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3379
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3380
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3381
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3382
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3383
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3384
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3385
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3386
helpText
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3387
    "return the helpText for the currently selected item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3388
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3389
    ^ self helpTextForItem:selection
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3390
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3391
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3392
helpTextAt:srcPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  3393
    "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
  3394
     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
  3395
     "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3396
    |dstMenu dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3397
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3398
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3399
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3400
    dstMenu isNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3401
        ^ ''
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3402
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3403
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3404
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3405
  ^ dstMenu helpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)).
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3406
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3407
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3408
helpTextForItem:anItem
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3409
    "returns the helpText for an item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3410
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3411
    |key val app|
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3412
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3413
    anItem isNil ifTrue:[^ ''].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3414
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3415
    (val := anItem activeHelpText) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3416
        (     (key := anItem activeHelpKey) notNil
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3417
         and:[(app := self application) notNil]
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3418
        ) ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3419
            val := app helpTextForKey:key.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3420
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3421
        anItem activeHelpText:(val ? '').
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3422
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3423
    ^ val
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3424
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3425
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3426
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3427
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3428
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3429
    "returns image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3430
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3431
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3432
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3433
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3434
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3435
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3436
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3437
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3438
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3439
1688
271829d6a2e4 category changes
Claus Gittinger <cg@exept.de>
parents: 1679
diff changeset
  3440
!MenuPanel methodsFor:'initialization & release'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3441
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3442
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3443
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3444
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3445
    ^self
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3446
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3447
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3448
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3449
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3450
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3451
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3452
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3453
    self isPopUpView ifTrue:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3454
        (PopUpView shadowsOnDevice:device) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3455
            shadowView isNil ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3456
                shadowView := (ShadowView onDevice:device) for:self
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3457
            ] ifFalse:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3458
                self saveUnder:true.
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3459
            ].
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3460
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3461
    ] ifFalse:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3462
        explicitExtent == true ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3463
            (self width) == (superView width) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3464
                self verticalLayout:false
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3465
            ]
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3466
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3467
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3468
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3469
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3470
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3471
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3472
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3473
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3474
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3475
    self clearLastActiveMenu.
2000
94bc3e5bba84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  3476
    items notNil ifTrue:[items copy do:[:el|el destroy]].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3477
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3478
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3479
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3480
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3481
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3482
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3483
    items     := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3484
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3485
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3486
    "Modified: / 27.2.1998 / 17:41:25 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3487
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3488
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3489
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3490
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3491
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3492
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3493
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  3494
    "/ 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
  3495
    "/ (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
  3496
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  3497
    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
  3498
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3499
    superMenu isNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3500
        fgColor                   := DefaultForegroundColor         onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3501
        activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3502
        activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3503
        disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3504
        rightArrow                := RightArrowForm                 onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3505
        selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3506
        selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3507
        buttonLightColor          := ButtonLightColor               onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3508
        buttonShadowColor         := ButtonShadowColor              onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3509
        ButtonHalfLightColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3510
            buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3511
        ButtonHalfShadowColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3512
            buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3513
        buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3514
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3515
        (rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3516
            rightArrowShadow := rightArrowShadow onDevice:device
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3517
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3518
    ] ifFalse:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3519
        fgColor                   := superMenu foregroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3520
        activeBgColor             := superMenu activeBackgroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3521
        activeFgColor             := superMenu activeForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3522
        disabledFgColor           := superMenu disabledForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3523
        rightArrow                := superMenu rightArrow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3524
        rightArrowShadow          := superMenu rightArrowShadow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3525
        selectionFrameBrightColor := superMenu selectionFrameBrightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3526
        selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3527
        buttonLightColor          := superMenu buttonLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3528
        buttonShadowColor         := superMenu buttonShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3529
        buttonHalfLightColor      := superMenu buttonHalfLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3530
        buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3531
        buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3532
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3533
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3534
    items notNil ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3535
        items do:[:eachItem |
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3536
            eachItem fetchDeviceResources
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3537
        ]
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3538
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3539
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3540
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3541
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3542
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3543
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3544
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3545
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3546
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3547
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  3548
    viewBackground := DefaultBackgroundColor.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3549
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3550
    onLevel          := DefaultHilightLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3551
    offLevel         := 0. "/ DefaultLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3552
    itemSpace        := DefaultItemSpace.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3553
    groupDividerSize := DefaultGroupDividerSize.
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3554
    fitFirstPanel    := false.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3555
    font             := MenuView defaultFont onDevice:device.
1923
530426a3d692 support #level:
ca
parents: 1922
diff changeset
  3556
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3557
    self updateLevelAndBorder.
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3558
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3559
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3560
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3561
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3562
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3563
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3564
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3565
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3566
    self enableMotionEvents.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3567
    enabled := true.
1877
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  3568
    self extentChangedFlag:false.
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  3569
    self originChangedFlag:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3570
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3571
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3572
    mustRearrange  := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3573
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3574
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3575
map
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3576
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3577
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3578
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3579
    |loIndices loItems|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3580
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3581
    enteredItem := nil.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3582
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3583
    self enableMotionEvents.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3584
    self becomesActiveMenu.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3585
    super map.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3586
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3587
    loIndices := InitialSelectionQuerySignal query.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3588
    loItems   := items ? #[].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3589
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3590
    loItems do:[:anItem| anItem fetchImages ].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3591
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3592
    self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3593
        self doGrab
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3594
    ] ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3595
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3596
    ].
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3597
    loItems do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3598
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3599
    loIndices size > 0 ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3600
        self redrawX:0 y:0 width:width height:height.
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3601
        self openMenusFromItemIndices:loIndices.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3602
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3603
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  3604
    "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
  3605
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3606
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3607
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3608
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3609
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3610
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3611
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3612
    self isPopUpView ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3613
        "Because of #saveUnder of ShadowView the order of realize is significant:
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3614
         shadowView must be realized before self"
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3615
        self hiddenOnRealize:true.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3616
        super realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3617
        self resize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3618
        self makeFullyVisible.
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3619
"/        self mustRearrange.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3620
        shadowView notNil ifTrue:[
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3621
            shadowView realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3622
        ].
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3623
        self raise.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3624
        self map.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3625
    ] ifFalse:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3626
        super realize.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3627
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3628
    self allSubViewsDo:[:aView| aView realize ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3630
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3631
recreate
1832
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
  3632
    "this is called after a snapin or a migration.
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
  3633
     If the image was saved with an active menu, hide the menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3634
    "
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  3635
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3636
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3637
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3638
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3639
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3640
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3641
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3642
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3643
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3644
    self fetchDeviceResources.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3645
    self mustRearrange.      "/ care for changed font sizes etc.
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3646
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3647
    self do:[:anItem |
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3648
        anItem reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3649
    ].
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3650
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3651
    "Created: / 10.9.1998 / 21:37:05 / cg"
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3652
    "Modified: / 17.8.2000 / 18:01:33 / cg"
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3653
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3654
1796
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3655
reinitialize
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3656
    "reinit after a snapIn
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3657
    "
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3658
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3659
    super reinitialize.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3660
"/    self reinitStyle.
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3661
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3662
    "Modified: / 17.8.2000 / 17:53:31 / cg"
1796
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3663
!
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3664
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3665
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  3666
    "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
  3667
     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
  3668
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3669
    self clearLastActiveMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3670
    self doUngrab:(superMenu isNil).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3671
"/    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3672
"/         self doUngrab:(superMenu isNil)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3673
"/    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3674
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3675
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3676
    shadowView notNil ifTrue:[shadowView unmap].
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3677
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3678
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3679
updateLevelAndBorder
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3680
    "update level & border, when it is known if I am a popUpView"
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3681
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3682
    |bw lvl|
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3683
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3684
    self isPopUpView ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3685
        bw  := styleSheet at:#'popup.borderWidth' default:1.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3686
        lvl := styleSheet at:#'popup.level'       default:0.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3687
    ] ifFalse:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3688
        bw  := styleSheet is3D ifFalse:[1] ifTrue:[0].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3689
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3690
    self borderWidth:bw.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3691
    self level:lvl.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3692
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3693
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3694
!MenuPanel methodsFor:'keyboard control'!
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3695
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3696
mnemonicViewNext:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3697
    "a  mnemonicKey event as forwarded from the keyboardProcessor - if there
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3698
     is the mnemonic-key defined for any menuItem, handle the menuItem and
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3699
     return the topMenu otherwise nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3700
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3701
    |menu uKey lKey list|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3702
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3703
    superMenu notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3704
        ^ superMenu mnemonicViewNext:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3705
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3706
    shown ifFalse:[^ nil].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3707
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3708
    uKey := aKeyEvent rawKey last asUppercase.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3709
    lKey := uKey asLowercase.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3710
    menu := self detectGrabMenu. "/ first lookup the current grapMenu before starting in the topMenu
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3711
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3712
    [true] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3713
        list := menu selectItemIndicesFor:[:el||k|k := el accessCharacter. k == uKey or:[k == lKey]]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3714
                                 maxDepth:10.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3715
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3716
        list size ~~ 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3717
            "/ has item which responds to the mnemonic
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3718
            menu processCollectedIndices:list.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3719
          ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3720
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3721
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3722
        menu == self ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3723
            "/ must clear existing selection
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3724
            self selection:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3725
          ^ nil
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3726
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3727
        menu := self.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3728
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3729
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3730
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3731
openMenusFromItemIndices:anItemIndiceList
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3732
    "open all menus derived from sequence of item indices
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3733
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3734
    |item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3735
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3736
    anItemIndiceList size == 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3737
        ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3738
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3739
    item := self itemAt:(anItemIndiceList removeFirst).
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3740
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3741
    (item notNil and:[item enabled]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3742
        InitialSelectionQuerySignal answer:anItemIndiceList do:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3743
            self openMenuOnSelect:true.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3744
            self selection:item.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3745
            self openMenuOnSelect:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3746
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3747
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3748
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3749
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3750
processCollectedIndices:indices
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3751
    |menu item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3752
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3753
    indices size == 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3754
        ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3755
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3756
    menu := self.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3757
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3758
    [menu selectionIndex == indices first] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3759
        (    (item := menu selection) isNil             "/ shouldn't happen
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3760
         or:[(menu := item submenu) isNil]              "/ no more indices; done
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3761
        ) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3762
            ^ true
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3763
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3764
        indices removeFirst.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3765
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3766
        indices isEmpty ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3767
           menu selection:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3768
         ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3769
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3770
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3771
    menu openMenusFromItemIndices:indices.
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3772
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3773
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3774
processShortcut:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3775
    "a  shortcutKey event as forwarded from the keyboardProcessor - if there is the
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3776
     shortcut-key defined process the shortcut and return true otherwise false.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3777
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3778
    |menu rKey lKey list item winGroup|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3779
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3780
    superMenu notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3781
        ^ superMenu processShortcut:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3782
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3783
    shown ifFalse:[^ false].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3784
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3785
    item := nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3786
    rKey := aKeyEvent rawKey.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3787
    lKey := aKeyEvent key.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3788
    menu := self detectGrabMenu. "/ first lookup the current grapMenu before starting in the topMenu
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3789
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3790
    [true] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3791
        list := menu selectItemIndicesFor:[:el||skey|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3792
                                                item := el.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3793
                                                skey := el shortcutKey.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3794
                                                skey == rKey or:[skey == lKey]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3795
                                          ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3796
                                 maxDepth:10.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3797
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3798
        list size ~~ 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3799
            "/ has item which responds to the shortcut
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3800
            item hasSubmenu ifFalse:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3801
                menu accept:item
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3802
            ] ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3803
                menu processCollectedIndices:list.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3804
                self windowGroup focusView:self.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3805
            ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3806
          ^ true
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3807
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3808
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3809
        menu == self ifTrue:[ ^ false ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3810
        menu := self.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3811
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3812
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3813
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3814
selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3815
    "returns the sequence of indices up to the item for which the block
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3816
     returns true. The first entry is the topmenu, the last entry the
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3817
     item for which the block returns true.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3818
     If no item is detected, nil is returned
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3819
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3820
    (maxDepth <= 0 or:[items isNil]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3821
        ^ nil
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3822
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3823
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3824
    "/ first search horizontal
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3825
    items keysAndValuesDo:[:anIdx :anItem|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3826
        (aOneArgBlock value:anItem) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3827
            (anItem isEnabled and:[anItem isVisible]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3828
                ^ OrderedCollection with:anIdx.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3829
            ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3830
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3831
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3832
    "/ search in subMenus
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3833
    items keysAndValuesDo:[:anIdx :anItem| |menu seq|
1919
26fa92fa9465 only search submenus for shortCuts if the menu is a static one
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
  3834
        (anItem hasSubmenu
26fa92fa9465 only search submenus for shortCuts if the menu is a static one
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
  3835
         and:[anItem isVisible 
26fa92fa9465 only search submenus for shortCuts if the menu is a static one
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
  3836
         and:[anItem isEnabled]]) ifTrue:[
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3837
            menu := anItem submenu.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3838
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3839
            (menu notNil and:[menu isEnabled]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3840
                seq := menu selectItemIndicesFor:aOneArgBlock maxDepth:(maxDepth - 1).
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3841
                seq notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3842
                    seq addFirst:anIdx.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3843
                  ^ seq
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3844
                ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3845
            ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3846
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3847
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3848
    ^ nil
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3849
! !
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3850
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3851
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3852
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3853
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3854
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3855
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3856
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3857
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3858
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3859
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3860
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3861
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3862
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3863
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3864
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3865
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3866
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3867
superMenu:aSuperMenu
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3868
    "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
  3869
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3870
    (superMenu := aSuperMenu) notNil ifTrue:[
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3871
        super font:(superMenu font).
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3872
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3873
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3874
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3875
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3876
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3877
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3878
    |menu smenu|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3879
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3880
    menu := self.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3881
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3882
    [(smenu := menu superMenu) notNil] whileTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3883
        menu := smenu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3884
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3885
    ^ menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3886
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3887
1825
962390f1b499 category change
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
  3888
!MenuPanel methodsFor:'printing & storing'!
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3889
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3890
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3891
    "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
  3892
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3893
    |string label|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3894
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3895
    string := 'Menu:'.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3896
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3897
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3898
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3899
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3900
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3901
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3902
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3903
    "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
  3904
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3905
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3906
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3907
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3908
application
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3909
    "optimize access to retrive the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3910
    "
1921
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3911
    |appl akey w views|
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3912
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3913
    superMenu notNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3914
        ^ superMenu application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3915
    ].
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  3916
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3917
    akey := #appl.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3918
    appl := self menuAdornmentAt:akey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3919
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3920
    appl isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3921
        (appl := super application) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3922
            windowGroup isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3923
                ^ nil   "/ RETRY LATER
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3924
            ].
1921
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3925
            views := windowGroup mainGroup topViews.
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3926
            views size == 0 ifTrue:[
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3927
                ^ nil   "/ RETRY LATER
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3928
            ].
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3929
            w := views first.
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  3930
            w == self ifTrue:[
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3931
                thisContext isRecursive ifTrue:[
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3932
                    self error:'recursive application query'
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3933
                ].
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3934
                "/ appl := akey
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  3935
            ].
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3936
            appl := (w application) ? akey.
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3937
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3938
        self menuAdornmentAt:akey put:appl
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3939
    ].
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3940
    ^ appl ~~ akey ifTrue:[appl] ifFalse:[nil]
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3941
!
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3942
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3943
detectItemForKey:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3944
    "returns the item assigned to a key, accessCharacter or starts with.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3945
     if no item is detected nil is returned.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3946
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3947
    |cIdx uKey lKey item|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3948
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3949
    items isNil ifTrue:[^ nil].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3950
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3951
    cIdx := self selectionIndex.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3952
    uKey := aKey asUppercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3953
    lKey := aKey asLowercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3954
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3955
    items keysAndValuesDo:[:anIndex :anItem| |char label|
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3956
        (     anIndex ~~ cIdx
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3957
         and:[anItem canSelect
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3958
         and:[(label := anItem textLabel) notNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3959
         and:[label size ~~ 0]]]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3960
        ) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3961
            (char := anItem accessCharacter) notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3962
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3963
                    ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3964
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3965
            ] ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3966
                char := label at:1.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3967
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3968
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3969
                    anIndex > cIdx ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3970
                        ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3971
                    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3972
                    item isNil ifTrue:[item := anItem]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3973
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3974
            ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3975
        ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3976
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3977
    ^ item
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3978
!
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3979
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3980
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3981
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3982
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3983
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3984
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3985
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3986
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3987
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3988
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  3989
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3990
    "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
  3991
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3992
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3993
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3994
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3995
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3996
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3997
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3998
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  3999
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4000
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4001
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4002
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4003
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4004
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4005
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4006
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4007
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4008
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4009
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4010
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4011
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4012
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4013
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4014
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4015
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4016
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4017
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4018
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4019
registerImageOnDevice:anImage
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4020
    |image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4021
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4022
    (image := anImage) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4023
        image device ~~ device ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4024
            image := image copy.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4025
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4026
        image := image on:device.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4027
        image := image clearMaskedPixels.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4028
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4029
    ^ image
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4030
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4031
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4032
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4033
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4034
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4035
    "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
  4036
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4037
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4038
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4039
    "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
  4040
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4041
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4042
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4043
    "set the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4044
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4045
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4046
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4047
    "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
  4048
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4049
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4050
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4051
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4052
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4053
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4054
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4055
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4056
    "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
  4057
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4058
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4059
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4060
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4061
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4062
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4063
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4064
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4065
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4066
    prevFocusView notNil ifTrue:[
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4067
        self windowGroup focusView:prevFocusView.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4068
        prevFocusView := nil.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4069
    ].
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4070
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4071
    top activeMenu == self ifTrue:[
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4072
        top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4073
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4074
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4075
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4076
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4077
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4078
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4079
    "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
  4080
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4081
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4082
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4083
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4084
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4085
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4086
!MenuPanel methodsFor:'private scrolling'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4087
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4088
hasScrollerAt:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4089
    "returns true if a visible scroller at a direction exists
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4090
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4091
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4092
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4093
    self hasScrollers ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4094
        ^ false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4095
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4096
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4097
    aDirection == #PREV ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4098
        layout := items first layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4099
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4100
      ^ self verticalLayout ifTrue:[ layout top  < margin]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4101
                           ifFalse:[ layout left < margin]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4102
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4103
    layout := items last layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4104
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4105
  ^ self verticalLayout ifTrue:[ layout bottom > (height - margin)]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4106
                       ifFalse:[ layout right  > (width  - margin)]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4107
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4108
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4109
hasScrollers
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4110
    "returns true if scrollers are needed
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4111
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4112
    |maxExtent first last isVert|
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4113
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4114
    (mustRearrange or:[items size < 2]) ifTrue:[^ false].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4115
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4116
    isVert := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4117
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4118
    superView notNil ifTrue:[
2039
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4119
        (    (first := items first layout) isNil
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4120
         or:[(last  := items last  layout) isNil]
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4121
        ) ifTrue:[
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4122
            ^ false
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4123
        ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4124
        isVert ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4125
            ^ first top < 0 or:[last bottom > height]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4126
        ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4127
        ^ first left < 0 or:[last right > width]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4128
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4129
    maxExtent := self maxExtent.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4130
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4131
    isVert ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4132
        ^ (height < maxExtent y) not
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4133
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4134
    ^ (width < maxExtent x) not
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4135
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4136
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4137
indexOfItemAtScroller:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4138
    "returns the index of the item under the scroller or 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4139
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4140
    |bounds min max layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4141
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4142
    bounds := self scrollerBoundsAt:aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4143
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4144
    bounds isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4145
        ^ 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4146
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4147
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4148
    self verticalLayout ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4149
        min := bounds top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4150
        max := bounds bottom.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4151
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4152
        items keysAndValuesDo:[:anIndex :anItem|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4153
            anItem isVisible ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4154
                layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4155
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4156
                (layout top < max and:[layout bottom > min]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4157
                    ^ anIndex
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4158
                ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4159
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4160
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4161
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4162
        min := bounds left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4163
        max := bounds right.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4164
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4165
        items keysAndValuesDo:[:anIndex :anItem|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4166
            anItem isVisible ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4167
                layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4168
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4169
                (layout left < max and:[layout right > min]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4170
                    ^ anIndex
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4171
                ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4172
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4173
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4174
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4175
    ^ 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4176
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4177
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4178
makeItemVisible:anItem
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4179
    "make an item visible
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4180
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4181
    |boundsPREV boundsNEXT delta layout index scr0 scr1 windowSz scrSz doScroll
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4182
     isVertical boundsMin layoutMin boundsMax layoutMax dltOrg
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4183
     inv1 inv2|
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4184
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4185
    (     anItem notNil
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4186
     and:[self hasScrollers
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4187
     and:[(layout := anItem layout) notNil]]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4188
    ) ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4189
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4190
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4191
    index      := self indexOfItem:anItem.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4192
    boundsPREV := self scrollerBoundsAt:#PREV.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4193
    boundsNEXT := self scrollerBoundsAt:#NEXT.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4194
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4195
    isVertical := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4196
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4197
    isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4198
        boundsMin := boundsPREV bottom.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4199
        boundsMax := boundsNEXT top.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4200
        layoutMin := layout top.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4201
        layoutMax := layout bottom.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4202
        windowSz  := height.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4203
    ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4204
        boundsMin := boundsPREV right.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4205
        boundsMax := boundsNEXT left.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4206
        layoutMin := layout left.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4207
        layoutMax := layout right.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4208
        windowSz  := width.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4209
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4210
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4211
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4212
    layoutMin < boundsMin ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4213
        "/ test whether is first visible item
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4214
        index := items findLast:[:el| el isVisible] startingAt:(index - 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4215
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4216
        index == 0 ifTrue:[ scr0 := margin ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4217
                  ifFalse:[ scr0 := boundsMin ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4218
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4219
        delta := layoutMin negated + scr0.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4220
    ] ifFalse:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4221
        layoutMax > boundsMax ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4222
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4223
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4224
        "/ test whether is last visible item
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4225
        index  := items findFirst:[:el| el isVisible ] startingAt:(index + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4226
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4227
        index == 0 ifTrue:[ scr0 := windowSz - margin ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4228
                  ifFalse:[ scr0 := boundsMax ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4229
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4230
        delta := scr0 - layoutMax.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4231
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4232
    delta == 0 ifTrue:[ ^ self ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4233
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4234
    doScroll := false.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4235
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4236
    shown ifTrue:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4237
        delta abs < (windowSz / 2) ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4238
            doScroll := true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4239
            self repairDamage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4240
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4241
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4242
    isVertical ifTrue:[ dltOrg := 0@delta ] ifFalse:[dltOrg := delta@0].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4243
    items do:[:el| el moveBy:dltOrg ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4244
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4245
    doScroll ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4246
        ^ self invalidate
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4247
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4248
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4249
    windowSz  := windowSz - margin - margin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4250
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4251
    scr0  := boundsMin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4252
    scr1  := scr0 + delta abs.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4253
    scrSz := boundsMax - scr1.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4254
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4255
    delta < 0 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4256
        isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4257
            self copyFrom:self x:margin y:scr1 toX:margin y:scr0
2041
00e511a396d0 either invoke catchExpose or do not copy async.
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
  4258
                           width:windowSz height:scrSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4259
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4260
            scr1 := scr0 + scrSz.
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4261
            inv2 := (margin @ scr1) extent:(windowSz @ (height - scr1 - margin)).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4262
            "/ self invalidateX:margin y:scr1 width:windowSz height:(height - scr1 - margin).
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4263
        ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4264
            self copyFrom:self x:scr1 y:margin toX:scr0 y:margin
2041
00e511a396d0 either invoke catchExpose or do not copy async.
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
  4265
                           width:scrSz height:windowSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4266
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4267
            scr1 := scr0 + scrSz.
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4268
            inv2 := (scr1 @ margin) extent:((width - scr1 - margin) @ windowSz).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4269
            "/ self invalidateX:scr1 y:margin width:(width - scr1 - margin) height:windowSz.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4270
        ].
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4271
        inv1 := boundsPREV.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4272
    ] ifFalse:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4273
        isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4274
            self copyFrom:self x:margin y:scr0 toX:margin y:scr1
2041
00e511a396d0 either invoke catchExpose or do not copy async.
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
  4275
                           width:windowSz height:scrSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4276
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4277
            inv2 := (margin @ margin) extent:(windowSz @ (scr1 - margin)).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4278
            "/ self invalidateX:margin y:margin width:windowSz height:scr1 - margin.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4279
        ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4280
            self copyFrom:self x:scr0 y:margin toX:scr1 y:margin
2041
00e511a396d0 either invoke catchExpose or do not copy async.
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
  4281
                           width:scrSz height:windowSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4282
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4283
            inv2 := (margin @ margin) extent:(scr1 - margin) @ windowSz.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4284
            "/ self invalidateX:margin y:margin width:scr1 - margin height:windowSz.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4285
        ].
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4286
        inv1 := boundsNEXT.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4287
    ].
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4288
    self invalidate:inv1.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4289
    self invalidate:inv2.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4290
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4291
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4292
scrollerBoundsAt:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4293
    "returns the bounds of the scroller at a direction or nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4294
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4295
    |y x w h inset|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4296
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4297
    self hasScrollers ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4298
        ^ nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4299
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4300
    inset := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4301
    x := y := inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4302
    w := h := 15.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4303
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4304
    self verticalLayout ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4305
        aDirection == #NEXT ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4306
            y := height - h - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4307
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4308
        w := width - inset - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4309
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4310
        aDirection == #NEXT ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4311
            x := width - w - inset.       
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4312
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4313
        h := height - inset - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4314
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4315
    ^ Rectangle left:x top:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4316
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4317
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4318
scrollerDirectionAtPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4319
    "returns the scroller-direction at aPoint, or nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4320
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4321
    self hasScrollers ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4322
        #( PREV NEXT ) do:[:aDirection| |bounds|
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4323
            (    (bounds := self scrollerBoundsAt:aDirection) notNil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4324
             and:[bounds containsPoint:aPoint]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4325
            ) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4326
                ^ (self hasScrollerAt:aDirection) ifTrue:[aDirection] ifFalse:[nil]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4327
            ]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4328
        ]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4329
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4330
    ^ nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4331
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4332
    "Created: / 13.11.2001 / 14:13:16 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4333
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4334
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4335
scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4336
    "returns the one and only scrolling - data holder
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4337
     for a menu and all contained submenus
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4338
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4339
    superMenu notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4340
        ^ superMenu scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4341
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4342
    scrolling isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4343
        scrolling := Scrolling new.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4344
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4345
    ^ scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4346
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4347
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4348
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4349
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4350
detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4351
    "returns the menu which is responsible for the grap; the last opened menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4352
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4353
    |subMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4354
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4355
    selection notNil ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4356
        (subMenu := selection visibleSubmenu) notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4357
            ^ subMenu detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4358
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4359
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4360
    ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4361
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4362
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4363
detectMenuAtGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4364
    "returns the menu which contains the grab-point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4365
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4366
    |dstMenu dstPoint firstMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4367
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4368
    dstPoint := self translateGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4369
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4370
    ((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
  4371
        firstMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4372
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4373
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4374
    (selection isNil or:[(dstMenu := selection visibleSubmenu) isNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4375
        ^ firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4376
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4377
    dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4378
  ^ dstMenu ? firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4379
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4380
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4381
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4382
detectViewAtX:x y:y in:aTopView
1922
1a2ab52eb2ab bug fix in #detectViewAtX:y:in:
ca
parents: 1921
diff changeset
  4383
    "detect view at x@y
1a2ab52eb2ab bug fix in #detectViewAtX:y:in:
ca
parents: 1921
diff changeset
  4384
    "
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4385
    ^ aTopView detectViewAt:(x@y).
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4386
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4387
"/ cg: old code was (refactored to use common code)
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4388
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4389
"/    |p subViews|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4390
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4391
"/    (subViews := aTopView subViews) notNil ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4392
"/        subViews do:[:v| |p|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4393
"/            v shown ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4394
"/                (    (x between:(v left) and:(v right))
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4395
"/                 and:[y between:(v top)  and:(v bottom)]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4396
"/                ) ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4397
"/                    p := device translatePoint:(x@y) from:(aTopView id) to:(v id).
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4398
"/                  ^ self detectViewAtX:p x y:p y in:v.
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4399
"/                ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4400
"/            ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4401
"/        ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4402
"/    ].
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4403
"/    ^ aTopView
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4404
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4405
    "Modified: / 10.10.2001 / 13:45:56 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4406
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4407
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4408
itemAtPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4409
    "returns the item at a point x@y or nil if none detected
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4410
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4411
    items notNil ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4412
        ^ items detect:[:el| el containsPoint:aPoint] ifNone:nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4413
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4414
    ^ nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4415
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4416
    "Created: / 13.11.2001 / 13:58:23 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4417
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4418
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4419
itemAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4420
    "returns the item at a point x@y or nil if none detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4421
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4422
    items notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4423
        ^ items detect:[:el| el containsPointX:x y:y] ifNone:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4424
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4425
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4426
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4427
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4428
superMenuAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4429
    "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
  4430
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4431
    |grabPoint superMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4432
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4433
    (self containsPointX:x y:y) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4434
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4435
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4436
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4437
    grabPoint := (x@y) - (self translateGrabPoint:0).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4438
    superMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4439
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4440
    [ (superMenu := superMenu superMenu) notNil ] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4441
        (superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4442
            ^ superMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4443
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4444
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4445
  ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4446
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4447
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4448
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4449
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4450
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4451
container:aView
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4452
    super container:aView.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4453
    aView notNil ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4454
        "/ I am no longer a popUpView
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4455
        self updateLevelAndBorder
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4456
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4457
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4458
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4459
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4460
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4461
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4462
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4463
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4464
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4465
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4466
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4467
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  4468
    ^ (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
  4469
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4470
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4471
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4472
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4473
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4474
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4475
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4476
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4477
    groupSizes size ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4478
        i := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4479
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4480
        groupSizes do:[:t|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4481
            (i := i + t) == anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4482
                ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4483
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4484
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4485
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4486
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4487
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4488
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4489
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4490
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4491
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4492
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4493
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4494
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4495
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4496
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4497
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4498
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4499
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4500
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4501
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4502
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4503
    "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
  4504
     be fit to the extent of its superView;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4505
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4506
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4507
    ^ false
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4508
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4509
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4510
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4511
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4512
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4513
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4514
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4515
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4516
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4517
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4518
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4519
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4520
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4521
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4522
    ^ self verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4523
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4524
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4525
!
c05874084d4c implement
ca
parents: 407
diff changeset
  4526
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4527
isViewWrapper
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4528
    ^ subViews size ~~ 0
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4529
!
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4530
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4531
openMenuOnSelect
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4532
    ^ (self menuAdornmentAt:#openMenuOnSelect) ? DefaultOpenOnSelect.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4533
        
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4534
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4535
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4536
openMenuOnSelect:something
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4537
    ^ self menuAdornmentAt:#openMenuOnSelect put:something
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4538
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4539
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4540
type
428
ca
parents: 427
diff changeset
  4541
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4542
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4543
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4544
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4545
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4546
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4547
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4548
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4549
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4550
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4551
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4552
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4553
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4554
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4555
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4556
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4557
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4558
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4559
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4560
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4561
selection:anItemOrNil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4562
    "change selection to an item or nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4563
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4564
    |item newSel hlp visItem|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4565
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4566
    (newSel := anItemOrNil) isNumber ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4567
        newSel := self itemAt:anItemOrNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4568
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4569
    visItem := newSel.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4570
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4571
    (newSel notNil and:[newSel canSelect]) ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4572
        newSel := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4573
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4574
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4575
    selection == newSel ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4576
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4577
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4578
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4579
    (item := selection) notNil ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4580
        selection := nil.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4581
        item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4582
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4583
    self makeItemVisible:visItem.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4584
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4585
    newSel isNil ifTrue:[^ self].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4586
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4587
    newSel == enteredItem ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4588
        enteredItem := nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4589
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4590
        self pointerEntersItem:nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4591
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4592
    selection := newSel.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4593
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4594
    ActiveHelp isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4595
        hlp := ActiveHelp currentHelpListener.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4596
        hlp initiateHelpFor:self atX:nil y:nil now:true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4597
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4598
    shown "realized" ifTrue:[self rearrangeItems].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4599
    selection selected:true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4600
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4601
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4602
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4603
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4604
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4605
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4606
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4607
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4608
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4609
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4610
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4611
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4612
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4613
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4614
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4615
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4616
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4617
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4618
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4619
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4620
!MenuPanel methodsFor:'translation'!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4621
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4622
translateGrabPoint:aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4623
    "translate the grab point into self
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4624
    "
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4625
    superMenu isNil ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4626
        "I am the grapView"
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4627
        aGrabPoint isNumber ifTrue:[^ aGrabPoint @ aGrabPoint].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4628
      ^ aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4629
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4630
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4631
    relativeGrabOrigin isNil ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4632
        relativeGrabOrigin := self topMenu translatePoint:0 to:self.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4633
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4634
    ^ relativeGrabOrigin + aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4635
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4636
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4637
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4638
translateMenuPoint:aPoint toMenu:aMenu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4639
    "translate a point into another menu its point
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4640
    "
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4641
    |grapPoint|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4642
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4643
    aMenu == self ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4644
        ^ aPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4645
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4646
    grapPoint := aPoint - (self translateGrabPoint:0).
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4647
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4648
  ^ aMenu translateGrabPoint:grapPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4649
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4650
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4651
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4652
translatePoint:aPoint to:anotherWindowOrNilForScreen
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4653
    "translate a point in my window to anotherWindowOrNilForScreen (or root window if nil)
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4654
    "
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4655
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4656
    ^ device 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4657
        translatePoint:aPoint asPoint 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4658
        fromView:self 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4659
        toView:anotherWindowOrNilForScreen
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4660
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4661
    "Modified: / 10.10.2001 / 14:11:47 / cg"
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4662
! !
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4663
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4664
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4665
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4666
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4667
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4668
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4669
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4670
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4671
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4672
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4673
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4674
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4675
    ^ VerticalInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4676
!
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4677
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4678
verticalPopUpInset
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4679
    ^ VerticalPopUpInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4680
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4681
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4682
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4683
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4684
separatorSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4685
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4686
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4687
    ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4688
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4689
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4690
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4691
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4692
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4693
    "
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4694
    <resource: #style (#'menuPanel.verticalInset')>
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4695
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4696
    HorizontalInset       := 2.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4697
    VerticalInset         := MenuPanel styleSheet at:#'menuPanel.verticalInset' default:2.
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4698
    VerticalPopUpInset    := 2.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4699
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4700
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4701
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4702
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  4703
    LabelRightOffset      := 15.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4704
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4705
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4706
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4707
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4708
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4709
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4710
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4711
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4712
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4713
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4714
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4715
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4716
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4717
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4718
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4719
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4720
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4721
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4722
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4723
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4724
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4725
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4726
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4727
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4728
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4729
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
  4730
!MenuPanel::Item methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4731
420
ca
parents: 417
diff changeset
  4732
canAccept
ca
parents: 417
diff changeset
  4733
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  4734
    "
ca
parents: 417
diff changeset
  4735
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4736
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4737
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4738
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4739
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4740
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4741
    |arg|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4742
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4743
    indication notNil ifTrue:[    
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4744
        arg := self indicationValue not.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4745
        self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4746
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4747
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4748
            choice value:choiceValue.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4749
          ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4750
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4751
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4752
    ^ arg
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4753
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4754
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4755
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4756
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4757
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4758
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4759
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4760
    ^ accessCharacter
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4761
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4762
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4763
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4764
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4765
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4766
    ^ accessCharacterPosition
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4767
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4768
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4769
accessCharacterPosition:anIndex 
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4770
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4771
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4772
    accessCharacterPosition := anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4773
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4774
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4775
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4776
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4777
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4778
    ^ argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4779
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4780
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4781
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4782
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4783
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4784
    argument := anArgument.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4785
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4786
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4787
font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4788
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4789
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4790
    ^ font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4791
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4792
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4793
font:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4794
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4795
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4796
    aFont ~= font ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4797
        font := aFont notNil ifTrue:[aFont onDevice:(menuPanel device)]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4798
                            ifFalse:[nil].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4799
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4800
        rawLabel notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4801
            "have to recompute the extent"
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4802
            self label:label
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4803
        ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4804
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4805
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4806
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4807
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4808
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4809
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4810
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4811
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4812
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4813
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4814
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4815
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4816
    "
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4817
    |size char lbl mfont f oldExtent
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4818
     h "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4819
     w "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4820
    |
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4821
    oldExtent       := rawLabelExtent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4822
    accessCharacter := rawLabelExtent := disabledRawLabel := nil.
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4823
    label           := aLabel value.
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4824
    rawLabel        := label value ? ''.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4825
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4826
    rawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4827
        "CHECK FOR SEPARATOR"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4828
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4829
        (isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4830
            size := rawLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4831
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4832
            size == 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4833
                rawLabel := nil.                        "blank separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4834
              ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4835
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4836
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4837
            size == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4838
                char := rawLabel first.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4839
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4840
                (char == $- or:[char == $=]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4841
                    label    := rawLabel.               "line separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4842
                    rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4843
                  ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4844
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4845
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4846
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4847
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4848
        rawLabel isCollection ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4849
            rawLabel := rawLabel asArray.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4850
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4851
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4852
    mfont := menuPanel setFont:font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4853
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4854
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4855
        w := h := 0.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4856
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4857
        rawLabel keysAndValuesDo:[:i :el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4858
            el notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4859
                lbl := self updateAccessCharacterFor:el.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4860
                rawLabel at:i put:lbl.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4861
                w := w max:(lbl widthOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4862
                h := h + 1 + (lbl heightOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4863
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4864
                h := h + 3
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4865
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4866
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4867
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4868
        rawLabel := self updateAccessCharacterFor:rawLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4869
        w := rawLabel  widthOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4870
        h := rawLabel heightOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4871
    ].
1797
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4872
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4873
    "/ care for italic fonts - give a few more pixels at the end
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4874
    f := mfont ? (menuPanel font).
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4875
    (f notNil and:[f italic]) ifTrue:[
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4876
        w := w + 2.
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4877
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4878
    rawLabelExtent := w@h.
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4879
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4880
    menuPanel setFont:mfont.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4881
    menuPanel shown ifTrue:[ self fetchImages ].
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4882
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4883
    oldExtent = rawLabelExtent ifTrue:[
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4884
        self invalidate
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4885
    ] ifFalse:[
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4886
        menuPanel mustRearrange
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4887
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4888
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4889
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4890
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4891
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4892
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4893
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4894
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4895
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4896
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4897
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4898
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4899
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4900
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4901
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4902
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4903
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4904
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4905
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4906
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4907
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4908
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4909
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4910
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4911
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4912
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4913
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4914
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4915
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4916
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4917
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  4918
    ^ shortcutKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4919
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4920
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4921
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4922
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4923
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4924
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  4925
    shortcutKey ~~ aKey ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  4926
        shortcutKey := aKey.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4927
        self invalidate.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4928
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4929
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4930
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4931
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4932
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4933
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4934
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4935
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4936
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4937
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4938
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4939
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4940
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4941
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4942
    startGroup := aSymbol.
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4943
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  4944
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4945
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4946
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4947
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4948
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  4949
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4950
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4951
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4952
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4953
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4954
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4955
    "
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4956
    |widget|
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4957
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4958
    aSubMenu isNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4959
        subMenu notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4960
            subMenu destroy.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4961
            subMenu := nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4962
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4963
        ^ self
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4964
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4965
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4966
    (aSubMenu isKindOf:Menu) ifTrue:[
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4967
        subMenu := MenuPanel new.
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4968
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4969
        menuPanel notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4970
            subMenu receiver:menuPanel receiver.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4971
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4972
        subMenu superMenu:menuPanel.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4973
        subMenu menu:aSubMenu.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4974
    ] ifFalse:[
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4975
        aSubMenu isView ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4976
            (aSubMenu isKindOf:ApplicationModel) ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4977
                "/ ... mhhhh ....
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4978
                ^ self submenuChannel:aSubMenu
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4979
            ].            
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4980
            widget := SimpleView new.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4981
            widget client:aSubMenu.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4982
        ] ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4983
            widget := aSubMenu
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4984
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4985
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4986
        (widget isKindOf:MenuPanel) ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4987
            subMenu := widget
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4988
        ] ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4989
            subMenu := MenuPanel new.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4990
            subMenu receiver:menuPanel receiver.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4991
            subMenu addSubView:widget.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4992
            subMenu extent:(widget preferredExtent).
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4993
            widget origin:0.0@0.0 corner:1.0@1.0.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4994
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  4995
        subMenu superMenu:menuPanel.
1929
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  4996
    ].
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  4997
    self keepLinkedMenu ifTrue:[
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  4998
        submenuChannel := nil
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  4999
    ]
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5000
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5001
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5002
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5003
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5004
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5005
    |txt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5006
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5007
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5008
        rawLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5009
            ^ rawLabel perform:#string ifNotUnderstood:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5010
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5011
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5012
        rawLabel do:[:el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5013
            (txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5014
                ^ txt
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
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5018
    ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5019
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5020
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5021
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5022
triggerOnDown
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5023
    "trigger the action if pressed
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5024
    "
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5025
    triggerOnDown == true ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5026
        self hasSubmenu ifFalse:[^ true].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5027
        triggerOnDown := false.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5028
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5029
    ^ false
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5030
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5031
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5032
triggerOnDown:aBool
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5033
    "trigger the action if pressed
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5034
    "
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5035
    triggerOnDown := aBool.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5036
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5037
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5038
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5039
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5040
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5041
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5042
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5043
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5044
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5045
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5046
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5047
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5048
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5049
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5050
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5051
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5052
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5053
    value    := aValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5054
    argument := anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5055
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5056
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5057
!MenuPanel::Item methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5058
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5059
choice
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5060
    "implements a radio group; the field
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
    ^ choice
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5063
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5064
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5065
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5066
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5067
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5068
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5069
    choice == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5070
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5071
    choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5072
        choice removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5073
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5074
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5075
    (choice := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5076
        choice isSymbol ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5077
            (choice := self aspectAt:choice) isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5078
                choice := something
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5079
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5080
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5081
        choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5082
            choice addDependent:self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5083
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5084
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5085
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5086
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5087
choiceValue
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5088
    "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
  5089
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5090
    ^ choiceValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5091
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5092
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5093
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5094
choiceValue:something
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5095
    "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
  5096
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5097
    choiceValue ~= something ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5098
        choiceValue := something.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5099
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5100
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5101
            self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5102
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5103
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5104
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5105
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5106
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5107
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5108
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5109
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5110
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5111
    menuPanel enabled ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5112
        enableChannel isSymbol ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5113
            state := self aspectAt:enableChannel.
1806
5ca7e602ca7c ignore Backspace in shortKey processing;
Claus Gittinger <cg@exept.de>
parents: 1800
diff changeset
  5114
            state isNil ifTrue:[
1902
8676e04e404a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1889
diff changeset
  5115
                ('MenuPanel::Item [info]: no aspect for ',enableChannel, ' (in ' , (label?rawLabel) printString , ')') infoPrintCR
1806
5ca7e602ca7c ignore Backspace in shortKey processing;
Claus Gittinger <cg@exept.de>
parents: 1800
diff changeset
  5116
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5117
            state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5118
                enableChannel := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5119
                enableChannel addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5120
                state := enableChannel value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5121
            ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5122
                state := state value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5123
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5124
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5125
            state := enableChannel value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5126
        ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5127
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5128
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5129
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5130
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5131
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5132
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5133
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5134
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5135
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5136
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5137
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5138
        oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5139
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5140
        oldState := enableChannel value.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5141
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5142
            enableChannel removeDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5143
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5144
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5145
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5146
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5147
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5148
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5149
        newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5150
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5151
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5152
            enableChannel addDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5153
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5154
            enableChannel isSymbol ifTrue:[^ self]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5155
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5156
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5157
        newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5158
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5159
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5160
    newState ~~ oldState ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5161
        self invalidate
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5162
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5163
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5164
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5165
hideMenuOnActivated
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5166
    "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5167
    "
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5168
    ^ hideMenuOnActivated ? true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5169
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5170
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5171
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5172
hideMenuOnActivated:aBool
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5173
   "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5174
   "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5175
   hideMenuOnActivated := aBool.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5176
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5177
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5178
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5179
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5180
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5181
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5182
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5183
    ^ indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5184
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5185
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5186
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5187
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5188
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5189
    indication == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5190
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5191
    indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5192
        indication removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5193
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5194
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5195
    (indication := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5196
        indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5197
            indication addDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5198
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5199
            "/ to force an update of the value
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5200
            self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5201
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5202
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5203
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5204
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5205
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5206
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5207
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  5208
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5209
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5210
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5211
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5212
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5213
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5214
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5215
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5216
    layout notNil ifTrue:[
1731
89932327a6f8 redrawAsButton no longer exists; call invalidate
ca
parents: 1730
diff changeset
  5217
        self invalidate.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5218
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5219
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5220
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5221
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5222
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5223
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5224
keepLinkedMenu
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5225
    "get the keepLinkedMenu flag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5226
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5227
    ^ keepLinkedMenu ? false
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5228
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5229
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5230
keepLinkedMenu:aFlag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5231
    "get the keepLinkedMenu flag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5232
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5233
    keepLinkedMenu := aFlag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5234
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5235
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5236
showBusyCursorWhilePerforming
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5237
    "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
  5238
     while performing the menu action. Defaults to false.
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
    ^ showBusyCursorWhilePerforming ? false
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5241
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5242
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5243
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5244
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5245
showBusyCursorWhilePerforming:aBoolean
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5246
    "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
  5247
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5248
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5249
    showBusyCursorWhilePerforming := aBoolean.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5250
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5251
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5252
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5253
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5254
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5255
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5256
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5257
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5258
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5259
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5260
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5261
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5262
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5263
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5264
!MenuPanel::Item methodsFor:'accessing-dimension'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5265
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5266
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5267
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5268
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5269
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5270
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5271
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5272
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5273
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5274
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5275
    layout := aLayout.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5276
    self invalidate.
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  5277
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5278
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5279
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5280
moveBy:aPoint
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5281
    "move layout origin
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5282
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5283
    layout moveBy:aPoint.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5284
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5285
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5286
preferredExtent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5287
    "compute my preferred extent excluding the shortCutKey and the menu identifier
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5288
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5289
    |isVertical
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5290
     x "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5291
     y "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5292
     s "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5293
    |
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5294
    self isVisible ifFalse:[^ 0@0 ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5295
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5296
    isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5297
        s := menuPanel maxAbsoluteButtonLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5298
        x := s + HorizontalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5299
        y := s + VerticalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5300
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5301
        x  := HorizontalInset.
1766
e3667c5b8b30 may not assign potential nil to a smallInt-typed variable
Claus Gittinger <cg@exept.de>
parents: 1765
diff changeset
  5302
        y  := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5303
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5304
    x := x * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5305
    y := y * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5306
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5307
    isVertical := menuPanel verticalLayout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5308
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5309
    rawLabel isNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5310
        "SEPARATOR"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5311
        s := self class separatorSize.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5312
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5313
        "width of doubleSeparator is 5 !!!!"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5314
        isVertical ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5315
            x := x max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5316
            y := y + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5317
        ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5318
            y := y max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5319
            x := x + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5320
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5321
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5322
        x := x + rawLabelExtent x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5323
        y := y + rawLabelExtent y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5324
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5325
        isButton ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5326
            menuPanel showSeparatingLines ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5327
                "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
  5328
                isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5329
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5330
            (indication notNil or:[choice notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5331
                x := x + 2 + menuPanel iconIndicationOff width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5332
            ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5333
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5334
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5335
    ^ x@y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5336
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5337
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5338
!MenuPanel::Item methodsFor:'accessing-help'!
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5339
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5340
activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5341
    "get the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5342
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5343
    ^ activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5344
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5345
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5346
activeHelpKey:aHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5347
    "set the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5348
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5349
    activeHelpKey ~~ aHelpKey ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5350
        activeHelpKey  := aHelpKey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5351
        activeHelpText := nil.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5352
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5353
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5354
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5355
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5356
activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5357
    "get the active helpText or nil if not yet resolved
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5358
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5359
    ^ activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5360
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5361
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5362
activeHelpText:aText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5363
    "set the active helpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5364
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5365
    activeHelpText := aText.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5366
! !
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5367
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5368
!MenuPanel::Item methodsFor:'activation / deactivation'!
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5369
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5370
currentSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5371
    "returns the current submenu or nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5372
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5373
    ^ subMenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5374
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5375
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5376
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5377
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5378
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5379
hideSubmenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5380
    "hide submenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5381
    "
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5382
    |id|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5383
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5384
    subMenu notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5385
        subMenu realized ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5386
            (id := subMenu id) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5387
                menuPanel device unmapWindow:id
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5388
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5389
        ] ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5390
           subMenu hide
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5391
        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5392
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5393
        subMenu windowGroup:nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5394
        menuPanel windowGroup removeView:subMenu.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5395
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5396
        "/ release menu if derived from channel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5397
        submenuChannel notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5398
            subMenu := nil
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5399
        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5400
     ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5401
!
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5402
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5403
openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5404
    "opens the submenu; make sure, that the submenu and the menPanel
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5405
     is fully visible by shifting it into the visible screen area if
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5406
     nescessary.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5407
    "
1790
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5408
    |p o device isVertical topMenu windGrp prefExtent item
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5409
     devBot   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5410
     devRight "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5411
     width    "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5412
     height   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5413
     top      "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5414
     left     "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5415
    |
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5416
1737
c18896a7cb50 replace shown by realized; when opening a submenue-submenue by shortcut key
ca
parents: 1735
diff changeset
  5417
    (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
  5418
        ^ self
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5419
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5420
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5421
    topMenu := menuPanel topMenu.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5422
    (subMenu device notNil and:[topMenu device ~~ subMenu device]) ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5423
        subMenu releaseDeviceResources.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5424
        subMenu setDevice:topMenu device id:nil gcId:nil.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5425
        subMenu recreate.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5426
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5427
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5428
    windGrp := topMenu windowGroup.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5429
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5430
    subMenu superMenu:menuPanel.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5431
    subMenu becomesActiveMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5432
    subMenu cursor:Cursor hand.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5433
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5434
    windGrp notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5435
        subMenu windowGroup:windGrp.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5436
        windGrp addTopView:subMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5437
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5438
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5439
    " Q&D kludge - if any visibility attributes are blocks;
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5440
      TODO: only invoke mustRearrange if any are blocks
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5441
            (since I react correctly on valueHolder changes)
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5442
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5443
    subMenu rearrangeItemsIfItemVisibilityChanged.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5444
    subMenu fixSize.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5445
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5446
    "compute origin of subMenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5447
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5448
    isVertical := menuPanel verticalLayout.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5449
    device     := menuPanel device.
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5450
    prefExtent := subMenu preferredExtent.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5451
    height     := prefExtent y.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5452
    width      := prefExtent x.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5453
    devBot     := device  usableHeight.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5454
    devRight   := device  usableWidth.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5455
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5456
    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
  5457
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5458
    menuPanel isPopUpView ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5459
        o := menuPanel origin + p
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5460
    ] ifFalse:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5461
        o := menuPanel translatePoint:p to:nil.   "/ translate to root window
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5462
    ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5463
    left := o x.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5464
    top  := o y.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5465
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5466
    top + height > devBot ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5467
        top := isVertical ifTrue:[devBot - height]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5468
                         ifFalse:[top - layout height - height + 2]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5469
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5470
    top := top max:0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5471
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5472
"/    (isVertical not and:[subMenu isVerticalLayout]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5473
"/        top < menuPanel bottom ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5474
"/            left := left + layout width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5475
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5476
"/        left + width > devRight ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5477
"/            left := o x - width - 2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5478
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5479
"/    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5480
        
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5481
    left + width > devRight ifTrue:[
2012
256be477be6d translatePoint fix.
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
  5482
        left := isVertical ifTrue:[left - layout width - width + 2]
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5483
                          ifFalse:[devRight - width]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5484
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5485
    left := left max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5486
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5487
    subMenu origin:(left@top).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5488
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5489
    subMenu realized ifFalse:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5490
        subMenu realize. 
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5491
    ] ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5492
        topMenu device mapWindow:(subMenu id).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5493
    ].
1790
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5494
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5495
    menuPanel openMenuOnSelect ifFalse:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5496
        (    menuPanel superMenu notNil                                         "/ not the top menu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5497
         or:[((item := subMenu itemAt:1) notNil and:[item hasSubmenu not])]     "/ top menu but no submenu item
1790
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5498
        ) ifTrue:[
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5499
            subMenu selectionIndex:1
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5500
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5501
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5502
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5503
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5504
toggleSubmenuVisibility
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5505
    "toggle the visibility of the submenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5506
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5507
    subMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5508
        subMenu shown ifTrue:[^ self hideSubmenu]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5509
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5510
        (subMenu := self setupSubmenu) isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5511
            "/ cannot open a submenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5512
            ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5513
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5514
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5515
    self openSubmenu.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5516
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5517
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5518
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5519
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5520
visibleSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5521
    "returns the current visible submenu or nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5522
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5523
    subMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5524
        subMenu shown ifTrue:[^ subMenu].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5525
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5526
    ^ nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5527
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5528
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5529
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5530
! !
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5531
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5532
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5533
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5534
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5535
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5536
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5537
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5538
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5539
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5540
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  5541
    (appl isValueModel) ifTrue:[
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5542
        ^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5543
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5544
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5545
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5546
        Object messageNotUnderstoodSignal handle:[:ex|
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5547
            ex parameter selector == aKey ifFalse:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5548
                ex reject
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5549
            ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  5550
            ('MenuPanel [info]: application does not provide aspect ' , aKey) infoPrintCR.
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5551
        ] do:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5552
            aKey last == $: ifTrue:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5553
                value := appl perform:aKey with:(argument ? self).
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5554
            ] ifFalse:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5555
                (appl isKindOf:ApplicationModel) ifTrue:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5556
                    value := appl aspectFor:aKey
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5557
                ] ifFalse:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5558
                    value := appl perform:aKey
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5559
                ]
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5560
            ]
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5561
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5562
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5563
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  5564
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  5565
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5566
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5567
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5568
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5569
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5570
update:something with:aParameter from:changedObject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5571
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5572
    |form rect|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5573
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5574
    (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
  5575
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5576
    self isSeparator ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5577
        "/ NOT A SEPARATOR
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5578
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5579
        menuPanel shown ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5580
            changedObject == enableChannel ifTrue:[
1864
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5581
                (enableChannel value == false and:[self isSelected]) ifTrue:[
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5582
                    ^ menuPanel selection:nil.
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5583
                ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5584
                ^ self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5585
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5586
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5587
            (changedObject == indication or:[changedObject == choice]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5588
                isButton ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5589
                    self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5590
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5591
                    "/ invalidate the interactor only
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5592
                    "/ take any interactor; interactors has the same extent
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5593
                    form := menuPanel iconIndicationOff.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5594
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5595
                    rect := Rectangle left:(layout left + HorizontalInset)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5596
                                       top:(layout top)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5597
                                     width:(form width)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5598
                                    height:(layout height).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5599
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5600
                    menuPanel invalidate:rect repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5601
                ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5602
                ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5603
            ].
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  5604
        ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  5605
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5606
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5607
    changedObject == isVisible ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5608
        menuPanel mustRearrange.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5609
        menuPanel rearrangeItems.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5610
      ^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5611
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5612
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  5613
    super update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5614
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5615
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5616
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5617
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5618
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5619
    (indication notNil and:[indication isSymbol]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5620
        " indication is a selector otherwise a change notification
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5621
          is raised from the model !!!!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5622
        "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5623
        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
  5624
    ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5625
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5626
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5627
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5628
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5629
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5630
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5631
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5632
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5633
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5634
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5635
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5636
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5637
    label isImage ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5638
        rcv := ResourceRetriever new.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5639
        rcv className:#MenuEditor.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5640
        rcv selector:#iconUnknown.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5641
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5642
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5643
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  5644
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5645
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5646
    enableChannel isSymbol ifTrue:[
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5647
        item enabled:enableChannel
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5648
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5649
    item font:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5650
    item accessCharacterPosition:accessCharacterPosition.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5651
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5652
    item startGroup:startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5653
    item argument:argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5654
    item nameKey:nameKey.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5655
    item shortcutKeyCharacter:shortcutKey.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5656
    value      isSymbol ifTrue:[item value:value].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5657
    indication isSymbol ifTrue:[item indication:indication].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5658
    choice     isSymbol ifTrue:[item choice:choice].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5659
    isVisible  isSymbol ifTrue:[item isVisible:isVisible].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5660
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5661
    item choiceValue:choiceValue.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5662
    item hideMenuOnActivated:hideMenuOnActivated.
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5663
    item keepLinkedMenu:keepLinkedMenu.
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5664
    item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5665
    item triggerOnDown:(self triggerOnDown).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5666
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5667
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5668
    submenuChannel isSymbol ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5669
        item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5670
    ] ifFalse:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5671
        subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5672
            item submenu:(subMenu asMenu)
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5673
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5674
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5675
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5676
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5677
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5678
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5679
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5680
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5681
    |lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5682
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5683
    menuPanel disabledRedrawDo:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5684
        label := rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5685
        accessCharacterPosition       := aMenuItem accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5686
        argument                      := aMenuItem argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5687
        choiceValue                   := aMenuItem choiceValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5688
        showBusyCursorWhilePerforming := aMenuItem showBusyCursorWhilePerforming.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5689
        triggerOnDown                 := aMenuItem triggerOnDown.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5690
        hideMenuOnActivated           := aMenuItem hideMenuOnActivated.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5691
        keepLinkedMenu                := aMenuItem keepLinkedMenu.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5692
        isButton                      := aMenuItem isButton ? false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5693
        nameKey                       := aMenuItem nameKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5694
        startGroup                    := aMenuItem startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5695
        shortcutKey                   := aMenuItem shortcutKeyCharacter.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5696
        value                         := aMenuItem value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5697
        activeHelpKey                 := aMenuItem activeHelpKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5698
        activeHelpText                := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5699
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5700
        self font:(aMenuItem font).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5701
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5702
        self    enabled:(aMenuItem enabled).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5703
        self indication:(aMenuItem indication).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5704
        self     choice:(aMenuItem choice).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5705
        self  isVisible:(aMenuItem isVisible).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5706
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5707
        (lbl := aMenuItem labelImage value) isNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5708
            lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5709
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5710
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5711
        self label:lbl.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5712
        submenuChannel := aMenuItem submenuChannel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5713
        self submenu:(aMenuItem submenu).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5714
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  5715
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  5716
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5717
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5718
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5719
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5720
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5721
drawButton
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5722
    "draw as button
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5723
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5724
    |drawObject fg level isSelected bg ownBgCol
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5725
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5726
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5727
    drawObject := rawLabel.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5728
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5729
    "COMPUTE COLORS"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5730
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5731
        bg := self activeBackgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5732
        fg := self activeForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5733
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5734
        self isEntered ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5735
            bg := self buttonEnteredBackgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5736
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5737
            bg := self backgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5738
        ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5739
        self enabled ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5740
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5741
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5742
            fg := menuPanel disabledForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5743
            drawObject := self disabledRawLabel
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5744
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5745
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5746
1708
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5747
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5748
        bg := ownBgCol
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5749
    ].
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5750
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5751
    "DRAW BACKGROUND"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5752
    bg ~= menuPanel backgroundColor ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5753
        menuPanel paint:bg.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5754
        menuPanel fillRectangle:layout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5755
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5756
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5757
    x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5758
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5759
    isSelected ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5760
        "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
  5761
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5762
        indication notNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5763
            "button is indicator and set"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5764
            isSelected := self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5765
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5766
            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
  5767
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5768
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5769
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5770
    isSelected ifTrue:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5771
        level := menuPanel buttonActiveLevel.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5772
        x     := x + level abs.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5773
    ] ifFalse:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5774
        level := self isEntered ifTrue:[menuPanel buttonEnteredLevel]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5775
                               ifFalse:[menuPanel buttonPassiveLevel].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5776
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5777
    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
  5778
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5779
    level ~~ 0 ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5780
        menuPanel drawButtonEdgesFor:self level:level
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5781
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5782
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5783
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5784
drawLabel
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5785
    "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
  5786
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5787
    |scKey cLb cLa drawObject fg arrow 
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5788
     isSelected isEnabled form
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5789
     h "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5790
     y "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5791
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5792
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5793
    |
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5794
    drawObject := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  5795
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5796
    isEnabled := self enabled.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5797
    isSelected := self isSelected.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5798
    isSelected ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5799
        fg := self activeForegroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5800
    ] ifFalse:[
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5801
        isEnabled ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5802
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5803
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5804
            fg  := menuPanel disabledForegroundColor.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5805
            drawObject := self disabledRawLabel
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5806
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5807
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5808
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5809
    h := layout height.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5810
    x := layout left + HorizontalInset.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5811
    t := layout top.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5812
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5813
    ((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
  5814
        y := t + ((h - form height) // 2).
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5815
        
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5816
        form displayOn:menuPanel x:x y:y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5817
        x := x + 2 + form width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5818
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5819
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5820
    self drawRawLabel:drawObject atX:x paint:fg.
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  5821
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5822
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5823
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5824
    (     shortcutKey notNil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5825
     and:[(x := menuPanel shortKeyInset) ~~ 0
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5826
     and:[(scKey:= self shortcutKeyAsString) notNil]]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5827
    ) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5828
        x := layout left + x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5829
        y := t + ((h - (scKey heightOn:menuPanel)) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5830
        y := y + menuPanel font ascent.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5831
        scKey displayOn:menuPanel x:x y:y. 
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5832
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  5833
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5834
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5835
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5836
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5837
        arrow := menuPanel rightArrow.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5838
        x := layout right - arrow width - HorizontalInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5839
        y := t + (h - arrow height // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5840
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5841
        (menuPanel styleSheet is3D not
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5842
        or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5843
            ^ menuPanel displayForm:arrow x:x y:y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5844
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5845
        cLa := menuPanel shadowColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5846
        cLb := menuPanel lightColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5847
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5848
        isSelected ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5849
            fg  := cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5850
            cLa := cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5851
            cLb := fg
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5852
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5853
        menuPanel paint:cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5854
        menuPanel displayForm:arrow x:x y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5855
        menuPanel paint:cLb.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5856
        menuPanel displayForm:drawObject x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5857
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  5858
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  5859
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5860
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5861
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5862
drawRawLabel:aLabel atX:x paint:fg
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5863
    "draw a labeled entry; no button, no separator.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5864
    "
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5865
    |mfont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5866
     y  "{ Class:SmallInteger }"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5867
     y0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5868
     x0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5869
    |
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5870
    mfont := menuPanel setFont:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5871
    menuPanel paint:fg.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5872
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5873
    y := layout top + (layout height - rawLabelExtent y // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5874
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5875
    aLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5876
        aLabel isImageOrForm ifFalse:[
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5877
            y := y + menuPanel font ascent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5878
        ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5879
        aLabel displayOn:menuPanel x:x y:y.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5880
    ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5881
        aLabel do:[:el|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5882
            el notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5883
                el isImageOrForm ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5884
                    y0 := y + menuPanel font ascent
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5885
                ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5886
                    y0 := y
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5887
                ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5888
                x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5889
                el displayOn:menuPanel x:x0 y:y0.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5890
                y := y + 1 + (el heightOn:menuPanel)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5891
            ] ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5892
                y := y + 3   "/ see #label:
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5893
            ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5894
        ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5895
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5896
    menuPanel setFont:mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5897
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5898
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5899
drawSeparatingLines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5900
    "draw separating lines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5901
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5902
    |index item lfSep rtSep items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5903
     l "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5904
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5905
     r "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5906
     b "{ Class:SmallInteger }"
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  5907
    |
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5908
    items := menuPanel items.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5909
    index := items identityIndexOf:self.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5910
    item  := items at:(index - 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5911
    lfSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5912
    item  := items at:(index + 1) ifAbsent:nil.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5913
    rtSep := item notNil and:[item isButton not].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5914
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5915
    (lfSep isNil and:[rtSep]) isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5916
        ^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5917
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5918
    menuPanel paint:(menuPanel lightColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5919
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5920
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5921
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5922
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5923
    b := layout bottom.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5924
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5925
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5926
        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
  5927
        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
  5928
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5929
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5930
        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
  5931
        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
  5932
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5933
        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
  5934
        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
  5935
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5936
        menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5937
        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
  5938
        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
  5939
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5940
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5941
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5942
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5943
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5944
drawSeparator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5945
    "draw as separator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5946
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5947
    |type lightColor isDouble
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5948
     x0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5949
     x1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5950
     y0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5951
     y1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5952
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5953
    type := self separatorType.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5954
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5955
    (type isNil or:[type == #blankLine]) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5956
        ^ self
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5957
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5958
    isDouble   := type == #doubleLine.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5959
    lightColor := menuPanel lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5960
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5961
    menuPanel paint:(menuPanel shadowColor).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5962
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5963
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5964
        x0 := layout left  + HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5965
        x1 := layout right - HorizontalInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5966
        y0 := layout top   - 1 + (layout height // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5967
        isDouble ifTrue:[y0 := y0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5968
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5969
                         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
  5970
        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
  5971
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5972
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5973
                         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
  5974
        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
  5975
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5976
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5977
        y1 := layout bottom.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5978
        x0 := layout left - 1 + (layout width // 2).
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5979
        y0 := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5980
        isDouble ifTrue:[x0 := x0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5981
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5982
                         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
  5983
        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
  5984
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5985
        menuPanel paint:lightColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5986
                         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
  5987
        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
  5988
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5989
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5990
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5991
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5992
invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5993
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5994
    (rawLabel notNil and:[menuPanel notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5995
        menuPanel invalidateItem:self repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5996
    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5997
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5998
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5999
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6000
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6001
redraw
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6002
    "redraw item
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6003
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6004
    |isSelected ownBgCol paint bgColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6005
     x  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6006
     y  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6007
     w  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6008
     h  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6009
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6010
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6011
    self isVisible ifFalse:[^ self].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6012
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6013
    rawLabel isNil  ifTrue:[^ self drawSeparator].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6014
    isButton        ifTrue:[^ self drawButton].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6015
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6016
    "/ 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
  6017
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6018
    isSelected := self isSelected.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6019
    bgColor    := menuPanel backgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6020
    paint      := isSelected ifTrue:[self activeBackgroundColor] ifFalse:[bgColor].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6021
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6022
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6023
        paint := ownBgCol
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6024
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6025
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6026
    paint ~= bgColor ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6027
        menuPanel paint:paint.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6028
        menuPanel fillRectangle:layout.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6029
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6030
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6031
    menuPanel showSeparatingLines ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6032
        self drawSeparatingLines
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6033
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6034
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6035
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6036
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6037
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6038
        ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6039
                                 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6040
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6041
        x := layout left.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6042
        y := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6043
        w := layout width.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6044
        h := layout height.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6045
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6046
        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
  6047
        menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4).  
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6048
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6049
    menuPanel drawLabelEdgeFor:self selected:isSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6050
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6051
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6052
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6053
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6054
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6055
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6056
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6057
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6058
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6059
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6060
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6061
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6062
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6063
    enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6064
    isVisible     isValueModel  ifTrue:[isVisible    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6065
    indication    isValueModel ifTrue:[indication    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6066
    choice        isValueModel ifTrue:[choice        removeDependent:self].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6067
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6068
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6069
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6070
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6071
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6072
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6073
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6074
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6075
    isButton  := false.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6076
!
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6077
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6078
reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6079
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6080
    subMenu notNil ifTrue:[
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6081
        subMenu reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6082
    ].
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6083
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6084
    "Created: / 17.8.2000 / 17:57:07 / cg"
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6085
    "Modified: / 17.8.2000 / 18:00:08 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6086
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6087
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6088
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6089
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6090
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6091
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6092
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6093
    |block form image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6094
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6095
    disabledRawLabel notNil ifTrue:[^ disabledRawLabel].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6096
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6097
    disabledRawLabel := rawLabel ? ''.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6098
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6099
    disabledRawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6100
        ^ disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6101
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6102
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6103
    block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6104
        (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6105
            el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6106
                el colorMap notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6107
                    rslt := menuPanel lightenedImageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6108
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6109
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6110
                el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6111
                    ((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6112
                        form := menuPanel lightenedImageOnDevice:form
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6113
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6114
                    ((image := el image) notNil and:[image colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6115
                        image := menuPanel lightenedImageOnDevice:image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6116
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6117
                    rslt := LabelAndIcon form:form image:image string:(el string).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6118
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6119
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6120
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6121
        rslt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6122
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6123
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6124
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6125
        disabledRawLabel := Array new:(rawLabel size).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6126
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6127
        rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6128
            disabledRawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6129
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6130
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6131
        disabledRawLabel := block value:rawLabel
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6132
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6133
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6134
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6135
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6136
fetchDeviceResources
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6137
    disabledRawLabel := nil.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6138
    self fetchImages.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6139
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6140
    font notNil ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6141
        font := font onDevice:(menuPanel device)
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6142
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6143
!
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6144
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6145
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6146
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6147
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6148
    |icon block|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6149
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6150
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6151
        block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6152
            (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6153
                el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6154
                    rslt := menuPanel imageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6155
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6156
                    el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6157
                        (icon := el image) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6158
                            el image:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6159
                        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6160
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6161
                        (icon := el icon) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6162
                            el icon:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6163
                        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6164
                    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6165
                ]
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6166
            ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6167
            rslt
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6168
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6169
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6170
        rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6171
            rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6172
                rawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6173
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6174
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6175
            rawLabel := block value:rawLabel
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6176
        ]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6177
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6178
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6179
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6180
updateAccessCharacterFor:aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6181
    |s i rest label pos|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6182
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6183
    (accessCharacter notNil or:[aLabel isNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6184
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6185
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6186
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6187
    aLabel isString ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6188
        aLabel class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6189
            aLabel string:(self updateAccessCharacterFor:(aLabel string))
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6190
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6191
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6192
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6193
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6194
    s := aLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6195
    i := 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6196
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6197
    label := aLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6198
    pos := accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6199
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6200
    [((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
  6201
        rest := label copyFrom:(i+1).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6202
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6203
        i == 1 ifTrue:[label := rest]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6204
              ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6205
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6206
        (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
  6207
        s := s - 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6208
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6209
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6210
    (pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[
1762
840521c06b92 bugfix for && in label
ca
parents: 1750
diff changeset
  6211
        ^ label
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6212
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6213
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6214
    label isText ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6215
        label := Text string:label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6216
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6217
    label emphasisAt:pos add:#underline.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6218
  ^ label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6219
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6220
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6221
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6222
!MenuPanel::Item methodsFor:'printing & storing'!
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6223
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6224
displayString
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6225
    ^ self class name, '[', label printString, ']'
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6226
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6227
! !
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6228
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6229
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6230
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6231
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6232
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6233
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6234
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6235
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6236
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6237
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6238
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6239
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6240
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6241
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6242
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6243
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6244
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6245
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6246
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6247
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6248
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6249
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6250
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6251
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6252
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6253
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6254
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6255
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6256
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6257
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6258
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6259
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6260
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6261
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6262
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6263
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6264
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6265
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6266
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6267
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6268
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6269
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6270
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6271
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6272
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6273
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6274
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6275
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6276
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6277
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6278
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6279
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6280
    "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
  6281
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6282
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6283
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6284
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6285
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6286
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6287
    "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
  6288
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6289
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6290
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6291
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6292
    "
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6293
    |isOn|
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6294
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6295
    choice isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6296
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6297
    isOn := choice value = choiceValue.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6298
    self enabled ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6299
        ^ isOn ifTrue:[menuPanel iconRadioGroupDisabledOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6300
               ifFalse:[menuPanel iconRadioGroupDisabledOff]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6301
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6302
    ^ isOn ifTrue:[menuPanel iconRadioGroupOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6303
           ifFalse:[menuPanel iconRadioGroupOff]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6304
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6305
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6306
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6307
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6308
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6309
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6310
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6311
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6312
    |subm sel num|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6313
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6314
    aRecv isNil ifTrue:[^ nil].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6315
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6316
    sel := submenuChannel asSymbol.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6317
    num := sel numArgs.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6318
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6319
    num == 0 ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6320
        Object messageNotUnderstoodSignal handle:[:ex|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6321
            |selector|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6322
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6323
            ((selector := ex parameter selector) == sel
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6324
            or:[selector == #aspectFor:]) ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6325
                ex reject
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6326
            ].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6327
        ] do:[
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6328
            subm := aRecv aspectFor:sel.
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6329
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6330
        subm notNil ifTrue:[^ subm].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6331
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6332
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6333
    (Array with:(aRecv) with:(aRecv class))
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6334
    do:[:aPossibleReceiver |
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6335
        Object messageNotUnderstoodSignal handle:[:ex|
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6336
            ex parameter selector == sel ifFalse:[ ex reject ]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6337
        ] do:[
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6338
                     num == 0 ifTrue:[subm := aPossibleReceiver perform:sel]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6339
            ifFalse:[num == 1 ifTrue:[subm := aPossibleReceiver perform:sel with:(argument ? menuPanel)]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6340
            ifFalse:[                 subm := aPossibleReceiver perform:sel with:argument with:menuPanel]]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6341
        ].
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6342
        subm notNil ifTrue:[^ subm].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6343
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6344
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6345
    ^ subm
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6346
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6347
    "Modified: / 30.10.2001 / 13:28:25 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6348
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6349
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6350
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6351
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6352
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6353
    |numArgs sel recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6354
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6355
    indication isNil ifTrue:[^ nil].                                    "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6356
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6357
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6358
        ^ indication value == true                                      "block or model"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6359
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6360
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6361
    (numArgs := indication numArgs) == 2 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6362
        recv := menuPanel receiver.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6363
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6364
        (recv isValueModel) ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6365
            (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6366
                sel := indication copyFrom:1 to:(indication indexOf:$:).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6367
                sel := sel asSymbol.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6368
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6369
                Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6370
                    ex parameter selector == sel ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6371
                        ex reject
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6372
                    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6373
                ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6374
                    sel := recv perform:sel with:argument
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6375
                ]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6376
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6377
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6378
        ^ sel value == true
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6379
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6380
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6381
    numArgs ~~ 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6382
        sel := (indication copyWithoutLast:1) asSymbol
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6383
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6384
        sel := indication
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6385
    ].    
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6386
    sel := self aspectAt:sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6387
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6388
    sel isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6389
        indication := sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6390
        indication addDependent:self.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6391
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6392
    ^ sel value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6393
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6394
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6395
indicationValue:aValue
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6396
    "set the indication value
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6397
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6398
    |numArgs recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6399
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6400
    indication isNil ifTrue:[^ self].                                   "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6401
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6402
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6403
        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
  6404
      ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6405
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6406
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6407
    (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
  6408
        ^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6409
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6410
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6411
    recv := menuPanel receiver.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6412
    recv isValueModel ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6413
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6414
    recv isNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6415
        recv := menuPanel application.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6416
        recv isNil ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6417
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6418
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6419
    Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6420
        (ex parameter selector ~~ indication) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6421
            ex reject
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6422
        ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6423
        ('MenuPanel [info]: application does not respond to ' , indication) infoPrintCR.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6424
    ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6425
        numArgs == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6426
            recv perform:indication with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6427
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6428
            recv perform:indication with:(argument ? self) with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6429
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6430
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6431
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6432
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6433
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6434
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6435
    "
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6436
    |val|
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6437
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6438
    indication isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6439
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6440
    val := self indicationValue.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6441
    self enabled ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6442
        ^ val == true 
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6443
            ifTrue:[menuPanel iconIndicationDisabledOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6444
            ifFalse:[menuPanel iconIndicationDisabledOff]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6445
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6446
    ^ val == true 
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6447
        ifTrue:[menuPanel iconIndicationOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6448
        ifFalse:[menuPanel iconIndicationOff]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6449
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6450
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6451
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6452
    "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
  6453
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6454
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6455
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6456
    "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
  6457
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6458
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  6459
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  6460
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6461
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6462
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6463
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6464
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6465
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6466
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6467
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6468
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6469
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6470
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6471
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6472
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6473
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6474
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6475
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6476
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6477
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6478
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6479
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6480
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6481
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6482
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6483
    submenuChannel notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6484
        submenuChannel isSymbol ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6485
            subm := submenuChannel
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6486
        ] ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6487
            appl := menuPanel application.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6488
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6489
            (subm := self findSubMenuIn:appl) isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6490
                (recv := menuPanel receiver) ~~ appl ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6491
                    subm := self findSubMenuIn:recv
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6492
                ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6493
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6494
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6495
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6496
        (subm := subm value) isArray ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6497
            subm := Menu new fromLiteralArrayEncoding:subm.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6498
            "/ cg: linked menus also may contain translations ...
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6499
            subm notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6500
                appl notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6501
                    subm findGuiResourcesIn:appl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6502
                ]                
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6503
            ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6504
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6505
        self submenu:subm.
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6506
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6507
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6508
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6509
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6510
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6511
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6512
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6513
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6514
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6515
canChangeVisibility
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6516
    "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
  6517
     otherwise there is a change notification raised if the model changed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6518
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6519
    ^ isVisible isSymbol
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6520
"/  ^ isVisible notNil and:[isVisible ~~ true]
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6521
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6522
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6523
canSelect
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6524
    "returns true if item is selectable; no separator, visible and enabled.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6525
     in case of a choice (RadioButton) i have to check for the choiceValue
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6526
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6527
    (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
  6528
        (choice isNil or:[choice value ~= choiceValue]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6529
            ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6530
        ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6531
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6532
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6533
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6534
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6535
containsPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6536
    "returns true if aPoint is contained in my layout
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6537
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6538
    (self isVisible and:[layout notNil]) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6539
        ^ layout containsPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6540
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6541
    ^ false
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6542
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6543
    "Created: / 13.11.2001 / 13:55:31 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6544
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6545
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6546
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6547
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6548
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6549
    (self isVisible and:[layout notNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6550
        ^ layout containsPointX:x y:y
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  6551
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  6552
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6553
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6554
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6555
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6556
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6557
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6558
    ^ indication notNil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6559
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6560
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6561
hasSubmenu
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6562
    "returns true if the item is configured as an subMenu entry
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6563
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  6564
    ^ subMenu notNil or:[submenuChannel notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6565
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6566
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6567
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6568
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6569
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6570
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6571
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6572
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6573
isLabeledItem
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6574
    "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
  6575
    "
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6576
    ^ rawLabel notNil and:[isButton not]
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6577
!
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6578
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6579
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6580
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6581
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6582
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6583
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6584
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6585
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6586
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6587
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6588
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6589
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6590
    isVisible isSymbol ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6591
        state := self aspectAt:isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6592
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6593
        state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6594
            isVisible := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6595
            isVisible addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6596
            state := isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6597
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6598
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6599
        state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6600
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6601
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6602
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6603
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6604
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6605
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6606
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6607
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6608
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6609
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6610
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6611
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6612
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6613
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6614
        oldState := isVisible value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6615
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6616
            isVisible removeDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6617
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6618
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6619
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6620
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6621
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6622
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6623
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6624
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6625
            isVisible addDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6626
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6627
            isVisible isSymbol ifTrue:[^ self]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6628
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6629
        menuPanel shown ifFalse:[^ self].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6630
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6631
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6632
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6633
    newState ~~ oldState ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6634
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6635
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6636
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6637
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6638
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6639
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6640
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6641
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6642
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6643
    |nm prefix|
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6644
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6645
    shortcutKey isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6646
        ^ nil
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6647
    ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6648
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6649
    shortcutKey isCharacter ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6650
        nm := shortcutKey asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6651
    ] ifFalse:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6652
        "/ this is somewhat complicated: we have the symbolic key at hand,
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6653
        "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6654
        "/ Ask the devices keyboardMap for the backtranslation.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6655
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6656
        nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6657
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6658
        "/ some modifier-key combination ?
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6659
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6660
        (nm startsWith:#Cmd) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6661
            prefix := #Cmd.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6662
        ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6663
            prefix := #Alt.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6664
        ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6665
            prefix := #Meta.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6666
        ] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6667
            prefix := #Ctrl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6668
        ]]]].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6669
        prefix notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6670
            nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6671
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6672
            nm := nm asString
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6673
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6674
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6675
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6676
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6677
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6678
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6679
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6680
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6681
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6682
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6683
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6684
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6685
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6686
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6687
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6688
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6689
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6690
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6691
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6692
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6693
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6694
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6695
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6696
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6697
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6698
    "
1998
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  6699
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  6700
    ^ menuPanel notNil and:[menuPanel selection == self]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6701
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6702
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6703
selected:isSelected
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6704
    "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
  6705
     submenu and perform a redraw
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6706
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6707
    menuPanel isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6708
        ^ self hideSubmenu
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6709
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6710
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6711
    isSelected ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6712
        self invalidate.
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6713
        self hideSubmenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6714
    ] ifTrue:[
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6715
        menuPanel realized ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6716
            (indication isNil or:[isButton not]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6717
                self invalidate
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6718
            ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6719
1788
e1f32720fbb4 donot automatically open the submenu of a popup menu
ca
parents: 1787
diff changeset
  6720
            (menuPanel isPopUpView not or:[menuPanel openMenuOnSelect]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6721
                (subMenu := self setupSubmenu) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6722
                    self openSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6723
                ]
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6724
            ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6725
        ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6726
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6727
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6728
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6729
!MenuPanel::Scrolling class methodsFor:'default icons'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6730
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6731
icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6732
    "This resource specification was automatically generated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6733
     by the ImageEditor of ST/X."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6734
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6735
    "Do not manually edit this!! If it is corrupted,
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6736
     the ImageEditor may not be able to read the specification."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6737
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6738
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6739
     self icon inspect
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6740
     ImageEditor openOnClass:self andSelector:#icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6741
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6742
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6743
    <resource: #image>
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6744
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6745
    ^Icon
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6746
        constantNamed:#'MenuPanel::Scrolling class icon'
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6747
        ifAbsentPut:[(Depth1Image new) width: 11; height: 11; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?>@@@@@@ @C@@N@@<@C8@O<@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 11; height: 11; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@_<@? A<@C @D@@@@@@@@@@@a') ; yourself); yourself]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6748
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6749
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6750
!MenuPanel::Scrolling class methodsFor:'instance creation'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6751
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6752
new
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6753
    ^ self basicNew initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6754
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6755
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6756
!MenuPanel::Scrolling methodsFor:'accessing'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6757
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6758
activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6759
    "returns the active menu the scrolling is activated on; nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6760
     is returned if scrolling is deactivated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6761
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6762
    ^ activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6763
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6764
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6765
direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6766
    "returns the scroll-direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6767
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6768
    ^ direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6769
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6770
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6771
iconAt:aDirection on:aMenu
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6772
    |icon device index|
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6773
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6774
    device := aMenu device.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6775
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6776
    aDirection == #PREV ifTrue:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6777
        aMenu verticalLayout ifTrue:[index := 3]    "/ 3 - 1 * 90  180
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6778
                            ifFalse:[index := 2]    "/ 2 - 1 * 90  90   
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6779
    ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6780
        aMenu verticalLayout ifTrue:[index := 1]    "/ 1 - 1 * 90  0
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6781
                            ifFalse:[index := 4]    "/ 4 - 1 * 90  270
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6782
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6783
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6784
    icon := icons at:index.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6785
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6786
    (icon isNil or:[icon device ~~ device]) ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6787
        icon := self class icon.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6788
        index > 1 ifTrue:[ icon := icon rotated:(index - 1 * 90) ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6789
                 ifFalse:[ icon := icon copy ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6790
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6791
        icon := icon onDevice:device.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6792
        icon clearMaskedPixels.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6793
        icons at:index put:icon
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6794
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6795
    ^ icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6796
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6797
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6798
!MenuPanel::Scrolling methodsFor:'initialization'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6799
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6800
initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6801
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6802
    semaLock := RecursionLock new.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6803
    icons    := Array new:4.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6804
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6805
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6806
!MenuPanel::Scrolling methodsFor:'queries'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6807
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6808
isActive
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6809
    "returns true if scrolling is activated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6810
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6811
    ^ activeMenu notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6812
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6813
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6814
!MenuPanel::Scrolling methodsFor:'user operations'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6815
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6816
startAt:aDirection on:aMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6817
    "start scrolling; returns true if scrolling is activated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6818
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6819
    |bounds index|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6820
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6821
    semaLock critical:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6822
        self stop.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6823
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6824
        (     aDirection notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6825
         and:[aMenu notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6826
         and:[(bounds := aMenu scrollerBoundsAt:aDirection) notNil]]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6827
        ) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6828
            activeMenu := aMenu.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6829
            direction  := aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6830
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6831
            index := aMenu indexOfItemAtScroller:aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6832
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6833
            index ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6834
                scrollTask := [ |item step|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6835
                                [
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6836
                                    step := (aDirection == #PREV) ifTrue:[-1] ifFalse:[1].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6837
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6838
                                    [ aMenu shown and:[(item := aMenu itemAt:index) notNil] ] whileTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6839
                                        aMenu makeItemVisible:item.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6840
                                        Delay waitForSeconds:0.05.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6841
                                        index := index + step.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6842
                                    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6843
                                    item := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6844
                                ] valueNowOrOnUnwindDo:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6845
                                    scrollTask := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6846
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6847
                                    item notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6848
                                        "/ process was killed
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6849
                                        aMenu invalidate:bounds
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6850
                                    ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6851
                                ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6852
                              ] forkAt:8.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6853
            ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6854
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6855
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6856
    ^ bounds notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6857
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6858
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6859
stop
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6860
    "stop scrolling; returns true if the scrolling was activated otherwise false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6861
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6862
    |task resp|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6863
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6864
    activeMenu isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6865
        ^ false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6866
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6867
    semaLock critical:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6868
        resp := activeMenu notNil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6869
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6870
        (task := scrollTask) notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6871
            scrollTask := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6872
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6873
            Error handle:[:ex|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6874
            ] do:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6875
                task terminateWithAllSubprocesses.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6876
                task waitUntilTerminated.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6877
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6878
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6879
        activeMenu := direction := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6880
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6881
    ^ resp
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6882
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6883
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6884
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6885
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6886
version
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6887
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.283 2001-11-13 13:19:27 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6888
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6889
MenuPanel initialize!