Menu.st
author Claus Gittinger <cg@exept.de>
Wed, 26 Feb 2020 17:18:29 +0100
changeset 4455 93ed941728ff
parent 4442 510751dc36f5
permissions -rw-r--r--
#DOCUMENTATION by cg class: Menu comment/format in: #menuItemWithKey:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4036
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
     1
"{ Encoding: utf8 }"
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
     2
1354
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     3
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     4
 COPYRIGHT (c) 1997 by eXept Software AG
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     5
              All Rights Reserved
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     6
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     7
 This software is furnished under a license and may be used
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     8
 only in accordance with the terms of that license and with the
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    10
 be provided or otherwise made available to, or used by, any
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    11
 other person.  No title to or ownership of the software is
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    12
 hereby transferred.
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    13
"
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
    14
"{ Package: 'stx:libview2' }"
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
    15
3449
1ba7759f8a59 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3355
diff changeset
    16
"{ NameSpace: Smalltalk }"
1ba7759f8a59 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3355
diff changeset
    17
2854
d37c539b59ad inherit from model, for cheap dependents.
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
    18
Model subclass:#Menu
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
    19
	instanceVariableNames:'items groupSizes receiver'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Views-Support'
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
3778
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    25
Query subclass:#NeedResourcesQuery
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    26
	instanceVariableNames:''
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    27
	classVariableNames:''
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    28
	poolDictionaries:''
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    29
	privateIn:Menu
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    30
!
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
    31
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
1354
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    34
copyright
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    35
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    36
 COPYRIGHT (c) 1997 by eXept Software AG
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    37
              All Rights Reserved
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    38
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    39
 This software is furnished under a license and may be used
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    40
 only in accordance with the terms of that license and with the
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    42
 be provided or otherwise made available to, or used by, any
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    43
 other person.  No title to or ownership of the software is
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    44
 hereby transferred.
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    45
"
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    46
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    47
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    48
!
0c7e6c83b440 copyrights
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
    49
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
documentation
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    52
    Menu (aka MenuSpec, that's what it is!!).
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    53
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    54
    similar to UISpecifications, this describes the look, feel and behavior of
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    55
    popUpMenus, toolbarMenus and window menus.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    57
    Instances of me are usually created from menuSpec methods, which return a literal
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    58
    array description of me.
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    59
    Instances of me are processed by MenuBuilders, which create a real MenuView/MenuPanel
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    60
    from that into a window. 
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    62
    Should be relatively VisualWorks compatible (clean room development, by emulating the
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    63
    protocol needed by some public domain VW applications)
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    64
    
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    [author:]
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    66
        Claus Gittinger
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    [see also:]
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    69
        MenuItem
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
    70
        PopUpMenu
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    74
!Menu class methodsFor:'instance creation'!
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    75
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    76
labelArray:arrayOfString lines:linesArray values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    77
    "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
    78
     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
    79
     The valueArray contains value objects for each menu item 
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    80
     (or is nil if no value objects are specified)."
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    81
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    82
    |nLabel valueArray menuItems groupLengths|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    83
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    84
    nLabel := arrayOfString size.
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    85
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    86
    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
    87
        (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
    88
            valueArray := #()
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    89
        ] ifFalse:[
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
    90
            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
    91
        ]
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    92
    ] 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
    93
        valueArray := valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    94
    ].
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    95
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    96
    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
    97
        ^ self error: 'illegal menu combination'
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    98
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    99
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   100
    menuItems := Array new:nLabel.
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   101
    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
   102
        |mi v|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   103
3222
2bc1eca23bd7 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3185
diff changeset
   104
        mi := MenuItem label:(arrayOfString at:i) asString.
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   105
        v := valueArray at:i.
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   106
        (v isKindOf:Menu) ifTrue:[mi submenu:v].
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   107
        menuItems at:i put:mi
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   108
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   109
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   110
    (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
   111
        groupLengths := (menuItems isEmpty)
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   112
                            ifTrue: [Array new:0]
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   113
                            ifFalse: [Array with:menuItems size]
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   114
    ] ifFalse:[
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   115
        groupLengths := Array new:(linesArray size + 1).
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   116
        groupLengths at:1 put:linesArray first.
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   117
        2 to:linesArray size do: [:i | 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   118
            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
   119
        ].
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   120
        groupLengths at:groupLengths size put:(menuItems size - linesArray last).
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   121
    ].
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   122
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   123
    ^ self new 
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   124
        menuItems:menuItems 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   125
        menuItemGroups:groupLengths 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   126
        values:valueArray
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   127
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   128
    "Modified: / 19.4.1998 / 11:30:18 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   129
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   130
1174
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   131
labelArray:arrayOfString values:valueArrayOrNil
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   132
    "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
   133
     The valueArray contains value objects for each menu item 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   134
     (or is nil if no value objects are specified)."
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   135
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   136
    ^ self 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   137
        labelArray:arrayOfString 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   138
        lines:nil 
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   139
        values: valueArrayOrNil
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   140
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   141
!
f58d5c8cee82 added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   142
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   143
labelList:arrayOfGroupStrings values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   144
    |labels lines|
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   145
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   146
    lines := arrayOfGroupStrings collect:[:each | each size].
2017
0cdc1c537fa0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
   147
    labels := arrayOfGroupStrings collectAll:[:eachGroup | eachGroup].
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   148
    ^ self labelArray:labels lines:lines values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   149
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   150
    "Modified: 20.6.1997 / 10:46:45 / cg"
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   151
    "Created: 13.9.1997 / 10:35:46 / cg"
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   152
!
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   153
738
f7e6b6cd3855 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   154
labels:aString lines:linesArray values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   155
    ^ self 
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   156
	labelArray:(aString asCollectionOfLines)
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   157
	lines:linesArray
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   158
	values:valueArrayOrNil
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   159
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   160
    "Created: / 31.10.1997 / 03:12:20 / cg"
738
f7e6b6cd3855 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   161
    "Modified: / 31.10.1997 / 03:23:42 / cg"
1525
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   162
!
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   163
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   164
labels:aString values:valueArrayOrNil
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   165
    ^ self 
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   166
        labelArray:(aString asCollectionOfLines)
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   167
        lines:#()
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   168
        values:valueArrayOrNil
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   169
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   170
    "Modified: / 31.10.1997 / 03:23:42 / cg"
9008957b8ff7 compatibility
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   171
    "Created: / 12.11.2001 / 16:06:36 / cg"
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   172
! !
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   173
1764
caf114053269 method category rename
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
   174
!Menu methodsFor:'Compatibility-ST80'!
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   175
2126
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   176
addLine
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   177
    self addSeparator
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   178
!
79be7625f40f addLine: VW7 compat.
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
   179
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   180
indexOfMenuItem:anItem
2433
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   181
    ^ items indexOf:anItem
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   182
2433
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   183
    "Created: / 27.10.1997 / 16:34:19 / cg"
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   184
!
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   185
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   186
indexOfMenuItemForWhich:aBlock
632122b652eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   187
    ^ items findFirst:aBlock
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   188
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   189
    "Created: / 27.10.1997 / 16:34:19 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   190
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   191
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   192
menuButtons
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   193
    "ST-80 seems to use a special menuButton class here.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   194
     Here, kludge a collection of menuItems."
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   195
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   196
    ^ items
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   197
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   198
    "Created: / 27.10.1997 / 16:33:35 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   199
! !
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   200
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   201
!Menu methodsFor:'Compatibility-Squeak'!
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   202
2764
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   203
add:label target:target selector:selector
3185
0d09b958253d class: Menu
Claus Gittinger <cg@exept.de>
parents: 3117
diff changeset
   204
    self addItem:(MenuItem label:label itemValue:[target perform:selector]).
2764
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   205
!
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   206
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   207
balloonTextForLastItem:aString
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   208
    items last helpText:aString
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   209
!
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   210
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   211
labels:labels lines:lines selections:selections
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   212
    |labelArray|
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
    labels isString ifTrue:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   215
        labelArray := labels asCollectionOfLines.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   216
    ] ifFalse:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   217
        labelArray := labels.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   218
    ].
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   219
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   220
    1 to:labelArray size do:[:idx |
3355
214c2aa60193 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
   221
        self addItem:(MenuItem 
214c2aa60193 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
   222
                        label:(labelArray at:idx)
214c2aa60193 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
   223
                        itemValue:(selections at:idx)).
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   224
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   225
        (lines includes:idx) ifTrue:[
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   226
            self addSeparator.
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   227
        ].
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   228
    ].
3022
ce344185f4f4 menuitem protocol
Claus Gittinger <cg@exept.de>
parents: 2967
diff changeset
   229
ce344185f4f4 menuitem protocol
Claus Gittinger <cg@exept.de>
parents: 2967
diff changeset
   230
    "Modified: / 09-09-2012 / 13:08:55 / cg"
1782
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   231
! !
6a40c04cda8c squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   232
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
!Menu methodsFor:'accessing'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
2916
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   235
atMenuItemLabeled:aString putSubmenu:aMenu visible:visible
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   236
    (self menuItemLabeled:aString)
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   237
        submenu:aMenu;
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   238
        isVisible:visible
2916
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   239
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   240
    "Created: / 30-06-2011 / 10:30:22 / cg"
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   241
!
ff96b6187a5f added: #atMenuItemLabeled:putSubmenu:visible:
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   242
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   243
atNameKey:aNameKey
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   244
    "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
   245
     Searches in allItems (i.e. also in subMenus)"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   246
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   247
    self allItemsDo:[:anItem|
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   248
	anItem nameKey == aNameKey ifTrue:[^ anItem]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   249
    ].
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   250
    ^ nil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   251
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   252
    "Modified: / 27.10.1997 / 15:12:00 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   253
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   254
3340
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   255
atNameKey:aNameKey ifPresentDo:aBlock
3951
e5d3a0e5404f #DOCUMENTATION by mawalch
mawalch
parents: 3942
diff changeset
   256
    "look for a menuItem with the given nameKey. If one is found, aBlock is evaluated for it.
3340
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   257
     If not, nothing is done.
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   258
     Searches in allItems (i.e. also in subMenus).
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   259
     Returns the item or nil."
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   260
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   261
    |item|
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   262
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   263
    (item := self atNameKey:aNameKey) notNil ifTrue:[
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   264
        aBlock value:item.
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   265
    ].
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   266
    ^ item
3951
e5d3a0e5404f #DOCUMENTATION by mawalch
mawalch
parents: 3942
diff changeset
   267
e5d3a0e5404f #DOCUMENTATION by mawalch
mawalch
parents: 3942
diff changeset
   268
    "Modified (comment): / 16-05-2017 / 10:55:03 / mawalch"
3340
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   269
!
96d5a7df1639 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3254
diff changeset
   270
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   271
groupSizes
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   272
    ^ groupSizes
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   273
!
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   274
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   275
groupSizes:something
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   276
    groupSizes := something.
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   277
!
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   278
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   279
itemAtValue:aValue
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   280
    "gets the item which has aValue assigned as value"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   281
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   282
    ^ self menuAndSubmenusDetectItem:[:anItem | anItem value == aValue ].
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   283
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   284
    "Created: / 14-03-2017 / 16:12:37 / cg"
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   285
    "Modified (comment): / 24-05-2018 / 16:11:15 / Claus Gittinger"
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   286
!
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   287
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   288
items
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   289
    ^ items
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   290
!
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   291
3833
7bec3052fa14 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3778
diff changeset
   292
items:aCollectionOfMenuItems
7bec3052fa14 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3778
diff changeset
   293
    items := aCollectionOfMenuItems
7bec3052fa14 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3778
diff changeset
   294
!
7bec3052fa14 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3778
diff changeset
   295
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   296
labelAt:anIndex
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   297
    "gets the label of the menu item at the given index or nil"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   298
    
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   299
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   300
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   301
    (item := self menuItemAt:anIndex) notNil ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   302
        ^ item label
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   303
    ].
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   304
    ^ nil
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   305
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   306
    "Modified: / 02-02-1998 / 13:28:32 / cg"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   307
    "Modified (comment): / 24-05-2018 / 16:11:26 / Claus Gittinger"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   308
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   309
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   310
labelAtValue:aValue
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   311
    "gets the label of the menu item assigned to value"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   312
    
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   313
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   314
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   315
    item := self menuAndSubmenusDetectItem:[:anItem | anItem value == aValue ].
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   316
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   317
    item notNil ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   318
        ^ item label
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   319
    ].
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   320
    ^ nil
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   321
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   322
    "Modified: / 02-02-1998 / 13:28:28 / cg"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   323
    "Modified (comment): / 24-05-2018 / 16:11:30 / Claus Gittinger"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   324
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   325
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
labels
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "return a collection of labels from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
977
e07277070839 return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   329
    items isNil ifTrue:[^ #()].
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    ^ items collect:[:anItem | anItem label]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   332
    "Created: / 25.2.1997 / 19:47:53 / cg"
977
e07277070839 return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   333
    "Modified: / 19.6.1998 / 02:36:22 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   336
lastItem
2584
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   337
    "returns the last item or nil, if there are none"
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   338
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   339
    ^ items isEmptyOrNil 
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   340
        ifTrue:[nil]
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   341
        ifFalse:[items last]
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   342
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   343
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   344
lines
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   345
    "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
   346
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   347
    |lines groupSz|
737
c8bdd9dd8906 st80 stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   348
3752
42375c1cc0e9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 3449
diff changeset
   349
    (groupSz := groupSizes size) <= 1 ifTrue: [^ #()].
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   350
    lines := Array new:(groupSz - 1).
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   351
    lines at:1 put:groupSizes first.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   352
    2 to:(groupSz-1) do:[:i |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   353
        lines at:i put:(lines at:(i - 1)) + (groupSizes at:i)
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   354
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   355
    ^ lines
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   356
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   357
    "Modified: / 2.2.1998 / 13:28:19 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   358
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   359
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   360
menuItemAt:index 
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   361
    "gets the menu item at the given index. 
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   362
     When the index is out of bounds, nil is returned"
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   363
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   364
    (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
   365
        ^ items at:index
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   366
    ].
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   367
    ^ nil
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
    "Modified: / 30-06-2011 / 10:51:39 / cg"
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   370
    "Modified (comment): / 14-03-2017 / 16:11:31 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   371
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   372
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   373
menuItemLabeled:anItemLabel 
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   374
    "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
   375
     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
   376
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   377
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   378
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   379
            |l|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   380
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   381
            ((l := anItem label) sameAs:anItemLabel) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   382
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   383
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   384
            (l includes:$&) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   385
                ((l copyWithout:$&) sameAs:anItemLabel) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   386
                    ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   387
                ]
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   388
            ]
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   389
        ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   390
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   391
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   392
    "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
   393
    "Modified: / 30-06-2011 / 10:51:44 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   394
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   395
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   396
menuItemWithArgument:aValue 
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   397
    "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
   398
     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
   399
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   400
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   401
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   402
            |l|
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   403
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   404
            (anItem argument = aValue) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   405
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   406
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   407
        ].
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   408
    ^ nil
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   409
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   410
    "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
   411
    "Modified: / 30-06-2011 / 10:51:50 / cg"
2908
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   412
!
e21010b76553 added: #menuItemWithArgument:
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
   413
4455
93ed941728ff #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4442
diff changeset
   414
menuItemWithKey:aNameKey 
2952
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   415
    "return the menuItem for the given key; nil if no such item is in the menu.
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   416
     Searches all items (i.e. also submenu items)"
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   417
    
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   418
    self 
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   419
        allItemsDo:[:anItem | 
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   420
4455
93ed941728ff #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4442
diff changeset
   421
            (anItem nameKey = aNameKey) ifTrue:[
2952
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   422
                ^ anItem
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   423
            ].
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   424
        ].
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   425
    ^ nil
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   426
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   427
    "Created: / 19-04-2011 / 14:42:18 / cg"
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   428
    "Modified: / 30-06-2011 / 10:51:50 / cg"
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   429
    "Created: / 07-10-2011 / 15:04:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   430
!
1cedbbc95433 added: #menuItemWithKey:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2918
diff changeset
   431
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   432
menuItemWithValue:aValue 
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   433
    "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
   434
     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
   435
    
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   436
    self 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   437
        allItemsDo:[:anItem | 
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   438
            |l|
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   439
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   440
            (anItem value == aValue) ifTrue:[
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   441
                ^ anItem
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   442
            ].
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   443
        ].
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   444
    ^ nil
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   445
2918
44a68f3ffba5 fixes for Jan's menu rewriting in NewSystemBrowser
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   446
    "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
   447
    "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
   448
!
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
   449
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   450
menuItems
1327
b0b482a84570 menuItems always returns a collection (never nil)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   451
    ^ items ? #()
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   452
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   453
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   454
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
   455
    |n|
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   456
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   457
    items := groupSizes := nil.
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   458
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   459
    aCollectionOfMenuItems size == 0 ifTrue:[ ^ self ].
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   460
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    items := aCollectionOfMenuItems.
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   462
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   463
    sizes size > 0 ifTrue:[
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   464
        groupSizes := sizes.
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   465
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   466
        n := sizes inject:0 into:[:sumSoFar :this | sumSoFar + this].
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   467
900
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   468
        n = items size ifTrue:[
3117
3c7f6b69b2c5 Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 3028
diff changeset
   469
            groupSizes := sizes copyButLast: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
   470
        ]
aa93395cdb55 care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   471
    ].
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   473
    values notNil ifTrue:[
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   474
        items with:values do:[:anItem :eachValue |anItem value:eachValue]
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   475
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   476
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   477
    "Modified: / 19-04-1998 / 11:47:34 / cg"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   478
    "Modified (format): / 24-05-2018 / 15:18:25 / Claus Gittinger"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
1116
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   481
menuPerformer:something
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   482
    "set the receiver of the menu messages"
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   483
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   484
    receiver := something.
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   485
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   486
    "Modified: / 2.2.1998 / 13:26:29 / cg"
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   487
!
2b08dc4f8ae1 checkin from browser
tm
parents: 1111
diff changeset
   488
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   489
numberOfItems
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   490
    "return the number of items in this menu"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   491
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   492
    ^ items size
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   493
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   494
    "Created: / 6.3.1997 / 15:15:53 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   495
    "Modified: / 2.2.1998 / 13:26:40 / cg"
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   496
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   497
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   498
receiver
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   499
    "return the receiver of the menu messages"
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   500
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   501
    ^ receiver
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   502
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   503
    "Modified: / 2.2.1998 / 13:26:20 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   504
!
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   505
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   506
receiver:something
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   507
    "set the receiver of the menu messages"
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   508
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   509
    receiver := something.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   510
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   511
    "Modified: / 2.2.1998 / 13:26:29 / cg"
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   512
!
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   513
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
valueAt:index
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   515
    "return the value of an item"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    ^ (items at:index) value
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   519
    "Created: / 25-02-1997 / 19:49:41 / cg"
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   520
    "Modified (comment): / 14-03-2017 / 16:10:23 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   523
valueAt:anIndex put:aValue
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   524
    "put value at an index"
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   525
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   526
    (items at:anIndex) value:aValue
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   527
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   528
    "Created: / 06-03-1997 / 15:15:48 / cg"
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   529
    "Modified (comment): / 14-03-2017 / 16:10:29 / cg"
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   530
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   531
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
values
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    "return a collection of values from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    ^ items collect:[:anItem | anItem value]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    "Created: 25.2.1997 / 19:49:29 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   538
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   539
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   540
values:aCollectionOfValues
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   541
    "set the collection of values in my items"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   542
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   543
    |s|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   544
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   545
    s := aCollectionOfValues readStream.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   546
    self itemsDo:[:item |
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   547
        |val|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   548
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   549
        val := s next.
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   550
        item value:val
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   551
    ].
1111
6c1084c56d7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   552
    s atEnd ifFalse:[
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   553
        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
   554
    ]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   555
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   556
    "Created: / 27-10-1997 / 15:15:47 / cg"
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
   557
    "Modified (comment): / 14-03-2017 / 16:10:41 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   558
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   559
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   560
visibleMenuItemGroups
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   561
    |itemGroups visibleItemGroups nextItem|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   562
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   563
    itemGroups := OrderedCollection new.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   564
    nextItem := 1.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   565
    groupSizes do:[:groupSize |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   566
        itemGroups addLast: (items copyFrom:nextItem to:nextItem + groupSize - 1).
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   567
        nextItem := nextItem + groupSize
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   568
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   569
    self hasHiddenItems ifFalse:[^ itemGroups].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   570
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   571
    "Remove the hidden items."
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   572
    visibleItemGroups := OrderedCollection new.
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   573
    itemGroups do:[:eachItemGroup |
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   574
        |visibleItemGroup|
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   575
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   576
        visibleItemGroup := eachItemGroup reject:[:eachMenuItem | eachMenuItem hidden].
2129
e68ef88be0c7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   577
        visibleItemGroup notEmpty ifTrue:[
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   578
            visibleItemGroups addLast: visibleItemGroup
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   579
        ]
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   580
    ].
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   581
    ^ visibleItemGroups
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   582
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   583
    "Created: / 27.10.1997 / 15:07:50 / cg"
801
0b87e3ba8eaf comments
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   584
    "Modified: / 2.2.1998 / 13:25:52 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   587
!Menu methodsFor:'accessing-resource'!
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   588
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   589
findGuiResourcesIn:aResourceContainerOrApplication
4036
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   590
    "resolve national language translations from aResourceContainerOrApplication.
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   591
     Unless already set, remember aResourceContainerOrApplication as menu receiver"
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   592
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   593
    ^ self findGuiResourcesIn:aResourceContainerOrApplication for:nil
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   594
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   595
    "Modified: / 26-10-2006 / 16:37:57 / cg"
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   596
!
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   597
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   598
findGuiResourcesIn:aResourceContainerOrApplication for:aViewOrNil
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   599
    "resolve national language translations from aResourceContainerOrApplication.
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   600
     Unless already set, remember aResourceContainerOrApplication as menu receiver"
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   601
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   602
    receiver isNil ifTrue:[
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   603
        receiver := aResourceContainerOrApplication
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   604
    ].
3778
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
   605
    self 
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   606
        findGuiResourcesIn:aResourceContainerOrApplication
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   607
        for:aViewOrNil
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   608
        rememberResourcesIn:(ValueHolder new)
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   609
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   610
    "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
   611
!
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   612
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   613
findGuiResourcesIn:aResourceContainerOrApplication for:aViewOrNil rememberResourcesIn:aValueHolderOrNil
3845
fbeacbb4b90b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
   614
    "resolve national language translations from aResourceContainerOrApplication"
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   615
3967
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   616
    |need resolvedItems rcv|
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   617
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   618
    "/ 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
   619
    "/ menu via #receiver: by the application.
4036
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   620
    "/ if the submenu's receiver is nil, the parentmenu's receiver will be used, 
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   621
    "/ which is ok.
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   622
    "/ But if it was changed below, we would need a recursive setting in #receiver: as well.
4036
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   623
    "/    receiver isNil ifTrue:[
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   624
    "/        receiver := aResourceContainerOrApplication
05c32a3bb82e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3968
diff changeset
   625
    "/    ].
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   626
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   627
    items isEmptyOrNil ifTrue:[^ self].
3965
acb5ac4df86b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3951
diff changeset
   628
    "/ someone might catch queries and return some non-boolean
acb5ac4df86b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3951
diff changeset
   629
    "/ this is a bad side effect of Query being a subclass of Notification!!
3967
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   630
    (need := NeedResourcesQuery query) == true ifFalse:[
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   631
        need isBoolean ifFalse:[
3968
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   632
            "/ Transcript showCR:NeedResourcesQuery findHandler senderContext(GuiBrowser::ExpeccoGuiBrowser >> update:with:from: [70]).
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   633
            "/ self halt.
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   634
            "/ NeedResourcesQuery query.
3967
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   635
            thisContext fullPrintAllOn:Transcript
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   636
        ].    
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   637
        ^self
ab5639417445 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
   638
    ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   639
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   640
    resolvedItems := OrderedCollection new.
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   641
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   642
    items do:[:anItem |
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   643
        anItem isMenuSlice ifTrue:[ 
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   644
            |resItems|
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   645
2059
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   646
            rcv := aResourceContainerOrApplication.
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   647
            [rcv notNil and:[resItems isNil]] whileTrue:[
3965
acb5ac4df86b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3951
diff changeset
   648
                "/ pass down the original app while walking the master chain,
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   649
                "/ so that subclices can be redefined by the master
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   650
                "/ (is that what we want???)
3965
acb5ac4df86b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3951
diff changeset
   651
                resItems := anItem resolveSliceMenuItemsIn:rcv for:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil.
2059
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   652
                rcv := rcv perform:#masterApplication ifNotUnderstood:nil.
36e4aa247402 fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   653
            ].
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   654
            "/ if there is no mastApp, or it did not provide the slice,
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   655
            "/ ask the view itself.
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   656
            resItems isNil ifTrue:[
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   657
                aViewOrNil notNil ifTrue:[
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   658
                    resItems := anItem resolveSliceMenuItemsIn:aViewOrNil for:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil.
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   659
                ].
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   660
            ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   661
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   662
            resItems notEmptyOrNil ifTrue:[
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   663
                resolvedItems addAll:resItems.
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   664
            ]
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   665
        ] ifFalse:[
3449
1ba7759f8a59 class: Menu
Claus Gittinger <cg@exept.de>
parents: 3355
diff changeset
   666
            anItem findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil.
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   667
            resolvedItems add:anItem.
1534
292c277fcf6a findGuiResources... now sets the receiver, if not yet set
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
   668
        ].
1986
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   669
    ].
f819e439d917 *** empty log message ***
ca
parents: 1782
diff changeset
   670
    items := resolvedItems.
2269
7fae2df3ba48 resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   671
3968
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   672
    "Modified: / 23-07-2017 / 12:17:58 / cg"
4083
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   673
!
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   674
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   675
findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   676
    "resolve national language translations from aResourceContainerOrApplication"
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   677
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   678
    ^ self 
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   679
        findGuiResourcesIn:aResourceContainerOrApplication 
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   680
        for:nil
014bc5ef8149 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   681
        rememberResourcesIn:aValueHolderOrNil
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   682
! !
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   683
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   684
!Menu methodsFor:'adding & removing'!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   685
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   686
addItem:aMenuItem
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   687
    "add a menuItem at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   688
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   689
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   690
    items isNil ifTrue:[
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   691
        items := OrderedCollection new
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   692
    ] ifFalse:[
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   693
        items := items asOrderedCollection
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   694
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   695
    items add:aMenuItem.
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   696
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   697
    "Modified: / 4.8.1998 / 17:31:13 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   698
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   699
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   700
addItem:aMenuItem beforeIndex:anIndex
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   701
    "add a menuItem at some position;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   702
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   703
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   704
    items isNil ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   705
        items := OrderedCollection new
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   706
    ] ifFalse:[
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   707
        items := items asOrderedCollection
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   708
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   709
    items add:aMenuItem beforeIndex:anIndex.
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   710
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   711
    "Modified: / 4.8.1998 / 17:31:39 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   712
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   713
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   714
addItem:aMenuItem value:aValue
3022
ce344185f4f4 menuitem protocol
Claus Gittinger <cg@exept.de>
parents: 2967
diff changeset
   715
    aMenuItem itemValue:aValue.
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   716
    self addItem:aMenuItem.
3022
ce344185f4f4 menuitem protocol
Claus Gittinger <cg@exept.de>
parents: 2967
diff changeset
   717
ce344185f4f4 menuitem protocol
Claus Gittinger <cg@exept.de>
parents: 2967
diff changeset
   718
    "Modified: / 09-09-2012 / 13:08:50 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   719
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   720
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   721
addItemGroup:aGroup
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   722
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   723
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   724
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   725
    groupSizes isNil ifTrue:[
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   726
        groupSizes := OrderedCollection with:items size.
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   727
    ].
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   728
    groupSizes add:aGroup size.
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   729
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   730
    aGroup do:[:item |
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   731
        self addItem:item
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   732
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   733
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   734
    "Created: / 27.10.1997 / 15:02:15 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   735
    "Modified: / 4.8.1998 / 17:32:06 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   736
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   737
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   738
addItemGroup:aGroup values:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   739
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   740
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   741
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   742
    aGroup with:values do:[:item :value |
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   743
        item value:value
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   744
    ].
1758
b55ccdd15885 itemGroup fix
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   745
    self addItemGroup:aGroup
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   746
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   747
    "Modified: / 4.8.1998 / 17:32:18 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   748
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   749
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   750
addItemGroupLabels:labels values:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   751
    "add a group of items at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   752
     useful to build a menu programmatically (or, to add more items dynamically)"
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   753
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   754
    |items|
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   755
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   756
    items := labels with:values
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   757
                collect:[:label :value | 
3185
0d09b958253d class: Menu
Claus Gittinger <cg@exept.de>
parents: 3117
diff changeset
   758
                            MenuItem label:label itemValue:value
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   759
                        ].
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   760
    self addItemGroup:items
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   761
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   762
    "Created: / 27.10.1997 / 19:49:27 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   763
    "Modified: / 4.8.1998 / 17:35:22 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   764
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   765
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   766
addItemLabel:label value:value
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   767
    "add an item at the end;
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   768
     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
   769
3185
0d09b958253d class: Menu
Claus Gittinger <cg@exept.de>
parents: 3117
diff changeset
   770
    self addItem:(MenuItem label:label itemValue:value)
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   771
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   772
    "Created: / 27.10.1997 / 19:47:12 / cg"
1029
c77fe01f61a4 comments added;
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   773
    "Modified: / 4.8.1998 / 17:34:44 / cg"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   774
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   775
4442
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   776
addItemLabel:label value:value enabled:enabled
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   777
    "add an item at the end;
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   778
     useful to build a menu programmatically (or, to add more items dynamically)"
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   779
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   780
    self addItem:(MenuItem label:label itemValue:value enabled:enabled)
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   781
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   782
    "Created: / 27.10.1997 / 19:47:12 / cg"
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   783
    "Modified: / 4.8.1998 / 17:34:44 / cg"
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   784
!
510751dc36f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   785
3226
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   786
addItems: collection
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   787
    "Add all items in given collection.
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   788
     Useful to build a menu programmatically (or, to add more items dynamically)"
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   789
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   790
    items isNil ifTrue:[
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   791
        items := OrderedCollection new
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   792
    ] ifFalse:[
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   793
        items := items asOrderedCollection
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   794
    ].
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   795
    items addAll: collection
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   796
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   797
    "Created: / 01-09-2013 / 16:43:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   798
!
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   799
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   800
addItemsFrom: anotherMenu
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   801
    "Add all items from another menu.
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   802
     Useful to build a menu programmatically (or, to add more items dynamically)"
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   803
3254
8c2680e496c9 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3245
diff changeset
   804
    self addItems: anotherMenu items ? #()
3226
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   805
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   806
    "Created: / 01-09-2013 / 16:44:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3254
8c2680e496c9 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3245
diff changeset
   807
    "Modified: / 04-10-2013 / 19:28:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3226
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   808
!
5cbe343a7611 class: Menu
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3222
diff changeset
   809
4086
de7c2d6148e1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4083
diff changeset
   810
addLabel:aLabel selector:aSelector action:aBlock
de7c2d6148e1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4083
diff changeset
   811
    self addItem:(MenuItem label:aLabel itemValue:aBlock).
de7c2d6148e1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4083
diff changeset
   812
!
de7c2d6148e1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4083
diff changeset
   813
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   814
addSeparator
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   815
    "add a separating line item at the end;
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   816
     useful to build a menu programmatically (or, to add more items dynamically)"
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   817
2814
f75f27d92a5b changed: #addSeparator
Claus Gittinger <cg@exept.de>
parents: 2764
diff changeset
   818
    self addItem:(MenuItem separator).
1500
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   819
!
367e30b243cd added #addSeparator
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   820
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   821
removeItem:aMenuItem
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   822
    "remove an item from the menu"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   823
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   824
    |idx|
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   825
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   826
    items notNil ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   827
        idx := items identityIndexOf:aMenuItem.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   828
        idx ~~ 0 ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   829
            items removeAtIndex:idx
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   830
        ]
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   831
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   832
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   833
    "Created: / 13.9.1997 / 10:27:31 / cg"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   834
    "Modified: / 2.2.1998 / 13:26:49 / cg"
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   835
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   836
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   837
removeItemAt:anIndex
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   838
    "remove item at an index
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   839
    "
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   840
    anIndex <= items size ifTrue:[
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   841
        ^ items removeAtIndex:anIndex
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   842
    ].
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   843
    ^ nil
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   844
! !
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
   845
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
!Menu methodsFor:'converting'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   848
asOldStylePopUpMenuFor:anApplicationOrNil
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   849
    "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
   850
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   851
    |menuView itemsShown|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   852
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   853
    itemsShown := items 
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   854
        select:[:each |
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   855
            |visibilityInItem|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   856
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   857
            visibilityInItem := each isVisible.
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   858
            visibilityInItem isNil ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   859
                true
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   860
            ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   861
                visibilityInItem isBoolean ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   862
                    visibilityInItem
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   863
                ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   864
                    visibilityInItem isSymbol ifTrue:[
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   865
                        anApplicationOrNil isNil
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   866
                        or:[ (anApplicationOrNil perform:visibilityInItem) value ].
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   867
                    ] ifFalse:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   868
                        visibilityInItem value
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   869
                    ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   870
                ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   871
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   872
        ].
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   873
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   874
    menuView := MenuView 
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   875
        labels:(itemsShown collect:[:each | each label])
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   876
        selectors:(itemsShown collect:[:each | each value])
2751
d0729d604864 changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2584
diff changeset
   877
        accelerators:(itemsShown collect:[:each | each shortcutKey])
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   878
        args:(itemsShown collect:[:each | each argument])
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   879
        receiver:receiver.
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   880
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   881
    itemsShown doWithIndex:[:each :idx |
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   882
        |enabledInItem enabled|
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   883
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   884
        enabledInItem := each enabled.
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   885
        enabledInItem notNil ifTrue:[
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   886
            enabledInItem isSymbol ifTrue:[
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   887
                anApplicationOrNil isNil ifTrue:[
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   888
                    Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ 
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   889
                        self halt:('no application to ask %1 (enabled)' bindWith:enabledInItem)
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   890
                    ].
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   891
                ].
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   892
                enabled := anApplicationOrNil isNil or:[ (anApplicationOrNil perform:enabledInItem) ].
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   893
            ] ifFalse:[
3028
29a0a22942fe changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 3022
diff changeset
   894
                enabled := enabledInItem
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   895
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   896
            enabled value ifFalse:[
2092
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   897
                menuView disable:idx
2081
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   898
            ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   899
        ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   900
    ].
52ba70a79ce9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
   901
3245
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   902
    menuView actions:(itemsShown
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   903
                        collect:[:each |
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   904
                            [ 
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   905
                                |actionOrSymbol|
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   906
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   907
                                actionOrSymbol := each itemValue.
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   908
                                actionOrSymbol isBlock ifTrue:[
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   909
                                    actionOrSymbol value
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   910
                                ] ifFalse:[
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   911
                                    receiver perform:actionOrSymbol 
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   912
                                ]
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   913
                            ]
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   914
                        ]
5dd413dddd1c class: Menu
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
   915
                      ).
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   916
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   917
    ^ PopUpMenu forMenu:menuView
2867
b745ee0a04ac comment/format
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   918
2917
2ba0fee85a7f changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   919
    "Modified: / 30-06-2011 / 10:35:57 / cg"
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
   920
    "Modified: / 24-05-2018 / 15:26:17 / Claus Gittinger"
2080
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   921
!
4fe491fe114c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   922
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
fromLiteralArrayEncoding:aLiteralEncodedArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
    "read my contents from a aLiteralEncodedArray"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   926
    "/ original (VW) format encodes as:
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   927
    "/   #( Menu
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   928
    "/          items-array
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   929
    "/          groups-array (usually nil)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   930
    "/          values-array (usually nil)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   931
    "/   )
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   932
    "/ groups-array and values-array can be left empty (see fromLiteralArrayEncoding)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   933
    "/
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   934
    "/ new condensed format (menu items array elements are sliced in directly):
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   935
    "/   #( Menu
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   936
    "/          (MenuItem ...)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   937
    "/          (MenuItem ...)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   938
    "/          ...
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   939
    "/   )
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   940
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   941
    |itemArrayOrFirstItem itemArray groupArrayOrNil valuesArrayOrNil numSlots|
1620
bf72298c42bc bug fixes; handle unspecified items in literalArrayEncoding
ca
parents: 1599
diff changeset
   942
4311
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
   943
    numSlots := aLiteralEncodedArray size.
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
   944
    numSlots > 1 ifTrue:[
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   945
        itemArrayOrFirstItem := aLiteralEncodedArray at:2.
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   946
        "/ new or old format?
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   947
        (itemArrayOrFirstItem notNil 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   948
          and:[itemArrayOrFirstItem isArray
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   949
          and:[itemArrayOrFirstItem size > 1
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   950
          and:[itemArrayOrFirstItem first isSymbol
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   951
         ]]]  ) ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   952
            "/ new condensed format
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   953
            itemArray := aLiteralEncodedArray from:2 collect:[:item | item decodeAsLiteralArray].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   954
        ] ifFalse:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   955
            itemArray := itemArrayOrFirstItem.
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   956
            itemArray notNil ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   957
                itemArray := itemArray collect:[:item | item decodeAsLiteralArray].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   958
            ].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   959
            numSlots > 2 ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   960
                groupArrayOrNil := aLiteralEncodedArray at:3.
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   961
                numSlots > 3 ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   962
                    valuesArrayOrNil := aLiteralEncodedArray at:4.
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   963
                ].
4311
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
   964
            ].
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   965
        ].
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   966
    ].
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   967
    
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   968
    self menuItems:itemArray menuItemGroups:groupArrayOrNil values:valuesArrayOrNil.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
   970
    "extracted from PD folder.st:
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   972
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   973
                        #rawLabel: 'left' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   974
                        #value: #left ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   975
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   976
                        #rawLabel: 'center' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   977
                        #value: #center ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   978
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   979
                        #rawLabel: 'right' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   980
                        #value: #right ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   981
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   982
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   983
             nil 
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
       ) decodeAsLiteralArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    "
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   986
    "
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   987
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   988
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   989
                        #label: 'Straighten Up' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   990
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   991
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   992
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   993
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   994
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   995
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
   996
            #(#straightenUp #inspect #halt ) 
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   997
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   998
    "
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   999
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1000
    "extracted from iconicBrowser.st:
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
  1001
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1002
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1003
                        #label: 'Straighten Up' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1004
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1005
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1006
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1007
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1008
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1009
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1010
             #(1 2 3 )
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
  1011
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
  1012
    "
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1014
    "extracted from refactory213.st:
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
  1015
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1016
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1017
                    #label: 'File List' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1018
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1019
                #(#MenuItem #label: 'File Editor...' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1020
                    #accessCharacterPosition: 6 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1021
                #(#MenuItem #label: 'Refactoring Tool...' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1022
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1023
                #(#MenuItem #label: 'Workspace' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1024
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1025
                #(#MenuItem #label: 'New Canvas' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1026
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1027
                #(#MenuItem #label: 'Palette' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1028
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1029
                #(#MenuItem #label: 'Canvas Tool' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1030
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1031
                #(#MenuItem #label: 'Image Editor' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1032
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1033
                #(#MenuItem #label: 'Menu Editor' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1034
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1035
                #(#MenuItem #label: 'Advanced' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1036
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1037
                #(#MenuItem #label: 'DLL and C Connect' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1038
                    #accessCharacterPosition: 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1039
                #(#MenuItem #label: 'System Transcript' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1040
                    #accessCharacterPosition: 8 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1041
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1042
              #(4 5 2 1 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1043
              #(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1044
        ) decodeAsLiteralArray startUp
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
  1045
    "
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
  1046
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1047
    "submenus:
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1048
     #(#Menu #(
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1049
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1050
                        #label: 'Foo' 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1051
                        #submenu: #(#Menu #(
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1052
                                            #(#MenuItem #label: 'foo 1')     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1053
                                            #(#MenuItem #label: 'foo 2')     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1054
                                          )
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1055
                                          nil
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1056
                                          #(11 22)
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1057
                                   )     
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1058
                 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1059
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1060
                        #label: 'Inspect' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1061
                #(#MenuItem 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1062
                        #label: 'Coredump' ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1063
              ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1064
             #(3 ) 
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1065
             #(1 2 3 )
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1066
       ) decodeAsLiteralArray startUp  
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1067
    "
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1068
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1069
    "old format:
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1070
     #(#Menu
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1071
        (
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1072
            #(#MenuItem #label: 'Foo' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1073
            #(#MenuItem #label: 'Inspect' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1074
            #(#MenuItem #label: 'Coredump' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1075
        )
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1076
        nil
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1077
        nil
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1078
     ) decodeAsLiteralArray startUp  
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1079
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1080
     #(#Menu
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1081
        (
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1082
            #(#MenuItem #label: 'Foo' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1083
            #(#MenuItem #label: 'Inspect' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1084
            #(#MenuItem #label: 'Coredump' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1085
        )
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1086
        nil
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1087
        nil
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1088
     ) decodeAsLiteralArray literalArrayEncoding  
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1089
    "
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1090
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1091
    "condensed format (new):
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1092
     #(#Menu 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1093
        #(#MenuItem #label: 'Foo' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1094
        #(#MenuItem #label: 'Inspect' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1095
        #(#MenuItem #label: 'Coredump' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1096
     ) decodeAsLiteralArray startUp  
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1097
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1098
     #(#Menu 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1099
        #(#MenuItem #label: 'Foo' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1100
        #(#MenuItem #label: 'Inspect' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1101
        #(#MenuItem #label: 'Coredump' ) 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1102
     ) decodeAsLiteralArray literalArrayEncoding  
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1103
    "
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1104
2864
f90017f2da66 changed: #fromLiteralArrayEncoding:
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  1105
    "Modified: / 08-08-2010 / 14:43:03 / cg"
4311
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
  1106
    "Modified: / 19-07-2019 / 18:29:20 / Claus Gittinger"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1107
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1108
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1109
literalArrayEncoding
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1110
    "return myself encoded as a literal array"
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1111
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1112
    |useNewFormat coll itemArray groupsArray valuesArray size|
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1113
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1114
    useNewFormat := true.
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1115
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1116
    "/ ST/X does not use or support a value array
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1117
    "/ (valuesa are in the items, not in the menu)
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1118
    valuesArray := nil. 
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1119
    "/ however, the code below would deal correctly with a non-nil valuesArray...
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1120
    "/ (who knows if we'll need it some time)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1121
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1122
    "/ encodes as:
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1123
    "/   #( Menu
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1124
    "/          items-array
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1125
    "/          groups-array (usually nil)
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1126
    "/          values-array (usually nil)
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1127
    "/   )
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1128
    "/ groups-array and values-array can be left empty (see fromLiteralArrayEncoding)
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1129
    "/
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1130
    "/ new condensed format (menu items array elements are sliced in directly):
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1131
    "/   #( Menu
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1132
    "/          (MenuItem ...)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1133
    "/          (MenuItem ...)
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1134
    "/          ...
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1135
    "/   )
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1136
    
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1137
    coll := OrderedCollection new.
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
  1138
    coll add:#Menu.
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1139
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1140
    (size := items size) == 0  ifTrue:[
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1141
        itemArray := nil
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1142
    ] ifFalse:[
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1143
        itemArray := Array new:size.
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1144
        items keysAndValuesDo:[:anIndex :anItem|
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1145
            itemArray at:anIndex put:(anItem literalArrayEncoding)
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1146
        ]
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1147
    ].
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1148
    useNewFormat ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1149
        (groupSizes isEmptyOrNil and:[valuesArray isEmptyOrNil]) ifTrue:[
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1150
            "/ generate new condensed format
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1151
            itemArray notEmptyOrNil ifTrue:[ coll addAll:itemArray ].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1152
            ^ coll asArray.
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1153
        ].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1154
    ].
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1155
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1156
    coll add:itemArray.
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1157
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1158
    (size := groupSizes size) == 0  ifTrue:[
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1159
        groupsArray := nil
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1160
    ] ifFalse:[
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1161
        groupsArray := Array new:size.
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1162
        groupSizes keysAndValuesDo:[:anIndex :aSize|
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1163
            groupsArray at:anIndex put:(aSize literalArrayEncoding)
1245
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1164
        ]
93d262fccc63 bugFix in
ca
parents: 1174
diff changeset
  1165
    ].
4311
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
  1166
    
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1167
    (groupsArray notNil or:[valuesArray notNil]) ifTrue:[
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1168
        coll add:groupsArray.
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1169
        valuesArray notNil ifTrue:[
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1170
            coll add:valuesArray. "/ always nil, currently
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1171
        ].    
4330
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1172
    ]. 
461296396b3f #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4311
diff changeset
  1173
4310
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1174
    ^ coll asArray
a618a8ac992a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
  1175
4311
06a46e58fe14 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4310
diff changeset
  1176
    "Modified (format): / 19-07-2019 / 18:30:20 / Claus Gittinger"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1179
!Menu methodsFor:'enumerating'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1180
2494
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1181
allItemsDetect:aOneArgBlock ifNone:exceptionalValue
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1182
    "recursively find an element amongst each item and submenu items"
2494
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1183
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1184
    self itemsDo:[:anItem|
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1185
        |sub subItem|
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1186
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1187
        (aOneArgBlock value:anItem) ifTrue:[^ anItem].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1188
        (sub := anItem submenu) notNil ifTrue:[
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1189
            subItem := sub allItemsDetect:aOneArgBlock ifNone:nil.
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1190
            subItem notNil ifTrue:[^ subItem].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1191
        ]
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1192
    ].
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1193
    ^ exceptionalValue value
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1194
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1195
    "Modified (comment): / 24-05-2018 / 16:10:36 / Claus Gittinger"
2494
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1196
!
994b030ae562 new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1197
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
  1198
allItemsDo:aOneArgBlock
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1199
    "recursively evaluate block on each item and submenu items"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1200
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
  1201
    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
  1202
        |sub|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1203
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1204
        aOneArgBlock value:anItem.
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1205
        (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
  1206
            sub allItemsDo:aOneArgBlock
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1207
        ]
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
  1208
    ]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1209
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1210
    "Modified: / 19-06-1998 / 00:34:53 / cg"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1211
    "Modified (comment): / 24-05-2018 / 16:10:41 / Claus Gittinger"
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
  1212
!
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
  1213
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1214
detectItem:aBlock
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1215
    "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
  1216
     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
  1217
     true evaluation.
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1218
     If none of the evaluations returns true, return the result of the
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1219
     evaluation of the exceptionBlock"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1220
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1221
    ^ self detectItem:aBlock ifNone:[self errorNotFound]
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1222
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1223
    "Modified (comment): / 24-05-2018 / 16:10:46 / Claus Gittinger"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1224
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1225
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
  1226
detectItem:aBlock ifNone:exceptionValue
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1227
    "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
  1228
     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
  1229
     true evaluation.
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1230
     If none of the evaluations returns true, return the value from exceptionValue"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1231
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1232
    items notNil ifTrue:[
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
  1233
        ^ items detect:aBlock ifNone:exceptionValue
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1234
    ].
3942
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
  1235
    ^ exceptionValue value
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
  1236
521552945b3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3845
diff changeset
  1237
    "Modified (comment): / 14-03-2017 / 16:09:51 / cg"
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1238
    "Modified (comment): / 24-05-2018 / 16:10:51 / Claus Gittinger"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1239
!
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1240
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1241
do:aOneArgBlock
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1242
    "recursively evaluate block on each item and submenu items"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1243
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1244
    self allItemsDo:aOneArgBlock
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1245
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1246
    "Created: / 24-05-2018 / 16:10:25 / Claus Gittinger"
940
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1247
!
418cfd9b298d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 939
diff changeset
  1248
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
  1249
itemsDo:aOneArgBlock
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1250
    "evaluate the block for each item in the current menu"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1251
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
  1252
    items notNil ifTrue:[items do:aOneArgBlock]
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1253
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1254
    "Modified (comment): / 24-05-2018 / 16:10:55 / Claus Gittinger"
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
  1255
!
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
  1256
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1257
menuAndSubmenusDetectItem:aOneArgBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1258
    "evaluate the block for each item in the current menu and all
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1259
     submenus. In case that the block returns a non nil argument,
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1260
     the item will be returned"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1261
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1262
    |item|
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1263
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1264
    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
  1265
        items do:[:anItem|
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1266
            |sub|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1267
972
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1268
            (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
  1269
                ^ anItem
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1270
            ].
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1271
            (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
  1272
                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
  1273
                item notNil ifTrue:[
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1274
                    ^ item
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1275
                ]
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1276
            ]
09bc0765dbc1 no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1277
        ]
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1278
    ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1279
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1280
4095
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1281
    "Modified: / 19-06-1998 / 00:35:00 / cg"
563b7c522f45 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4086
diff changeset
  1282
    "Modified (comment): / 24-05-2018 / 16:10:59 / Claus Gittinger"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1283
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1284
672
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1285
!Menu methodsFor:'kludged fixes'!
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1286
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1287
destroy
1599
85108dff13a9 comment
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  1288
    "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
  1289
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1290
    "Created: 28.7.1997 / 10:16:52 / cg"
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1291
! !
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1292
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1293
!Menu methodsFor:'menu items'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1294
2404
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1295
removeAllAccelerators
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1296
    self allItemsDo:[:eachItem |
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1297
        eachItem shortcutKey:nil.
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1298
    ].
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1299
!
8cbc5d26f26e +removeAllAccelerators
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
  1300
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1301
someMenuItemLabeled:aLabel
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1302
    "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
  1303
     is not found, nil is returned
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1304
    "
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1305
    ^ self someMenuItemLabeled:aLabel ifNone:nil
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1306
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1307
    "Created: / 14.11.1997 / 20:55:17 / cg"
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1308
!
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1309
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1310
someMenuItemLabeled:aLabel ifNone:exceptionBlock
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1311
    "get the menu item labeled aLabel; in case that the value
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1312
     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
  1313
    "
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1314
    |item|
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1315
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1316
    item := self menuAndSubmenusDetectItem:[:anItem| anItem label = aLabel].
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1317
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1318
    item notNil ifTrue:[
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1319
	^ item
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1320
    ].
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1321
    ^ exceptionBlock value
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1322
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1323
    "Created: / 14.11.1997 / 20:56:13 / cg"
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1324
!
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1325
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1326
someMenuItemWithValue:aValue
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1327
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1328
     is not found nil is returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1329
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1330
    ^ self someMenuItemWithValue:aValue ifNone:nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1331
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1332
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1333
someMenuItemWithValue:aValue ifNone:exceptionBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1334
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1335
     is not found, the given exceptionBlock is executed and returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1336
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1337
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1338
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1339
    item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1340
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1341
    item notNil ifTrue:[
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1342
	^ item
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1343
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1344
  ^ exceptionBlock value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1345
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1346
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1347
!Menu methodsFor:'queries'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1348
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1349
hasHiddenItems
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1350
    "test whether any item is hidden"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1351
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1352
    self allItemsDo:[:anItem|
740
4f45cc61d4e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
  1353
	anItem isHidden ifTrue:[^ true]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1354
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1355
    ^ false
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1356
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1357
    "Modified: / 27.10.1997 / 15:12:44 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1358
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
  1359
2584
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1360
hasItems
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1361
    "test whether there are any menu-items"
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1362
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1363
    ^ items notEmptyOrNil
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1364
!
5b5c3dda9a4b +hasItems query
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1365
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1366
hasSubMenuAt:anIndex
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1367
    "test whether the menu item at the given index has a submenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1368
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1369
    ^ (self menuItemAt:anIndex) hasSubmenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1370
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
  1371
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
!Menu methodsFor:'startup'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1374
show
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1375
    "realize the menu at its last position; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1376
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1377
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1378
    ^ (MenuPanel menu:self) show ? 0
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1379
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1380
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1381
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1382
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1383
showAt:aPoint
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1384
    "realize the menu at aPoint; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1385
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1386
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1387
    ^ self showAt:aPoint resizing:true
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1388
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1389
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1390
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1391
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1392
showAt:aPoint resizing:aBoolean
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1393
    "realize the menu at aPoint; returns the value associated with the
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
     selected item, 0 if none was selected"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1396
    ^ ((MenuPanel menu:self) showAt:aPoint resizing:aBoolean) ? 0
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1397
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1398
    "Modified: / 8.7.1998 / 19:57:55 / cg"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1399
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1400
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1401
showAtPointer
4383
95689e660a4b #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 4330
diff changeset
  1402
    "realize the menu at the current pointer position; 
95689e660a4b #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 4330
diff changeset
  1403
     returns the value associated with the selected item, 0 if none was selected"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1404
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1405
    ^ self startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1406
!
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
  1407
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1408
showCenteredIn:aView
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1409
    "realize the menu visible at the aView center; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1410
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1411
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1412
    ^ ((MenuPanel menu:self) showCenteredIn:aView) ? 0
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1413
996
1e10d01c90b8 careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1414
    "Modified: / 8.7.1998 / 19:58:05 / cg"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1415
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1416
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1417
startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1418
    "display the menu as a popUp; returns the value associated with the
2039
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1419
     selected item, nil if none was selected.
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1420
     (should we return 0 form ST-80 compatibility ?)"
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
  1421
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1422
    ^ (MenuPanel menu:self) startUp "/ ? 0
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1424
"   
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1425
        |m|
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1426
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1427
        m := #(#Menu #(
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1428
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1429
                                #rawLabel: 'left' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1430
                                #value: #left ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1431
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1432
                                #rawLabel: 'center' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1433
                                #value: #center ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1434
                        #(#MenuItem 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1435
                                #rawLabel: 'right' 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1436
                                #value: #right ) ) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1437
                 #(2) 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1438
                nil 
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1439
        ) decodeAsLiteralArray.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1441
      Transcript showCR:(m startUp)        
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
  1442
"
938
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1443
!
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1444
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1445
startUpAt:aPoint
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1446
    "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
  1447
     selected item, 0 if none was selected"
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1448
939
f6df8fbf6b4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1449
    ^ ((MenuPanel menu:self) startUpAt:aPoint) ? 0
938
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1450
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1451
"   
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1452
        |m|
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1453
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1454
        m := #(#Menu #(
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1455
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1456
                                #rawLabel: 'left' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1457
                                #value: #left ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1458
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1459
                                #rawLabel: 'center' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1460
                                #value: #center ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1461
                        #(#MenuItem 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1462
                                #rawLabel: 'right' 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1463
                                #value: #right ) ) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1464
                 #(2) 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1465
                nil 
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1466
        ) decodeAsLiteralArray.
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1467
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1468
      Transcript showCR:(m startUpAt:100@100)        
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1469
"
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1470
dfa1b1666cfa added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1471
    "Created: / 21.5.1998 / 14:15:21 / cg"
939
f6df8fbf6b4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1472
    "Modified: / 21.5.1998 / 14:17:46 / cg"
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1473
!
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1474
1652
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1475
startUpFor:originatingWidget
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1476
    "display the menu as a popUp; returns the value associated with the
2039
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1477
     selected item, nil if none was selected.
30187ff89c64 comment
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  1478
     (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
  1479
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1480
    ^ (MenuPanel menu:self) startUpFor:originatingWidget "/ ? 0
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1481
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1482
"   
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1483
        |m|
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1484
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1485
        m := #(#Menu #(
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1486
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1487
                                #rawLabel: 'left' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1488
                                #value: #left ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1489
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1490
                                #rawLabel: 'center' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1491
                                #value: #center ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1492
                        #(#MenuItem 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1493
                                #rawLabel: 'right' 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1494
                                #value: #right ) ) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1495
                 #(2) 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1496
                nil 
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1497
        ) decodeAsLiteralArray.
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1498
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1499
      Transcript showCR:(m startUp)        
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1500
"
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1501
!
e2a96fa70eef can now specify if menu action is to be performed by
ca
parents: 1620
diff changeset
  1502
1367
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1503
startUpOrNil
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1504
    "display the menu as a popUp; returns the value associated with the
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1505
     selected item, nil if none was selected"
37bf7a7b5bd1 compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1506
1405
c7775c10e8fd tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents: 1401
diff changeset
  1507
    ^ (MenuPanel menu:self) startUpOrNil
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
2967
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1510
!Menu methodsFor:'utilities'!
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1511
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1512
replaceArgument: oldValue with: newValue
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1513
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1514
    "Recusively Replace argument in menu items where
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1515
     current argument is equal to oldValue by newValue"
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1516
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1517
    self itemsDo:[:item|
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1518
        item replaceArgument: oldValue with: newValue
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1519
    ]
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1520
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1521
    "Created: / 12-10-2011 / 20:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1522
! !
c50ab5fa6cf0 Added #replaceArgument:with:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2952
diff changeset
  1523
3778
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1524
!Menu::NeedResourcesQuery class methodsFor:'defaults'!
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1525
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1526
defaultAnswer
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1527
    ^ true
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1528
! !
902a70992ca0 #TUNING by sr
sr
parents: 3752
diff changeset
  1529
3968
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1530
!Menu::NeedResourcesQuery methodsFor:'accessing'!
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1531
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1532
defaultResumeValue
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1533
    "the default answer, if no one handles the query and the exception is resumed"
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1534
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1535
    ^ true
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1536
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1537
    "Created: / 23-07-2017 / 12:13:27 / cg"
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1538
! !
b3a568ff40cd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
  1539
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1540
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
3845
fbeacbb4b90b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  1542
version
fbeacbb4b90b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  1543
    ^ '$Header$'
fbeacbb4b90b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  1544
!
fbeacbb4b90b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  1545
2764
c83f22018324 squeak oompatibility:
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1546
version_CVS
3752
42375c1cc0e9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 3449
diff changeset
  1547
    ^ '$Header$'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
! !
3117
3c7f6b69b2c5 Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 3028
diff changeset
  1549