PullDownMenu.st
changeset 1988 55184833642a
parent 1980 8c7a9ecadb5e
child 2048 aa46b832f842
equal deleted inserted replaced
1987:599825bed176 1988:55184833642a
   637     numberOfLabels := titleArray size.
   637     numberOfLabels := titleArray size.
   638     menus := Array new:numberOfLabels.
   638     menus := Array new:numberOfLabels.
   639     titles := Array new:numberOfLabels.
   639     titles := Array new:numberOfLabels.
   640 
   640 
   641     titleArray keysAndValuesDo:[:index :entry |
   641     titleArray keysAndValuesDo:[:index :entry |
   642 	|e|
   642         |e|
   643 
   643 
   644 	entry isImage ifTrue:[
   644         entry isImage ifTrue:[
   645 	    e := entry on:device
   645             e := entry onDevice:device
   646 	] ifFalse:[
   646         ] ifFalse:[
   647 	    e := entry printString
   647             e := entry printString
   648 	].
   648         ].
   649 	titles at:index put:e
   649         titles at:index put:e
   650     ].
   650     ].
   651     shown ifTrue:[
   651     shown ifTrue:[
   652 	self invalidate "/ clear; redraw
   652         self invalidate "/ clear; redraw
   653     ]
   653     ]
   654 
   654 
   655     "Modified: 29.5.1996 / 16:21:00 / cg"
   655     "Modified: 29.5.1996 / 16:21:00 / cg"
   656 !
   656 !
   657 
   657 
   805 backgroundColor:aColor
   805 backgroundColor:aColor
   806     "set the background drawing color.
   806     "set the background drawing color.
   807      You should not use this method; instead leave the value as
   807      You should not use this method; instead leave the value as
   808      defined in the styleSheet."
   808      defined in the styleSheet."
   809 
   809 
   810     bgColor := aColor on:device
   810     bgColor := aColor onDevice:device
   811 !
   811 !
   812 
   812 
   813 font:aFont
   813 font:aFont
   814     "set the menus font.
   814     "set the menus font.
   815      adjusts menu-origins when font changes.
   815      adjusts menu-origins when font changes.
   816      You should not use this method; instead leave the value as
   816      You should not use this method; instead leave the value as
   817      defined in the styleSheet.
   817      defined in the styleSheet.
   818      CAVEAT: with the addition of Text objects,
   818      CAVEAT: with the addition of Text objects,
   819 	     this method is going to be obsoleted by a textStyle
   819              this method is going to be obsoleted by a textStyle
   820 	     method, which allows specific control over
   820              method, which allows specific control over
   821 	     normalFont/boldFont/italicFont parameters."
   821              normalFont/boldFont/italicFont parameters."
   822 
   822 
   823     aFont ~~ font ifTrue:[
   823     aFont ~~ font ifTrue:[
   824 	super font:(aFont on:device).
   824         super font:(aFont onDevice:device).
   825 	self height:(font height + (font descent * 2)).
   825         self height:(font height + (font descent * 2)).
   826 	shown ifTrue:[
   826         shown ifTrue:[
   827 	    self setMenuOrigins
   827             self setMenuOrigins
   828 	]
   828         ]
   829     ]
   829     ]
   830 
   830 
   831     "Modified: 22.5.1996 / 12:37:04 / cg"
   831     "Modified: 22.5.1996 / 12:37:04 / cg"
   832 !
   832 !
   833 
   833 
   834 foregroundColor:aColor
   834 foregroundColor:aColor
   835     "set the foreground drawing color.
   835     "set the foreground drawing color.
   836      You should not use this method; instead leave the value as
   836      You should not use this method; instead leave the value as
   837      defined in the styleSheet."
   837      defined in the styleSheet."
   838 
   838 
   839     fgColor := aColor on:device
   839     fgColor := aColor onDevice:device
   840 !
   840 !
   841 
   841 
   842 showSeparatingLines:aBoolean
   842 showSeparatingLines:aBoolean
   843     "turn on/off drawing of separating lines.
   843     "turn on/off drawing of separating lines.
   844      You should not use this method; instead leave the value as
   844      You should not use this method; instead leave the value as
   906 
   906 
   907 drawTitle:stringOrImage x:x0 selected:selected
   907 drawTitle:stringOrImage x:x0 selected:selected
   908     |y w x wSpace fg bg map|
   908     |y w x wSpace fg bg map|
   909 
   909 
   910     selected ifTrue:[
   910     selected ifTrue:[
   911 	fg := activeFgColor.
   911         fg := activeFgColor.
   912 	bg := activeBgColor
   912         bg := activeBgColor
   913     ] ifFalse:[
   913     ] ifFalse:[
   914 	fg := fgColor.
   914         fg := fgColor.
   915 	bg := bgColor
   915         bg := bgColor
   916     ].
   916     ].
   917 
   917 
   918     wSpace := font widthOf:' '.
   918     wSpace := font widthOf:' '.
   919     x := x0.
   919     x := x0.
   920     stringOrImage isString ifTrue:[
   920     stringOrImage isString ifTrue:[
   921 	y := ((height - (font height)) // 2) + (font ascent) "+ topMargin".
   921         y := ((height - (font height)) // 2) + (font ascent) "+ topMargin".
   922 	w := font widthOf:stringOrImage.
   922         w := font widthOf:stringOrImage.
   923     ] ifFalse:[
   923     ] ifFalse:[
   924 	y := ((height - stringOrImage height) // 2) max:0.
   924         y := ((height - stringOrImage height) // 2) max:0.
   925 	w := stringOrImage width
   925         w := stringOrImage width
   926     ].
   926     ].
   927     w := w + (wSpace * 2).
   927     w := w + (wSpace * 2).
   928 
   928 
   929     self paint:bg.
   929     self paint:bg.
   930     self fillRectangleX:x y:0 width:w height:height.
   930     self fillRectangleX:x y:0 width:w height:height.
   931 
   931 
   932     self is3D ifTrue:[
   932     self is3D ifTrue:[
   933 	self drawEdgesForX:x y:0
   933         self drawEdgesForX:x y:0
   934 		     width:w
   934                      width:w
   935 		    height:height
   935                     height:height
   936 		     level:(selected ifTrue:[onLevel] ifFalse:[offLevel])
   936                      level:(selected ifTrue:[onLevel] ifFalse:[offLevel])
   937     ].
   937     ].
   938     self paint:fg on:bg.
   938     self paint:fg on:bg.
   939     x := x + wSpace.
   939     x := x + wSpace.
   940     stringOrImage isString ifTrue:[
   940     stringOrImage isString ifTrue:[
   941 	self displayOpaqueString:stringOrImage x:x y:y
   941         self displayOpaqueString:stringOrImage x:x y:y
   942     ] ifFalse:[
   942     ] ifFalse:[
   943 	stringOrImage isImageOrForm ifTrue:[
   943         stringOrImage isImageOrForm ifTrue:[
   944 	    stringOrImage depth == 1 ifTrue:[
   944             stringOrImage depth == 1 ifTrue:[
   945 		(map := stringOrImage colorMap) notNil ifTrue:[
   945                 (map := stringOrImage colorMap) notNil ifTrue:[
   946 		    map at:1 put:((map at:1) on:device).
   946                     map at:1 put:((map at:1) onDevice:device).
   947 		    map at:2 put:((map at:2) on:device).
   947                     map at:2 put:((map at:2) onDevice:device).
   948 
   948 
   949 		    self paint:(map at:2) on:(map at:1).
   949                     self paint:(map at:2) on:(map at:1).
   950 		    self displayOpaqueForm:stringOrImage x:x y:y.
   950                     self displayOpaqueForm:stringOrImage x:x y:y.
   951 		    ^ self
   951                     ^ self
   952 		]
   952                 ]
   953 	    ].
   953             ].
   954 	    self displayForm:stringOrImage x:x y:y
   954             self displayForm:stringOrImage x:x y:y
   955 	] ifFalse:[
   955         ] ifFalse:[
   956 	    stringOrImage displayOn:self x:x y:y
   956             stringOrImage displayOn:self x:x y:y
   957 	]
   957         ]
   958     ]
   958     ]
   959 
   959 
   960     "Modified: 14.1.1997 / 00:06:07 / cg"
   960     "Modified: 14.1.1997 / 00:06:07 / cg"
   961 !
   961 !
   962 
   962 
  1411 fetchDeviceResources
  1411 fetchDeviceResources
  1412     "fetch device colors, to avoid reallocation at redraw time"
  1412     "fetch device colors, to avoid reallocation at redraw time"
  1413 
  1413 
  1414     super fetchDeviceResources.
  1414     super fetchDeviceResources.
  1415 
  1415 
  1416     bgColor notNil ifTrue:[bgColor := bgColor on:device].
  1416     bgColor notNil ifTrue:[bgColor := bgColor onDevice:device].
  1417     fgColor notNil ifTrue:[fgColor := fgColor on:device].
  1417     fgColor notNil ifTrue:[fgColor := fgColor onDevice:device].
  1418 
  1418 
  1419     activeBgColor notNil ifTrue:[activeBgColor := activeBgColor on:device].
  1419     activeBgColor notNil ifTrue:[activeBgColor := activeBgColor onDevice:device].
  1420     activeFgColor notNil ifTrue:[activeFgColor := activeFgColor on:device].
  1420     activeFgColor notNil ifTrue:[activeFgColor := activeFgColor onDevice:device].
  1421 
  1421 
  1422     "Created: 13.1.1997 / 23:25:14 / cg"
  1422     "Created: 13.1.1997 / 23:25:14 / cg"
  1423 !
  1423 !
  1424 
  1424 
  1425 initCursor
  1425 initCursor
  1439 
  1439 
  1440 "/    DefaultFont notNil ifTrue:[font := DefaultFont on:device].
  1440 "/    DefaultFont notNil ifTrue:[font := DefaultFont on:device].
  1441 
  1441 
  1442     showSeparatingLines := DefaultSeparatingLines. "/ false.
  1442     showSeparatingLines := DefaultSeparatingLines. "/ false.
  1443     DefaultViewBackground notNil ifTrue:[
  1443     DefaultViewBackground notNil ifTrue:[
  1444         viewBackground := DefaultViewBackground on:device
  1444         viewBackground := DefaultViewBackground onDevice:device
  1445     ].
  1445     ].
  1446 
  1446 
  1447     DefaultForegroundColor notNil ifTrue:[
  1447     DefaultForegroundColor notNil ifTrue:[
  1448         fgColor := DefaultForegroundColor
  1448         fgColor := DefaultForegroundColor
  1449     ] ifFalse:[
  1449     ] ifFalse:[
  1509 !
  1509 !
  1510 
  1510 
  1511 initialize
  1511 initialize
  1512     super initialize.
  1512     super initialize.
  1513 
  1513 
  1514     font := font on:device.
  1514     font := font onDevice:device.
  1515     self origin:(0.0 @ 0.0)
  1515     self origin:(0.0 @ 0.0)
  1516 	 extent:(1.0 @ self preferredExtent y)
  1516          extent:(1.0 @ self preferredExtent y)
  1517 "/         extent:(1.0 @ (font height + (font descent * 2)  + topMargin)).
  1517 "/         extent:(1.0 @ (font height + (font descent * 2)  + topMargin)).
  1518 !
  1518 !
  1519 
  1519 
  1520 recreate
  1520 recreate
  1521     "if the image was saved with an active menu, hide it"
  1521     "if the image was saved with an active menu, hide it"
  1789 ! !
  1789 ! !
  1790 
  1790 
  1791 !PullDownMenu class methodsFor:'documentation'!
  1791 !PullDownMenu class methodsFor:'documentation'!
  1792 
  1792 
  1793 version
  1793 version
  1794     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.86 1999-08-04 14:10:07 cg Exp $'
  1794     ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.87 1999-08-18 14:38:30 cg Exp $'
  1795 ! !
  1795 ! !