PullDownMenu.st
changeset 4678 7b9d701d947b
parent 4325 d1db60deb969
child 4710 8a081c228e90
equal deleted inserted replaced
4677:67285ce170f9 4678:7b9d701d947b
    42 "
    42 "
    43 !
    43 !
    44 
    44 
    45 documentation
    45 documentation
    46 "
    46 "
    47     Notice: this class is obsolete now - please use a MenuPanel
    47     Notice: this class is obsolete now 
    48     in new applications, which provides all of this functionality,
    48     - please use a MenuPanel in new applications, 
    49     plus more.
    49     which provides all of this functionality, plus more and a nicer look.
    50 
    50 
    51     PullDown menu provides the top (always visible) part of these menus. 
    51     PullDown menu provides the top (always visible) part of these menus. 
    52     It controls display of its menus, which become visible when one of the 
    52     It controls display of its menus, which become visible when one of the 
    53     PullDownMenus entries is pressed.
    53     PullDownMenus entries is pressed.
    54 
    54 
   447      or #at:putLabels:selectors:..."
   447      or #at:putLabels:selectors:..."
   448 
   448 
   449     |idx|
   449     |idx|
   450 
   450 
   451     indexOrString isNil ifTrue:[
   451     indexOrString isNil ifTrue:[
   452 	idx := titles size
   452         idx := titles size
   453     ] ifFalse:[
   453     ] ifFalse:[
   454 	idx := self indexOf:indexOrString.
   454         idx := self indexOf:indexOrString.
   455     ].
   455     ].
   456 
   456 
   457     titles isNil ifTrue:[
   457     titles isNil ifTrue:[
   458 	menus := Array with:nil.
   458         menus := Array with:nil.
   459 	titles := Array with:label.
   459         titles := Array with:label.
   460 	selectors := Array with:selector.
   460         selectors := Array with:selector.
   461     ] ifFalse:[
   461     ] ifFalse:[
   462 	menus := (menus copyTo:idx) , #(nil) , (menus copyFrom:idx+1).
   462         menus := menus copyWith:nil insertedAfterIndex:idx.
   463 	titles := ((titles copyTo:idx) copyWith:label) , (titles copyFrom:idx+1).
   463         titles := titles copyWith:label insertedAfterIndex:idx.
   464 	selectors := ((selectors copyTo:idx) copyWith:selector) , (selectors copyFrom:idx+1).
   464         selectors := selectors copyWith:selector insertedAfterIndex:idx.
   465     ].
   465     ].
   466 
   466 
   467     shown ifTrue:[
   467     shown ifTrue:[
   468 	self redraw
   468         self redraw
   469     ]
   469     ]
   470 
   470 
   471     "
   471     "
   472      |top m|
   472      |top m|
   473 
   473 
   476      m labels:#('file' 'edit').
   476      m labels:#('file' 'edit').
   477      m selectors:#(file #edit).
   477      m selectors:#(file #edit).
   478 
   478 
   479      m add:'help' selector:#help after:#file.
   479      m add:'help' selector:#help after:#file.
   480      m at:#help putMenu:(MenuView labels:#('foo' 'bar')
   480      m at:#help putMenu:(MenuView labels:#('foo' 'bar')
   481 			       selectors:#(foo bar)
   481                                selectors:#(foo bar)
   482 				receiver:nil).
   482                                 receiver:nil).
   483 
   483 
   484      top open
   484      top open
   485     "
   485     "
   486 
   486 
   487     "Modified: 5.7.1996 / 11:40:47 / cg"
   487     "Modified: 5.7.1996 / 11:40:47 / cg"
   494      or #at:putLabels:selectors:..."
   494      or #at:putLabels:selectors:..."
   495 
   495 
   496     |idx|
   496     |idx|
   497 
   497 
   498     indexOrString isNil ifTrue:[
   498     indexOrString isNil ifTrue:[
   499 	idx := 1
   499         idx := 1
   500     ] ifFalse:[
   500     ] ifFalse:[
   501 	idx := self indexOf:indexOrString.
   501         idx := self indexOf:indexOrString.
   502     ].
   502     ].
   503 
   503 
   504     titles isNil ifTrue:[
   504     titles isNil ifTrue:[
   505 	menus := Array with:nil.
   505         menus := Array with:nil.
   506 	titles := Array with:label.
   506         titles := Array with:label.
   507 	selectors := Array with:selector.
   507         selectors := Array with:selector.
   508     ] ifFalse:[
   508     ] ifFalse:[
   509 	menus := (menus copyTo:idx-1) , #(nil) , (menus copyFrom:idx).
   509         menus := menus copyWith:nil insertedAfterIndex:idx-1.
   510 	titles := ((titles copyTo:idx-1) copyWith:label) , (titles copyFrom:idx).
   510         titles := titles copyWith:label insertedAfterIndex:idx-1.
   511 	selectors := ((selectors copyTo:idx-1) copyWith:selector) , (selectors copyFrom:idx).
   511         selectors := selectors copyWith:selector insertedAfterIndex:idx-1.
   512     ].
   512     ].
   513 
   513 
   514     shown ifTrue:[
   514     shown ifTrue:[
   515 	self redraw
   515         self redraw
   516     ]
   516     ]
   517 
   517 
   518     "
   518     "
   519      |top m|
   519      |top m|
   520 
   520 
   523      m labels:#('file' 'edit').
   523      m labels:#('file' 'edit').
   524      m selectors:#(file #edit).
   524      m selectors:#(file #edit).
   525 
   525 
   526      m add:'help' selector:#help before:#edit.
   526      m add:'help' selector:#help before:#edit.
   527      m at:#help putMenu:(MenuView labels:#('foo' 'bar')
   527      m at:#help putMenu:(MenuView labels:#('foo' 'bar')
   528 			       selectors:#(foo bar)
   528                                selectors:#(foo bar)
   529 				receiver:nil).
   529                                 receiver:nil).
   530 
   530 
   531      m add:'foo' selector:#foo before:nil.
   531      m add:'foo' selector:#foo before:nil.
   532      m at:#foo putMenu:(MenuView labels:#('foo1' 'foo2')
   532      m at:#foo putMenu:(MenuView labels:#('foo1' 'foo2')
   533 			       selectors:#(foo1 foo2)
   533                                selectors:#(foo1 foo2)
   534 				receiver:nil).
   534                                 receiver:nil).
   535 
   535 
   536      top open
   536      top open
   537     "
   537     "
   538 
   538 
   539     "Modified: 5.7.1996 / 11:40:55 / cg"
   539     "Modified: 5.7.1996 / 11:40:55 / cg"
  1812 ! !
  1812 ! !
  1813 
  1813 
  1814 !PullDownMenu class methodsFor:'documentation'!
  1814 !PullDownMenu class methodsFor:'documentation'!
  1815 
  1815 
  1816 version
  1816 version
  1817     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.106 2011-10-05 14:13:41 az Exp $'
  1817     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.107 2013-08-26 13:13:01 cg Exp $'
  1818 !
  1818 !
  1819 
  1819 
  1820 version_CVS
  1820 version_CVS
  1821     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.106 2011-10-05 14:13:41 az Exp $'
  1821     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.107 2013-08-26 13:13:01 cg Exp $'
  1822 ! !
  1822 ! !
       
  1823