MenuPanel.st
author Claus Gittinger <cg@exept.de>
Mon, 19 May 2008 15:10:25 +0200
changeset 3402 5941cc1ff429
parent 3394 90e7bc4402b5
child 3403 e7e2d3ba54b9
permissions -rw-r--r--
flybyhelp - give menuPanel achance to provide a text (for colorMenu and fontMen)
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
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
     3
	      All Rights Reserved
2005
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
"
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
    13
2182
59a770bbb95a changed superclass to View (to inherit model)
Claus Gittinger <cg@exept.de>
parents: 2171
diff changeset
    14
View subclass:#MenuPanel
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    15
	instanceVariableNames:'adornment shadowView mapTime mustRearrange superMenu
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    16
		shortKeyInset selection items groupSizes receiver enabled
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    17
		lastActiveMenu enteredItem prevFocusView previousPointerGrab
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    18
		previousKeyboardGrab relativeGrabOrigin hasImplicitGrap
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    19
		scrollActivity rightArrowShadow rightArrow fgColor verticalLayout
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    20
		showSeparatingLines showGroupDivider implicitGrabView
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    21
		lastPointerView openDelayedMenuBlock preferredWidth application
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    22
		originator centerItems hideOnRelease defaultHideOnRelease
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    23
		buttonInsetX buttonInsetY itemSpace activeBackgroundColor
3328
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
    24
		stringOffsetX doAccessCharacterTranslation'
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    25
	classVariableNames:'InitialSelectionQuerySignal Images LigthenedImages
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    26
		DefaultForegroundColor DefaultBackgroundColor IconIndicationOn
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    27
		IconIndicationOff IconRadioOn IconRadioOff
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    28
		IconDisabledIndicationOn IconDisabledIndicationOff
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    29
		IconDisabledRadioOn IconDisabledRadioOff'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    30
	poolDictionaries:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    31
	category:'Views-Menus'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    32
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    33
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    34
Object subclass:#Item
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    35
	instanceVariableNames:'menuItem layout menuPanel subMenu displayLabel displayLabelExtent
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    36
		disabledDisplayLabel enableChannel label activeHelpText
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    37
		flyByHelpText isVisible indication choice accessCharacter'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    38
	classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    39
		VerticalButtonInset LabelRightOffset VerticalPopUpInset'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    40
	poolDictionaries:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    41
	privateIn:MenuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    42
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    43
2692
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
    44
Object subclass:#Adornment
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    45
	instanceVariableNames:'indication accessCharacterPosition shortcutKey argument argument2
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    46
		choice choiceValue'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    47
	classVariableNames:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    48
	poolDictionaries:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    49
	privateIn:MenuPanel::Item
2692
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
    50
!
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
    51
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
    52
Object subclass:#ScrollActivity
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    53
	instanceVariableNames:'semaLock activeMenu scrollTask direction icons'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    54
	classVariableNames:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    55
	poolDictionaries:''
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    56
	privateIn:MenuPanel
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    57
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
    58
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    59
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    60
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    61
copyright
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    62
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    63
 COPYRIGHT (c) 1997 by eXept Software AG
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
    64
	      All Rights Reserved
2005
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    65
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    66
 This software is furnished under a license and may be used
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    67
 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
    68
 inclusion of the above copyright notice.   This software may not
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    69
 be provided or otherwise made available to, or used by, any
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    70
 other person.  No title to or ownership of the software is
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    71
 hereby transferred.
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    72
"
a85fab2cc6f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    73
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    74
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    75
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    76
documentation
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    77
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    78
    a menu panel used for both pull-down-menus and pop-up-menus.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    79
2170
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
    80
    this will eventually replace most of the MenuView and PopUpMenu stuff.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    81
    (and hopefully be ST-80 compatible ...)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    82
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    83
    To create a menu, there exists a MenuEditor which will generate
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    84
    a menu specification.
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    85
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
    86
2061
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    87
    Notice:
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    88
        This is going to replace the obsolete MenuView.
faf64f2cd28e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
    89
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    90
    [author:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    91
        Claus Atzkern
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    92
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
    93
    [see also:]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    94
        Menu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    95
        MenuItem
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
    96
        MenuEditor
2170
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
    97
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
    98
    cg: this code is so ugly - needs a complete rewrite...
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
    99
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   100
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   101
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   102
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   103
examples
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   104
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   105
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   106
    start as PullDownMenu
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   107
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   108
    |top subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   109
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   110
    top := StandardSystemView new.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   111
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   112
    mview := MenuPanel in:top.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   113
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   114
    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   115
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   116
    mview verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   117
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   118
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   119
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   120
    mview shortcutKeyAt:2 put:#Cut.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   121
    mview accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   122
    mview accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   123
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   124
    mview enabledAt:5 put:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   125
    mview groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   126
    s1 := MenuPanel labels:labels.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   127
    s1 accessCharacterPositionAt:1 put:1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   128
    s1 accessCharacterPositionAt:2 put:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   129
    s1 groupSizes:#( 2 2 ).
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   130
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   131
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   132
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   133
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   134
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   135
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   136
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   137
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   138
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   139
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   140
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   141
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   142
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   143
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   144
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   145
    mview subMenuAt:2 put:(MenuPanel labels:labels).
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   146
    top extent:(mview preferredExtent).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   147
    top open.
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   148
										[exEnd]
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   149
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   150
										[exBegin]
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   151
    |top menu view item|
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   152
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   153
    top  := StandardSystemView extent:240@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   154
    menu := MenuPanel in:top.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   155
    menu labels:#( 'foo' 'Application' 'Clock' ).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   156
    menu verticalLayout:false.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   157
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   158
    menu subMenuAt:1 put:(MenuPanel labels:#( 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   159
    menu subMenuAt:2 put:(MenuPanel labels:#( 'foo' 'bar' 'baz' )).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   160
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   161
    view := ClockView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   162
    view preferredExtent:100@100.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   163
    item := menu itemAt:3.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   164
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   165
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   166
    view := SimpleView new.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   167
    view client:(CodingExamples_GUI::GUIDemoExtendedComboBox new).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   168
    view preferredExtent:(400@50).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   169
    item := menu itemAt:2.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   170
    item submenu:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   171
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   172
    menu origin:0@0 corner:1.0@30.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
   173
    top open.
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   174
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   175
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   176
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   177
    start as PopUpMenu
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   178
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   179
    |subView mview desc s1 s2 s3 img lbs labels|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   180
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   181
    mview := MenuPanel new.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   182
    labels := #( 'foo' 'bar' 'baz' ).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   183
    mview level:2.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   184
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   185
    img := Image fromFile:'bitmaps/SBrowser.xbm'.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   186
    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   187
    mview labels:lbs.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   188
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   189
    s1 := MenuPanel labels:labels.
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   190
    s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   191
    s3 := MenuPanel labels:lbs.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   192
    s1 subMenuAt:2 put:s2.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   193
    s1 subMenuAt:3 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   194
    s2 subMenuAt:3 put:s3.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   195
    s3 subMenuAt:3 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   196
    s3 shortcutKeyAt:3 put:$q.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   197
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   198
    mview subMenuAt:1 put:s1.
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   199
    mview subMenuAt:4 put:(MenuPanel labels:lbs).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   200
    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   201
    s1 shortcutKeyAt:1 put:#Copy.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   202
    s1 shortcutKeyAt:3 put:#Paste.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   203
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   204
    mview subMenuAt:2 put:(MenuPanel labels:labels).
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   205
    mview startUp
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   206
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   207
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   208
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   209
    start from menu spec
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   210
										[exBegin]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   211
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   212
436
c03d6faa41a6 process events befor accept
ca
parents: 434
diff changeset
   213
    menu := MenuPanel menu:
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   214
	#(#Menu #( #(#MenuItem 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   215
		    #label: 'File' 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   216
		    #submenu:
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   217
		      #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   218
				 (#MenuItem 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   219
				    #label: 'edit' 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   220
				    #submenu:
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   221
				      #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   222
						 #(#MenuItem #label: 'close' #value:#close)     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   223
					       )
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   224
					       nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   225
					       nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   226
				       )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   227
				  )
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   228
				 #(#MenuItem #label: 'help' #value:#help )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   229
			       )
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   230
			       nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   231
			       nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   232
		       )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   233
		 ) 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   234
		#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   235
		#(#MenuItem #label: 'Bar' 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   236
			    #submenu:
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   237
			       #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   238
					  #(#MenuItem #label: 'bar 2' #value:#bar2 )     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   239
					)
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   240
					nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   241
					nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   242
				)     
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   243
		 ) 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   244
	      ) 
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   245
	      #( 2 )
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   246
	      nil
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   247
	 ) decodeAsLiteralArray.  
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   248
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   249
    menu verticalLayout:false.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   250
    Transcript showCR:(menu startUp).
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   251
										[exEnd]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   252
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   253
"
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   254
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   255
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   256
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   257
!MenuPanel class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   258
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   259
fromSpec:aSpec
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   260
    ^ self fromSpec:aSpec receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   261
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   262
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   263
fromSpec:aSpec receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   264
    |menu|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   265
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   266
    aSpec notNil ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   267
	menu := Menu new.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   268
	menu receiver:aReceiver.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   269
	menu fromLiteralArrayEncoding:aSpec.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   270
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   271
  ^ self menu:menu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   272
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   273
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   274
labels:labels
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   275
    ^ self labels:labels nameKeys:nil receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   276
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   277
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   278
labels:labels nameKeys:nameKeys
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   279
    ^ self labels:labels nameKeys:nameKeys receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   280
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   281
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   282
labels:labels nameKeys:nameKeys receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   283
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   284
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   285
    mview := self menu:nil receiver:aReceiver.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   286
    mview labels:labels.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   287
    mview nameKeys:nameKeys.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   288
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   289
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   290
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   291
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   292
labels:labels receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   293
    ^ self labels:labels nameKeys:nil receiver:aReceiver
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   294
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
   295
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   296
menu:aMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   297
    ^ self menu:aMenu receiver:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   298
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   299
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   300
menu:aMenu receiver:aReceiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   301
    |mview|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   302
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   303
    mview := self new.
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   304
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   305
    (aMenu notNil and:[aMenu receiver isNil]) ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   306
	"/ no receiver specified in the menu; thus set the receiver immediately
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   307
	mview receiver:aReceiver
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   308
    ].
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   309
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   310
    mview menu:aMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   311
1955
dea13bc1f1e0 bug fix when setting the receiver
ca
parents: 1929
diff changeset
   312
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   313
"/ a menu itself may contain a receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   314
"/ thus we do not overwrite the receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   315
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   316
    aReceiver notNil ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
   317
	mview receiver:aReceiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   318
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   319
  ^ mview
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   320
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   321
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   322
!MenuPanel class methodsFor:'class initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   323
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   324
initialize
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   325
    InitialSelectionQuerySignal isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   326
        InitialSelectionQuerySignal := QuerySignal new.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   327
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   328
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   329
    "
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   330
     self initialize
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   331
    "
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   332
660
d1670dfe5445 Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents: 658
diff changeset
   333
    "Modified: / 15.1.1998 / 23:08:31 / stefan"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   334
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   335
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   336
preSnapshot
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   337
    "remove all resources"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   338
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   339
    Images := nil.
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   340
    LigthenedImages := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   341
! !
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   342
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   343
!MenuPanel class methodsFor:'default icons'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   344
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   345
delayedMenuIndicator
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   346
    "This resource specification was automatically generated
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   347
     by the ImageEditor of ST/X."
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   348
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   349
    "Do not manually edit this!! If it is corrupted,
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   350
     the ImageEditor may not be able to read the specification."
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   351
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   352
    "
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   353
     self delayedMenuIndicator inspect
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   354
     ImageEditor openOnClass:self andSelector:#delayedMenuIndicator
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   355
     Icon flushCachedIcons
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   356
    "
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   357
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   358
    <resource: #image>
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   359
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   360
    ^Icon
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   361
        constantNamed:#'MenuPanel class delayedMenuIndicator'
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   362
        ifAbsentPut:[(Depth1Image new) width: 7; height: 6; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@HCB') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 6; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@J+V[C P') ; yourself); yourself]
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   363
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   364
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   365
iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   366
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   367
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   368
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   369
    "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
   370
     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
   371
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   372
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   373
     self iconIndicationDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   374
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   375
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   376
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   377
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   378
2755
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   379
    IconDisabledIndicationOff isNil ifTrue:[
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   380
        IconDisabledIndicationOff := Icon
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   381
            constantNamed:#'MenuPanel iconIndicationDisabledOff'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   382
            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]
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   383
    ].
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   384
    ^ IconDisabledIndicationOff
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   385
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   386
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   387
iconIndicationDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   388
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   389
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   390
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   391
    "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
   392
     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
   393
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   394
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   395
     self iconIndicationDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   396
     ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOn
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
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   399
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   400
2755
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   401
    IconDisabledIndicationOn isNil ifTrue:[
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   402
        IconDisabledIndicationOn := Icon
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   403
            constantNamed:#'MenuPanel iconIndicationDisabledOn'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   404
            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]
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   405
    ].
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   406
    ^ IconDisabledIndicationOn
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   407
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   408
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   409
iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   410
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   411
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   414
     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
   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
     self iconIndicationOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   418
     ImageEditor openOnClass:self andSelector:#iconIndicationOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   419
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   420
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   421
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   422
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   423
    IconIndicationOff isNil ifTrue:[
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   424
        IconIndicationOff := Icon
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   425
            constantNamed:#'MenuPanel iconIndicationOff'
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   426
            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]
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   427
    ].
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   428
    ^ IconIndicationOff
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   429
!
1726
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
iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   432
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   433
     by the ImageEditor of ST/X."
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
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   436
     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
   437
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   438
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   439
     self iconIndicationOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   440
     ImageEditor openOnClass:self andSelector:#iconIndicationOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   441
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   442
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   443
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   444
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   445
    IconIndicationOn isNil ifTrue:[
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   446
        IconIndicationOn := Icon
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   447
                constantNamed:#'MenuPanel iconIndicationOn'
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   448
                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]
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   449
    ].
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   450
    ^ IconIndicationOn
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   451
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   452
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   453
iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   454
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   455
     by the ImageEditor of ST/X."
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
    "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
   458
     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
   459
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   460
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   461
     self iconRadioGroupDisabledOff inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   462
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOff
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   463
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   464
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   465
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   466
2755
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   467
    IconDisabledRadioOff isNil ifTrue:[
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   468
        IconDisabledRadioOff := Icon
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   469
            constantNamed:#'MenuPanel iconRadioGroupDisabledOff'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   470
            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]
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   471
    ].
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   472
    ^ IconDisabledRadioOff
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   473
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   474
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   475
iconRadioGroupDisabledOn
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   476
    "This resource specification was automatically generated
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   477
     by the ImageEditor of ST/X."
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   478
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   479
    "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
   480
     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
   481
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   482
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   483
     self iconRadioGroupDisabledOn inspect
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   484
     ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
   485
     Icon flushCachedIcons
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   486
    "
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   487
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   488
    <resource: #image>
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   489
2755
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   490
    IconDisabledRadioOn isNil ifTrue:[
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   491
        IconDisabledRadioOn := Icon
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   492
            constantNamed:#'MenuPanel class iconRadioGroupDisabledOn'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   493
            ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DYUZ(AIUU+AIUUVLRUUU#D%UUX1IUUVLRUUU#AYUU#@Z%U(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]
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   494
    ].
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   495
    ^ IconDisabledRadioOn
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   496
!
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   497
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   498
iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   499
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   500
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   501
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   502
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   503
     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
   504
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   505
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   506
     self iconRadioGroupOff inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   507
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   508
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   509
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   510
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   511
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   512
    IconRadioOff isNil ifTrue:[
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   513
        IconRadioOff := Icon
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   514
            constantNamed:#'MenuPanel iconRadioGroupOff'
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   515
            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]
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   516
    ].
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   517
    ^ IconRadioOff
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   518
!
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   519
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   520
iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   521
    "This resource specification was automatically generated
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   522
     by the ImageEditor of ST/X."
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   523
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   524
    "Do not manually edit this!! If it is corrupted,
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   525
     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
   526
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   527
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   528
     self iconRadioGroupOn inspect
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   529
     ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   530
    "
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   531
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   532
    <resource: #image>
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   533
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   534
    IconRadioOn isNil ifTrue:[
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   535
        IconRadioOn := Icon
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   536
            constantNamed:#'MenuPanel iconRadioGroupOn'
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   537
            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]
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   538
    ].
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   539
    ^ IconRadioOn
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   540
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   541
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   542
menuIndicator
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   543
    "This resource specification was automatically generated
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   544
     by the ImageEditor of ST/X."
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   545
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   546
    "Do not manually edit this!! If it is corrupted,
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   547
     the ImageEditor may not be able to read the specification."
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   548
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   549
    "
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   550
     self menuIndicator inspect
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   551
     ImageEditor openOnClass:self andSelector:#menuIndicator
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   552
     Icon flushCachedIcons
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   553
    "
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   554
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   555
    <resource: #image>
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   556
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   557
    ^Icon
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   558
        constantNamed:#'MenuPanel::Item class menuIndicator'
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   559
        ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@B@0 @a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?''08D@@a') ; yourself); yourself]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   560
! !
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
   561
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
   562
!MenuPanel class methodsFor:'defaults'!
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   563
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   564
defaultBackgroundColor
2609
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
   565
    DefaultBackgroundColor notNil ifTrue:[^ DefaultBackgroundColor].
2372
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   566
    ^ StyleSheet at:#'pullDownMenu.backgroundColor' default:DefaultViewBackgroundColor.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   567
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   568
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   569
defaultLevel
2372
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   570
    ^ StyleSheet at:#'pullDownMenu.level' default:1
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   571
"
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   572
self defaultLevel
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   573
"
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   574
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   575
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   576
delayedMenuIndicatorOffset
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   577
    "returns an additional offset between the label and the
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   578
     delayedMenu indication (i.e. the down-arrow icon)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   579
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   580
    ^ 1 "2"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   581
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   582
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   583
maxShortCutSearchLevel
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   584
    "1 means: only search in top items.
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   585
     2 means: search one level of menus.
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   586
     used to be 10"
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   587
3384
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   588
    MaxShortCutSearchLevel isNil ifTrue:[MaxShortCutSearchLevel := 2.].
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   589
    ^ MaxShortCutSearchLevel
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   590
!
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   591
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   592
maxShortCutSearchLevel: anInteger
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   593
    "1 means: only search in top items.
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   594
     2 means: search one level of menus."
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   595
f42018cf8f9f class variable for MaxShortCutSearchLevel
fm
parents: 3383
diff changeset
   596
    MaxShortCutSearchLevel := anInteger
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   597
!
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
   598
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   599
menuIndicatorOffset
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   600
    "returns an additional offset between the label and the
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   601
     delayedMenu indication (i.e. the down-arrow icon)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   602
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   603
    ^ 1 "2"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   604
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
   605
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   606
mnemonicIdentifier
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   607
    "returns the identifier each mnemonic starts with;
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   608
     ex:
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   609
        &File   mnemonic := Cmdf
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   610
        F&ile   mnemonic := Cmdi
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   611
        ....."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   612
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   613
    ^ 'Cmd'
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   614
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
   615
450
ac72eb2ed895 initialize fix
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   616
updateStyleCache
2777
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
   617
    "extract values from the styleSheet and cache them in class variables"
657
a8246e896fa3 class initialize routine completed
tz
parents: 653
diff changeset
   618
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   619
    <resource: #style (
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   620
        #'popup.borderWidth' #'popup.level' 
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   621
        #'selection.disabledForegroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   622
        #'pullDownMenu.foregroundColor' #'pullDownMenu.backgroundColor' #'pullDownMenu.level'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   623
        #'menu.itemHorizontalSpace' #'menu.buttonItemHorizontalSpace' #'menu.buttonItemSpace'
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   624
        #'menu.itemSpace' #'menu.buttonItemVerticalSpace'
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   625
        #'menu.buttonActiveLevel' #'menu.buttonPassiveLevel' #'menu.buttonEnteredLevel'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   626
        #'menu.hilightLevel' #'menu.enteredLevel'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   627
        #'menu.groupDividerSize' #'menu.itemMargin'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   628
        #'menu.disabledEtchedForegroundColor' #'menu.hilightForegroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   629
        #'menu.enteredBackgroundColor' #'menu.enteredForegroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   630
        #'menu.disabledForegroundColor' #'menu.buttonEnteredBackgroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   631
        #'menu.selectionFollowsMouse'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   632
        #'button.disabledEtchedForegroundColor' #'button.disabledForegroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   633
        #'button.activeBackgroundColor' #'button.backgroundColor' #'button.lightColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   634
        #'button.enteredBackgroundColor' #'button.halfLightColor' #'button.halfShadowColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   635
        #'button.activeLevel' #'button.passiveLevel' #'button.edgeStyle'
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   636
        #'menu.iconIndicationOn' #'menu.iconIndicationOff'
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   637
        #'menu.iconIndicationOn.bitmapFile' #'menu.iconIndication.bitmapOffFile'
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   638
        #'menu.iconRadioOn' #'menu.iconRadioOff'
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   639
        #'menu.iconRadioOn.bitmapFile' #'menu.iconRadioOff.bitmapFile'
2755
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   640
        #'menu.iconDisabledIndicationOn' #'menu.iconDisabledIndicationOff'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   641
        #'menu.iconDisabledIndicationOn.bitmapFile' #'menu.iconDisabledIndication.bitmapOffFile'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   642
        #'menu.iconDisabledRadioOn' #'menu.iconDisabledRadioOff'
f8035120da51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   643
        #'menu.iconDisabledRadioOn.bitmapFile' #'menu.iconDisabledRadioOff.bitmapFile'
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   644
    )>
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   645
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   646
    |styleSheet style var foregroundColor backgroundColor buttonPassiveBackgroundColor
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   647
    buttonActiveLevel buttonPassiveLevel buttonEnteredLevel getBitmapOrFile|
2607
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   648
2611
9814b5547d63 bugfix: backgroundColor after loading new style
ca
parents: 2610
diff changeset
   649
    "clear DefaultBackgroundColor caused by accessing the #defaultBackgroundColor
9814b5547d63 bugfix: backgroundColor after loading new style
ca
parents: 2610
diff changeset
   650
     which returns the default cashed DefaultBackgroundColor
9814b5547d63 bugfix: backgroundColor after loading new style
ca
parents: 2610
diff changeset
   651
    "
9814b5547d63 bugfix: backgroundColor after loading new style
ca
parents: 2610
diff changeset
   652
    DefaultBackgroundColor := nil.
9814b5547d63 bugfix: backgroundColor after loading new style
ca
parents: 2610
diff changeset
   653
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   654
    MenuView            updateStyleCache.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   655
    SelectionInListView updateStyleCache.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   656
2372
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   657
    styleSheet  := StyleSheet.
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   658
    style       := styleSheet name.
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
   659
2607
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   660
    DefaultFont     := MenuView defaultFont.
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   661
    foregroundColor := DefaultForegroundColor := styleSheet colorAt:#'pullDownMenu.foregroundColor' 
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   662
                                                            default:[styleSheet 
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   663
                                                                        colorAt:#'menu.foregroundColor'
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   664
                                                                        default:Color black].
2609
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
   665
    backgroundColor := DefaultBackgroundColor := self defaultBackgroundColor.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   666
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   667
    var := styleSheet colorAt:#'menu.hilightBackgroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   668
    var isNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   669
        style == #motif ifTrue:[ var := backgroundColor ]
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   670
                       ifFalse:[ var := styleSheet is3D ifFalse:[foregroundColor] ifTrue:[backgroundColor] ]
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   671
    ].
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   672
    styleSheet at:#'menuPanel.activeBackgroundColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   673
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   674
    var := styleSheet colorAt:#'menu.disabledEtchedForegroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   675
    var isNil ifTrue:[ var := styleSheet colorAt:#'button.disabledEtchedForegroundColor' ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   676
    styleSheet at:#'menuPanel.disabledEtchedFgColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   677
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   678
    var := styleSheet colorAt:#'menu.disabledForegroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   679
    var isNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   680
        var := styleSheet colorAt:#'selection.disabledForegroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   681
        var isNil ifTrue:[ var := styleSheet colorAt:#'button.disabledForegroundColor' default:Color darkGray ]
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   682
    ].
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   683
    styleSheet at:#'menuPanel.disabledForegroundColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   684
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   685
    var := styleSheet colorAt:#'menu.hilightForegroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   686
    var isNil ifTrue:[ var := styleSheet is3D ifTrue:[foregroundColor] ifFalse:[backgroundColor] ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   687
    styleSheet at:#'menuPanel.activeForegroundColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   688
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   689
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   690
    buttonActiveLevel := styleSheet at:#'menu.buttonActiveLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]).
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   691
    buttonActiveLevel isNil ifTrue:[ buttonActiveLevel := styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]) ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   692
    styleSheet at:#'menuPanel.buttonActiveLevel' put:buttonActiveLevel.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   693
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   694
    buttonPassiveLevel := styleSheet at:#'menu.buttonPassiveLevel'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   695
    buttonPassiveLevel isNil ifTrue:[ buttonPassiveLevel :=  styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0])].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   696
    styleSheet at:#'menuPanel.buttonPassiveLevel' put:buttonPassiveLevel.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   697
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   698
    buttonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:buttonPassiveLevel.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   699
    styleSheet at:#'menuPanel.buttonEnteredLevel' put:buttonEnteredLevel.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   700
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   701
    var := (buttonActiveLevel abs max:(buttonPassiveLevel abs)) max:(buttonEnteredLevel abs).
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   702
    styleSheet at:#'menuPanel.maxAbsoluteButtonLevel' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   703
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   704
    buttonPassiveBackgroundColor := styleSheet at:#'button.backgroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   705
    buttonPassiveBackgroundColor isNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   706
        buttonPassiveBackgroundColor := (styleSheet at:'viewBackground') ? backgroundColor
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   707
    ].
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   708
    styleSheet at:#'menuPanel.buttonPassiveBackgroundColor' put:buttonPassiveBackgroundColor.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   709
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   710
    var := styleSheet at:#'button.lightColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   711
    var isNil ifTrue:[ var := (buttonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) lightened ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   712
    styleSheet at:#'menuPanel.buttonLightColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   713
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   714
    var :=  styleSheet at:#'button.shadowColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   715
    var isNil ifTrue:[ var := (buttonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   716
    styleSheet at:#'menuPanel.buttonShadowColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   717
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   718
    var := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   719
    var isNil ifTrue:[ var := styleSheet colorAt:#'button.enteredBackgroundColor' default:buttonPassiveBackgroundColor ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   720
    styleSheet at:#'menuPanel.buttonEnteredBackgroundColor' put:var.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   721
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
   722
    Item updateStyleCache.
2607
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   723
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   724
    getBitmapOrFile := [:key :fileKey |
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   725
        |var|
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   726
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   727
        var := styleSheet at:key ifAbsent:nil.
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   728
        var isNil ifTrue:[
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   729
            var := styleSheet at:fileKey ifAbsent:nil.
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   730
            var notNil ifTrue:[
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   731
                var := Smalltalk imageFromFileNamed:var forClass:self.
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   732
            ].
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   733
        ].
2754
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   734
        var
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   735
    ].
e1099c448aa9 more xp style
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
   736
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   737
    IconIndicationOn := getBitmapOrFile value:#'menu.iconIndicationOn' value:#'menu.iconIndicationOn.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   738
    IconIndicationOff := getBitmapOrFile value:#'menu.iconIndicationOff' value:#'menu.iconIndicationOff.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   739
    IconDisabledIndicationOn := getBitmapOrFile value:#'menu.iconDisabledIndicationOn' value:#'menu.iconDisabledIndicationOn.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   740
    IconDisabledIndicationOff := getBitmapOrFile value:#'menu.iconDisabledIndicationOff' value:#'menu.iconDisabledIndicationOff.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   741
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   742
    IconRadioOn := getBitmapOrFile value:#'menu.iconRadioOn' value:#'menu.iconRadioOn.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   743
    IconRadioOff := getBitmapOrFile value:#'menu.iconRadioOff' value:#'menu.iconRadioOff.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   744
    IconDisabledRadioOn := getBitmapOrFile value:#'menu.iconDisabledRadioOn' value:#'menu.iconDisabledRadioOn.bitmapFile'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
   745
    IconDisabledRadioOff := getBitmapOrFile value:#'menu.iconDisabledRadioOff' value:#'menu.iconDisabledRadioOff.bitmapFile'.
2752
1d1788de3393 more xp style
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
   746
2607
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   747
    "
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   748
     self updateStyleCache
5eecd27af4e4 *** empty log message ***
ca
parents: 2604
diff changeset
   749
    "
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   750
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
   751
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   752
!MenuPanel class methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   753
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   754
image:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   755
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   756
Images := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   757
"
2269
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   758
    |deviceImages|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   759
1156
6fa33dc93509 fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   760
    anImage device == aDevice ifTrue:[
2269
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   761
        ^ anImage
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   762
    ].
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   763
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   764
    Images isNil ifTrue:[ Images := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   765
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   766
    (deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[
2269
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   767
        Images at:aDevice put:(deviceImages := Dictionary new)
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   768
    ].
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   769
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   770
    ^ deviceImages at:anImage ifAbsentPut:[ |image|
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   771
        image := anImage copy onDevice:aDevice.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   772
        image clearMaskedPixels.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   773
        deviceImages at:anImage put:image.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   774
        image
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
   775
    ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   776
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   777
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   778
lightenedImage:anImage onDevice:aDevice
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   779
"
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   780
LigthenedImages := nil
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   781
"
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   782
    |deviceImages image colorMap|
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   783
1853
399e2eac3b99 Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents: 1841
diff changeset
   784
    LigthenedImages isNil ifTrue:[ LigthenedImages := WeakIdentityDictionary new ].
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   785
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   786
    (deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   787
        LigthenedImages at:aDevice put:(deviceImages := Dictionary new)
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   788
    ].
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   789
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   790
    (image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   791
        ^ image
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   792
    ].
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   793
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   794
    colorMap := anImage perform:#colorMap ifNotUnderstood:nil.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   795
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   796
    colorMap notNil ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   797
        image := anImage copy lightened onDevice:aDevice.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   798
        image clearMaskedPixels.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   799
    ] ifFalse:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
   800
        image := self image:anImage onDevice:aDevice
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   801
    ].
1097
8a2f6c5ad1a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1096
diff changeset
   802
    deviceImages at:anImage put:image.
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   803
    ^ image
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   804
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
   805
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   806
!MenuPanel class methodsFor:'private'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   807
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   808
subMenu:aSubMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   809
    "create a submenu; can be redifined in derived classes"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   810
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   811
    ^ (self new) menu:aSubMenu.
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   812
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   813
    "Modified: / 8.8.1998 / 02:13:11 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   814
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   815
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
   816
!MenuPanel methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   817
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   818
accept
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   819
    "accept current selected item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   820
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
   821
    ^ self acceptItem:(self selection) inMenu:self
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   822
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   823
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
   824
accept:anItem 
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   825
    "this is the topMenu: accept item "
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   826
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   827
    |item tgState itemIdx recv panel masterGroup winGrp acceptAction focusView|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
   828
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   829
    self superMenu notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   830
        ^ self topMenu accept:anItem
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   831
    ].
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   832
    prevFocusView ~~ self ifTrue:[
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   833
        focusView := prevFocusView.
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   834
    ].
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   835
    prevFocusView := nil.
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   836
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
   837
    self openDelayed:nil.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   838
    self scrollActivity stop.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
   839
    self selection:nil.
420
ca
parents: 417
diff changeset
   840
ca
parents: 417
diff changeset
   841
    (anItem notNil and:[anItem canAccept]) ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   842
        tgState := anItem toggleIndication.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   843
        panel   := anItem menuPanel.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   844
        itemIdx := panel findFirst:[:el| el == anItem ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   845
        item    := anItem.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   846
        recv    := panel receiver.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   847
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   848
    self doUngrab:true.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   849
510
8f77b9382066 bug fix with redraw
ca
parents: 505
diff changeset
   850
    self isPopUpView ifFalse:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   851
        self do:[:el| el updateIndicators].
3143
645efaba917a bugfix: check for notNil windowGroup
ca
parents: 3142
diff changeset
   852
        (winGrp := self windowGroup) notNil ifTrue:[
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   853
            winGrp processExposeEvents.
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   854
        ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   855
    ] ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   856
        self unmap.
2712
8a5f94b10261 late expose event bug fixed
ca
parents: 2696
diff changeset
   857
        self device sync. "/ round trip - all expose events are now received
3143
645efaba917a bugfix: check for notNil windowGroup
ca
parents: 3142
diff changeset
   858
645efaba917a bugfix: check for notNil windowGroup
ca
parents: 3142
diff changeset
   859
        (winGrp := self windowGroup) notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   860
            "/ give expose event a chance to arrive
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   861
            [shown and:[realized]] whileTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   862
                winGrp processExposeEventsFor:self
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   863
            ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   864
            masterGroup := winGrp previousGroup.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   865
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   866
        "/ cg: disabled-not needed - try PopUpList with destroy...
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   867
        "/ self destroy.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   868
        masterGroup notNil ifTrue:[masterGroup processExposeEvents].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   869
    ].
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   870
3144
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   871
    acceptAction := [   
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   872
                        |winGrp|
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   873
3189
a2e61ce4a7cb focus handling
ca
parents: 3187
diff changeset
   874
                        (focusView notNil and:[(winGrp := self windowGroup) notNil]) ifTrue:[
a2e61ce4a7cb focus handling
ca
parents: 3187
diff changeset
   875
                            winGrp focusView:focusView.
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
   876
                        ].
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
   877
                        self accept:item index:itemIdx toggle:tgState receiver:recv.
3189
a2e61ce4a7cb focus handling
ca
parents: 3187
diff changeset
   878
2826
7294e112f2c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   879
                    ].
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
   880
1710
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   881
    (item notNil 
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   882
    and:[item showBusyCursorWhilePerforming
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   883
    and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]])
bb9bb814e7c4 showBusy code moved
Claus Gittinger <cg@exept.de>
parents: 1709
diff changeset
   884
    ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   885
        winGrp withWaitCursorDo:acceptAction
3144
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   886
    ] ifFalse:[
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   887
        acceptAction value
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   888
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   889
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   890
    self isPopUpView ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   891
        self menuAdornmentAt:#item put:item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   892
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
   893
    ^ item.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   894
3144
772766a2e99e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   895
    "Modified: / 08-11-2006 / 17:14:06 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   896
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   897
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   898
accept:anItem index:anIndex toggle:aState receiver:aReceiver
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   899
    "accept an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
   900
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   901
    |value argument numArgs isValueModel rec args arg2 
1697
345d3664e10c added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   902
     app master fallBack|
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   903
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   904
    anItem isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   905
        self menuAdornmentAt:#hasPerformed put:true.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   906
      ^ nil
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   907
    ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   908
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   909
    isValueModel := aReceiver isValueModel.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   910
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   911
    self menuAdornmentAt:#hasPerformed put:isValueModel.
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   912
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   913
    (value := anItem value) isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   914
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   915
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   916
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   917
    (argument := anItem argument) isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   918
        argument := aState ? anItem
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
   919
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   920
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   921
    value isSymbol ifFalse:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   922
        "/ a valueHolder or block
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   923
        (value respondsTo:#valueWithArguments:) ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   924
             ^ value
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   925
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   926
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   927
        numArgs := value perform:#numArgs ifNotUnderstood:0.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   928
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   929
        numArgs == 0 ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   930
            args := nil
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   931
        ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   932
            numArgs == 1 ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   933
                args := Array with:argument
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   934
            ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   935
                args := Array with:argument with:self
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   936
            ]
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   937
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   938
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   939
        value valueWithArguments:args.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   940
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   941
        self menuAdornmentAt:#hasPerformed put:true.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   942
        ^ anIndex
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   943
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
   944
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   945
    anItem sendToOriginator ifTrue:[
2473
6ace3a7234b0 care for nil originator
Claus Gittinger <cg@exept.de>
parents: 2471
diff changeset
   946
        rec := self originator.
6ace3a7234b0 care for nil originator
Claus Gittinger <cg@exept.de>
parents: 2471
diff changeset
   947
        rec isNil ifTrue:[
2844
e813c02733ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   948
            self error:'no originating widget (no target for message)' mayProceed:true.
2473
6ace3a7234b0 care for nil originator
Claus Gittinger <cg@exept.de>
parents: 2471
diff changeset
   949
        ].
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   950
    ] ifFalse:[
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   951
        rec := aReceiver
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   952
    ].
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   953
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   954
    rec isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   955
        ^ value
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   956
    ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   957
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   958
    isValueModel ifTrue:[
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   959
        rec value:value
465
67a0f3dd503a in case of performing a selector '0' is returned
ca
parents: 464
diff changeset
   960
    ] ifFalse:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   961
        arg2 := self.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   962
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   963
        "/ support for ST80 style applications
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   964
        "/ (expecting the message to go to the application
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   965
        "/  if not understood by the view)
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   966
        "/ These expect the controller to be passed as argument.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   967
        "/ sigh.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   968
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   969
        (rec isView
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   970
        and:[(rec respondsTo:value) not
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   971
        and:[(app := rec application) ~~ rec
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   972
        and:[app notNil]]]) ifTrue:[
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
   973
            arg2 := rec controller.       "/ the Views controller
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   974
            rec := app.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   975
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   976
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   977
        (numArgs := value numArgs) == 0 ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   978
            args := nil
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   979
        ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   980
            numArgs == 1 ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   981
                args := Array with:argument
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   982
            ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   983
                args := Array with:argument with:arg2
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   984
            ]
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   985
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   986
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   987
        fallBack := 
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   988
            [
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   989
                "/ mhmh - the receiver did not respond to that message;
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   990
                "/ if there is a master-application, try that one
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   991
                "/ (recursive)
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   992
                master := rec perform:#masterApplication ifNotUnderstood:nil.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   993
                master notNil ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   994
                    rec := master.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   995
                    rec perform:value withArguments:args ifNotUnderstood:fallBack
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   996
                ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   997
                    self 
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   998
                        error:'unimplemented (or error in) menu message: ' , value
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
   999
                        mayProceed:true
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1000
                ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1001
            ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1002
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1003
        rec perform:value withArguments:args ifNotUnderstood:fallBack.
420
ca
parents: 417
diff changeset
  1004
    ].
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  1005
    self menuAdornmentAt:#hasPerformed put:true.
1270
0ae582fd7294 send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
  1006
    ^ value
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1007
1719
ba7ebb56e6fd recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
  1008
    "Modified: / 19.2.2000 / 11:08:22 / cg"
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1009
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1010
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1011
acceptItem:anItem inMenu:aMenu
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  1012
    |tgState topMenu|
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  1013
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  1014
    topMenu := self topMenu.
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  1015
    topMenu openDelayed:nil.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1016
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  1017
    (anItem isNil or:[anItem hideMenuOnActivated]) ifTrue:[
2934
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1018
        topMenu accept:anItem
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1019
    ] ifFalse:[
2934
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1020
        anItem canAccept ifTrue:[
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1021
            tgState := anItem toggleIndication.
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1022
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1023
            self accept:anItem
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1024
                  index:(aMenu selectionIndex)
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1025
                 toggle:tgState 
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1026
               receiver:(aMenu receiver).
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1027
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1028
            aMenu do:[:el| el updateIndicators].
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1029
            anItem hideMenuOnActivated ifFalse:[
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1030
                aMenu invalidate
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1031
            ].
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  1032
        ]
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1033
    ]
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1034
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  1035
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1036
lastItemAccepted
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1037
    "returns last item selected or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1038
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1039
  ^ self topMenu menuAdornmentAt:#item
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1040
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1041
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1042
lastValueAccepted
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1043
    "returns last value accepted or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1044
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1045
    ^ self lastItemAccepted value
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1046
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1047
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1048
!MenuPanel methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1049
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1050
accessCharacterPositionAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1051
    "get the access character position for a textLabel"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1052
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1053
    ^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1054
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1055
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1056
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1057
    "get the access character position for a textLabel"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1058
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1059
    self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1060
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1061
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1062
accessCharacterPositions
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1063
    "returns a collection of accessCharacterPositions or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1064
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1065
    ^ self collect:[:anItem| anItem accessCharacterPosition ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1066
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1067
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1068
accessCharacterPositions:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1069
    "define accessCharacterPositions for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1070
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1071
    self onEachPerform:#accessCharacterPosition: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1072
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1073
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1074
args
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1075
    "returns a collection of arguments or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1076
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1077
    ^ self collect:[:anItem| anItem argument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1078
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1079
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1080
args:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1081
    "define arguments for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1082
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1083
    self onEachPerform:#argument: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1084
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1085
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1086
argsAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1087
    "gets the argument of an item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1088
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1089
    ^ self itemAt:stringOrNumber do:[:el| el argument ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1090
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1091
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1092
argsAt:stringOrNumber put:anArgument
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1093
    "sets the argument of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1094
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1095
    self itemAt:stringOrNumber do:[:el| el argument:anArgument ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1096
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1097
3332
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1098
doAccessCharacterTranslation
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1099
    "true if &-chars in a label are to be treated as accessCharacter indicators.
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1100
     Can be set to false to leave labels unchanged"
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1101
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1102
    ^ doAccessCharacterTranslation ? true
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1103
!
321b83142fc3 changed #doAccessCharacterTranslation
Claus Gittinger <cg@exept.de>
parents: 3328
diff changeset
  1104
3328
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1105
doAccessCharacterTranslation:aBoolean
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1106
    "true if &-chars in a label are to be treated as accessCharacter indicators.
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1107
     Can be set to false to leave labels unchanged"
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1108
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1109
    doAccessCharacterTranslation := aBoolean
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1110
!
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  1111
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1112
enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1113
    "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
  1114
     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
  1115
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1116
    ^ enteredItem
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1117
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1118
    "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
  1119
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1120
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1121
groupSizes
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1122
    "gets collection of group sizes"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1123
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1124
  ^ groupSizes
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1125
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1126
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1127
groupSizes:aGroupSizes
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1128
    "sets collection of group sizes"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1129
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1130
    aGroupSizes = groupSizes ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1131
        groupSizes := aGroupSizes copy.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1132
        self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1133
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1134
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1135
2731
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1136
hideOnRelease
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1137
    ^ hideOnRelease
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1138
!
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1139
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1140
hideOnRelease:something
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1141
    hideOnRelease := something.
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1142
!
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1143
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1144
labelAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1145
    "gets the label of an item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1146
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1147
  ^ self itemAt:stringOrNumber do:[:el| el label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1148
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1149
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1150
labelAt:stringOrNumber put:aLabel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1151
    "sets the label of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1152
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1153
    self itemAt:stringOrNumber do:[:el| el label:aLabel ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1154
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1155
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1156
labels
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1157
    "returns a collection of labels's or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1158
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1159
    ^ self collect:[:anItem| anItem label ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1160
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1161
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1162
labels:labels
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1163
    "define labels for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1164
2118
89d02ebc5b65 optimize #labels: and #fetchImages in Item. discard block
ca
parents: 2113
diff changeset
  1165
    |size|
89d02ebc5b65 optimize #labels: and #fetchImages in Item. discard block
ca
parents: 2113
diff changeset
  1166
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1167
    self disabledRedrawDo:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1168
        self removeAll.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1169
        size := labels size.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1170
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1171
        size > 0 ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1172
            items := OrderedCollection new:size.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1173
            labels do:[:aLabel| items add:(Item in:self label:aLabel) ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1174
        ]
2118
89d02ebc5b65 optimize #labels: and #fetchImages in Item. discard block
ca
parents: 2113
diff changeset
  1175
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1176
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1177
1999
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1178
menuPerformer:anObject 
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1179
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1180
     from all submenus no specific receiver is defined )."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1181
1999
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1182
    ^ self receiver:anObject
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1183
!
56a97236e72d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
  1184
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1185
nameKeyAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1186
    "gets the nameKey of an item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1187
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1188
    ^ self itemAt:stringOrNumber do:[:el| el nameKey ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1189
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1190
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1191
nameKeyAt:stringOrNumber put:aNameKey
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1192
    "sets the nameKey of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1193
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1194
    self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1195
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1196
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1197
nameKeys
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1198
    "returns a collection of nameKeyss or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1199
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1200
    ^ self collect:[:anItem| anItem nameKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1201
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1202
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1203
nameKeys:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1204
    "define nameKeys for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1205
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1206
    self onEachPerform:#nameKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1207
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1208
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1209
numberOfItems
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1210
    "gets number of items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1211
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1212
    ^ items size
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1213
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1214
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1215
originator
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1216
    originator notNil ifTrue:[^ originator].
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1217
    superMenu notNil ifTrue:[
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1218
        ^ superMenu originator
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1219
    ].
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1220
    ^ nil
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1221
!
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  1222
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1223
receiver
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1224
    "get the menu-receiver. Thats the one who gets the messages ( both from myself and
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1225
     from all submenus no specific receiver is defined )."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1226
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1227
    (receiver isNil and:[superMenu notNil]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1228
        ^ superMenu receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1229
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1230
  ^ receiver
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1231
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1232
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1233
receiver:anObject 
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1234
    "set the menu-receiver. Thats the one who gets the messages ( both from myself and
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1235
     from all submenus no specific receiver is defined )."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1236
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  1237
    receiver := anObject
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1238
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1239
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1240
shortcutKeyAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1241
    "gets the shortCutKey of an item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1242
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1243
    ^ self itemAt:stringOrNumber do:[:el| el shortcutKey ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1244
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1245
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1246
shortcutKeyAt:stringOrNumber put:aKey
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1247
    "sets the shortCutKey of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1248
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1249
    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
  1250
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1251
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1252
shortcutKeys
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1253
    "returns a collection of shortcutKeys or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1254
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1255
    ^ self collect:[:anItem| anItem shortcutKey ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1256
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1257
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1258
shortcutKeys:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1259
    "define shortcutKeys for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1260
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1261
    self onEachPerform:#shortcutKey: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1262
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1263
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1264
valueAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1265
    "gets value of an item; a block, valueHolder, ..."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1266
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1267
    ^ self itemAt:stringOrNumber do:[:el| el value ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1268
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1269
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1270
valueAt:stringOrNumber put:someThing
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1271
    "sets value of an item; a block, valueHolder, ..."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1272
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1273
    self itemAt:stringOrNumber do:[:el| el value:someThing ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1274
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1275
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1276
values:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1277
    "define values for each item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1278
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1279
    self onEachPerform:#value: withArgList:something
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1280
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1281
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1282
!MenuPanel methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1283
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1284
disableAll
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1285
    "disable all items; not the menu in case of enabled"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1286
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1287
    self do:[:anItem| anItem enabled:false]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1288
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1289
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1290
disableAll:collectionOfIndicesOrNames
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1291
    "disable an collection of items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1292
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1293
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1294
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1295
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1296
enableAll
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1297
    "enable all items; not the menu in case of disabled"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1298
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1299
    self do:[:anItem| anItem enabled:true]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1300
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1301
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1302
enableAll:collectionOfIndicesOrNames
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1303
    "enable an collection of items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1304
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1305
    collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1306
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1307
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1308
enabled
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1309
    "returns enabled state"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1310
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1311
    ^ enabled
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1312
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1313
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1314
enabled:aState
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1315
    "change enabled state of menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1316
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  1317
    |state|
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1318
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1319
    state := aState ? true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1320
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1321
    enabled ~~ state ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1322
        enabled := state.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1323
        self invalidate.
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1324
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1325
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1326
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1327
enabledAt:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1328
    "gets the enabled state of an item or false"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1329
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1330
  ^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1331
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1332
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1333
enabledAt:stringOrNumber put:aState
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1334
    "sets the enabled state of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1335
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1336
    self itemAt:stringOrNumber do:[:el| el enabled:aState ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1337
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1338
2731
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1339
exclusivePointer:aBoolean
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1340
    "Do nothing here. Compatibility with PopUpListController"
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1341
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1342
    ^ self
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1343
!
7382424af8d9 Don't carsh when typing SPACE in PopUpList
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  1344
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1345
isEnabled:stringOrNumber
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1346
    "gets the enabled state of an item or false"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1347
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1348
    ^ self enabledAt:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1349
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1350
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1351
!MenuPanel methodsFor:'accessing-channels'!
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1352
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1353
enableChannel:aValueHolder
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1354
    "set my enableChannel"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1355
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1356
    enableChannel notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1357
        enableChannel removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1358
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1359
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1360
    (enableChannel := aValueHolder) notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1361
        enableChannel addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1362
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1363
    self enabled:(enableChannel value).
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1364
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1365
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1366
menuChannel
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1367
    ^ self menuHolder
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1368
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1369
    "Created: / 27-03-2007 / 08:38:31 / cg"
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1370
!
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  1371
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1372
menuHolder:aValueHolder
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1373
    "set my menuHolder"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1374
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1375
    menuHolder notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1376
        menuHolder removeDependent:self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1377
    ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1378
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1379
    (menuHolder := aValueHolder) notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1380
        menuHolder addDependent:self.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1381
    ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  1382
    self menu:(menuHolder value)
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1383
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  1384
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1385
!MenuPanel methodsFor:'accessing-color & font'!
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1386
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1387
activeBackgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1388
    "get the background drawing color used to highlight selection"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1389
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1390
    ^ styleSheet colorAt:#'menuPanel.activeBackgroundColor'
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1391
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1392
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1393
activeForegroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1394
    "get the foreground color used to highlight selections"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1395
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1396
    ^ styleSheet colorAt:#'menuPanel.activeForegroundColor'
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1397
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1398
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1399
backgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1400
    "return the background color"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1401
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  1402
    ^ super viewBackground
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1403
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1404
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1405
backgroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1406
    "set the background drawing color. You should not use this method;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1407
     instead, leave the value as defined in the styleSheet."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1408
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1409
    self backgroundColor ~~ aColor ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  1410
        super viewBackground:aColor.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  1411
        self invalidate "/ RepairNow:true
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1412
    ]
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1413
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1414
    "Modified: / 6.6.1998 / 19:50:06 / cg"
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1415
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1416
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1417
buttonActiveBackgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1418
    "get the background drawing color used to highlight button selection"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1419
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1420
    ^ styleSheet colorAt:#'button.activeBackgroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1421
                 default:(self viewBackground)
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1422
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1423
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1424
buttonEdgeStyle
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1425
    "get the button edge style"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1426
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1427
    ^ styleSheet at:#'button.edgeStyle'
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1428
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1429
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1430
buttonEnteredBackgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1431
    "get the background drawing color used to highlight entered button items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1432
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1433
    ^ styleSheet colorAt:#'menuPanel.buttonEnteredBackgroundColor'
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1434
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1435
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1436
buttonEnteredLevel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1437
    "get the 3D-level used to highlight entered button items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1438
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1439
    ^ styleSheet at:#'menuPanel.buttonEnteredLevel'
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1440
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1441
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1442
buttonHalfLightColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1443
    "get the background drawing color used to half light button frame"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1444
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1445
    ^ styleSheet colorAt:#'button.halfLightColor'
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1446
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1447
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1448
buttonHalfShadowColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1449
    "get the background drawing color used to half shadow button frame"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1450
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1451
    ^ styleSheet colorAt:#'button.halfShadowColor'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1452
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1453
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1454
buttonLightColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1455
    "get the background drawing color used to light button frame"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1456
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1457
    ^ styleSheet colorAt:#'menuPanel.buttonLightColor'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1458
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1459
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1460
buttonPassiveBackgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1461
    "get the background drawing color used for button"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1462
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1463
    ^ styleSheet colorAt:#'menuPanel.buttonPassiveBackgroundColor'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1464
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1465
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1466
buttonShadowColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1467
    "get the background drawing color used to shadow button frame"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1468
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1469
    ^ styleSheet colorAt:#'menuPanel.buttonShadowColor'
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1470
!
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1471
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1472
disabledEtchedForegroundColor
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1473
    "return the color used for etching disabled items.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1474
     If nil, no 3D effect is drawn."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1475
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1476
    ^ styleSheet colorAt:#'menuPanel.disabledEtchedFgColor'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1477
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1478
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1479
disabledForegroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1480
    "return the foreground color used by disabled items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1481
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1482
    ^ styleSheet colorAt:#'menuPanel.disabledForegroundColor'
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1483
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1484
2170
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1485
enteredBackgroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1486
    "return the background color for entered items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1487
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1488
    ^ styleSheet colorAt:#'menu.enteredBackgroundColor'
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1489
                 default:(self backgroundColor)
2170
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1490
!
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1491
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1492
enteredForegroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1493
    "return the foreground color for entered items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1494
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1495
    ^ styleSheet colorAt:#'menu.enteredForegroundColor' default:fgColor
2170
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1496
!
e76171113581 enteredFG / enteredBG
Claus Gittinger <cg@exept.de>
parents: 2166
diff changeset
  1497
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1498
font:aFont
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1499
    "set the font"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1500
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1501
    (aFont isNil or:[aFont = font]) ifTrue:[ ^ self ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1502
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1503
    super font:aFont.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1504
    self do:[:anItem| anItem fontChanged ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1505
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1506
    (shown and:[superMenu notNil]) ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1507
        self extent:(self preferredExtent)
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1508
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  1509
    self mustRearrange.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1510
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1511
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1512
foregroundColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1513
    "return the passive foreground color"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1514
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  1515
    ^ fgColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1516
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1517
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1518
foregroundColor:aColor
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1519
    "set the foregroundColor drawing color. You should not use this method;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1520
     instead leave the value as defined in the styleSheet."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1521
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1522
    aColor ~= fgColor ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1523
        fgColor := aColor onDevice:device.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  1524
        self invalidate
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1525
    ].
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1526
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  1527
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1528
maxAbsoluteButtonLevel
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1529
    "returns the maximum absolute button level; used to compute the preferred
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1530
     extent of a button"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1531
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1532
    ^ styleSheet at:#'menuPanel.maxAbsoluteButtonLevel'
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1533
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1534
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1535
selectionFrameBrightColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1536
    "get the selection frame bright color"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1537
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1538
    ^ Color white
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1539
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1540
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1541
selectionFrameDarkColor
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1542
    "get the selection frame dark color"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1543
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1544
    ^ Color black
730
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1545
!
9e45051a4fbd better button draw routine + style sheet support
tz
parents: 729
diff changeset
  1546
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1547
setFont:aFont
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  1548
    "set the font if the argument is nonNil; 
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  1549
     Return nil, if the font was unchanged; otherwise, return the old font"
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  1550
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1551
    |currentFont|
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1552
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1553
    (aFont notNil and:[aFont ~= font]) ifTrue:[
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  1554
        currentFont := font.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  1555
        super font:aFont.
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1556
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  1557
    ^ currentFont
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  1558
!
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  1559
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  1560
viewBackground:aColor
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  1561
    super viewBackground:aColor
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1562
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1563
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1564
!MenuPanel methodsFor:'accessing-dimensions'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1565
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1566
height
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1567
    "default height"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1568
3334
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  1569
    (self hasExplicitExtent not) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1570
        ^ self preferredExtent y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1571
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1572
    ^ super height
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1573
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1574
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1575
maxExtent
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1576
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1577
    device notNil ifTrue:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1578
        ^ device usableExtent - 2.
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1579
    ].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1580
    superMenu notNil ifTrue:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1581
        ^ superMenu maxExtent
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1582
    ].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1583
    "don't know, assume there is no maxExtent"
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1584
    self error:'don''t know maxExtent'.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1585
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1586
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1587
preferredExtent
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1588
    "compute and returns my preferred extent"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1589
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1590
    |maxExtent usedExtent|
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1591
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1592
    preferredExtent notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1593
        ^ preferredExtent
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1594
    ].
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1595
    usedExtent := self preferredExtentOfItems.
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1596
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1597
    superView isNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1598
        "/ is standalone
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  1599
        preferredWidth notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1600
            usedExtent x < preferredWidth ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1601
                usedExtent := preferredWidth @ usedExtent y.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1602
            ]
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1603
        ]
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1604
    ].
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1605
        
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1606
    maxExtent := self maxExtent.
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1607
    maxExtent notNil ifTrue:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1608
        usedExtent := usedExtent min:maxExtent.
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1609
    ].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  1610
    ^ usedExtent
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1611
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1612
    "Modified: / 10.10.2001 / 14:57:25 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1613
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1614
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1615
preferredExtentOfItems
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  1616
    "compute and returns my preferred extent including all items
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1617
        !!!!!! changes have influence on method #rearrangeItems !!!!!!"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1618
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1619
    |hasMenu shCtKey extent showAcc sck
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1620
     x            "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1621
     y            "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1622
     size         "{ Class:SmallInteger }"
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1623
     buttonInsetX2 "{ Class:SmallInteger }"
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1624
     buttonInsetY2 "{ Class:SmallInteger }"
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1625
     labelInsetX  "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1626
     labelInsetY  "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1627
     itemMargin   "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1628
     groupDividerSize "{ Class:SmallInteger }"
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  1629
    |
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1630
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1631
    (size := items size) == 0 ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1632
        self isViewWrapper ifTrue:[ ^ subViews first extent ].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1633
        ^ 32 @ 32
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1634
    ].
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1635
    stringOffsetX := nil.
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1636
    buttonInsetX2 := 2 * buttonInsetX.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1637
    buttonInsetY2 := 2 * buttonInsetY.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1638
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1639
    self isPopUpView ifFalse:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1640
        labelInsetX := labelInsetY := 2 * (self enteredLevel abs).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1641
    ] ifTrue:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  1642
        labelInsetX := labelInsetY := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1643
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1644
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1645
    x := 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1646
    y := 0.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1647
    groupDividerSize := self groupDividerSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1648
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1649
    self verticalLayout ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1650
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1651
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1652
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1653
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1654
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1655
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1656
                
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1657
                el isButton ifTrue:[
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1658
                    eX := eX + buttonInsetX2.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1659
                    eY := eY + buttonInsetY2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1660
                ] ifFalse:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  1661
                    eX := eX + labelInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  1662
                    eY := eY + labelInsetY.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1663
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1664
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1665
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1666
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1667
                    ] ifFalse:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1668
                        el needsItemSpaceWhenDrawing ifTrue:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1669
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  1670
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1671
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1672
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1673
                x := eX + x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1674
                y := eY max:y.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1675
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1676
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1677
    ] ifTrue:[
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1678
        hasMenu := false.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1679
        shCtKey := 0.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1680
        showAcc := MenuView showAcceleratorKeys == true.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1681
        y := x.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1682
        x := 0.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1683
        itemMargin := 2 * self itemMargin.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1684
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1685
        items keysAndValuesDo:[:key :el| |eX eY|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1686
            extent := el preferredExtent.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1687
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1688
            "/ check for visibility (extent x ~~ 0)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1689
            (eX := extent x) ~~ 0 ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1690
                eY := extent y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1691
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1692
                el isButton ifTrue:[
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1693
                    eX := eX + buttonInsetX2.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1694
                    eY := eY + buttonInsetY2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1695
                ] ifFalse:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  1696
                    eX := eX + labelInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  1697
                    eY := eY + labelInsetY.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1698
                ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1699
                hasMenu ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1700
                    hasMenu := el hasSubmenu
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1701
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1702
                (showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1703
                    shCtKey := shCtKey max:(sck widthOn:self)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1704
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1705
                key ~~ size ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1706
                    (self hasGroupDividerAt:key) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1707
                        y := y + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1708
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1709
                ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1710
                y := eY + y.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1711
                x := eX max:x.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1712
            ].
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1713
        ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1714
        x := x + itemMargin.
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1715
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1716
        (hasMenu or:[shCtKey ~~ 0]) ifTrue:[
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1717
            shortKeyInset := x + Item labelRightOffset.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1718
            x := shortKeyInset + shCtKey + self subMenuIndicationWidth.
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1719
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1720
            (shCtKey ~~ 0 and:[hasMenu]) ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1721
                x := x + self shortcutKeyOffset. 
1472
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1722
            ]
fd1871a0d888 call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents: 1464
diff changeset
  1723
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1724
"/ to have a small inset
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1725
        y := y + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1726
"/        x := x + 1.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1727
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1728
    x := x + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1729
    y := y + margin + margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1730
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1731
    ^ x @ y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1732
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1733
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1734
preferredWidth:aWidthOrNil
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1735
    "used for example by combo box to setup the preferred width for the popup menu.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1736
     If nil (default), the width is computed from the contained items.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1737
     If not nil, the width is the maximum from the contained items and the required width."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1738
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1739
    preferredWidth := aWidthOrNil.
2024
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1740
!
1214769c0441 + #preferredWidth:
Claus Gittinger <cg@exept.de>
parents: 2020
diff changeset
  1741
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1742
shortKeyInset
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1743
    "left inset of shortcutKey"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1744
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1745
    ^ shortKeyInset
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1746
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1747
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1748
stringOffsetXfor:anItem
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1749
    "return the x offset for a MenuItem where to draw the text
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1750
    "
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1751
    |label w|
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1752
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1753
    anItem isButton ifTrue:[ ^ 0 ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1754
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1755
    stringOffsetX isNil ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1756
        stringOffsetX := 0.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1757
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1758
        (self isPopUpView and:[self verticalLayout]) ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1759
            self do:[:el|
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1760
                el isVisible ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1761
                    (    (label := el indicatorForm) notNil
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1762
                     or:[(label := el choiceForm) notNil]
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1763
                    ) ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1764
                        stringOffsetX := stringOffsetX max:(label width + 2).
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1765
                    ] ifFalse:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1766
                        label := el displayLabel.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1767
                        label class == LabelAndIcon ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1768
                            stringOffsetX := stringOffsetX max:(label xOfString).
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1769
                        ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1770
                    ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1771
                ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1772
            ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1773
        ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1774
    ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1775
    w := 0.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1776
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1777
    (    (label := anItem indicatorForm) notNil
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1778
     or:[(label := anItem choiceForm) notNil]
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1779
    ) ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1780
        w := label width + 2.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1781
    ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1782
    stringOffsetX == 0 ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1783
        ^ w
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1784
    ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1785
    w == 0 ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1786
        label := anItem displayLabel.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1787
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1788
        label class == LabelAndIcon ifTrue:[
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1789
            ^ stringOffsetX - label xOfString
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1790
        ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1791
    ].
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1792
    ^ stringOffsetX.
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1793
!
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  1794
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1795
subMenuIndicationWidth
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1796
    ^ self rightArrow width
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1797
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1798
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1799
!MenuPanel methodsFor:'accessing-interactors'!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1800
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1801
iconIndicationDisabledOff
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1802
    ^ self registerImageOnDevice:(self class iconIndicationDisabledOff)
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1803
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1804
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1805
iconIndicationDisabledOn
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1806
    ^ self registerImageOnDevice:(self class iconIndicationDisabledOn)
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1807
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1808
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1809
iconIndicationOff
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1810
    ^ self registerImageOnDevice:(self class iconIndicationOff)
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1811
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1812
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1813
iconIndicationOn
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1814
    ^ self registerImageOnDevice:(self class iconIndicationOn)
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1815
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1816
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1817
iconRadioGroupDisabledOff
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1818
    ^ self registerImageOnDevice:(self class iconRadioGroupDisabledOff)
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1819
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1820
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1821
iconRadioGroupDisabledOn
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1822
    ^ self registerImageOnDevice:(self class iconRadioGroupDisabledOn)
1798
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1823
!
08ae92e6fdf3 extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1824
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1825
iconRadioGroupOff
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1826
    ^ self registerImageOnDevice:(self class iconRadioGroupOff)
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1827
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1828
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1829
iconRadioGroupOn
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1830
    ^ self registerImageOnDevice:(self class iconRadioGroupOn)
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1831
! !
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  1832
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1833
!MenuPanel methodsFor:'accessing-items'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1834
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1835
itemAt:stringOrNumber do:aOneArgBlock
2505
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1836
    "evaluate the block for an item and return the result from the block. In case that  
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1837
     the item does not exist nil is returned"
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1838
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1839
    ^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1840
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1841
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1842
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1843
    "evaluate teh block for an item and return the result from the block. In case that  
2505
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1844
     the item does not exists the result of the exception block is returned (no arguments)"
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1845
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1846
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1847
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1848
    item := self itemAt:stringOrNumber.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1849
    item notNil ifTrue:[ ^ aOneArgBlock value:item ].
2505
56607624d05a Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents: 2504
diff changeset
  1850
    ^ exceptionBlock value
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1851
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1852
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1853
itemAtIndex:anIndex
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1854
    "returns item at an index or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1855
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  1856
    ^ 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
  1857
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1858
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1859
items
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1860
    "returns list of items or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1861
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  1862
    ^ items
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1863
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1864
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  1865
!MenuPanel methodsFor:'accessing-look'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1866
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1867
buttonActiveLevel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1868
    "get the buttons active level"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1869
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1870
    ^ styleSheet at:#'menuPanel.buttonActiveLevel'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1871
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1872
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1873
buttonPassiveLevel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1874
    "get the buttons passive level"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1875
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1876
    ^ styleSheet at:#'menuPanel.buttonPassiveLevel'
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1877
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  1878
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1879
centerItems
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1880
    ^ centerItems ? false
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1881
!
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1882
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1883
centerItems:aBoolean
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1884
    centerItems := aBoolean
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1885
!
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  1886
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1887
fitFirstPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1888
    "gets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1889
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1890
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1891
     NOT SUPPORTED"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1892
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1893
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1894
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1895
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1896
fitFirstPanel:aState
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1897
    "sets true if the first panel in the menu hierarchy must be fit 
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1898
     to the extent of its superView
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  1899
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1900
     NOT SUPPORTED"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1901
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1902
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1903
level:anInt
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1904
    anInt ~~ level ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  1905
	super level:anInt.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  1906
	self mustRearrange
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  1907
    ]
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1908
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1909
    "Modified: / 15.11.2001 / 17:42:07 / cg"
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1910
!
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  1911
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1912
rightArrow
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  1913
    rightArrow isNil ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  1914
        device isNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1915
            ^ SelectionInListView rightArrowFormOn:Display
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1916
        ].
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1917
        rightArrow := SelectionInListView rightArrowFormOn:device
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1918
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1919
    ^ rightArrow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1920
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1921
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1922
rightArrowShadow
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  1923
    ^ rightArrowShadow
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1924
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1925
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1926
showGroupDivider
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1927
    "get the enabled flag for showing groupDiveders"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1928
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1929
    ^ showGroupDivider
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1930
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1931
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1932
showGroupDivider:aState
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1933
    "set the enabled flag for showing groupDiveders"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1934
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1935
    showGroupDivider ~~ aState ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1936
        showGroupDivider := aState.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1937
        self mustRearrange.
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  1938
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1939
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1940
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1941
showSeparatingLines
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1942
    "gets true if drawing of separating lines is enabled."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1943
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1944
    ^ showSeparatingLines
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1945
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1946
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  1947
showSeparatingLines:aState
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1948
    "turn on/off drawing of separating lines."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1949
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1950
    aState ~~ showSeparatingLines ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1951
        showSeparatingLines := aState.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1952
        self mustRearrange
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1953
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1954
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1955
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1956
verticalLayout
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1957
    "get the layout: vertical( true ) or horizontal( false )"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1958
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  1959
    verticalLayout notNil ifTrue:[ ^ verticalLayout ].
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1960
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1961
    superMenu notNil ifTrue:[ verticalLayout := true ]
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1962
                    ifFalse:[ verticalLayout := self isPopUpView ].
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  1963
    ^ verticalLayout
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1964
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1965
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1966
verticalLayout:aState
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1967
    "set the layout: vertical( true ) or horizontal( false )"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1968
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1969
    aState ~~ verticalLayout ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1970
        verticalLayout isNil ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1971
            verticalLayout := aState
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1972
        ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1973
            verticalLayout := aState.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1974
            self mustRearrange.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1975
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  1976
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1977
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  1978
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1979
!MenuPanel methodsFor:'accessing-style'!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1980
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1981
buttonInsetX
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1982
    "returns the verical button space"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1983
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1984
    ^ buttonInsetX
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1985
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1986
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1987
buttonInsetY
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1988
    "returns the verical button space"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1989
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1990
    ^ buttonInsetY
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1991
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1992
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1993
enteredLevel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1994
    "returns the enter-level for an unselected item moved through"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  1995
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1996
    ^ styleSheet at:#'menu.enteredLevel'  default:0
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1997
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1998
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  1999
groupDividerSize
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2000
    "returns the width of a group divider"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2001
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2002
    ^ styleSheet at:#'menu.groupDividerSize' default:6
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2003
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2004
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2005
itemMargin
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2006
    "returns the margin of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2007
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2008
    ^ styleSheet at:#'menu.itemMargin' default:0
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2009
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2010
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2011
itemSpace
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2012
    "returns the additional space for an item in a (vertical) panel"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2013
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  2014
    ^ itemSpace
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2015
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2016
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2017
selectionFollowsMouse
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2018
    "returns true if the selection follows the mouse"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2019
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2020
    ^ styleSheet at:#'menu.selectionFollowsMouse' default:false
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2021
!
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2022
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2023
shortcutKeyOffset
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2024
    "returns the offset for a shortcutKey"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2025
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2026
    ^ 5
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2027
! !
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2028
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  2029
!MenuPanel methodsFor:'accessing-submenu'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2030
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2031
subMenuAt:stringOrNumber
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2032
    "gets the current submenu of an item; if the submenu is nil, the
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2033
     submenu is generated if specified otherwise nil is returned."
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2034
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2035
    |submenu|
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2036
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2037
    
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2038
    self itemAt:stringOrNumber do:[:anItem|
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2039
        submenu := anItem currentSubmenu.
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2040
        submenu isNil ifTrue:[
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2041
            submenu := anItem setupSubmenu
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2042
        ].
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2043
    ].
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2044
    ^ submenu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2045
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2046
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2047
subMenuAt:stringOrNumber put:aSubMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2048
    "sets the submenu of an item"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2049
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2050
    self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2051
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2052
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2053
subMenuShown
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2054
    "return the currently visible submenu - or nil if there is none"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2055
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2056
    |item submenu|
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2057
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2058
    item := self selection.
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2059
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2060
    item notNil ifTrue:[
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2061
        submenu := item currentSubmenu.
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2062
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2063
        (submenu notNil and:[submenu shown]) ifTrue:[
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2064
            ^ submenu
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  2065
        ].
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2066
    ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2067
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2068
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2069
2504
0ce78a73aacf method category rename
Claus Gittinger <cg@exept.de>
parents: 2503
diff changeset
  2070
!MenuPanel methodsFor:'activation & deactivation'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2071
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  2072
closeMenus
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2073
    "close all menus without accepting"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2074
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  2075
    self topMenu accept:nil.
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  2076
!
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  2077
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2078
hide
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2079
    "hide the view, leave its modal event loop"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2080
2407
d8cdc13f677b checkin from browser
penk
parents: 2374
diff changeset
  2081
    "/ TODO: replace with LeaveSignal raise.
d8cdc13f677b checkin from browser
penk
parents: 2374
diff changeset
  2082
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2083
    self selection:nil.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2084
    self unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2085
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2086
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2087
show
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2088
    "realize the view at its last position;
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2089
     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
  2090
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2091
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2092
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2093
    ^ self showAt:(self origin) resizing:true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2094
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2095
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2096
showAt:aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2097
    "realize the view at aPoint.
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2098
     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
  2099
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2100
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2101
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2102
  ^ self showAt:aPoint resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2103
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2104
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2105
showAt:aPoint resizing:aBoolean
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2106
    "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
  2107
     or if I have already performed.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2108
     Return the items value, otherwise.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2109
     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
  2110
     menu (i.e. the view or controller), which will perform the action
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2111
     if a non-nil is returned."
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2112
1331
aae37cbfb30a fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents: 1330
diff changeset
  2113
    self rearrangeItemsIfItemVisibilityChanged.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2114
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2115
    aBoolean ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2116
        self fixSize.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2117
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2118
    self origin:aPoint.
1459
53f83c83b354 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1455
diff changeset
  2119
"/    self makeFullyVisible.   -- done in realize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2120
    self openModal:[true]. "realize     "
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2121
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2122
    "/ if I have already performed,
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2123
    "/ return nil - to avoid items triggering twice.
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2124
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2125
    (self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2126
        ^ nil
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2127
    ].
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2128
984
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2129
    ^ self lastValueAccepted
87d36803b9d8 oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents: 971
diff changeset
  2130
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2131
    "Modified: / 15.9.1998 / 12:50:23 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2132
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2133
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2134
showAtPointer
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2135
    "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
  2136
     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
  2137
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2138
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2139
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2140
  ^ self showAt:(device pointerPosition) resizing:true
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2141
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2142
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2143
showCenteredIn:aView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2144
    "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
  2145
     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
  2146
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2147
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2148
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2149
    |top|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2150
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2151
    top := aView topView.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2152
    top raise.
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2153
    ^ 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
  2154
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  2155
    "Modified: / 15.9.1998 / 12:45:50 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2156
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2157
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2158
startUp
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2159
    "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
  2160
     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
  2161
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2162
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2163
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2164
    ^ self showAtPointer
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2165
!
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2166
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2167
startUpAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2168
    "realize the menu at aPoint
1836
89a1b938c09e fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents: 1832
diff changeset
  2169
     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
  2170
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2171
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2172
897
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2173
    ^ self showAt:aPoint
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2174
6bbc8c15ac0a added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 890
diff changeset
  2175
    "Created: / 21.5.1998 / 14:15:57 / cg"
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2176
!
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2177
2332
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2178
startUpFor:originatingWidget
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2179
    "realize the menu at the current pointer position
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2180
     return the value of the selectedItem or nil, of none was selected
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2181
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2182
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2183
2332
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2184
    originator := originatingWidget.
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2185
    ^ self startUp
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2186
!
7e98cc0c92b7 can now specify if menu action is to be performed by
ca
parents: 2331
diff changeset
  2187
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2188
startUpOrNil
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2189
    "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
  2190
     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
  2191
     (unless the menu has already performed its action, by sending an appropriate message
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2192
      to some performer)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2193
1750
f9e5700bd99a compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
  2194
    ^ self showAtPointer
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2195
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2196
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2197
!MenuPanel methodsFor:'adding & removing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2198
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2199
createAtIndex:anIndexOrNil
1800
600f247a2846 comment
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  2200
    "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
  2201
     is added to the end. If the index is not valid nil is returned;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2202
     otherwise the new created item is returned."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2203
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2204
    |max item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2205
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2206
    max := (items size) + 1.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2207
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2208
    anIndexOrNil notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2209
        (anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2210
            ^ nil
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2211
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2212
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2213
    items isNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2214
        items := OrderedCollection new
1151
199863d6a463 items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
  2215
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2216
        items := items asOrderedCollection
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2217
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2218
    item := Item in:self.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2219
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2220
    (anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2221
        items add:item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2222
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2223
        items add:item beforeIndex:anIndexOrNil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2224
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2225
    ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2226
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2227
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2228
remove:stringOrNumber
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2229
    "remove the first item which is assigned to stringOrNumber;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2230
     if found, remove and return it"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2231
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2232
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2233
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2234
    (item := self itemAt:stringOrNumber) notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2235
        items remove:item.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2236
        item  destroy.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2237
        items isEmpty ifTrue:[items := nil].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2238
        self mustRearrange.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2239
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2240
  ^ item
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2241
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2243
removeAll
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2244
    "remove all items and submenus"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2245
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2246
    self disabledRedrawDo:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2247
        self selection:nil.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2248
        groupSizes := nil.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2249
        items notNil ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2250
            items copy do:[:el| el destroy ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2251
        ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2252
        items := nil
2050
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2253
    ].
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2254
ef5517d7a2d0 do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents: 2048
diff changeset
  2255
    "Modified: / 15.11.2001 / 17:02:51 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2256
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2257
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2258
!MenuPanel methodsFor:'change & update'!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2259
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2260
update:something with:aParameter from:changedObject
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2261
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2262
    changedObject == menuHolder    ifTrue:[^ self menu:(menuHolder value)].
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  2263
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2264
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2265
    super update:something with:aParameter from:changedObject
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2266
! !
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2267
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2268
!MenuPanel methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2269
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2270
asMenu
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2271
    "convert contents to a menu"
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2272
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2273
    |menu|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2274
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2275
    menu := Menu new.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2276
    menu groupSizes:groupSizes.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2277
    self do:[:anItem| menu addItem:(anItem asMenuItem) ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  2278
    ^ menu
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2279
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2280
    "Modified: / 27-03-2007 / 08:39:48 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2281
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2282
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2283
fromSpec:aMenuSpec
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2284
    "build from spec"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2285
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2286
    self menu:(Menu decodeFromLiteralArray:aMenuSpec)
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2287
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2288
    "Modified: / 27-03-2007 / 08:42:43 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2289
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2290
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2291
menu:aMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2292
    "convert to Menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2293
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2294
    self disabledRedrawDo:[
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2295
        |menu newItems menuReceiver|
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2296
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2297
        self removeAll.
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2298
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2299
        (menu := aMenu) notNil ifTrue:[
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2300
            (aMenu isCollection) ifTrue:[
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2301
                menu := Menu decodeFromLiteralArray:aMenu.
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2302
            ] ifFalse:[
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2303
                menuReceiver := menu receiver.        
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2304
                menuReceiver notNil ifTrue:[
2793
2c524ca057f6 *** empty log message ***
penk
parents: 2777
diff changeset
  2305
                    self receiver:menuReceiver.
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2306
                ]
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2307
            ].
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2308
            (newItems := menu menuItems) size > 0 ifTrue:[
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2309
                items := newItems collect:[:ni | 
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2310
                                |i|
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2311
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2312
                                i:= Item in:self.
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2313
                                i menuItem:ni.
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2314
                                i.
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2315
                            ].
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2316
            ].
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2317
            self groupSizes:(menu groupSizes).
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  2318
        ]
1063
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2319
    ]
08b7ca464437 dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  2320
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  2321
    "Modified: / 27-03-2007 / 08:42:28 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2322
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2323
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2324
!MenuPanel methodsFor:'dependents access'!
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2325
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2326
addDependencies
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2327
    "add all dependencies"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2328
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2329
    self do:[:anItem| anItem addDependencies ].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2330
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2331
    menuHolder    notNil ifTrue:[menuHolder    addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2332
    enableChannel notNil ifTrue:[enableChannel addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2333
!
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2334
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2335
removeDependencies
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2336
    "remove all dependencies"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2337
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2338
    self do:[:anItem| anItem removeDependencies ].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2339
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2340
    menuHolder    notNil ifTrue:[menuHolder    removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2341
    enableChannel notNil ifTrue:[enableChannel removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2342
! !
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  2343
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2344
!MenuPanel methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2345
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2346
disabledRedrawDo:aBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2347
    "evaluate a block without redrawing within the block; after processing
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2348
     of the block a redraw might be performed"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2349
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2350
    |state|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2351
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2352
    state := mustRearrange.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2353
    mustRearrange := true.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2354
    aBlock value.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2355
    mustRearrange := state.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2356
    self mustRearrange
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2357
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2358
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2359
drawButtonEdgesFor:anItem level:aLevel
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2360
    |layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2361
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2362
    aLevel ~~ 0 ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2363
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2364
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2365
        styleSheet is3D ifFalse:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2366
            self displayRectangle:layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2367
        ] ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2368
            self drawEdgesForX:(layout left)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2369
                             y:(layout top)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2370
                         width:(layout width)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2371
                        height:(layout height)
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2372
                         level:aLevel 
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2373
                        shadow:(self buttonShadowColor) 
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2374
                         light:(self buttonLightColor)
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2375
                    halfShadow:(self buttonHalfShadowColor) 
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2376
                     halfLight:(self buttonHalfLightColor)
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2377
                         style:(self buttonEdgeStyle)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2378
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2379
    ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2380
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2381
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2382
drawFocusForItem:anItem
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2383
    |lytItem|
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2384
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2385
    lytItem := anItem layout.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2386
    self paint:(Color black).
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2387
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2388
    self displayDottedRectangleX:(lytItem left)
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2389
                               y:(lytItem top)
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2390
                           width:(lytItem width)
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2391
                          height:(lytItem height).
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2392
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2393
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2394
drawItemsX:x y:y width:w height:h
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2395
    "redraw items and groups in a damage"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2396
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2397
    |isVertical item layout prevClip
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2398
     x1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2399
     x2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2400
     y1             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2401
     y2             "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2402
     start          "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2403
     stop           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2404
     size           "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2405
     groupDivInset  "{ Class:SmallInteger }"
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2406
    |
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2407
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2408
    size := items size.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2409
    isVertical := self verticalLayout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2410
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2411
    isVertical ifTrue:[
2064
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2412
        start := items findFirst:[:el| |l| l := el layout. l notNil and:[l bottom > y]].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2413
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2414
        y1 := y + h.
2064
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2415
        stop := items findFirst:[:el| |l| l := el layout. l notNil and:[l top > y1] ] 
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2416
                     startingAt:(start + 1).
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2417
    ] ifFalse:[
2064
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2418
        start := items findFirst:[:el| |l| l := el layout. l notNil and:[l right > x ]].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2419
        start == 0 ifTrue:[ ^ self ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2420
        x1  := x + w.
2064
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2421
        stop := items findFirst:[:el| |l| l := el layout.l notNil and:[l left > x1]] 
0e0d1fe431fb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  2422
                     startingAt:(start + 1).
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2423
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2424
    stop  == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2425
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  2426
    (groupSizes size ~~ 0 and:[showGroupDivider]) ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2427
        groupDivInset := self groupDividerSize // 2.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2428
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2429
        groupDivInset ~~ 0 ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2430
            (start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2431
                start := start - 1
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2432
            ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2433
        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2434
    ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2435
        groupDivInset := 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2436
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2437
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2438
    prevClip := clipRect.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2439
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2440
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2441
    start to:stop do:[:i|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2442
        item := items at:i.
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  2443
        item draw.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2444
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2445
        (groupDivInset ~~ 0 and:[i ~~ size and:[self hasGroupDividerAt:i]]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2446
            layout := item layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2447
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2448
            isVertical ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2449
                x1 := layout left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2450
                x2 := layout right.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2451
                y1 := layout bottom + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2452
                y2 := y1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2453
            ] ifFalse:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2454
                y1 := layout top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2455
                y2 := layout bottom.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2456
                x1 := layout right + groupDivInset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2457
                x2 := x1.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2458
            ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2459
            self paint:shadowColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2460
            self displayLineFromX:x1 y:y1 toX:x2 y:y2.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2461
            self paint:lightColor.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2462
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2463
            isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ]
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2464
                      ifFalse:[x1 := x1 + 1. x2 := x1 ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2465
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2466
            self displayLineFromX:x1 y:y1 toX:x2 y:y2
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2467
        ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2468
        selection == item ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2469
            self focusComesByTab ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2470
                self drawFocusForItem:item.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2471
            ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2472
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2473
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2474
    self clippingRectangle:prevClip.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2475
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2476
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2477
drawLabelEdgeFor:anItem selected:isSelected
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2478
    |level layout|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2479
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2480
    isSelected ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2481
        level := styleSheet at:#'menu.hilightLevel' default:0.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2482
    ] ifFalse:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2483
        anItem == enteredItem ifTrue:[ level := self enteredLevel ]
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2484
                             ifFalse:[ level := 0 ]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2485
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2486
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  2487
    level ~~ 0 ifTrue:[
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2488
        layout := anItem layout.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2489
1691
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2490
        self drawEdgesForX:(layout left)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2491
                         y:(layout top)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2492
                     width:(layout width)
8e1a9d7a298e bugfix in drawLableEdge...
ca
parents: 1690
diff changeset
  2493
                    height:(layout height)
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2494
                     level:level
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2495
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2496
!
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2497
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2498
drawScrollerAt:aDirection bounds:bounds
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2499
    "draw a scroller"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2500
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2501
    |scrolling icon level x y w h|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2502
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2503
    x := bounds left.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2504
    y := bounds top.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2505
    w := bounds width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2506
    h := bounds height.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2507
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2508
    scrolling := self scrollActivity.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2509
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2510
    (scrolling activeMenu == self and:[scrolling direction == aDirection]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2511
        level := -2
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2512
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2513
        level := 1
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2514
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2515
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2516
    level ~~ 0 ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2517
        self drawEdgesForX:x y:y width:w height:h level:level.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2518
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2519
    icon := scrolling iconAt:aDirection on:self.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2520
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2521
    icon displayOn:self x:(x + (w - icon width  // 2))
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2522
                        y:(y + (h - icon height // 2)).
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2523
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2524
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2525
invalidateItem:anItem repairNow:aBool
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2526
    "an item changed; invalidate the items layout"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2527
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2528
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2529
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  2530
    (mustRearrange not and:[shown]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2531
        layout := anItem layout.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2532
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2533
        (layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2534
            self invalidate:(layout copy insetBy:-1) repairNow:aBool
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2535
        ]
1728
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2536
    ].
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2537
fc0bd6482feb kludge redraw bug fix
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  2538
    "Modified: / 29.2.2000 / 11:28:59 / cg"
746
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2539
!
bd252bbe276f better drawing routine for button behavior
tz
parents: 739
diff changeset
  2540
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2541
mustRearrange
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2542
    "force rearrange (i.e. set the rearrange flag)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2543
2080
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2544
    mustRearrange ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  2545
        mustRearrange := true.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  2546
        self invalidate "/ RepairNow:true
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2547
    ]
590
3177528b5f95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  2548
911
6b1ad8b039c5 no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2549
    "Modified: / 6.6.1998 / 19:51:07 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2550
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2551
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2552
rearrangeGroups
3126
8dca3b01f1db new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3125
diff changeset
  2553
    "implements the groupIdentifier #right/#conditionalRight in a horizontal menu"
8dca3b01f1db new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3125
diff changeset
  2554
8dca3b01f1db new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3125
diff changeset
  2555
    <resource: #style (#'menuPanel.ignoreConditionalStartGroupRight')>
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2556
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2557
    |layout point
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2558
     dltX  "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2559
     start "{ Class:SmallInteger }"
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2560
    |
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2561
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2562
    (self isPopUpView or:[self verticalLayout]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2563
        ^ self
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2564
    ].
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2565
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2566
    layout := items last layout.
3246
c9e0e6fe80a4 changed #rearrangeGroups
Claus Gittinger <cg@exept.de>
parents: 3242
diff changeset
  2567
    layout notNil ifTrue:[
c9e0e6fe80a4 changed #rearrangeGroups
Claus Gittinger <cg@exept.de>
parents: 3242
diff changeset
  2568
        (dltX := width - margin - layout right) <= 0 ifTrue:[
c9e0e6fe80a4 changed #rearrangeGroups
Claus Gittinger <cg@exept.de>
parents: 3242
diff changeset
  2569
            ^ self  "/ no free space
c9e0e6fe80a4 changed #rearrangeGroups
Claus Gittinger <cg@exept.de>
parents: 3242
diff changeset
  2570
        ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2571
    ].
3125
25a0bdbe879a startGroup-right is ignorable via styleSheet
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
  2572
3127
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  2573
    "/ The behavior of #conditionalRight is controlled by the styleSheet.
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  2574
    "/ If menuPanel.ignoreConditionalStartGroupRight is true, it is ignored.
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  2575
    "/ otherwise, it is treated like #right.
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  2576
    "/ This allows for groups to be specified as #right under motif, but
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  2577
    "/ non-right under win32 (as is used woth the help-menus).
3148
6b74db598eae conditionalRight revisited
Claus Gittinger <cg@exept.de>
parents: 3147
diff changeset
  2578
    (StyleSheet at:#'menuPanel.ignoreConditionalStartGroupRight' ifAbsent:false) ifTrue:[
6b74db598eae conditionalRight revisited
Claus Gittinger <cg@exept.de>
parents: 3147
diff changeset
  2579
        start := items findFirst:[:anItem| anItem startGroup == #right ].
6b74db598eae conditionalRight revisited
Claus Gittinger <cg@exept.de>
parents: 3147
diff changeset
  2580
    ] ifFalse:[
6b74db598eae conditionalRight revisited
Claus Gittinger <cg@exept.de>
parents: 3147
diff changeset
  2581
        start := items findFirst:[:anItem| anItem startGroup == #right or:[ anItem startGroup == #conditionalRight ] ].
3126
8dca3b01f1db new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3125
diff changeset
  2582
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2583
    start == 0 ifTrue:[
3125
25a0bdbe879a startGroup-right is ignorable via styleSheet
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
  2584
        ^ self  "/ no right-group item detected
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2585
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2586
    point := dltX @ 0.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2587
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2588
    "/ move items layout to right
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2589
    items from:start do:[:anItem|
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2590
        anItem isVisible ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2591
            anItem layout moveBy:point.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2592
        ]
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2593
    ].
3125
25a0bdbe879a startGroup-right is ignorable via styleSheet
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
  2594
3246
c9e0e6fe80a4 changed #rearrangeGroups
Claus Gittinger <cg@exept.de>
parents: 3242
diff changeset
  2595
    "Modified: / 10-10-2007 / 00:29:34 / cg"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2596
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2597
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2598
rearrangeItems
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2599
    "recompute the layout of each item
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2600
        !!!!!! changes have influence on method #preferredExtentOfItems !!!!!!"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2601
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2602
    |isVertical extent isPopUpMenu
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2603
     x            "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2604
     y            "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2605
     x0           "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2606
     y0           "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2607
     x1           "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2608
     y1           "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2609
     size         "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2610
     insetX       "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2611
     insetY       "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2612
     labelInsetX  "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2613
     labelInsetY  "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2614
     itemMargin   "{ Class:SmallInteger }"
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2615
     groupDividerSize "{ Class:SmallInteger }"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2616
    |
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2617
    (mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2618
        mustRearrange := false.
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  2619
        ^ self
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2620
    ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2621
2080
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2622
"/  DON'T SET THIS!!
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2623
"/  item layout:  below of first item -> item invalidate 
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2624
"/                                    -> menuPanel invalidateItem:repairDamage: 
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2625
"/                                    -> invalidate:rapairDamage:
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2626
"/                                    -> redrawX:y:width:height:
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2627
"/                                    tries to get uninitialized layout from second item.
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2628
"/ This happens in a modal debugger!!
f37673e44158 Fix rearrangeItem stuff
Stefan Vogel <sv@exept.de>
parents: 2079
diff changeset
  2629
"/    mustRearrange := false.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2630
    isVertical       := self verticalLayout.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2631
    groupDividerSize := self groupDividerSize.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2632
    isPopUpMenu      := self isPopUpView.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2633
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  2634
    isPopUpMenu ifFalse:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2635
        labelInsetX := labelInsetY := self enteredLevel abs.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2636
    ] ifTrue:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2637
        labelInsetX := labelInsetY := 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2638
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2639
3334
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  2640
    (isPopUpMenu or:[self hasExplicitExtent not]) ifTrue:[ 
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  2641
        |saveExtent maxExtent extentToSet|
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  2642
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2643
        extent := self preferredExtent.
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2644
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2645
        isPopUpMenu ifTrue:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2646
            maxExtent := self maxExtent.
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2647
            maxExtent notNil ifTrue:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2648
                extentToSet := isVertical ifTrue:[extent x @ (extent y min:(maxExtent y))] 
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2649
                                          ifFalse:[(extent x min:(maxExtent x)) @ extent y].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2650
            ].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2651
        ] ifFalse:[
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2652
            extent := extentToSet := isVertical ifTrue:[extent x @ 1.0] ifFalse:[1.0 @ extent y].
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2653
        ].
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  2654
        self extent:extentToSet.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2655
    ] ifFalse:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2656
        extent := self computeExtent
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2657
    ].
1082
382324ddce3f support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents: 1081
diff changeset
  2658
1093
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2659
    x := y := margin.
7cb44303b016 margin fixes
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
  2660
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2661
    isVertical ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2662
        y0 := margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2663
        y1 := extent y - margin.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2664
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2665
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2666
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2667
                el layout:(Rectangle left:x top:y0 right:x bottom:y1)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2668
            ] ifTrue:[
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2669
                el isButton ifTrue:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2670
                    insetX := buttonInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2671
                    insetY := buttonInsetY.
2062
31ba9af25394 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  2672
                ] ifFalse:[            
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2673
                    insetX := labelInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2674
                    insetY := labelInsetY.
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2675
                ].
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2676
                x0 := x  + insetX.
2171
90a7393eb53c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2170
diff changeset
  2677
                x1 := x0 + (el preferredExtent x).
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2678
                el layout:(Rectangle left:x0 top:(y0 + insetY) right:x1 bottom:(y1 - insetY)).
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2679
                x := x1 + insetX.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2680
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2681
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2682
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2683
                        x := x + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2684
                    ] ifFalse:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  2685
                        el needsItemSpaceWhenDrawing ifTrue:[
1723
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2686
                            x := x + itemSpace
f633725a0ace use itemSpace only for horizontal menus and between labeled items
ca
parents: 1719
diff changeset
  2687
                        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2688
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2689
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2690
            ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2691
        ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2692
    ] ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2693
        itemMargin := self itemMargin.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2694
        x0 := margin.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2695
        x1 := extent x - margin - itemMargin.  "/ -1
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2696
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2697
        items keysAndValuesDo:[:anIndex :el|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2698
            el isVisible ifFalse:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2699
                el layout:(Rectangle left:x0 top:y right:x1 bottom:y)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2700
            ] ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2701
                el isButton ifTrue:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2702
                    insetX := buttonInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2703
                    insetY := buttonInsetY.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2704
                ] ifFalse:[
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2705
                    insetX := labelInsetX.
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2706
                    insetY := labelInsetY.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2707
                ].
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2708
                y0 := y  + insetY.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2709
                y1 := y0 + el preferredExtent y.
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  2710
                el layout:(Rectangle left:(x0 + insetX + itemMargin) top:y0 right:(x1 - insetX) bottom:y1).
2145
aa6c81509521 prep to separate vertical from horizontal space
penk
parents: 2143
diff changeset
  2711
                y := y1 + insetY.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2712
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2713
                size ~~ anIndex ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2714
                    (self hasGroupDividerAt:anIndex) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2715
                        y := y + groupDividerSize
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2716
                    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2717
                ]
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2718
            ]
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  2719
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  2720
    ].
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2721
    self rearrangeGroups.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2722
    selection notNil ifTrue:[self makeItemVisible:selection].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2723
    mustRearrange := false.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2724
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2725
    "Modified: / 13.11.2001 / 20:17:21 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2726
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2727
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2728
rearrangeItemsIfItemVisibilityChanged
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2729
    "check for items which can change its visibility;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2730
     if at least one item exists, rearrange all items"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2731
1464
3070de4c8b88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1459
diff changeset
  2732
    items isNil ifTrue:[^ self].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2733
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2734
    items do:[:item |
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2735
        item canChangeVisibility ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2736
            mustRearrange := true.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2737
            self rearrangeItems.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2738
            ^ self
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2739
        ].
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2740
    ]
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2741
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  2742
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2743
redrawX:x y:y width:w height:h
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2744
    "redraw a damage"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2745
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2746
    |y0 y1 x0 x1 prvBound mustDraw nxtBound|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2747
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  2748
    (shown and:[w ~~ 0]) ifFalse:[^ self].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2749
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2750
    mustRearrange ifTrue:[
3334
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  2751
        self isPopUpView ifFalse:[ self explicitExtent:true].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2752
        self rearrangeItems.
2569
bfe9e33b545e not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2550
diff changeset
  2753
        self invalidate.
bfe9e33b545e not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2550
diff changeset
  2754
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2755
    ].
2888
095d9fb3e846 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
  2756
    "/ self paint:(self viewBackground).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2757
    self clearRectangleX:x y:y width:w height:h.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2758
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2759
    items size == 0 ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2760
        ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2761
    ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2762
    y0 := y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2763
    y1 := y + h.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2764
    x0 := x.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2765
    x1 := x + w.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2766
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2767
    "Draw the scroll handles - especially for Popup-Lists"
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2768
    
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2769
    self hasScrollers ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2770
        (self hasScrollerAt:#PREV) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2771
            prvBound := self scrollerBoundsAt:#PREV.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2772
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2773
            self verticalLayout ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2774
                (mustDraw := (prvBound bottom > y)) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2775
                    y0 := prvBound bottom.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2776
                ].
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2777
            ] ifFalse:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2778
                (mustDraw := (prvBound right > x)) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2779
                    x0 := prvBound right.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2780
                ].
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2781
            ].
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2782
            mustDraw ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2783
                self drawScrollerAt:#PREV bounds:prvBound.
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2784
            ].
1387
ad7a920fdf61 less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  2785
        ].
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2786
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2787
        (self hasScrollerAt:#NEXT) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2788
            nxtBound := self scrollerBoundsAt:#NEXT.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2789
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2790
            self verticalLayout ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2791
                (mustDraw := (nxtBound top < y1)) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2792
                    y1 := nxtBound top.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2793
                ]
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2794
            ] ifFalse:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2795
                (mustDraw := (nxtBound left < x1)) ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2796
                    x1 := nxtBound left.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2797
                ]
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2798
            ].
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2799
            mustDraw ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2800
                self drawScrollerAt:#NEXT bounds:nxtBound.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2801
            ].
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2802
        ].
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2803
    ].
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2804
    self menuAdornmentAt:#lastDrawnScrollerNextBounds put:nxtBound.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  2805
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2806
    (y1 > y0 and:[x1 > x0]) ifTrue:[
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  2807
        self drawItemsX:x0 y:y0 width:(x1 - x0) height:(y1 - y0)
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2808
    ].
2052
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2809
61367c7a47aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  2810
    "Modified: / 15.11.2001 / 20:57:32 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2811
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2812
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2813
!MenuPanel methodsFor:'enumerting & searching'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2814
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2815
collect:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2816
    "evaluate the argument, aOneArgBlock for every item in the menuPanel
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2817
     and return a collection of the results"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2818
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2819
    items notNil ifTrue:[^ items collect:aOneArgBlock ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  2820
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2821
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2822
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2823
do:aOneArgBlock
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2824
    "evaluate the argument, aOneArgBlock for every item in the menuPanel."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2825
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2826
    items notNil ifTrue:[ items do:aOneArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2827
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2828
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2829
findFirst:aOneArgBlock
3206
48a66f672af3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3203
diff changeset
  2830
    "find the index of the first item, for which evaluation of the argument, aOneArgBlock
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2831
     returns true; return its index or 0 if none detected."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2832
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2833
    items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ].
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2834
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2835
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2836
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2837
findLast:aOneArgBlock
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2838
    "find the last item, for which evaluation of the argument, aOneArgBlock
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2839
     returns true; return its index or 0 if none detected."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2840
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2841
    items notNil ifTrue:[ ^ items findLast:aOneArgBlock ].
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2842
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2843
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2844
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2845
firstItemSelectable
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2846
    "returns the first item which is selectable or nil
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2847
    "
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2848
    items size > 0 ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2849
        ^ items detect:[:anItem| anItem canSelect ] ifNone:nil
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2850
    ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2851
    ^ nil
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2852
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  2853
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2854
indexOf:something
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2855
    "returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2856
     If no item match 0 is returned. No range checks are performed on a number argument"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2857
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2858
    |i v|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2859
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2860
    something isNumber ifTrue:[ ^ something ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2861
    something isNil    ifTrue:[ ^ 0 ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2862
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2863
    i := self findFirst:[:el | (el nameKey = something) or: [el = something]].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2864
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2865
    i ~~ 0 ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2866
        ^ i
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2867
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2868
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2869
    something isSymbol ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2870
        i := self findFirst:[:el|
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2871
                                v := el value.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2872
                                v isSymbol and:[v == something]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2873
                            ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2874
        i ~~ 0 ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2875
            ^ i
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2876
        ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2877
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2878
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  2879
    (something respondsTo:#string) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2880
        v := something string.
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2881
      ^ self findFirst:[:el | el textLabel = v].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2882
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  2883
    ^ 0
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2884
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2885
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2886
indexOfItem:anItem
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2887
    "returns the index of the item or 0"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2888
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2889
    ^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0]
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2890
!
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  2891
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2892
keysAndValuesDo:aTwoArgBlock
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2893
    "evaluate the argument, aTwoArgBlock for every item in the menuPanel."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2894
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2895
    items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2896
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2897
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2898
!MenuPanel methodsFor:'event handling'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2899
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  2900
buttonMotion:state x:x y:y
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2901
    "open or close the corresponding submenu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2902
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2903
    |menue motionPoint translatedPoint sensor|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2904
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2905
    self scrollActivity isActive ifTrue:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2906
        ^ self
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2907
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2908
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2909
    sensor := self sensor.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2910
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2911
    (sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2912
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2913
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2914
    menue := self detectGrabMenu.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  2915
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2916
    motionPoint := x@y.
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2917
    translatedPoint := menue translateGrabPoint:motionPoint.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2918
    menue handleButtonMotion:state atPoint:translatedPoint.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2919
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2920
    hideOnRelease := true.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2921
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2922
    (self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2923
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2924
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2925
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  2926
    (selection notNil and:[selection visibleSubmenu isNil]) ifTrue:[
3321
2f495adadca5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
  2927
        "/ selection on grabView without a submenu (Button ...); check whether moving out
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2928
        (self containsPoint:motionPoint) ifFalse:[
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2929
            ^ self accept:nil
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2930
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2931
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2932
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  2933
    "Modified: / 13.11.2001 / 20:21:49 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2934
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2935
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2936
buttonPress:button x:x y:y
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2937
    "any button pressed; open or close the corresponding submenus"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2938
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2939
    |menu point|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2940
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2941
    hideOnRelease := true.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2942
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2943
    self scrollActivity stop.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2944
    point := x@y.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2945
    menu  := self detectMenuAtGrabPoint:point.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2946
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2947
    menu isNil ifTrue:[
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2948
        self accept:nil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2949
    ] ifFalse:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  2950
        point := menu translateGrabPoint:point.
3383
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  2951
        menu handleButtonPress:button atPoint:point.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2952
    ]
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2953
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  2954
    "Modified: / 13.11.2001 / 14:12:32 / cg"
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2955
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2956
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2957
buttonRelease:button x:x y:y
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2958
    "button release action; accept selection and close all views"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  2959
2679
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2960
    |topMenu dstMenu item srcPoint dstPoint subm hideMenuAndPerformAction 
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2961
     releaseTime menuMapTime|
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  2962
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  2963
    topMenu := self topMenu.
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  2964
    topMenu openDelayed:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2965
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2966
    self scrollActivity stop ifTrue:[
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2967
        ^ self
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2968
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  2969
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2970
    dstMenu := topMenu activeMenu.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2971
2679
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2972
    hideMenuAndPerformAction := dstMenu selection notNil or:[dstMenu isPopUpView not].
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2973
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2974
    hideMenuAndPerformAction ifFalse:[
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2975
        hideOnRelease ifTrue:[
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2976
            releaseTime := windowGroup lastEvent timeStamp.
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2977
            menuMapTime := dstMenu mapTime ? releaseTime.
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2978
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  2979
            hideMenuAndPerformAction := (releaseTime millisecondDeltaFrom:menuMapTime)
2679
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2980
                        > (PopUpMenu maxClickTimeToStayOpen).
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2981
        ].
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2982
    ].
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2983
302ab06d7110 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  2984
    hideMenuAndPerformAction ifTrue:[
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2985
        srcPoint := x@y.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  2986
        
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2987
        (     (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2988
         and:[(item    := dstMenu selection) notNil]
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2989
        ) ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2990
            item visibleSubmenu notNil ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2991
                dstMenu selection:nil.
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2992
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2993
                (selection isNil and:[self isPopUpView not]) ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2994
                    self accept:nil
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2995
                ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2996
                ^ self
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2997
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2998
            ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  2999
            subm := item currentSubmenu.
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3000
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3001
            subm notNil ifTrue:[
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3002
                subm shown ifTrue:[^ self].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3003
                "/ test whether any action is assigned to the menu
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3004
                "/ if not ignorre accept
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3005
                item hasDelayedMenu ifFalse:[^ self].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3006
                "/ handle action defined for the delayed menu
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3007
            ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3008
            dstPoint := dstMenu translateGrabPoint:srcPoint.
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3009
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3010
            (dstMenu itemAtPoint:dstPoint) == dstMenu selection ifFalse:[
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3011
                item := nil
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3012
            ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3013
            topMenu acceptItem:item inMenu:dstMenu.
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3014
            ^ self
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3015
        ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3016
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3017
        (selection notNil and:[dstMenu == self]) ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3018
            selection visibleSubmenu notNil ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3019
                ^ self
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3020
            ]
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3021
        ].
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3022
        self accept:nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3023
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3024
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3025
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3026
handleSizeChanged:how
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3027
    "used to handle the scrollers and groups in a none popUpView
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3028
    "
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3029
    |layouts damage isVertical scrollBound|
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3030
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3031
    (mustRearrange or:[items size == 0 or:[self isPopUpView]]) ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3032
        ^ self
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3033
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3034
    mustRearrange := true.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3035
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3036
    shown ifFalse:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3037
        ^ self
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3038
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3039
    layouts := OrderedCollection new.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3040
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3041
    items do:[:el| |layout|
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3042
        (layout := el layout) isNil ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3043
            self invalidate.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3044
            ^ self.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3045
        ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3046
        layouts add:layout.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3047
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3048
    isVertical  := self verticalLayout.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3049
    scrollBound := self scrollerBoundsAt:#NEXT.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3050
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3051
    self rearrangeItems.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3052
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3053
    items keysAndValuesDo:[:i :el| |newLyt oldLyt|
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3054
        damage isNil ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3055
            newLyt := el layout.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3056
            oldLyt := layouts at:i ifAbsent:newLyt.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3057
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3058
            newLyt ~= oldLyt ifTrue:[ |x y start|
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3059
                start := 0.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3060
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3061
                i > 1 ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3062
                    isVertical ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3063
                        x := 0.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3064
                        y := start := (oldLyt top min:(newLyt top)) min:(height - scrollBound height).
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3065
                    ] ifFalse:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3066
                        y := 0.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3067
                        x := start := (oldLyt left min:(newLyt left)) min:(width - scrollBound width).
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3068
                    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3069
                ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3070
                start <= 20 ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3071
                    self invalidate.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3072
                    ^ self
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3073
                ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3074
                damage := Rectangle left:x top:y extent:(self extent).
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3075
            ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3076
        ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3077
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3078
    damage isNil ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3079
        damage := scrollBound.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3080
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3081
    scrollBound := self menuAdornmentAt:#lastDrawnScrollerNextBounds.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3082
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3083
    scrollBound notNil ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3084
        damage := damage merge:scrollBound
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3085
    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3086
    self invalidate:damage.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3087
!
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3088
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3089
keyPress:key x:x y:y
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3090
    "any key is pressed"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3091
2869
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3092
    <resource: #keyboard (#Escape
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3093
                          #Tab #FocusNext #FocusPrevious
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3094
                          #CursorLeft #CursorRight )>
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3095
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3096
    |menu menusSuperMenu sensor|
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3097
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3098
    sensor := self sensor.
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3099
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3100
"/    sensor anyButtonPressed ifTrue:[
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3101
"/        ^ self  "/ ignored while any button is pressed
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3102
"/    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3103
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3104
    self scrollActivity isActive ifTrue:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3105
        key ~~ #Escape ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3106
            ^ self
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3107
        ].
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3108
        self scrollActivity stop
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3109
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3110
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3111
       (key == #Tab 
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3112
    or:[key == #FocusNext
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3113
    or:[key == #FocusPrevious]]) ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3114
        self accept:nil.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3115
        ^ super keyPress:key x:x y:y
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3116
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3117
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3118
    menu := self detectGrabMenu.
2869
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3119
    menusSuperMenu := menu superMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3120
3394
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  3121
    (key == #Escape) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3122
        "/ must hide the active menu
2869
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3123
        (menusSuperMenu notNil and:[menusSuperMenu ~~ self]) ifTrue:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3124
            "/ hide active menu but keep the grab
2869
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3125
            menusSuperMenu selection:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3126
        ] ifFalse:[
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3127
            "/ hide active menu and ungrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3128
            self accept:nil
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3129
        ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3130
        ^ self
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3131
    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3132
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3133
    menu isViewWrapper ifFalse:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3134
        sensor compressKeyPressEventsWithKey:key.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3135
        menu handleKeyPress:key.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3136
        ^ self
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3137
    ].
2869
3e24a0b78c17 comment
Claus Gittinger <cg@exept.de>
parents: 2860
diff changeset
  3138
    menusSuperMenu == self ifFalse:[^ self].
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3139
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3140
    "/ allow cursor movement
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3141
    (key == #CursorLeft or:[key == #CursorRight]) ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3142
        (self containsPoint:x@y) ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3143
            self handleKeyPress:key.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3144
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3145
    ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3146
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3147
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3148
pointerLeave:state
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3149
    |sensor|
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3150
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3151
    self scrollActivity isActive ifTrue:[^ self].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3152
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3153
    self detectGrabMenu handlePointerLeave:state.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3154
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3155
    (selection isNil or:[self isPopUpView]) ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3156
        ^ self
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3157
    ].
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3158
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3159
    selection visibleSubmenu notNil ifTrue:[^ self].
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3160
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3161
    windowGroup focusView ~~ self ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3162
        self accept:nil
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3163
    ] ifFalse:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3164
        selection isButton ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3165
            sensor := self sensor.
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3166
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3167
            sensor isNil ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3168
                self accept:nil
2255
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3169
            ] ifFalse:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3170
                "/ I'have the focus; if no button pressed, than keep the selection
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3171
                sensor anyButtonPressed ifTrue:[
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3172
                    self selection:nil
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3173
                ]
e8bf6618da02 #pointerLeave: depends on selection, focusView, mouseButton...
ca
parents: 2253
diff changeset
  3174
            ].
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3175
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3176
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3177
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3178
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3179
sizeChanged:how
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3180
    "redraw #right groups"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3181
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3182
"/    self isPopUpView ifFalse:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3183
"/        mustRearrange := true.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3184
"/        self invalidate
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3185
"/    ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3186
"/    ^ super sizeChanged:how.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3187
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3188
    self handleSizeChanged:how.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  3189
    super sizeChanged:how.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3190
! !
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3191
2503
4f34d55dae21 method category rename
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  3192
!MenuPanel methodsFor:'event handling-processing'!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3193
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3194
clearImplicitGrab
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3195
    implicitGrabView := lastPointerView := nil.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3196
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3197
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3198
dispatchEvent:ev withFocusOn:focusView delegate:doDelegate
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3199
    "dispatch and handle an event"
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3200
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3201
    |view x y p syntheticEvent menu|
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3202
2658
04f9fdd74b8e event handling
Claus Gittinger <cg@exept.de>
parents: 2652
diff changeset
  3203
    ev isDamage ifTrue:[
04f9fdd74b8e event handling
Claus Gittinger <cg@exept.de>
parents: 2652
diff changeset
  3204
        ^ super dispatchEvent:ev withFocusOn:focusView delegate:false.
04f9fdd74b8e event handling
Claus Gittinger <cg@exept.de>
parents: 2652
diff changeset
  3205
    ].
04f9fdd74b8e event handling
Claus Gittinger <cg@exept.de>
parents: 2652
diff changeset
  3206
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3207
    (superMenu isNil and:[ev isButtonPressEvent]) ifTrue:[
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3208
        focusView ~~ self ifTrue:[prevFocusView := focusView].
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3209
    ].
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3210
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3211
    "/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3212
    "/ but never get the buttonRelease, since someone else (a popUp) grabbed the
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3213
    "/ pointer in the meantime, and has eaten the release event ... (double-sigh)
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3214
    implicitGrabView notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3215
        self sensor leftButtonPressed ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3216
            self clearImplicitGrab.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3217
        ].
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3218
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3219
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3220
    ((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3221
        ^ super dispatchEvent:ev withFocusOn:focusView delegate:false.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3222
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3223
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3224
    implicitGrabView notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3225
        ev isButtonEvent ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3226
            p := device translatePoint:(x@y) fromView:self toView:implicitGrabView.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3227
            ev view:implicitGrabView.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3228
            ev arguments at:2 put:p x.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3229
            ev arguments at:3 put:p y.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3230
            implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3231
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3232
            ev isButtonReleaseEvent ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3233
                self clearImplicitGrab.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3234
            ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3235
            ^ self
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3236
        ]
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3237
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3238
    menu := self detectMenuAtGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3239
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3240
    (menu isNil or:[menu isViewWrapper not]) ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3241
        self clearImplicitGrab.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3242
      ^ super dispatchEvent:ev withFocusOn:focusView delegate:false
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3243
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3244
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3245
    p    := menu translateGrabPoint:(x@y).
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3246
    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
  3247
    p    := device translatePoint:(x@y) fromView:self toView:view.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3248
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3249
    ev isButtonPressEvent ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3250
        (view wantsFocusWithButtonPress) ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3251
            view requestFocus.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3252
        ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3253
        view ~~ self ifTrue:[ "/ can this ever be self ?
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3254
            implicitGrabView := view.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3255
        ]
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3256
    ].
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3257
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3258
    ev isButtonMotionEvent ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3259
        lastPointerView ~~ view ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3260
            "/ must generate enter/leave ... (sigh)
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3261
            lastPointerView notNil ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3262
                "/ XXX: should be fixed
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3263
                syntheticEvent := WindowEvent pointerLeave:0 view:lastPointerView.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3264
                lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3265
            ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3266
            view notNil ifTrue:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3267
                syntheticEvent := WindowEvent pointerEnter:0 x:x y:y view:view.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3268
                view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3269
            ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3270
            lastPointerView := view.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  3271
        ].
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3272
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3273
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3274
    ev view:view.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3275
    ev x:p x.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3276
    ev y:p y.
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3277
    view dispatchEvent:ev withFocusOn:focusView delegate:false.
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  3278
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  3279
    "Modified: / 10.10.2001 / 13:54:47 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3280
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3281
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3282
handleButtonMotion:state atPoint:motionPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3283
    "open or close the corresponding submenus"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3284
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3285
    |menu item translatedPoint containsPoint direction|
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3286
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3287
    containsPoint    := self containsPoint:motionPoint.
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3288
    containsPoint ifTrue:[ item := self itemAtPoint:motionPoint ].
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3289
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3290
    "no aotoscroll, if the mouse pointer is inside the scroll button"
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3291
    direction := self scrollerDirectionAtPoint:motionPoint.
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3292
    direction notNil ifTrue:[
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3293
        self pointerEntersItem:nil.
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  3294
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  3295
        self sensor anyButtonPressed ifTrue:[
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  3296
            self scrollActivity startIfRequiredAt:direction on:self comesViaButtonPress:false.
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  3297
        ].
3242
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3298
        ^ self
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3299
    ].
4d8c5bde0f98 Show scroll buttons, if menu is larger than screen (needed for PopupListm ComboBox, ...)
Stefan Vogel <sv@exept.de>
parents: 3233
diff changeset
  3300
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3301
    self pointerEntersItem:item.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3302
1910
119f91172b70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3303
    (state == 0 or:[self sensor anyButtonPressed not]) ifTrue:[
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3304
        (     self selectionFollowsMouse
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3305
         and:[self topMenu focusComesByTab not]
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3306
        ) ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3307
            self isPopUpView ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3308
                item isNil ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3309
                    superMenu notNil ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3310
                        translatedPoint := self translateMenuPoint:motionPoint toMenu:superMenu.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3311
                        superMenu handleButtonMotion:state atPoint:translatedPoint.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3312
                    ]
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3313
                ] ifFalse:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3314
                    self selection:item openMenu:false.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3315
                    self openDelayed:item afterSeconds:0.1.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3316
                ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3317
            ] ifFalse:[ "/ processing in the toolbar
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3318
                (item notNil and:[self hasSelection and:[item canSelect]]) ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3319
                    self selection:item openMenu:true.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3320
                ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3321
            ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3322
        ].
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3323
        ^ self
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3324
    ].
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  3325
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3326
    containsPoint ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3327
        self selection:item openMenu:true.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3328
        ^ self
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3329
    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3330
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3331
    menu := self superMenuAtPoint:motionPoint.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3332
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3333
    menu notNil ifTrue:[
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3334
        translatedPoint := self translateMenuPoint:motionPoint toMenu:menu.
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3335
        menu handleButtonMotion:state atPoint:translatedPoint.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3336
        ^ self
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3337
    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3338
    self isPopUpView ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3339
        self selection:nil
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3340
    ].
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3341
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3342
3383
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3343
handleButtonPress:button atPoint:aPoint
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3344
    "a button pressed; open or close the corresponding submenus"
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3345
3233
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3346
    | item direction wasSelected|
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3347
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3348
    item := self itemAtPoint:aPoint.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3349
    item isNil ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3350
        self selection:nil openMenu:false.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  3351
        ^ self
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3352
    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3353
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3354
    direction := self scrollerDirectionAtPoint:aPoint.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3355
    direction notNil ifTrue:[
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  3356
        (self scrollActivity startIfRequiredAt:direction on:self comesViaButtonPress:true) ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3357
            self pointerEntersItem:nil.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3358
            ^ self
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3359
        ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3360
    ].
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3361
3383
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3362
    button == 2 ifTrue:[
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3363
        item hasDelayedMenu ifTrue:[
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3364
            self selection:item openMenu:false.
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3365
            self openDelayed:item afterSeconds:0.
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3366
            ^ self.
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3367
        ].
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3368
    ].
81b34d7be9b4 right-click delayed menu
Claus Gittinger <cg@exept.de>
parents: 3363
diff changeset
  3369
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3370
    wasSelected := (selection == item).
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3371
    wasSelected ifFalse:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3372
        self selection:item openMenu:true
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3373
    ].
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  3374
    item hasDelayedMenu ifTrue:[^ self].
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3375
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3376
    (item isToggle or:[item triggerOnDown]) ifFalse:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3377
        (wasSelected and:[item hasSubmenu and:[item visibleSubmenu isNil]]) ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3378
            item toggleSubmenuVisibility
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3379
        ].
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3380
        ^ self
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3381
    ].
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3382
    (item canAccept and:[item == self selection]) ifFalse:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3383
        ^ self
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3384
    ].
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3385
    self invalidateItem:item repairNow:true.
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3386
    self acceptItem:item inMenu:self.
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3387
3233
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3388
    [ (device notNil and:[device anyButtonPressed]) ] whileTrue:[
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3389
        "/ using device - sensor is not updated sometimes
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3390
        Delay waitForSeconds:0.1.
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3391
    ].
50bec260bddc bugfix - waiting for anyButtonPressede not
ca
parents: 3224
diff changeset
  3392
    self sensor flushUserEvents.
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3393
    self selection:nil.
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3394
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  3395
    "Created: / 13.11.2001 / 14:12:04 / cg"
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  3396
    "Modified: / 13.11.2001 / 19:50:52 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3397
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3398
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3399
handleCursorKey:aKey
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3400
    "handle a cursor key"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3401
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3402
    |next menu item isVrt backKey p1 p2
2354
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3403
     idx0  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3404
     idx   "{ Class:SmallInteger }"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  3405
     size  "{ Class:SmallInteger }"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  3406
    |
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3407
    (size  := items size) == 0 ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3408
        superMenu notNil ifTrue:[superMenu handleCursorKey:aKey].
2354
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3409
        ^ self
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3410
    ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3411
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3412
    isVrt := self verticalLayout.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3413
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3414
    (    (isVrt     and:[aKey == #CursorUp    or:[aKey == #CursorDown]])
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3415
     or:[(isVrt not and:[aKey == #CursorRight or:[aKey == #CursorLeft]])]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3416
    ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3417
        selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3418
            (superMenu notNil and:[superMenu verticalLayout == isVrt]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3419
                ^ superMenu handleCursorKey:aKey
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3420
            ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3421
            idx := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3422
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3423
            isVrt ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3424
                "/ used because of vertical scrolling
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3425
                idx := items findFirst:[:el| el layout top > 0 ].
2354
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3426
                idx ~~ 0 ifTrue:[idx := idx - 1 ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3427
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3428
        ] ifFalse:[
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  3429
            idx := self indexOf:selection.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3430
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3431
        next := aKey == #CursorRight or:[aKey == #CursorDown].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3432
2354
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3433
        idx0 := idx.
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3434
        size timesRepeat:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3435
            |el|
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3436
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3437
            next ifTrue:[idx := idx + 1] ifFalse:[idx := idx - 1].
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3438
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3439
            idx > size ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3440
                idx := 0 "1"
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3441
            ] ifFalse:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3442
                idx < 0 ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3443
                    idx := size
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3444
                ] 
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3445
            ].
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3446
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3447
            idx == 0 ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3448
                self selection:nil.
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3449
                ^ self
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3450
            ] ifFalse:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3451
                (el := items at:idx ifAbsent:nil) notNil ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3452
                    el canSelect ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3453
                        el hasDelayedMenu ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3454
                            "/ do not open menu
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3455
                            self selection:el openMenu:false
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3456
                        ] ifFalse:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3457
                            "/ open comes from style-sheet
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3458
                            self selection:el.
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3459
                        ].
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3460
                        ^ self
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3461
                    ].
2354
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3462
                ]
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3463
            ].
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3464
            idx == idx0 ifTrue:[
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3465
                ^ self
1bd2ac73b73c cursorUp/Down behavior
Claus Gittinger <cg@exept.de>
parents: 2347
diff changeset
  3466
            ].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3467
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3468
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3469
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3470
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3471
    superMenu notNil ifTrue:[
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3472
        p1 := self translateGrabPoint:0.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  3473
        p2 := superMenu translateGrabPoint:0.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3474
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3475
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3476
    isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3477
        (superMenu notNil and:[p1 x > p2 x]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3478
            backKey := #CursorRight
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3479
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3480
            backKey := #CursorLeft.
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3481
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3482
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3483
        (superMenu notNil and:[p1 y > p2 y]) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3484
            backKey := #CursorDown
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3485
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3486
            backKey := #CursorUp.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3487
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3488
    ].    
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3489
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3490
    aKey == backKey ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3491
        superMenu isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3492
            self accept:nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3493
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3494
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3495
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3496
            ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3497
                superMenu selection hideSubmenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3498
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3499
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3500
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3501
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3502
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3503
    selection isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3504
        superMenu isNil ifTrue:[^ self accept:nil].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3505
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3506
        superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3507
            superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3508
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3509
            (item := items findFirst:[:el| el canSelect]) notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3510
                self selectionIndex:item
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3511
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3512
        ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3513
        ^ self
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3514
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3515
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3516
    selection hasSubmenu ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3517
        (menu := selection visibleSubmenu) isNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3518
            selection toggleSubmenuVisibility
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3519
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3520
            menu selectionIndex:1
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3521
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3522
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3523
        superMenu notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3524
            superMenu verticalLayout ~~ isVrt ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3525
                superMenu handleCursorKey:aKey
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3526
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3527
        ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3528
            self accept:nil
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3529
        ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3530
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3531
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3532
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3533
handleKeyPress:key
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3534
    "any key is pressed"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3535
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3536
    |item inMenu|
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3537
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3538
    (key == #Return or:[key == Character space]) ifTrue:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3539
        self handleReturnPressed
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3540
    ] ifFalse:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3541
        key isCharacter ifTrue:[
1862
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3542
"/            selection notNil ifTrue:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3543
"/                inMenu := self
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3544
"/            ] ifFalse:[
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3545
"/                (inMenu := superMenu) isNil ifTrue:[^ self].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3546
"/            ].
ffbe4c06defd handleKeyPress: search character-key in wrapped menu
ca
parents: 1853
diff changeset
  3547
            inMenu := self.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3548
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3549
            (item := inMenu detectItemForKey:key) notNil ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3550
                inMenu selection:item
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3551
            ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3552
        ] ifFalse:[
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3553
            (     key == #CursorDown or:[key == #CursorUp
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3554
              or:[key == #CursorLeft or:[key == #CursorRight]]]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3555
            ) ifTrue:[
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3556
                self handleCursorKey:key
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3557
            ]
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3558
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3559
    ]
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  3560
!
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3561
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3562
handlePointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3563
    self  pointerEntersItem:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3564
    super pointerLeave:state
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3565
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3566
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3567
handleReturnPressed
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3568
    "any key is pressed"
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3569
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3570
    |sensor subm item|
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3571
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3572
    (item := selection) isNil ifTrue:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3573
        superMenu notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3574
            item := superMenu selection.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3575
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3576
            item value notNil ifTrue:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3577
                "/ is a delayed menu
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3578
                self accept:item
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3579
            ] ifFalse:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3580
                item toggleSubmenuVisibility
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3581
            ]
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3582
        ] ifFalse:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3583
            self accept
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3584
        ].
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3585
        ^ self
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3586
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3587
    selection hasSubmenu ifTrue:[
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3588
        selection hasDelayedMenu ifFalse:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3589
            selection toggleSubmenuVisibility.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3590
          ^ self
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3591
        ].
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3592
        subm := selection currentSubmenu.
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3593
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3594
        (subm notNil and:[subm shown]) ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3595
            selection toggleSubmenuVisibility.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  3596
          ^ self
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3597
        ].
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3598
        self openDelayed:nil
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3599
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3600
    self accept.
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3601
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3602
    " test for toggle "
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3603
    item isToggle ifTrue:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3604
        self selection:item.
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3605
    ] ifFalse:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3606
        (selection notNil and:[selection triggerOnDown]) ifFalse:[
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3607
            ^ self
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3608
        ]
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3609
    ].    
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3610
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3611
    (sensor := self sensor) isNil ifTrue:[
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3612
        ^ self
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3613
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3614
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3615
    [   
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3616
        sensor flushKeyboardFor:nil.
2238
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3617
        Delay waitForSeconds:0.1.
68ecae98bcd2 bug fix for toggles (buttun motion ...)
ca
parents: 2235
diff changeset
  3618
        sensor hasKeyPressEventFor:nil.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  3619
    ] whileTrue.
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3620
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  3621
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3622
pointerEntersItem:anItemOrNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3623
    "the pointer moves over an item or nil; restore the old item and
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3624
     redraw the new item highlighted."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3625
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3626
    |oldItem newItem|
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3627
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3628
    (     anItemOrNil notNil
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3629
     and:[anItemOrNil canSelect
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3630
     and:[selection isNil
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3631
     and:[self isPopUpView not]]]) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3632
        anItemOrNil isButton ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3633
            (    self buttonEnteredBackgroundColor ~= self buttonPassiveBackgroundColor
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3634
             or:[self buttonEnteredLevel ~= self buttonPassiveLevel]
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3635
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3636
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3637
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3638
        ] ifFalse:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3639
            (self enteredLevel ~~ 0 
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3640
              or:[self enteredBackgroundColor ~= self backgroundColor]
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  3641
            ) ifTrue:[
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3642
                newItem := anItemOrNil
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3643
            ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3644
        ]
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3645
    ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3646
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3647
    newItem ~~ enteredItem ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3648
        oldItem     := enteredItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3649
        enteredItem := newItem.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3650
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3651
        oldItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3652
            self invalidateItem:oldItem repairNow:(enteredItem isNil).
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3653
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3654
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3655
        enteredItem notNil ifTrue:[
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3656
            self invalidateItem:enteredItem repairNow:true.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3657
        ].
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3658
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3659
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3660
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3661
!MenuPanel methodsFor:'focus handling'!
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3662
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3663
canTab
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3664
    "depends whether I'am a toolbar and selectable items exists
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3665
    "
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3666
    |selectableItem|
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3667
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3668
    (super canTab and:[self isPopUpView not]) ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3669
        selectableItem := self firstItemSelectable.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3670
        ^ selectableItem notNil
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3671
    ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3672
    ^ false
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3673
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3674
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3675
focusComesByTab
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3676
    "returns true if focus comes by tab and should be drawn
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3677
    "
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3678
    |focusComesByTab|
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3679
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3680
    focusComesByTab := self menuAdornmentAt:#focusComesByTab.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3681
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3682
    focusComesByTab == true ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3683
        (shown and:[self hasFocus]) ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3684
            ^ true
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3685
        ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3686
        self menuAdornmentAt:#focusComesByTab put:false.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3687
    ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3688
    ^ false
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3689
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3690
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3691
focusComesByTab:aBoolean
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3692
    "only handled for toolBars"
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3693
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3694
    |selectableItem|
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3695
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3696
    (self supportsFocusOnTab and:[self isPopUpView not]) ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3697
        self menuAdornmentAt:#focusComesByTab put:aBoolean.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3698
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3699
        self hasSelection ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3700
            ^ self
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3701
        ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3702
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3703
        aBoolean ifTrue:[
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3704
            selectableItem := self firstItemSelectable.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3705
        ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3706
        self selection:selectableItem openMenu:false.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3707
    ].
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3708
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3709
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3710
hasKeyboardFocus:aBoolean
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3711
    "notification from the windowGroup that I got/lost the keyboard focus."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3712
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3713
    |focusView|
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3714
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3715
    self isPopUpView ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3716
        "/ not visible for popup menus
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3717
        ^ super hasKeyboardFocus:aBoolean
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3718
    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3719
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3720
    (aBoolean not and:[selection notNil]) ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3721
        hasImplicitGrap ~~ true ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3722
            focusView := windowGroup focusView.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3723
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3724
            focusView == self ifFalse:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3725
                self selection:nil.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3726
            ]
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3727
        ]
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3728
    ].            
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3729
    super hasKeyboardFocus:aBoolean.
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3730
!
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3731
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3732
showFocus:focusComesByTab
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3733
    self focusComesByTab:focusComesByTab.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3734
    super showFocus:focusComesByTab.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3735
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3736
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3737
showNoFocus:focusByTab
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3738
    self focusComesByTab:false.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3739
    super showNoFocus:focusByTab.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3740
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3741
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3742
supportsFocusOnTab
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3743
    "returns true if focus is supported
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3744
    "
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3745
    ^ (styleSheet at:#'focusHighlightStyle') == #win95
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3746
!
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3747
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3748
wantsFocusWithButtonPress
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3749
    "needs only the focus if I'am a toolbar; all events are delegated
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3750
     to my subMenus"
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3751
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  3752
    ^ self isPopUpView not
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3753
! !
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  3754
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3755
!MenuPanel methodsFor:'grabbing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3756
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3757
doGrab
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3758
    relativeGrabOrigin := nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3759
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3760
    superMenu notNil ifTrue:[
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3761
        superMenu doGrab
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3762
    ] ifFalse:[
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3763
        hasImplicitGrap ~~ true ifTrue:[
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3764
            self grabMouseAndKeyboard.
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3765
            hasImplicitGrap := true
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3766
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3767
    ]
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3768
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3769
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3770
doUngrab:forceDo
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3771
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3772
    relativeGrabOrigin := nil.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  3773
    self clearImplicitGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3774
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3775
    superMenu notNil ifTrue:[
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3776
        forceDo ifTrue:[
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3777
            superMenu doUngrab:true
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3778
        ].
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3779
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3780
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3781
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3782
    hasImplicitGrap ~~ true ifTrue:[
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3783
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3784
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3785
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3786
    forceDo ifFalse:[
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3787
        (selection notNil or:[prevFocusView == self]) ifTrue:[
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3788
            ^ self
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3789
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3790
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3791
    self ungrabMouseAndKeyboard.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3792
    self selection:nil.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3793
    hasImplicitGrap := nil.
1703
e127eff742bb bugfix: request focus
ca
parents: 1701
diff changeset
  3794
    prevFocusView   := nil.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3795
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3796
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3797
grabKeyboard
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3798
    "grap the keyboard; keep previous grab"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3799
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3800
    previousKeyboardGrab := device activeKeyboardGrab.
2713
9e417aa397c0 *** empty log message ***
ca
parents: 2712
diff changeset
  3801
    ^ super grabKeyboard
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3802
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3803
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3804
grabMouseAndKeyboard
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3805
    "get exclusive access to pointer and keyboard"
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3806
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3807
    |winGroup sensor|
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3808
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3809
    winGroup := self windowGroup.
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3810
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3811
    (realized and:[winGroup notNil]) ifTrue:[
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3812
        prevFocusView isNil ifTrue:[
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3813
             prevFocusView := winGroup focusView.
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3814
        ].
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3815
        sensor := self sensor.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3816
        device activePointerGrab ~~ self ifTrue:[
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3817
            sensor flushMotionEventsFor:nil.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3818
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3819
            (self grabPointer) ifFalse:[
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3820
                Delay waitForSeconds:0.1.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3821
                (self grabPointer) ifFalse:[
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3822
                    "give up"
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3823
                    'MenuPanel [warning]: could not grab pointer' errorPrintCR.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3824
                    self unmap
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3825
                ]
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3826
            ]
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3827
        ].
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3828
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3829
        device activeKeyboardGrab ~~ self ifTrue:[
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3830
            device sync.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3831
            sensor flushKeyboardFor:nil.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3832
            self grabKeyboard.
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2481
diff changeset
  3833
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3834
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3835
3158
fe0c2cb46fcb focus handling
ca
parents: 3148
diff changeset
  3836
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  3837
    "Modified: / 2.2.1998 / 23:43:59 / stefan"
1254
38b8bcfabbd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
  3838
    "Modified: / 15.3.1999 / 12:01:38 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3839
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3840
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3841
grabPointerWithCursor:aCursorOrNil
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3842
    "grap the pointer; keep previous grab"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3843
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3844
    previousPointerGrab := device activePointerGrab.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3845
    hasImplicitGrap := true.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3846
    ^ super grabPointerWithCursor:aCursorOrNil
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3847
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3848
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3849
ungrabKeyboard
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3850
    "ungrap the keyboard; restore previous grab"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3851
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3852
    super ungrabKeyboard.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3853
2579
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3854
    (previousKeyboardGrab notNil
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3855
    and:[ previousKeyboardGrab realized ]) ifTrue:[
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3856
        device grabKeyboardInView:previousKeyboardGrab.
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3857
    ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3858
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3859
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3860
ungrabMouseAndKeyboard
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3861
    "ungrab resources (mouse and keyboard)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3862
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3863
    self ungrabPointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3864
    self ungrabKeyboard.
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3865
!
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3866
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3867
ungrabPointer
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3868
    "ungrap the pointer; restore previous grab"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3869
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3870
    super ungrabPointer.
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  3871
2579
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3872
    (previousPointerGrab notNil
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3873
    and:[ previousPointerGrab realized ]) ifTrue:[
114e5cf689a2 care for previous-grab-window still being visible
james
parents: 2574
diff changeset
  3874
        device grabPointerInView:previousPointerGrab.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1613
diff changeset
  3875
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3876
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3877
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3878
!MenuPanel methodsFor:'help'!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3879
2058
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3880
flyByHelpTextAt:srcPoint
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3881
    "return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3882
     If there is a selection, that items helpText is used (ignoring the given point)."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3883
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3884
    self withMenuAndItemAt:srcPoint do:[:menu :item | ^ menu flyByHelpTextForItem:item].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3885
    ^ nil
2058
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3886
!
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3887
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3888
flyByHelpTextForItem:anItem
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3889
    "returns the helpText for an item (empty if none)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3890
2063
8bff9e49f1e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  3891
    anItem isNil ifTrue:[^ nil].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  3892
    ^ anItem flyByHelpText.
2058
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3893
!
f0a23f80454e flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
  3894
3402
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3895
flyByHelpTextForKey:aKey
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3896
    |app text|
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3897
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3898
    app := self application.
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3899
    app isNil ifTrue:[^ nil].
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3900
    text := self application flyByHelpTextForKey:aKey.
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3901
    text notNil ifTrue:[^ text].
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3902
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3903
    ^ nil.
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3904
!
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3905
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3906
helpText
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3907
    "return the helpText for the currently selected item (empty if none)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3908
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3909
    ^ self helpTextForItem:selection
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3910
!
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3911
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  3912
helpTextAt:srcPoint
1252
6db6906da49b debug print
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
  3913
    "return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3914
     If there is a selection, that items helpText is used (ignoreing the given point)."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3915
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3916
    self withMenuAndItemAt:srcPoint do:[:menu :item | ^ menu helpTextForItem:item].
2884
6e060df8f158 fix: MUST return nil, if there is no help text (not empty string !)
Claus Gittinger <cg@exept.de>
parents: 2883
diff changeset
  3917
    ^ nil
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3918
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3919
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  3920
helpTextForItem:anItem
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3921
    "returns the helpText for an item (empty if none)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3922
2884
6e060df8f158 fix: MUST return nil, if there is no help text (not empty string !)
Claus Gittinger <cg@exept.de>
parents: 2883
diff changeset
  3923
    anItem isNil ifTrue:[^ nil].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  3924
    ^ anItem activeHelpText.
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3925
!
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3926
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3927
withMenuAndItemAt:srcPoint do:aBlock
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3928
    |dstMenu dstPoint item|
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3929
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3930
    dstMenu := self detectMenuAtGrabPoint:srcPoint.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3931
    dstMenu notNil ifTrue:[
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3932
        dstPoint := dstMenu translateGrabPoint:srcPoint.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3933
        item := dstMenu itemAtPoint:dstPoint.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3934
        aBlock value:dstMenu value:item.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  3935
    ]
1251
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3936
! !
eb5b4cdbacde fixed helpText display;
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
  3937
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3938
!MenuPanel methodsFor:'image registration'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3939
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  3940
imageOnMyDevice:anImage
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3941
    "returns image registered on device"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3942
2770
d46f94ddabef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2768
diff changeset
  3943
    ^ self class image:anImage value onDevice:device
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3944
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3945
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3946
lightenedImageOnDevice:anImage
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3947
    "returns lightened image registered on device"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3948
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3949
    ^ self class lightenedImage:anImage onDevice:device
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3950
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  3951
1688
271829d6a2e4 category changes
Claus Gittinger <cg@exept.de>
parents: 1679
diff changeset
  3952
!MenuPanel methodsFor:'initialization & release'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3953
767
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3954
addToCurrentProject
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3955
    "ignored here"
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3956
!
ffa2a09a1039 added #addToCurrentProject in order to avoid restart errors
tz
parents: 746
diff changeset
  3957
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3958
create
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3959
    "create the shadow view for a none contained submenu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3960
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3961
    super create.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3962
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3963
    self isPopUpView ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3964
        (PopUpView shadowsOnDevice:device) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3965
            shadowView isNil ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3966
                shadowView := (ShadowView onDevice:device) for:self
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3967
            ] ifFalse:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3968
                self saveUnder:true.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3969
            ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3970
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3971
    ] ifFalse:[
3334
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  3972
        self hasExplicitExtent ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3973
            (self width) == (superView width) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3974
                self verticalLayout:false
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3975
            ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3976
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3977
    ]
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3978
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  3979
    "Modified: / 28.7.1998 / 02:11:44 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3980
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3981
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3982
destroy
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3983
    "destroy items and shadowView; remove dependencies"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3984
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  3985
    self clearLastActiveMenu.
2051
d958c12cc08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2050
diff changeset
  3986
    items notNil ifTrue:[items copy do:[:el|el destroy]].
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  3987
    items := nil.
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  3988
    self removeDependencies.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3989
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  3990
    super destroy.
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  3991
    prevFocusView := superMenu := nil.
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3992
    shadowView notNil ifTrue:[shadowView destroy].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3993
2051
d958c12cc08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2050
diff changeset
  3994
    "Modified: / 15.11.2001 / 17:08:45 / cg"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3995
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  3996
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  3997
fetchDeviceResources
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3998
    "fetch device colors, to avoid reallocation at redraw time"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  3999
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4000
    |style|
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4001
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4002
    superMenu notNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4003
        styleSheet := superMenu styleSheet
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4004
    ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4005
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4006
    super fetchDeviceResources.
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4007
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  4008
    "/ 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
  4009
    "/ (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
  4010
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4011
    superMenu isNil ifTrue:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4012
        rightArrow isNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4013
            rightArrow := SelectionInListView rightArrowFormOn:device.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  4014
        ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4015
        fgColor := fgColor onDevice:device.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4016
        style   := styleSheet name.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4017
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4018
        (style ~~ #os2 and:[style ~~ #win95 and:[style ~~ #winXP]]) ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4019
            rightArrowShadow := SelectionInListView rightArrowShadowFormOn:device
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4020
        ] ifFalse:[
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4021
            rightArrowShadow := nil
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4022
        ].
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4023
    ] ifFalse:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4024
        rightArrow       := superMenu rightArrow.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4025
        rightArrowShadow := superMenu rightArrowShadow.
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4026
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4027
        self foregroundColor:(superMenu foregroundColor).
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  4028
        self             font:(superMenu font).
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4029
"/        self  viewBackground:(superMenu viewBackground).
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  4030
    ].
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  4031
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  4032
    items notNil ifTrue:[
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4033
        items do:[:eachItem| eachItem fetchDeviceResources ]
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  4034
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  4035
1137
7df0b776e47a fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
  4036
    "Modified: / 15.9.1998 / 12:51:29 / cg"
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4037
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4038
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4039
initStyle
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4040
    "initialize style specific stuff"
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4041
2919
0c83b23cb6c6 resource directive
Claus Gittinger <cg@exept.de>
parents: 2895
diff changeset
  4042
    <resource: #style (#'menu.buttonItemHorizontalSpace' #'menu.buttonItemSpace'
0c83b23cb6c6 resource directive
Claus Gittinger <cg@exept.de>
parents: 2895
diff changeset
  4043
                       #'menu.buttonItemVerticalSpace'   #'menu.itemSpace'
0c83b23cb6c6 resource directive
Claus Gittinger <cg@exept.de>
parents: 2895
diff changeset
  4044
                       #'menu.itemHorizontalSpace'       
0c83b23cb6c6 resource directive
Claus Gittinger <cg@exept.de>
parents: 2895
diff changeset
  4045
                       #'popup.hideOnRelease'
0c83b23cb6c6 resource directive
Claus Gittinger <cg@exept.de>
parents: 2895
diff changeset
  4046
                       )>
2609
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
  4047
    |fn|
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
  4048
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4049
    super initStyle.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4050
2883
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4051
    buttonInsetX := styleSheet at:#'menu.buttonItemHorizontalSpace'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4052
    buttonInsetX isNil ifTrue:[ buttonInsetX := styleSheet at:#'menu.buttonItemSpace' default:0 ].
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4053
    buttonInsetX := buttonInsetX abs.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4054
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4055
    buttonInsetY := styleSheet at:#'menu.buttonItemVerticalSpace'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4056
    buttonInsetY isNil ifTrue:[ buttonInsetY := styleSheet at:#'menu.buttonItemSpace' default:0 ].
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4057
    buttonInsetY := buttonInsetY abs.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4058
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4059
    itemSpace := styleSheet at:#'menu.itemHorizontalSpace'.
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4060
    itemSpace isNil ifTrue:[ itemSpace := styleSheet at:#'menu.itemSpace' default:[ font widthOf:' '] ].
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4061
58f2f296254d defaults
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  4062
2609
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
  4063
    fgColor := DefaultForegroundColor ? Color black.
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
  4064
    DefaultBackgroundColor notNil ifTrue:[ viewBackground := DefaultBackgroundColor ].
b927f450c4c8 *** empty log message ***
ca
parents: 2607
diff changeset
  4065
    fn := self class defaultFont.
2610
a30fc1fb35d7 *** empty log message ***
ca
parents: 2609
diff changeset
  4066
    fn notNil ifTrue:[ self font:fn ].
1923
530426a3d692 support #level:
ca
parents: 1922
diff changeset
  4067
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4068
    defaultHideOnRelease := styleSheet at:#'popup.hideOnRelease' default:true.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4069
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4070
    self updateLevelAndBorder.
580
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4071
!
249f6cfc5bb2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
  4072
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4073
initialize
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4074
    "set default configuration"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4075
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4076
    super initialize.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  4077
2877
6f7df547445b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2871
diff changeset
  4078
    self enableMotionEvents.  "/ for flyByHelp
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  4079
    enabled := true.
1877
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  4080
    self extentChangedFlag:false.
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
  4081
    self originChangedFlag:false.
3334
50374a42b3d9 use accessors for hiddenOnrealize and explicitExtent
Claus Gittinger <cg@exept.de>
parents: 3332
diff changeset
  4082
    "/ explicitExtent      := nil.
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4083
    shortKeyInset       := 0.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4084
    mustRearrange       := false.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4085
    showSeparatingLines := false.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4086
    showGroupDivider    := true.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4087
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4088
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  4089
map
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  4090
    "grab the pointer here, when visible (but not if control has already been lost). 
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4091
     If the grab fails, try again and unmap myself if that fails too."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4092
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4093
    |loIndices loItems|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4094
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4095
    enteredItem := nil.
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  4096
1024
28c87a2369f6 show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
  4097
    self enableMotionEvents.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4098
    self becomesActiveMenu.
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  4099
    super map.
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4100
    self addDependencies.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4101
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  4102
    loIndices := InitialSelectionQuerySignal query.
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4103
    loItems   := items ? #[].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4104
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4105
    loItems do:[:anItem| anItem fetchImages ].
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4106
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4107
    self isPopUpView ifTrue:[
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4108
        self doGrab
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4109
    ] ifFalse:[
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4110
        super viewBackground:(self backgroundColor).
717
540e638fdebb Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 712
diff changeset
  4111
    ].
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4112
    loItems do:[:el| el updateIndicators ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4113
1785
efa4cc8ca917 mnemonic behaviour changed
ca
parents: 1775
diff changeset
  4114
    loIndices size > 0 ifTrue:[
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4115
        self redrawX:0 y:0 width:width height:height.
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4116
        self openMenusFromItemIndices:loIndices.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4117
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4118
1177
cfd7f71639f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
  4119
    "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
  4120
    "Modified: / 18.3.1999 / 18:22:18 / stefan"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4121
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4122
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4123
realize
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4124
    "realize menu and shadowView"
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  4125
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4126
    |bgColor|
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4127
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4128
    self isPopUpView ifTrue:[
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4129
        bgColor := styleSheet colorAt:'menu.backgroundColor'.
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4130
        bgColor notNil ifTrue:[ self viewBackground:bgColor ].
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  4131
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4132
        "Because of #saveUnder of ShadowView the order of realize is significant:
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4133
         shadowView must be realized before self"
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4134
        self hiddenOnRealize:true.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4135
        super realize.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4136
        self resize.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4137
        self makeFullyVisible.
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4138
"/        self mustRearrange.
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4139
        shadowView notNil ifTrue:[
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4140
            shadowView realize.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4141
        ].
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4142
        self raise.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4143
        self map.
736
220741d8049b Use #saveUnder.
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  4144
    ] ifFalse:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4145
        super realize.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4146
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4147
    self allSubViewsDo:[:aView| aView realize ].
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4148
    hideOnRelease := defaultHideOnRelease.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4149
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4150
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4151
recreate
1832
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
  4152
    "this is called after a snapin or a migration.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4153
     If the image was saved with an active menu, hide the menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4154
1455
5685ec322a5b sizeChanged:...
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
  4155
    selection := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4156
    super recreate.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4157
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4158
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4159
reinitStyle
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4160
    "handle style change while being open (win32 only - for now)"
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4161
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4162
    super reinitStyle.
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4163
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4164
    self fetchDeviceResources.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4165
    self mustRearrange.      "/ care for changed font sizes etc.
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4166
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4167
    self do:[:anItem |
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4168
        anItem reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4169
    ].
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4170
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4171
    "Created: / 10.9.1998 / 21:37:05 / cg"
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  4172
    "Modified: / 17.8.2000 / 18:01:33 / cg"
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4173
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  4174
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4175
unmap
1330
63d2fe5ebd48 comment
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
  4176
    "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
  4177
     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
  4178
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4179
    mapTime := nil.
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4180
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  4181
    self removeDependencies.
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4182
    self clearLastActiveMenu.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4183
    self doUngrab:(superMenu isNil).
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4184
"/    self isPopUpView ifTrue:[
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4185
"/         self doUngrab:(superMenu isNil)
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4186
"/    ].
3142
4f1c952048c5 focusView handling
ca
parents: 3133
diff changeset
  4187
    prevFocusView := nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4188
    super unmap.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4189
    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
  4190
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4191
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4192
updateLevelAndBorder
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4193
    "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
  4194
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4195
    |bw lvl|
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4196
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4197
    self isPopUpView ifTrue:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4198
        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
  4199
        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
  4200
    ] ifFalse:[
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4201
        bw  := styleSheet is3D ifFalse:[1] ifTrue:[0].
2372
d136f6d4b7c5 bugfix if font is nil
ca
parents: 2364
diff changeset
  4202
        lvl := styleSheet at:#'pullDownMenu.level' default:1.
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4203
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4204
    self borderWidth:bw.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  4205
    self level:lvl.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4206
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4207
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4208
!MenuPanel methodsFor:'keyboard control'!
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4209
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4210
mnemonicViewNext:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4211
    "a  mnemonicKey event as forwarded from the keyboardProcessor - if there
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4212
     is the mnemonic-key defined for any menuItem, handle the menuItem and
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4213
     return the topMenu otherwise nil."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4214
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4215
    |menu uKey lKey list index accessCharacterMatchQuery maxShortCutSearchLevel|
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4216
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4217
    superMenu notNil ifTrue:[ ^ superMenu mnemonicViewNext:aKeyEvent ].
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4218
    shown ifFalse:[^ nil].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4219
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4220
    uKey := aKeyEvent rawKey last asUppercase.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4221
    lKey := uKey asLowercase.
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4222
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4223
    accessCharacterMatchQuery := [:el|
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4224
                                    |k| 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4225
                                    k := el accessCharacter. 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4226
                                    k == uKey or:[k == lKey]
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4227
                                 ].
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4228
    maxShortCutSearchLevel := self class maxShortCutSearchLevel.
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4229
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4230
    selection notNil ifTrue:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4231
        "first lookup the current grapMenu before starting in the topMenu
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4232
        "
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4233
        menu := self detectGrabMenu.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4234
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4235
        [ menu ~~ self ] whileTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4236
            index := menu selectionIndex.
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4237
            list  := menu 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4238
                        selectItemIndicesFor:accessCharacterMatchQuery
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4239
                        maxDepth:maxShortCutSearchLevel from:(index + 1) to:99999
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4240
                        ignoreSubmenuBlock:[:anItem| anItem ignoreMnemonicKeys ].
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4241
        
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4242
            list size ~~ 0 ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4243
                "/ has item which responds to the mnemonic
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4244
                menu processCollectedIndices:list.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4245
                ^ self
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4246
            ].
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4247
            menu := menu superMenu.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4248
        ].
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4249
        index := self selectionIndex.
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4250
        list  := self 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4251
                    selectItemIndicesFor:accessCharacterMatchQuery
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4252
                    maxDepth:maxShortCutSearchLevel from:(1 + index) to:99999
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4253
                    ignoreSubmenuBlock:[:anItem| anItem ignoreMnemonicKeys ].
2603
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4254
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4255
    ] ifFalse:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4256
        index := 99999.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4257
        list  := nil.
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4258
    ].    
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4259
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4260
    list isNil ifTrue:[
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4261
        list := self 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4262
                    selectItemIndicesFor:accessCharacterMatchQuery
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4263
                    maxDepth:maxShortCutSearchLevel from:1 to:index
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4264
                    ignoreSubmenuBlock:[:anItem| anItem ignoreMnemonicKeys ].
2603
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4265
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4266
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4267
        list isNil ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4268
            "/ must clear existing selection
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4269
            self selection:nil.
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4270
            ^ nil
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4271
        ]
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4272
    ].
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4273
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4274
    "/ has item which responds to the mnemonic
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4275
    self processCollectedIndices:list.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4276
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4277
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4278
openMenusFromItemIndices:anItemIndiceList
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4279
    "open all menus derived from sequence of item indices"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4280
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4281
    |item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4282
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4283
    anItemIndiceList size == 0 ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  4284
        ^ self
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4285
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4286
    item := self itemAt:(anItemIndiceList removeFirst).
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4287
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4288
    (item notNil and:[item enabled]) ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  4289
        InitialSelectionQuerySignal answer:anItemIndiceList do:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  4290
            self selection:item openMenu:true.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  4291
        ]
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4292
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4293
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4294
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4295
processCollectedIndices:indices
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4296
    |menu item|
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4297
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4298
    indices size == 0 ifTrue:[
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4299
        ^ self
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4300
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4301
    menu := self.
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4302
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4303
    "/ first lookup in current open submenus
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4304
    [menu selectionIndex == indices first] whileTrue:[
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4305
        (    (item := menu selection) isNil
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4306
         or:[(menu := item currentSubmenu) isNil]
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4307
        ) ifTrue:[ "/ selected but no submenu open - not handled
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4308
            ^ self
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4309
        ].
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4310
        indices removeFirst.
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4311
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4312
        indices isEmpty ifTrue:[
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4313
           menu selection:nil.
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4314
         ^ self
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4315
        ]
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4316
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4317
    menu openMenusFromItemIndices:indices.
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4318
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4319
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4320
processShortcut:aKeyEvent
2926
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4321
    "a shortcutKey event as forwarded from the keyboardProcessor.
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4322
     If there is a shortcut-key defined, process it and return true.
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4323
     Otherwise return false."
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4324
3394
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4325
    |menu rKey lKey list item selectableItem|
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4326
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4327
    superMenu notNil ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4328
        ^ superMenu processShortcut:aKeyEvent
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4329
    ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4330
    shown ifFalse:[^ false].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4331
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4332
    lKey := aKeyEvent key.
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4333
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4334
    "/ fast check, cursor keys are not supported
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4335
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4336
    ( #( CursorDown CursorUp CursorRight CursorLeft Return Escape
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4337
       ) includes:lKey
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4338
    ) ifTrue:[
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4339
        ^ false.
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4340
    ].
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4341
    rKey := aKeyEvent rawKey.
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4342
    item := nil.
3328
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  4343
    menu := self detectGrabMenu. "/ first lookup the current grabMenu before starting in the topMenu
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4344
3394
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4345
    "/ special for Cmd-only event (i.e. ALT-only)
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4346
    aKeyEvent isKeyReleaseEvent ifTrue:[
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4347
        selection isNil ifTrue:[
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4348
            prevFocusView := self windowGroup focusView.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4349
            self requestFocus. "/ self windowGroup focusView:self.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4350
            selectableItem := self firstItemSelectable.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4351
            self selection:selectableItem openMenu:false.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4352
        ] ifFalse:[
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4353
            prevFocusView requestFocus.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4354
            self selection:nil.
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4355
        ].
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4356
        ^ true
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4357
    ].
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4358
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4359
    [true] whileTrue:[
2926
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4360
        list := menu 
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4361
                    selectItemIndicesFor:[:el|
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4362
                        |skey|
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4363
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4364
                        item := el.
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4365
                        el ignoreShortcutKeys ifTrue:[
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4366
                            false    
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4367
                        ] ifFalse:[
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4368
                            skey := el shortcutKey.
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4369
                            skey == rKey or:[skey == lKey]
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4370
                        ]
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4371
                    ]
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4372
                    maxDepth:(self class maxShortCutSearchLevel) from:1 to:99999
2926
0d6dc899b49f ignoreShortcutKeys also blocks individual items
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
  4373
                    ignoreSubmenuBlock:[:anItem | anItem ignoreShortcutKeys ].
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4374
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4375
        list size ~~ 0 ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4376
            "/ has item which responds to the shortcut
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4377
            item hasSubmenu ifFalse:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4378
                menu accept:item
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4379
            ] ifTrue:[
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4380
                menu processCollectedIndices:list.
3394
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4381
                self requestFocus. "/ self windowGroup focusView:self.
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4382
            ].
3394
90e7bc4402b5 Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents: 3384
diff changeset
  4383
            ^ true
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4384
        ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4385
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4386
        menu == self ifTrue:[ ^ false ].
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4387
        menu := self.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4388
    ].
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  4389
    ^ false     "/ never reached
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4390
!
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4391
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4392
selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth from:aStart to:aStop ignoreSubmenuBlock:ignoreSubmenueBlock
2603
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4393
    "returns the sequence of indices up to the item for which the block returns true.
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4394
     The first entry is the topmenu, the last entry the item for which the block returns
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4395
     true. If no item is detected, nil is returned.
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4396
     If the ignoreSubmenueBlock is not nil, the menu under the item (argument to the block)
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4397
     is created and passed through if the block returns false.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4398
     Otherwise the item is not asked for its submenu."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4399
2112
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4400
    |start stop|
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4401
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4402
    maxDepth <= 0 ifTrue:[^ nil].
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4403
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4404
    start := aStart max:1.
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4405
    stop  := aStop  min:(items size).
c4cd07f21fac processing mnemonic's (search next from current)
ca
parents: 2111
diff changeset
  4406
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4407
    start to:stop do:[:i| |item menu result|
2603
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4408
        item := items at:i.
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4409
        (item enabled and:[item isVisible]) ifTrue:[
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4410
            (aOneArgBlock value:item) ifTrue:[
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4411
                ^ OrderedCollection with:i
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4412
            ].
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4413
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4414
            maxDepth > 1 ifTrue:[
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4415
                (item hasSubmenu and:[item hasDelayedMenu not]) ifTrue:[
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4416
                    (ignoreSubmenueBlock isNil or:[(ignoreSubmenueBlock value:item) not]) ifTrue:[
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  4417
                        menu := item setupSubmenu.
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4418
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4419
                        (menu notNil and:[menu isEnabled]) ifTrue:[
3363
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4420
                            result := menu 
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4421
                                        selectItemIndicesFor:aOneArgBlock
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4422
                                        maxDepth:(maxDepth - 1) from:1 to:99999
33e881abd5b2 accelerator search limited to 2-levels;
Claus Gittinger <cg@exept.de>
parents: 3360
diff changeset
  4423
                                        ignoreSubmenuBlock:ignoreSubmenueBlock.
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4424
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4425
                            result notNil ifTrue:[
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4426
                                result addFirst:i.
3128
9b92638bbd58 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  4427
                                ^ result
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4428
                            ].
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4429
                        ].
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4430
                    ].
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4431
                ].
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  4432
            ].
2603
edb5408fd3e7 prepared to test an item whether the submenu should be created caused by mnemonic or accelorator key
ca
parents: 2579
diff changeset
  4433
        ].
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4434
    ].
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4435
    ^ nil
3128
9b92638bbd58 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  4436
9b92638bbd58 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  4437
    "Modified: / 18-10-2006 / 10:30:00 / cg"
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  4438
! !
1878
1afc5cdf3002 mnemonic-key and shortcut-key support;
ca
parents: 1877
diff changeset
  4439
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4440
!MenuPanel methodsFor:'misc'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4441
427
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4442
raiseDeiconified
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4443
    ^ self raise
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4444
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4445
    "Created: 21.6.1997 / 13:29:12 / cg"
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4446
!
82cbad72e197 raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
  4447
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4448
superMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4449
    "returns supermenu or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4450
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4451
    ^ superMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4452
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4453
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4454
topMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4455
    "returns the topMenu; the one having no superMenu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4456
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4457
    |menu smenu|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4458
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4459
    menu := self.
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4460
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4461
    [(smenu := menu superMenu) notNil] whileTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4462
        menu := smenu
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4463
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  4464
    ^ menu
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4465
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4466
1825
962390f1b499 category change
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
  4467
!MenuPanel methodsFor:'printing & storing'!
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4468
3360
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4469
printOn:aStream
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4470
    |label|
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4471
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4472
    aStream nextPutAll:'Menu:'.
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4473
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4474
    self do:[:eachItem|
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4475
        label  := eachItem label.
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4476
        label notEmptyOrNil ifTrue:[
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4477
            aStream nextPutAll:'  '.
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4478
            label printOn:aStream.
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4479
        ].
f329bc4a2254 Define #printOn: for each method defining #printString
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
  4480
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4481
! !
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4482
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4483
!MenuPanel methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4484
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4485
application
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4486
    "optimize access to retrive the application"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4487
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4488
    application notNil ifTrue:[^ application ].
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4489
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4490
    superMenu notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4491
        application := superMenu application.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4492
        ^ application
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4493
    ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4494
    application := super application.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4495
    ^ application
1872
b20e27632fd8 application fetch fix
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
  4496
!
434
9898a2909ef0 add active help for items
ca
parents: 433
diff changeset
  4497
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4498
detectItemForKey:aKey
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4499
    "returns the item assigned to a key, accessCharacter or starts with.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4500
     if no item is detected nil is returned."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4501
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4502
    |cIdx uKey lKey item|
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4503
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4504
    items isNil ifTrue:[^ nil].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4505
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4506
    cIdx := self selectionIndex.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4507
    uKey := aKey asUppercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4508
    lKey := aKey asLowercase.
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4509
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4510
    items keysAndValuesDo:[:anIndex :anItem| |char label|
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4511
        (     anIndex ~~ cIdx
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4512
         and:[anItem canSelect
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4513
         and:[(label := anItem textLabel) notNil
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4514
         and:[label size ~~ 0]]]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4515
        ) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4516
            (char := anItem accessCharacter) notNil ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4517
                (char == uKey or:[char == lKey]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4518
                    ^ anItem
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4519
                ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4520
            ] ifFalse:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4521
                char := label at:1.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4522
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4523
                (char == uKey or:[char == lKey]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4524
                    anIndex > cIdx ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4525
                        ^ anItem
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4526
                    ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4527
                    item isNil ifTrue:[item := anItem]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4528
                ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4529
            ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4530
        ]
1572
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4531
    ].
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4532
    ^ item
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4533
!
80a8e8a38fb1 ca: bugfix
ca
parents: 1499
diff changeset
  4534
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4535
menuAdornmentAt:aSymbol
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4536
    "returns a value derived from adornment"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4537
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4538
    adornment isNil ifTrue:[^ nil].
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4539
    ^ adornment at:aSymbol ifAbsent:nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4540
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4541
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  4542
menuAdornmentAt:aSymbol put:something
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4543
    "sets a value for the specific menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4544
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4545
    |oldValue|
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4546
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4547
    adornment isNil ifTrue:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4548
        something isNil ifTrue:[^ self].
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4549
        adornment := IdentityDictionary new.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4550
    ] ifFalse:[
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4551
        oldValue := adornment at:aSymbol ifAbsent:nil.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  4552
        oldValue == something ifTrue:[^ self].
653
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4553
    ].
cf9b6ef11ade bug fix; no automatic rearrange of items
ca
parents: 650
diff changeset
  4554
    adornment at:aSymbol put:something.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4555
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4556
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4557
onEachPerform:aSelector withArgList:aList
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4558
    "on each item perform selector with an argument derived from aList"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4559
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4560
    aList isCollection ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4561
        items size >= aList size ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4562
            aList keysAndValuesDo:[:anIndex :anArg|
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4563
                (items at:anIndex) perform:aSelector with:anArg
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4564
            ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4565
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4566
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4567
        self do:[:anItem| anItem perform:aSelector with:aList ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4568
    ]
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4569
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4570
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  4571
registerImageOnDevice:anImage
2269
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4572
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4573
    anImage isNil ifTrue:[ ^ nil ].
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4574
  ^ self class image:anImage onDevice:device
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4575
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4576
"/    |image|
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4577
"/
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4578
"/    (image := anImage) notNil ifTrue:[
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4579
"/        image device ~~ device ifTrue:[
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4580
"/            image := image copy.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4581
"/        ].
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4582
"/        image := image onDevice:device.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4583
"/        image := image clearMaskedPixels.
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4584
"/    ].
e250e3adfc56 registration of images
ca
parents: 2255
diff changeset
  4585
"/    ^ image
2355
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4586
!
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4587
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4588
superMenu:aSuperMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4589
    "set my supermenu from which i'am activated"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4590
2355
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4591
    superMenu := aSuperMenu.
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4592
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  4593
    superMenu notNil ifTrue:[
2355
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4594
        styleSheet       := superMenu styleSheet.
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4595
        rightArrow       := superMenu rightArrow.
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4596
        rightArrowShadow := superMenu rightArrowShadow.
cd91ed4dc4c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
  4597
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4598
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4599
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4600
!MenuPanel methodsFor:'private-activation'!
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4601
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4602
activeMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4603
    "returns the current active menu or self (the top menu)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4604
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4605
    ^ lastActiveMenu ? self
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4606
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4607
    "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
  4608
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4609
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4610
activeMenu:aMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4611
    "set the current active menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4612
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4613
    lastActiveMenu := aMenu
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4614
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4615
    "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
  4616
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4617
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4618
becomesActiveMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4619
    "submenu becomes the active menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4620
3224
96aba140912d bugfix for mapTime
ca
parents: 3222
diff changeset
  4621
    mapTime isNil ifTrue:[
96aba140912d bugfix for mapTime
ca
parents: 3222
diff changeset
  4622
        "/ set the mapTime if not yet done
96aba140912d bugfix for mapTime
ca
parents: 3222
diff changeset
  4623
        mapTime := AbsoluteTime now.
96aba140912d bugfix for mapTime
ca
parents: 3222
diff changeset
  4624
    ].
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4625
    self topMenu activeMenu:self.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4626
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4627
    "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
  4628
!
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4629
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4630
clearLastActiveMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4631
    "reset the current active menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4632
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4633
    |top|
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4634
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4635
    top := self topMenu.
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4636
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4637
"/    prevFocusView notNil ifTrue:[
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4638
"/        self windowGroup focusView:prevFocusView.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4639
"/        prevFocusView := nil.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4640
"/    ].
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4641
"/
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4642
    top activeMenu == self ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  4643
        top activeMenu:nil
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4644
    ]
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4645
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4646
    "Created: / 27.2.1998 / 17:41:17 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4647
!
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4648
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4649
mapTime
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4650
    "get the time the menu was activated or nil"
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4651
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4652
    ^ mapTime
798
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4653
74f4e7b66a46 ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  4654
    "Modified: / 27.2.1998 / 17:41:18 / cg"
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4655
!
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4656
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4657
mapTime:aTimestamp
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4658
    "set the time the menu was activated"
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4659
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4660
    mapTime := aTimestamp.
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4661
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  4662
    "Modified: / 27.2.1998 / 17:41:18 / cg"
687
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4663
! !
23ce9888d76f bug fixes:
ca
parents: 681
diff changeset
  4664
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4665
!MenuPanel methodsFor:'private-scrolling'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4666
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4667
hasScrollerAt:aDirection
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4668
    "returns true if a visible scroller at a direction exists"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4669
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4670
    |layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4671
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4672
    self hasScrollers ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4673
        ^ false
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4674
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4675
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4676
    aDirection == #PREV ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4677
        layout := items first layout.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4678
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4679
      ^ self verticalLayout ifTrue:[ layout top  < margin]
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4680
                           ifFalse:[ layout left < margin]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4681
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4682
    layout := items last layout.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4683
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4684
  ^ self verticalLayout ifTrue:[ layout bottom > (height - margin)]
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4685
                       ifFalse:[ layout right  > (width  - margin)]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4686
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4687
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4688
hasScrollers
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4689
    "returns true if scrollers are needed"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4690
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4691
    |maxExtent first last isVert|
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4692
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4693
    (mustRearrange or:[items size <= 1]) ifTrue:[^ false].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4694
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4695
    isVert := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4696
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4697
    superView notNil ifTrue:[
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4698
        ((first := items first layout) isNil
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4699
         or:[(last  := items last layout) isNil]
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4700
        ) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4701
            ^ false
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4702
        ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4703
        isVert ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4704
            ^ first top < 0 or:[last bottom > height]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4705
        ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4706
        ^ first left < 0 or:[last right > width]
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4707
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4708
    maxExtent := self maxExtent.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4709
    isVert ifTrue:[
2729
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4710
        ^ (height >= maxExtent y)
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4711
    ].
d28bc8243494 Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents: 2715
diff changeset
  4712
    ^ (width >= maxExtent x)
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4713
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4714
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4715
indexOfItemAtScroller:aDirection
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4716
    "returns the index of the item under the scroller or 0"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4717
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4718
    |bounds min max layout|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4719
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  4720
    self hasScrollers ifFalse:[ ^ 0 ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4721
    bounds := self scrollerBoundsAt:aDirection.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4722
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4723
    self verticalLayout ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4724
        min := bounds top.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4725
        max := bounds bottom.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4726
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4727
        items keysAndValuesDo:[:anIndex :anItem|
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4728
            anItem isVisible ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4729
                layout := anItem layout.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4730
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4731
                (layout top < max and:[layout bottom > min]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4732
                    ^ anIndex
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4733
                ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4734
            ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4735
        ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4736
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4737
        min := bounds left.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4738
        max := bounds right.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4739
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4740
        items keysAndValuesDo:[:anIndex :anItem|
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4741
            anItem isVisible ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4742
                layout := anItem layout.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4743
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4744
                (layout left < max and:[layout right > min]) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4745
                    ^ anIndex
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4746
                ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4747
            ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4748
        ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4749
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4750
    ^ 0
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4751
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4752
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4753
makeItemVisible:anItem
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4754
    "make an item visible"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4755
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4756
    |boundsPREV boundsNEXT delta layout index scr0 scr1 windowSz scrSz doScroll
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4757
     isVertical boundsMin layoutMin boundsMax layoutMax dltOrg
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4758
     inv1 inv2|
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4759
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4760
    (     anItem notNil
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4761
     and:[self hasScrollers
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4762
     and:[(layout := anItem layout) notNil]]
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4763
    ) ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4764
        ^ self
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4765
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4766
    index      := self indexOfItem:anItem.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4767
    boundsPREV := self scrollerBoundsAt:#PREV.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4768
    boundsNEXT := self scrollerBoundsAt:#NEXT.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4769
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4770
    isVertical := self verticalLayout.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4771
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4772
    isVertical ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4773
        boundsMin := boundsPREV bottom.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4774
        boundsMax := boundsNEXT top.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4775
        layoutMin := layout top.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4776
        layoutMax := layout bottom.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4777
        windowSz  := height.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4778
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4779
        boundsMin := boundsPREV right.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4780
        boundsMax := boundsNEXT left.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4781
        layoutMin := layout left.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4782
        layoutMax := layout right.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4783
        windowSz  := width.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4784
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4785
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4786
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4787
    layoutMin < boundsMin ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4788
        layoutMin >= 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4789
            ^ self
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4790
        ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4791
        "/ test whether is first visible item
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4792
        index := items findLast:[:el| el isVisible] startingAt:(index - 1).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4793
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4794
        index == 0 ifTrue:[ scr0 := margin ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4795
                  ifFalse:[ scr0 := boundsMin ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4796
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4797
        delta := layoutMin negated + scr0.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4798
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4799
        layoutMax > boundsMax ifFalse:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4800
            ^ self
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4801
        ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4802
        "/ test whether is last visible item
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4803
        index  := items findFirst:[:el| el isVisible ] startingAt:(index + 1).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4804
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4805
        index == 0 ifTrue:[ scr0 := windowSz - margin ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4806
                  ifFalse:[ scr0 := boundsMax ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4807
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4808
        delta := scr0 - layoutMax.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4809
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4810
    delta == 0 ifTrue:[ ^ self ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4811
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4812
    doScroll := false.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4813
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4814
    shown ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4815
        delta abs < (windowSz / 2) ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4816
            doScroll := true.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4817
            self repairDamage
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4818
        ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4819
    ].
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4820
    isVertical ifTrue:[ dltOrg := 0@delta ] ifFalse:[dltOrg := delta@0].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4821
    items do:[:el| el moveBy:dltOrg ].
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4822
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4823
    doScroll ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4824
        self invalidate.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4825
        ^ self
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4826
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4827
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4828
    windowSz  := windowSz - margin - margin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4829
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4830
    scr0  := boundsMin.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4831
    scr1  := scr0 + delta abs.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4832
    scrSz := boundsMax - scr1.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4833
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  4834
    delta < 0 ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4835
        isVertical ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4836
            self copyFrom:self x:margin y:scr1 toX:margin y:scr0
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4837
                           width:windowSz height:scrSz async:false.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4838
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4839
            scr1 := scr0 + scrSz.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4840
            inv2 := (margin @ scr1) extent:(windowSz @ (height - scr1 - margin)).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4841
            "/ self invalidateX:margin y:scr1 width:windowSz height:(height - scr1 - margin).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4842
        ] ifFalse:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4843
            self copyFrom:self x:scr1 y:margin toX:scr0 y:margin
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4844
                           width:scrSz height:windowSz async:false.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4845
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4846
            scr1 := scr0 + scrSz.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4847
            inv2 := (scr1 @ margin) extent:((width - scr1 - margin) @ windowSz).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4848
            "/ self invalidateX:scr1 y:margin width:(width - scr1 - margin) height:windowSz.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4849
        ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4850
        inv1 := boundsPREV.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4851
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4852
        isVertical ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4853
            self copyFrom:self x:margin y:scr0 toX:margin y:scr1
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4854
                           width:windowSz height:scrSz async:false.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4855
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4856
            inv2 := (margin @ margin) extent:(windowSz @ (scr1 - margin)).
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4857
            "/ self invalidateX:margin y:margin width:windowSz height:scr1 - margin.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4858
        ] ifFalse:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4859
            self copyFrom:self x:scr0 y:margin toX:scr1 y:margin
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4860
                           width:scrSz height:windowSz async:false.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4861
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4862
            inv2 := (margin @ margin) extent:(scr1 - margin) @ windowSz.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4863
            "/ self invalidateX:margin y:margin width:scr1 - margin height:windowSz.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4864
        ].
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
  4865
        inv1 := boundsNEXT.
2042
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4866
    ].
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4867
    self invalidate:inv1.
cc2141b4117f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2041
diff changeset
  4868
    self invalidate:inv2.
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4869
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  4870
    "Modified: / 13.11.2001 / 20:26:42 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4871
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4872
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4873
scrollActivity
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4874
    "returns the one and only scrollActivity - data holder
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4875
     for a menu and all contained submenus"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4876
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4877
    superMenu notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4878
        ^ superMenu scrollActivity
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4879
    ].
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4880
    scrollActivity isNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4881
        scrollActivity := ScrollActivity new.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4882
    ].
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4883
    ^ scrollActivity
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4884
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4885
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4886
scrollerBoundsAt:aDirection
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  4887
    "returns the bounds of the scroller at a direction"
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4888
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4889
    |y x w h inset|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4890
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4891
    inset := 0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4892
    x := y := inset.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4893
    w := h := 15.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4894
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4895
    self verticalLayout ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4896
        aDirection == #NEXT ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4897
            y := height - h - inset.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4898
        ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4899
        w := width - inset - inset.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4900
    ] ifFalse:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4901
        aDirection == #NEXT ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4902
            x := width - w - inset.       
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4903
        ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4904
        h := height - inset - inset.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4905
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4906
    ^ Rectangle left:x top:y width:w height:h
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4907
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4908
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4909
scrollerDirectionAtPoint:aPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4910
    "returns the scroller-direction at aPoint, or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4911
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4912
    self hasScrollers ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4913
        #( PREV NEXT ) do:[:aDirection| |bounds|
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  4914
            bounds := self scrollerBoundsAt:aDirection.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  4915
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  4916
            (bounds containsPoint:aPoint) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4917
                ^ (self hasScrollerAt:aDirection) ifTrue:[aDirection] ifFalse:[nil]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4918
            ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4919
        ]
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4920
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4921
    ^ nil
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4922
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4923
    "Created: / 13.11.2001 / 14:13:16 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4924
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  4925
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4926
!MenuPanel methodsFor:'private-searching'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  4927
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4928
detectGrabMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4929
    "returns the menu which is responsible for the grap; the last opened menu"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4930
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4931
    |subMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4932
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4933
    selection notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4934
        (subMenu := selection visibleSubmenu) notNil ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4935
            ^ subMenu detectGrabMenu
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4936
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4937
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4938
    ^ self
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4939
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4940
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4941
detectMenuAtGrabPoint:aGrabPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4942
    "returns the menu which contains the grab-point"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4943
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4944
    |dstMenu dstPoint firstMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4945
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4946
    dstPoint := self translateGrabPoint:aGrabPoint.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4947
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4948
    ((dstPoint x between:0 and:width) and:[dstPoint y between:0 and:height]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4949
        firstMenu := self.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4950
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4951
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  4952
    (selection isNil or:[(dstMenu := selection visibleSubmenu) isNil]) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4953
        ^ firstMenu
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4954
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4955
    dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  4956
    ^ dstMenu ? firstMenu
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4957
!
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  4958
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4959
detectViewAtX:x y:y in:aTopView
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4960
    "detect view at x@y"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4961
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4962
    ^ aTopView detectViewAt:(x@y).
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4963
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4964
"/ 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
  4965
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4966
"/    |p subViews|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4967
"/
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4968
"/    (subViews := aTopView subViews) notNil ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4969
"/        subViews do:[:v| |p|
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4970
"/            v shown ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4971
"/                (    (x between:(v left) and:(v right))
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4972
"/                 and:[y between:(v top)  and:(v bottom)]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4973
"/                ) ifTrue:[
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4974
"/                    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
  4975
"/                  ^ 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
  4976
"/                ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4977
"/            ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4978
"/        ]
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4979
"/    ].
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4980
"/    ^ aTopView
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4981
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  4982
    "Modified: / 10.10.2001 / 13:45:56 / cg"
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4983
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  4984
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4985
itemAt:stringOrNumberOrPoint
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4986
    "returns item assigned to an index, nameKey, textLabel or value if symbol.
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4987
     If no item match nil is returned."
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  4988
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4989
    |idx|
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4990
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4991
    stringOrNumberOrPoint isPoint ifTrue:[
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4992
        ^ self itemAtPoint:stringOrNumberOrPoint
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4993
    ].
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4994
    idx := self indexOf:stringOrNumberOrPoint.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4995
    (idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ].
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  4996
    ^ nil
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4997
!
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4998
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  4999
itemAtPoint:aPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5000
    "returns the item at aPoint or nil if none detected"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5001
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5002
    |x y|
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5003
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5004
    items notNil ifTrue:[
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5005
        x := aPoint x.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5006
        y := aPoint y.
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5007
        ^ items detect:[:el| el containsPointX:x y:y] ifNone:nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5008
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5009
    ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5010
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5011
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  5012
superMenuAtPoint:aPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5013
    "returns the superMenu which contains aPoint, or nil if none detected"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5014
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5015
    |grabPoint superMenu|
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5016
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  5017
    (self containsPoint:aPoint) ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5018
        ^ self
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5019
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5020
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  5021
    grabPoint := aPoint - (self translateGrabPoint:0).
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5022
    superMenu := self.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5023
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5024
    [ (superMenu := superMenu superMenu) notNil ] whileTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5025
        (superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5026
            ^ superMenu
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5027
        ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5028
    ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5029
    ^ nil
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5030
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  5031
    "Created: / 13.11.2001 / 20:22:53 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5032
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5033
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5034
!MenuPanel methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5035
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5036
container:aView
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5037
    super container:aView.
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5038
    aView notNil ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  5039
	"/ I am no longer a popUpView
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  5040
	self updateLevelAndBorder
2003
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5041
    ].
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5042
!
732fbaf5864f avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  5043
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5044
containsPoint:aPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5045
    "returns true if the argument, aPoint is contained by the view"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5046
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5047
    ^ self containsPointX:(aPoint x) y:(aPoint y)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5048
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5049
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5050
containsPointX:x y:y
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5051
    "returns true if point is contained by the view"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5052
708
245b1aa06151 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  5053
    ^ (x between:0 and:width) and:[y between:0 and:height]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5054
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5055
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5056
hasGroupDividerAt:anIndex
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5057
    "returns true if a divider is defined at an index"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5058
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5059
    |i|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5060
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5061
    groupSizes size ~~ 0 ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5062
        i := 0.
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5063
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5064
        groupSizes do:[:t|
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5065
            (i := i + t) == anIndex ifTrue:[
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5066
                ^ true
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5067
            ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5068
        ]
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5069
    ].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5070
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5071
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5072
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5073
hasGroupDividers
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5074
    "returns true if any group divider exists"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5075
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5076
    ^ (items size ~~ 0 and:[groupSizes size ~~ 0])
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5077
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5078
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5079
isFitPanel
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5080
    "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
  5081
     be fit to the extent of its superView;
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5082
     NOT SUPPORTED"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5083
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5084
    ^ false
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5085
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5086
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5087
isPopUpView
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5088
    "return true if view is a popup view; without decoration
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5089
     and popUp to top immediately"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5090
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5091
    ^ superView isNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5092
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5093
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5094
isVerticalLayout
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5095
    "returns true if vertical layout otherwise false( horizontal layout )"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5096
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5097
    ^ self verticalLayout
416
c05874084d4c implement
ca
parents: 407
diff changeset
  5098
!
c05874084d4c implement
ca
parents: 407
diff changeset
  5099
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  5100
isViewWrapper
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  5101
    ^ items size == 0 and:[subViews size ~~ 0]
1793
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  5102
!
f76529768dd6 keyPress:... check for wrapped view
ca
parents: 1791
diff changeset
  5103
416
c05874084d4c implement
ca
parents: 407
diff changeset
  5104
type
428
ca
parents: 427
diff changeset
  5105
    ^ nil.
416
c05874084d4c implement
ca
parents: 407
diff changeset
  5106
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5107
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5108
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5109
!MenuPanel methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5110
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5111
hasSelection
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5112
    "returns true if a selection exists"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5113
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5114
    ^ self selection notNil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5115
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5116
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5117
openDelayed:anItem
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5118
    self openDelayed:anItem afterSeconds:0.5.
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5119
!
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5120
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5121
openDelayed:anItem afterSeconds:seconds
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5122
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5123
    superMenu notNil ifTrue:[
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5124
        superMenu openDelayed:anItem afterSeconds:seconds.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5125
        ^ self
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5126
    ].
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5127
    openDelayedMenuBlock notNil ifTrue:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5128
        Processor removeTimedBlock:openDelayedMenuBlock.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5129
        openDelayedMenuBlock := nil.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5130
    ].
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5131
    (anItem notNil and:[anItem hasSubmenu]) ifFalse:[
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5132
        openDelayedMenuBlock := nil.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5133
        ^ self
2253
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5134
    ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5135
    openDelayedMenuBlock := [
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5136
        openDelayedMenuBlock := nil.
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5137
        anItem openDelayedSubmenu
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5138
    ].
2f6fa29b1f99 starting removing #menuAdornmentAt:
ca
parents: 2251
diff changeset
  5139
3187
f97f27a9d496 focus handling
ca
parents: 3158
diff changeset
  5140
    Processor addTimedBlock:openDelayedMenuBlock afterSeconds:seconds.
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5141
!
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5142
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5143
selection
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5144
    "returns current selected item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5145
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5146
    ^ selection
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5147
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5148
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5149
selection:anItemOrNil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5150
    "change selection to an item or nil
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5151
     if the item has a submenu the first item might be selected (style-sheet)"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5152
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5153
    |openMenu openOnSelect submenu item|
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5154
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5155
    selection == anItemOrNil ifTrue:[^ self].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5156
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5157
    (anItemOrNil isNil or:[anItemOrNil hasSubmenu not]) ifTrue:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5158
        self selection:anItemOrNil openMenu:false.
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5159
        ^ self
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5160
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5161
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5162
    openMenu     := self isPopUpView not.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5163
    openOnSelect := styleSheet at:#'menu.openOnSelect' default:false.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5164
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5165
    openMenu ifFalse:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5166
        openMenu := openOnSelect.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5167
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5168
    self selection:anItemOrNil openMenu:openMenu.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5169
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5170
    openOnSelect ifFalse:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5171
        "/ select first item in submenu
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5172
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5173
        submenu := anItemOrNil currentSubmenu.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5174
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5175
        submenu notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5176
            item := submenu itemAt:1.
2347
9c22beda83cd hideOnRelease now from styleSheet;
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  5177
            (item notNil and:[item hasSubmenu not]) ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5178
                submenu selection:item openMenu:false
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5179
            ]
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5180
        ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5181
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5182
!
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5183
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5184
selection:anItemOrNil openMenu:openMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5185
    "change selection to an item or nil"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5186
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5187
    |helpListener oldSelect|
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5188
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5189
    anItemOrNil == selection ifTrue:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5190
        ^ self
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5191
    ].
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5192
    self openDelayed:nil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5193
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5194
    oldSelect := selection.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5195
    selection := nil.
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5196
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5197
    anItemOrNil notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5198
        self makeItemVisible:anItemOrNil.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5199
        anItemOrNil canSelect ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5200
            selection := anItemOrNil
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5201
        ] ifFalse:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5202
            oldSelect isNil ifTrue:[^ self].
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5203
        ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5204
    ].
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5205
    oldSelect notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5206
        "/ clear current selection
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5207
        oldSelect isSelected:false.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5208
    ].
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  5209
    selection isNil ifTrue:[^ self].
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5210
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5211
    selection == enteredItem ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5212
        enteredItem := nil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5213
    ] ifFalse:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5214
        self pointerEntersItem:nil
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5215
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5216
    ActiveHelp isActive ifTrue:[
2251
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5217
        helpListener := ActiveHelp currentHelpListener.
30490c3f2173 bug fixes with focus handling
ca
parents: 2249
diff changeset
  5218
        helpListener initiateHelpFor:self at:nil now:true.
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5219
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5220
    shown ifTrue:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5221
        self rearrangeItems.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5222
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5223
        openMenu ifFalse:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5224
            selection invalidate.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5225
        ]
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5226
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5227
    openMenu ifTrue:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5228
        selection isSelected:true.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  5229
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5230
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5231
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5232
selectionIndex
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5233
    "returns index of current selection or 0"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5234
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5235
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5236
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5237
    (item := self selection) notNil ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5238
        ^ self findFirst:[:el| el == item ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5239
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5240
    ^ 0
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5241
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5242
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5243
selectionIndex:anIndex
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5244
    "set selection at an index"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5245
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5246
    self selection:(self itemAt:anIndex)
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5247
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5248
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5249
!MenuPanel methodsFor:'translation'!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5250
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5251
translateGrabPoint:aGrabPoint
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5252
    "translate the grab point into self"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5253
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5254
    superMenu isNil ifTrue:[
2936
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5255
        "I am the grabView"
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5256
        aGrabPoint isNumber ifTrue:[^ aGrabPoint @ aGrabPoint].
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5257
        ^ aGrabPoint
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5258
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5259
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5260
    relativeGrabOrigin isNil ifTrue:[
2936
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5261
        relativeGrabOrigin := self topMenu translatePoint:0 to:self.    
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5262
        relativeGrabOrigin isNil ifTrue:[
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5263
            "I am the grabView"
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5264
            aGrabPoint isNumber ifTrue:[^ aGrabPoint @ aGrabPoint].
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5265
            ^ aGrabPoint
723062b99960 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  5266
        ].
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5267
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5268
    ^ relativeGrabOrigin + aGrabPoint
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5269
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5270
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5271
translateMenuPoint:aPoint toMenu:aMenu
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5272
    "translate a point into another menu its point"
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5273
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5274
    |grapPoint|
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5275
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5276
    aMenu == self ifTrue:[
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5277
        ^ aPoint
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5278
    ].
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5279
    grapPoint := aPoint - (self translateGrabPoint:0).
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5280
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5281
    ^ aMenu translateGrabPoint:grapPoint
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5282
!
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5283
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  5284
translatePoint:aPoint to:anotherWindowOrNilForScreen
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5285
    "translate a point in my window to anotherWindowOrNilForScreen (or root window if nil)"
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  5286
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  5287
    ^ device 
2715
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5288
        translatePoint:aPoint asPoint 
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5289
        fromView:self 
11d4f65d42d2 categories
Claus Gittinger <cg@exept.de>
parents: 2713
diff changeset
  5290
        toView:anotherWindowOrNilForScreen
2020
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  5291
1f1868eba475 extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
  5292
    "Modified: / 10.10.2001 / 14:11:47 / cg"
1791
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5293
! !
bd26612c387a optimization: no longer use #translatePoint:from:to:
ca
parents: 1790
diff changeset
  5294
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5295
!MenuPanel::Item class methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5296
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5297
horizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5298
    ^ HorizontalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5299
!
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5300
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5301
labelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5302
    ^ LabelRightOffset
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5303
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5304
689
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5305
verticalInset
aa13913add84 clear lastActiveMenu when closed
ca
parents: 687
diff changeset
  5306
    ^ VerticalInset
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5307
!
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5308
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5309
verticalPopUpInset
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5310
    ^ VerticalPopUpInset
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5311
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5312
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5313
!MenuPanel::Item class methodsFor:'defaults'!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5314
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5315
halfSeparatorSize
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5316
    "returns the size of a space-separator"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5317
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5318
    ^ 5
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5319
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5320
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5321
separatorSize
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5322
    "returns the size of a separator"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5323
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5324
    ^ 10
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5325
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5326
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  5327
updateStyleCache
2777
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  5328
    "extract values from the styleSheet and cache them in class variables"
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  5329
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5330
    <resource: #style (#'menuPanel.verticalInset')>
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5331
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5332
    HorizontalInset       := 2.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5333
    VerticalInset         := MenuPanel styleSheet at:#'menuPanel.verticalInset' default:2.
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5334
    VerticalPopUpInset    := 2.
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5335
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5336
    HorizontalButtonInset := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5337
    VerticalButtonInset   := 3.
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  5338
681
62c7cdaca188 extra default inset values for button behaviour added
tz
parents: 680
diff changeset
  5339
    LabelRightOffset      := 15.
1765
a003f417d6ad fix for vertical spacing
Claus Gittinger <cg@exept.de>
parents: 1762
diff changeset
  5340
2777
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  5341
    "
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  5342
     self updateStyleCache
56bb352f6b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  5343
    "
1124
4a7fec62a572 smaller checkbox.
Claus Gittinger <cg@exept.de>
parents: 1117
diff changeset
  5344
! !
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  5345
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5346
!MenuPanel::Item class methodsFor:'instance creation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5347
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5348
in:aSuperMenu
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5349
    ^ self in:aSuperMenu label:nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5350
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5351
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5352
in:aSuperMenu label:aLabel
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5353
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5354
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5355
    item := self new in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5356
    item label:aLabel.
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5357
    ^ item
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5358
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5359
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5360
in:aSuperMenu menuItem:aMenuItem
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5361
    |item|
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5362
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5363
    item := self in:aSuperMenu.
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5364
    item menuItem:aMenuItem.
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5365
    ^ item.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5366
!
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5367
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5368
new
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5369
    ^ self basicNew initialize
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5370
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5371
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1806
diff changeset
  5372
!MenuPanel::Item methodsFor:'accepting'!
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5373
420
ca
parents: 417
diff changeset
  5374
canAccept
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5375
    "returns true if item is acceptable"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5376
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5377
    self enabled    ifFalse:[ ^ false].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5378
    self hasSubmenu ifFalse:[ ^ true ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5379
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5380
    self hasDelayedMenu ifFalse:[^ false ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  5381
  ^ subMenu isNil or:[subMenu shown not]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5382
!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5383
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5384
toggleIndication
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5385
    "toggle indication or choice"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5386
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5387
    |arg|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5388
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5389
    indication notNil ifTrue:[    
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5390
        arg := self indicationValue not.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5391
        self indicationValue:arg.
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5392
    ] ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5393
        choice notNil ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5394
            choice value:(menuItem choiceValue).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5395
            ^ true
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5396
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5397
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5398
    ^ arg
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5399
! !
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5400
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5401
!MenuPanel::Item methodsFor:'accessing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5402
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5403
accessCharacter
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5404
    "returns my accessCharacter or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5405
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5406
    ^ accessCharacter
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5407
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5408
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5409
accessCharacterPosition
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5410
    "get the access character position or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5411
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5412
    ^ menuItem accessCharacterPosition
1726
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
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5415
accessCharacterPosition:anIndex 
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5416
    "set the access character position or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5417
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5418
    menuItem accessCharacterPosition:anIndex.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5419
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5420
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5421
argument
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5422
    "gets the argument"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5423
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5424
    ^ menuItem argument
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5425
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5426
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5427
argument:anArgument
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5428
    "sets the argument"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5429
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5430
    menuItem argument:anArgument.
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5431
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5432
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5433
displayLabel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5434
    "returns my printable Label"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5435
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5436
    ^ displayLabel
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5437
!
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5438
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5439
displayLabelExtent
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5440
    "returns the labels extent"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5441
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5442
    |prevFont w h|
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5443
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5444
    displayLabelExtent notNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5445
        ^ displayLabelExtent
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5446
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5447
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5448
    displayLabel isNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5449
        displayLabelExtent := 0@0.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5450
        ^ displayLabelExtent
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5451
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5452
    prevFont := menuPanel setFont:(self font).
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5453
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5454
    displayLabel isArray ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5455
        w := h := 0.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5456
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5457
        displayLabel do:[:aSubLabel|
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5458
            aSubLabel notNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5459
                w := w max:(aSubLabel widthOn:menuPanel).
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5460
                h := h + 1 + (aSubLabel heightOn:menuPanel).
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5461
            ] ifFalse:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5462
                h := h + (self spaceBetweenEmptyLines)
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5463
            ]
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5464
        ]
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5465
    ] ifFalse:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5466
        w := displayLabel  widthOn:menuPanel.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5467
        h := displayLabel heightOn:menuPanel.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5468
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5469
    "/ care for italic fonts - give a few more pixels at the end
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5470
    menuPanel font italic ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5471
        w := w + 2.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5472
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5473
    displayLabelExtent := w@h.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5474
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5475
    prevFont notNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5476
        menuPanel setFont:prevFont.     "/ restore previous font
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5477
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5478
    ^ displayLabelExtent
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5479
!
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5480
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5481
font
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5482
    "returns the user configured font or nil (default menu font)"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5483
2373
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5484
    |font|
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5485
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5486
    menuPanel isNil ifTrue:[^ nil].
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5487
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5488
    font := menuItem font.
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5489
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5490
    font notNil ifTrue:[
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5491
        font := font onDevice:(menuPanel device).
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5492
        menuItem font:font.
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5493
    ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5494
    ^ font
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5495
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5496
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5497
font:aFont
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5498
    "returns the user configured font or nil (default menu font)"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5499
2373
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  5500
    menuItem font:aFont.
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5501
!
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  5502
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5503
ignoreMnemonicKeys
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5504
    "if true, mnemonic (access character) in the submenus under the item are ignored"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5505
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5506
    ^ menuItem ignoreMnemonicKeys
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5507
!
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5508
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5509
ignoreMnemonicKeys:aBoolean
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5510
    "if true, mnemonic (access character) in the submenus under the item are ignored"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5511
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5512
    menuItem ignoreMnemonicKeys:aBoolean.
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5513
!
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5514
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5515
ignoreShortcutKeys
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5516
    "if true, shortcutKeys (accelerators) in the submenus under the item are ignored"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5517
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5518
    ^ menuItem ignoreShortcutKeys
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5519
!
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5520
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5521
ignoreShortcutKeys:aBoolean
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5522
    "if true, shortcutKeys (accelerators) in the submenus under the item are ignored"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5523
2604
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5524
    menuItem ignoreShortcutKeys:aBoolean.
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5525
!
34401b14b068 support of ignoreMnemonicKeys and ignoreShortcutKeys during processing
ca
parents: 2603
diff changeset
  5526
2345
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  5527
itemValue
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5528
    "gets the items value"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5529
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5530
    ^ menuItem itemValue
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5531
!
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5532
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5533
itemValue:aValue
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5534
    "argument could be a value holder, an action or selector"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5535
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5536
    menuItem itemValue:aValue.
2345
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  5537
!
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  5538
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5539
label
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5540
    "returns the label"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5541
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5542
    ^ label
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5543
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5544
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5545
label:aLabel
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  5546
    "set a new label; if the label changed, a redraw is performed;
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5547
     handle characters $& (ST-80 compatibility)"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5548
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5549
    |size char oldExtent|
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5550
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5551
    oldExtent          := displayLabelExtent.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5552
    displayLabelExtent := nil. "/ force a recomputation
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5553
    accessCharacter    := disabledDisplayLabel := nil.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5554
    label              := aLabel value.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5555
    displayLabel       := label value ? ''.
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5556
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5557
    displayLabel isString ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5558
        "CHECK FOR SEPARATOR"
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5559
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5560
        (menuItem isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5561
            size := displayLabel size.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5562
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5563
            size == 0 ifTrue:[
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5564
                displayLabel := nil.            "blank separator"
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5565
                ^ self
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5566
            ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5567
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5568
            size == 1 ifTrue:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5569
                char := displayLabel first.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5570
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5571
                (char == $- or:[char == $=]) ifTrue:[
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5572
                    label := displayLabel.      "line separator"
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5573
                    displayLabel := nil.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5574
                    ^ self
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5575
                ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5576
            ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5577
        ]
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5578
    ] ifFalse:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5579
        displayLabel isCollection ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5580
            displayLabel := displayLabel asArray.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5581
        ]
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5582
    ].
3328
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5583
    menuPanel doAccessCharacterTranslation ifTrue:[
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5584
        displayLabel notNil ifTrue:[
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5585
            displayLabel isArray ifTrue:[
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5586
                displayLabel keysAndValuesDo:[:i :el|
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5587
                    el notNil ifTrue:[
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5588
                        displayLabel at:i put:(self updateAccessCharacterFor:el).
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5589
                    ].
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5590
                ].
3328
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5591
            ] ifFalse:[
037d6d506879 no access character translation for the combo-list
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
  5592
                displayLabel := self updateAccessCharacterFor:displayLabel.
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5593
            ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5594
        ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5595
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5596
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5597
    menuPanel shown ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5598
        self fetchImages.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5599
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5600
        oldExtent = self displayLabelExtent ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5601
            self invalidate
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5602
        ] ifFalse:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  5603
            menuPanel mustRearrange
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5604
        ]
1978
a53447b8cbe2 set label; reange menu if extent changed otherwise redraw only the item
martin
parents: 1955
diff changeset
  5605
    ].
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5606
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5607
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5608
menuPanel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5609
    "returns my menuPanel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5610
399
d083b1bce58d ST-80 compatibility
ca
parents: 396
diff changeset
  5611
    ^ menuPanel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5612
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5613
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5614
nameKey
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5615
    "gets the nameKey"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5616
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5617
    ^ menuItem nameKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5618
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5619
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5620
nameKey:aNameKey
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5621
    "sets the nameKey"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5622
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5623
    menuItem nameKey:aNameKey.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5624
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5625
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5626
rawLabel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5627
    "returns my raw, unprocessed label"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5628
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5629
    ^ menuItem rawLabel
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5630
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5631
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5632
shortcutKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5633
    "get the key to press to select the submenu from the keyboard or if
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5634
     no submenu exists evaluate the action assigned to the item (accept)."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5635
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5636
    ^ menuItem shortcutKey
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5637
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5638
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5639
shortcutKey:aKey
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5640
    "set the key to press to select the submenu from the keyboard or if
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5641
     no submenu exists evaluate the action assigned to the item (accept)."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5642
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5643
    menuItem shortcutKey ~= aKey ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5644
        menuItem shortcutKey:aKey.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5645
        self invalidate.
1889
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  5646
    ].
43516e4588ce give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  5647
!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5648
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5649
startGroup
3127
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5650
    "start group #left #right #conditionalRight ... or nil
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5651
     at the moment only #right and #conditionalRight are implemented"
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5652
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5653
    ^ menuItem startGroup
3127
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5654
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5655
    "Modified: / 16-10-2006 / 13:06:25 / cg"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5656
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5657
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5658
startGroup:aSymbol
3127
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5659
    "start group #left #right #conditionalRight ...
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5660
     at the moment only #right and #conditionalRight are implemented"
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5661
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5662
    menuItem startGroup:aSymbol.
3127
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5663
9b522d37eca0 new startGroup value: #conditionalRight
Claus Gittinger <cg@exept.de>
parents: 3126
diff changeset
  5664
    "Modified: / 16-10-2006 / 13:06:37 / cg"
710
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5665
!
4453e463ff16 add new feature:
ca
parents: 709
diff changeset
  5666
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5667
submenu
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5668
    "returns my submenu or creates it if its defined via a selector or channel.
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5669
     May return nil, if there is really no menu"
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5670
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5671
    subMenu isNil ifTrue:[
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5672
        self setupSubmenu
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5673
    ].
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5674
    ^ subMenu
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5675
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5676
    "Modified: / 07-11-2006 / 11:09:49 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5677
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5678
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5679
submenu:aSubMenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5680
    "set a new submenu; an existing submenu will be destroyed. 
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5681
     This might lead to a redraw if 'hasSubmenu' changed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5682
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5683
    |widget|
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5684
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5685
    aSubMenu isNil ifTrue:[
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5686
        subMenu notNil ifTrue:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5687
            subMenu destroy.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5688
            subMenu := nil.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5689
        ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5690
        ^ self
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5691
    ].
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5692
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  5693
    (aSubMenu isKindOf:Menu) ifTrue:[
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5694
        subMenu := MenuPanel new.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5695
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5696
        menuPanel notNil ifTrue:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5697
            subMenu receiver:menuPanel receiver.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5698
        ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5699
        subMenu superMenu:menuPanel.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5700
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5701
        menuItem horizontalLayout == true ifTrue:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5702
            subMenu verticalLayout:false
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5703
        ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5704
        subMenu menu:aSubMenu.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5705
    ] ifFalse:[
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5706
        aSubMenu isView ifFalse:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5707
            (aSubMenu isKindOf:ApplicationModel) ifFalse:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5708
                "/ ... mhhhh ....
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5709
                ^ menuItem submenuChannel:aSubMenu
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5710
            ].            
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5711
            widget := SimpleView new.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5712
            widget client:aSubMenu.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5713
        ] ifTrue:[
2827
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  5714
            widget := aSubMenu.
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  5715
            subMenu perform:#superMenu: with:menuPanel ifNotUnderstood:[].
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5716
        ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5717
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5718
        (widget isKindOf:MenuPanel) ifTrue:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5719
            subMenu := widget.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5720
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5721
            menuItem horizontalLayout == true ifTrue:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5722
                subMenu verticalLayout:false
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5723
            ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5724
        ] ifFalse:[
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5725
            subMenu := MenuPanel new.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5726
            subMenu receiver:menuPanel receiver.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5727
            subMenu addSubView:widget.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5728
            subMenu extent:(widget preferredExtent).
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5729
            widget origin:0.0@0.0 corner:1.0@1.0.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5730
        ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5731
        subMenu superMenu:menuPanel.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5732
    ].
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5733
!
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5734
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5735
submenuOrNil
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5736
    "returns my submenu or nil if there is none or its defined via a channel or selector"
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5737
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5738
    ^ subMenu
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5739
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5740
    "Created: / 07-11-2006 / 11:04:47 / cg"
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5741
!
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  5742
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5743
textLabel
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5744
    "returns my textLabel or nil.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5745
     Used internally to select items via initial-character, for example."
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5746
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5747
    |txt|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5748
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5749
    displayLabel notNil ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5750
        displayLabel isArray ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5751
            ^ displayLabel perform:#string ifNotUnderstood:nil
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5752
        ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5753
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5754
        displayLabel do:[:el|
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5755
            (txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5756
                ^ txt
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5757
            ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  5758
        ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5759
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5760
    ^ nil
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5761
!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5762
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5763
triggerOnDown
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5764
    "return true if triggering the action if pressed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5765
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5766
    menuItem triggerOnDown ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5767
        self hasSubmenu ifFalse:[^ true].
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5768
    ].
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5769
    ^ false
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5770
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5771
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5772
triggerOnDown:aBool
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5773
    "setup to trigger the action if pressed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5774
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5775
    menuItem triggerOnDown:aBool.
1841
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5776
!
5d01716cc37c implement: triggerOnDown
ca
parents: 1836
diff changeset
  5777
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5778
value
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5779
    "gets the items value
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5780
     Left here for ST80 compatibility - value is a bad name"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5781
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5782
    ^ menuItem itemValue
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5783
!
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5784
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5785
value:aValue
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5786
    "could be a value holder, an action or selector
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5787
     Left here for ST80 compatibility - value: is a bad name"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5788
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5789
    menuItem itemValue:aValue.
502
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5790
!
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5791
dedc1b29b6ac support of arguments
ca
parents: 498
diff changeset
  5792
value:aValue argument:anArgument
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5793
    "set the value and an argument"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5794
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5795
    menuItem itemValue:aValue.
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  5796
    menuItem  argument:anArgument.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5797
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5798
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5799
!MenuPanel::Item methodsFor:'accessing-behavior'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5800
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5801
choice
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5802
    "implements a radio group; the field"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5803
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5804
    ^ choice
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5805
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5806
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5807
choice:something
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5808
    "set choice indication"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5809
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5810
    choice == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5811
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5812
    choice isValueModel ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5813
        choice removeDependent:self
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5814
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5815
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5816
    (choice := something) notNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5817
        choice isSymbol ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5818
            (choice := self aspectAt:choice) isNil ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5819
                choice := something
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5820
            ]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5821
        ].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5822
        choice isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5823
            choice addDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5824
        ]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  5825
    ].
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5826
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5827
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5828
choiceValue
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5829
    "implements a radio group; the value writen to the choice if selected"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5830
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5831
    ^ menuItem choiceValue
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5832
!
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5833
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  5834
choiceValue:something
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5835
    "implements a radio group; the value writen to the choice if selected"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5836
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5837
    menuItem choiceValue ~= something ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5838
        menuItem choiceValue:something.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5839
        choice notNil ifTrue:[ self invalidate ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5840
    ].
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5841
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  5842
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5843
enabled
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5844
    "returns the enabled state"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5845
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5846
    |state|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  5847
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5848
    menuPanel enabled ifFalse:[^ false].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5849
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5850
    enableChannel isSymbol ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5851
        state := self aspectAt:enableChannel.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5852
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5853
        state isNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5854
            self ifNotInUIBuilderInfoPrintCR:
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5855
                ('MenuPanel::Item [info]: no aspect for ', enableChannel, ' (in ' , label printString , ')').
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5856
            ^ true
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5857
        ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5858
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5859
        state isValueModel ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5860
            enableChannel := state.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5861
            enableChannel addDependent:self.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5862
            state := enableChannel value.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5863
        ] ifFalse:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5864
            state := state value
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5865
        ]
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5866
    ] ifFalse:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5867
        state := enableChannel value
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5868
    ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5869
    ^ state ~~ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5870
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5871
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  5872
enabled:something
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5873
    "change the enabled state; if the state changed, a redraw is performed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5874
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5875
    |oldState newState|
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5876
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5877
    enableChannel isNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5878
        oldState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5879
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5880
        oldState := enableChannel value.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5881
        enableChannel isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5882
            enableChannel removeDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5883
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5884
    ].
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5885
    enableChannel := something.
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5886
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5887
    enableChannel isNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5888
        menuPanel shown ifFalse:[^ self].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5889
        newState := true
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5890
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5891
        enableChannel isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5892
            enableChannel addDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5893
        ] ifFalse:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5894
            enableChannel isSymbol ifTrue:[^ self]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5895
        ].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5896
        menuPanel shown ifFalse:[^ self].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5897
        newState := enableChannel value.
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5898
    ].
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5899
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  5900
    newState ~~ oldState ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5901
        self invalidate
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  5902
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5903
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5904
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5905
hideMenuOnActivated
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5906
    "hide the menu when the item was activated; the default is true"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5907
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5908
    ^ menuItem hideMenuOnActivated
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5909
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5910
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5911
hideMenuOnActivated:aBool
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5912
   "hide the menu when the item was activated; the default is true"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5913
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5914
   menuItem hideMenuOnActivated:aBool.
1670
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5915
!
dbc8a05605e0 add new behavior: hideMenuOnActivated
ca
parents: 1666
diff changeset
  5916
2216
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5917
ifNotInUIBuilderInfoPrintCR:aMessage
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5918
    "/ q&d hack to suppress info-messages in UIBuilder
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5919
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5920
    (menuPanel receiver isNil
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5921
    and:[ menuPanel application notNil
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5922
    and:[ menuPanel application askFor:#isUIPainter]])
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5923
    ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  5924
	^ self "/ suppressed
2216
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5925
    ].
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5926
    aMessage infoPrintCR
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5927
!
9cbeda150dae no info for toolbarmenu enable channel
penk
parents: 2214
diff changeset
  5928
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5929
indication
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5930
    "get on/off indication"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5931
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5932
    ^ indication
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5933
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5934
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  5935
indication:something
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5936
    "set on/off indication"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5937
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5938
    indication == something ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5939
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5940
    indication isValueModel ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5941
        indication removeDependent:self
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5942
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5943
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5944
    (indication := something) notNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5945
        indication isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5946
            indication addDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5947
        ] ifFalse:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5948
            "/ to force an update of the value
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5949
            self indicationValue
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5950
        ]
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  5951
    ].
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5952
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5953
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5954
keepLinkedMenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5955
    "get the keepLinkedMenu flag"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5956
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5957
    ^ menuItem keepLinkedMenu
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5958
!
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5959
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5960
keepLinkedMenu:aBool
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5961
    "get the keepLinkedMenu flag"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5962
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5963
    menuItem keepLinkedMenu:aBool.
1767
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5964
!
e6325bfd4fad allow views in subMenus
ca
parents: 1766
diff changeset
  5965
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5966
sendToOriginator
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5967
    "if true, the message is sent to the originating widget;
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5968
     otherwise (the default), it it sent to the receiver/application."
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5969
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5970
    ^ menuItem sendToOriginator
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5971
!
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5972
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5973
sendToOriginator:aBoolean
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5974
    "if true, the message is sent to the originating widget;
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5975
     otherwise (the default), it it sent to the receiver/application."
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5976
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  5977
    menuItem sendToOriginator:aBoolean.
2331
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5978
!
ebd240410703 can now specify if menu action is to be performed by
ca
parents: 2326
diff changeset
  5979
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5980
submenuChannel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5981
    "get the submenu channel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5982
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5983
    ^ menuItem submenuChannel
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5984
!
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5985
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  5986
submenuChannel:aSelectorOrNil
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5987
    "returns the submenu channel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5988
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  5989
    menuItem submenuChannel:aSelectorOrNil.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5990
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5991
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  5992
!MenuPanel::Item methodsFor:'accessing-dimension'!
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  5993
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5994
moveBy:aPoint
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5995
    "move the layouts origin"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5996
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5997
    layout moveBy:aPoint.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5998
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  5999
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6000
preferredExtent
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6001
    "compute my preferred extent excluding the shortCutKey and the menu identifier"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6002
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6003
    |isVertical icon wIcon isButton labelExtent
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6004
     x "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6005
     y "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6006
     s "{ Class:SmallInteger }"
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6007
    |
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6008
    self isVisible ifFalse:[^ 0@0 ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6009
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6010
    isButton := menuItem isButton.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6011
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6012
    isButton ifTrue:[
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6013
        s := menuPanel maxAbsoluteButtonLevel.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6014
        x := s + HorizontalButtonInset.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6015
        y := s + VerticalButtonInset.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6016
    ] ifFalse:[
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6017
        x  := HorizontalInset.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6018
        y  := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6019
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6020
    x := x * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6021
    y := y * 2.
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6022
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6023
    isVertical := menuPanel verticalLayout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6024
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6025
    self isSeparator ifTrue:[
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6026
        "SEPARATOR"
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6027
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6028
        s := self class separatorSize.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6029
        label = '' ifTrue:[
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6030
            s := self class halfSeparatorSize.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6031
        ].
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6032
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6033
        "width of doubleSeparator is 5 !!!!"
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6034
        isVertical ifFalse:[
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6035
            x := x max:s.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6036
            y := y + 5.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6037
        ] ifTrue:[
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6038
            y := y max:s.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6039
            x := x + 5.
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6040
        ].
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6041
    ] ifFalse:[
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6042
        labelExtent := self displayLabelExtent.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6043
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6044
        x := x + labelExtent x.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6045
        y := y + labelExtent y.
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6046
        x := x + (menuPanel stringOffsetXfor:self).
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6047
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6048
        isButton ifFalse:[
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6049
            menuPanel showSeparatingLines ifTrue:[
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6050
                "width of separator is 2 plus right offset 1 := 3"
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6051
                isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3].
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6052
            ].
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6053
        ].
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6054
        wIcon := 0.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6055
        self hasMenuIndicator ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6056
            icon := MenuPanel menuIndicator.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6057
            wIcon := MenuPanel menuIndicatorOffset + icon width.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6058
        ] ifFalse:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6059
            self hasDelayedMenuIndicator ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6060
                icon := MenuPanel delayedMenuIndicator.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6061
                wIcon := MenuPanel delayedMenuIndicatorOffset + icon width.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6062
            ]
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6063
        ].
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6064
        x := x + wIcon.
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6065
    ].
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  6066
    ^ x@y
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6067
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6068
1679
af40842718f6 when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents: 1670
diff changeset
  6069
!MenuPanel::Item methodsFor:'accessing-help'!
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6070
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6071
activeHelpKey
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6072
    "get the active helpKey; the key to retrieve the helpText from the application"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6073
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6074
    ^ menuItem activeHelpKey
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6075
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6076
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6077
activeHelpKey:aHelpKey
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6078
    "set the active helpKey; the key to retrieve the helpText from the application"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6079
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6080
    menuItem activeHelpKey:aHelpKey.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6081
    activeHelpText := nil.
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6082
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6083
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6084
activeHelpText
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6085
    "get the active helpText or nil if not yet resolved"
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6086
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6087
    |app key|
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6088
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6089
    activeHelpText notNil ifTrue:[^ activeHelpText].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6090
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6091
    ((key := self activeHelpKey) notNil 
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6092
    and:[(app := menuPanel application) notNil]) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6093
        ^ app helpTextForKey:key.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6094
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6095
    ^ nil
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6096
!
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6097
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6098
activeHelpText:aText
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6099
    "set the active helpText"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6100
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6101
    activeHelpText := aText.
2345
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6102
!
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6103
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6104
flyByHelpText
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6105
    "get the flyBy helpText or nil."
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6106
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6107
    |text key app|
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6108
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6109
    flyByHelpText notNil ifTrue:[^ flyByHelpText].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6110
2574
366e5807711f separators have no flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2569
diff changeset
  6111
    self isSeparator ifTrue:[^ nil].
366e5807711f separators have no flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2569
diff changeset
  6112
2471
e6e52dc428a2 it is not the isButton behavior,
martin
parents: 2460
diff changeset
  6113
    "/ its NOT the button-attribute, which controls flyByHelp suppression...
e6e52dc428a2 it is not the isButton behavior,
martin
parents: 2460
diff changeset
  6114
    "/ (if you have an argument for that let us know..)
e6e52dc428a2 it is not the isButton behavior,
martin
parents: 2460
diff changeset
  6115
    "/    self isButton ifFalse:[^ nil].
e6e52dc428a2 it is not the isButton behavior,
martin
parents: 2460
diff changeset
  6116
    (menuPanel isNil or:[menuPanel isPopUpView]) ifTrue:[^ nil].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6117
2652
686c0f0acb90 do not show help for items which have a menu (launchers about-item)
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  6118
    "/ if an activeHelpKey was explicitely given, use that one
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6119
    key := self activeHelpKey. 
2895
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6120
    app := menuPanel application.
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6121
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6122
    "/ special hook for menuItems added by other applications (i.e. via addMenuItem to the launcher)
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6123
    (key isAssociation) ifTrue:[
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6124
        app := key key.
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6125
        key := key value.
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6126
    ].
4e63ee409513 flyByHelpText in Launcher
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
  6127
3402
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6128
    key notNil ifTrue:[
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6129
        app notNil ifTrue:[
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6130
            text := app flyByHelpTextForKey:key.
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6131
        ].
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6132
        text isNil ifTrue:[
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6133
            text := menuPanel flyByHelpTextForKey:key.
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6134
        ].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6135
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6136
2652
686c0f0acb90 do not show help for items which have a menu (launchers about-item)
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  6137
    "/ otherwise, construct from the label; but only if I do not have a submenu
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6138
    text isNil ifTrue:[
2676
01dc236c3dcd flyByHelp: shown for items with menu IFF there is an activeHelp key
ca
parents: 2675
diff changeset
  6139
        self hasSubmenu ifTrue:[
01dc236c3dcd flyByHelp: shown for items with menu IFF there is an activeHelp key
ca
parents: 2675
diff changeset
  6140
            ^ key
01dc236c3dcd flyByHelp: shown for items with menu IFF there is an activeHelp key
ca
parents: 2675
diff changeset
  6141
        ].
2652
686c0f0acb90 do not show help for items which have a menu (launchers about-item)
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  6142
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6143
        text := key.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6144
        text isNil ifTrue:[
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6145
            displayLabel isString ifTrue:[
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6146
                text := displayLabel string.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6147
            ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6148
        ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6149
        text isNil ifTrue:[
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6150
            text := self rawLabel.
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6151
            text isString ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6152
                text := menuItem rawLabel.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6153
                text isString ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6154
                    text := nil.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6155
                ]
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6156
            ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6157
            text notNil ifTrue:[
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6158
                (text includes:$&) ifTrue:[ 
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6159
                    text := (self updateAccessCharacterFor:text) string.
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6160
                ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6161
            ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6162
        ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6163
    ].
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6164
3402
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  6165
    (text isString and:[text isBlank]) ifTrue:[ text := nil ].
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6166
    text = displayLabel ifTrue:[
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6167
        "for text menus: it does not make sense to show the labels string again
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6168
         (i.e. in a pull down menu)"
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6169
        ^ nil
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  6170
    ].
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6171
    ^ text
2345
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6172
!
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6173
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6174
flyByHelpText:aText
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6175
    "exlicitly set the flyBy helpText. For example, to dynamically change it."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6176
2345
8b7b3e384002 fallBack to activeHelpKey and label, if no flyByHelp is
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  6177
    flyByHelpText := aText.
1613
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6178
! !
5e23d6be5918 optimize accessing helpText
ca
parents: 1612
diff changeset
  6179
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6180
!MenuPanel::Item methodsFor:'accessing-look'!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6181
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6182
horizontalLayout
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6183
    "on default submenus has a vertical layout;
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6184
     true, the submenu has a horizontal layout."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6185
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  6186
    ^ menuItem horizontalLayout ? false
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6187
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6188
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6189
horizontalLayout:aBoolean
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6190
    "on default submenus has a vertical layout;
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6191
     true, the submenu has a horizontal layout."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6192
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  6193
    menuItem horizontalLayout:aBoolean.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6194
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6195
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6196
isButton
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6197
    "returns whether the item looks like a Button"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6198
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6199
    ^ menuItem isButton
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6200
!
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6201
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6202
isButton:aBool
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6203
    "set/clear the item to look like a Button"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6204
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6205
    menuItem isButton ~~ aBool ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6206
        menuItem isButton:aBool.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6207
        self invalidate.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6208
    ]
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6209
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6210
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6211
layout
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6212
    "returns my layout ( Rectangle )"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6213
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6214
    ^ layout
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6215
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6216
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6217
layout:aLayout
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6218
    "set a new layout ( Rectangle )"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6219
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6220
    layout := aLayout.
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6221
    self invalidate.
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6222
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6223
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6224
showBusyCursorWhilePerforming
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6225
    "get the flag which controls if a busy cursor is to be shown
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6226
     while performing the menu action. Defaults to false."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6227
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6228
    ^ menuItem showBusyCursorWhilePerforming
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6229
!
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6230
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6231
showBusyCursorWhilePerforming:aBoolean
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6232
    "set/clear the flag which controls if a busy cursor is to be shown
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6233
     while performing the menu action. Defaults to false."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6234
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6235
    menuItem showBusyCursorWhilePerforming:aBoolean.
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6236
! !
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  6237
2504
0ce78a73aacf method category rename
Claus Gittinger <cg@exept.de>
parents: 2503
diff changeset
  6238
!MenuPanel::Item methodsFor:'activation & deactivation'!
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6239
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6240
currentSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6241
    "returns the current submenu or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6242
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6243
    ^ subMenu
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6244
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6245
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6246
hideSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6247
    "hide submenu"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6248
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6249
    self hideSubmenu:subMenu.
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6250
!
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6251
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6252
hideSubmenu:aSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6253
    "hide submenu"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6254
2871
c74f2a6ff335 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  6255
    |id wg|
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6256
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6257
    aSubmenu isNil ifTrue:[^ self].
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6258
    aSubmenu removeDependencies.
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6259
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6260
    aSubmenu realized ifFalse:[
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6261
        id := aSubmenu id.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6262
        id notNil ifTrue:[ menuPanel device unmapWindow:id ]
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6263
    ] ifTrue:[
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6264
        aSubmenu hide
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6265
    ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6266
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6267
    aSubmenu windowGroup:nil.
2871
c74f2a6ff335 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  6268
    (wg := menuPanel windowGroup) notNil ifTrue:[
c74f2a6ff335 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  6269
        wg removeView:aSubmenu.
c74f2a6ff335 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  6270
    ].
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6271
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6272
    "/ release menu if derived from channel
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6273
    (subMenu == aSubmenu and:[menuItem submenuChannel notNil]) ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6274
        menuItem keepLinkedMenu ifFalse:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6275
            subMenu := nil
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6276
        ]
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6277
    ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6278
!
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6279
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6280
openDelayedSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6281
    "called to open now my delayed submenu"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6282
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6283
    |subMenuBeforeOpening|
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6284
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6285
    (self isSelected and:[menuPanel shown]) ifFalse:[^ self].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6286
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6287
    subMenu notNil ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6288
        subMenu realized ifTrue:[
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6289
            "/ already open
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6290
            ^ self
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6291
        ].
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6292
    ].
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6293
    self setupSubmenu.
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6294
    subMenu isNil ifTrue:[^ self].
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6295
    subMenuBeforeOpening := subMenu.
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6296
    self openSubmenu.
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  6297
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6298
    (subMenuBeforeOpening == subMenu and:[self isSelected]) ifFalse:[
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6299
        "/ closed during building or opening the submenu
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6300
        self hideSubmenu:subMenuBeforeOpening.
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6301
    ].
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6302
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6303
    "Modified: / 07-11-2006 / 11:07:57 / cg"
1705
201f9ce1b2d2 checkin from browser
ca
parents: 1704
diff changeset
  6304
!
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6305
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6306
openSubmenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6307
    "opens the submenu; make sure, that the submenu and the menPanel
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6308
     is fully visible by shifting it into the visible screen area if
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6309
     nescessary."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6310
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6311
    |p o device isVertical topMenu windGrp prefExtent lastEvent
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6312
     devBot   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6313
     devRight "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6314
     width    "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6315
     height   "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6316
     top      "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6317
     left     "{ Class:SmallInteger }"
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6318
    |
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6319
1737
c18896a7cb50 replace shown by realized; when opening a submenue-submenue by shortcut key
ca
parents: 1735
diff changeset
  6320
    (subMenu notNil and:[subMenu shown not and:[self isSelected and:[menuPanel realized]]]) ifFalse:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6321
        ^ self
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6322
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6323
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6324
    topMenu := menuPanel topMenu.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6325
    (subMenu device notNil and:[topMenu device ~~ subMenu device]) ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6326
        subMenu releaseDeviceResources.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6327
        subMenu setDevice:topMenu device id:nil gcId:nil.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6328
        subMenu recreate.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6329
    ].
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  6330
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6331
    windGrp := topMenu windowGroup.
3203
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6332
    windGrp notNil ifTrue:[
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6333
        lastEvent := windGrp lastEvent.
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6334
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6335
        (lastEvent notNil and:[lastEvent isButtonPressEvent]) ifTrue:[
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6336
            subMenu mapTime:(lastEvent timeStamp).
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6337
        ].
97d6c1d7b7d7 get timeStamp from buttonPress and buttonRelease event
ca
parents: 3192
diff changeset
  6338
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6339
    subMenu superMenu:menuPanel.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6340
    subMenu becomesActiveMenu.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6341
    subMenu cursor:Cursor hand.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6342
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6343
    windGrp notNil ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6344
        subMenu windowGroup:windGrp.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6345
        windGrp addTopView:subMenu.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6346
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6347
2111
f3d67f7c0f92 bug fix when opening a menu by mnemonic
ca
parents: 2100
diff changeset
  6348
    "Q&D kludge - test whether the layout is nil;
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6349
                  if true recompute the layouts
2111
f3d67f7c0f92 bug fix when opening a menu by mnemonic
ca
parents: 2100
diff changeset
  6350
    "
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  6351
    layout isNil ifTrue:[menuPanel rearrangeItems].
2111
f3d67f7c0f92 bug fix when opening a menu by mnemonic
ca
parents: 2100
diff changeset
  6352
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6353
    " Q&D kludge - if any visibility attributes are blocks;
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6354
      TODO: only invoke mustRearrange if any are blocks
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6355
            (since I react correctly on valueHolder changes)
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6356
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6357
    subMenu rearrangeItemsIfItemVisibilityChanged.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6358
    subMenu fixSize.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6359
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6360
    "compute origin of subMenu
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6361
    "
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6362
    isVertical := menuPanel verticalLayout.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6363
    device     := menuPanel device.
1714
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  6364
    prefExtent := subMenu preferredExtent.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  6365
    height     := prefExtent y.
b4c05977e9d5 get heigth and width from preferredExtent when open a submenu
ca
parents: 1710
diff changeset
  6366
    width      := prefExtent x.
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6367
    devBot     := device  usableHeight.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6368
    devRight   := device  usableWidth.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6369
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6370
    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
  6371
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6372
    menuPanel isPopUpView ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6373
        o := menuPanel origin + p
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6374
    ] ifFalse:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6375
        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
  6376
    ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6377
    left := o x.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6378
    top  := o y.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6379
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6380
    top + height > devBot ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6381
        top := isVertical ifTrue:[devBot - height]
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6382
                         ifFalse:[top - layout height - height + 2]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6383
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6384
    top := top max:0.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6385
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6386
"/    (isVertical not and:[subMenu isVerticalLayout]) ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6387
"/        top < menuPanel bottom ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6388
"/            left := left + layout width.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6389
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6390
"/        left + width > devRight ifTrue:[
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6391
"/            left := o x - width - 2
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6392
"/        ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6393
"/    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  6394
        
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6395
    left + width > devRight ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6396
        left := isVertical ifTrue:[left - layout width - width + 2]
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6397
                          ifFalse:[devRight - width]
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6398
    ].
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6399
    left := left max:0.
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6400
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6401
    subMenu origin:(left@top).
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6402
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6403
    subMenu realized ifFalse:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6404
        subMenu realize. 
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6405
    ] ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  6406
        topMenu device mapWindow:(subMenu id).
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6407
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6408
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6409
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6410
toggleSubmenuVisibility
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6411
    "toggle the visibility of the submenu"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6412
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6413
    subMenu notNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6414
        subMenu shown ifTrue:[^ self hideSubmenu]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6415
    ] ifFalse:[
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6416
        self setupSubmenu.
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6417
        subMenu isNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6418
            "/ cannot open a submenu
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6419
            ^ self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6420
        ]
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6421
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6422
    self openSubmenu.
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6423
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  6424
    "Modified: / 07-11-2006 / 11:06:42 / cg"
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6425
!
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6426
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6427
visibleSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6428
    "returns the current visible submenu or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6429
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6430
    subMenu notNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6431
        subMenu shown ifTrue:[^ subMenu].
1786
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6432
    ].
f27f48940f48 change behaviour of cursor/key control and menu actication
ca
parents: 1785
diff changeset
  6433
    ^ nil
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6434
! !
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  6435
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6436
!MenuPanel::Item methodsFor:'building'!
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6437
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6438
aspectAt:aKey
3092
a1dee282cab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  6439
    "returns the value assigned to key or nil"
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6440
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6441
    |appl value|
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6442
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6443
    appl := menuPanel receiver.
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6444
1219
6a0d677a6fac removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  6445
    (appl isValueModel) ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6446
        ^ appl value:aKey
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6447
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6448
2123
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6449
    appl isNil ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6450
        appl := menuPanel application.
2123
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6451
    ].
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6452
    appl isNil ifTrue:[ ^ nil].
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6453
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6454
    MessageNotUnderstood handle:[:ex|
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6455
        ex selector == aKey ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6456
            ex reject
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6457
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6458
        self ifNotInUIBuilderInfoPrintCR:
2771
3328da9f3df8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2770
diff changeset
  6459
            ('MenuPanel::Item [info]: application (%1) does not provide aspect: %2' 
3328da9f3df8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2770
diff changeset
  6460
             bindWith:appl classNameWithArticle with:aKey).
2123
091268558e93 *** empty log message ***
ca
parents: 2118
diff changeset
  6461
    ] do:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6462
        aKey numArgs == 1 ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6463
            value := appl perform:aKey with:(menuItem argument ? self).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6464
        ] ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6465
            (appl respondsTo:#aspectFor:) ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6466
                value := appl aspectFor:aKey
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6467
            ] ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6468
                value := appl perform:aKey
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6469
            ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6470
        ]
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6471
    ].
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6472
    ^ value
1029
c9e90585fa89 only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  6473
3092
a1dee282cab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  6474
    "Modified: / 05-10-2006 / 03:10:20 / cg"
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6475
! !
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  6476
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6477
!MenuPanel::Item methodsFor:'change & update'!
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6478
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6479
fontChanged
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6480
    "called whenever the font changed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6481
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6482
    displayLabel notNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6483
        displayLabelExtent := nil.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6484
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6485
        subMenu notNil ifTrue:[
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6486
            subMenu font:(menuPanel font).
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6487
        ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6488
    ].
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6489
!
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6490
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6491
update:something with:aParameter from:changedObject
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
    |form rect|
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
    (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
  6496
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6497
    self isSeparator ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6498
        "/ NOT A SEPARATOR
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6499
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6500
        menuPanel shown ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6501
            changedObject == enableChannel ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6502
                (enableChannel value == false and:[self isSelected]) ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6503
                    ^ menuPanel selection:nil.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6504
                ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6505
                ^ self invalidate
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6506
            ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6507
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6508
            (changedObject == indication or:[changedObject == choice]) ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6509
                menuItem isButton ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6510
                    self invalidate
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6511
                ] ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6512
                    "/ invalidate the interactor only
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6513
                    "/ take any interactor; interactors has the same extent
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6514
                    form := menuPanel iconIndicationOff.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6515
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6516
                    rect := Rectangle left:(layout left + HorizontalInset)
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6517
                                       top:(layout top)
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6518
                                     width:(form width)
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6519
                                    height:(layout height).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6520
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6521
                    menuPanel invalidate:rect repairNow:false
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6522
                ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6523
                ^ self
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6524
            ].
2855
c7f3481ff14a redraw when a valueHolder changes.
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
  6525
            self invalidate.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6526
        ].
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  6527
    ].
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6528
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6529
    changedObject == isVisible ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6530
        menuPanel mustRearrange.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6531
        menuPanel rearrangeItems.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6532
        ^ self.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6533
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  6534
498
b4c341497621 bug fixes:
ca
parents: 475
diff changeset
  6535
    super update:something with:aParameter from:changedObject
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6536
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6537
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6538
updateIndicators
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6539
    "update indicators "
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6540
2934
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6541
    indication notNil ifTrue:[
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6542
        (indication isSymbol 
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6543
        or:[menuItem hideMenuOnActivated not])
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6544
        ifTrue:[
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6545
            "indication is a selector;
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6546
             otherwise no need to redraw, because
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6547
             a change notification is raised from the model !!!!"
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6548
            self update:nil with:nil from:indication
b4ec1cbb3302 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2926
diff changeset
  6549
        ]
1074
25e3910947de added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
  6550
    ]
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6551
! !
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  6552
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6553
!MenuPanel::Item methodsFor:'converting'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6554
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6555
asMenuItem
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6556
    "convert to a MenuItem"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6557
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6558
    ^ menuItem
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6559
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6560
2827
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  6561
menuItem
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  6562
    ^ menuItem
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  6563
!
139c1089bcb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
  6564
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6565
menuItem:aMenuItem
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6566
    "setup attributes from a MenuItem"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6567
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6568
    |lbl|
389
d5487b5fb834 st80: perform on value
ca
parents: 388
diff changeset
  6569
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6570
    menuPanel disabledRedrawDo:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6571
        menuItem := aMenuItem.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6572
        menuItem isNil ifTrue:[ menuItem := MenuItem new].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6573
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6574
        label := displayLabel := activeHelpText := nil.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6575
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6576
        self    enabled:(menuItem enabled).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6577
        self indication:(menuItem indication).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6578
        self     choice:(menuItem choice).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6579
        self  isVisible:(menuItem isVisible ? true).
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6580
2855
c7f3481ff14a redraw when a valueHolder changes.
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
  6581
"/ we should call the resourceRetriever here instead of labelImage
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6582
"/ but ... ??
2855
c7f3481ff14a redraw when a valueHolder changes.
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
  6583
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6584
        (lbl := menuItem labelImage value) isNil ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6585
            lbl := menuItem rawLabel. "/ avoid translating &'s twice
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6586
        ].
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6587
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  6588
        self submenu:(menuItem submenu).
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  6589
        self label:lbl.
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6590
    ]
1033
9badc22e3d03 oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents: 1032
diff changeset
  6591
1090
cf3d9f5648da only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  6592
    "Modified: / 22.8.1998 / 15:34:16 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6593
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6594
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6595
!MenuPanel::Item methodsFor:'dependents access'!
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6596
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6597
addDependencies
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6598
    "add all dependencies"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6599
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6600
    enableChannel isValueModel ifTrue:[enableChannel addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6601
    isVisible     isValueModel ifTrue:[isVisible     addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6602
    indication    isValueModel ifTrue:[indication    addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6603
    choice        isValueModel ifTrue:[choice        addDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6604
!
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6605
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6606
removeDependencies
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6607
    "remove all dependencies"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6608
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6609
    enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6610
    isVisible     isValueModel ifTrue:[isVisible     removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6611
    indication    isValueModel ifTrue:[indication    removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6612
    choice        isValueModel ifTrue:[choice        removeDependent:self].
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6613
! !
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  6614
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6615
!MenuPanel::Item methodsFor:'drawing'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  6616
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6617
choiceForm
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6618
    "returns choice form or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6619
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6620
    |isOn|
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6621
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6622
    choice isNil ifTrue:[^ nil].
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6623
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6624
    isOn := (choice value = menuItem choiceValue).
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6625
    self enabled ifFalse:[
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6626
        ^ isOn ifTrue:[menuPanel iconRadioGroupDisabledOn]
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6627
               ifFalse:[menuPanel iconRadioGroupDisabledOff]
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6628
    ].
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6629
    ^ isOn ifTrue:[menuPanel iconRadioGroupOn]
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6630
           ifFalse:[menuPanel iconRadioGroupOff]
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6631
!
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  6632
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6633
draw
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6634
    "redraw this item"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6635
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6636
    |isSelected ownBgCol paint bgColor
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6637
     x  "{ Class:SmallInteger }"
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6638
     y  "{ Class:SmallInteger }"
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6639
     w  "{ Class:SmallInteger }"
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6640
     h  "{ Class:SmallInteger }"
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6641
    |
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6642
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6643
    self isVisible ifFalse:[^ self].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6644
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6645
    self isSeparator ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6646
        self drawSeparator.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6647
        ^ self
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6648
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6649
    menuItem isButton ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6650
        self drawButton.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6651
        ^ self
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6652
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6653
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6654
    "/ DRAW A LABELED ENTRY; no button, no separator
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6655
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6656
    isSelected := self isSelected.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6657
    bgColor    := menuPanel backgroundColor.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6658
    paint      := isSelected 
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6659
                    ifTrue:[self activeBackgroundColor] 
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6660
                    ifFalse:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6661
                        (self isEnabled and:[ self isEntered ]) ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6662
                            menuPanel enteredBackgroundColor
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6663
                        ] ifFalse:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6664
                            bgColor
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6665
                        ]].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6666
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6667
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6668
        paint := ownBgCol
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6669
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6670
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6671
    paint ~= bgColor ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6672
        menuPanel paint:paint.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6673
        menuPanel fillRectangle:layout.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6674
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6675
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6676
    menuPanel showSeparatingLines ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6677
        self drawSeparatingLines
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6678
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6679
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6680
    self drawLabel.  
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6681
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6682
    (ownBgCol notNil and:[isSelected]) ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6683
        ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor]
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6684
                                 ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6685
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6686
        x := layout left.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6687
        y := layout top.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6688
        w := layout width.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6689
        h := layout height.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6690
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6691
        menuPanel displayRectangleX:(x + 1) y:(y + 1) width:(w - 2) height:(h - 2).
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6692
        menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4).  
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6693
    ].
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6694
    menuPanel drawLabelEdgeFor:self selected:isSelected.
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6695
!
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6696
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6697
drawButton
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6698
    "draw as button"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6699
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6700
    |drawObject fg etchFg level isEnabled isSelected bg ownBgCol showSelected
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6701
     x "{ Class:SmallInteger }"
2143
7b99a7348c97 draw label shifted right-down when pressed
penk
parents: 2142
diff changeset
  6702
     y "{ Class:SmallInteger }"
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6703
    |
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6704
    drawObject := displayLabel.
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6705
    isEnabled  := self enabled.
2159
1eac041aeb3d toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  6706
    isSelected := self isSelected.
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6707
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6708
    isSelected ifFalse:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6709
        "/ test whether button has pressed toggle behaviour
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6710
        showSelected := (self isToggle and:[self indicationValue]).
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6711
    ] ifTrue:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6712
        showSelected := isSelected
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6713
    ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6714
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6715
    showSelected ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6716
        bg := self activeBackgroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6717
        fg := self activeForegroundColor.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6718
    ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6719
        self isEntered ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6720
            bg := self buttonEnteredBackgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6721
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6722
            bg := self backgroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6723
        ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6724
        isEnabled ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6725
            fg := menuPanel foregroundColor
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6726
        ] ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6727
            fg := menuPanel disabledForegroundColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6728
            etchFg := menuPanel disabledEtchedForegroundColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6729
            drawObject := self disabledRawLabel
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6730
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6731
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6732
1708
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  6733
    (ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  6734
        bg := ownBgCol
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  6735
    ].
cfaf55b9043d bug fix in background color of button when derives from label(text)
ca
parents: 1707
diff changeset
  6736
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6737
    "DRAW BACKGROUND"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6738
    bg ~= menuPanel backgroundColor ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6739
        menuPanel paint:bg.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6740
        menuPanel fillRectangle:layout.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6741
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6742
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6743
    x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6744
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6745
    (drawObject isImage and:[menuPanel centerItems]) ifTrue:[
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6746
        x := x + (layout width - menuPanel buttonPassiveLevel - HorizontalButtonInset - 1 - drawObject width // 2).
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6747
    ].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6748
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6749
    isSelected ifFalse:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6750
        "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
  6751
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6752
        indication notNil ifTrue:[
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6753
            "button is indicator and set"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6754
            isSelected := self indicationValue
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6755
        ] ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6756
            isSelected := (choice notNil and:[choice value = menuItem choiceValue]).
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6757
        ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6758
    ].
2143
7b99a7348c97 draw label shifted right-down when pressed
penk
parents: 2142
diff changeset
  6759
    y := 0.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6760
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6761
    isSelected ifTrue:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6762
        level := menuPanel buttonActiveLevel.
2142
ea2a32738005 pressed button label only shifted by one pixel
penk
parents: 2141
diff changeset
  6763
        x     := x + 1 "level abs".
2143
7b99a7348c97 draw label shifted right-down when pressed
penk
parents: 2142
diff changeset
  6764
        y     := y + 1 "level abs".
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6765
    ] ifFalse:[   
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6766
        level := self isEntered ifTrue:[menuPanel buttonEnteredLevel]
2219
93426020ceed *** empty log message ***
ca
parents: 2216
diff changeset
  6767
                               ifFalse:[menuPanel buttonPassiveLevel].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6768
    ].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6769
2817
805bb3b2ef28 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2793
diff changeset
  6770
    drawObject notEmptyOrNil ifTrue:[
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6771
        etchFg notNil ifTrue:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6772
            self drawRawLabel:drawObject atX:x+1 yOffset:y+1 paint:etchFg.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6773
        ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6774
        self drawRawLabel:drawObject atX:x yOffset:y+0 paint:fg.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6775
    ].
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6776
    self drawMenuIndicator.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6777
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6778
    level ~~ 0 ifTrue:[
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6779
        menuPanel drawButtonEdgesFor:self level:level
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6780
    ].
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6781
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6782
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6783
drawLabel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6784
    "draw a labeled entry; no button, no separator."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6785
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6786
    |scKey cLb cLa drawObject fg etchFg arrow 
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6787
     isSelected isEnabled form
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6788
     h "{ Class:SmallInteger }"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6789
     y "{ Class:SmallInteger }"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6790
     x "{ Class:SmallInteger }"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6791
     t "{ Class:SmallInteger }"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6792
    |
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  6793
    drawObject := displayLabel.
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6794
    isEnabled  := self enabled.
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6795
    isSelected := self isSelected.
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6796
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6797
    isSelected ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6798
        fg := self activeForegroundColor
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6799
    ] ifFalse:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6800
        isEnabled ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6801
            self isEntered ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6802
                fg := menuPanel enteredForegroundColor
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6803
            ] ifFalse:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6804
                fg := menuPanel foregroundColor
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6805
            ]
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6806
        ] ifFalse:[
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6807
            fg          := menuPanel disabledForegroundColor.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6808
            etchFg      := menuPanel disabledEtchedForegroundColor.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6809
            drawObject  := self disabledRawLabel
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6810
        ]
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6811
    ].
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6812
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6813
    h := layout height.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6814
    x := layout left + HorizontalInset.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6815
    t := layout top.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6816
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6817
    (    (form := self indicatorForm) notNil
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6818
     or:[(form := self choiceForm) notNil]
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6819
    ) ifTrue:[
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6820
        y := t + ((h - form height) // 2).
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6821
        form displayOn:menuPanel x:x y:y.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6822
    ].
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6823
2817
805bb3b2ef28 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2793
diff changeset
  6824
    drawObject notEmptyOrNil ifTrue:[
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6825
        x := x + (menuPanel stringOffsetXfor:self).
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6826
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6827
        etchFg notNil ifTrue:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6828
            self drawRawLabel:drawObject atX:x+1 yOffset:1 paint:etchFg.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6829
        ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6830
        self drawRawLabel:drawObject atX:x yOffset:0 paint:fg.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6831
    ].
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6832
    self drawMenuIndicator.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6833
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6834
    "/ DRAW SHORTCUT KEY
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6835
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6836
    (     menuItem shortcutKey notNil
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6837
     and:[(x := menuPanel shortKeyInset) ~~ 0
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6838
     and:[(scKey:= self shortcutKeyAsString) notNil]]
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6839
    ) ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6840
        x := layout left + x.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6841
        y := t + ((h - (scKey heightOn:menuPanel)) // 2).
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6842
        y := y + menuPanel font ascent.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6843
        scKey displayOn:menuPanel x:x y:y. 
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6844
    ].
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6845
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6846
    "/ DRAW SUBMENU INDICATION
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6847
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6848
    (menuPanel isVerticalLayout and:[self hasSubmenu]) ifFalse:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6849
        ^ self
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6850
    ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6851
    arrow := menuPanel rightArrow.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6852
    x := layout right - arrow width - HorizontalInset.
3131
611b833f2ac9 *** empty log message ***
ca
parents: 3128
diff changeset
  6853
    y := t + ((h - arrow height) // 2).
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6854
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6855
    (menuPanel styleSheet is3D not
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6856
    or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6857
        ^ menuPanel displayForm:arrow x:x y:y
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6858
    ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6859
    cLa := menuPanel shadowColor.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6860
    cLb := menuPanel lightColor.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6861
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6862
    isSelected ifFalse:[
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6863
        fg  := cLa.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6864
        cLa := cLb.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6865
        cLb := fg
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6866
    ].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6867
    menuPanel paint:cLa.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6868
    menuPanel displayForm:arrow x:x y:y.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6869
    menuPanel paint:cLb.
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  6870
    menuPanel displayForm:drawObject x:x y:y. 
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6871
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6872
    "Modified: / 6.9.1998 / 21:48:53 / cg"
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6873
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6874
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6875
drawMenuIndicator
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6876
    "draw a menu indicator if the item has a menu or delayed menu."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6877
2220
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6878
    |x y icon bAbsLevel|
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6879
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6880
    self hasDelayedMenuIndicator ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6881
        icon := MenuPanel delayedMenuIndicator.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6882
    ] ifFalse:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6883
        self hasMenuIndicator ifTrue:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6884
            icon := MenuPanel menuIndicator.
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6885
        ] ifFalse:[
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6886
            ^ self
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6887
        ]
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6888
    ].
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  6889
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6890
    x := layout right  - icon width.
2460
9afb27f470a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  6891
    false "delayedMenuIndicatorVerticalPosition == #center" ifTrue:[
2220
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6892
        y := layout height - icon height // 2 + layout top.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6893
    ] ifFalse:[
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6894
        y := layout bottom - icon height - 2.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6895
    ].
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6896
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6897
    bAbsLevel := 0.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  6898
    menuItem isButton ifTrue:[
2220
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6899
        self isSelected ifTrue:[
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6900
            x := x + 1.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6901
            y := y + 1.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6902
        ].
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6903
        bAbsLevel := menuPanel maxAbsoluteButtonLevel.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6904
        x := x - bAbsLevel.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6905
        y := y - bAbsLevel.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6906
    ].
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6907
    x := x - 1 "- HorizontalInset".
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6908
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6909
    (self isEnabled "and:[self delayedMenuIsEnabled]") ifFalse:[
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6910
        icon := menuPanel lightenedImageOnDevice:icon
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6911
    ].
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6912
    icon displayOn:menuPanel x:x y:y.
2220
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6913
2234
29eba50f76eb drawColSep beautified;
Claus Gittinger <cg@exept.de>
parents: 2232
diff changeset
  6914
    (false "drawDelayedMenuIndicatorSeparator" and:[ menuPanel buttonPassiveLevel ~~ 0 ])
2761
611ecd331c14 more xp style
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6915
    ifTrue:[               
2220
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6916
        menuPanel paint:menuPanel buttonShadowColor.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6917
        menuPanel displayLineFromX:x-2 y:layout top+bAbsLevel+1 toX:x-2 y:layout bottom-bAbsLevel-2.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6918
        menuPanel paint:menuPanel buttonLightColor.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6919
        menuPanel displayLineFromX:x-1 y:layout top+bAbsLevel+1 toX:x-1 y:layout bottom-bAbsLevel-2.
5ea0ceb20354 delayed submenu indicator
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
  6920
    ].
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6921
!
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  6922
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6923
drawRawLabel:aLabel atX:x yOffset:yOffset paint:fg
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6924
    "draw a labeled entry; no button, no separator."
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6925
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6926
    |mfont labelExtent
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  6927
     y  "{ Class:SmallInteger }"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6928
     y0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6929
     x0 "{ Class:SmallInteger }"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6930
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6931
2373
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  6932
    mfont := menuPanel setFont:(self font).
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6933
    "/ fontAscent := menuPanel font ascent.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6934
    menuPanel paint:fg.
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6935
    labelExtent := self displayLabelExtent.
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6936
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6937
    y := layout top + (layout height - labelExtent y // 2) + yOffset.
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6938
"/  menuPanel centerItems ifTrue:[self halt].
2675
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6939
    aLabel isArray ifFalse:[ |printLabel|
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6940
        aLabel isText ifTrue:[
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6941
            "/background of label already drawn
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6942
            printLabel := aLabel withoutEmphasis:#backgroundColor.
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6943
        ] ifFalse:[
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6944
            printLabel := aLabel.
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6945
        ].
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6946
        y := y + (printLabel ascentOn:menuPanel).
7a090a030736 bugfix when drawing Text with #backgroundColor (see ColorMenu)
ca
parents: 2659
diff changeset
  6947
        printLabel displayOn:menuPanel x:x y:y.
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  6948
    ] ifTrue:[
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6949
        aLabel do:[:el|
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6950
            el notNil ifTrue:[
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6951
                y0 := y + (el ascentOn:menuPanel).
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6952
"/                el isImageOrForm ifFalse:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6953
"/                    y0 := y + fontAscent
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6954
"/                ] ifTrue:[
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6955
"/                    y0 := y
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6956
"/                ].
2614
86086fc6a99c bugfix: adapt extents if font changed
ca
parents: 2611
diff changeset
  6957
                x0 := x + (labelExtent x - (el widthOn:menuPanel) // 2).
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6958
                el displayOn:menuPanel x:x0 y:y0.
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6959
                y := y + 1 + (el heightOn:menuPanel)
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6960
            ] ifFalse:[
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  6961
                y := y + (self spaceBetweenEmptyLines) 
2337
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6962
            ]
7f384db88273 centerItems attribute
Claus Gittinger <cg@exept.de>
parents: 2332
diff changeset
  6963
        ].
1727
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  6964
    ].
a6365337be59 support setting font in MenuPanel and Editor
ca
parents: 1726
diff changeset
  6965
    menuPanel setFont:mfont
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6966
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  6967
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6968
drawSeparatingLines
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6969
    "draw separating lines"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6970
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6971
    |myIndex lfSep rtSep items prevItem nextItem
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6972
     lightColor shadowColor
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6973
     l "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6974
     t "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6975
     r "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6976
     b "{ Class:SmallInteger }"
706
d716edbdbe47 show separators bug cleaned
tz
parents: 689
diff changeset
  6977
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6978
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6979
    items := menuPanel items.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6980
    myIndex := items identityIndexOf:self.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6981
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6982
    prevItem  := items at:(myIndex - 1) ifAbsent:nil.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6983
    lfSep := prevItem notNil and:[prevItem isButton not].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6984
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6985
    nextItem  := items at:(myIndex + 1) ifAbsent:nil.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6986
    rtSep := nextItem notNil and:[nextItem isButton not].
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6987
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6988
    (lfSep or:[rtSep]) ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  6989
        ^ self
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  6990
    ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6991
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6992
    lightColor := menuPanel lightColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6993
    shadowColor := menuPanel shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6994
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  6995
    menuPanel paint:lightColor.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  6996
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6997
    l := layout left.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6998
    t := layout top.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  6999
    r := layout right.
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  7000
    b := layout bottom.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7001
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7002
    menuPanel verticalLayout ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7003
        lfSep ifTrue:[menuPanel displayLineFromX:l y:t-1 toX:r y:t-1].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7004
        rtSep ifTrue:[menuPanel displayLineFromX:l y:b-1 toX:r y:b-1].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7005
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7006
        menuPanel paint:shadowColor.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7007
        lfSep ifTrue:[menuPanel displayLineFromX:l y:t-2 toX:r y:t-2].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7008
        rtSep ifTrue:[menuPanel displayLineFromX:l y:b-2 toX:r y:b-2].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7009
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7010
        lfSep ifTrue:[menuPanel displayLineFromX:l-1 y:t toX:l-1 y:b].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7011
        rtSep ifTrue:[menuPanel displayLineFromX:r-1 y:t toX:r-1 y:b].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7012
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7013
        menuPanel paint:shadowColor.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7014
        lfSep ifTrue:[menuPanel displayLineFromX:l-2 y:t toX:l-2 y:b].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7015
        rtSep ifTrue:[menuPanel displayLineFromX:r-2 y:t toX:r-2 y:b]. 
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7016
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7017
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7018
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7019
drawSeparator
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7020
    "draw as separator"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7021
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7022
    |type lightColor shadowColor isDouble
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7023
     left top
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7024
     x0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7025
     x1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7026
     y0  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7027
     y1  "{ Class:SmallInteger }"
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7028
    |
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7029
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7030
    type := self separatorType.
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7031
    (type isNil or:[type == #blankLine]) ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7032
        ^ self
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7033
    ].
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7034
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7035
    isDouble := type == #doubleLine.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7036
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7037
    lightColor := menuPanel lightColor.
2059
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7038
    shadowColor := menuPanel shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7039
    menuPanel paint:shadowColor.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7040
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7041
    left := layout left.
c760cfb7d689 code cleanup;
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
  7042
    top := layout top.
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7043
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7044
    menuPanel verticalLayout ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7045
        x0 := left  + HorizontalInset.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7046
        x1 := layout right - HorizontalInset.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7047
        y0 := top   - 1 + (layout height // 2).
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7048
        isDouble ifTrue:[y0 := y0 - 2].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7049
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7050
        menuPanel displayLineFromX:x0 y:y0   toX:x1 y:y0.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7051
        isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+4 toX:x1 y:y0+4].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7052
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7053
        menuPanel paint:lightColor.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7054
        menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7055
        isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+5 toX:x1 y:y0+5].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7056
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7057
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7058
        y1 := layout bottom.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7059
        x0 := left - 1 + (layout width // 2).
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7060
        y0 := top.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7061
        isDouble ifTrue:[x0 := x0 - 2].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7062
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7063
        menuPanel displayLineFromX:x0   y:y0 toX:x0   y:y1.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7064
        isDouble ifTrue:[menuPanel displayLineFromX:x0+4 y:y0 toX:x0+4 y:y1].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7065
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7066
        menuPanel paint:lightColor.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7067
        menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7068
        isDouble ifTrue:[menuPanel displayLineFromX:x0+5 y:y0 toX:x0+5 y:y1].
1707
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7069
    ]
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7070
!
4354f516e937 add some comment to methods; split draw routines for buttons labels ..
ca
parents: 1705
diff changeset
  7071
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7072
indicatorForm
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7073
    "returns indication form or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7074
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7075
    |val|
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7076
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7077
    indication isNil ifTrue:[^ nil].
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7078
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7079
    val := self indicationValue.
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7080
    self enabled ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7081
        ^ val == true 
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7082
            ifTrue:[menuPanel iconIndicationDisabledOn]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7083
            ifFalse:[menuPanel iconIndicationDisabledOff]
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7084
    ].
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7085
    ^ val == true 
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7086
        ifTrue:[menuPanel iconIndicationOn]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7087
        ifFalse:[menuPanel iconIndicationOff]
2768
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7088
!
9c79a348a443 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2761
diff changeset
  7089
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7090
invalidate
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7091
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7092
    layout isNil ifTrue:[^ self].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7093
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7094
    (displayLabel notNil and:[menuPanel notNil]) ifTrue:[
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7095
        menuPanel invalidateItem:self repairNow:false
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7096
    ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7097
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7098
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7099
!MenuPanel::Item methodsFor:'initialization'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7100
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7101
destroy
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7102
    "destroy submenus, remove dependencies"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7103
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  7104
    self submenu:nil.
2681
2d928e2d12af removeDependents on hide;
ca
parents: 2679
diff changeset
  7105
    self removeDependencies.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  7106
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7107
    menuPanel := nil.
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  7108
!
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  7109
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7110
in:aPanel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7111
    "create item in a menuPanel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7112
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7113
    menuPanel := aPanel.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7114
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7115
    menuItem isNil ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7116
        self halt.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7117
        menuItem := MenuItem new
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7118
    ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7119
!
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7120
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7121
initialize
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7122
    menuItem := MenuItem new.
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7123
!
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7124
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7125
reinitStyle
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7126
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7127
    subMenu notNil ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7128
	subMenu reinitStyle
1811
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7129
    ].
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7130
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7131
    "Created: / 17.8.2000 / 17:57:07 / cg"
df4f5e5b3396 restart under windows
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  7132
    "Modified: / 17.8.2000 / 18:00:08 / cg"
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7133
! !
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7134
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7135
!MenuPanel::Item methodsFor:'label basics'!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7136
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7137
disabledRawLabel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7138
    "returns the label used if the item is disabled"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7139
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7140
    |block form image|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7141
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7142
    disabledDisplayLabel notNil ifTrue:[^ disabledDisplayLabel].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7143
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7144
    disabledDisplayLabel := displayLabel ? ''.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7145
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7146
    disabledDisplayLabel isString ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7147
        ^ disabledDisplayLabel
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7148
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7149
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7150
    block := [:el| |rslt|
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7151
        (rslt := el) notNil ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7152
            el isImageOrForm ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7153
                el colorMap notNil ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7154
                    rslt := menuPanel lightenedImageOnDevice:el
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7155
                ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7156
            ] ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7157
                (displayLabel isKindOf:LabelAndIcon) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7158
                    ((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7159
                        form := menuPanel lightenedImageOnDevice:form
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7160
                    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7161
                    ((image := el image) notNil and:[image colorMap notNil]) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7162
                        image := menuPanel lightenedImageOnDevice:image
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7163
                    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7164
                    rslt := LabelAndIcon form:form image:image string:(el string).
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7165
                ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7166
            ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7167
        ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7168
        rslt
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7169
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7170
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7171
    displayLabel isArray ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7172
        disabledDisplayLabel := Array new:(displayLabel size).
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7173
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7174
        displayLabel keysAndValuesDo:[:anIndex :aLabel|
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7175
            disabledDisplayLabel at:anIndex put:(block value:aLabel)
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7176
        ]
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7177
    ] ifFalse:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7178
        disabledDisplayLabel := block value:displayLabel
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7179
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7180
    ^ disabledDisplayLabel
794
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7181
!
5ac9de4f5c82 basic routine to access the images; at the moment
ca
parents: 781
diff changeset
  7182
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  7183
fetchDeviceResources
2373
8dbf026f0bd1 bug fix: specific font used by item
ca
parents: 2372
diff changeset
  7184
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7185
    disabledDisplayLabel := nil.
1829
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  7186
    self fetchImages.
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  7187
!
bd8b95c5bb89 migration fixes
Claus Gittinger <cg@exept.de>
parents: 1825
diff changeset
  7188
616
a6157b083830 support of different styles
ca
parents: 608
diff changeset
  7189
fetchImages
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7190
    "fetch my icon images"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7191
2118
89d02ebc5b65 optimize #labels: and #fetchImages in Item. discard block
ca
parents: 2113
diff changeset
  7192
    |icon|
89d02ebc5b65 optimize #labels: and #fetchImages in Item. discard block
ca
parents: 2113
diff changeset
  7193
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7194
    (displayLabel isNil or:[displayLabel isString]) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7195
        ^ self
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7196
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7197
    displayLabel isImageOrForm ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7198
        displayLabel := menuPanel imageOnMyDevice:displayLabel.
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7199
        ^ self.  
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7200
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7201
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7202
    (displayLabel isKindOf:LabelAndIcon) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7203
        (icon := displayLabel image) notNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7204
            displayLabel image:(menuPanel imageOnMyDevice:icon)
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7205
        ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7206
        (icon := displayLabel icon) notNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7207
            displayLabel icon:(menuPanel imageOnMyDevice:icon)
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7208
        ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7209
        ^ self
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7210
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7211
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7212
    displayLabel isArray ifFalse:[^ self].            
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7213
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7214
    displayLabel keysAndValuesDo:[:i :el|
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7215
        (el notNil and:[el isString not]) ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7216
            el isImageOrForm ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7217
                displayLabel at:i put:(menuPanel imageOnMyDevice:el).
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7218
            ] ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7219
                el class == LabelAndIcon ifTrue:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7220
                    (icon := el image) notNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7221
                        el image:(menuPanel imageOnMyDevice:icon)
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7222
                    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7223
                    (icon := el icon) notNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2485
diff changeset
  7224
                        el icon:(menuPanel imageOnMyDevice:icon)
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7225
                    ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7226
                ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7227
            ]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7228
        ]
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  7229
    ].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7230
!
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7231
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7232
updateAccessCharacterFor:aLabel
2550
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  7233
    "replace the & by the short-key attribute (i.e. underline it)"
1dc3745fc313 do not show the menus label again as fly by help
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
  7234
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7235
    |s i rest label pos|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7236
3192
a64a9c9143c4 shortcuts... processing
ca
parents: 3189
diff changeset
  7237
    accessCharacter notNil ifTrue:[^ aLabel].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7238
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7239
    aLabel isString ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7240
        aLabel class == LabelAndIcon ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7241
            aLabel string:(self updateAccessCharacterFor:(aLabel string))
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7242
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7243
        ^ aLabel
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7244
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7245
    s := aLabel size.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7246
    i := 1.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7247
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7248
    label := aLabel.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7249
    pos := menuItem accessCharacterPosition.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7250
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7251
    [((i := label indexOf:$& startingAt:i) ~~ 0 and:[i < s])] whileTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7252
        rest := label copyFrom:(i+1).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7253
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7254
        i == 1 ifTrue:[label := rest]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7255
              ifFalse:[label := (label copyFrom:1 to:(i-1)), rest].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7256
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7257
        (label at:i) == $& ifTrue:[i := i + 1] ifFalse:[pos := i].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7258
        s := s - 1.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7259
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7260
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7261
    (pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7262
        ^ label
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7263
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7264
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7265
    label isText ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7266
        label := Text string:label
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7267
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7268
    label emphasisAt:pos add:#underline.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7269
    ^ label
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7270
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7271
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  7272
!MenuPanel::Item methodsFor:'printing & storing'!
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  7273
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  7274
displayString
1690
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  7275
    ^ self class name, '[', label printString, ']'
38b23fb1a931 add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents: 1688
diff changeset
  7276
1573
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  7277
! !
fd124ee2bce5 shortcutKeys; arrange layout if selection changed
ca
parents: 1572
diff changeset
  7278
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7279
!MenuPanel::Item methodsFor:'private'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7280
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7281
activeBackgroundColor
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7282
    "returns the active background color derived from menuPanel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7283
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7284
    menuItem isButton ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7285
        ^ menuPanel buttonActiveBackgroundColor
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7286
    ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7287
    ^ menuPanel activeBackgroundColor
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7288
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7289
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7290
activeForegroundColor
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7291
    "returns the active foreground color derived from menuPanel"
650
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7292
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7293
    ^menuPanel activeForegroundColor
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7294
!
29dcdf6a5994 button and label translation support added
tz
parents: 638
diff changeset
  7295
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  7296
backgroundColor
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7297
    "returns the background color derived from menuPanel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7298
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7299
    menuItem isButton ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7300
        ^ menuPanel buttonPassiveBackgroundColor
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7301
    ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7302
    ^ menuPanel backgroundColor
727
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  7303
!
3ba54333342a button style from style sheet
tz
parents: 723
diff changeset
  7304
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7305
backgroundColorFromLabel
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7306
    "returns the background color derived from label or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7307
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7308
    |run|
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7309
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7310
    label isText ifFalse:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7311
    run := label emphasis.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7312
    run size == 0 ifTrue:[^ nil ].
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7313
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7314
    run := run first.
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7315
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7316
    run size == 0 ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7317
        (run value isColor and:[run key == #backgroundColor]) ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7318
            ^ run value
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7319
        ]
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7320
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7321
        run do:[:r|
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7322
            (r value isColor and:[r key == #backgroundColor]) ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7323
                ^ r value
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7324
            ]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7325
        ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7326
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7327
  ^ nil
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7328
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7329
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7330
buttonEnteredBackgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7331
    "returns the background color to use when thhe mouse has entered 
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7332
     derived from menuPanel"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7333
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7334
    menuItem isButton ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7335
        ^ menuPanel buttonEnteredBackgroundColor
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7336
    ].
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7337
    ^ menuPanel backgroundColor
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7338
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7339
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  7340
findSubMenuIn:aRecv
1051
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  7341
    "ask the receiver for a submenu aspect, sending it
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  7342
     #aspectFor: first; then trying the selector itself.
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  7343
     Ignore the error if that message is not understood
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  7344
     (but not other message-not-understoods)"
a448c854fcbb catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  7345
2069
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2064
diff changeset
  7346
    |subm sel numArgs|
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7347
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7348
    aRecv isNil ifTrue:[^ nil].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7349
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7350
    sel := menuItem submenuChannel.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7351
    sel isString ifFalse:[^ nil].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7352
    sel := sel asSymbol.
2069
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2064
diff changeset
  7353
    numArgs := sel numArgs.
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2064
diff changeset
  7354
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2064
diff changeset
  7355
    numArgs == 0 ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7356
        MessageNotUnderstood handle:[:ex |
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7357
            |selector|
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7358
2737
b0daaddb418b Use MessageNotUnderstood>>#selector
Stefan Vogel <sv@exept.de>
parents: 2736
diff changeset
  7359
            ((selector := ex selector) == sel
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7360
            or:[selector == #aspectFor:]) ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7361
                ex reject
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7362
            ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7363
        ] do:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7364
            subm := aRecv aspectFor:sel.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7365
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7366
        subm notNil ifTrue:[^ subm].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7367
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7368
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  7369
    (Array with:(aRecv) with:(aRecv class))
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  7370
    do:[:aPossibleReceiver |
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7371
        MessageNotUnderstood handle:[:ex|
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7372
            ex message selector == sel ifFalse:[ ex reject ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7373
        ] do:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7374
            numArgs == 0 ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7375
                subm := aPossibleReceiver perform:sel
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7376
            ] ifFalse:[ 
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7377
                numArgs == 1 ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7378
                    subm := aPossibleReceiver perform:sel with:(menuItem argument ? menuPanel)
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7379
                ] ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7380
                    subm := aPossibleReceiver perform:sel with:(menuItem argument) with:menuPanel
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7381
                ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7382
            ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7383
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7384
        subm notNil ifTrue:[^ subm].
1795
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7385
    ].
6afd0e768267 submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents: 1793
diff changeset
  7386
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  7387
    ^ subm
2043
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  7388
133a9674bcdf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2042
diff changeset
  7389
    "Modified: / 30.10.2001 / 13:28:25 / cg"
663
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  7390
!
b418df6b72d8 retrive submenu:
ca
parents: 661
diff changeset
  7391
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7392
indicationValue
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7393
    "returns indication value or nil in case of no indication"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7394
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7395
    |numArgs sel recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7396
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7397
    indication isNil ifTrue:[^ nil].                                    "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7398
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7399
    indication isSymbol ifFalse:[                                       
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7400
        ^ indication value == true                                      "block or model"
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7401
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7402
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7403
    (numArgs := indication numArgs) == 2 ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7404
        recv := menuPanel receiver.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7405
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7406
        (recv isValueModel) ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7407
            (recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7408
                sel := indication copyFrom:1 to:(indication indexOf:$:).
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7409
                sel := sel asSymbol.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7410
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7411
                MessageNotUnderstood handle:[:ex| 
2737
b0daaddb418b Use MessageNotUnderstood>>#selector
Stefan Vogel <sv@exept.de>
parents: 2736
diff changeset
  7412
                    ex selector == sel ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7413
                        ex reject
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7414
                    ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7415
                ] do:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7416
                    sel := recv perform:sel with:(menuItem argument)
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7417
                ]
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7418
            ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7419
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7420
        ^ sel value == true
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7421
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7422
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7423
    numArgs ~~ 0 ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7424
        sel := (indication copyWithoutLast:1) asSymbol
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7425
    ] ifFalse:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7426
        sel := indication
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7427
    ].    
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7428
    sel := self aspectAt:sel.
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7429
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7430
    sel isValueModel ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7431
        indication := sel.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7432
        indication addDependent:self.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7433
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7434
    ^ sel value == true
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7435
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7436
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7437
indicationValue:aValue
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7438
    "set the indication value"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7439
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7440
    |numArgs recv|
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7441
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7442
    indication isNil ifTrue:[^ self].                                   "no indication specified"
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7443
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7444
    indication isSymbol ifFalse:[                                       
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7445
        indication perform:#value: with:aValue ifNotUnderstood:nil.     "block or model"
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7446
        ^ self
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7447
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7448
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7449
    (numArgs := indication numArgs) == 0 ifTrue:[                       "no arguments to selector; cannot set"
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7450
        ^ self
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  7451
    ].
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  7452
524
d602402ce5ae receiver might be a ValueModel; VW
ca
parents: 510
diff changeset
  7453
    recv := menuPanel receiver.
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7454
    recv isValueModel ifTrue:[^ self].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7455
1218
6ce43fcb2603 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1217
diff changeset
  7456
    recv isNil ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7457
        recv := menuPanel application.
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7458
        recv isNil ifTrue:[^ self].
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7459
    ].
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7460
2069
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2064
diff changeset
  7461
    MessageNotUnderstood handle:[:ex| 
2737
b0daaddb418b Use MessageNotUnderstood>>#selector
Stefan Vogel <sv@exept.de>
parents: 2736
diff changeset
  7462
        (ex selector ~~ indication) ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7463
            ex reject
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7464
        ].
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7465
        self ifNotInUIBuilderInfoPrintCR:
2771
3328da9f3df8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2770
diff changeset
  7466
            ('MenuPanel::Item [info]: application (%1) does not respond to: %2' 
3328da9f3df8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2770
diff changeset
  7467
             bindWith:recv classNameWithArticle with:indication).
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7468
    ] do:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7469
        numArgs == 1 ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7470
            recv perform:indication with:aValue
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7471
        ] ifFalse:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7472
            recv perform:indication with:(menuItem argument ? self) with:aValue
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7473
        ]
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7474
    ].
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7475
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7476
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7477
isEntered
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7478
    "returns true if the mouse pointer is over the item"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7479
1081
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7480
    ^ menuPanel enteredItem == self
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7481
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7482
    "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
  7483
!
fd67c198eeea added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  7484
464
a788fdce92e2 add submenuChannel
ca
parents: 461
diff changeset
  7485
separatorType
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7486
    "returns type of separator line or nil"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7487
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  7488
    |c lbl|
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7489
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7490
    self isSeparator ifFalse:[
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7491
        ^ nil
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7492
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7493
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  7494
    (lbl := label value) isNil ifTrue:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7495
        ^ #singleLine
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7496
    ].
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7497
390
a0cf1f90da2c enabled and style
ca
parents: 389
diff changeset
  7498
    lbl size == 1 ifTrue:[
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7499
        c := lbl first.
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7500
        c == $- ifTrue:[^ #singleLine].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7501
        c == $= ifTrue:[^ #doubleLine].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7502
    ].
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7503
    ^ #blankLine
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  7504
!
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  7505
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  7506
setupSubmenu
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7507
    |appl master recv submenuHolder submenu submenuEncoding channel|
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7508
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7509
    channel := menuItem submenuChannel value.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7510
    channel isNil ifTrue:[ ^ subMenu ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7511
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7512
    subMenu notNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7513
        menuItem keepLinkedMenu ifTrue:[ ^ subMenu ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7514
    ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7515
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7516
    channel isSymbol ifFalse:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7517
        submenuHolder := channel
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7518
    ] ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7519
        appl := menuPanel application.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7520
        appl isNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7521
            appl := menuPanel receiver.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7522
            appl notNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7523
                (submenuHolder := self findSubMenuIn:appl) isNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7524
                    [submenuHolder isNil 
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7525
                     and:[(master := appl perform:#masterApplication ifNotUnderstood:nil) notNil
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7526
                          and:[master ~~ appl]]] whileTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7527
                        appl := master.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7528
                        submenuHolder := self findSubMenuIn:appl.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7529
                    ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7530
                ]
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  7531
            ].
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7532
        ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7533
        submenuHolder isNil ifTrue:[    
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7534
            (submenuHolder := self findSubMenuIn:appl) isNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7535
                (recv := menuPanel receiver) ~~ appl ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7536
                    appl := recv.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7537
                    submenuHolder := self findSubMenuIn:appl
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  7538
                ]
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  7539
            ]
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7540
        ]
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7541
    ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7542
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7543
    (submenu := submenuHolder value) isArray ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7544
        submenuEncoding := submenu.    
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  7545
        submenu := Menu decodeFromLiteralArray:submenuEncoding.
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7546
        "/ cg: linked menus also may contain translations ...
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7547
        submenu notNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7548
            appl notNil ifTrue:[
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7549
                submenu findGuiResourcesIn:appl.
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7550
            ]                
2232
5784671fb497 when searching for a sumbenus application, do NOT
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  7551
        ].
2364
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7552
    ].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7553
    "/ appl notNil ifTrue:[submenu application:appl].
c72f35819bda remove attribute submenuChannel - derives from menuItem
ca
parents: 2362
diff changeset
  7554
    self submenu:submenu.
1130
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  7555
    ^ subMenu
fb79ef4aeec8 style changes
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
  7556
3222
828febe4d844 use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3206
diff changeset
  7557
    "Modified: / 27-03-2007 / 08:43:25 / cg"
2485
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  7558
!
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  7559
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  7560
spaceBetweenEmptyLines
b3d92f4a5f7b correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  7561
        ^ 3
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7562
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7563
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7564
!MenuPanel::Item methodsFor:'queries'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7565
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  7566
canChangeVisibility
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  7567
    "return true if I am not always visible; can only be changed by a selector
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7568
     otherwise there is a change notification raised if the model changed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7569
3122
81ab6b6b4ff2 *** empty log message ***
fm
parents: 3112
diff changeset
  7570
    ^ isVisible isSymbol or:[isVisible isValueModel]
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  7571
"/  ^ isVisible notNil and:[isVisible ~~ true]
3112
01341303806d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3092
diff changeset
  7572
01341303806d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3092
diff changeset
  7573
    "Modified: / 11-10-2006 / 21:43:31 / cg"
3122
81ab6b6b4ff2 *** empty log message ***
fm
parents: 3112
diff changeset
  7574
    "Modified: / 12-10-2006 / 09:30:48 / User"
1217
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  7575
!
c6a4c536aa8c care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents: 1212
diff changeset
  7576
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7577
canSelect
1699
d7b522c4b332 grabing and recomputation of items
ca
parents: 1698
diff changeset
  7578
    "returns true if item is selectable; no separator, visible and enabled.
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7579
     in case of a choice (RadioButton) i have to check for the choiceValue"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7580
2362
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7581
    self isSeparator ifTrue:[^ false].
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7582
7a0f2e986289 rawLabel visa isSeparator
ca
parents: 2360
diff changeset
  7583
    (self isVisible and:[self enabled]) ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7584
        (choice isNil or:[choice value ~= menuItem choiceValue]) ifTrue:[
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7585
            ^ true
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7586
        ].
1078
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  7587
    ].
3adf74275ebd support choice for buttons
ca
parents: 1076
diff changeset
  7588
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7589
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7590
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7591
containsPoint:aPoint
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7592
    "returns true if aPoint is contained in my layout"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7593
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7594
    (self isVisible and:[layout notNil]) ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7595
        ^ layout containsPoint:aPoint
2046
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7596
    ].
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7597
    ^ false
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7598
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7599
    "Created: / 13.11.2001 / 13:55:31 / cg"
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7600
!
012798480de6 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2043
diff changeset
  7601
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7602
containsPointX:x y:y
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7603
    "returns true if point is contained in my layout"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7604
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7605
    (self isVisible and:[layout notNil]) ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7606
        ^ layout containsPointX:x y:y
505
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  7607
    ].
562d5661a855 check for valid layout
ca
parents: 502
diff changeset
  7608
    ^ false
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7609
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7610
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7611
hasDelayedMenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7612
    "returns true if a delayed menu exists"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7613
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  7614
    self hasSubmenu ifFalse:[
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  7615
        ^ false
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7616
    ].
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  7617
    menuItem itemValue notNil ifTrue:[ ^ true ].
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  7618
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  7619
    (indication isNil and:[choice isNil]) ifTrue:[
2326
a8447d6449eb show submenu indicator (for button) even for normal menus
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  7620
        ^ false
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7621
    ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7622
    ^ true
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7623
!
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7624
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7625
hasDelayedMenuIndicator
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7626
    "returns true if the item has a delayed menu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7627
     and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7628
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7629
    menuPanel isPopUpView ifFalse:[
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7630
        ^ self hasDelayedMenu
2214
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7631
    ].
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7632
    ^ false
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7633
!
8eefad87cf62 drawing delayed menu indicators... first try not yet finished
ca
parents: 2199
diff changeset
  7634
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7635
hasIndication
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7636
    "returns true if on/off indication exists"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7637
1726
a4733a8b51e1 support labeled arrays; printing vertical (font not yet supported)
ca
parents: 1723
diff changeset
  7638
    ^ indication notNil
407
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7639
!
40554a07d5aa fix bugs; implement indication; text with backgroundColor
ca
parents: 399
diff changeset
  7640
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7641
hasMenuIndicator
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7642
    "returns true if the item has a delayed menu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7643
     and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7644
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7645
    menuPanel isPopUpView ifFalse:[
2360
aa745970fcb9 *** empty log message ***
ca
parents: 2359
diff changeset
  7646
        ^ self hasSubmenu and:[menuItem isButton]
2344
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7647
    ].
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7648
    ^ false
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7649
!
d8a5d00c004e different icons for delayed and non-delayed menus
Claus Gittinger <cg@exept.de>
parents: 2342
diff changeset
  7650
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7651
hasSubmenu
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7652
    "returns true if the item is configured as an subMenu entry"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7653
    
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7654
    ^ subMenu notNil or:[ menuItem submenuChannel notNil ]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7655
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7656
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7657
isEnabled
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7658
    "returns the enabled state"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7659
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7660
    ^ self enabled
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7661
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7662
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  7663
isSeparator
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7664
    "returns true if item is a separator"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7665
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7666
    ^ displayLabel isNil
608
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  7667
!
0d8d910768af use default font derived from style
ca
parents: 601
diff changeset
  7668
2159
1eac041aeb3d toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  7669
isToggle
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7670
    "returns true if on/off indication exists"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7671
2159
1eac041aeb3d toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  7672
    ^ self hasIndication and:[ self isButton ]
1eac041aeb3d toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  7673
!
1eac041aeb3d toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  7674
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7675
isVisible
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7676
    "returns the visibility state"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7677
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7678
    |state|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7679
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7680
    isVisible isSymbol ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7681
        state := self aspectAt:isVisible.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7682
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7683
        state isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7684
            isVisible := state.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7685
            isVisible addDependent:self.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7686
            state := isVisible.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7687
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7688
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7689
        state := isVisible
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7690
    ].
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7691
  ^ state value ~~ false
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7692
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7693
    "Modified: / 5.10.1998 / 12:08:28 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7694
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7695
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7696
isVisible:something
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7697
    "change the visibility state; if the state changed, a redraw is performed"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7698
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7699
    |oldState newState|
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7700
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7701
    isVisible isNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7702
        oldState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7703
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7704
        oldState := isVisible value.
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7705
        isVisible isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7706
            isVisible removeDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7707
        ]
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7708
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7709
    isVisible := something.
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7710
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7711
    isVisible isNil ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7712
        newState := true
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7713
    ] ifFalse:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7714
        isVisible isValueModel ifTrue:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7715
            isVisible addDependent:self
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7716
        ] ifFalse:[
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7717
            isVisible isSymbol ifTrue:[^ self]
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7718
        ].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7719
        menuPanel shown ifFalse:[^ self].
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7720
        newState := isVisible value.
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7721
    ].
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7722
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7723
    newState ~~ oldState ifTrue:[
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7724
        menuPanel mustRearrange
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7725
    ]
1164
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7726
e6e9633abf48 kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents: 1156
diff changeset
  7727
    "Modified: / 5.10.1998 / 12:12:04 / cg"
712
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7728
!
4167a3f39bff support of visible/invisible items
ca
parents: 711
diff changeset
  7729
2433
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7730
needsItemSpaceWhenDrawing
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7731
    ^ self isSeparator not and:[menuItem isButton not]
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7732
!
49341ed11830 rawLabel/label/textLabel confusion cleaned up
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  7733
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7734
shortcutKeyAsString
3301
bb7fab3e1d7a *** empty log message ***
fm
parents: 3295
diff changeset
  7735
    "converts shortcutKey to a text object for the menu-label-hint"
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7736
2972
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7737
    |shortcutKey|
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7738
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7739
    shortcutKey := menuItem shortcutKey.
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  7740
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  7741
    shortcutKey isNil ifTrue:[
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7742
        ^ nil
1609
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  7743
    ].
2c8d62894ebe optimize searchinf for shortCutKeys
ca
parents: 1600
diff changeset
  7744
    shortcutKey isCharacter ifTrue:[
3301
bb7fab3e1d7a *** empty log message ***
fm
parents: 3295
diff changeset
  7745
        shortcutKey == Character space ifFalse:[
bb7fab3e1d7a *** empty log message ***
fm
parents: 3295
diff changeset
  7746
            ^ 'Space'
bb7fab3e1d7a *** empty log message ***
fm
parents: 3295
diff changeset
  7747
        ].
2972
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7748
        ^ shortcutKey asString
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7749
    ].
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7750
    ^ menuPanel device shortKeyStringFor:shortcutKey.
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7751
65841fbd0933 shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents: 2936
diff changeset
  7752
    "Modified: / 08-08-2006 / 15:46:24 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7753
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7754
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7755
!MenuPanel::Item methodsFor:'selection'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7756
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7757
isSelected
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7758
    "returns true if item is selected"
1998
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  7759
5059b7c9cd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  7760
    ^ menuPanel notNil and:[menuPanel selection == self]
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7761
!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7762
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7763
isSelected:isSelected
1473
1f62652f146e use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
  7764
    "change selection to a state. Dependant on the state open or hide an existing
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7765
     submenu and perform a redraw"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7766
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7767
    (isSelected and:[menuPanel notNil]) ifFalse:[
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7768
        self invalidate.
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7769
        self hideSubmenu.
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7770
        ^ self
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7771
    ].
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7772
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7773
    menuPanel realized ifFalse:[ ^ self ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7774
2359
de4236cc8e7b *** empty log message ***
ca
parents: 2355
diff changeset
  7775
    (indication isNil or:[menuItem isButton not]) ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7776
        self invalidate
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7777
    ].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7778
    self hasSubmenu ifFalse:[ ^ self].
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7779
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7780
    self hasDelayedMenu ifTrue:[
2249
cb1073891ea8 add: #selection:openMenu:
ca
parents: 2238
diff changeset
  7781
        menuPanel openDelayed:self
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7782
    ] ifFalse:[
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  7783
        self setupSubmenu.
2374
975fa3542e82 replace ifNil and ifNotNil
ca
parents: 2373
diff changeset
  7784
        subMenu notNil ifTrue:[ self openSubmenu ].
1701
026ece539435 prepare delayed open of submenus
ca
parents: 1699
diff changeset
  7785
    ].
3133
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  7786
dd8417f3373b code cleanup; comments
Claus Gittinger <cg@exept.de>
parents: 3131
diff changeset
  7787
    "Modified: / 07-11-2006 / 11:08:03 / cg"
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7788
! !
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7789
2692
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7790
!MenuPanel::Item::Adornment methodsFor:'accessing'!
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7791
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7792
argument2
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7793
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7794
  ^ argument2
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7795
!
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7796
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7797
argument2:anArgumentOrNil
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7798
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7799
    argument2 := anArgumentOrNil
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7800
! !
93566e299318 +actionValue2
werner
parents: 2681
diff changeset
  7801
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7802
!MenuPanel::ScrollActivity class methodsFor:'default icons'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7803
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7804
icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7805
    "This resource specification was automatically generated
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7806
     by the ImageEditor of ST/X."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7807
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7808
    "Do not manually edit this!! If it is corrupted,
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7809
     the ImageEditor may not be able to read the specification."
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7810
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7811
    "
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7812
     self icon inspect
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7813
     ImageEditor openOnClass:self andSelector:#icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7814
    "
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7815
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7816
    <resource: #image>
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7817
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7818
    ^Icon
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7819
	constantNamed:#'MenuPanel::Scrolling class icon'
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7820
	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
  7821
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7822
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7823
!MenuPanel::ScrollActivity class methodsFor:'instance creation'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7824
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7825
new
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7826
    ^ self basicNew initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7827
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7828
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7829
!MenuPanel::ScrollActivity methodsFor:'accessing'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7830
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7831
activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7832
    "returns the active menu the scrolling is activated on; nil
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7833
     is returned if scrolling is deactivated"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7834
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7835
    ^ activeMenu
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7836
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7837
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7838
direction
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7839
    "returns the scroll-direction"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7840
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7841
    ^ direction
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7842
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7843
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7844
iconAt:aDirection on:aMenu
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7845
    |icon device index|
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7846
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7847
    device := aMenu device.
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7848
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7849
    aDirection == #PREV ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7850
	aMenu verticalLayout ifTrue:[index := 3]    "/ 3 - 1 * 90  180
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7851
			    ifFalse:[index := 2]    "/ 2 - 1 * 90  90   
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7852
    ] ifFalse:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7853
	aMenu verticalLayout ifTrue:[index := 1]    "/ 1 - 1 * 90  0
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7854
			    ifFalse:[index := 4]    "/ 4 - 1 * 90  270
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7855
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7856
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7857
    icon := icons at:index.
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7858
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7859
    (icon isNil or:[icon device ~~ device]) ifTrue:[
3147
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7860
	icon := self class icon.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7861
	index > 1 ifTrue:[ icon := icon rotated:(index - 1 * 90) ]
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7862
		 ifFalse:[ icon := icon copy ].
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7863
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7864
	icon := icon onDevice:device.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7865
	icon clearMaskedPixels.
b7c2db746f84 conditionalRight fix
Claus Gittinger <cg@exept.de>
parents: 3144
diff changeset
  7866
	icons at:index put:icon
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7867
    ].
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7868
    ^ icon
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7869
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7870
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7871
!MenuPanel::ScrollActivity methodsFor:'initialization'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7872
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7873
initialize
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7874
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7875
    semaLock := RecursionLock new.
2018
2130a45b7dfe checkin from browser
ca
parents: 2016
diff changeset
  7876
    icons    := Array new:4.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7877
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7878
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7879
!MenuPanel::ScrollActivity methodsFor:'queries'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7880
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7881
isActive
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7882
    "returns true if scrolling is activated"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7883
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7884
    ^ activeMenu notNil
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7885
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7886
2137
0aaeeab0811d renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  7887
!MenuPanel::ScrollActivity methodsFor:'user operations'!
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7888
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7889
startIfRequiredAt:aDirection on:aMenu comesViaButtonPress:comesViaButtonPress
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7890
    "start scrolling; returns true if scrolling is activated"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7891
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7892
    |bounds index isScrolledMenu boundsOnRoot|
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7893
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7894
    isScrolledMenu := (aDirection notNil and:[aMenu notNil and:[aMenu hasScrollers]]).
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7895
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7896
    semaLock critical:[
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7897
        self stop.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7898
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7899
        isScrolledMenu ifTrue:[
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7900
            bounds := aMenu scrollerBoundsAt:aDirection.
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7901
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7902
            comesViaButtonPress ifFalse:[
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7903
                boundsOnRoot := Rectangle origin:(aMenu device translatePointToRoot:(bounds origin) fromView:aMenu)
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7904
                                          extent:(bounds extent).
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7905
            ].
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7906
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7907
            activeMenu := aMenu.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7908
            direction  := aDirection.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7909
            index      := aMenu indexOfItemAtScroller:aDirection.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7910
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7911
            index ~~ 0 ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7912
                scrollTask := 
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7913
                    [ 
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7914
                        |item step continue|
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7915
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7916
                        [
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7917
                            step := (aDirection == #PREV) ifTrue:[-1] ifFalse:[1].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7918
                            ( aMenu shown and:[(item := aMenu itemAt:index) notNil] ) ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7919
                                aMenu makeItemVisible:item.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7920
                                index := index + step.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7921
                            ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7922
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7923
                            Delay waitForSeconds:(ButtonController defaultInitialDelay).
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7924
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7925
                            [
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7926
                                continue := (aMenu shown and:[(item := aMenu itemAt:index) notNil]).
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7927
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7928
                                boundsOnRoot notNil ifTrue:[
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7929
                                    continue ifTrue:[
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7930
                                        continue := boundsOnRoot containsPoint:aMenu sensor mousePoint.
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7931
                                    ] ifFalse:[
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7932
                                        boundsOnRoot := nil.
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7933
                                    ]
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7934
                                ].
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7935
                                continue
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7936
                            ]  whileTrue:[
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7937
                                aMenu makeItemVisible:item.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7938
                                Delay waitForSeconds:(ButtonController defaultRepeatDelay).
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7939
                                index := index + step.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7940
                            ].
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7941
                            item := nil.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7942
                        ] ensure:[
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7943
                            activeMenu := direction := scrollTask := nil.
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7944
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7945
                            item notNil ifTrue:[
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7946
                                "/ process was killed
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7947
                                aMenu invalidate:bounds
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7948
                            ]
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7949
                        ].
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7950
                        boundsOnRoot notNil ifTrue:[ aMenu invalidate:bounds ].
2860
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7951
                    ] forkAt:8.
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7952
            ]
300aa94bb73e A2989: redraw optimieren
ca
parents: 2855
diff changeset
  7953
        ]
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7954
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7955
    ^ bounds notNil
2047
62de65e3a61b initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  7956
2048
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  7957
    "Created: ca"
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  7958
ba472f3f46c7 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2047
diff changeset
  7959
    "Modified: / 13.11.2001 / 20:15:52 / cg"
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7960
!
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7961
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7962
stop
2870
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7963
    "stop scrolling; returns true if the scrolling was activated otherwise false"
0a92cf0052f5 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  7964
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7965
    |task resp|
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7966
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7967
    activeMenu isNil ifTrue:[
2231
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7968
        ^ false
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7969
    ].
3295
53616022ca5f activate scroller if button is pressed and moved over scroller
ca
parents: 3246
diff changeset
  7970
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7971
    semaLock critical:[
2231
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7972
        resp := activeMenu notNil.
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7973
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7974
        (task := scrollTask) notNil ifTrue:[
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7975
            scrollTask := nil.
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7976
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7977
            Error handle:[:ex|
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7978
            ] do:[
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7979
                task terminateWithAllSubprocessesInGroup.
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7980
                task waitUntilTerminated.
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7981
            ].
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7982
        ].
65cec3d10fb1 Change sends to obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2220
diff changeset
  7983
        activeMenu := direction := nil.
2016
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7984
    ].
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7985
    ^ resp
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7986
! !
f1ba765d4fa7 add scrolling - first
ca
parents: 2012
diff changeset
  7987
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7988
!MenuPanel class methodsFor:'documentation'!
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7989
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7990
version
3402
5941cc1ff429 flybyhelp - give menuPanel achance to provide a text
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  7991
    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.464 2008-05-19 13:10:25 cg Exp $'
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7992
! !
2199
61ef4fe363e7 *** empty log message ***
ca
parents: 2187
diff changeset
  7993
388
dce33f8bb806 intitial checkin
ca
parents:
diff changeset
  7994
MenuPanel initialize!