MenuPanel.st
author Claus Gittinger <cg@exept.de>
Tue, 11 Dec 2001 12:53:42 +0100
changeset 2062 31ba9af25394
parent 2061 faf64f2cd28e
child 2063 8bff9e49f1e9
permissions -rw-r--r--
checkin from browser
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
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    20
		lastActiveMenu activeBgColor disabledFgColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    21
		disabledEtchedFgColor groupDividerSize itemSpace fitFirstPanel
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    22
		rightArrow rightArrowShadow selectionFrameBrightColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    23
		selectionFrameDarkColor buttonLightColor buttonShadowColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    24
		buttonHalfLightColor buttonHalfShadowColor enteredItem
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    25
		buttonEnteredBgColor prevFocusView previousPointerGrab
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    26
		previousKeyboardGrab relativeGrabOrigin hasImplicitGrap
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    27
		iconIndicationOff iconIndicationOn iconRadioGroupOff
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    28
		iconRadioGroupOn iconIndicationDisabledOff
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    29
		iconIndicationDisabledOn iconRadioGroupDisabledOff
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    30
		iconRadioGroupDisabledOn scrolling'
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    31
	classVariableNames:'InitialSelectionQuerySignal DefaultAdornment ShortcutKeyOffset
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    32
		DefaultGroupDividerSize DefaultHilightLevel DefaultLevel
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    33
		DefaultItemSpace DefaultButtonItemSpace DefaultForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    34
		DefaultBackgroundColor DefaultHilightForegroundColor
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
    35
		DefaultHilightBackgroundColor DefaultDisabledForegroundColor
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    36
		DefaultDisabledEtchedForegroundColor DefaultEnteredLevel
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    37
		DefaultSelectionFollowsMouse DefaultOpenOnSelect
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    38
		DefaultFitFirstPanel RightArrowForm RightArrowShadowForm
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    39
		SelectionFrameBrightColor SelectionFrameDarkColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    40
		ButtonActiveLevel ButtonPassiveLevel ButtonActiveBackgroundColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    41
		ButtonPassiveBackgroundColor ButtonLightColor ButtonShadowColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    42
		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle Images
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
    43
		LigthenedImages ButtonEnteredBackgroundColor ButtonEnteredLevel'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    44
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    45
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    46
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    47
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    48
Object subclass:#Item
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    49
	instanceVariableNames:'layout menuPanel subMenu rawLabel rawLabelExtent disabledRawLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    50
		enableChannel nameKey value label activeHelpKey activeHelpText
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    51
		submenuChannel startGroup isButton isVisible hideMenuOnActivated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
    52
		indication accessCharacterPosition shortcutKey argument choice
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
    53
		choiceValue showBusyCursorWhilePerforming accessCharacter font
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
    54
		keepLinkedMenu triggerOnDown'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    55
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
    56
		VerticalButtonInset LabelRightOffset VerticalPopUpInset'
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    57
	poolDictionaries:''
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
    58
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    61
Object subclass:#Scrolling
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
    62
	instanceVariableNames:'semaLock activeMenu scrollTask direction icons'
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    63
	classVariableNames:''
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    64
	poolDictionaries:''
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    65
	privateIn:MenuPanel
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    66
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    67
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    68
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    69
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    70
copyright
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    71
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    72
 COPYRIGHT (c) 1997 by eXept Software AG
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    73
	      All Rights Reserved
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    74
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    75
 This software is furnished under a license and may be used
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    76
 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
    77
 inclusion of the above copyright notice.   This software may not
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    78
 be provided or otherwise made available to, or used by, any
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    79
 other person.  No title to or ownership of the software is
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    80
 hereby transferred.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    81
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    82
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    83
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    84
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    85
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    86
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    87
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    88
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    89
    not yet finished MenuPanel class - this will eventually replace
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
    most of the MenuView and PopUpMenu stuff.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    91
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    92
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    93
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    94
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    95
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    96
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    97
    Notice:
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    98
        This is going to replace the obsolete MenuView.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    99
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   100
    DefaultSelectionFollowsMouse := true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   101
    DefaultSelectionFollowsMouse := false.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   102
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   103
    [author:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   104
        Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   105
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    [see also:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   107
        Menu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   108
        MenuItem
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   109
        MenuEditor
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   112
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   114
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
    start as PullDownMenu
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   117
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   118
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   122
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   124
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   126
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   127
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   128
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   130
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   131
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   134
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   138
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   140
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   141
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   144
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   145
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   146
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   148
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   149
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   150
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   151
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   152
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   153
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   154
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   155
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   156
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   157
    top open.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   158
                                                                                [exEnd]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   159
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   160
                                                                                [exBegin]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   161
    |top menu view item|
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   162
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   163
    top  := StandardSystemView extent:240@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   164
    menu := MenuPanel in:top.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   165
    menu labels:#( 'foo' 'Application' 'Clock' ).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   166
    menu verticalLayout:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   167
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   168
    menu subMenuAt:1 put:(MenuPanel labels:#( 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   169
    menu subMenuAt:2 put:(MenuPanel labels:#( 'foo' 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   170
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   171
    view := ClockView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   172
    view preferredExtent:100@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   173
    item := menu itemAt:3.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   174
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   175
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   176
    view := SimpleView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   177
    view client:(CodingExamples_GUI::GUIDemoExtendedComboBox new).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   178
    view preferredExtent:(400@50).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   179
    item := menu itemAt:2.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   180
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   181
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   182
    menu origin:0@0 corner:1.0@30.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   183
    top open.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   184
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   185
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   186
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   187
    start as PopUpMenu
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   188
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   189
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   190
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   191
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   192
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   193
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   194
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   195
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   196
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   197
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   198
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   199
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   200
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   201
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   202
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   203
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   204
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   205
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   206
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   207
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   208
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   209
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   210
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   211
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   212
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   213
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   214
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   215
    mview startUp
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   216
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   217
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   218
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   219
    start from menu spec
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   220
                                                                                [exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   221
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   222
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   223
    menu := MenuPanel menu:
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   224
        #(#Menu #( #(#MenuItem 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   225
                    #label: 'File' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   226
                    #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   227
                      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   228
                                 (#MenuItem 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   229
                                    #label: 'edit' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   230
                                    #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   231
                                      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   232
                                                 #(#MenuItem #label: 'close' #value:#close)     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   233
                                               )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   234
                                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   235
                                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   236
                                       )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   237
                                  )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   238
                                 #(#MenuItem #label: 'help' #value:#help )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   239
                               )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   240
                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   241
                               nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   242
                       )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   243
                 ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   244
                #(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   245
                #(#MenuItem #label: 'Bar' 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   246
                            #submenu:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   247
                               #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   248
                                          #(#MenuItem #label: 'bar 2' #value:#bar2 )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   249
                                        )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   250
                                        nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   251
                                        nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   252
                                )     
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   253
                 ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   254
              ) 
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   255
              #( 2 )
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   256
              nil
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   257
         ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
    Transcript showCR:(menu startUp).
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   261
                                                                                [exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   262
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   263
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   267
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   268
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   269
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   274
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
    aSpec notNil ifTrue:[
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   277
        menu := Menu new.
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   278
        menu receiver:aReceiver.
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   279
        menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   285
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   286
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   287
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   288
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   289
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   290
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   291
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   292
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   293
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   294
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   295
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   296
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   297
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   298
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   299
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   300
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   301
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   302
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   303
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   304
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   305
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   306
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   307
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   308
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   309
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   310
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   311
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   312
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   313
    mview := self new.
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   314
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   315
    (aMenu notNil and:[aMenu receiver isNil]) ifTrue:[
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   316
        "/ no receiver specified in the menu; thus set the receiver immediately
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   317
        mview receiver:aReceiver
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   318
    ].
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   319
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   320
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   321
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   322
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   323
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   324
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   325
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   326
    aReceiver notNil ifTrue:[
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   327
        mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   328
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   329
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   330
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   331
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   332
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   333
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   334
initialize
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   335
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   336
    DefaultAdornment := nil.
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   337
    self initialize
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   338
    "
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   339
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   340
    InitialSelectionQuerySignal isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   341
	InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   342
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   343
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   344
    DefaultAdornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   345
	DefaultAdornment := IdentityDictionary new
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   346
	    at:#showSeparatingLines put:false;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   347
	    at:#showGroupDivider    put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   348
	    at:#verticalLayout      put:true;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   349
	    at:#item                put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   350
	    at:#value               put:nil;
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
   351
	    yourself
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   352
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   353
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   354
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   355
!
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
preSnapshot
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   358
    "remove all resources
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   359
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   360
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   361
    LigthenedImages := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   362
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   363
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   364
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   365
!MenuPanel class methodsFor:'default icons'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   366
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   367
iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   368
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   369
     by the ImageEditor of ST/X."
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
    "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
   372
     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
   373
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
     self iconIndicationDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   376
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOff
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
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   379
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   380
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   381
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   382
        constantNamed:#'MenuPanel iconIndicationDisabledOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   383
        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
   384
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   385
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   386
iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   387
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   388
     by the ImageEditor of ST/X."
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
    "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
   391
     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
   392
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
     self iconIndicationDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   395
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOn
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
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   398
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   399
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   400
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   401
        constantNamed:#'MenuPanel iconIndicationDisabledOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   402
        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
   403
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   404
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   405
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   406
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   407
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   410
     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
   411
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
     self iconIndicationOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   414
     ImageEditor openOnClass:self andSelector:#iconIndicationOff
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   417
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   418
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   419
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   420
        constantNamed:#'MenuPanel iconIndicationOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   421
        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
   422
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   423
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   424
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   425
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   426
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   429
     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
   430
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
     self iconIndicationOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   433
     ImageEditor openOnClass:self andSelector:#iconIndicationOn
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   436
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   437
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   438
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   439
        constantNamed:#'MenuPanel iconIndicationOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   440
        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
   441
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   442
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   443
iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   444
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   445
     by the ImageEditor of ST/X."
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
    "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
   448
     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
   449
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
     self iconRadioGroupDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   452
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOff
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
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   455
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   456
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   457
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   458
        constantNamed:#'MenuPanel iconRadioGroupDisabledOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   459
        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
   460
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   461
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   462
iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   463
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   464
     by the ImageEditor of ST/X."
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
    "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
   467
     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
   468
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
     self iconRadioGroupDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   471
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn
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
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   474
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   475
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   476
    ^Icon
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   477
        constantNamed:#'MenuPanel iconRadioGroupDisabledOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   478
        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
   479
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   480
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   481
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   482
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   483
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   486
     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
   487
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
     self iconRadioGroupOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   490
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   493
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   494
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   495
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   496
        constantNamed:#'MenuPanel iconRadioGroupOff'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   497
        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
   498
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   499
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   500
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   501
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   502
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   505
     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
   506
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
     self iconRadioGroupOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   509
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   512
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   513
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   514
    ^Icon
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   515
        constantNamed:#'MenuPanel iconRadioGroupOn'
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   516
        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
   517
! !
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   518
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   519
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   520
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   521
mnemonicIdentifier
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   522
    "returns the identifier each mnemonic starts with;
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   523
     ex:
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   524
        &File   mnemonic := Cmdf
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   525
        F&ile   mnemonic := Cmdi
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
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   528
    ^ 'Cmd'
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   529
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   530
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   531
updateStyleCache
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   532
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   533
    <resource: #style (#'menu.foregroundColor' #'menu.backgroundColor'
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   534
                       #'menu.hilightForegroundColor'  #'menu.hilightBackgroundColor' 
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   535
                       #'menu.disabledForegroundColor' #'menu.disabledEtchedForegroundColor'
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   536
                       #'menu.buttonEnteredBackgroundColor'
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   537
                       #'menu.hilightLevel'  #'menu.groupDividerSize'
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   538
                       #'menu.itemSpace'     #'menu.buttonItemSpace'
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   539
                       #'menu.fitFirstPanel' #'menu.buttonActiveLevel'
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   540
                       #'menu.buttonPassiveLevel'    #'menu.buttonEnteredLevel'
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   541
                       #'menu.selectionFollowsMouse' #'menu.enteredLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   542
                       #'viewBackground'
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   543
                       #'pullDownMenu.level'  
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   544
                       #'pullDownMenu.hilightLevel'
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   545
                       #'button.disabledForegroundColor' #'button.disabledEtchedForegroundColor'
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   546
                       #'button.enteredBackgroundColor'
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   547
                       #'button.activeBackgroundColor' #'button.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   548
                       #'button.lightColor' #'button.shadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   549
                       #'button.halfLightColor' #'button.halfShadowColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   550
                       #'button.passiveLevel' #'button.activeLevel'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   551
                       #'button.edgeStyle')>
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   552
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   553
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   554
    |style styleSheet|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   555
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   556
    styleSheet := StyleSheet.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   557
    style      := styleSheet name.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   558
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   559
    DefaultForegroundColor := styleSheet colorAt:#'menu.foregroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   560
                                         default:Color black.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   561
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   562
    DefaultBackgroundColor := styleSheet colorAt:#'menu.backgroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   563
                                         default:DefaultViewBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   564
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   565
    DefaultHilightForegroundColor := styleSheet colorAt:#'menu.hilightForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   566
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   567
    DefaultHilightForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   568
        styleSheet is3D ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   569
            DefaultHilightForegroundColor := DefaultForegroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   570
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   571
            DefaultHilightForegroundColor := DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   572
        ].
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
    DefaultDisabledForegroundColor := styleSheet colorAt:#'menu.disabledForegroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   576
    DefaultDisabledForegroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   577
        DefaultDisabledForegroundColor := styleSheet colorAt:#'button.disabledForegroundColor'
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   578
                                                     default:Color darkGray.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   579
    ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   580
    DefaultDisabledEtchedForegroundColor := styleSheet colorAt:#'menu.disabledEtchedForegroundColor'.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   581
    DefaultDisabledEtchedForegroundColor isNil ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   582
        DefaultDisabledEtchedForegroundColor := styleSheet colorAt:#'button.disabledEtchedForegroundColor'.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   583
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   584
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   585
    DefaultHilightBackgroundColor := styleSheet colorAt:#'menu.hilightBackgroundColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   586
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   587
    DefaultHilightBackgroundColor isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   588
        style == #motif ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   589
            DefaultHilightBackgroundColor := DefaultBackgroundColor
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   590
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   591
            DefaultHilightBackgroundColor := styleSheet is3D ifFalse:[DefaultForegroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   592
                                                              ifTrue:[DefaultBackgroundColor]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   593
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   594
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   595
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   596
    DefaultLevel := styleSheet at:#'pullDownMenu.level' default:0.
1337
f0ed36b3c3d6 style fixes
Claus Gittinger <cg@exept.de>
parents: 1336
diff changeset
   597
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   598
    (style == #motif or:[style == #iris]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   599
        DefaultHilightLevel := 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   600
        DefaultLevel        := DefaultLevel + 1.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   601
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   602
        (DefaultHilightLevel    := styleSheet at:'pullDownMenu.hilightLevel') isNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   603
            DefaultHilightLevel := styleSheet at:'menu.hilightLevel' default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   604
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   605
        styleSheet is3D ifTrue:[DefaultLevel := DefaultLevel + 1].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   606
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   607
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   608
    DefaultGroupDividerSize := styleSheet at:#'menu.groupDividerSize' default:6.
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
   609
    DefaultItemSpace        := styleSheet at:#'menu.itemSpace' default:2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   610
    DefaultButtonItemSpace  := styleSheet at:#'menu.buttonItemSpace' default:0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   611
    DefaultFitFirstPanel    := styleSheet at:#'menu.fitFirstPanel' default:true.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   612
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
   613
    MenuView updateStyleCache.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   614
    DefaultFont    := MenuView defaultFont.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   615
    RightArrowForm := SelectionInListView rightArrowFormOn:Display.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   616
1054
f56416a8d26b win95 has no 3D right-arrow for subMenus.
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
   617
    (style ~~ #os2 and:[style ~~ #win95]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   618
        RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   619
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   620
        RightArrowShadowForm := nil
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   621
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   622
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   623
    SelectionFrameBrightColor    := Color white.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   624
    SelectionFrameDarkColor      := Color black.
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
   625
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   626
    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
   627
    ButtonActiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   628
        ButtonActiveLevel        :=  styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   629
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   630
    ButtonPassiveLevel           :=  styleSheet at:#'menu.buttonPassiveLevel'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   631
    ButtonPassiveLevel isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   632
        ButtonPassiveLevel       :=  styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0]).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   633
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   634
    ButtonActiveBackgroundColor  :=  styleSheet at:#'button.activeBackgroundColor' default: DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   635
    ButtonPassiveBackgroundColor := (styleSheet at:#'button.backgroundColor') ? (styleSheet at:'viewBackground') ? DefaultBackgroundColor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   636
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   637
    ButtonLightColor             := styleSheet at:#'button.lightColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   638
    ButtonLightColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   639
        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
   640
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   641
    ButtonShadowColor            :=  styleSheet at:#'button.shadowColor'.
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
   642
    ButtonShadowColor isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   643
        ButtonShadowColor := (ButtonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened. "/ Color white
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   644
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   645
    ButtonHalfLightColor         :=  styleSheet at:#'button.halfLightColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   646
    ButtonHalfShadowColor        :=  styleSheet at:#'button.halfShadowColor'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   647
    ButtonEdgeStyle              :=  styleSheet at:#'button.edgeStyle'.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   648
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   649
    ButtonEnteredBackgroundColor := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   650
    ButtonEnteredBackgroundColor isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   651
        ButtonEnteredBackgroundColor := styleSheet colorAt:#'button.enteredBackgroundColor'
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   652
                                                  default:ButtonPassiveBackgroundColor.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   653
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   654
    ButtonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:ButtonPassiveLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   655
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   656
    DefaultSelectionFollowsMouse := styleSheet at:#'menu.selectionFollowsMouse' default:false.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   657
    DefaultEnteredLevel          := styleSheet at:#'menu.enteredLevel'          default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
   658
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   659
    ShortcutKeyOffset            := 5.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   660
    DefaultOpenOnSelect := styleSheet at:#'menu.openOnSelect' default:false.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   661
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   662
    Item updateStyleCache
1018
67c883ab05d6 kludge fixes for normal style.
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   663
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   664
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   665
     self updateStyleCache
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   666
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   667
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   668
    "Modified: / 10.9.1998 / 21:40:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   669
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   670
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   671
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   672
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   673
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   674
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   675
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   676
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   677
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   678
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   679
    anImage device == aDevice ifTrue:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   680
        ^ anImage
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   681
    ].
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   682
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   683
    Images isNil ifTrue:[ Images := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   684
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   685
    (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
   686
        Images at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   687
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   688
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   689
    (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
   690
        ^ image
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   691
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   692
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   693
    image := anImage copy onDevice:aDevice.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   694
    image clearMaskedPixels.
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   695
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   696
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   697
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   698
    "Modified: / 29.9.1998 / 12:02:41 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   699
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   700
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   701
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   702
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   703
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   704
"
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   705
    |deviceImages image|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   706
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   707
    LigthenedImages isNil ifTrue:[ LigthenedImages := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   708
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   709
    (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
   710
        LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   711
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   712
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   713
    (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
   714
        ^ image
794
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
    ((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
   718
        image := anImage copy lightened onDevice:aDevice.
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   719
        image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   720
    ] ifFalse:[
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   721
        image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   722
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   723
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   724
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   725
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   726
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   727
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   728
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   729
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   730
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   731
subMenu:aSubMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   732
    "create a submenu; can be redifined in derived classes
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   733
    "
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   734
  ^ (self new) menu:aSubMenu.
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   735
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   736
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   737
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   738
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
   739
!MenuPanel methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   740
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   741
accept
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   742
    "accept current selected item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   743
    "
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   744
    ^ self acceptItem:(self selection) inMenu:self
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   745
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   746
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
   747
accept:anItem 
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   748
    "this is the topMenu: accept item
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   749
    "
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   750
    |value item tgState itemIdx recv panel masterGroup winGrp acceptAction|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
   751
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   752
    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
   753
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   754
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
   755
    self scrolling stop.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   756
    self selection:nil.
420
ca
parents: 417
diff changeset
   757
ca
parents: 417
diff changeset
   758
    (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
   759
        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
   760
        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
   761
        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
   762
        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
   763
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   764
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   765
    self doUngrab:true.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   766
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   767
    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
   768
        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
   769
        self windowGroup processExposeEvents.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   770
    ] 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
   771
        self unmap.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   772
        (winGrp := self windowGroup) notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   773
            "/ give expose event a chance to arrive
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   774
            [shown and:[realized]] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   775
                winGrp processExposeEventsFor:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   776
            ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   777
            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
   778
        ].
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   779
        "/ cg: disabled-not needed - try PopUpList with destroy...
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   780
        "/ self destroy.
1382
a852ac554869 oops - query for shown is not enough to wait for a view to
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   781
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   782
    ].
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   783
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   784
    acceptAction := [ value := self accept:item index:itemIdx toggle:tgState receiver:recv ].
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   785
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   786
    (item notNil 
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   787
    and:[item showBusyCursorWhilePerforming
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   788
    and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]])
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   789
    ifTrue:[
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   790
        winGrp withWaitCursorDo:acceptAction
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   791
    ] ifFalse:acceptAction.
524
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
    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
   794
        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
   795
        self menuAdornmentAt:#item  put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   796
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   797
    ^ item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   798
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   799
    "Modified: / 15.11.2001 / 17:05:40 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   800
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   801
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   802
accept:anItem index:anIndex toggle:aState receiver:aReceiver
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   803
    "accept an item
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   804
    "
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   805
    |value argument numArgs isKindOfValueModel rec args arg2 
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   806
     app master fallBack|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   807
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   808
    anItem isNil ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   809
        self menuAdornmentAt:#hasPerformed put:true.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   810
        ^ nil
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   811
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   812
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   813
    self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   814
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   815
    (value := anItem value) isNil ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   816
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   817
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   818
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   819
    (argument := anItem argument) isNil ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   820
        argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   821
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   822
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   823
    value isSymbol ifFalse:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   824
        "/ a valueHolder or block
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   825
        (value respondsTo:#valueWithArguments:) ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   826
             ^ value
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   827
        ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   828
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   829
        numArgs := value perform:#numArgs ifNotUnderstood:0.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   830
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   831
        numArgs == 0 ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   832
            args := nil
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   833
        ] ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   834
            numArgs == 1 ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   835
                args := Array with:argument
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   836
            ] ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   837
                args := Array with:argument with:self
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   838
            ]
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   839
        ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   840
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   841
        value valueWithArguments:args.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   842
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   843
        self menuAdornmentAt:#hasPerformed put:true.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   844
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   845
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   846
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   847
    aReceiver isNil ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   848
        ^ value
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   849
    ].
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   850
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   851
    isKindOfValueModel := aReceiver isValueModel.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   852
    isKindOfValueModel ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   853
        aReceiver value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   854
    ] ifFalse:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   855
        rec := aReceiver.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   856
        arg2 := self.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   857
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   858
        "/ support for ST80 style applications
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   859
        "/ (expecting the message to go to the application
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   860
        "/  if not understood by the view)
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   861
        "/ These expect the controller to be passed as argument.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   862
        "/ sigh.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   863
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   864
        (aReceiver isView
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   865
        and:[(aReceiver respondsTo:value) not
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   866
        and:[(app := aReceiver application) ~~ aReceiver
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   867
        and:[app notNil]]]) ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   868
            rec := app.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   869
            arg2 := aReceiver controller "/ the Views controller
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   870
        ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   871
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   872
        (numArgs := value numArgs) == 0 ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   873
            args := nil
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   874
        ] ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   875
            numArgs == 1 ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   876
                args := Array with:argument
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   877
            ] ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   878
                args := Array with:argument with:arg2
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   879
            ]
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   880
        ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   881
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   882
        fallBack := 
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   883
            [
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   884
                "/ mhmh - the receiver did not respond to that message;
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   885
                "/ if there is a master-application, try that one
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   886
                "/ (recursive)
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   887
                master := rec perform:#masterApplication ifNotUnderstood:nil.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   888
                master notNil ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   889
                    rec := master.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   890
                    rec perform:value withArguments:args ifNotUnderstood:fallBack
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   891
                ] ifFalse:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   892
                    self 
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   893
                        error:'unimplemented (or error in) menu message: ' , value
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   894
                        mayProceed:true
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   895
                ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   896
            ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   897
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   898
        rec perform:value withArguments:args ifNotUnderstood:fallBack.
420
ca
parents: 417
diff changeset
   899
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   900
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   901
    ^ value
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
   902
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   903
    "Modified: / 19.2.2000 / 11:08:22 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   904
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   905
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   906
acceptItem:anItem inMenu:aMenu
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   907
    |tgState|
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   908
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
   909
    (anItem isNil or:[anItem hideMenuOnActivated]) ifTrue:[
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   910
        self topMenu accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   911
    ] ifFalse:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   912
        anItem canAccept ifTrue:[
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   913
            tgState := anItem toggleIndication.
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   914
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   915
            self accept:anItem
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   916
                  index:(aMenu selectionIndex)
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   917
                 toggle:tgState 
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   918
               receiver:(aMenu receiver).
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   919
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   920
            aMenu do:[:el| el updateIndicators].
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   921
        ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   922
    ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   923
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   924
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   925
lastItemAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   926
    "returns last item selected or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   927
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   928
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   929
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   930
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   931
lastValueAccepted
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   932
    "returns last value accepted or nil
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   933
    "
971
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   934
    ^ (self lastItemAccepted) value
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   935
"/    |top|
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   936
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   937
"/    top := self topMenu.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   938
"/
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   939
"/    (top menuAdornmentAt:#hasPerformed) == true ifTrue:[
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   940
"/        ^ self topMenu menuAdornmentAt:#value.
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   941
"/    ].
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   942
"/  ^ nil
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   943
c000e2691543 fixed #lastValueSelected
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   944
    "Modified: / 18.6.1998 / 23:37:09 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   945
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   946
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   947
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   948
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   949
accessCharacterPositionAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   950
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   951
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   952
    ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   953
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   954
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   955
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
   956
    "get the access character position for a textLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   957
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   958
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   959
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   960
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   961
accessCharacterPositions
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   962
    "returns a collection of accessCharacterPosition's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   963
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   964
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   965
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   966
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   967
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   968
accessCharacterPositions:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   969
    "define accessCharacterPosition's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   970
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   971
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   972
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   973
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   974
args
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   975
    "returns a collection of argument's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   976
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   977
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   978
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   979
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   980
args:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   981
    "define arguments for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   982
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   983
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   984
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   985
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   986
argsAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   987
    "gets the argument of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   988
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   989
    ^ self itemAt:stringOrNumber do:[:el| el argument ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   990
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   991
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   992
argsAt:stringOrNumber put:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   993
    "sets the argument of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   994
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   995
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   996
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   997
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   998
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   999
    "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
  1000
     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
  1001
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1002
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1003
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1004
    "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
  1005
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1006
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1007
groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1008
    "gets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1009
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1010
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1011
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1012
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1013
groupSizes:aGroupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1014
    "sets collection of group sizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1015
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1016
    aGroupSizes = groupSizes ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1017
	groupSizes := aGroupSizes copy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1018
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1019
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1020
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1021
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1022
labelAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1023
    "gets the label of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1024
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1025
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1026
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1027
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1028
labelAt:stringOrNumber put:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1029
    "sets the label of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1030
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1031
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1032
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1033
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1034
labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1035
    "returns a collection of labels's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1036
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1037
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1038
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1039
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1040
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1041
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1042
    "define labels for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1043
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1044
    self disabledRedrawDo:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1045
	self removeAll.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1046
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1047
	labels notNil ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1048
	    labels do:[:aLabel|(self createAtIndex:nil) label:aLabel]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1049
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1050
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1051
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1052
1999
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1053
menuPerformer:anObject 
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1054
    "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
  1055
     from all submenus no specific receiver is defined ).
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1056
    "
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1057
    ^ self receiver:anObject
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1058
!
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1059
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
nameKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1061
    "gets the nameKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1062
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1063
  ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1064
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1065
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1066
nameKeyAt:stringOrNumber put:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1067
    "sets the nameKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1068
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1069
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1070
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1071
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1072
nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1073
    "returns a collection of nameKeys's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1074
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1075
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1076
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1077
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1078
nameKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1079
    "define nameKeys for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1080
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1081
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1082
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1083
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1084
numberOfItems
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1085
    "gets number of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1086
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1087
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1088
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1089
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1090
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1091
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1092
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1093
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1094
    (receiver isNil and:[superMenu notNil]) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1095
	^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1096
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1097
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1098
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1099
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1100
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1101
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1102
     from all submenus no specific receiver is defined ).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1103
    "
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1104
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1105
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1106
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1107
shortcutKeyAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1108
    "gets the shortCutKey of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1109
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1110
  ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1111
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1112
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1113
shortcutKeyAt:stringOrNumber put:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1114
    "sets the shortCutKey of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1115
    "
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1116
    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
  1117
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1118
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1119
shortcutKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1120
    "returns a collection of shortcutKey's or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1121
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1122
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1123
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1124
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1125
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1126
shortcutKeys:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1127
    "define shortcutKey's for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1128
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1129
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1130
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1132
valueAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1133
    "gets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1134
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1135
  ^ self itemAt:stringOrNumber do:[:el| el value ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1136
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1137
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1138
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1139
valueAt:stringOrNumber put:someThing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1140
    "sets value of an item; a block, valueHolder, ...
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1141
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1142
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1143
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1144
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1145
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1146
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1147
values:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1148
    "define values for each item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1149
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1150
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1151
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1152
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1153
!MenuPanel methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1154
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1155
disableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1156
    "disable all items; not the menu in case of enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1157
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1158
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1159
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1160
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1161
disableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1162
    "disable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1163
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1164
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1165
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1166
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1167
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1168
enableAll
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1169
    "enable all items; not the menu in case of disabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1170
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1171
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1172
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1173
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1174
enableAll:collectionOfIndicesOrNames
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1175
    "enable an collection of items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1176
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1177
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1178
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1179
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1180
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1181
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1182
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1183
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1184
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1185
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1186
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1187
enabled:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1188
    "change enabled state of menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1189
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  1190
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1191
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1192
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1193
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1194
    enabled ~~ state ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1195
        enabled := state.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1196
        self invalidate.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1197
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1198
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1199
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1200
enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1201
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1202
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1203
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1204
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1205
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1206
enabledAt:stringOrNumber put:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1207
    "sets the enabled state of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1208
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1209
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1210
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1211
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1212
isEnabled:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1213
    "gets the enabled state of an item or false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1214
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1215
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1216
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1217
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1218
!MenuPanel methodsFor:'accessing-channels'!
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1219
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1220
enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1221
    "gets a enable channel or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1222
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1223
    ^ enableChannel
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1224
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1225
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1226
enableChannel:aValueHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1227
    "set my enableChannel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1228
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1229
    enableChannel notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1230
	enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1231
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1232
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1233
    (enableChannel := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1234
	enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1235
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1236
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1237
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1238
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1239
menuHolder
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1240
    "gets a menu holder or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1241
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1242
    ^ menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1243
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1244
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1245
menuHolder:aValueHolder
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1246
    "set my menuHolder
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1247
    "
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1248
    menuHolder notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1249
	menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1250
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1251
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1252
    (menuHolder := aValueHolder) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1253
	menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1254
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1255
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1256
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1257
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1258
!MenuPanel methodsFor:'accessing-color & font'!
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1259
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1260
activeBackgroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1261
    "get the background drawing color used to highlight selection
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1262
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1263
    ^ activeBgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1264
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1265
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1266
activeForegroundColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1267
    "get the foreground color used to highlight selections
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1268
    "
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1269
    ^ activeFgColor
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1270
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1271
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1272
backgroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1273
    "return the background color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1274
    "
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1275
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1276
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1277
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1278
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1279
    "set the background drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1280
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1281
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1282
    super viewBackground ~~ aColor ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1283
	super viewBackground:aColor.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1284
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1285
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1286
	]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1287
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1288
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1289
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1290
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1291
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1292
buttonActiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1293
    "get the background drawing color used to highlight button selection
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1294
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1295
    ^ ButtonActiveBackgroundColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1296
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1297
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1298
buttonEdgeStyle
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1299
    "get the button edge style
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1300
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1301
    ^ ButtonEdgeStyle
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1302
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1303
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1304
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1305
    "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
  1306
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1307
    ^ buttonEnteredBgColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1308
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1309
    "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
  1310
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1311
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1312
buttonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1313
    "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
  1314
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1315
    ^ ButtonEnteredLevel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1316
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1317
    "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
  1318
    "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
  1319
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1320
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1321
buttonHalfLightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1322
    "get the background drawing color used to half light button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1323
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1324
    ^ buttonHalfLightColor
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1325
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1326
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1327
buttonHalfShadowColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1328
    "get the background drawing color used to half shadow button frame
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1329
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1330
    ^ buttonHalfShadowColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1331
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1332
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1333
buttonLightColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1334
    "get the background drawing color used to light button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1335
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1336
    ^ buttonLightColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1337
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1338
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1339
buttonPassiveBackgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1340
    "get the background drawing color used for button
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1341
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1342
    ^ ButtonPassiveBackgroundColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1343
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1344
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1345
buttonShadowColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1346
    "get the background drawing color used to shadow button frame
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1347
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1348
    ^ buttonShadowColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1349
!
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1350
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1351
disabledEtchedForegroundColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1352
    "return the color used for etching disabled items.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1353
     If nil, no 3D effect is drawn.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1354
    "
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1355
    ^ disabledEtchedFgColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1356
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1357
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1358
disabledForegroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1359
    "return the foreground color used by disabled items
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1360
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1361
    ^ disabledFgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1362
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1363
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1364
font:aFont
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1365
    "set the font
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1366
    "
829
c86ed87da63b bug fix:
ca
parents: 828
diff changeset
  1367
    (aFont notNil and:[aFont ~= font]) ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1368
        super font:(aFont onDevice:device).
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1369
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1370
        superMenu notNil ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1371
            self extent:(self preferredExtent)
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1372
        ].
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1373
        self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1374
    ]
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1375
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1376
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1377
foregroundColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1378
    "return the passive foreground color
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1379
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1380
    ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1381
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1382
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1383
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1384
    "set the foregroundColor drawing color. You should not use this method;
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1385
     instead leave the value as defined in the styleSheet.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1386
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1387
    fgColor ~~ aColor ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1388
        fgColor := aColor onDevice:device.
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1389
        shown ifTrue:[
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1390
            self invalidate "/ RepairNow:true
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1391
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1392
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1393
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1394
    "Modified: / 6.6.1998 / 19:50:46 / cg"
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1395
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1396
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1397
lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1398
    "get the lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1399
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1400
    ^ lightColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1401
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1402
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1403
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1404
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1405
maxAbsoluteButtonLevel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1406
    "returns the maximum absolute button level; used to compute the preferred
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1407
     extent of a button
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1408
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1409
    |level|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1410
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1411
    level := (ButtonActiveLevel abs) max:(ButtonEnteredLevel abs).
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1412
    ^ level max:(ButtonPassiveLevel abs)
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1413
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1414
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1415
selectionFrameBrightColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1416
    "get the selection frame bright color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1417
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1418
    ^ selectionFrameBrightColor
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1419
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1420
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1421
selectionFrameDarkColor
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1422
    "get the selection frame dark color
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1423
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1424
    ^ selectionFrameDarkColor
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1425
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1426
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1427
setFont:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1428
    "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
  1429
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1430
    |currentFont|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1431
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1432
    (aFont notNil and:[aFont ~= font]) ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1433
        currentFont := font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1434
        super font:aFont.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1435
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1436
    ^ currentFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1437
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1438
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1439
shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1440
    "get the shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1441
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1442
    ^ shadowColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1443
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1444
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1445
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1446
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1447
!MenuPanel methodsFor:'accessing-dimensions'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1448
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1449
height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1450
    "default height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1451
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1452
    (explicitExtent ~~ true) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1453
        ^ self preferredExtent y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1454
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1455
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1456
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1457
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1458
maxExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1459
    "CLAUS: returns the maximum extent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1460
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1461
    |x y|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1462
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1463
    device isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1464
        superMenu notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1465
            ^ superMenu maxExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1466
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1467
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1468
    y := device usableHeight - 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1469
    x := device usableWidth  - 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1470
  ^ x@y
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1471
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1472
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1473
preferredExtent
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1474
    "compute and returns my preferred extent
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1475
    "
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1476
    |maxExtent usedExtent w|
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1477
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1478
    preferredExtent notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1479
        ^ preferredExtent
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1480
    ].
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1481
    maxExtent  := self maxExtent.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1482
    usedExtent := self preferredExtentOfItems.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1483
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1484
    superView isNil ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1485
        "/ is standalone
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1486
        w := self menuAdornmentAt:#Width.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1487
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1488
        w notNil ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1489
            usedExtent x < w ifTrue:[
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1490
                usedExtent := w @ usedExtent y.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1491
            ]
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1492
        ]
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1493
    ].
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1494
        
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1495
    ^ usedExtent min:maxExtent
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1496
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1497
    "Modified: / 10.10.2001 / 14:57:25 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1498
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1499
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1500
preferredExtentOfItems
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1501
    "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
  1502
        !!!!!! changes have influence on method #rearrangeItems !!!!!!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1503
    "
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1504
    |hasMenu shCtKey extent showAcc sck
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1505
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1506
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1507
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1508
     buttonInset "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1509
     labelInset  "{ Class:SmallInteger }"
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1510
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1511
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1512
    (size := items size) == 0 ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1513
        ^ 32 @ 32
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1514
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1515
    buttonInset := 2 * (DefaultButtonItemSpace abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1516
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1517
    self isPopUpView ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1518
        labelInset := 2 * (DefaultEnteredLevel abs).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1519
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1520
        labelInset := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1521
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1522
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1523
    x := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1524
    y := 0.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1525
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1526
    self verticalLayout ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1527
        "/ HORIZONTAL LAYOUT
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1528
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1529
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1530
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1531
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1532
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1533
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1534
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1535
                
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1536
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1537
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1538
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1539
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1540
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1541
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1542
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1543
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1544
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1545
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1546
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1547
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1548
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1549
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1550
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1551
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1552
                x := eX + x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1553
                y := eY max:y.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1554
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1555
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1556
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1557
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1558
        shCtKey := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1559
        showAcc := MenuView showAcceleratorKeys == true.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1560
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1561
        x := 0.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1562
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1563
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1564
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1565
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1566
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1567
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1568
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1569
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1570
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1571
                    eX := eX + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1572
                    eY := eY + buttonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1573
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1574
                    eX := eX + labelInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1575
                    eY := eY + labelInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1576
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1577
                hasMenu ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1578
                    hasMenu := el hasSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1579
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1580
                (showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1581
                    shCtKey := shCtKey max:(sck widthOn:self)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1582
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1583
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1584
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1585
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1586
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1587
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1588
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1589
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1590
                y := eY + y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1591
                x := eX max:x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1592
            ].
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1593
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1594
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1595
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1596
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1597
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1598
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1599
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1600
                x := x + ShortcutKeyOffset 
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1601
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1602
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1603
"/ to have a small inset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1604
        y := y + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1605
"/        x := x + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1606
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1607
    x := x + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1608
    y := y + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1609
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1610
  ^ x @ y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1611
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1612
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1613
preferredWidth:aWidth
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1614
    self menuAdornmentAt:#Width put:aWidth.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1615
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1616
    "Created: / 10.10.2001 / 14:56:39 / cg"
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1617
!
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1618
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1619
shortKeyInset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1620
    "left inset of shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1621
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1622
  ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1623
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1624
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1625
subMenuIndicationWidth
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1626
    ^ RightArrowForm width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1627
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1628
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1629
!MenuPanel methodsFor:'accessing-interactors'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1630
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1631
iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1632
    iconIndicationDisabledOff isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1633
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1634
            iconIndicationDisabledOff := superMenu iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1635
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1636
            iconIndicationDisabledOff := self registerImageOnDevice:(self class iconIndicationDisabledOff)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1637
        ].
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
    ^ iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1640
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1641
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1642
iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1643
    iconIndicationDisabledOn isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1644
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1645
            iconIndicationDisabledOn := superMenu iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1646
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1647
            iconIndicationDisabledOn := self registerImageOnDevice:(self class iconIndicationDisabledOn)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1648
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1649
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1650
    ^ iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1651
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1652
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1653
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1654
    iconIndicationOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1655
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1656
            iconIndicationOff := superMenu iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1657
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1658
            iconIndicationOff := self registerImageOnDevice:(self class iconIndicationOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1659
        ].
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
    ^ iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1662
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1663
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1664
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1665
    iconIndicationOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1666
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1667
            iconIndicationOn := superMenu iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1668
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1669
            iconIndicationOn := self registerImageOnDevice:(self class iconIndicationOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1670
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1671
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1672
    ^ iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1673
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1674
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1675
iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1676
    iconRadioGroupDisabledOff isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1677
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1678
            iconRadioGroupDisabledOff := superMenu iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1679
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1680
            iconRadioGroupDisabledOff := self registerImageOnDevice:(self class iconRadioGroupDisabledOff)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1681
        ].
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
    ^ iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1684
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1685
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1686
iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1687
    iconRadioGroupDisabledOn isNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1688
        superMenu notNil ifTrue:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1689
            iconRadioGroupDisabledOn := superMenu iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1690
        ] ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1691
            iconRadioGroupDisabledOn := self registerImageOnDevice:(self class iconRadioGroupDisabledOn)
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1692
        ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1693
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1694
    ^ iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1695
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1696
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1697
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1698
    iconRadioGroupOff isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1699
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1700
            iconRadioGroupOff := superMenu iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1701
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1702
            iconRadioGroupOff := self registerImageOnDevice:(self class iconRadioGroupOff)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1703
        ].
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
    ^ iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1706
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1707
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1708
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1709
    iconRadioGroupOn isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1710
        superMenu notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1711
            iconRadioGroupOn := superMenu iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1712
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1713
            iconRadioGroupOn := self registerImageOnDevice:(self class iconRadioGroupOn)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1714
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1715
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1716
    ^ iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1717
! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1718
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1719
!MenuPanel methodsFor:'accessing-items'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1720
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1721
itemAt:stringOrNumber
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1722
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1723
     If no item match nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1724
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1725
    |idx|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1726
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1727
    idx := self indexOf:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1728
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1729
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1730
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1731
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1732
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1733
itemAt:stringOrNumber do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1734
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1735
     the item not exists nil is returned
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1736
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1737
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1738
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1739
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1740
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1741
    "evaluate teh block for an item and return the result from the block. In case that  
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1742
     the item not exists the result of the exception block is returned (no arguments).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1743
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1744
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1745
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1746
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1747
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1748
  ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1749
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1750
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1751
itemAtIndex:anIndex
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1752
    "returns item at an index or nil
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1753
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1754
    ^ 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
  1755
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1756
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1757
items
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1758
    "returns list of items or nil
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1759
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1760
    ^ items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1761
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1762
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1763
!MenuPanel methodsFor:'accessing-look'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1764
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1765
buttonActiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1766
    "get the button active level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1767
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1768
    ^ ButtonActiveLevel
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1769
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1770
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1771
buttonPassiveLevel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1772
    "get the button passive level
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1773
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1774
    ^ ButtonPassiveLevel
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1775
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1776
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1777
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1778
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1779
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1780
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1781
     NOT SUPPORTED
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1782
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1783
    ^ fitFirstPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1784
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1785
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1786
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1787
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1788
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1789
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1790
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1791
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1792
    fitFirstPanel := aState.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1793
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1794
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1795
groupDividerSize
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1796
    "get the size of the group dividers
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1797
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1798
  ^ groupDividerSize
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
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1802
groupDividerSize:aSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1803
    "set the size of the group dividers. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1804
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1805
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1806
    aSize ~~ groupDividerSize ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1807
	groupDividerSize := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1808
	self mustRearrange.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1809
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1810
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1811
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1812
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1813
itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1814
    "get the space space between to items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1815
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1816
  ^ itemSpace
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1817
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1818
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1819
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1820
itemSpace:aSize
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1821
    "set the horizontal space between to items. You should not use this
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1822
     method; instead leave the value as defined in the styleSheet.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1823
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1824
    aSize ~~ itemSpace ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1825
	itemSpace := aSize.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1826
	self mustRearrange
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1827
    ].
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1828
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1829
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1830
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1831
level:anInt
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1832
    anInt ~~ level ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1833
        super level:anInt.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1834
        self mustRearrange
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1835
    ]
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1836
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1837
    "Modified: / 15.11.2001 / 17:42:07 / cg"
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1838
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1839
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1840
rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1841
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1842
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1843
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1844
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1845
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1846
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1847
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1848
showGroupDivider
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1849
    "get the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1850
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1851
  ^ (self menuAdornmentAt:#showGroupDivider)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1852
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1853
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1854
showGroupDivider:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1855
    "set the enabled flag for showing groupDiveders
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1856
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1857
    (self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1858
	self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1859
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1860
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1861
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1862
showSeparatingLines
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1863
    "gets true if drawing of separating lines is enabled.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1864
    "
1222
8d58a1a93582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
  1865
  ^ (self menuAdornmentAt:#showSeparatingLines)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1866
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1867
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1868
showSeparatingLines:aState
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1869
    "turn on/off drawing of separating lines.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1870
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1871
    (self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1872
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1873
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1874
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1875
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1876
verticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1877
    "get the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1878
    "
1824
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1879
    |direction|
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1880
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1881
    direction := self menuAdornmentAt:#verticalLayout.
ad38ecd8752d support horizontal or vertical layout for popup menus
ca
parents: 1819
diff changeset
  1882
  ^ direction notNil ifTrue:[direction] ifFalse:[superMenu notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1883
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1884
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1885
verticalLayout:aState
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1886
    "set the layout: or vertical( true ) or horizontal( false )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1887
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1888
    (self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[        
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1889
	self mustRearrange
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1890
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1891
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1892
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1893
!MenuPanel methodsFor:'accessing-submenu'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1894
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1895
subMenuAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1896
    "gets the submenu of an item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1897
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1898
  ^ self itemAt:stringOrNumber do:[:el| el submenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1899
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1900
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1901
subMenuAt:stringOrNumber put:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1902
    "sets the submenu of an item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1903
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1904
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1905
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1906
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1907
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1908
subMenuShown
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1909
    "return the currently visible submenu - or nil if there is none
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1910
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1911
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1912
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1913
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  1914
	^ item submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1915
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1916
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1917
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1918
1698
8d29156bab20 category rename
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1919
!MenuPanel methodsFor:'activation / deactivation'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1920
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1921
closeMenus
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1922
    "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
  1923
    "
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1924
    self topMenu accept:nil.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1925
!
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  1926
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1927
hide
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1928
    "hide the view, leave its modal event loop
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1929
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1930
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1931
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1932
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1933
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1934
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1935
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1936
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1937
show
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1938
    "realize the view at its last position;
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1939
     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
  1940
     (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
  1941
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1942
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1943
  ^ self showAt:(self origin) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1944
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1945
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1946
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1947
showAt:aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1948
    "realize the view at aPoint.
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1949
     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
  1950
     (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
  1951
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1952
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1953
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1954
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1955
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1957
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1958
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1959
    "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
  1960
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1961
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1962
     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
  1963
     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
  1964
     if a non-nil is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1965
    "
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1966
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  1967
    self rearrangeItemsIfItemVisibilityChanged.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1968
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1969
    aBoolean ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1970
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1971
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1972
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1973
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1974
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1975
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1976
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1977
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1978
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1979
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  1980
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1981
    ].
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1982
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1983
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  1984
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  1985
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1986
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1987
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1988
showAtPointer
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  1989
    "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
  1990
     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
  1991
     (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
  1992
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1993
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1994
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1995
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1996
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1997
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1998
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1999
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2000
    "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
  2001
     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
  2002
     (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
  2003
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2004
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2005
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2006
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2007
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2008
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2009
    ^ 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
  2010
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2011
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2012
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2013
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2014
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2015
    "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
  2016
     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
  2017
     (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
  2018
      to some performer)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2019
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2020
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2021
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2022
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2023
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2024
    "realize the menu at aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2025
     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
  2026
     (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
  2027
      to some performer)
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2028
    "
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2029
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2030
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2031
    "Created: / 21.5.1998 / 14:15:57 / cg"
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2032
!
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2033
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2034
startUpOrNil
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2035
    "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
  2036
     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
  2037
     (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
  2038
      to some performer)
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2039
    "
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2040
    ^ self showAtPointer
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2041
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2042
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2043
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2044
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2045
createAtIndex:anIndexOrNil
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2046
    "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
  2047
     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
  2048
     otherwise the new created item is returned.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2049
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2050
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2051
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2052
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2053
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2054
    anIndexOrNil notNil ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2055
        (anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2056
            ^ nil
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2057
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2058
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2059
    items isNil ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2060
        items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  2061
    ] ifFalse:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2062
        items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2063
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2064
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2065
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2066
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2067
        items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2068
    ] ifFalse:[
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2069
        items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2070
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2071
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2072
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2073
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2074
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2075
    "remove the first item which is assigned to stringOrNumber;
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2076
     if found, remove and return it
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2077
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2078
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2079
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2080
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2081
	items remove:item.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2082
	item  destroy.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2083
	items isEmpty ifTrue:[items := nil].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2084
	self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2085
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2086
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2087
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2088
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2089
removeAll
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2090
    "remove all items and submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2091
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2092
    self disabledRedrawDo:[
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2093
        self selection:nil.
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2094
        groupSizes := nil.
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2095
        items notNil ifTrue:[
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2096
            items copy do:[:el| el destroy ].
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2097
        ].
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2098
        items := nil
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2099
    ].
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2100
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2101
    "Modified: / 15.11.2001 / 17:02:51 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2102
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2103
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2104
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2105
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2106
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2107
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2108
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2109
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2110
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2111
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2112
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2113
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2116
asMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2117
    "convert contents to menu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2118
    "
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2119
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2120
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2121
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2122
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2123
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  2124
    ^ menu
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2125
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2126
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2127
fromSpec:aMenuSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2128
    "build from spec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2129
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2130
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2131
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2132
    menu := Menu new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2133
    menu fromLiteralArrayEncoding:aMenuSpec.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2134
    self menu:menu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2135
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2136
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2137
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2138
menu:aMenu
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2139
    "convert to Menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2140
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2141
    self disabledRedrawDo:[
1666
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2142
        |menu newItems|
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
        self removeAll.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2145
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2146
        (menu := aMenu) notNil ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2147
            (aMenu isCollection) ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2148
                menu := Menu new.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2149
                menu fromLiteralArrayEncoding:aMenu.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2150
            ] ifFalse:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2151
                menu receiver notNil ifTrue:[receiver := menu receiver]
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2152
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2153
            (newItems := menu menuItems) size > 0 ifTrue:[
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2154
                items := newItems collect:[:ni | 
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2155
                                |i|
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2156
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2157
                                i:= Item in:self.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2158
                                i menuItem:ni.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2159
                                i.
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2160
                            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2161
            ].
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2162
            self groupSizes:(menu groupSizes).
cbeea1429021 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1660
diff changeset
  2163
        ]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2164
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2165
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2166
    "Modified: / 8.8.1998 / 02:05:04 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2167
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2168
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2169
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2170
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2171
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2172
    "evaluate a block without redrawing within the block; after processing
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2173
     of the block a redraw might be performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2174
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2175
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2176
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2177
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2178
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2179
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2180
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2181
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2182
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2183
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2184
drawButtonEdgesFor:anItem level:aLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2185
    |layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2186
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2187
    aLevel ~~ 0 ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2188
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2189
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2190
        styleSheet is3D ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2191
            self displayRectangle:layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2192
        ] ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2193
            self drawEdgesForX:(layout left)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2194
                             y:(layout top)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2195
                         width:(layout width)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2196
                        height:(layout height)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2197
                         level:aLevel 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2198
                        shadow:buttonShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2199
                         light:buttonLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2200
                    halfShadow:buttonHalfShadowColor 
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2201
                     halfLight:buttonHalfLightColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2202
                         style:ButtonEdgeStyle
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2203
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2204
    ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2205
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2206
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2207
drawItemsX:x y:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2208
    "redraw items and groups in a damage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2209
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2210
    |isVertical item layout prevClip
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2211
     x1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2212
     x2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2213
     y1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2214
     y2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2215
     start          "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2216
     stop           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2217
     size           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2218
     groupDivInset  "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2219
    |
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2220
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2221
    size := items size.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2222
    isVertical := self verticalLayout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2223
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2224
    isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2225
        start := items findFirst:[:el| el layout bottom > y ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2226
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2227
        y1 := y + h.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2228
        stop := items findFirst:[:el| el layout top > y1 ] startingAt:(start + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2229
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2230
        start := items findFirst:[:el| el layout right > x ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2231
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2232
        x1  := x + w.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2233
        stop := items findFirst:[:el| el layout left > x1] startingAt:(start + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2234
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2235
    stop  == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2236
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2237
    (groupSizes size ~~ 0 and:[self showGroupDivider]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2238
        groupDivInset := groupDividerSize // 2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2239
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2240
        groupDivInset ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2241
            (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2242
                start := start - 1
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2243
            ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2244
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2245
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2246
        groupDivInset := 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2247
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2248
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2249
    prevClip := clipRect.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2250
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2251
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2252
    start to:stop do:[:i|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2253
        item := items at:i.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2254
        item redraw.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2255
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2256
        (groupDivInset ~~ 0 and:[i ~~ size and:[self hasGroupDividerAt:i]]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2257
            layout := item layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2258
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2259
            isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2260
                x1 := layout left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2261
                x2 := layout right.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2262
                y1 := layout bottom + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2263
                y2 := y1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2264
            ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2265
                y1 := layout top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2266
                y2 := layout bottom.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2267
                x1 := layout right + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2268
                x2 := x1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2269
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2270
            self paint:shadowColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2271
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2272
            self paint:lightColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2273
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2274
            isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2275
                      ifFalse:[x1 := x1 + 1. x2 := x1 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2276
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2277
            self displayLineFromX:x1 y:y1 toX:x2 y:y2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2278
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2279
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2280
    self clippingRectangle:prevClip.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2281
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2282
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2283
drawLabelEdgeFor:anItem selected:isSelected
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2284
    |level layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2285
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2286
    isSelected ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2287
        level := onLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2288
    ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2289
        anItem == enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2290
            level := DefaultEnteredLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2291
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2292
            level := offLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2293
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2294
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2295
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2296
    level ~~ 0 ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2297
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2298
1691
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2299
        self drawEdgesForX:(layout left)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2300
                         y:(layout top)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2301
                     width:(layout width)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2302
                    height:(layout height)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2303
                     level:level
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2304
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2305
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2306
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2307
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2308
drawScrollerAt:aDirection bounds:bounds
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2309
    "draw a scroller
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2310
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2311
    |scrolling icon level x y w h|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2312
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2313
    x := bounds left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2314
    y := bounds top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2315
    w := bounds width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2316
    h := bounds height.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2317
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2318
    scrolling := self scrolling.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2319
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2320
    (scrolling activeMenu == self and:[scrolling direction == aDirection]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2321
        level := -2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2322
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2323
        level := 1
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2324
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2325
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2326
    level ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2327
        self drawEdgesForX:x y:y width:w height:h level:level.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2328
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2329
    icon := scrolling iconAt:aDirection on:self.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2330
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2331
    icon displayOn:self x:(x + (w - icon width  // 2))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2332
                        y:(y + (h - icon height // 2)).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2333
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2334
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2335
invalidateItem:anItem repairNow:aBool
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2336
    "an item changed; invalidate the items layout
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2337
    "
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2338
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2339
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2340
    (mustRearrange not and:[shown]) ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2341
        layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2342
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2343
        (layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2344
            self invalidate:(layout copy insetBy:-1) repairNow:aBool
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2345
        ]
1728
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2346
    ].
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2347
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2348
    "Modified: / 29.2.2000 / 11:28:59 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2349
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2350
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2351
invalidateX:x y:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2352
    "add a damage to redraw part of the view
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2353
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2354
    shown ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2355
        self invalidate:(Rectangle left:x top:y width:w height:h) 
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2356
              repairNow:false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2357
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2358
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2359
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2360
mustRearrange
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  2361
    "force rearrange (i.e. set the rearrange flag)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2362
    "
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  2363
    mustRearrange == true ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2364
	mustRearrange := true.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2365
	shown ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2366
	    self invalidate "/ RepairNow:true
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  2367
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2368
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  2369
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2370
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2371
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2372
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2373
rearrangeGroups
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2374
    "implements the groupIdentifier #right in a horizontal menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2375
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2376
    |layout point
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2377
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2378
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2379
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2380
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2381
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2382
        ^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2383
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2384
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2385
    layout := items last layout.
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2386
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2387
    (dltX := width - margin - layout right) <= 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2388
        ^ self  "/ no free space
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2389
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2390
    start := items findFirst:[:anItem| anItem startGroup == #right ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2391
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2392
    start == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2393
        ^ self  "/ no item detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2394
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2395
    point := dltX @ 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2396
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2397
    "/ move items layout to right
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2398
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2399
    items from:start do:[:anItem|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2400
        anItem isVisible ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2401
            anItem layout moveBy:point.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2402
        ]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2403
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2404
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2405
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2406
rearrangeItems
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2407
    "recompute the layout of each item
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2408
        !!!!!! changes have influence on method #preferredExtentOfItems !!!!!!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2409
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2410
    |isVertical extent isPopUpMenu
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2411
     x           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2412
     y           "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2413
     x0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2414
     y0          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2415
     x1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2416
     y1          "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2417
     size        "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2418
     inset       "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2419
     labelInset  "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2420
     buttonInset "{ Class:SmallInteger }"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2421
    |
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2422
    (mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2423
        mustRearrange := false.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2424
      ^ self
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2425
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2426
    mustRearrange := false.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2427
    isVertical  := self verticalLayout.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2428
    buttonInset := DefaultButtonItemSpace abs.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2429
    isPopUpMenu := self isPopUpView.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2430
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2431
    isPopUpMenu ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2432
        labelInset := DefaultEnteredLevel abs.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2433
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2434
        labelInset := 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2435
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2436
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2437
    (isPopUpMenu or:[explicitExtent ~~ true]) ifTrue:[ |savExt maxExt|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2438
        savExt := extent := self preferredExtent copy.
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2439
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2440
        isPopUpMenu ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2441
            isVertical ifTrue:[extent y:1.0] ifFalse:[extent x:1.0]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2442
        ] ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2443
            savExt := extent copy.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2444
            maxExt := self maxExtent.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2445
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2446
            isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2447
                extent y:(extent y min:(maxExt y))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2448
            ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2449
                extent x:(extent x min:(maxExt x))
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2450
            ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2451
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2452
        self extent:extent.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2453
        extent := savExt.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2454
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2455
        extent := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2456
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2457
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2458
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2459
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2460
    isVertical ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2461
        y0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2462
        y1 := extent y - margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2463
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2464
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2465
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2466
                el layout:(Rectangle left:x top:y0 right:x bottom:y1)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2467
            ] ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2468
                el isButton ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2469
                    inset := DefaultButtonItemSpace
2062
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  2470
                ] ifFalse:[            
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2471
                    inset := labelInset
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2472
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2473
                x0 := x  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2474
                x1 := x0 + el preferredExtent x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2475
                el layout:(Rectangle left:x0 top:(y0 + inset) right:x1 bottom:(y1 - inset)).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2476
                x := x1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2477
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2478
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2479
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2480
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2481
                    ] ifFalse:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2482
                        el isLabeledItem ifTrue:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2483
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2484
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2485
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2486
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2487
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2488
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2489
    ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2490
        x0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2491
        x1 := extent x - margin.  "/ -1
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2492
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2493
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2494
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2495
                el layout:(Rectangle left:x0 top:y right:x1 bottom:y)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2496
            ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2497
                el isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2498
                    inset := DefaultButtonItemSpace
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2499
                ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2500
                    inset := labelInset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2501
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2502
                y0 := y  + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2503
                y1 := y0 + el preferredExtent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2504
                el layout:(Rectangle left:(x0 + inset) top:y0 right:(x1 - inset) bottom:y1).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2505
                y := y1 + inset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2506
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2507
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2508
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2509
                        y := y + groupDividerSize
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2510
"/                    ] ifFalse:[
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2511
"/                        y := y + itemSpace
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2512
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2513
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2514
            ]
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2515
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2516
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2517
    self rearrangeGroups.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2518
    selection notNil ifTrue:[self makeItemVisible:selection].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2519
    mustRearrange := false.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2520
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2521
    "Modified: / 13.11.2001 / 20:17:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2522
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2523
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2524
rearrangeItemsIfItemVisibilityChanged
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2525
    "check for items which can change its visibility;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2526
     if at least one item exists, rearrange all items
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2527
    "
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2528
    items isNil ifTrue:[^ self].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2529
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2530
    items do:[:item |
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2531
        item canChangeVisibility ifTrue:[
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2532
            mustRearrange := true.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2533
            self rearrangeItems.
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2534
            ^ self
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2535
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2536
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2537
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2538
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2539
redrawX:x y:y width:w height:h
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2540
    "redraw a damage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2541
    "
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2542
    |y0 y1 x0 x1 bounds mustDrawPrevScroller mustDrawNextScroller|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2543
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2544
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2545
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2546
    mustRearrange ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2547
        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
  2548
        self rearrangeItems.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2549
      ^ self invalidate
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2550
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2551
    self paint:(self backgroundColor).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2552
    self clearRectangleX:x y:y width:w height:h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2553
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2554
    items size == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2555
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2556
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2557
    y0 := y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2558
    y1 := y + h.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2559
    x0 := x.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2560
    x1 := x + w.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2561
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2562
    self hasScrollers ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2563
        (self hasScrollerAt:#PREV) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2564
            bounds := self scrollerBoundsAt:#PREV.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2565
            mustDrawPrevScroller := false.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2566
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2567
            self verticalLayout ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2568
                bounds bottom > y ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2569
                    y0 := bounds bottom.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2570
                    mustDrawPrevScroller := true.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2571
                ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2572
            ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2573
                bounds right > x ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2574
                    x0 := bounds right.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2575
                    mustDrawPrevScroller := true.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2576
                ].
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2577
            ].
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2578
            mustDrawPrevScroller ifTrue:[
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2579
                self drawScrollerAt:#PREV bounds:bounds.
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2580
            ].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2581
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2582
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2583
        (self hasScrollerAt:#NEXT) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2584
            bounds := self scrollerBoundsAt:#NEXT.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2585
            mustDrawNextScroller := false.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2586
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2587
            self verticalLayout ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2588
                bounds top < y1 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2589
                    y1 := bounds top.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2590
                    mustDrawNextScroller := true.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2591
                ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2592
            ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2593
                bounds left < x1 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2594
                    x1 := bounds left.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2595
                    mustDrawNextScroller := true.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2596
                ]
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2597
            ].
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2598
            mustDrawNextScroller ifTrue:[
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2599
                self drawScrollerAt:#NEXT bounds:bounds.
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2600
            ].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2601
        ]
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2602
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2603
    (y1 > y0 and:[x1 > x0]) ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2604
        self drawItemsX:x0 y:y0 width:(x1 - x0) height:(y1 - y0)
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2605
    ].
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2606
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2607
    "Modified: / 15.11.2001 / 20:57:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2608
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2609
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2610
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2611
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2612
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2613
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2614
     and return a collection of the results
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2615
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2616
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  2617
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2618
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2619
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2620
do:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2621
    "evaluate the argument, aOneArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2622
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2623
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2624
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2625
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2626
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2627
findFirst:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2628
    "find the first item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2629
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2630
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2631
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2632
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2633
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2634
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2635
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2636
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2637
    "find the last item, for which evaluation of the argument, aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2638
     returns true; return its index or 0 if none detected.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2639
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2640
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2641
  ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2642
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2643
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2644
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2645
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2646
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2647
     If no item match 0 is returned. No range checks are performed on a number argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2648
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2649
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2650
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2651
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2652
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2653
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2654
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2655
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2656
    i ~~ 0 ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2657
	^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2658
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2659
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2660
    something isSymbol ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2661
	i := self findFirst:[:el|
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2662
				v := el value.
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2663
				v isSymbol and:[v == something]
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2664
			    ].
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2665
	i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2666
	    ^ i
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2667
	]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2668
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2669
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2670
    (something respondsTo:#string) ifTrue:[
1368
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  2671
	v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2672
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2673
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2674
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2675
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2676
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2677
indexOfItem:anItem
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2678
    "returns the index of the item or 0
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2679
    "
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2680
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2681
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2682
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2683
keysAndValuesDo:aTwoArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2684
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2685
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2686
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2687
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2688
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2689
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2690
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2691
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2692
buttonMotion:state x:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2693
    "open or close the corresponding submenus
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2694
    "
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2695
    |menue motionPoint translatedPoint sensor|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2696
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2697
    self scrolling isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2698
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2699
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2700
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2701
    sensor := self sensor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2702
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2703
    (sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2704
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2705
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2706
    menue := self detectGrabMenu.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  2707
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2708
    motionPoint := x@y.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2709
    translatedPoint := menue translateGrabPoint:motionPoint.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2710
    menue handleButtonMotion:state atPoint:translatedPoint.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2711
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2712
    (self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2713
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2714
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2715
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2716
    (selection notNil and:[selection visibleSubmenu isNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2717
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2718
        (self containsPoint:motionPoint) ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2719
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2720
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2721
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2722
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2723
    "Modified: / 13.11.2001 / 20:21:49 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2724
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2725
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2726
buttonPress:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2727
    "any button pressed; open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2728
    "
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2729
    |menu point|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2730
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2731
    self scrolling stop.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2732
"/    self scrolling inspect.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2733
    point := x@y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2734
    menu  := self detectMenuAtGrabPoint:point.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2735
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2736
    menu isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2737
        self accept:nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2738
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2739
        point := menu translateGrabPoint:point.
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2740
        menu handleButtonPressAtPoint:point.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2741
    ]
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2742
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2743
    "Modified: / 13.11.2001 / 14:12:32 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2744
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2745
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2746
buttonRelease:button x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2747
    "button release action; accept selection and close all views
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2748
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2749
    |topMenu dstMenu item srcPoint dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2750
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2751
    self scrolling stop ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2752
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2753
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2754
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2755
    topMenu := self topMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2756
    dstMenu := topMenu activeMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2757
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2758
    (    dstMenu selection notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2759
     or:[dstMenu isPopUpView not
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2760
     or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2761
         and:(dstMenu mapTime)) > 400]]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2762
    ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2763
        srcPoint := x@y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2764
        
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2765
        (     (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2766
         and:[(item    := dstMenu selection) notNil]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2767
        ) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2768
            item visibleSubmenu notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2769
                dstMenu selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2770
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2771
                (selection isNil and:[self isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2772
                    self accept:nil
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2773
                ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2774
            ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2775
                item currentSubmenu isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2776
                    dstPoint := dstMenu translateGrabPoint:srcPoint.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2777
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2778
                    (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
  2779
                        item := nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2780
                    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2781
                    topMenu acceptItem:item inMenu:dstMenu.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2782
                ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2783
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2784
            ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2785
        ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2786
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2787
        (selection notNil and:[dstMenu == self]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2788
            selection visibleSubmenu notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2789
                ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2790
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2791
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2792
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2793
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2794
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2795
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2796
keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2797
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2798
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2799
    |menu rawKey|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2800
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2801
    self scrolling isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2802
        key ~~ #Escape ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2803
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2804
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2805
        self scrolling stop
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2806
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2807
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2808
       (key == #Tab 
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2809
    or:[key == #FocusNext
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2810
    or:[key == #FocusPrevious]]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2811
        self accept:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2812
      ^ super keyPress:key x:x y:y
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2813
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2814
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2815
    menu := self detectGrabMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2816
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2817
    key == #Escape ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2818
        "/ must hide the active menu
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2819
        ((menu := menu superMenu) notNil and:[menu ~~ self]) ifTrue:[
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2820
            "/ hide active menu but keep the grab
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2821
            menu selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2822
        ] ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  2823
            "/ hide active menu and ungrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2824
            self accept:nil
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2825
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2826
    ] ifFalse:[
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2827
        menu isViewWrapper ifFalse:[
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2828
            self sensor compressKeyPressEventsWithKey:key.
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2829
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2830
            menu handleKeyPress:key.
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  2831
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2832
"/            selection isNil ifTrue:[
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2833
"/                self accept:nil keepValue:true
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2834
"/            ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2835
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2836
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2837
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2838
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2839
pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2840
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2841
    self scrolling isActive ifTrue:[^ self].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2842
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2843
    self detectGrabMenu handlePointerLeave:state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2844
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2845
    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2846
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2847
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2848
    (selection notNil and:[selection hasSubmenu not]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2849
        "/ selection on grabView withou a submenu (Button ...); check whether moving out
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2850
        self sensor anyButtonPressed ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2851
            ^ self accept:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2852
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2853
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2854
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2855
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2856
sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2857
    "redraw #right groups
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2858
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2859
    self isPopUpView ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2860
        mustRearrange := true.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2861
        shown ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2862
            self invalidate
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2863
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2864
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2865
    super sizeChanged:how
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2866
! !
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2867
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2868
!MenuPanel methodsFor:'event handling processing'!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2869
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2870
clearImplicitGrab
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2871
    self menuAdornmentAt:#implicitGrabView put:nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2872
    self menuAdornmentAt:#lastPointerView  put:nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2873
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2874
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2875
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2876
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2877
dispatchEvent:ev withFocusOn:focusView delegate:doDelegate
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2878
    "dispatch and handle an event
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2879
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2880
    |view x y p syntheticEvent implicitGrabView lastPointerView menu|
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2881
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2882
    implicitGrabView := self menuAdornmentAt:#implicitGrabView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2883
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2884
    "/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2885
    "/ but never get the buttonRelease, since someone else (a popUp) grabbed the
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2886
    "/ pointer in the meantime, and has eaten the release event ... (double-sigh)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2887
    implicitGrabView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2888
        self sensor leftButtonPressed ifFalse:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2889
            self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2890
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2891
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2892
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2893
    ((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2894
        ^ super dispatchEvent:ev withFocusOn:focusView delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2895
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2896
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2897
    implicitGrabView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2898
        ev isButtonEvent ifTrue:[
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2899
            p := device translatePoint:(x@y) fromView:self toView:implicitGrabView.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2900
            ev view:implicitGrabView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2901
            ev arguments at:2 put:p x.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2902
            ev arguments at:3 put:p y.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2903
            implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2904
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2905
            ev isButtonReleaseEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2906
                self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2907
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2908
            ^ self
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2909
        ]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2910
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2911
    menu := self detectMenuAtGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2912
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2913
    (menu isNil or:[menu isViewWrapper not]) ifTrue:[
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2914
        self clearImplicitGrab.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2915
      ^ super dispatchEvent:ev withFocusOn:focusView delegate:false
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2916
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2917
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2918
    p    := menu translateGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2919
    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
  2920
    p    := device translatePoint:(x@y) fromView:self toView:view.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2921
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2922
    ev isButtonPressEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2923
        (view wantsFocusWithButtonPress) ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2924
            view requestFocus.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2925
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2926
        view ~~ self ifTrue:[ "/ can this ever be self ?
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2927
            self menuAdornmentAt:#implicitGrabView put:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2928
        ]
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2929
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2930
    lastPointerView := self menuAdornmentAt:#lastPointerView.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2931
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2932
    ev isButtonMotionEvent ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2933
        lastPointerView ~~ view ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2934
            "/ must generate enter/leave ... (sigh)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2935
            lastPointerView notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2936
                syntheticEvent := WindowEvent inputEvent
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2937
                                     for:lastPointerView
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2938
                                     type:#pointerLeave:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2939
                                     arguments:(Array with:0).   "/ XXX: should be fixed
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2940
                lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2941
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2942
            view notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2943
                syntheticEvent := WindowEvent inputEvent
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2944
                                     for:view
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2945
                                     type:#pointerEnter:x:y:
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2946
                                     arguments:(Array with:0 with:x with:y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2947
                view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2948
            ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2949
            self menuAdornmentAt:#lastPointerView put:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2950
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2951
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2952
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2953
    ev view:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2954
    ev x:p x.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2955
    ev y:p y.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2956
    view dispatchEvent:ev withFocusOn:focusView delegate:false.
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2957
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  2958
    "Modified: / 10.10.2001 / 13:54:47 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2959
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  2960
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2961
handleButtonMotion:state atPoint:motionPoint
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2962
    "open or close the corresponding submenus
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2963
    "
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2964
    |menu translatedPoint sel|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2965
1910
119f91172b70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  2966
    (state == 0 or:[self sensor anyButtonPressed not]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2967
        "/ highlight enterItem if no selection exists
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2968
        selection isNil ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2969
            (self containsPoint:motionPoint) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2970
                ((sel := self itemAtPoint:motionPoint) isNil or:[sel canSelect not]) ifTrue:[
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
                (DefaultSelectionFollowsMouse and:[superMenu notNil]) ifTrue:[
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2974
                    self select:sel openMenu:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2975
"/                    self openMenuOnSelect:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2976
"/                    self selection:sel.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2977
"/                    self openMenuOnSelect:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2978
                ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2979
                    self pointerEntersItem:sel
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2980
                ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2981
                ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2982
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2983
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2984
        self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2985
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2986
        (DefaultSelectionFollowsMouse and:[(menu := self superMenuAtPoint:motionPoint) notNil]) ifTrue:[
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.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2989
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2990
            (sel notNil and:[sel canSelect]) ifTrue:[
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2991
                self select:sel openMenu:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2992
"/                self openMenuOnSelect:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2993
"/                self selection:sel.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  2994
"/                self openMenuOnSelect:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2995
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2996
        ].
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2997
        ^ self
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2998
    ].
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2999
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3000
    self pointerEntersItem:nil.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3001
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3002
    (menu := self superMenuAtPoint:motionPoint) isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3003
        self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3004
            self selection:nil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3005
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3006
        ^ self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3007
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3008
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3009
    menu == self ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3010
        (sel := self itemAtPoint:motionPoint) notNil ifTrue:[
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3011
            self select:sel openMenu:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3012
"/            self openMenuOnSelect:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3013
"/            self selection:sel.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3014
"/            self openMenuOnSelect:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3015
        ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3016
    ] ifFalse:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3017
        translatedPoint := self translateMenuPoint:motionPoint toMenu:menu.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3018
        sel   := menu itemAtPoint:translatedPoint.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3019
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3020
        (sel isNil and:[menu isPopUpView not]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3021
            sel := menu selection.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3022
        ].
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3023
        menu select:sel openMenu:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3024
"/        menu openMenuOnSelect:true.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3025
"/        menu selection:sel.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  3026
"/        menu openMenuOnSelect:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3027
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3028
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3029
    "Created: / 13.11.2001 / 20:21:24 / cg"
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3030
    "Modified: / 13.11.2001 / 20:26:32 / cg"
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3031
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3032
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3033
handleButtonPressAtPoint:aPoint
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3034
    "a button pressed; open or close the corresponding submenus
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3035
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3036
    |item sensor yS direction|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3037
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3038
    item := self itemAtPoint:aPoint.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3039
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3040
    item notNil ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3041
        direction := self scrollerDirectionAtPoint:aPoint.
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3042
        direction notNil ifTrue:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3043
            (self scrolling startIfRequiredAt:direction on:self) ifTrue:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3044
                self pointerEntersItem:nil.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3045
                ^ self
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3046
            ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3047
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3048
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3049
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3050
    self openMenuOnSelect:true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3051
    self selection:item.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3052
    self openMenuOnSelect:nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3053
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3054
    (     item notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3055
     and:[item triggerOnDown
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3056
     and:[item canAccept
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3057
     and:[item == self selection]]]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3058
    ) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3059
        self invalidateItem:item repairNow:true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3060
        self acceptItem:item inMenu:self.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3061
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3062
        self selection == item ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3063
            (sensor := self sensor) notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3064
                [sensor anyButtonPressed] whileTrue:[ Delay waitForSeconds:0.1 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3065
                sensor flushUserEvents.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3066
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3067
            self selection:nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3068
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3069
    ].
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3070
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3071
    "Created: / 13.11.2001 / 14:12:04 / cg"
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3072
    "Modified: / 13.11.2001 / 19:50:52 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3073
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3074
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3075
handleCursorKey:aKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3076
    "handle a cursor key
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3077
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3078
    |next menu item isVrt backKey p1 p2
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3079
     idx   "{ Class:SmallInteger }"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3080
     size  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3081
    |
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3082
    (size  := items size) == 0 ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3083
        superMenu notNil ifTrue:[superMenu handleCursorKey:aKey].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3084
      ^ self
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3085
    ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3086
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3087
    isVrt := self verticalLayout.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3088
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3089
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3090
    (    (isVrt     and:[aKey == #CursorUp    or:[aKey == #CursorDown]])
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3091
     or:[(isVrt not and:[aKey == #CursorRight or:[aKey == #CursorLeft]])]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3092
    ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3093
        selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3094
            (superMenu notNil and:[superMenu verticalLayout == isVrt]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3095
                ^ superMenu handleCursorKey:aKey
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3096
            ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3097
            idx := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3098
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3099
            isVrt ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3100
                "/ used because of vertical scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3101
                idx := items findFirst:[:el| el layout top > 0 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3102
                idx ~~ 0 ifTrue:[idx := idx := idx - 1 ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3103
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3104
        ] ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3105
            idx := self indexOf:selection.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3106
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3107
        next := aKey == #CursorRight or:[aKey == #CursorDown].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3108
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3109
        size timesRepeat:[|el|
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3110
            next ifTrue:[(idx := idx + 1) > size ifTrue:[idx := 1]]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3111
                ifFalse:[(idx := idx - 1) < 1    ifTrue:[idx := size]].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3112
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3113
            (el := items at:idx ifAbsent:nil) notNil ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3114
                el canSelect ifTrue:[^ self selection:el].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3115
            ]
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
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3118
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3119
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3120
    superMenu notNil ifTrue:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3121
        p1 := self translateGrabPoint:0.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3122
        p2 := superMenu translateGrabPoint:0.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3123
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3124
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3125
    isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3126
        (superMenu notNil and:[p1 x > p2 x]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3127
            backKey := #CursorRight
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3128
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3129
            backKey := #CursorLeft.
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
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3132
        (superMenu notNil and:[p1 y > p2 y]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3133
            backKey := #CursorDown
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
            backKey := #CursorUp.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3136
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3137
    ].    
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3138
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3139
    aKey == backKey ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3140
        superMenu isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3141
            self accept:nil
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
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3144
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3145
            ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3146
                superMenu selection hideSubmenu
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
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3149
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3150
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3151
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3152
    selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3153
        superMenu isNil ifTrue:[^ self accept:nil].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3154
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3155
        superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3156
            superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3157
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3158
            (item := items findFirst:[:el| el canSelect]) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3159
                self selection:item
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3160
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3161
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3162
        ^ self
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
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3165
    selection hasSubmenu ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3166
        (menu := selection visibleSubmenu) isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3167
            selection toggleSubmenuVisibility
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3168
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3169
            menu selectionIndex:1
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3170
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3171
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3172
        superMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3173
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3174
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3175
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3176
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3177
            self accept:nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3178
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3179
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3180
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3181
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3182
handleKeyPress:key
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3183
    "any key is pressed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3184
    "
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3185
    |item inMenu rawKey|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3186
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3187
    (key == #Return or:[key == Character space]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3188
        self handleReturnPressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3189
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3190
        key isCharacter ifTrue:[
1862
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3191
"/            selection notNil ifTrue:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3192
"/                inMenu := self
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3193
"/            ] ifFalse:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3194
"/                (inMenu := superMenu) isNil ifTrue:[^ self].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3195
"/            ].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3196
            inMenu := self.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3197
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3198
            (item := inMenu detectItemForKey:key) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3199
                inMenu selection:item
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3200
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3201
        ] ifFalse:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3202
            (     key == #CursorDown or:[key == #CursorUp
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3203
              or:[key == #CursorLeft or:[key == #CursorRight]]]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3204
            ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3205
                self handleCursorKey:key
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3206
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3207
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3208
    ]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3209
!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3210
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3211
handlePointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3212
    self  pointerEntersItem:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3213
    super pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3214
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3215
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3216
handleReturnPressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3217
    "any key is pressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3218
    "
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3219
    |sensor|
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3220
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3221
    selection isNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3222
        superMenu notNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3223
            superMenu selection toggleSubmenuVisibility
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3224
        ] ifFalse:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3225
            self accept
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3226
        ].
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3227
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3228
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3229
    selection hasSubmenu ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3230
        ^ selection toggleSubmenuVisibility
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3231
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3232
    self accept.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3233
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3234
    (selection notNil and:[selection triggerOnDown]) ifFalse:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3235
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3236
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3237
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3238
    (sensor := self sensor) isNil ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3239
        ^ self
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3240
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3241
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3242
    [   sensor flushKeyboardFor:nil.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3243
        Delay waitForSeconds:0.1.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3244
        sensor hasKeyPressEventFor:nil.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3245
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3246
    ] whileTrue.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3247
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3248
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3249
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3250
pointerEntersItem:anItemOrNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3251
    "the pointer moves over an item or nil; restore the old item and
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3252
     redraw the new item highlighted.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3253
    "
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3254
    |oldItem newItem|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3255
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3256
    (     anItemOrNil notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3257
     and:[anItemOrNil canSelect
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3258
     and:[selection isNil
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3259
     and:[self isPopUpView not]]]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3260
        anItemOrNil isButton ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3261
            (    buttonEnteredBgColor ~= ButtonPassiveBackgroundColor
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3262
             or:[ButtonEnteredLevel   ~~ ButtonPassiveLevel]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3263
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3264
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3265
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3266
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3267
            DefaultEnteredLevel ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3268
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3269
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3270
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3271
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3272
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3273
    newItem ~~ enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3274
        oldItem     := enteredItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3275
        enteredItem := newItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3276
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3277
        oldItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3278
            self invalidateItem:oldItem repairNow:(enteredItem isNil).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3279
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3280
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3281
        enteredItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3282
            self invalidateItem:enteredItem repairNow:true.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3283
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3284
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3285
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3286
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3287
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3288
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3289
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3290
doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3291
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3292
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3293
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3294
        superMenu doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3295
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3296
        hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3297
            self grabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3298
            hasImplicitGrap := true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3299
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3300
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3301
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3302
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3303
doUngrab:forceDo
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3304
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3305
    relativeGrabOrigin := nil.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3306
    self clearImplicitGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3307
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3308
    superMenu notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3309
        forceDo ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3310
            superMenu doUngrab:true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3311
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3312
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3313
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3314
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3315
    hasImplicitGrap ~~ true ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3316
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3317
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3318
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3319
    forceDo ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3320
        (selection notNil or:[prevFocusView == self]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3321
            ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3322
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3323
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3324
    self ungrabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3325
    self selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3326
    hasImplicitGrap := nil.
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3327
    prevFocusView   := nil.
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3328
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3329
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3330
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3331
grabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3332
    "grap the keyboard; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3333
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3334
    previousKeyboardGrab := device activeKeyboardGrab.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3335
  ^ super grabKeyboard
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3336
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3337
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3338
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3339
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3340
grabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3341
    "get exclusive access to pointer and keyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3342
    "
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3343
    |sensor|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3344
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3345
    realized ifTrue:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3346
        prevFocusView := self windowGroup focusView.
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  3347
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3348
        sensor := self sensor.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3349
        device activePointerGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3350
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3351
                sensor flushMotionEventsFor:nil.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3352
            ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3353
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3354
            (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3355
                Delay waitForSeconds:0.1.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3356
                (self grabPointer) ifFalse:[
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3357
                    "give up"
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3358
                    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3359
                    self unmap
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3360
                ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3361
            ]
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3362
        ].
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3363
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3364
        device activeKeyboardGrab ~~ self ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3365
            sensor notNil ifTrue:[
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3366
                device sync.
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3367
                sensor flushKeyboardFor:nil
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3368
            ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3369
            self grabKeyboard.
1575
c56d76e45113 force set focus
ca
parents: 1574
diff changeset
  3370
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3371
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3372
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3373
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  3374
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3375
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3376
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3377
grabPointerWithCursor:aCursorOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3378
    "grap the pointer; keep previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3379
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3380
    previousPointerGrab := device activePointerGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3381
    hasImplicitGrap := true.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3382
  ^ super grabPointerWithCursor:aCursorOrNil
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3383
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3384
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3385
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3386
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3387
ungrabKeyboard
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3388
    "ungrap the keyboard; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3389
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3390
    super ungrabKeyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3391
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3392
    previousKeyboardGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3393
        device grabKeyboardInView:previousKeyboardGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3394
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3395
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3396
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3397
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3398
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3399
ungrabMouseAndKeyboard
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3400
    "ungrab resources (mouse and keyboard)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3401
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3402
    self ungrabPointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3403
    self ungrabKeyboard.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3404
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3405
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3406
ungrabPointer
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3407
    "ungrap the pointer; restore previous grab
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3408
    "
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3409
    super ungrabPointer.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3410
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3411
    previousPointerGrab notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3412
        device grabPointerInView:previousPointerGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3413
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3414
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3415
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3416
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3417
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3418
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3419
2058
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3420
flyByHelpTextAt:srcPoint
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3421
    "return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3422
     If there is a selection, that items helpText is used (ignoreing the given point).
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3423
     "
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3424
    |dstMenu dstPoint|
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3425
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3426
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3427
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3428
    dstMenu isNil ifTrue:[
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3429
        ^ ''
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3430
    ].
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3431
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3432
    dstPoint := dstMenu translateGrabPoint:srcPoint.
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3433
  ^ dstMenu flyByHelpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)).
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3434
!
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3435
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3436
flyByHelpTextForItem:anItem
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3437
    "returns the helpText for an item (empty if none)
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3438
    "
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3439
    |key val app|
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3440
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3441
    anItem isNil ifTrue:[^ ''].
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3442
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3443
    (     (key := anItem activeHelpKey) notNil
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3444
     and:[(app := self application) notNil]
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3445
    ) ifTrue:[
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3446
        val := app flyByHelpTextForKey:key.
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3447
    ].
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3448
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3449
    ^ val
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3450
!
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3451
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3452
helpText
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3453
    "return the helpText for the currently selected item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3454
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3455
    ^ self helpTextForItem:selection
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3456
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3457
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3458
helpTextAt:srcPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  3459
    "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
  3460
     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
  3461
     "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3462
    |dstMenu dstPoint|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3463
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3464
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3465
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3466
    dstMenu isNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3467
        ^ ''
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3468
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3469
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3470
    dstPoint := dstMenu translateGrabPoint:srcPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3471
  ^ dstMenu helpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)).
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3472
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3473
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3474
helpTextForItem:anItem
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3475
    "returns the helpText for an item (empty if none)
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3476
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3477
    |key val app|
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3478
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3479
    anItem isNil ifTrue:[^ ''].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3480
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3481
    (val := anItem activeHelpText) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3482
        (     (key := anItem activeHelpKey) notNil
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3483
         and:[(app := self application) notNil]
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3484
        ) ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3485
            val := app helpTextForKey:key.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3486
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3487
        anItem activeHelpText:(val ? '').
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3488
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3489
    ^ val
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3490
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3491
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3492
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3493
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3494
imageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3495
    "returns image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3496
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3497
    ^ self class image:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3498
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3499
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3500
lightenedImageOnDevice:anImage
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3501
    "returns lightened image registered on device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3502
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3503
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3504
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3505
1688
271829d6a2e4 category changes
Claus Gittinger <cg@exept.de>
parents: 1679
diff changeset
  3506
!MenuPanel methodsFor:'initialization & release'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3507
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3508
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3509
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3510
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3511
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3512
create
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3513
    "create the shadow view for a none contained submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3514
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3515
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3516
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3517
    self isPopUpView ifTrue:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3518
        (PopUpView shadowsOnDevice:device) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3519
            shadowView isNil ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3520
                shadowView := (ShadowView onDevice:device) for:self
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3521
            ] ifFalse:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3522
                self saveUnder:true.
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3523
            ].
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3524
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3525
    ] ifFalse:[
1499
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3526
        explicitExtent == true ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3527
            (self width) == (superView width) ifTrue:[
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3528
                self verticalLayout:false
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3529
            ]
07951b17b43e allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  3530
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3531
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3532
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3533
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3534
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3535
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3536
destroy
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3537
    "destroy items and shadowView; remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3538
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3539
    self clearLastActiveMenu.
2051
d958c12cc08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2050
diff changeset
  3540
    items notNil ifTrue:[items copy do:[:el|el destroy]].
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  3541
    items     := nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3542
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3543
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3544
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3545
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3546
    super destroy.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3547
    superMenu := nil.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3548
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3549
2051
d958c12cc08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2050
diff changeset
  3550
    "Modified: / 15.11.2001 / 17:08:45 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3551
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3552
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3553
fetchDeviceResources
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3554
    "fetch device colors, to avoid reallocation at redraw time"
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3555
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3556
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3557
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  3558
    "/ 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
  3559
    "/ (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
  3560
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  3561
    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
  3562
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3563
    superMenu isNil ifTrue:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3564
        fgColor                   := DefaultForegroundColor         onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3565
        activeBgColor             := DefaultHilightBackgroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3566
        activeFgColor             := DefaultHilightForegroundColor  onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3567
        disabledFgColor           := DefaultDisabledForegroundColor onDevice:device.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  3568
        DefaultDisabledEtchedForegroundColor notNil ifTrue: [
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  3569
            disabledEtchedFgColor     := DefaultDisabledEtchedForegroundColor onDevice:device.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  3570
        ].
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3571
        rightArrow                := RightArrowForm                 onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3572
        selectionFrameBrightColor := SelectionFrameBrightColor      onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3573
        selectionFrameDarkColor   := SelectionFrameDarkColor        onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3574
        buttonLightColor          := ButtonLightColor               onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3575
        buttonShadowColor         := ButtonShadowColor              onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3576
        ButtonHalfLightColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3577
            buttonHalfLightColor      := ButtonHalfLightColor           onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3578
        ButtonHalfShadowColor notNil ifTrue: [
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3579
            buttonHalfShadowColor     := ButtonHalfShadowColor          onDevice:device].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3580
        buttonEnteredBgColor      := ButtonEnteredBackgroundColor   onDevice:device.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3581
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3582
        (rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3583
            rightArrowShadow := rightArrowShadow onDevice:device
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3584
        ]
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3585
    ] ifFalse:[
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3586
        fgColor                   := superMenu foregroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3587
        activeBgColor             := superMenu activeBackgroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3588
        activeFgColor             := superMenu activeForegroundColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3589
        disabledFgColor           := superMenu disabledForegroundColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  3590
        disabledEtchedFgColor     := superMenu disabledEtchedForegroundColor.
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3591
        rightArrow                := superMenu rightArrow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3592
        rightArrowShadow          := superMenu rightArrowShadow.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3593
        selectionFrameBrightColor := superMenu selectionFrameBrightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3594
        selectionFrameDarkColor   := superMenu selectionFrameDarkColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3595
        buttonLightColor          := superMenu buttonLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3596
        buttonShadowColor         := superMenu buttonShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3597
        buttonHalfLightColor      := superMenu buttonHalfLightColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3598
        buttonHalfShadowColor     := superMenu buttonHalfShadowColor.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3599
        buttonEnteredBgColor      := superMenu buttonEnteredBackgroundColor.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3600
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3601
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3602
    items notNil ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3603
        items do:[:eachItem |
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3604
            eachItem fetchDeviceResources
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3605
        ]
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3606
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3607
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  3608
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3609
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3610
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3611
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3612
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3613
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3614
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3615
1336
6087005f59a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  3616
    viewBackground := DefaultBackgroundColor.
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3617
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3618
    onLevel          := DefaultHilightLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3619
    offLevel         := 0. "/ DefaultLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3620
    itemSpace        := DefaultItemSpace.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3621
    groupDividerSize := DefaultGroupDividerSize.
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3622
    fitFirstPanel    := false.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  3623
    font             := MenuView defaultFont onDevice:device.
1923
530426a3d692 support #level:
ca
parents: 1922
diff changeset
  3624
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3625
    self updateLevelAndBorder.
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3626
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  3627
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3628
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3629
    "set default configuration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3630
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3631
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3632
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3633
1730
4936edfc2eee must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  3634
    self enableMotionEvents.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  3635
    enabled := true.
1877
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  3636
    self extentChangedFlag:false.
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  3637
    self originChangedFlag:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3638
    explicitExtent := nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3639
    shortKeyInset  := 0.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3640
    mustRearrange  := false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3641
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3642
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3643
map
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3644
    "grab the pointer here, when visible (but not if control has already been lost). 
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3645
     If the grab fails, try again and unmap myself if that fails too.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3646
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3647
    |loIndices loItems|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3648
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3649
    enteredItem := nil.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3650
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3651
    self enableMotionEvents.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3652
    self becomesActiveMenu.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3653
    super map.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3654
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3655
    loIndices := InitialSelectionQuerySignal query.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3656
    loItems   := items ? #[].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3657
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3658
    loItems do:[:anItem| anItem fetchImages ].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3659
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3660
    self isPopUpView ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3661
        self doGrab
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3662
    ] ifFalse:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3663
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3664
    ].
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3665
    loItems do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3666
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3667
    loIndices size > 0 ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  3668
        self redrawX:0 y:0 width:width height:height.
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  3669
        self openMenusFromItemIndices:loIndices.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3670
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3671
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  3672
    "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
  3673
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3674
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3675
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3676
realize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3677
    "realize menu and shadowView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3678
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3679
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3680
    self isPopUpView ifTrue:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3681
        "Because of #saveUnder of ShadowView the order of realize is significant:
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3682
         shadowView must be realized before self"
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3683
        self hiddenOnRealize:true.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3684
        super realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3685
        self resize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3686
        self makeFullyVisible.
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3687
"/        self mustRearrange.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3688
        shadowView notNil ifTrue:[
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3689
            shadowView realize.
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3690
        ].
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3691
        self raise.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  3692
        self map.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3693
    ] ifFalse:[
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  3694
        super realize.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3695
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3696
    self allSubViewsDo:[:aView| aView realize ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3697
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3698
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3699
recreate
1832
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
  3700
    "this is called after a snapin or a migration.
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
  3701
     If the image was saved with an active menu, hide the menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3702
    "
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  3703
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3704
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3705
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3706
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3707
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3708
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3709
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3710
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3711
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3712
    self fetchDeviceResources.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3713
    self mustRearrange.      "/ care for changed font sizes etc.
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3714
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3715
    self do:[:anItem |
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3716
        anItem reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3717
    ].
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3718
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3719
    "Created: / 10.9.1998 / 21:37:05 / cg"
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3720
    "Modified: / 17.8.2000 / 18:01:33 / cg"
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3721
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  3722
1796
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3723
reinitialize
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3724
    "reinit after a snapIn
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3725
    "
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3726
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3727
    super reinitialize.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3728
"/    self reinitStyle.
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3729
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  3730
    "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
  3731
!
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
  3732
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3733
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  3734
    "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
  3735
     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
  3736
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3737
    self clearLastActiveMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3738
    self doUngrab:(superMenu isNil).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3739
"/    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3740
"/         self doUngrab:(superMenu isNil)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3741
"/    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3742
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3743
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3744
    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
  3745
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3746
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3747
updateLevelAndBorder
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3748
    "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
  3749
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3750
    |bw lvl|
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3751
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3752
    self isPopUpView ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3753
        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
  3754
        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
  3755
    ] ifFalse:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3756
        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
  3757
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3758
    self borderWidth:bw.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  3759
    self level:lvl.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3760
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3761
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3762
!MenuPanel methodsFor:'keyboard control'!
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
mnemonicViewNext:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3765
    "a  mnemonicKey event as forwarded from the keyboardProcessor - if there
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3766
     is the mnemonic-key defined for any menuItem, handle the menuItem and
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3767
     return the topMenu otherwise nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3768
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3769
    |menu uKey lKey list|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3770
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3771
    superMenu notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3772
        ^ superMenu mnemonicViewNext:aKeyEvent
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
    shown ifFalse:[^ nil].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3775
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3776
    uKey := aKeyEvent rawKey last asUppercase.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3777
    lKey := uKey asLowercase.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3778
    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
  3779
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3780
    [true] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3781
        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
  3782
                                 maxDepth:10.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3783
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3784
        list size ~~ 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3785
            "/ has item which responds to the mnemonic
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3786
            menu processCollectedIndices:list.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3787
          ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3788
        ].
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
        menu == self ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3791
            "/ must clear existing selection
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3792
            self selection:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3793
          ^ nil
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3794
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3795
        menu := self.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3796
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3797
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3798
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3799
openMenusFromItemIndices:anItemIndiceList
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3800
    "open all menus derived from sequence of item indices
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3801
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3802
    |item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3803
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3804
    anItemIndiceList size == 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3805
        ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3806
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3807
    item := self itemAt:(anItemIndiceList removeFirst).
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
    (item notNil and:[item enabled]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3810
        InitialSelectionQuerySignal answer:anItemIndiceList do:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3811
            self openMenuOnSelect:true.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3812
            self selection:item.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3813
            self openMenuOnSelect:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3814
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3815
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3816
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3817
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3818
processCollectedIndices:indices
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3819
    |menu item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3820
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3821
    indices size == 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3822
        ^ self
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
    menu := self.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3825
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3826
    [menu selectionIndex == indices first] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3827
        (    (item := menu selection) isNil             "/ shouldn't happen
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3828
         or:[(menu := item submenu) isNil]              "/ no more indices; done
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3829
        ) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3830
            ^ true
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
        indices removeFirst.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3833
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3834
        indices isEmpty ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3835
           menu selection:nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3836
         ^ self
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3837
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3838
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3839
    menu openMenusFromItemIndices:indices.
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3840
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3841
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3842
processShortcut:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3843
    "a  shortcutKey event as forwarded from the keyboardProcessor - if there is the
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3844
     shortcut-key defined process the shortcut and return true otherwise false.
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
    |menu rKey lKey list item winGroup|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3847
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3848
    superMenu notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3849
        ^ superMenu processShortcut:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3850
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3851
    shown ifFalse:[^ false].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3852
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3853
    item := nil.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3854
    rKey := aKeyEvent rawKey.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3855
    lKey := aKeyEvent key.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3856
    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
  3857
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3858
    [true] whileTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3859
        list := menu selectItemIndicesFor:[:el||skey|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3860
                                                item := el.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3861
                                                skey := el shortcutKey.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3862
                                                skey == rKey or:[skey == lKey]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3863
                                          ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3864
                                 maxDepth:10.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3865
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3866
        list size ~~ 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3867
            "/ has item which responds to the shortcut
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3868
            item hasSubmenu ifFalse:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3869
                menu accept:item
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3870
            ] ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3871
                menu processCollectedIndices:list.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3872
                self windowGroup focusView:self.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3873
            ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3874
          ^ true
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3875
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3876
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3877
        menu == self ifTrue:[ ^ false ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3878
        menu := self.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3879
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3880
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3881
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3882
selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3883
    "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
  3884
     returns true. The first entry is the topmenu, the last entry the
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3885
     item for which the block returns true.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3886
     If no item is detected, nil is returned
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3887
    "
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3888
    (maxDepth <= 0 or:[items isNil]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3889
        ^ nil
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3890
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3891
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3892
    "/ first search horizontal
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3893
    items keysAndValuesDo:[:anIdx :anItem|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3894
        (aOneArgBlock value:anItem) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3895
            (anItem isEnabled and:[anItem isVisible]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3896
                ^ OrderedCollection with:anIdx.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3897
            ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3898
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3899
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3900
    "/ search in subMenus
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3901
    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
  3902
        (anItem hasSubmenu
26fa92fa9465 only search submenus for shortCuts if the menu is a static one
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
  3903
         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
  3904
         and:[anItem isEnabled]]) ifTrue:[
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3905
            menu := anItem submenu.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3906
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3907
            (menu notNil and:[menu isEnabled]) ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3908
                seq := menu selectItemIndicesFor:aOneArgBlock maxDepth:(maxDepth - 1).
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3909
                seq notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3910
                    seq addFirst:anIdx.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3911
                  ^ seq
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3912
                ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3913
            ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3914
        ]
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3915
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3916
    ^ nil
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3917
! !
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  3918
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3919
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3920
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3921
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3922
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3923
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3924
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3925
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  3926
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3927
superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3928
    "returns supermenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3929
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3930
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3931
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3932
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3933
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3934
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3935
superMenu:aSuperMenu
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3936
    "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
  3937
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3938
    (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
  3939
        super font:(superMenu font).
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  3940
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3941
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3942
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3943
topMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3944
    "returns the topMenu; the one having no superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3945
    "
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3946
    |menu smenu|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3947
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3948
    menu := self.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3949
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3950
    [(smenu := menu superMenu) notNil] whileTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3951
        menu := smenu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3952
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3953
    ^ menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3954
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3955
1825
962390f1b499 category change
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
  3956
!MenuPanel methodsFor:'printing & storing'!
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3957
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3958
printString
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3959
    "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
  3960
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3961
    |string label|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3962
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3963
    string := 'Menu:'.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3964
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3965
    self do:[:anItem|
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3966
	label  := anItem label ? ''.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  3967
	string := string ,' ', label printString.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3968
    ].
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3969
    ^ string
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3970
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3971
    "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
  3972
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3973
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3974
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3975
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3976
application
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3977
    "optimize access to retrive the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3978
    "
1921
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3979
    |appl akey w views|
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3980
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  3981
    superMenu notNil ifTrue:[
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3982
        ^ superMenu application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3983
    ].
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  3984
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3985
    akey := #appl.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3986
    appl := self menuAdornmentAt:akey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3987
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3988
    appl isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3989
        (appl := super application) isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3990
            windowGroup isNil ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3991
                ^ nil   "/ RETRY LATER
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3992
            ].
1921
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3993
            views := windowGroup mainGroup topViews.
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3994
            views size == 0 ifTrue:[
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3995
                ^ nil   "/ RETRY LATER
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3996
            ].
f3f120d43849 oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
  3997
            w := views first.
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  3998
            w == self ifTrue:[
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  3999
                thisContext isRecursive ifTrue:[
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4000
                    self error:'recursive application query'
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4001
                ].
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4002
                "/ appl := akey
1870
ba2f5f6b5005 avoid recursive runaway in #applciation
ca
parents: 1864
diff changeset
  4003
            ].
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4004
            appl := (w application) ? akey.
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4005
        ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4006
        self menuAdornmentAt:akey put:appl
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  4007
    ].
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4008
    ^ appl ~~ akey ifTrue:[appl] ifFalse:[nil]
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4009
!
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4010
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4011
detectItemForKey:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4012
    "returns the item assigned to a key, accessCharacter or starts with.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4013
     if no item is detected nil is returned.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4014
    "
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4015
    |cIdx uKey lKey item|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4016
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4017
    items isNil ifTrue:[^ nil].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4018
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4019
    cIdx := self selectionIndex.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4020
    uKey := aKey asUppercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4021
    lKey := aKey asLowercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4022
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4023
    items keysAndValuesDo:[:anIndex :anItem| |char label|
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4024
        (     anIndex ~~ cIdx
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4025
         and:[anItem canSelect
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4026
         and:[(label := anItem textLabel) notNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4027
         and:[label size ~~ 0]]]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4028
        ) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4029
            (char := anItem accessCharacter) notNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4030
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4031
                    ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4032
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4033
            ] ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4034
                char := label at:1.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4035
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4036
                (char == uKey or:[char == lKey]) ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4037
                    anIndex > cIdx ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4038
                        ^ anItem
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4039
                    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4040
                    item isNil ifTrue:[item := anItem]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4041
                ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4042
            ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4043
        ]
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4044
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4045
    ^ item
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4046
!
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4047
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4048
menuAdornmentAt:aSymbol
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4049
    "returns a value derived from adornment
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4050
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4051
    |adm|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4052
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4053
    adm := adornment ? DefaultAdornment.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4054
  ^ adm at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4055
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4056
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4057
menuAdornmentAt:aSymbol put:something
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4058
    "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
  4059
     current stored value, true is returned otherwise false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4060
    "
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4061
    (self menuAdornmentAt:aSymbol) == something ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4062
	^ false
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4063
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4064
    adornment isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4065
	adornment := DefaultAdornment copy
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4066
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4067
    adornment at:aSymbol put:something.
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4068
  ^ true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4069
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4070
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4071
onEachPerform:aSelector withArgList:aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4072
    "on each item perform selector with an argument derived from aList
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4073
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4074
    aList isCollection ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4075
	items size >= aList size ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4076
	    aList keysAndValuesDo:[:anIndex :anArg|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4077
		(items at:anIndex) perform:aSelector with:anArg
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4078
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4079
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4080
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4081
	self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4082
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4083
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4084
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4085
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4086
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4087
registerImageOnDevice:anImage
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4088
    |image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4089
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4090
    (image := anImage) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4091
        image device ~~ device ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4092
            image := image copy.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4093
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4094
        image := image on:device.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4095
        image := image clearMaskedPixels.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4096
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4097
    ^ image
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4098
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4099
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4100
!MenuPanel methodsFor:'private activation'!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4101
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4102
activeMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4103
    "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
  4104
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4105
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4106
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4107
    "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
  4108
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4109
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4110
activeMenu:aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4111
    "set the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4112
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4113
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4114
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4115
    "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
  4116
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4117
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4118
becomesActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4119
    "submenu becomes the active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4120
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4121
    mapTime := Time millisecondClockValue.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4122
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4123
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4124
    "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
  4125
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4126
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4127
clearLastActiveMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4128
    "reset the current active menu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4129
    "
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4130
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4131
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4132
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4133
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4134
    prevFocusView notNil ifTrue:[
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4135
        self windowGroup focusView:prevFocusView.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4136
        prevFocusView := nil.
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4137
    ].
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4138
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4139
    top activeMenu == self ifTrue:[
1612
42e2fce5a1f9 set focus back
ca
parents: 1610
diff changeset
  4140
        top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4141
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4142
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4143
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4144
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4145
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4146
mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4147
    "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
  4148
    "
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4149
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4150
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4151
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4152
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4153
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4154
!MenuPanel methodsFor:'private scrolling'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4155
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4156
hasScrollerAt:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4157
    "returns true if a visible scroller at a direction exists
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4158
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4159
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4160
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4161
    self hasScrollers ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4162
        ^ false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4163
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4164
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4165
    aDirection == #PREV ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4166
        layout := items first layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4167
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4168
      ^ self verticalLayout ifTrue:[ layout top  < margin]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4169
                           ifFalse:[ layout left < margin]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4170
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4171
    layout := items last layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4172
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4173
  ^ self verticalLayout ifTrue:[ layout bottom > (height - margin)]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4174
                       ifFalse:[ layout right  > (width  - margin)]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4175
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4176
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4177
hasScrollers
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4178
    "returns true if scrollers are needed
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4179
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4180
    |maxExtent first last isVert|
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4181
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4182
    (mustRearrange or:[items size < 2]) ifTrue:[^ false].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4183
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4184
    isVert := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4185
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4186
    superView notNil ifTrue:[
2039
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4187
        (    (first := items first layout) isNil
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4188
         or:[(last  := items last  layout) isNil]
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4189
        ) ifTrue:[
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4190
            ^ false
176da0a9b13c test for empty layouts
ca
parents: 2024
diff changeset
  4191
        ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4192
        isVert ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4193
            ^ first top < 0 or:[last bottom > height]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4194
        ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4195
        ^ first left < 0 or:[last right > width]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4196
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4197
    maxExtent := self maxExtent.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4198
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4199
    isVert ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4200
        ^ (height < maxExtent y) not
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4201
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4202
    ^ (width < maxExtent x) not
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4203
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4204
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4205
indexOfItemAtScroller:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4206
    "returns the index of the item under the scroller or 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4207
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4208
    |bounds min max layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4209
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4210
    bounds := self scrollerBoundsAt:aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4211
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4212
    bounds isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4213
        ^ 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4214
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4215
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4216
    self verticalLayout ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4217
        min := bounds top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4218
        max := bounds bottom.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4219
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4220
        items keysAndValuesDo:[:anIndex :anItem|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4221
            anItem isVisible ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4222
                layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4223
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4224
                (layout top < max and:[layout bottom > min]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4225
                    ^ anIndex
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4226
                ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4227
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4228
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4229
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4230
        min := bounds left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4231
        max := bounds right.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4232
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4233
        items keysAndValuesDo:[:anIndex :anItem|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4234
            anItem isVisible ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4235
                layout := anItem layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4236
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4237
                (layout left < max and:[layout right > min]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4238
                    ^ anIndex
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4239
                ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4240
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4241
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4242
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4243
    ^ 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4244
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4245
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4246
makeItemVisible:anItem
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4247
    "make an item visible
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4248
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4249
    |boundsPREV boundsNEXT delta layout index scr0 scr1 windowSz scrSz doScroll
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4250
     isVertical boundsMin layoutMin boundsMax layoutMax dltOrg
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4251
     inv1 inv2|
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4252
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4253
    (     anItem notNil
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4254
     and:[self hasScrollers
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4255
     and:[(layout := anItem layout) notNil]]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4256
    ) ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4257
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4258
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4259
    index      := self indexOfItem:anItem.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4260
    boundsPREV := self scrollerBoundsAt:#PREV.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4261
    boundsNEXT := self scrollerBoundsAt:#NEXT.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4262
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4263
    isVertical := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4264
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4265
    isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4266
        boundsMin := boundsPREV bottom.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4267
        boundsMax := boundsNEXT top.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4268
        layoutMin := layout top.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4269
        layoutMax := layout bottom.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4270
        windowSz  := height.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4271
    ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4272
        boundsMin := boundsPREV right.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4273
        boundsMax := boundsNEXT left.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4274
        layoutMin := layout left.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4275
        layoutMax := layout right.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4276
        windowSz  := width.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4277
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4278
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4279
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4280
    layoutMin < boundsMin ifTrue:[
2062
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  4281
        layoutMin >= 0 ifTrue:[
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  4282
            ^ self
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  4283
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4284
        "/ test whether is first visible item
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4285
        index := items findLast:[:el| el isVisible] startingAt:(index - 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4286
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4287
        index == 0 ifTrue:[ scr0 := margin ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4288
                  ifFalse:[ scr0 := boundsMin ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4289
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4290
        delta := layoutMin negated + scr0.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4291
    ] ifFalse:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4292
        layoutMax > boundsMax ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4293
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4294
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4295
        "/ test whether is last visible item
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4296
        index  := items findFirst:[:el| el isVisible ] startingAt:(index + 1).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4297
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4298
        index == 0 ifTrue:[ scr0 := windowSz - margin ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4299
                  ifFalse:[ scr0 := boundsMax ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4300
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4301
        delta := scr0 - layoutMax.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4302
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4303
    delta == 0 ifTrue:[ ^ self ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4304
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4305
    doScroll := false.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4306
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4307
    shown ifTrue:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4308
        delta abs < (windowSz / 2) ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4309
            doScroll := true.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4310
            self repairDamage
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4311
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4312
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4313
    isVertical ifTrue:[ dltOrg := 0@delta ] ifFalse:[dltOrg := delta@0].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4314
    items do:[:el| el moveBy:dltOrg ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4315
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4316
    doScroll ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4317
        ^ self invalidate
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4318
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4319
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4320
    windowSz  := windowSz - margin - margin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4321
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4322
    scr0  := boundsMin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4323
    scr1  := scr0 + delta abs.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4324
    scrSz := boundsMax - scr1.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4325
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4326
    delta < 0 ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4327
        isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4328
            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
  4329
                           width:windowSz height:scrSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4330
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4331
            scr1 := scr0 + scrSz.
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4332
            inv2 := (margin @ scr1) extent:(windowSz @ (height - scr1 - margin)).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4333
            "/ self invalidateX:margin y:scr1 width:windowSz height:(height - scr1 - margin).
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4334
        ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4335
            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
  4336
                           width:scrSz height:windowSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4337
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4338
            scr1 := scr0 + scrSz.
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4339
            inv2 := (scr1 @ margin) extent:((width - scr1 - margin) @ windowSz).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4340
            "/ self invalidateX:scr1 y:margin width:(width - scr1 - margin) height:windowSz.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4341
        ].
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4342
        inv1 := boundsPREV.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4343
    ] ifFalse:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4344
        isVertical ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4345
            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
  4346
                           width:windowSz height:scrSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4347
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4348
            inv2 := (margin @ margin) extent:(windowSz @ (scr1 - margin)).
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4349
            "/ self invalidateX:margin y:margin width:windowSz height:scr1 - margin.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4350
        ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4351
            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
  4352
                           width:scrSz height:windowSz async:false.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4353
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4354
            inv2 := (margin @ margin) extent:(scr1 - margin) @ windowSz.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4355
            "/ self invalidateX:margin y:margin width:scr1 - margin height:windowSz.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4356
        ].
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4357
        inv1 := boundsNEXT.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4358
    ].
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4359
    self invalidate:inv1.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4360
    self invalidate:inv2.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4361
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4362
    "Modified: / 13.11.2001 / 20:26:42 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4363
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4364
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4365
scrollerBoundsAt:aDirection
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4366
    "returns the bounds of the scroller at a direction or nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4367
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4368
    |y x w h inset|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4369
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4370
    self hasScrollers ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4371
        ^ nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4372
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4373
    inset := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4374
    x := y := inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4375
    w := h := 15.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4376
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4377
    self verticalLayout ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4378
        aDirection == #NEXT ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4379
            y := height - h - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4380
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4381
        w := width - inset - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4382
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4383
        aDirection == #NEXT ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4384
            x := width - w - inset.       
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4385
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4386
        h := height - inset - inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4387
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4388
    ^ Rectangle left:x top:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4389
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4390
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4391
scrollerDirectionAtPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4392
    "returns the scroller-direction at aPoint, or nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4393
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4394
    self hasScrollers ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4395
        #( PREV NEXT ) do:[:aDirection| |bounds|
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4396
            (    (bounds := self scrollerBoundsAt:aDirection) notNil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4397
             and:[bounds containsPoint:aPoint]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4398
            ) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4399
                ^ (self hasScrollerAt:aDirection) ifTrue:[aDirection] ifFalse:[nil]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4400
            ]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4401
        ]
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4402
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4403
    ^ nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4404
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4405
    "Created: / 13.11.2001 / 14:13:16 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4406
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4407
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4408
scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4409
    "returns the one and only scrolling - data holder
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4410
     for a menu and all contained submenus
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4411
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4412
    superMenu notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4413
        ^ superMenu scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4414
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4415
    scrolling isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4416
        scrolling := Scrolling new.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4417
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4418
    ^ scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4419
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4420
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4421
!MenuPanel methodsFor:'private searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4422
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4423
detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4424
    "returns the menu which is responsible for the grap; the last opened menu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4425
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4426
    |subMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4427
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4428
    selection notNil ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4429
        (subMenu := selection visibleSubmenu) notNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4430
            ^ subMenu detectGrabMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4431
        ]
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
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4434
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4435
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4436
detectMenuAtGrabPoint:aGrabPoint
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4437
    "returns the menu which contains the grab-point
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4438
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4439
    |dstMenu dstPoint firstMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4440
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4441
    dstPoint := self translateGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4442
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4443
    ((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
  4444
        firstMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4445
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4446
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4447
    (selection isNil or:[(dstMenu := selection visibleSubmenu) isNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4448
        ^ firstMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4449
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4450
    dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  4451
    ^ dstMenu ? firstMenu
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4452
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4453
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4454
detectViewAtX:x y:y in:aTopView
1922
1a2ab52eb2ab bug fix in #detectViewAtX:y:in:
ca
parents: 1921
diff changeset
  4455
    "detect view at x@y
1a2ab52eb2ab bug fix in #detectViewAtX:y:in:
ca
parents: 1921
diff changeset
  4456
    "
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4457
    ^ aTopView detectViewAt:(x@y).
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4458
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4459
"/ 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
  4460
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4461
"/    |p subViews|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4462
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4463
"/    (subViews := aTopView subViews) notNil ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4464
"/        subViews do:[:v| |p|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4465
"/            v shown ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4466
"/                (    (x between:(v left) and:(v right))
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4467
"/                 and:[y between:(v top)  and:(v bottom)]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4468
"/                ) ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4469
"/                    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
  4470
"/                  ^ 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
  4471
"/                ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4472
"/            ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4473
"/        ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4474
"/    ].
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4475
"/    ^ aTopView
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4476
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4477
    "Modified: / 10.10.2001 / 13:45:56 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4478
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4479
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4480
itemAtPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4481
    "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
  4482
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4483
    items notNil ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4484
        ^ items detect:[:el| el containsPoint:aPoint] ifNone:nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4485
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4486
    ^ nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4487
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4488
    "Created: / 13.11.2001 / 13:58:23 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4489
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4490
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4491
itemAtX:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4492
    "returns the item at a point x@y or nil if none detected
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4493
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4494
    items notNil ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4495
        ^ items detect:[:el| el containsPointX:x y:y] ifNone:nil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4496
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4497
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4498
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4499
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4500
superMenuAtPoint:aPoint
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4501
    "returns the superMenu which contains aPoint, or nil if none detected
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4502
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4503
    |grabPoint superMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4504
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4505
    (self containsPoint:aPoint) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4506
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4507
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4508
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4509
    grabPoint := aPoint - (self translateGrabPoint:0).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4510
    superMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4511
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4512
    [ (superMenu := superMenu superMenu) notNil ] whileTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4513
        (superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4514
            ^ superMenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4515
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4516
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4517
  ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4518
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4519
    "Created: / 13.11.2001 / 20:22:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4520
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4521
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4522
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4523
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4524
container:aView
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4525
    super container:aView.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4526
    aView notNil ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4527
        "/ 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
  4528
        self updateLevelAndBorder
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4529
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4530
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4531
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4532
containsPoint:aPoint
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4533
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4534
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4535
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4536
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4537
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4538
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4539
    "returns true if point is contained by the view
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4540
    "
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  4541
    ^ (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
  4542
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4543
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4544
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4545
hasGroupDividerAt:anIndex
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4546
    "returns true if a divider is defined at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4547
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4548
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4549
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4550
    groupSizes size ~~ 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4551
        i := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4552
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4553
        groupSizes do:[:t|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4554
            (i := i + t) == anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4555
                ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4556
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4557
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4558
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4559
  ^ false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4560
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4561
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4562
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4563
hasGroupDividers
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4564
    "returns true if any group divider exists
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4565
    "
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4566
  ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4567
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4568
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4569
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4570
    "returns enabled state of menu and items
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4571
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4572
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4573
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4574
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4575
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4576
    "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
  4577
     be fit to the extent of its superView;
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4578
     NOT SUPPORTED
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4579
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4580
    ^ false
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4581
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4582
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4583
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4584
    "return true if view is a popup view; without decoration
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4585
     and popUp to top immediately
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4586
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4587
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4588
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4589
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4590
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4591
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4592
isVerticalLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4593
    "returns true if vertical layout otherwise false( horizontal layout )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4594
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4595
    ^ self verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4596
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4597
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4598
!
c05874084d4c implement
ca
parents: 407
diff changeset
  4599
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4600
isViewWrapper
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4601
    ^ subViews size ~~ 0
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4602
!
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  4603
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4604
openMenuOnSelect
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4605
    ^ (self menuAdornmentAt:#openMenuOnSelect) ? DefaultOpenOnSelect.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4606
        
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4607
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4608
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4609
openMenuOnSelect:something
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4610
    ^ self menuAdornmentAt:#openMenuOnSelect put:something
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4611
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4612
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4613
select:newSel openMenu:openMenu
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4614
    |old|
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4615
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4616
    old := self menuAdornmentAt:#openMenuOnSelect.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4617
    self menuAdornmentAt:#openMenuOnSelect put:openMenu.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4618
    self selection:newSel.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4619
    self menuAdornmentAt:#openMenuOnSelect put:old.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4620
!
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
  4621
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4622
type
428
ca
parents: 427
diff changeset
  4623
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  4624
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4625
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4626
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4627
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4628
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4629
hasSelection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4630
    "returns true if a selection exists
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4631
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4632
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4633
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4634
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4635
selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4636
    "returns current selected item or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4637
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4638
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4639
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4640
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4641
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4642
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4643
selection:anItemOrNil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4644
    "change selection to an item or nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4645
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4646
    |item newSel hlp visItem|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4647
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4648
    (newSel := anItemOrNil) isNumber ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4649
        newSel := self itemAt:anItemOrNil
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4650
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4651
    visItem := newSel.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4652
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4653
    (newSel notNil and:[newSel canSelect]) ifFalse:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4654
        newSel := nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4655
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4656
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4657
    selection == newSel ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4658
        ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4659
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4660
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4661
    (item := selection) notNil ifTrue:[
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4662
        selection := nil.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4663
        item selected:false.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4664
    ].
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4665
    visItem notNil ifTrue:[self makeItemVisible:visItem].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4666
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4667
    newSel isNil ifTrue:[^ self].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4668
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4669
    newSel == enteredItem ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4670
        enteredItem := nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4671
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4672
        self pointerEntersItem:nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4673
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4674
    selection := newSel.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4675
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4676
    ActiveHelp isActive ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4677
        hlp := ActiveHelp currentHelpListener.
2058
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  4678
        hlp initiateHelpFor:self at:nil now:true.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4679
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4680
    shown "realized" ifTrue:[self rearrangeItems].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4681
    selection selected:true.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4682
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4683
    "Modified: / 13.11.2001 / 20:17:47 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4684
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4685
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4686
selectionIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4687
    "returns index of current selection or 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4688
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4689
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4690
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4691
    (item := self selection) notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  4692
	^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4693
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4694
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4695
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4696
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4697
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4698
selectionIndex:anIndex
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4699
    "set selection at an index
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4700
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4701
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4702
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4703
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4704
!MenuPanel methodsFor:'translation'!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4705
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4706
translateGrabPoint:aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4707
    "translate the grab point into self
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4708
    "
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4709
    superMenu isNil ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4710
        "I am the grapView"
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4711
        aGrabPoint isNumber ifTrue:[^ aGrabPoint @ aGrabPoint].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4712
      ^ aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4713
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4714
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4715
    relativeGrabOrigin isNil ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4716
        relativeGrabOrigin := self topMenu translatePoint:0 to:self.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4717
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4718
    ^ relativeGrabOrigin + aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4719
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4720
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4721
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4722
translateMenuPoint:aPoint toMenu:aMenu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4723
    "translate a point into another menu its point
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4724
    "
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4725
    |grapPoint|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4726
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4727
    aMenu == self ifTrue:[
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4728
        ^ aPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4729
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4730
    grapPoint := aPoint - (self translateGrabPoint:0).
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4731
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4732
  ^ aMenu translateGrabPoint:grapPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4733
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4734
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4735
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4736
translatePoint:aPoint to:anotherWindowOrNilForScreen
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4737
    "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
  4738
    "
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4739
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4740
    ^ device 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4741
        translatePoint:aPoint asPoint 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4742
        fromView:self 
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4743
        toView:anotherWindowOrNilForScreen
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4744
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4745
    "Modified: / 10.10.2001 / 14:11:47 / cg"
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4746
! !
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4747
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4748
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4749
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4750
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4751
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4752
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4753
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4754
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4755
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4756
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4757
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4758
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  4759
    ^ VerticalInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4760
!
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4761
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4762
verticalPopUpInset
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4763
    ^ VerticalPopUpInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4764
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4765
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4766
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4767
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4768
separatorSize
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4769
    "returns size of a separator
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4770
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4771
    ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4772
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4773
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4774
updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4775
    "setup defaults
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  4776
     self updateStyleCache
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4777
    "
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4778
    <resource: #style (#'menuPanel.verticalInset')>
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4779
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4780
    HorizontalInset       := 2.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4781
    VerticalInset         := MenuPanel styleSheet at:#'menuPanel.verticalInset' default:2.
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4782
    VerticalPopUpInset    := 2.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4783
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4784
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4785
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  4786
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  4787
    LabelRightOffset      := 15.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4788
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  4789
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  4790
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  4791
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4792
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4793
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4794
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4795
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4796
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4797
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4798
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4799
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4800
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4801
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4802
    item label:aLabel.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4803
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4804
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4805
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4806
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4807
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4808
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4809
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4810
    item menuItem:aMenuItem.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4811
  ^ item.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4812
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4813
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
  4814
!MenuPanel::Item methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4815
420
ca
parents: 417
diff changeset
  4816
canAccept
ca
parents: 417
diff changeset
  4817
    "returns true if item is acceptable
ca
parents: 417
diff changeset
  4818
    "
ca
parents: 417
diff changeset
  4819
  ^ (self enabled and:[self hasSubmenu not])
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4820
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4821
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4822
toggleIndication
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4823
    "toggle indication or choice
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4824
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4825
    |arg|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4826
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4827
    indication notNil ifTrue:[    
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4828
        arg := self indicationValue not.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4829
        self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  4830
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4831
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4832
            choice value:choiceValue.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4833
          ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4834
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4835
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  4836
    ^ arg
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4837
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4838
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4839
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4840
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4841
accessCharacter
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4842
    "returns my accessCharacter or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4843
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4844
    ^ accessCharacter
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4845
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4846
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4847
accessCharacterPosition
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4848
    "get the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4849
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4850
    ^ accessCharacterPosition
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4851
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4852
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4853
accessCharacterPosition:anIndex 
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4854
    "set the access character position or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4855
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4856
    accessCharacterPosition := anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4857
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4858
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4859
argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4860
    "gets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4861
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4862
    ^ argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4863
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4864
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4865
argument:anArgument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4866
    "sets the argument
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4867
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4868
    argument := anArgument.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4869
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  4870
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4871
font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4872
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4873
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4874
    ^ font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4875
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4876
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4877
font:aFont
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4878
    "returns the user configured font or nil (default menu font)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4879
    "
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4880
    aFont ~= font ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4881
        font := aFont notNil ifTrue:[aFont onDevice:(menuPanel device)]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4882
                            ifFalse:[nil].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4883
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4884
        rawLabel notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4885
            "have to recompute the extent"
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4886
            self label:label
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4887
        ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4888
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4889
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4890
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4891
label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4892
    "returns the label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4893
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4894
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4895
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4896
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4897
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4898
    "set a new label; if the label changed, a redraw is performed;
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4899
     handle characters $& (ST-80 compatibility)
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4900
    "
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4901
    |size char lbl mfont f oldExtent
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4902
     h "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4903
     w "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4904
    |
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4905
    oldExtent       := rawLabelExtent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4906
    accessCharacter := rawLabelExtent := disabledRawLabel := nil.
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4907
    label           := aLabel value.
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4908
    rawLabel        := label value ? ''.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4909
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4910
    rawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4911
        "CHECK FOR SEPARATOR"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4912
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4913
        (isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4914
            size := rawLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4915
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4916
            size == 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4917
                rawLabel := nil.                        "blank separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4918
              ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4919
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4920
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4921
            size == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4922
                char := rawLabel first.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4923
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4924
                (char == $- or:[char == $=]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4925
                    label    := rawLabel.               "line separator"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4926
                    rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4927
                  ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4928
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4929
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4930
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4931
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4932
        rawLabel isCollection ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4933
            rawLabel := rawLabel asArray.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4934
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4935
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4936
    mfont := menuPanel setFont:font.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4937
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4938
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4939
        w := h := 0.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4940
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4941
        rawLabel keysAndValuesDo:[:i :el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4942
            el notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4943
                lbl := self updateAccessCharacterFor:el.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4944
                rawLabel at:i put:lbl.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4945
                w := w max:(lbl widthOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4946
                h := h + 1 + (lbl heightOn:menuPanel).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4947
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4948
                h := h + 3
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4949
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4950
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4951
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4952
        rawLabel := self updateAccessCharacterFor:rawLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4953
        w := rawLabel  widthOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4954
        h := rawLabel heightOn:menuPanel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4955
    ].
1797
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4956
28327a68241b give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4957
    "/ 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
  4958
    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
  4959
    (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
  4960
        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
  4961
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4962
    rawLabelExtent := w@h.
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4963
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  4964
    menuPanel setFont:mfont.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4965
    menuPanel shown ifTrue:[ self fetchImages ].
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4966
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4967
    oldExtent = rawLabelExtent ifTrue:[
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4968
        self invalidate
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4969
    ] ifFalse:[
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4970
        menuPanel mustRearrange
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  4971
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4972
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4973
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4974
menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4975
    "returns my menuPanel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4976
    "
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  4977
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4978
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4979
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4980
nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4981
    "gets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4982
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4983
    ^ nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4984
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4985
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4986
nameKey:aNameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4987
    "sets the nameKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4988
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4989
    nameKey := aNameKey.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4990
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4991
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4992
rawLabel
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4993
    "returns my printable Label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4994
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4995
    ^ rawLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4996
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4997
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4998
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4999
    "get the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5000
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5001
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5002
    ^ shortcutKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5003
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5004
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5005
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5006
    "set the key to press to select the submenu from the keyboard or if
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5007
     no submenu exists evaluate the action assigned to the item (accept).
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5008
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5009
    shortcutKey ~~ aKey ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5010
        shortcutKey := aKey.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5011
        self invalidate.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  5012
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  5013
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5014
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5015
startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5016
    "start group #left #right #center ... or nil
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5017
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5018
    "
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5019
    ^ startGroup
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5020
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5021
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5022
startGroup:aSymbol
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5023
    "start group #left #right #center ...
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5024
     at the moment only #right is implemented
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5025
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5026
    startGroup := aSymbol.
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5027
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5028
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5029
submenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5030
    "returns my submenu or nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5031
    "
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5032
    subMenu notNil ifTrue:[^ subMenu].
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5033
  ^ self setupSubmenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5034
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5035
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5036
submenu:aSubMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5037
    "set a new submenu; an existing submenu will be destroyed. This might lead
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5038
     to a redraw if 'hasSubmenu' changed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5039
    "
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5040
    |widget|
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5041
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5042
    aSubMenu isNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5043
        subMenu notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5044
            subMenu destroy.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5045
            subMenu := nil.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5046
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5047
        ^ self
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5048
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5049
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5050
    (aSubMenu isKindOf:Menu) ifTrue:[
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5051
        subMenu := MenuPanel new.
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5052
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5053
        menuPanel notNil ifTrue:[
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5054
            subMenu receiver:menuPanel receiver.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5055
        ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5056
        subMenu superMenu:menuPanel.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5057
        subMenu menu:aSubMenu.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5058
    ] ifFalse:[
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5059
        aSubMenu isView ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5060
            (aSubMenu isKindOf:ApplicationModel) ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5061
                "/ ... mhhhh ....
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5062
                ^ self submenuChannel:aSubMenu
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5063
            ].            
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5064
            widget := SimpleView new.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5065
            widget client:aSubMenu.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5066
        ] ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5067
            widget := aSubMenu
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5068
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5069
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5070
        (widget isKindOf:MenuPanel) ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5071
            subMenu := widget
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5072
        ] ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5073
            subMenu := MenuPanel new.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5074
            subMenu receiver:menuPanel receiver.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5075
            subMenu addSubView:widget.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5076
            subMenu extent:(widget preferredExtent).
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5077
            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
  5078
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5079
        subMenu superMenu:menuPanel.
1929
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  5080
    ].
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  5081
    self keepLinkedMenu ifTrue:[
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  5082
        submenuChannel := nil
58586354e428 bug fix: keepLinkedMenu
ca
parents: 1923
diff changeset
  5083
    ]
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5084
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5085
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5086
textLabel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5087
    "returns my textLabel or nil if none text
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5088
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5089
    |txt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5090
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5091
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5092
        rawLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5093
            ^ rawLabel perform:#string ifNotUnderstood:nil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5094
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5095
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5096
        rawLabel do:[:el|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5097
            (txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5098
                ^ txt
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
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5101
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5102
    ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5103
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5104
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5105
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5106
triggerOnDown
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5107
    "trigger the action if pressed
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5108
    "
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5109
    triggerOnDown == true ifTrue:[
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5110
        self hasSubmenu ifFalse:[^ true].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5111
        triggerOnDown := false.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5112
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5113
    ^ false
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5114
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5115
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5116
triggerOnDown:aBool
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5117
    "trigger the action if pressed
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5118
    "
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5119
    triggerOnDown := aBool.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5120
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5121
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5122
value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5123
    "gets value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5124
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5125
    ^ value
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5126
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5127
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5128
value:something
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5129
    "could be a value holder, an action or selector
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5130
    "
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5131
    value := something.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5132
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5133
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5134
value:aValue argument:anArgument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5135
    "set the value and an argument
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5136
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5137
    value    := aValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5138
    argument := anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5139
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5140
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5141
!MenuPanel::Item methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5142
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5143
choice
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5144
    "implements a radio group; the field
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5145
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5146
    ^ choice
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5147
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5148
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5149
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5150
choice:something
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5151
    "set choice indication
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5152
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5153
    choice == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5154
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5155
    choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5156
        choice removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5157
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5158
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5159
    (choice := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5160
        choice isSymbol ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5161
            (choice := self aspectAt:choice) isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5162
                choice := something
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5163
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5164
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5165
        choice isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5166
            choice addDependent:self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5167
        ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5168
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5169
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5170
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5171
choiceValue
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5172
    "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
  5173
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5174
    ^ choiceValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5175
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5176
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5177
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5178
choiceValue:something
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5179
    "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
  5180
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5181
    choiceValue ~= something ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5182
        choiceValue := something.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5183
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5184
        choice notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5185
            self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5186
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5187
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5188
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5189
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5190
enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5191
    "returns the enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5192
    "
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5193
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5194
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5195
    menuPanel enabled ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5196
        enableChannel isSymbol ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5197
            state := self aspectAt:enableChannel.
1806
5ca7e602ca7c ignore Backspace in shortKey processing;
Claus Gittinger <cg@exept.de>
parents: 1800
diff changeset
  5198
            state isNil ifTrue:[
1902
8676e04e404a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1889
diff changeset
  5199
                ('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
  5200
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5201
            state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5202
                enableChannel := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5203
                enableChannel addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5204
                state := enableChannel value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5205
            ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5206
                state := state value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5207
            ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5208
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5209
            state := enableChannel value
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5210
        ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5211
      ^ state ~~ false
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5212
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5213
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5214
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5215
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5216
enabled:something
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5217
    "change the enabled state; if the state changed, a redraw is performed
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5218
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5219
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5220
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5221
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5222
        oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5223
    ] ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5224
        oldState := enableChannel value.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5225
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5226
            enableChannel removeDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5227
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5228
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5229
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5230
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5231
    enableChannel isNil ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5232
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5233
        newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5234
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5235
        enableChannel isValueModel ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5236
            enableChannel addDependent:self
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5237
        ] ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5238
            enableChannel isSymbol ifTrue:[^ self]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5239
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5240
        menuPanel shown ifFalse:[^ self].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5241
        newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5242
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5243
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5244
    newState ~~ oldState ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5245
        self invalidate
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5246
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5247
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5248
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5249
hideMenuOnActivated
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5250
    "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5251
    "
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5252
    ^ hideMenuOnActivated ? true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5253
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5254
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5255
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5256
hideMenuOnActivated:aBool
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5257
   "hide the menu when the item was activated; the default is true
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5258
   "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5259
   hideMenuOnActivated := aBool.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5260
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5261
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5262
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5263
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5264
indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5265
    "get on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5266
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5267
    ^ indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5268
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5269
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5270
indication:something
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5271
    "set on/off indication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5272
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5273
    indication == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5274
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5275
    indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5276
        indication removeDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5277
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5278
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5279
    (indication := something) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5280
        indication isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5281
            indication addDependent:self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5282
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5283
            "/ to force an update of the value
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5284
            self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5285
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5286
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5287
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5288
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5289
isButton
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5290
    "returns whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5291
    "
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  5292
    ^ isButton
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5293
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5294
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5295
isButton:anBoolean
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5296
    "sets whether item looks like a Button
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5297
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5298
    isButton := anBoolean.
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5299
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5300
    layout notNil ifTrue:[
1731
89932327a6f8 redrawAsButton no longer exists; call invalidate
ca
parents: 1730
diff changeset
  5301
        self invalidate.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5302
    ]
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5303
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5304
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5305
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5306
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  5307
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5308
keepLinkedMenu
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5309
    "get the keepLinkedMenu flag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5310
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5311
    ^ keepLinkedMenu ? false
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5312
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5313
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5314
keepLinkedMenu:aFlag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5315
    "get the keepLinkedMenu flag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5316
    "
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5317
    keepLinkedMenu := aFlag
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5318
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5319
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5320
showBusyCursorWhilePerforming
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5321
    "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
  5322
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5323
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5324
    ^ showBusyCursorWhilePerforming ? false
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5325
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5326
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5327
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5328
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5329
showBusyCursorWhilePerforming:aBoolean
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5330
    "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
  5331
     while performing the menu action. Defaults to false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5332
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5333
    showBusyCursorWhilePerforming := aBoolean.
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5334
!
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
  5335
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5336
submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5337
    "get the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5338
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5339
  ^ submenuChannel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5340
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5341
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5342
submenuChannel:aSelectorOrNil
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5343
    "returns the submenu channel
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5344
    "
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5345
    submenuChannel := aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5346
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5347
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5348
!MenuPanel::Item methodsFor:'accessing-dimension'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5349
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5350
layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5351
    "returns my layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5352
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5353
    ^ layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5354
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5355
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5356
layout:aLayout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5357
    "set a new layout ( Rectangle )
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5358
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5359
    layout := aLayout.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5360
    self invalidate.
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  5361
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5362
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5363
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5364
moveBy:aPoint
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5365
    "move layout origin
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5366
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5367
    layout moveBy:aPoint.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5368
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5369
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5370
preferredExtent
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5371
    "compute my preferred extent excluding the shortCutKey and the menu identifier
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5372
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5373
    |isVertical
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5374
     x "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5375
     y "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5376
     s "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5377
    |
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5378
    self isVisible ifFalse:[^ 0@0 ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5379
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5380
    isButton ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5381
        s := menuPanel maxAbsoluteButtonLevel.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5382
        x := s + HorizontalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5383
        y := s + VerticalButtonInset.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5384
    ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5385
        x  := HorizontalInset.
1766
e3667c5b8b30 may not assign potential nil to a smallInt-typed variable
Claus Gittinger <cg@exept.de>
parents: 1765
diff changeset
  5386
        y  := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5387
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5388
    x := x * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5389
    y := y * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5390
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5391
    isVertical := menuPanel verticalLayout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5392
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5393
    rawLabel isNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5394
        "SEPARATOR"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5395
        s := self class separatorSize.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5396
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5397
        "width of doubleSeparator is 5 !!!!"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5398
        isVertical ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5399
            x := x max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5400
            y := y + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5401
        ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5402
            y := y max:s.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5403
            x := x + 5.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5404
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5405
    ] ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5406
        x := x + rawLabelExtent x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5407
        y := y + rawLabelExtent y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5408
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5409
        isButton ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5410
            menuPanel showSeparatingLines ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5411
                "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
  5412
                isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5413
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5414
            (indication notNil or:[choice notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5415
                x := x + 2 + menuPanel iconIndicationOff width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5416
            ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5417
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5418
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5419
    ^ x@y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5420
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5421
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5422
!MenuPanel::Item methodsFor:'accessing-help'!
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5423
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5424
activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5425
    "get the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5426
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5427
    ^ activeHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5428
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5429
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5430
activeHelpKey:aHelpKey
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5431
    "set the active helpKey; the key to retrieve the helpText from the application
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5432
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5433
    activeHelpKey ~~ aHelpKey ifTrue:[
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5434
        activeHelpKey  := aHelpKey.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5435
        activeHelpText := nil.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5436
    ].
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5437
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5438
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5439
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5440
activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5441
    "get the active helpText or nil if not yet resolved
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5442
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5443
    ^ activeHelpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5444
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5445
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5446
activeHelpText:aText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5447
    "set the active helpText
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5448
    "
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5449
    activeHelpText := aText.
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5450
! !
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  5451
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5452
!MenuPanel::Item methodsFor:'activation / deactivation'!
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5453
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5454
currentSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5455
    "returns the current submenu or nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5456
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5457
    ^ subMenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5458
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5459
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5460
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5461
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5462
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5463
hideSubmenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5464
    "hide submenu
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5465
    "
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5466
    |id|
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5467
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5468
    subMenu notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5469
        subMenu realized ifFalse:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5470
            (id := subMenu id) notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5471
                menuPanel device unmapWindow:id
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5472
            ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5473
        ] ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5474
           subMenu hide
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5475
        ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5476
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5477
        subMenu windowGroup:nil.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5478
        menuPanel windowGroup removeView:subMenu.
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5479
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5480
        "/ release menu if derived from channel
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5481
        submenuChannel notNil ifTrue:[
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5482
            subMenu := nil
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5483
        ]
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5484
     ].
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  5485
!
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5486
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5487
openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5488
    "opens the submenu; make sure, that the submenu and the menPanel
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5489
     is fully visible by shifting it into the visible screen area if
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5490
     nescessary.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5491
    "
1790
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5492
    |p o device isVertical topMenu windGrp prefExtent item
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5493
     devBot   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5494
     devRight "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5495
     width    "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5496
     height   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5497
     top      "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5498
     left     "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5499
    |
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5500
1737
c18896a7cb50 replace shown by realized; when opening a submenue-submenue by shortcut key
ca
parents: 1735
diff changeset
  5501
    (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
  5502
        ^ self
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5503
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5504
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5505
    topMenu := menuPanel topMenu.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5506
    (subMenu device notNil and:[topMenu device ~~ subMenu device]) ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5507
        subMenu releaseDeviceResources.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5508
        subMenu setDevice:topMenu device id:nil gcId:nil.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5509
        subMenu recreate.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5510
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  5511
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5512
    windGrp := topMenu windowGroup.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5513
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5514
    subMenu superMenu:menuPanel.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5515
    subMenu becomesActiveMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5516
    subMenu cursor:Cursor hand.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5517
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5518
    windGrp notNil ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5519
        subMenu windowGroup:windGrp.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5520
        windGrp addTopView:subMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5521
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5522
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5523
    " Q&D kludge - if any visibility attributes are blocks;
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5524
      TODO: only invoke mustRearrange if any are blocks
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5525
            (since I react correctly on valueHolder changes)
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5526
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5527
    subMenu rearrangeItemsIfItemVisibilityChanged.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5528
    subMenu fixSize.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5529
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5530
    "compute origin of subMenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5531
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5532
    isVertical := menuPanel verticalLayout.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5533
    device     := menuPanel device.
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5534
    prefExtent := subMenu preferredExtent.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5535
    height     := prefExtent y.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  5536
    width      := prefExtent x.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5537
    devBot     := device  usableHeight.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5538
    devRight   := device  usableWidth.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5539
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5540
    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
  5541
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5542
    menuPanel isPopUpView ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5543
        o := menuPanel origin + p
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5544
    ] ifFalse:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5545
        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
  5546
    ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5547
    left := o x.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5548
    top  := o y.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5549
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5550
    top + height > devBot ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5551
        top := isVertical ifTrue:[devBot - height]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5552
                         ifFalse:[top - layout height - height + 2]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5553
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5554
    top := top max:0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5555
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5556
"/    (isVertical not and:[subMenu isVerticalLayout]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5557
"/        top < menuPanel bottom ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5558
"/            left := left + layout width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5559
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5560
"/        left + width > devRight ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5561
"/            left := o x - width - 2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5562
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5563
"/    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5564
        
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5565
    left + width > devRight ifTrue:[
2012
256be477be6d translatePoint fix.
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
  5566
        left := isVertical ifTrue:[left - layout width - width + 2]
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5567
                          ifFalse:[devRight - width]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5568
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5569
    left := left max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5570
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5571
    subMenu origin:(left@top).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5572
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5573
    subMenu realized ifFalse:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5574
        subMenu realize. 
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5575
    ] ifTrue:[
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5576
        topMenu device mapWindow:(subMenu id).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5577
    ].
1790
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5578
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5579
    menuPanel openMenuOnSelect ifFalse:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5580
        (    menuPanel superMenu notNil                                         "/ not the top menu
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5581
         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
  5582
        ) ifTrue:[
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5583
            subMenu selectionIndex:1
98b89f8f4c17 do not select the first item if it represants a submenu
ca
parents: 1788
diff changeset
  5584
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5585
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5586
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5587
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5588
toggleSubmenuVisibility
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5589
    "toggle the visibility of the submenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5590
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5591
    subMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5592
        subMenu shown ifTrue:[^ self hideSubmenu]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5593
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5594
        (subMenu := self setupSubmenu) isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5595
            "/ cannot open a submenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5596
            ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5597
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5598
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5599
    self openSubmenu.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5600
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5601
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5602
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5603
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5604
visibleSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5605
    "returns the current visible submenu or nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5606
    "
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5607
    subMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5608
        subMenu shown ifTrue:[^ subMenu].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5609
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5610
    ^ nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5611
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  5612
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5613
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5614
! !
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  5615
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5616
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5617
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5618
aspectAt:aKey
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5619
    "retursns value assigned to key or nil
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5620
    "
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5621
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5622
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5623
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5624
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  5625
    (appl isValueModel) ifTrue:[
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5626
        ^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5627
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5628
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5629
    (appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5630
        Object messageNotUnderstoodSignal handle:[:ex|
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5631
            ex parameter selector == aKey ifFalse:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5632
                ex reject
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5633
            ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5634
            ('MenuPanel [info]: application does not provide aspect: ' , aKey) infoPrintCR.
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5635
        ] do:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5636
            aKey last == $: ifTrue:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5637
                value := appl perform:aKey with:(argument ? self).
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5638
            ] ifFalse:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5639
                (appl respondsTo:#aspectFor:) ifTrue:[
1775
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5640
                    value := appl aspectFor:aKey
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5641
                ] ifFalse:[
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5642
                    value := appl perform:aKey
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5643
                ]
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5644
            ]
7b63410aa8b3 allow selector with argument for #enabled and #visible
ca
parents: 1767
diff changeset
  5645
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5646
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5647
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  5648
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  5649
    "Modified: / 29.7.1998 / 11:59:50 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5650
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5651
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5652
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5653
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5654
update:something with:aParameter from:changedObject
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5655
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5656
    |form rect|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5657
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5658
    (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
  5659
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5660
    self isSeparator ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5661
        "/ NOT A SEPARATOR
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5662
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5663
        menuPanel shown ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5664
            changedObject == enableChannel ifTrue:[
1864
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5665
                (enableChannel value == false and:[self isSelected]) ifTrue:[
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5666
                    ^ menuPanel selection:nil.
cbc44ec70112 clear selection if item changed to disabled durring selected
ca
parents: 1862
diff changeset
  5667
                ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5668
                ^ self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5669
            ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5670
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5671
            (changedObject == indication or:[changedObject == choice]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5672
                isButton ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5673
                    self invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5674
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5675
                    "/ invalidate the interactor only
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5676
                    "/ take any interactor; interactors has the same extent
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5677
                    form := menuPanel iconIndicationOff.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5678
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5679
                    rect := Rectangle left:(layout left + HorizontalInset)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5680
                                       top:(layout top)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5681
                                     width:(form width)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5682
                                    height:(layout height).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5683
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5684
                    menuPanel invalidate:rect repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5685
                ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5686
                ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5687
            ].
1692
200a0b2e23c1 call invalidate instead of redraw
ca
parents: 1691
diff changeset
  5688
        ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  5689
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5690
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5691
    changedObject == isVisible ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5692
        menuPanel mustRearrange.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5693
        menuPanel rearrangeItems.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5694
      ^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5695
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  5696
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  5697
    super update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5698
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5699
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5700
updateIndicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5701
    "update indicators
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5702
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5703
    (indication notNil and:[indication isSymbol]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5704
        " indication is a selector otherwise a change notification
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5705
          is raised from the model !!!!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5706
        "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5707
        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
  5708
    ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5709
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5710
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5711
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5712
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5713
asMenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5714
    "convert to a MenuItem
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5715
    "
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5716
    |item label rcv|
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5717
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5718
    label := self label.
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5719
    item  := MenuItem labeled:(label printString).
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5720
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5721
    label isImage ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5722
        rcv := ResourceRetriever new.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5723
        rcv className:#MenuEditor.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5724
        rcv selector:#iconUnknown.
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5725
        item labelImage:rcv.
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5726
    ].
466
f025831cdae8 pick a imaged label; create a ResourceRetriever
ca
parents: 465
diff changeset
  5727
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  5728
    item activeHelpKey:activeHelpKey.
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5729
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5730
    enableChannel isSymbol ifTrue:[
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5731
        item enabled:enableChannel
460
5334456cedf8 handle enabled symbol; get aspect from application
ca
parents: 450
diff changeset
  5732
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5733
    item font:font.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5734
    item accessCharacterPosition:accessCharacterPosition.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5735
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5736
    item startGroup:startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5737
    item argument:argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5738
    item nameKey:nameKey.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  5739
    item shortcutKeyCharacter:shortcutKey.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5740
    value      isSymbol ifTrue:[item value:value].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5741
    indication isSymbol ifTrue:[item indication:indication].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5742
    choice     isSymbol ifTrue:[item choice:choice].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5743
    isVisible  isSymbol ifTrue:[item isVisible:isVisible].
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5744
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5745
    item choiceValue:choiceValue.
1819
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5746
    item hideMenuOnActivated:hideMenuOnActivated.
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5747
    item keepLinkedMenu:keepLinkedMenu.
576b0aaf9df1 asMenuItem: do not resolve models
ca
parents: 1811
diff changeset
  5748
    item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5749
    item triggerOnDown:(self triggerOnDown).
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  5750
    item isButton:isButton.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5751
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5752
    submenuChannel isSymbol ifTrue:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5753
        item submenuChannel:submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5754
    ] ifFalse:[
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5755
        subMenu notNil ifTrue:[
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5756
            item submenu:(subMenu asMenu)
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  5757
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5758
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5759
  ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5760
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5761
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5762
menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5763
    "setup attributes from a MenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5764
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5765
    |lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5766
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5767
    menuPanel disabledRedrawDo:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5768
        label := rawLabel := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5769
        accessCharacterPosition       := aMenuItem accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5770
        argument                      := aMenuItem argument.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5771
        choiceValue                   := aMenuItem choiceValue.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5772
        showBusyCursorWhilePerforming := aMenuItem showBusyCursorWhilePerforming.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5773
        triggerOnDown                 := aMenuItem triggerOnDown.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5774
        hideMenuOnActivated           := aMenuItem hideMenuOnActivated.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5775
        keepLinkedMenu                := aMenuItem keepLinkedMenu.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5776
        isButton                      := aMenuItem isButton ? false.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5777
        nameKey                       := aMenuItem nameKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5778
        startGroup                    := aMenuItem startGroup.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5779
        shortcutKey                   := aMenuItem shortcutKeyCharacter.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5780
        value                         := aMenuItem value.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5781
        activeHelpKey                 := aMenuItem activeHelpKey.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5782
        activeHelpText                := nil.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5783
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5784
        self font:(aMenuItem font).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5785
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5786
        self    enabled:(aMenuItem enabled).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5787
        self indication:(aMenuItem indication).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5788
        self     choice:(aMenuItem choice).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5789
        self  isVisible:(aMenuItem isVisible).
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5790
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5791
        (lbl := aMenuItem labelImage value) isNil ifTrue:[
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5792
            lbl := aMenuItem rawLabel. "/ avoid translating &'s twice
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5793
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5794
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5795
        self label:lbl.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5796
        submenuChannel := aMenuItem submenuChannel.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  5797
        self submenu:(aMenuItem submenu).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5798
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  5799
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  5800
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5801
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5802
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5803
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5804
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5805
drawButton
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5806
    "draw as button
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5807
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5808
    |drawObject fg etchFg level isEnabled isSelected bg ownBgCol
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5809
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5810
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5811
    drawObject := rawLabel.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5812
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5813
    "COMPUTE COLORS"
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5814
    isEnabled := self enabled.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5815
    (isSelected := self isSelected) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5816
        bg := self activeBackgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5817
        fg := self activeForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5818
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5819
        self isEntered ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5820
            bg := self buttonEnteredBackgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5821
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5822
            bg := self backgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5823
        ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5824
        isEnabled ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5825
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5826
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5827
            fg := menuPanel disabledForegroundColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5828
            etchFg := menuPanel disabledEtchedForegroundColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5829
            drawObject := self disabledRawLabel
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5830
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5831
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5832
1708
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5833
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5834
        bg := ownBgCol
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5835
    ].
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  5836
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5837
    "DRAW BACKGROUND"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5838
    bg ~= menuPanel backgroundColor ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5839
        menuPanel paint:bg.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5840
        menuPanel fillRectangle:layout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5841
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5842
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5843
    x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5844
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5845
    isSelected ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5846
        "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
  5847
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5848
        indication notNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5849
            "button is indicator and set"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5850
            isSelected := self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5851
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5852
            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
  5853
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5854
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5855
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5856
    isSelected ifTrue:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5857
        level := menuPanel buttonActiveLevel.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5858
        x     := x + level abs.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5859
    ] ifFalse:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5860
        level := self isEntered ifTrue:[menuPanel buttonEnteredLevel]
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5861
                                ifFalse:[menuPanel buttonPassiveLevel].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5862
    ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5863
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5864
    etchFg notNil ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5865
        self drawRawLabel:drawObject atX:x+1 yOffset:1 paint:etchFg.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5866
    ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5867
    self drawRawLabel:drawObject atX:x yOffset:0 paint:fg.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5868
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5869
    level ~~ 0 ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5870
        menuPanel drawButtonEdgesFor:self level:level
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5871
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5872
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5873
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5874
drawLabel
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5875
    "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
  5876
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5877
    |scKey cLb cLa drawObject fg etchFg arrow 
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5878
     isSelected isEnabled form
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5879
     h "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5880
     y "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5881
     x "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5882
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5883
    |
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5884
    drawObject := rawLabel.
1048
a8755e51706d bug fixes:
ca
parents: 1046
diff changeset
  5885
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5886
    isEnabled := self enabled.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5887
    isSelected := self isSelected.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5888
    isSelected ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5889
        fg := self activeForegroundColor
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5890
    ] ifFalse:[
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5891
        isEnabled ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5892
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5893
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5894
            fg  := menuPanel disabledForegroundColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5895
            etchFg := menuPanel disabledEtchedForegroundColor.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5896
            drawObject := self disabledRawLabel
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5897
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5898
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5899
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5900
    h := layout height.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5901
    x := layout left + HorizontalInset.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5902
    t := layout top.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5903
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5904
    ((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
  5905
        y := t + ((h - form height) // 2).
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  5906
        
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5907
        form displayOn:menuPanel x:x y:y.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5908
        x := x + 2 + form width.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5909
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5910
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5911
    etchFg notNil ifTrue:[
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5912
        self drawRawLabel:drawObject atX:x+1 yOffset:1 paint:etchFg.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5913
    ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5914
    self drawRawLabel:drawObject atX:x yOffset:0 paint:fg.
1046
c03b42debacb bug fixes:
ca
parents: 1045
diff changeset
  5915
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5916
    "/ DRAW SHORTCUT KEY
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5917
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5918
    (     shortcutKey notNil
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5919
     and:[(x := menuPanel shortKeyInset) ~~ 0
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5920
     and:[(scKey:= self shortcutKeyAsString) notNil]]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5921
    ) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5922
        x := layout left + x.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5923
        y := t + ((h - (scKey heightOn:menuPanel)) // 2).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5924
        y := y + menuPanel font ascent.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5925
        scKey displayOn:menuPanel x:x y:y. 
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5926
    ].
963
2660033bc16e hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  5927
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  5928
    "/ DRAW SUBMENU INDICATION
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5929
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5930
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5931
        arrow := menuPanel rightArrow.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5932
        x := layout right - arrow width - HorizontalInset.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5933
        y := t + (h - arrow height // 2).
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5934
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5935
        (menuPanel styleSheet is3D not
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5936
        or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5937
            ^ menuPanel displayForm:arrow x:x y:y
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5938
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5939
        cLa := menuPanel shadowColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5940
        cLb := menuPanel lightColor.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5941
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5942
        isSelected ifFalse:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5943
            fg  := cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5944
            cLa := cLb.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5945
            cLb := fg
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5946
        ].
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5947
        menuPanel paint:cLa.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5948
        menuPanel displayForm:arrow x:x y:y.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  5949
        menuPanel paint:cLb.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5950
        menuPanel displayForm:drawObject x:x y:y. 
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5951
    ]
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  5952
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  5953
    "Modified: / 6.9.1998 / 21:48:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5954
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5955
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5956
drawRawLabel:aLabel atX:x yOffset:yOffset paint:fg
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5957
    "draw a labeled entry; no button, no separator.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5958
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5959
    |mfont fontAscent
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5960
     y  "{ Class:SmallInteger }"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5961
     y0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5962
     x0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5963
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5964
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5965
    mfont := menuPanel setFont:font.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5966
    fontAscent := menuPanel font ascent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5967
    menuPanel paint:fg.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5968
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5969
    y := layout top + (layout height - rawLabelExtent y // 2) + yOffset.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5970
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5971
    aLabel isArray ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5972
        aLabel isImageOrForm ifFalse:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5973
            y := y + fontAscent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5974
        ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5975
        aLabel displayOn:menuPanel x:x y:y.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5976
    ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5977
        aLabel do:[:el|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5978
            el notNil ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5979
                el isImageOrForm ifFalse:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5980
                    y0 := y + fontAscent
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5981
                ] ifTrue:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5982
                    y0 := y
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5983
                ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5984
                x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5985
                el displayOn:menuPanel x:x0 y:y0.
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5986
                y := y + 1 + (el heightOn:menuPanel)
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5987
            ] ifFalse:[
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5988
                y := y + 3   "/ see #label:
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5989
            ]
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5990
        ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5991
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5992
    menuPanel setFont:mfont
1726
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
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5995
drawSeparatingLines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5996
    "draw separating lines
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  5997
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5998
    |myIndex lfSep rtSep items prevItem nextItem
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  5999
     lightColor shadowColor
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6000
     l "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6001
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6002
     r "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6003
     b "{ Class:SmallInteger }"
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  6004
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6005
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6006
    items := menuPanel items.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6007
    myIndex := items identityIndexOf:self.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6008
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6009
    prevItem  := items at:(myIndex - 1) ifAbsent:nil.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6010
    lfSep := prevItem notNil and:[prevItem isButton not].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6011
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6012
    nextItem  := items at:(myIndex + 1) ifAbsent:nil.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6013
    rtSep := nextItem notNil and:[nextItem isButton not].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6014
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6015
    (lfSep or:[rtSep]) ifFalse:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6016
        ^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6017
    ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6018
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6019
    lightColor := menuPanel lightColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6020
    shadowColor := menuPanel shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6021
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6022
    menuPanel paint:lightColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6023
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6024
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6025
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6026
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6027
    b := layout bottom.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6028
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6029
    menuPanel verticalLayout ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6030
        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
  6031
        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
  6032
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6033
        menuPanel paint:shadowColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6034
        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
  6035
        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
  6036
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6037
        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
  6038
        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
  6039
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6040
        menuPanel paint:shadowColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6041
        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
  6042
        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
  6043
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6044
!
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
drawSeparator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6047
    "draw as separator
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6048
    "
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6049
    |type lightColor shadowColor isDouble
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6050
     left top
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6051
     x0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6052
     x1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6053
     y0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6054
     y1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6055
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6056
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6057
    type := self separatorType.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6058
    (type isNil or:[type == #blankLine]) ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6059
        ^ self
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6060
    ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6061
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6062
    isDouble := type == #doubleLine.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6063
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6064
    lightColor := menuPanel lightColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6065
    shadowColor := menuPanel shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6066
    menuPanel paint:shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6067
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6068
    left := layout left.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6069
    top := layout top.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6070
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6071
    menuPanel verticalLayout ifTrue:[
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6072
        x0 := left  + HorizontalInset.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6073
        x1 := layout right - HorizontalInset.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6074
        y0 := top   - 1 + (layout height // 2).
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6075
        isDouble ifTrue:[y0 := y0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6076
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6077
        menuPanel displayLineFromX:x0 y:y0   toX:x1 y:y0.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6078
        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
  6079
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6080
        menuPanel paint:lightColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6081
        menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6082
        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
  6083
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6084
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6085
        y1 := layout bottom.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6086
        x0 := left - 1 + (layout width // 2).
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6087
        y0 := top.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6088
        isDouble ifTrue:[x0 := x0 - 2].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6089
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6090
        menuPanel displayLineFromX:x0   y:y0 toX:x0   y:y1.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6091
        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
  6092
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6093
        menuPanel paint:lightColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6094
        menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6095
        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
  6096
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6097
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6098
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6099
invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6100
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6101
    (rawLabel notNil and:[menuPanel notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6102
        menuPanel invalidateItem:self repairNow:false
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6103
    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6104
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6105
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6106
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6107
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6108
redraw
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6109
    "redraw item
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6110
    "
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6111
    |isSelected ownBgCol paint bgColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6112
     x  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6113
     y  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6114
     w  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6115
     h  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6116
    |
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6117
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6118
    self isVisible ifFalse:[^ self].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6119
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6120
    rawLabel isNil  ifTrue:[^ self drawSeparator].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6121
    isButton        ifTrue:[^ self drawButton].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6122
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6123
    "/ 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
  6124
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6125
    isSelected := self isSelected.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6126
    bgColor    := menuPanel backgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6127
    paint      := isSelected ifTrue:[self activeBackgroundColor] ifFalse:[bgColor].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6128
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6129
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6130
        paint := ownBgCol
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6131
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6132
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6133
    paint ~= bgColor ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6134
        menuPanel paint:paint.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6135
        menuPanel fillRectangle:layout.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6136
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6137
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6138
    menuPanel showSeparatingLines ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6139
        self drawSeparatingLines
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6140
    ].
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6141
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6142
    self drawLabel.  
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6143
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6144
    (ownBgCol notNil and:[isSelected]) ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6145
        ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6146
                                 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6147
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6148
        x := layout left.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6149
        y := layout top.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6150
        w := layout width.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6151
        h := layout height.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6152
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6153
        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
  6154
        menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4).  
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6155
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6156
    menuPanel drawLabelEdgeFor:self selected:isSelected.
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6157
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6158
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6159
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6160
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6161
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6162
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6163
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6164
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6165
destroy
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6166
    "destroy submenus, remove dependencies
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6167
    "
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6168
    self submenu:nil.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6169
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6170
    enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6171
    isVisible     isValueModel  ifTrue:[isVisible    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6172
    indication    isValueModel ifTrue:[indication    removeDependent:self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6173
    choice        isValueModel ifTrue:[choice        removeDependent:self].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6174
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6175
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6176
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6177
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6178
in:aPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6179
    "create item in a menuPanel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6180
    "
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6181
    menuPanel := aPanel.
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6182
    isButton  := false.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6183
!
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6184
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6185
reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6186
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6187
    subMenu notNil ifTrue:[
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6188
        subMenu reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6189
    ].
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6190
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6191
    "Created: / 17.8.2000 / 17:57:07 / cg"
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  6192
    "Modified: / 17.8.2000 / 18:00:08 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6193
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6194
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6195
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6196
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6197
disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6198
    "returns the label used if the item is disabled
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6199
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6200
    |block form image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6201
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6202
    disabledRawLabel notNil ifTrue:[^ disabledRawLabel].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6203
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6204
    disabledRawLabel := rawLabel ? ''.
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
    disabledRawLabel isString ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6207
        ^ disabledRawLabel
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
    block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6211
        (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6212
            el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6213
                el colorMap notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6214
                    rslt := menuPanel lightenedImageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6215
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6216
            ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6217
                el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6218
                    ((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6219
                        form := menuPanel lightenedImageOnDevice:form
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6220
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6221
                    ((image := el image) notNil and:[image colorMap notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6222
                        image := menuPanel lightenedImageOnDevice:image
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6223
                    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6224
                    rslt := LabelAndIcon form:form image:image string:(el string).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6225
                ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6226
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6227
        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6228
        rslt
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6229
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6230
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6231
    rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6232
        disabledRawLabel := Array new:(rawLabel size).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6233
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6234
        rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6235
            disabledRawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6236
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6237
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6238
        disabledRawLabel := block value:rawLabel
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6239
    ].
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6240
    ^ disabledRawLabel
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6241
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  6242
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6243
fetchDeviceResources
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6244
    disabledRawLabel := nil.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6245
    self fetchImages.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6246
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6247
    font notNil ifTrue:[
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6248
        font := font onDevice:(menuPanel device)
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6249
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6250
!
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6251
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6252
fetchImages
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6253
    "fetch images
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  6254
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6255
    |icon block|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6256
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6257
    rawLabel notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6258
        block := [:el| |rslt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6259
            (rslt := el) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6260
                el isImageOrForm ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6261
                    rslt := menuPanel imageOnDevice:el
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6262
                ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6263
                    el class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6264
                        (icon := el image) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6265
                            el image:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6266
                        ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6267
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6268
                        (icon := el icon) notNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6269
                            el icon:(menuPanel imageOnDevice:icon)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6270
                        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6271
                    ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6272
                ]
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6273
            ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6274
            rslt
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6275
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6276
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6277
        rawLabel isArray ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6278
            rawLabel keysAndValuesDo:[:anIndex :aLabel|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6279
                rawLabel at:anIndex put:(block value:aLabel)
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6280
            ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6281
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6282
            rawLabel := block value:rawLabel
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6283
        ]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6284
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6285
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6286
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6287
updateAccessCharacterFor:aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6288
    |s i rest label pos|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6289
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6290
    (accessCharacter notNil or:[aLabel isNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6291
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6292
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6293
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6294
    aLabel isString ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6295
        aLabel class == LabelAndIcon ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6296
            aLabel string:(self updateAccessCharacterFor:(aLabel string))
1709
0bc103eb4143 separtaor - label
ca
parents: 1708
diff changeset
  6297
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6298
        ^ aLabel
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6299
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6300
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6301
    s := aLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6302
    i := 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6303
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6304
    label := aLabel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6305
    pos := accessCharacterPosition.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6306
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6307
    [((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
  6308
        rest := label copyFrom:(i+1).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6309
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6310
        i == 1 ifTrue:[label := rest]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6311
              ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6312
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6313
        (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
  6314
        s := s - 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6315
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6316
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6317
    (pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[
1762
840521c06b92 bugfix for && in label
ca
parents: 1750
diff changeset
  6318
        ^ label
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6319
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6320
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6321
    label isText ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6322
        label := Text string:label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6323
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6324
    label emphasisAt:pos add:#underline.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6325
  ^ label
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6326
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6327
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6328
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6329
!MenuPanel::Item methodsFor:'printing & storing'!
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6330
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6331
displayString
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6332
    ^ self class name, '[', label printString, ']'
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6333
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6334
! !
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  6335
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6336
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6337
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6338
activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6339
    "returns the active background color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6340
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6341
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6342
    isButton ifTrue: [^menuPanel buttonActiveBackgroundColor].
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6343
    ^menuPanel activeBackgroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6344
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6345
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6346
activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6347
    "returns the active foreground color derived from menuPanel
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6348
    "
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6349
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6350
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6351
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  6352
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6353
backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6354
    "returns the background color derived from menuPanel
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6355
    "
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6356
1045
25d174d7b019 optimize:
ca
parents: 1044
diff changeset
  6357
    isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor].
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6358
    ^menuPanel backgroundColor
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6359
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  6360
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6361
backgroundColorFromLabel
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6362
    "returns the background color derived from label or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6363
    "
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6364
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6365
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6366
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6367
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6368
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6369
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6370
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6371
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6372
    run size == 0 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6373
	(run value isColor and:[run key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6374
	    ^ run value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6375
	]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6376
    ] ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6377
	run do:[:r|
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6378
	    (r value isColor and:[r key == #backgroundColor]) ifTrue:[
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6379
		^ r value
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6380
	    ]
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6381
	]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6382
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6383
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6384
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6385
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6386
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6387
    "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
  6388
     derived from menuPanel
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6389
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6390
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6391
    isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor].
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6392
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6393
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6394
    "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
  6395
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6396
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6397
choiceForm
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6398
    "returns choice form or nil
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6399
    "
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6400
    |isOn|
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6401
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6402
    choice isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6403
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6404
    isOn := choice value = choiceValue.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6405
    self enabled ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6406
        ^ isOn ifTrue:[menuPanel iconRadioGroupDisabledOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6407
               ifFalse:[menuPanel iconRadioGroupDisabledOff]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6408
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6409
    ^ isOn ifTrue:[menuPanel iconRadioGroupOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6410
           ifFalse:[menuPanel iconRadioGroupOff]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6411
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6412
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6413
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6414
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6415
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6416
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6417
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  6418
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6419
    |subm sel num|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6420
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6421
    aRecv isNil ifTrue:[^ nil].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6422
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6423
    sel := submenuChannel asSymbol.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6424
    num := sel numArgs.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6425
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6426
    num == 0 ifTrue:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6427
        Object messageNotUnderstoodSignal handle:[:ex|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6428
            |selector|
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6429
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6430
            ((selector := ex parameter selector) == sel
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6431
            or:[selector == #aspectFor:]) ifFalse:[
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6432
                ex reject
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6433
            ].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6434
        ] do:[
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6435
            subm := aRecv aspectFor:sel.
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6436
        ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6437
        subm notNil ifTrue:[^ subm].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6438
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6439
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6440
    (Array with:(aRecv) with:(aRecv class))
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6441
    do:[:aPossibleReceiver |
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6442
        Object messageNotUnderstoodSignal handle:[:ex|
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6443
            ex parameter selector == sel ifFalse:[ ex reject ]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6444
        ] do:[
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6445
                     num == 0 ifTrue:[subm := aPossibleReceiver perform:sel]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6446
            ifFalse:[num == 1 ifTrue:[subm := aPossibleReceiver perform:sel with:(argument ? menuPanel)]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6447
            ifFalse:[                 subm := aPossibleReceiver perform:sel with:argument with:menuPanel]]
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6448
        ].
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6449
        subm notNil ifTrue:[^ subm].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6450
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  6451
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6452
    ^ subm
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6453
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  6454
    "Modified: / 30.10.2001 / 13:28:25 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6455
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  6456
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6457
indicationValue
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6458
    "returns indication value or nil in case of no indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6459
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6460
    |numArgs sel recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6461
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6462
    indication isNil ifTrue:[^ nil].                                    "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6463
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6464
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6465
        ^ indication value == true                                      "block or model"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6466
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6467
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6468
    (numArgs := indication numArgs) == 2 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6469
        recv := menuPanel receiver.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6470
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6471
        (recv isValueModel) ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6472
            (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6473
                sel := indication copyFrom:1 to:(indication indexOf:$:).
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6474
                sel := sel asSymbol.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6475
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6476
                Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6477
                    ex parameter selector == sel ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6478
                        ex reject
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6479
                    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6480
                ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6481
                    sel := recv perform:sel with:argument
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6482
                ]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6483
            ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  6484
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6485
        ^ sel value == true
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6486
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6487
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6488
    numArgs ~~ 0 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6489
        sel := (indication copyWithoutLast:1) asSymbol
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6490
    ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6491
        sel := indication
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6492
    ].    
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6493
    sel := self aspectAt:sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6494
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6495
    sel isValueModel ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6496
        indication := sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6497
        indication addDependent:self.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6498
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6499
    ^ sel value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6500
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6501
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6502
indicationValue:aValue
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6503
    "set the indication value
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6504
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6505
    |numArgs recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6506
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6507
    indication isNil ifTrue:[^ self].                                   "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6508
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6509
    indication isSymbol ifFalse:[                                       
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6510
        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
  6511
      ^ self
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6512
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6513
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6514
    (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
  6515
        ^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6516
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6517
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6518
    recv := menuPanel receiver.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6519
    recv isValueModel ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6520
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  6521
    recv isNil ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6522
        recv := menuPanel application.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6523
        recv isNil ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6524
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6525
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6526
    Object messageNotUnderstoodSignal handle:[:ex| 
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6527
        (ex parameter selector ~~ indication) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6528
            ex reject
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6529
        ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  6530
        ('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
  6531
    ] do:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6532
        numArgs == 1 ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6533
            recv perform:indication with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6534
        ] ifFalse:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6535
            recv perform:indication with:(argument ? self) with:aValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6536
        ]
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6537
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6538
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6539
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6540
indicatorForm
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6541
    "returns indication form or nil
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6542
    "
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6543
    |val|
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6544
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6545
    indication isNil ifTrue:[^ nil].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6546
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6547
    val := self indicationValue.
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6548
    self enabled ifFalse:[
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6549
        ^ val == true 
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6550
            ifTrue:[menuPanel iconIndicationDisabledOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6551
            ifFalse:[menuPanel iconIndicationDisabledOff]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6552
    ].
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6553
    ^ val == true 
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6554
        ifTrue:[menuPanel iconIndicationOn]
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  6555
        ifFalse:[menuPanel iconIndicationOff]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6556
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6557
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6558
isEntered
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6559
    "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
  6560
    "
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6561
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6562
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6563
    "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
  6564
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  6565
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  6566
separatorType
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  6567
    "returns type of separator line or nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6568
    "
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6569
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6570
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6571
    rawLabel isNil ifFalse:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6572
	^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6573
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6574
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6575
    (lbl := label value) isNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6576
	^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6577
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6578
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6579
    lbl size == 1 ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6580
	c := lbl first.
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6581
	c == $- ifTrue:[^ #singleLine].
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6582
	c == $= ifTrue:[^ #doubleLine].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6583
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6584
  ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6585
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6586
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6587
setupSubmenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6588
    |appl recv subm|
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6589
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6590
    submenuChannel notNil ifTrue:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6591
        submenuChannel isSymbol ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6592
            subm := submenuChannel
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6593
        ] ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6594
            appl := menuPanel application.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6595
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6596
            (subm := self findSubMenuIn:appl) isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6597
                (recv := menuPanel receiver) ~~ appl ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6598
                    subm := self findSubMenuIn:recv
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6599
                ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6600
            ]
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6601
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6602
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6603
        (subm := subm value) isArray ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6604
            subm := Menu new fromLiteralArrayEncoding:subm.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6605
            "/ cg: linked menus also may contain translations ...
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6606
            subm notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6607
                appl notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6608
                    subm findGuiResourcesIn:appl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6609
                ]                
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6610
            ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6611
        ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6612
        self submenu:subm.
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6613
    ].
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6614
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6615
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6616
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  6617
    "Modified: / 19.5.1998 / 19:36:56 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6618
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6619
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6620
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6621
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6622
canChangeVisibility
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6623
    "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
  6624
     otherwise there is a change notification raised if the model changed
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6625
    "
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6626
    ^ isVisible isSymbol
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6627
"/  ^ isVisible notNil and:[isVisible ~~ true]
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6628
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  6629
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6630
canSelect
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6631
    "returns true if item is selectable; no separator, visible and enabled.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6632
     in case of a choice (RadioButton) i have to check for the choiceValue
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6633
    "
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6634
    (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
  6635
        (choice isNil or:[choice value ~= choiceValue]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6636
            ^ true
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6637
        ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6638
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  6639
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6640
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6641
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6642
containsPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6643
    "returns true if aPoint is contained in my layout
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6644
    "
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6645
    (self isVisible and:[layout notNil]) ifTrue:[
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6646
        ^ layout containsPoint:aPoint
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6647
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6648
    ^ false
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6649
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6650
    "Created: / 13.11.2001 / 13:55:31 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6651
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  6652
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6653
containsPointX:x y:y
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6654
    "returns true if point is contained in my layout
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6655
    "
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6656
    (self isVisible and:[layout notNil]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6657
        ^ layout containsPointX:x y:y
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  6658
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  6659
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6660
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6661
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6662
hasIndication
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6663
    "returns true if on/off indication exists
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6664
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6665
    ^ indication notNil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6666
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6667
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6668
hasSubmenu
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6669
    "returns true if the item is configured as an subMenu entry
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6670
    "
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  6671
    ^ subMenu notNil or:[submenuChannel notNil]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6672
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6673
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6674
isEnabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6675
    "returns enabled state
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6676
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6677
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6678
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6679
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6680
isLabeledItem
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6681
    "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
  6682
    "
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6683
    ^ rawLabel notNil and:[isButton not]
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6684
!
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  6685
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6686
isSeparator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6687
    "returns true if item is a separator
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6688
    "
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6689
    ^ rawLabel isNil
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6690
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6691
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6692
isVisible
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6693
    "returns the visibility state
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6694
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6695
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6696
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6697
    isVisible isSymbol ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6698
        state := self aspectAt:isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6700
        state isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6701
            isVisible := state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6702
            isVisible addDependent:self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6703
            state := isVisible.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6704
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6705
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6706
        state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6707
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6708
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6709
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6710
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6711
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6713
isVisible:something
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6714
    "change the state; if the state changed, a redraw is performed
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6715
    "
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6716
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6717
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6718
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6719
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6720
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6721
        oldState := isVisible value.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6722
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6723
            isVisible removeDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6724
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6725
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6726
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6727
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6728
    isVisible isNil ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6729
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6730
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6731
        isVisible isValueModel ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6732
            isVisible addDependent:self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6733
        ] ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6734
            isVisible isSymbol ifTrue:[^ self]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6735
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6736
        menuPanel shown ifFalse:[^ self].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6737
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6738
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6739
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6740
    newState ~~ oldState ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6741
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6742
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6743
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  6744
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6745
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6746
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6747
shortcutKeyAsString
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6748
    "converts shortcutKey to a text object
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6749
    "
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6750
    |nm prefix|
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6751
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6752
    shortcutKey isNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6753
        ^ nil
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6754
    ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6755
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6756
    shortcutKey isCharacter ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6757
        nm := shortcutKey asString
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6758
    ] ifFalse:[
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6759
        "/ this is somewhat complicated: we have the symbolic key at hand,
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6760
        "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6761
        "/ Ask the devices keyboardMap for the backtranslation.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6762
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6763
        nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6764
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6765
        "/ some modifier-key combination ?
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6766
        "/
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6767
        (nm startsWith:#Cmd) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6768
            prefix := #Cmd.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6769
        ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6770
            prefix := #Alt.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6771
        ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6772
            prefix := #Meta.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6773
        ] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6774
            prefix := #Ctrl.
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6775
        ]]]].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6776
        prefix notNil ifTrue:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6777
            nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6778
        ] ifFalse:[
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6779
            nm := nm asString
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  6780
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6781
    ].
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6782
    ^ nm
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6783
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6784
    "Modified: / 17.7.1998 / 11:56:40 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6785
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6786
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6787
shortcutKeyPrefixFor:aModifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6788
    "returns prefix assigned to a modifier
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6789
    "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6790
    |m|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6791
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6792
    m := menuPanel device modifierKeyTopFor:aModifier.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6793
    m notNil ifTrue:[
1117
3181b8002e05 background color setting
Claus Gittinger <cg@exept.de>
parents: 1110
diff changeset
  6794
	^ m , '-'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6795
    ].
987
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6796
    ^ aModifier , '-'.
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6797
541dff179cc2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  6798
    "Modified: / 17.7.1998 / 11:56:46 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6799
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6800
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6801
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6802
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6803
isSelected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6804
    "returns true if item is selected
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6805
    "
1998
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  6806
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  6807
    ^ menuPanel notNil and:[menuPanel selection == self]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6808
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6809
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6810
selected:isSelected
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6811
    "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
  6812
     submenu and perform a redraw
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6813
    "
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6814
    menuPanel isNil ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6815
        ^ self hideSubmenu
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6816
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6817
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6818
    isSelected ifFalse:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6819
        self invalidate.
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  6820
        self hideSubmenu.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6821
    ] ifTrue:[
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6822
        menuPanel realized ifTrue:[
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6823
            (indication isNil or:[isButton not]) ifTrue:[
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6824
                self invalidate
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6825
            ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6826
1788
e1f32720fbb4 donot automatically open the submenu of a popup menu
ca
parents: 1787
diff changeset
  6827
            (menuPanel isPopUpView not or:[menuPanel openMenuOnSelect]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6828
                (subMenu := self setupSubmenu) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6829
                    self openSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6830
                ]
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6831
            ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6832
        ]
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6833
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6834
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6835
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6836
!MenuPanel::Scrolling class methodsFor:'default icons'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6837
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6838
icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6839
    "This resource specification was automatically generated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6840
     by the ImageEditor of ST/X."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6841
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6842
    "Do not manually edit this!! If it is corrupted,
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6843
     the ImageEditor may not be able to read the specification."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6844
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6845
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6846
     self icon inspect
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6847
     ImageEditor openOnClass:self andSelector:#icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6848
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6849
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6850
    <resource: #image>
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6851
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6852
    ^Icon
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6853
        constantNamed:#'MenuPanel::Scrolling class icon'
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6854
        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
  6855
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6856
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6857
!MenuPanel::Scrolling class methodsFor:'instance creation'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6858
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6859
new
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6860
    ^ self basicNew initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6861
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6862
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6863
!MenuPanel::Scrolling methodsFor:'accessing'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6864
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6865
activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6866
    "returns the active menu the scrolling is activated on; nil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6867
     is returned if scrolling is deactivated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6868
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6869
    ^ activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6870
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6871
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6872
direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6873
    "returns the scroll-direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6874
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6875
    ^ direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6876
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6877
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6878
iconAt:aDirection on:aMenu
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6879
    |icon device index|
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6880
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6881
    device := aMenu device.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6882
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6883
    aDirection == #PREV ifTrue:[
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6884
        aMenu verticalLayout ifTrue:[index := 3]    "/ 3 - 1 * 90  180
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6885
                            ifFalse:[index := 2]    "/ 2 - 1 * 90  90   
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6886
    ] ifFalse:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6887
        aMenu verticalLayout ifTrue:[index := 1]    "/ 1 - 1 * 90  0
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6888
                            ifFalse:[index := 4]    "/ 4 - 1 * 90  270
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6889
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6890
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6891
    icon := icons at:index.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6892
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6893
    (icon isNil or:[icon device ~~ device]) ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6894
        icon := self class icon.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6895
        index > 1 ifTrue:[ icon := icon rotated:(index - 1 * 90) ]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6896
                 ifFalse:[ icon := icon copy ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6897
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6898
        icon := icon onDevice:device.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6899
        icon clearMaskedPixels.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6900
        icons at:index put:icon
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6901
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6902
    ^ icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6903
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6904
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6905
!MenuPanel::Scrolling methodsFor:'initialization'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6906
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6907
initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6908
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6909
    semaLock := RecursionLock new.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  6910
    icons    := Array new:4.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6911
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6912
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6913
!MenuPanel::Scrolling methodsFor:'queries'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6914
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6915
isActive
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6916
    "returns true if scrolling is activated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6917
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6918
    ^ activeMenu notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6919
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6920
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6921
!MenuPanel::Scrolling methodsFor:'user operations'!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6922
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6923
startIfRequiredAt:aDirection on:aMenu
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6924
    "start scrolling; returns true if scrolling is activated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6925
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6926
    |bounds index|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6927
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6928
    semaLock critical:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6929
        self stop.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6930
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6931
        (     aDirection notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6932
         and:[aMenu notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6933
         and:[(bounds := aMenu scrollerBoundsAt:aDirection) notNil]]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6934
        ) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6935
            activeMenu := aMenu.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6936
            direction  := aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6937
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6938
            index := aMenu indexOfItemAtScroller:aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6939
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6940
            index ~~ 0 ifTrue:[
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6941
                scrollTask := 
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6942
                    [ 
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6943
                        |item step|
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6944
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6945
                        [
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6946
                            step := (aDirection == #PREV) ifTrue:[-1] ifFalse:[1].
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6947
                            ( aMenu shown and:[(item := aMenu itemAt:index) notNil] ) ifTrue:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6948
                                aMenu makeItemVisible:item.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6949
                                index := index + step.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6950
                            ].
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6951
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6952
                            Delay waitForSeconds:(ButtonController defaultInitialDelay).
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6953
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6954
                            [ aMenu shown and:[(item := aMenu itemAt:index) notNil] ] whileTrue:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6955
                                aMenu makeItemVisible:item.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6956
                                Delay waitForSeconds:(ButtonController defaultRepeatDelay).
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6957
                                index := index + step.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6958
                            ].
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6959
                            item := nil.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6960
                        ] valueNowOrOnUnwindDo:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6961
                            scrollTask := nil.
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6962
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6963
                            item notNil ifTrue:[
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6964
                                "/ process was killed
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6965
                                aMenu invalidate:bounds
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6966
                            ]
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6967
                        ]
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6968
                    ] forkAt:8.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6969
            ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6970
        ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6971
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6972
    ^ bounds notNil
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  6973
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  6974
    "Created: ca"
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  6975
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  6976
    "Modified: / 13.11.2001 / 20:15:52 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6977
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6978
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6979
stop
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6980
    "stop scrolling; returns true if the scrolling was activated otherwise false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6981
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6982
    |task resp|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6983
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6984
    activeMenu isNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6985
        ^ false
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6986
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6987
    semaLock critical:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6988
        resp := activeMenu notNil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6989
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6990
        (task := scrollTask) notNil ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6991
            scrollTask := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6992
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6993
            Error handle:[:ex|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6994
            ] do:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6995
                task terminateWithAllSubprocesses.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6996
                task waitUntilTerminated.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6997
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6998
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6999
        activeMenu := direction := nil.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7000
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7001
    ^ resp
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7002
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7003
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7004
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7005
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7006
version
2062
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  7007
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.292 2001-12-11 11:53:42 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7008
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7009
MenuPanel initialize!