Menu.st
author Claus Gittinger <cg@exept.de>
Mon, 18 Jul 2011 09:38:29 +0200
changeset 2927 49bd291d76e0
parent 2918 44a68f3ffba5
child 2952 1cedbbc95433
permissions -rw-r--r--
changed: #startOpaqueDrag:offset:extent:in:at:atEnd:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1354
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     1
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     3
              All Rights Reserved
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     4
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     5
 This software is furnished under a license and may be used
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     6
 only in accordance with the terms of that license and with the
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     9
 other person.  No title to or ownership of the software is
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    10
 hereby transferred.
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    11
"
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
    12
"{ Package: 'stx:libview2' }"
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
    13
2854
d37c539b59ad inherit from model, for cheap dependents.
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
    14
Model subclass:#Menu
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
    15
	instanceVariableNames:'items groupSizes receiver'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Views-Support'
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
1354
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    23
copyright
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    24
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    25
 COPYRIGHT (c) 1997 by eXept Software AG
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    26
              All Rights Reserved
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    27
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    28
 This software is furnished under a license and may be used
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    29
 only in accordance with the terms of that license and with the
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    31
 be provided or otherwise made available to, or used by, any
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    32
 other person.  No title to or ownership of the software is
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    33
 hereby transferred.
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    34
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    35
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    36
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    37
!
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    38
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    not yet finished Menu class - this will eventually replace
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    most of the MenuView and PopUpMenu stuff.
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    (and hopefully be ST-80 compatible ...)
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    For now, only a subset of the full protocol is implemented.
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    [author:]
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
    48
	Claus Gittinger
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    [see also:]
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
    51
	MenuItem
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
    52
	PopUpMenu
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    56
!Menu class methodsFor:'instance creation'!
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    57
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    58
labelArray:arrayOfString lines:linesArray values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    59
    "return a menu with menu items built with labels from arrayOfString (not Symbols).  
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    60
     The linesArray describes which menu items are the last menu item in their group. 
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    61
     The valueArray contains value objects for each menu item 
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    62
     (or is nil if no value objects are specified)."
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    63
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    64
    |nLabel valueArray menuItems groupLengths|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    65
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    66
    nLabel := arrayOfString size.
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    67
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    68
    valueArrayOrNil isNil ifTrue:[
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    69
        (valueArray := arrayOfString isEmpty) ifTrue: [
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    70
            valueArray := #()
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    71
        ] ifFalse:[
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    72
            valueArray := (1 to:nLabel)
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    73
        ]
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    74
    ] ifFalse:[
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    75
        valueArray := valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    76
    ].
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    77
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    78
    nLabel ~~ valueArray size ifTrue: [
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    79
        ^ self error: 'illegal menu combination'
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    80
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    81
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    82
    menuItems := Array new:nLabel.
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    83
    1 to:nLabel do:[:i |
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    84
        |mi v|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    85
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    86
        mi := MenuItem labeled:(arrayOfString at:i) asString.
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    87
        v := valueArray at:i.
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    88
        (v isKindOf:Menu) ifTrue:[mi submenu:v].
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    89
        menuItems at:i put:mi
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    90
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    91
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    92
    (linesArray size == 0) ifTrue:[
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    93
        groupLengths := (menuItems isEmpty)
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    94
                            ifTrue: [Array new:0]
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    95
                            ifFalse: [Array with:menuItems size]
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    96
    ] ifFalse:[
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    97
        groupLengths := Array new:(linesArray size + 1).
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    98
        groupLengths at:1 put:linesArray first.
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    99
        2 to:linesArray size do: [:i | 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   100
            groupLengths at:i put:((linesArray at:i) - (linesArray at:i - 1))
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   101
        ].
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   102
        groupLengths at:groupLengths size put:(menuItems size - linesArray last).
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   103
    ].
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   104
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   105
    ^ self new 
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   106
        menuItems:menuItems 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   107
        menuItemGroups:groupLengths 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   108
        values:valueArray
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   109
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   110
    "Modified: / 19.4.1998 / 11:30:18 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   111
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   112
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   113
labelArray:arrayOfString values:valueArrayOrNil
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   114
    "return a menu with menu items built with labels from arrayOfString (not Symbols).  
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   115
     The valueArray contains value objects for each menu item 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   116
     (or is nil if no value objects are specified)."
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   117
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   118
    ^ self 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   119
        labelArray:arrayOfString 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   120
        lines:nil 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   121
        values: valueArrayOrNil
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   122
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   123
!
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   124
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   125
labelList:arrayOfGroupStrings values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   126
    |labels lines|
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   127
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   128
    lines := arrayOfGroupStrings collect:[:each | each size].
2017
0cdc1c537fa0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
   129
    labels := arrayOfGroupStrings collectAll:[:eachGroup | eachGroup].
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   130
    ^ self labelArray:labels lines:lines values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   131
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   132
    "Modified: 20.6.1997 / 10:46:45 / cg"
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   133
    "Created: 13.9.1997 / 10:35:46 / cg"
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   134
!
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   135
738
f7e6b6cd3855 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   136
labels:aString lines:linesArray values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   137
    ^ self 
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   138
	labelArray:(aString asCollectionOfLines)
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   139
	lines:linesArray
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   140
	values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   141
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   142
    "Created: / 31.10.1997 / 03:12:20 / cg"
738
f7e6b6cd3855 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   143
    "Modified: / 31.10.1997 / 03:23:42 / cg"
1525
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   144
!
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   145
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   146
labels:aString values:valueArrayOrNil
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   147
    ^ self 
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   148
        labelArray:(aString asCollectionOfLines)
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   149
        lines:#()
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   150
        values:valueArrayOrNil
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   151
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   152
    "Modified: / 31.10.1997 / 03:23:42 / cg"
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   153
    "Created: / 12.11.2001 / 16:06:36 / cg"
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   154
! !
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   155
1764
caf114053269 method category rename
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
   156
!Menu methodsFor:'Compatibility-ST80'!
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   157
2126
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   158
addLine
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   159
    self addSeparator
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   160
!
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   161
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   162
indexOfMenuItem:anItem
2433
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   163
    ^ items indexOf:anItem
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   164
2433
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   165
    "Created: / 27.10.1997 / 16:34:19 / cg"
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   166
!
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   167
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   168
indexOfMenuItemForWhich:aBlock
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   169
    ^ items findFirst:aBlock
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   170
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   171
    "Created: / 27.10.1997 / 16:34:19 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   172
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   173
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   174
menuButtons
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   175
    "ST-80 seems to use a special menuButton class here.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   176
     Here, kludge a collection of menuItems."
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   177
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   178
    ^ items
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   179
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   180
    "Created: / 27.10.1997 / 16:33:35 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   181
! !
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   182
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   183
!Menu methodsFor:'Compatibility-Squeak'!
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   184
2764
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   185
add:label target:target selector:selector
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   186
    self addItem:(MenuItem label:label value:[target perform:selector]).
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   187
!
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   188
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   189
balloonTextForLastItem:aString
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   190
    items last helpText:aString
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   191
!
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   192
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   193
labels:labels lines:lines selections:selections
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   194
    |labelArray|
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   195
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   196
    labels isString ifTrue:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   197
        labelArray := labels asCollectionOfLines.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   198
    ] ifFalse:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   199
        labelArray := labels.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   200
    ].
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   201
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   202
    1 to:labelArray size do:[:idx |
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   203
        |item|
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   204
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   205
        item := MenuItem new.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   206
        item label:(labelArray at:idx).
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   207
        item value:(selections at:idx).
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   208
        self addItem:item.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   209
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   210
        (lines includes:idx) ifTrue:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   211
            self addSeparator.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   212
        ].
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   213
    ].
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   214
! !
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   215
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
!Menu methodsFor:'accessing'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
2916
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   218
atMenuItemLabeled:aString putSubmenu:aMenu visible:visible
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   219
    (self menuItemLabeled:aString)
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   220
        submenu:aMenu;
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   221
        isVisible:visible
2916
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   222
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   223
    "Created: / 30-06-2011 / 10:30:22 / cg"
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   224
!
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   225
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   226
atNameKey:aNameKey
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   227
    "return the menuItem for the given nameKey; nil if no such item is in the menu.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   228
     Searches in allItems (i.e. also in subMenus)"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   229
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   230
    self allItemsDo:[:anItem|
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   231
	anItem nameKey == aNameKey ifTrue:[^ anItem]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   232
    ].
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   233
    ^ nil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   234
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   235
    "Modified: / 27.10.1997 / 15:12:00 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   236
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   237
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   238
groupSizes
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   239
    ^ groupSizes
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   240
!
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   241
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   242
groupSizes:something
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   243
    groupSizes := something.
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   244
!
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   245
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   246
items
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   247
    ^ items
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   248
!
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   249
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   250
labelAt:anIndex
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   251
    "gets the label of the menu item at the given index or nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   252
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   253
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   254
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   255
    (item := self menuItemAt:anIndex) notNil ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   256
        ^ item label
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   257
    ].
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   258
    ^ nil
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   259
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   260
    "Modified: / 2.2.1998 / 13:28:32 / cg"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   261
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   262
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   263
labelAtValue:aValue
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   264
    "gets the label of the menu item assigned to value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   265
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   266
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   267
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   268
    item := self menuAndSubmenusDetectItem:[:anItem | anItem value == aValue ].
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   269
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   270
    item notNil ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   271
        ^ item label
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   272
    ].
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   273
    ^ nil
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   274
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   275
    "Modified: / 2.2.1998 / 13:28:28 / cg"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   276
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   277
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
labels
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "return a collection of labels from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
977
e07277070839 return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   281
    items isNil ifTrue:[^ #()].
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    ^ items collect:[:anItem | anItem label]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   284
    "Created: / 25.2.1997 / 19:47:53 / cg"
977
e07277070839 return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   285
    "Modified: / 19.6.1998 / 02:36:22 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   288
lastItem
2584
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   289
    "returns the last item or nil, if there are none"
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   290
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   291
    ^ items isEmptyOrNil 
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   292
        ifTrue:[nil]
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   293
        ifFalse:[items last]
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   294
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   295
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   296
lines
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   297
    "return the indexes of the menu items that are the last menu item in their group (except the very last)."
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   298
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   299
    |lines groupSz|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   300
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   301
    (groupSz := groupSizes size) <= 1 ifTrue: [^ Array new].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   302
    lines := Array new:(groupSz - 1).
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   303
    lines at:1 put:groupSizes first.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   304
    2 to:(groupSz-1) do:[:i |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   305
        lines at:i put:(lines at:(i - 1)) + (groupSizes at:i)
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   306
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   307
    ^ lines
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   308
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   309
    "Modified: / 2.2.1998 / 13:28:19 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   310
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   311
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   312
menuItemAt:index 
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   313
    "gets the menu item at the given index. When the index is out of bounds
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   314
     nil is returned"
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   315
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   316
    (index > 0 and:[ index <= items size ]) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   317
        ^ items at:index
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   318
    ].
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   319
    ^ nil
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   320
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   321
    "Modified: / 30-06-2011 / 10:51:39 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   322
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   323
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   324
menuItemLabeled:anItemLabel 
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   325
    "return the menuItem for the given nameKey; nil if no such item is in the menu.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   326
     Searches all items (i.e. also submenu items)"
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   327
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   328
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   329
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   330
            |l|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   331
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   332
            ((l := anItem label) sameAs:anItemLabel) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   333
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   334
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   335
            (l includes:$&) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   336
                ((l copyWithout:$&) sameAs:anItemLabel) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   337
                    ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   338
                ]
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   339
            ]
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   340
        ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   341
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   342
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   343
    "Created: / 13-09-1997 / 10:25:16 / cg"
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   344
    "Modified: / 30-06-2011 / 10:51:44 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   345
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   346
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   347
menuItemWithArgument:aValue 
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   348
    "return the menuItem for the given value; nil if no such item is in the menu.
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   349
     Searches all items (i.e. also submenu items)"
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   350
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   351
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   352
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   353
            |l|
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   354
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   355
            (anItem argument = aValue) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   356
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   357
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   358
        ].
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   359
    ^ nil
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   360
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   361
    "Created: / 19-04-2011 / 14:42:18 / cg"
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   362
    "Modified: / 30-06-2011 / 10:51:50 / cg"
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   363
!
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   364
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   365
menuItemWithValue:aValue 
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   366
    "return the menuItem for the given value; nil if no such item is in the menu.
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   367
     Searches all items (i.e. also submenu items)"
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   368
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   369
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   370
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   371
            |l|
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   372
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   373
            (anItem value == aValue) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   374
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   375
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   376
        ].
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   377
    ^ nil
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   378
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   379
    "Created: / 13-09-1997 / 10:25:16 / cg"
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   380
    "Modified: / 30-06-2011 / 10:51:56 / cg"
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   381
!
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   382
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   383
menuItems
1327
b0b482a84570 menuItems always returns a collection (never nil)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   384
    ^ items ? #()
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   385
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   386
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   387
menuItems:aCollectionOfMenuItems menuItemGroups:sizes values:values
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   388
    |n|
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   389
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   390
    items := groupSizes := nil.
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   391
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   392
    aCollectionOfMenuItems size == 0 ifTrue:[ ^ self ].
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   393
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    items := aCollectionOfMenuItems.
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   395
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   396
    sizes size > 0 ifTrue:[
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   397
        groupSizes := sizes.
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   398
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   399
        n := sizes inject:0 into:[:sumSoFar :this | sumSoFar + this].
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   400
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   401
        n = items size ifTrue:[
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   402
            groupSizes := sizes copyWithoutLast:1
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   403
        ]
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   404
    ].
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   406
    values notNil ifTrue:[
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   407
        items with:values do:[:anItem :aValue |anItem value:aValue]
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   408
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   409
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   410
    "Modified: / 19.4.1998 / 11:47:34 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
1116
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   413
menuPerformer:something
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   414
    "set the receiver of the menu messages"
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   415
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   416
    receiver := something.
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   417
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   418
    "Modified: / 2.2.1998 / 13:26:29 / cg"
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   419
!
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   420
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   421
numberOfItems
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   422
    "return the number of items in this menu"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   423
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   424
    ^ items size
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   425
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   426
    "Created: / 6.3.1997 / 15:15:53 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   427
    "Modified: / 2.2.1998 / 13:26:40 / cg"
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   428
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   429
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   430
receiver
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   431
    "return the receiver of the menu messages"
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   432
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   433
    ^ receiver
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   434
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   435
    "Modified: / 2.2.1998 / 13:26:20 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   436
!
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   437
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   438
receiver:something
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   439
    "set the receiver of the menu messages"
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   440
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   441
    receiver := something.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   442
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   443
    "Modified: / 2.2.1998 / 13:26:29 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   444
!
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   445
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
valueAt:index
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    "return a collection of values from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
    ^ (items at:index) value
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    "Created: 25.2.1997 / 19:49:41 / cg"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   454
valueAt:anIndex put:aValue
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   455
    "put value an an index"
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   456
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   457
    (items at:anIndex) value:aValue
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   458
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   459
    "Created: 6.3.1997 / 15:15:48 / cg"
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   460
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   461
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
values
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    "return a collection of values from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
    ^ items collect:[:anItem | anItem value]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    "Created: 25.2.1997 / 19:49:29 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   468
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   469
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   470
values:aCollectionOfValues
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   471
    "return a collection of values from my items"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   472
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   473
    |s|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   474
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   475
    s := aCollectionOfValues readStream.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   476
    self itemsDo:[:item |
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   477
        |val|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   478
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   479
        val := s next.
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   480
        item value:val
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   481
    ].
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   482
    s atEnd ifFalse:[
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   483
        self error:'not enough elements in the value collection' mayProceed:true
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   484
    ]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   485
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   486
    "Created: / 27.10.1997 / 15:15:47 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   487
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   488
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   489
visibleMenuItemGroups
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   490
    |itemGroups visibleItemGroups nextItem|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   491
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   492
    itemGroups := OrderedCollection new.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   493
    nextItem := 1.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   494
    groupSizes do:[:groupSize |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   495
        itemGroups addLast: (items copyFrom:nextItem to:nextItem + groupSize - 1).
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   496
        nextItem := nextItem + groupSize
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   497
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   498
    self hasHiddenItems ifFalse:[^ itemGroups].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   499
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   500
    "Remove the hidden items."
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   501
    visibleItemGroups := OrderedCollection new.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   502
    itemGroups do:[:eachItemGroup |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   503
        |visibleItemGroup|
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   504
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   505
        visibleItemGroup := eachItemGroup reject:[:eachMenuItem | eachMenuItem hidden].
2129
e68ef88be0c7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   506
        visibleItemGroup notEmpty ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   507
            visibleItemGroups addLast: visibleItemGroup
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   508
        ]
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   509
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   510
    ^ visibleItemGroups
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   511
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   512
    "Created: / 27.10.1997 / 15:07:50 / cg"
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   513
    "Modified: / 2.2.1998 / 13:25:52 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   516
!Menu methodsFor:'accessing-resource'!
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   517
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   518
findGuiResourcesIn:aResourceContainerOrApplication
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   519
    "setup a resource owner"
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   520
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   521
    receiver isNil ifTrue:[
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   522
        receiver := aResourceContainerOrApplication
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   523
    ].
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   524
    ^ self 
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   525
        findGuiResourcesIn:aResourceContainerOrApplication 
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   526
        rememberResourcesIn:(ValueHolder new)
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   527
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   528
    "Modified: / 26-10-2006 / 16:37:57 / cg"
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   529
!
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   530
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   531
findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   532
    "setup a resource owner"
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   533
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   534
    |resolvedItems rcv|
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   535
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   536
    "/ cg: do not recursively change the receiver - it could be set for the top
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   537
    "/ menu via #receiver: by the application.
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   538
    "/ if the submenu's receiver is nil, the parentmenus receiver will be used, which is ok.
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   539
    "/ But if it was changed below, we would need a recursive setting in #receiver: as well.
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   540
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   541
"/    receiver isNil ifTrue:[
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   542
"/        receiver := aResourceContainerOrApplication
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   543
"/    ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   544
    items isEmptyOrNil ifTrue:[^ self].
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   545
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   546
    resolvedItems := OrderedCollection new.
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   547
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   548
    items do:[:anItem |
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   549
        anItem isMenuSlice ifTrue:[ 
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   550
            |resItems|
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   551
2059
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   552
            rcv := aResourceContainerOrApplication.
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   553
            [rcv notNil and:[resItems isNil]] whileTrue:[
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   554
                resItems := anItem resolveSliceMenuItemsIn:rcv
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   555
                                   rememberResourcesIn:aValueHolderOrNil.
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   556
                rcv := rcv perform:#masterApplication ifNotUnderstood:nil.
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   557
            ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   558
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   559
            resItems notEmptyOrNil ifTrue:[
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   560
                resolvedItems addAll:resItems.
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   561
            ]
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   562
        ] ifFalse:[
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   563
            anItem 
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   564
                findGuiResourcesIn:aResourceContainerOrApplication 
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   565
                rememberResourcesIn:aValueHolderOrNil.
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   566
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   567
            resolvedItems add:anItem.
1534
292c277fcf6a findGuiResources... now sets the receiver, if not yet set
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
   568
        ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   569
    ].
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   570
    items := resolvedItems.
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   571
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   572
    "Modified: / 22-09-2010 / 13:34:38 / cg"
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   573
! !
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   574
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   575
!Menu methodsFor:'adding & removing'!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   576
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   577
addItem:aMenuItem
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   578
    "add a menuItem at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   579
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   580
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   581
    items isNil ifTrue:[
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   582
        items := OrderedCollection new
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   583
    ] ifFalse:[
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   584
        items := items asOrderedCollection
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   585
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   586
    items add:aMenuItem.
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   587
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   588
    "Modified: / 4.8.1998 / 17:31:13 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   589
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   590
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   591
addItem:aMenuItem beforeIndex:anIndex
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   592
    "add a menuItem at some position;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   593
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   594
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   595
    items isNil ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   596
        items := OrderedCollection new
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   597
    ] ifFalse:[
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   598
        items := items asOrderedCollection
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   599
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   600
    items add:aMenuItem beforeIndex:anIndex.
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   601
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   602
    "Modified: / 4.8.1998 / 17:31:39 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   603
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   604
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   605
addItem:aMenuItem value:aValue
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   606
    aMenuItem value:aValue.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   607
    self addItem:aMenuItem.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   608
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   609
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   610
addItemGroup:aGroup
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   611
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   612
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   613
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   614
    groupSizes isNil ifTrue:[
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   615
        groupSizes := OrderedCollection with:items size.
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   616
    ].
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   617
    groupSizes add:aGroup size.
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   618
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   619
    aGroup do:[:item |
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   620
        self addItem:item
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   621
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   622
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   623
    "Created: / 27.10.1997 / 15:02:15 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   624
    "Modified: / 4.8.1998 / 17:32:06 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   625
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   626
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   627
addItemGroup:aGroup values:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   628
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   629
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   630
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   631
    aGroup with:values do:[:item :value |
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   632
        item value:value
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   633
    ].
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   634
    self addItemGroup:aGroup
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   635
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   636
    "Modified: / 4.8.1998 / 17:32:18 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   637
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   638
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   639
addItemGroupLabels:labels values:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   640
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   641
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   642
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   643
    |items|
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   644
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   645
    items := labels with:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   646
                collect:[:label :value | 
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   647
                            MenuItem label:label value:value
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   648
                        ].
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   649
    self addItemGroup:items
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   650
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   651
    "Created: / 27.10.1997 / 19:49:27 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   652
    "Modified: / 4.8.1998 / 17:35:22 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   653
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   654
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   655
addItemLabel:label value:value
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   656
    "add an item at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   657
     useful to build a menu programmatically (or, to add more items dynamically)"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   658
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   659
    self addItem:(MenuItem label:label value:value)
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   660
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   661
    "Created: / 27.10.1997 / 19:47:12 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   662
    "Modified: / 4.8.1998 / 17:34:44 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   663
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   664
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   665
addSeparator
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   666
    "add a separating line item at the end;
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   667
     useful to build a menu programmatically (or, to add more items dynamically)"
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   668
2814
f75f27d92a5b changed: #addSeparator
Claus Gittinger <cg@exept.de>
parents: 2764
diff changeset
   669
    self addItem:(MenuItem separator).
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   670
!
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   671
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   672
removeItem:aMenuItem
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   673
    "remove an item from the menu"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   674
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   675
    |idx|
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   676
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   677
    items notNil ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   678
        idx := items identityIndexOf:aMenuItem.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   679
        idx ~~ 0 ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   680
            items removeAtIndex:idx
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   681
        ]
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   682
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   683
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   684
    "Created: / 13.9.1997 / 10:27:31 / cg"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   685
    "Modified: / 2.2.1998 / 13:26:49 / cg"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   686
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   687
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   688
removeItemAt:anIndex
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   689
    "remove item at an index
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   690
    "
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   691
    anIndex <= items size ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   692
        ^ items removeAtIndex:anIndex
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   693
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   694
    ^ nil
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   695
! !
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   696
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
!Menu methodsFor:'converting'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   699
asOldStylePopUpMenuFor:anApplicationOrNil
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   700
    "a temporary kludge - will vanish, when oldStyle MenuView and PopUpMenu are gone"
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   701
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   702
    |menuView itemsShown|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   703
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   704
    itemsShown := items 
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   705
        select:[:each |
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   706
            |visibilityInItem|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   707
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   708
            visibilityInItem := each isVisible.
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   709
            visibilityInItem isNil ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   710
                true
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   711
            ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   712
                visibilityInItem isBoolean ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   713
                    visibilityInItem
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   714
                ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   715
                    visibilityInItem isSymbol ifTrue:[
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   716
                        anApplicationOrNil isNil
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   717
                        or:[ (anApplicationOrNil perform:visibilityInItem) value ].
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   718
                    ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   719
                        visibilityInItem value
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   720
                    ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   721
                ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   722
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   723
        ].
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   724
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   725
    menuView := MenuView 
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   726
        labels:(itemsShown collect:[:each | each label])
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   727
        selectors:(itemsShown collect:[:each | each value])
2751
d0729d604864 changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2584
diff changeset
   728
        accelerators:(itemsShown collect:[:each | each shortcutKey])
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   729
        args:(itemsShown collect:[:each | each argument])
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   730
        receiver:receiver.
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   731
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   732
    itemsShown doWithIndex:[:each :idx |
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   733
        |enabledInItem enabled|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   734
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   735
        enabledInItem := each enabled.
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   736
        enabledInItem notNil ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   737
            enabledInItem isSymbol ifTrue:[
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   738
                enabled := anApplicationOrNil isNil or:[ (anApplicationOrNil perform:enabledInItem) ].
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   739
            ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   740
                enabledInItem isBoolean ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   741
                    enabled := enabledInItem
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   742
                ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   743
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   744
            enabled value ifFalse:[
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   745
                menuView disable:idx
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   746
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   747
        ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   748
    ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   749
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   750
    menuView actions:(itemsShown collect:[:each | [ receiver perform:each value ]]).
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   751
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   752
    ^ PopUpMenu forMenu:menuView
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   753
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   754
    "Modified: / 30-06-2011 / 10:35:57 / cg"
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   755
!
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   756
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
fromLiteralArrayEncoding:aLiteralEncodedArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
    "read my contents from a aLiteralEncodedArray"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
    |items groups values|
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   762
    items := aLiteralEncodedArray at:2.
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   763
2864
f90017f2da66 changed: #fromLiteralArrayEncoding:
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   764
    items notNil ifTrue:[
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   765
        items := items collect:[:item | item decodeAsLiteralArray].
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   766
    ].
1405
c7775c10e8fd tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents: 1401
diff changeset
   767
    groups := aLiteralEncodedArray at:3 ifAbsent:nil.
c7775c10e8fd tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents: 1401
diff changeset
   768
    values := aLiteralEncodedArray at:4 ifAbsent:nil.
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   769
    self menuItems:items menuItemGroups:groups values:values.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    "extract from PD folder.st:
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   773
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   774
                        #rawLabel: 'left' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   775
                        #value: #left ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   776
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   777
                        #rawLabel: 'center' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   778
                        #value: #center ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   779
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   780
                        #rawLabel: 'right' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   781
                        #value: #right ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   782
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   783
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   784
             nil 
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
       ) decodeAsLiteralArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
    "
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   787
    "
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   788
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   789
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   790
                        #label: 'Straighten Up' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   791
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   792
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   793
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   794
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   795
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   796
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   797
            #(#straightenUp #inspect #halt ) 
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   798
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   799
    "
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   800
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   801
    "extract from iconicBrowser.st:
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   802
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   803
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   804
                        #label: 'Straighten Up' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   805
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   806
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   807
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   808
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   809
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   810
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   811
             #(1 2 3 )
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   812
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   813
    "
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   815
    "extract from refactory213.st:
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   816
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   817
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   818
                    #label: 'File List' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   819
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   820
                #(#MenuItem #label: 'File Editor...' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   821
                    #accessCharacterPosition: 6 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   822
                #(#MenuItem #label: 'Refactoring Tool...' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   823
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   824
                #(#MenuItem #label: 'Workspace' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   825
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   826
                #(#MenuItem #label: 'New Canvas' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   827
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   828
                #(#MenuItem #label: 'Palette' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   829
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   830
                #(#MenuItem #label: 'Canvas Tool' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   831
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   832
                #(#MenuItem #label: 'Image Editor' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   833
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   834
                #(#MenuItem #label: 'Menu Editor' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   835
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   836
                #(#MenuItem #label: 'Advanced' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   837
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   838
                #(#MenuItem #label: 'DLL and C Connect' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   839
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   840
                #(#MenuItem #label: 'System Transcript' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   841
                    #accessCharacterPosition: 8 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   842
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   843
              #(4 5 2 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   844
              #(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   845
        ) decodeAsLiteralArray startUp
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   846
    "
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   847
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   848
    "submenus:
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   849
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   850
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   851
                        #label: 'Foo' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   852
                        #submenu: #(#Menu #(
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   853
                                            #(#MenuItem #label: 'foo 1')     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   854
                                            #(#MenuItem #label: 'foo 2')     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   855
                                          )
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   856
                                          nil
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   857
                                          #(11 22)
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   858
                                   )     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   859
                 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   860
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   861
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   862
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   863
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   864
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   865
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   866
             #(1 2 3 )
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   867
       ) decodeAsLiteralArray startUp  
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   868
    "
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   869
2864
f90017f2da66 changed: #fromLiteralArrayEncoding:
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   870
    "Modified: / 08-08-2010 / 14:43:03 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   871
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   872
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   873
literalArrayEncoding
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   874
    "return myself encoded as a literal array"
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   875
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   876
    |coll array size|
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   877
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   878
    coll := OrderedCollection new.
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   879
    coll add:#Menu.
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   880
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   881
    (size := items size) == 0  ifTrue:[
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   882
        array := nil
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   883
    ] ifFalse:[
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   884
        array := Array new:size.
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   885
        items keysAndValuesDo:[:anIndex :anItem|
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   886
            array at:anIndex put:(anItem literalArrayEncoding)
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   887
        ]
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   888
    ].
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   889
    coll add:array.
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   890
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   891
    (size := groupSizes size) == 0  ifTrue:[
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   892
        array := nil
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   893
    ] ifFalse:[
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   894
        array := Array new:size.
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   895
        groupSizes keysAndValuesDo:[:anIndex :aSize|
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   896
            array at:anIndex put:(aSize literalArrayEncoding)
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   897
        ]
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   898
    ].
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   899
    coll add:array.
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   900
    coll add:nil.
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   901
  ^ coll asArray
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   904
!Menu methodsFor:'enumerating'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   905
2494
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   906
allItemsDetect:aOneArgBlock ifNone:exceptionalValue
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   907
    "find an element amongst each item and submenu items"
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   908
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   909
    self itemsDo:[:anItem|
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   910
        |sub subItem|
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   911
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   912
        (aOneArgBlock value:anItem) ifTrue:[^ anItem].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   913
        (sub := anItem submenu) notNil ifTrue:[
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   914
            subItem := sub allItemsDetect:aOneArgBlock ifNone:nil.
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   915
            subItem notNil ifTrue:[^ subItem].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   916
        ]
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   917
    ].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   918
    ^ exceptionalValue value
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   919
!
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   920
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   921
allItemsDo:aOneArgBlock
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   922
    "evaluate block on each item and submenu items
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   923
    "
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   924
    self itemsDo:[:anItem|
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   925
        |sub|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   926
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   927
        aOneArgBlock value:anItem.
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   928
        (sub := anItem submenu) notNil ifTrue:[
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   929
            sub allItemsDo:aOneArgBlock
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   930
        ]
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   931
    ]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   932
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   933
    "Modified: / 19.6.1998 / 00:34:53 / cg"
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   934
!
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   935
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   936
detectItem:aBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   937
    "evaluate the argument, aBlock for each item in the menu until the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   938
     block returns true; in this case return the item which caused the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   939
     true evaluation.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   940
     If none of the evaluations returns true, return the result of the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   941
     evaluation of the exceptionBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   942
    "
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   943
    ^ self detectItem:aBlock ifNone:[self errorNotFound]
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   944
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   945
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   946
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   947
detectItem:aBlock ifNone:exceptionBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   948
    "evaluate the argument, aBlock for each item in the menu until the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   949
     block returns true; in this case return the item which caused the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   950
     true evaluation.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   951
     If none of the evaluations returns true, return the result of the
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   952
     evaluation of the exceptionBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   953
    "
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   954
    items notNil ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   955
        ^ items detect:aBlock ifNone:exceptionBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   956
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   957
    ^ exceptionBlock value
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   958
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   959
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   960
itemsDo:aOneArgBlock
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   961
    "evaluate the block for each item in the current menu
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   962
    "
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   963
    items notNil ifTrue:[items do:aOneArgBlock]
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   964
!
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   965
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   966
menuAndSubmenusDetectItem:aOneArgBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   967
    "evaluate the block for each item in the current menu and all
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   968
     submenus. In case that the block returns a non nil argument,
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   969
     the item will be returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   970
    "
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   971
    |item|
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   972
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   973
    items notNil ifTrue:[
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   974
        items do:[:anItem|
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   975
            |sub|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   976
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   977
            (aOneArgBlock value:anItem) ifTrue:[
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   978
                ^ anItem
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   979
            ].
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   980
            (sub := anItem submenu) notNil ifTrue:[
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   981
                item := sub menuAndSubmenusDetectItem:aOneArgBlock.
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   982
                item notNil ifTrue:[
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   983
                    ^ item
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   984
                ]
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   985
            ]
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   986
        ]
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   987
    ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   988
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   989
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   990
    "Modified: / 19.6.1998 / 00:35:00 / cg"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   991
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   992
672
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   993
!Menu methodsFor:'kludged fixes'!
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   994
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   995
destroy
1599
85108dff13a9 comment
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   996
    "dummy to allow a menu to be used where a MenuView used to be"
672
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   997
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   998
    "Created: 28.7.1997 / 10:16:52 / cg"
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   999
! !
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1000
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1001
!Menu methodsFor:'menu items'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1002
2404
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1003
removeAllAccelerators
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1004
    self allItemsDo:[:eachItem |
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1005
        eachItem shortcutKey:nil.
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1006
    ].
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1007
!
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1008
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1009
someMenuItemLabeled:aLabel
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1010
    "get the menu item with that label; in case that the label
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1011
     is not found, nil is returned
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1012
    "
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1013
    ^ self someMenuItemLabeled:aLabel ifNone:nil
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1014
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1015
    "Created: / 14.11.1997 / 20:55:17 / cg"
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1016
!
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1017
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1018
someMenuItemLabeled:aLabel ifNone:exceptionBlock
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1019
    "get the menu item labeled aLabel; in case that the value
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1020
     is not found, the given exceptionBlock is executed and its value returned
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1021
    "
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1022
    |item|
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1023
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1024
    item := self menuAndSubmenusDetectItem:[:anItem| anItem label = aLabel].
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1025
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1026
    item notNil ifTrue:[
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1027
	^ item
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1028
    ].
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1029
    ^ exceptionBlock value
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1030
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1031
    "Created: / 14.11.1997 / 20:56:13 / cg"
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1032
!
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1033
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1034
someMenuItemWithValue:aValue
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1035
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1036
     is not found nil is returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1037
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1038
    ^ self someMenuItemWithValue:aValue ifNone:nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1039
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1040
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1041
someMenuItemWithValue:aValue ifNone:exceptionBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1042
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1043
     is not found, the given exceptionBlock is executed and returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1044
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1045
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1046
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1047
    item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1048
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1049
    item notNil ifTrue:[
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1050
	^ item
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1051
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1052
  ^ exceptionBlock value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1053
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1054
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1055
!Menu methodsFor:'queries'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1056
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1057
hasHiddenItems
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1058
    "test whether any item is hidden"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1059
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1060
    self allItemsDo:[:anItem|
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1061
	anItem isHidden ifTrue:[^ true]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1062
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1063
    ^ false
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1064
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1065
    "Modified: / 27.10.1997 / 15:12:44 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1066
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1067
2584
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1068
hasItems
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1069
    "test whether there are any menu-items"
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1070
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1071
    ^ items notEmptyOrNil
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1072
!
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1073
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1074
hasSubMenuAt:anIndex
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1075
    "test whether the menu item at the given index has a submenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1076
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1077
    ^ (self menuItemAt:anIndex) hasSubmenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1078
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1079
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
!Menu methodsFor:'startup'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1082
show
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1083
    "realize the menu at its last position; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1084
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1085
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1086
    ^ (MenuPanel menu:self) show ? 0
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1087
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1088
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1089
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1090
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1091
showAt:aPoint
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1092
    "realize the menu at aPoint; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1093
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1094
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1095
    ^ self showAt:aPoint resizing:true
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1096
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1097
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1098
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1099
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1100
showAt:aPoint resizing:aBoolean
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1101
    "realize the menu at aPoint; returns the value associated with the
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
     selected item, 0 if none was selected"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1104
    ^ ((MenuPanel menu:self) showAt:aPoint resizing:aBoolean) ? 0
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1105
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1106
    "Modified: / 8.7.1998 / 19:57:55 / cg"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1107
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1108
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1109
showAtPointer
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1110
    "realize the menu at the current pointer position; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1111
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1112
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1113
    ^ self startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1114
!
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1115
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1116
showCenteredIn:aView
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1117
    "realize the menu visible at the aView center; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1118
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1119
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1120
    ^ ((MenuPanel menu:self) showCenteredIn:aView) ? 0
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1121
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1122
    "Modified: / 8.7.1998 / 19:58:05 / cg"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1123
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1124
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1125
startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1126
    "display the menu as a popUp; returns the value associated with the
2039
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1127
     selected item, nil if none was selected.
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1128
     (should we return 0 form ST-80 compatibility ?)"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1129
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1130
    ^ (MenuPanel menu:self) startUp "/ ? 0
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1132
"   
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1133
        |m|
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1134
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1135
        m := #(#Menu #(
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1136
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1137
                                #rawLabel: 'left' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1138
                                #value: #left ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1139
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1140
                                #rawLabel: 'center' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1141
                                #value: #center ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1142
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1143
                                #rawLabel: 'right' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1144
                                #value: #right ) ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1145
                 #(2) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1146
                nil 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1147
        ) decodeAsLiteralArray.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1149
      Transcript showCR:(m startUp)        
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1150
"
938
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1151
!
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1152
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1153
startUpAt:aPoint
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1154
    "display the menu as a popUp at aPoint; returns the value associated with the
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1155
     selected item, 0 if none was selected"
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1156
939
f6df8fbf6b4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1157
    ^ ((MenuPanel menu:self) startUpAt:aPoint) ? 0
938
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1158
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1159
"   
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1160
        |m|
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1161
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1162
        m := #(#Menu #(
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1163
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1164
                                #rawLabel: 'left' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1165
                                #value: #left ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1166
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1167
                                #rawLabel: 'center' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1168
                                #value: #center ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1169
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1170
                                #rawLabel: 'right' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1171
                                #value: #right ) ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1172
                 #(2) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1173
                nil 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1174
        ) decodeAsLiteralArray.
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1175
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1176
      Transcript showCR:(m startUpAt:100@100)        
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1177
"
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1178
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1179
    "Created: / 21.5.1998 / 14:15:21 / cg"
939
f6df8fbf6b4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1180
    "Modified: / 21.5.1998 / 14:17:46 / cg"
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1181
!
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1182
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1183
startUpFor:originatingWidget
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1184
    "display the menu as a popUp; returns the value associated with the
2039
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1185
     selected item, nil if none was selected.
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1186
     (should we return 0 for ST-80 compatibility ?)"
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1187
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1188
    ^ (MenuPanel menu:self) startUpFor:originatingWidget "/ ? 0
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1189
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1190
"   
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1191
        |m|
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1192
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1193
        m := #(#Menu #(
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1194
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1195
                                #rawLabel: 'left' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1196
                                #value: #left ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1197
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1198
                                #rawLabel: 'center' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1199
                                #value: #center ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1200
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1201
                                #rawLabel: 'right' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1202
                                #value: #right ) ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1203
                 #(2) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1204
                nil 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1205
        ) decodeAsLiteralArray.
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1206
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1207
      Transcript showCR:(m startUp)        
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1208
"
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1209
!
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1210
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1211
startUpOrNil
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1212
    "display the menu as a popUp; returns the value associated with the
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1213
     selected item, nil if none was selected"
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1214
1405
c7775c10e8fd tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents: 1401
diff changeset
  1215
    ^ (MenuPanel menu:self) startUpOrNil
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
2764
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1220
version_CVS
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
  1221
    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.81 2011-06-30 09:19:00 cg Exp $'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
! !