Menu.st
author Claus Gittinger <cg@exept.de>
Sun, 02 Nov 1997 19:54:27 +0100
changeset 736 d9f874e6b1e4
parent 729 7e22cc23fd1f
child 737 c8bdd9dd8906
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
Object subclass:#Menu
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
     2
	instanceVariableNames:'items groupSizes receiver'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	classVariableNames:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	category:'Views-Support'
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
documentation
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
    not yet finished Menu class - this will eventually replace
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
    most of the MenuView and PopUpMenu stuff.
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
    (and hopefully be ST-80 compatible ...)
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
    For now, only a subset of the full protocol is implemented.
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    [author:]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
        Claus Gittinger
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    [see also:]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
        MenuItem
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
        PopUpMenu
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    27
!Menu class methodsFor:'instance creation'!
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    28
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    29
labelArray: arrayOfString lines: linesArray values: valueArrayOrNil
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    30
        "Answer a menu with menu items with labels from arrayOfString (not Symbols).  The linesArray describes which menu items are the last menu item in their group.  The valueArray contains value objects for each menu item (or is nil if no value objects are specified)."
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    31
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    32
        | valueArray menuItems groupLengths |
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    33
        valueArrayOrNil isNil
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    34
                ifTrue: [valueArray := arrayOfString isEmpty
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    35
                                                ifTrue: [#()]
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    36
                                                ifFalse:        [1 to: arrayOfString size]]
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    37
                ifFalse: [valueArray := valueArrayOrNil].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    38
        arrayOfString size ~= valueArray size
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    39
                ifTrue: [^self error: 'illegal menu combination'].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    40
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    41
        menuItems := Array new: arrayOfString size.
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    42
        1 to: arrayOfString size do:
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    43
                [:i |
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    44
                | mi v|
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    45
                mi := MenuItem labeled: (arrayOfString at: i) asString.
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    46
                v := valueArray at: i.
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    47
                (v isKindOf: Menu)
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    48
                        ifTrue: [mi submenu: v].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    49
                menuItems at: i put: mi].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    50
        (linesArray == nil or: [linesArray isEmpty])
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    51
                ifTrue: [
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    52
                        groupLengths := (menuItems isEmpty)
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    53
                                ifTrue: [Array new: 0]
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    54
                                ifFalse: [Array with: menuItems size]]
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    55
                ifFalse: [groupLengths := Array new: linesArray size + 1.
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    56
                                groupLengths at: 1 put: linesArray first.
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    57
                                2 to: linesArray size do: [:i | groupLengths at: i put: (linesArray at: i) - (linesArray at: i - 1)].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    58
                                groupLengths at: groupLengths size put: menuItems size - linesArray last].
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    59
        ^self new menuItems: menuItems menuItemGroups: groupLengths values: valueArray
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    60
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    61
    "Modified: 20.6.1997 / 10:46:45 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    62
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    63
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    64
labelList:arrayOfGroupStrings values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    65
    |labels lines|
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    66
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    67
    lines := arrayOfGroupStrings collect:[:each | each size].
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    68
    labels := OrderedCollection new.
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    69
    arrayOfGroupStrings do:[:group | labels addAll:group].
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    70
    ^ self labelArray:labels lines:lines values:valueArrayOrNil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    71
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    72
    "Modified: 20.6.1997 / 10:46:45 / cg"
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
    73
    "Created: 13.9.1997 / 10:35:46 / cg"
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    74
! !
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    75
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    76
!Menu methodsFor:'ST-80 compatibility'!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    77
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    78
indexOfMenuItem:anItem
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    79
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    80
    ^ items indexOf:anItem
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    81
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    82
    "Created: / 27.10.1997 / 16:34:19 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    83
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    84
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    85
menuButtons
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    86
    "ST-80 seems to use a special menuButton class here.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    87
     Here, kludge a collection of menuItems."
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    88
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    89
    ^ items
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    90
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    91
    "Created: / 27.10.1997 / 16:33:35 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    92
! !
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
    93
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
!Menu methodsFor:'accessing'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
    96
addItem:aMenuItem
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
    97
    items isNil ifTrue:[
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
    98
        items := OrderedCollection new
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
    99
    ].
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   100
    items add:aMenuItem.
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   101
!
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   102
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   103
addItem:aMenuItem value:aValue
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   104
    aMenuItem value:aValue.
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   105
    self addItem:aMenuItem.
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   106
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   107
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   108
addItemGroup:aCollectionOfItems
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   109
    groupSizes isNil ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   110
        groupSizes := OrderedCollection new
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   111
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   112
    groupSizes add:aCollectionOfItems size.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   113
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   114
    aCollectionOfItems do:[:item |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   115
        self addItem:item
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   116
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   117
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   118
    "Created: / 27.10.1997 / 15:02:15 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   119
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   120
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   121
addItemGroup:aGroup values:values
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   122
    groupSizes isNil ifTrue:[
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   123
        groupSizes := OrderedCollection new
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   124
    ].
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   125
    groupSizes add:items size.
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   126
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   127
    aGroup with:values do:[:item :value |
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   128
        self addItem:item value:value
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   129
    ].
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   130
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   131
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   132
addItemGroupLabels:labels values:values
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   133
    |items|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   134
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   135
    items := labels with:values
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   136
                collect:[:label :value |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   137
                            |item|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   138
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   139
                            item := MenuItem new.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   140
                            item label:label.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   141
                            item value:value.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   142
                        ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   143
    self addItemGroup:items
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   144
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   145
    "Created: / 27.10.1997 / 19:49:27 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   146
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   147
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   148
addItemLabel:label value:value
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   149
    |item|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   150
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   151
    item := MenuItem new.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   152
    item label:label.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   153
    item value:value.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   154
    self addItem:item
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   155
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   156
    "Created: / 27.10.1997 / 19:47:12 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   157
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   158
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   159
atNameKey:aNameKey
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   160
    "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
   161
     Searches in allItems (i.e. also in subMenus)"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   162
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   163
    self allItemsDo:[:anItem|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   164
        anItem nameKey == aNameKey ifTrue:[^ anItem]
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   165
    ].
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   166
    ^ nil
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   167
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   168
    "Modified: / 27.10.1997 / 15:12:00 / cg"
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   169
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   170
578
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   171
groupSizes
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   172
    "return the value of the instance variable 'groupSizes' (automatically generated)"
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   173
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   174
    ^ groupSizes!
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   175
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   176
groupSizes:something
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   177
    "set the value of the instance variable 'groupSizes' (automatically generated)"
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   178
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   179
    groupSizes := something.!
7e0f62d9bc47 access methods ...
ca
parents: 494
diff changeset
   180
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   181
labelAt:anIndex
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   182
    "gets the label of the menu item at the given index or nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   183
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   184
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   185
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   186
    (item := self menuItemAt:anIndex) notNil ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   187
        ^ item label
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   188
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   189
  ^ nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   190
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   191
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   192
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   193
labelAtValue:aValue
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   194
    "gets the label of the menu item assigned to value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   195
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   196
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   197
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   198
    item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   199
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   200
    item notNil ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   201
        ^ item label
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   202
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   203
  ^ nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   204
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   205
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   206
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
labels
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    "return a collection of labels from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    ^ items collect:[:anItem | anItem label]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "Created: 25.2.1997 / 19:47:53 / cg"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   215
lines
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   216
    "Answer 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
   217
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   218
    | lines |
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   219
    groupSizes size <= 1 ifTrue: [^Array new].
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   220
    lines := Array new: groupSizes size - 1.
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   221
    lines at: 1 put: groupSizes first.
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   222
    2 to: groupSizes size -1 do: 
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   223
            [:i |
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   224
            lines at: i put: (lines at: i - 1) + (groupSizes at: i)].
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   225
    ^lines
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   226
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   227
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   228
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   229
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   230
menuItemAt:index
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   231
    "gets the menu item at the given index. When the index is out of bounds
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   232
     nil is returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   233
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   234
    (index > 0 and:[index <= items size]) ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   235
        ^ items at:index
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   236
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   237
  ^ nil
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   238
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   239
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   240
menuItemLabeled:anItemLabel
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   241
    "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
   242
     Searches all items (i.e. also submenu items)"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   243
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   244
    self allItemsDo:[:anItem|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   245
                |l|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   246
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   247
                ((l := anItem label) sameAs: anItemLabel) ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   248
                    ^ anItem
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   249
                ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   250
                (l includes:$&) ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   251
                    ((l copyWithout:$&) sameAs: anItemLabel) ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   252
                        ^ anItem
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   253
                    ]
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   254
                ]
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   255
             ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   256
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   257
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   258
    "Created: / 13.9.1997 / 10:25:16 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   259
    "Modified: / 27.10.1997 / 15:23:33 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   260
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   261
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   262
menuItems
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   263
    ^ items
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   264
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   265
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   266
menuItems:aCollectionOfMenuItems menuItemGroups:sizes values:values
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    items := aCollectionOfMenuItems.
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   268
    groupSizes := sizes.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   270
    values notNil ifTrue:[
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   271
        items with:values do:[:anItem :aValue |anItem value:aValue]
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   272
    ].
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   273
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   274
    "Modified: 20.6.1997 / 10:45:30 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   277
numberOfItems
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   278
    ^ items size
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   279
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   280
    "Created: 6.3.1997 / 15:15:53 / cg"
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   281
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   282
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   283
receiver
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   284
    "return the value of the instance variable 'receiver' (automatically generated)"
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   285
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   286
    ^ receiver!
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   287
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   288
receiver:something
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   289
    "set the value of the instance variable 'receiver' (automatically generated)"
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   290
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   291
    receiver := something.!
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   292
696
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   293
removeItem:aMenuItem
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   294
    |idx|
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   295
    items notNil ifTrue:[
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   296
        idx := items identityIndexOf:aMenuItem.
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   297
        idx ~~ 0 ifTrue:[
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   298
            items removeAtIndex:idx
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   299
        ]
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   300
    ].
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   301
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   302
    "Created: 13.9.1997 / 10:27:31 / cg"
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   303
!
a49928754789 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   304
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
valueAt:index
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    "return a collection of values from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    ^ (items at:index) value
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "Created: 25.2.1997 / 19:49:41 / cg"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
494
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   313
valueAt:anIndex put:aValue
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   314
    "put value an an index"
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   315
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   316
    (items at:anIndex) value:aValue
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   317
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   318
    "Created: 6.3.1997 / 15:15:48 / cg"
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   319
!
ce8c074d5e6b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   320
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
values
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    "return a collection of values from my items"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    ^ items collect:[:anItem | anItem value]
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "Created: 25.2.1997 / 19:49:29 / cg"
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   327
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   328
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   329
values:aCollectionOfValues
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   330
    "return a collection of values from my items"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   331
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   332
    |s|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   333
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   334
    s := aCollectionOfValues readStream.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   335
    self itemsDo:[:item |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   336
        |val|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   337
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   338
        val := s next.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   339
        item value:val
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   340
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   341
    s atEnd ifFalse:[self halt]
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   342
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   343
    "Created: / 27.10.1997 / 15:15:47 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   344
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   345
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   346
visibleMenuItemGroups
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   347
        | itemGroups visibleItemGroups nextItem |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   348
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   349
        itemGroups := OrderedCollection new.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   350
        nextItem := 1.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   351
        groupSizes do: [:groupSize |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   352
                itemGroups addLast: (items copyFrom: nextItem to: nextItem + groupSize - 1).
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   353
                nextItem := nextItem + groupSize].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   354
        self hasHiddenItems ifFalse: [^itemGroups].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   355
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   356
        "Remove the hidden items."
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   357
        visibleItemGroups := OrderedCollection new.
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   358
        itemGroups do: [:eachItemGroup |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   359
                | visibleItemGroup |
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   360
                visibleItemGroup := eachItemGroup reject:
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   361
                                        [:eachMenuItem | eachMenuItem hidden].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   362
                visibleItemGroup isEmpty ifFalse: [
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   363
                        visibleItemGroups addLast: visibleItemGroup]].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   364
        ^visibleItemGroups
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   365
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   366
    "Created: / 27.10.1997 / 15:07:50 / cg"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   369
!Menu methodsFor:'accessing resource'!
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   370
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   371
findGuiResourcesIn:aResourceContainerOrApplication
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   372
    "setup a resource owner
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   373
    "
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   374
    aResourceContainerOrApplication notNil ifTrue:[
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   375
        items notNil ifTrue:[
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   376
            items do:[:anItem| anItem findGuiResourcesIn:aResourceContainerOrApplication ]
582
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   377
        ]
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   378
    ]
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   379
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   380
! !
94f55f6a8bad support of ResourceRetriver
ca
parents: 579
diff changeset
   381
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
!Menu methodsFor:'converting'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
fromLiteralArrayEncoding:aLiteralEncodedArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    "read my contents from a aLiteralEncodedArray"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    |items groups values|
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    items := (aLiteralEncodedArray at:2) collect:[:item | item decodeAsLiteralArray].
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    groups := aLiteralEncodedArray at:3.
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   391
    values := aLiteralEncodedArray at:4.
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   392
    self menuItems:items menuItemGroups:groups values:values.
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    "extract from PD folder.st:
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
     #(#Menu #(
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
                #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
                        #rawLabel: 'left' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
                        #value: #left ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
                #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
                        #rawLabel: 'center' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
                        #value: #center ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
                #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
                        #rawLabel: 'right' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
                        #value: #right ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
              ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
             #(3 ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
             nil 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
       ) decodeAsLiteralArray
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
    "
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   410
    "
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   411
     #(#Menu #(
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   412
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   413
                        #label: 'Straighten Up' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   414
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   415
                        #label: 'Inspect' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   416
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   417
                        #label: 'Coredump' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   418
              ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   419
             #(3 ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   420
            #(#straightenUp #inspect #halt ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   421
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   422
    "
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   423
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   424
    "extract from iconicBrowser.st:
452
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   425
     #(#Menu #(
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   426
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   427
                        #label: 'Straighten Up' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   428
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   429
                        #label: 'Inspect' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   430
                #(#MenuItem 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   431
                        #label: 'Coredump' ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   432
              ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   433
             #(3 ) 
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   434
             #(1 2 3 )
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   435
       ) decodeAsLiteralArray startUp  
b708d60b96b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 451
diff changeset
   436
    "
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   438
    "extract from refactory213.st:
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   439
     #(#Menu #(
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   440
                #(#MenuItem 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   441
                    #label: 'File List' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   442
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   443
                #(#MenuItem #label: 'File Editor...' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   444
                    #accessCharacterPosition: 6 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   445
                #(#MenuItem #label: 'Refactoring Tool...' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   446
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   447
                #(#MenuItem #label: 'Workspace' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   448
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   449
                #(#MenuItem #label: 'New Canvas' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   450
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   451
                #(#MenuItem #label: 'Palette' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   452
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   453
                #(#MenuItem #label: 'Canvas Tool' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   454
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   455
                #(#MenuItem #label: 'Image Editor' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   456
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   457
                #(#MenuItem #label: 'Menu Editor' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   458
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   459
                #(#MenuItem #label: 'Advanced' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   460
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   461
                #(#MenuItem #label: 'DLL and C Connect' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   462
                    #accessCharacterPosition: 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   463
                #(#MenuItem #label: 'System Transcript' 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   464
                    #accessCharacterPosition: 8 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   465
              ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   466
              #(4 5 2 1 ) 
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   467
              #(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) 
456
4eea9046617a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   468
        ) decodeAsLiteralArray startUp
454
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   469
    "
539b7c318760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 452
diff changeset
   470
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   471
    "submenus:
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   472
     #(#Menu #(
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   473
                #(#MenuItem 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   474
                        #label: 'Foo' 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   475
                        #submenu: #(#Menu #(
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   476
                                            #(#MenuItem #label: 'foo 1')     
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   477
                                            #(#MenuItem #label: 'foo 2')     
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   478
                                          )
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   479
                                          nil
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   480
                                          #(11 22)
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   481
                                   )     
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   482
                 ) 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   483
                #(#MenuItem 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   484
                        #label: 'Inspect' ) 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   485
                #(#MenuItem 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   486
                        #label: 'Coredump' ) 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   487
              ) 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   488
             #(3 ) 
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   489
             #(1 2 3 )
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   490
       ) decodeAsLiteralArray startUp  
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   491
    "
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   492
610
72dbf392e888 ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   493
    "Modified: 20.6.1997 / 10:45:51 / cg"
489
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   494
!
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   495
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   496
literalArrayEncoding
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   497
    "return myself encoded as a literal array"
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   498
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   499
    |coll|
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   500
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   501
    coll := OrderedCollection new.
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   502
    coll add:#Menu.
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   503
    coll add:(items literalArrayEncoding).
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   504
    coll add:(groupSizes literalArrayEncoding).
264ba86c52c1 checkin from browser
ca
parents: 457
diff changeset
   505
    coll add:nil.
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   506
  ^ coll asArray
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   509
!Menu methodsFor:'enumerating'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   510
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   511
allItemsDo:aOneArgBlock
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   512
    "evaluate block on each item and submenu items
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   513
    "
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   514
    self itemsDo:[:anItem|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   515
        |sub|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   516
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   517
        aOneArgBlock value:anItem.
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   518
        (sub := anItem submenu value) notNil ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   519
            sub allItemsDo:aOneArgBlock
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   520
        ]
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   521
    ]
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   522
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   523
    "Modified: / 27.10.1997 / 15:09:08 / cg"
665
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   524
!
9e8b4bc9fedb enumerating:
ca
parents: 627
diff changeset
   525
589
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   526
itemsDo:aOneArgBlock
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   527
    "evaluate the block for each item in the current menu
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   528
    "
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   529
    items notNil ifTrue:[items do:aOneArgBlock]
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   530
!
cc422fe7824f ST-80 compatibility; enumerating & indication
ca
parents: 584
diff changeset
   531
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   532
menuAndSubmenusDetectItem:aOneArgBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   533
    "evaluate the block for each item in the current menu and all
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   534
     submenus. In case that the block returns a non nil argument,
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   535
     the item will be returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   536
    "
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   537
    |item|
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   538
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   539
    items notNil ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   540
        items do:[:anItem|
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   541
            |sub|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   542
627
07c9a1c2d226 menuAndSubmenusDetectItem:aOneArgBlock
ca
parents: 610
diff changeset
   543
            (aOneArgBlock value:anItem) ifTrue:[
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   544
                ^ anItem
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   545
            ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   546
            (sub := anItem submenu value) notNil ifTrue:[
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   547
                item := sub menuAndSubmenusDetectItem:aOneArgBlock.
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   548
                item notNil ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   549
                    ^ item
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   550
                ]
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   551
            ]
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   552
        ]
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   553
    ].
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   554
    ^ nil
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   555
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   556
    "Modified: / 27.10.1997 / 15:09:43 / cg"
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   557
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   558
672
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   559
!Menu methodsFor:'kludged fixes'!
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   560
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   561
destroy
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   562
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   563
    "Created: 28.7.1997 / 10:16:52 / cg"
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   564
! !
2db4bb41aa93 added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   565
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   566
!Menu methodsFor:'menu items'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   567
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   568
someMenuItemWithValue:aValue
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   569
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   570
     is not found nil is returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   571
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   572
    ^ self someMenuItemWithValue:aValue ifNone:nil
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   573
!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   574
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   575
someMenuItemWithValue:aValue ifNone:exceptionBlock
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   576
    "get the menu item assigned with the value; in case that the value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   577
     is not found, the given exceptionBlock is executed and returned
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   578
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   579
    |item|
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   580
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   581
    item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   582
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   583
    item notNil ifTrue:[
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   584
        ^ item
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   585
    ].
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   586
  ^ exceptionBlock value
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   587
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   588
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   589
!Menu methodsFor:'queries'!
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   590
724
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   591
hasHiddenItems
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   592
    "test whether any item is hidden"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   593
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   594
    self allItemsDo:[:anItem|
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   595
        anItem isHidden ifTrue:[^ true]
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   596
    ].
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   597
    ^ false
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   598
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   599
    "Modified: / 27.10.1997 / 15:12:44 / cg"
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   600
!
898519684261 more VW comaptibility
Claus Gittinger <cg@exept.de>
parents: 696
diff changeset
   601
584
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   602
hasSubMenuAt:anIndex
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   603
    "test whether the menu item at the given index has a submenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   604
    "
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   605
    ^ (self menuItemAt:anIndex) hasSubmenu
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   606
! !
9a4c30f7586f ST-80 compatible features addded
ca
parents: 582
diff changeset
   607
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
!Menu methodsFor:'startup'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   610
show
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   611
    "realize the menu at its last position; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   612
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   613
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   614
    ^ (MenuPanel menu:self) show ? 0
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   615
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   616
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   617
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   618
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   619
showAt:aPoint
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   620
    "realize the menu at aPoint; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   621
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   622
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   623
    ^ self showAt:aPoint resizing:true
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   624
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   625
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   626
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   627
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   628
showAt:aPoint resizing:aBoolean
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   629
    "realize the menu at aPoint; returns the value associated with the
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
     selected item, 0 if none was selected"
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   632
    ^ (MenuPanel menu:self) showAt:aPoint resizing:aBoolean ? 0
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   633
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   634
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   635
showAtPointer
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   636
    "realize the menu at the current pointer position; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   637
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   638
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   639
    ^ self startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   640
!
457
19f2c28e4adb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   641
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   642
showCenteredIn:aView
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   643
    "realize the menu visible at the aView center; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   644
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   645
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   646
    ^ (MenuPanel menu:self) showCenteredIn:aView ? 0
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   647
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   648
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   649
!
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   650
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   651
startUp
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   652
    "display the menu as a popUp; returns the value associated with the
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   653
     selected item, 0 if none was selected"
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   654
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   655
    ^ (MenuPanel menu:self) startUp ? 0
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   657
"   
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
        |m|
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   659
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
        m := #(#Menu #(
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
                        #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
                                #rawLabel: 'left' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
                                #value: #left ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
                        #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
                                #rawLabel: 'center' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
                                #value: #center ) 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
                        #(#MenuItem 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
                                #rawLabel: 'right' 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
                                #value: #right ) ) 
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   670
                 #(2) 
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
                nil 
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
        ) decodeAsLiteralArray.
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
579
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   674
      Transcript showCR:(m startUp)        
77f6d490f1ac so far, so good
ca
parents: 578
diff changeset
   675
"
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
! !
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
!Menu class methodsFor:'documentation'!
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
version
729
7e22cc23fd1f bugfix:
ca
parents: 724
diff changeset
   681
    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.20 1997-11-01 12:24:36 ca Exp $'
451
95064b26ded1 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
! !