[Cuis-dev] [IMPROV] Using MenuMorph>>#addTitle: for subtitles

Gerald Klix cuis.01 at klix.ch
Thu May 6 07:41:47 PDT 2021


Sorry I was a bit too hasty, this one looks better.


HTH Gerald

On 2021-05-06 16:11, Gerald Klix via Cuis-dev wrote:
> Hi all, Hi Juan,
> 
> Please find enclosed a change set, that makes
> MenuMorph>>#addTitle: usable to add subtitles
> to menus.
> Try the attached script to see the difference.
> 
> 
> HTH and Best Regards,
> 
> Gerald
> 
-------------- next part --------------
'From Haver 5.0 [latest update: #4587] on 6 May 2021 at 4:36:32 pm'!

!MenuMorph methodsFor: 'construction' stamp: 'KLG 5/6/2021 16:35:55'!
addTitle: aString
	"Add a title line at the top of this menu Make aString its initial 
	contents.  
	If aSelector is not nil, then periodically obtain fresh values for its 
	contents by sending aSelector to aTarget.."

	| s pp w newMorph |
	
	newMorph _ WidgetMorph new noBorder.
	newMorph color: Theme current menuTitleBar.
	pp _ `8 at 2`.
	aString asString linesDo: [ :line | | font |
		font _ Preferences standardMenuFont.
		s _ LabelMorph new
			contents: line;
			font: (titleMorph
				ifNil: [ font bold ]
				ifNotNil: [ font italic ])..
		newMorph addMorphBack: s position: pp.
		pp _ pp + (0@(s morphHeight+2)) ].
	w _ newMorph submorphs inject: 0 into: [ :prev :each |
		prev max: each morphWidth ].
	newMorph morphExtent: (w + 16) @ (pp y).
	titleMorph
		 ifNil: [
			titleMorph _ newMorph.
			self addMorphFront: titleMorph ]
		ifNotNil: [ self addMorphBack: newMorph ].
	
	(self hasProperty: #needsStayUpIcons) ifTrue: [ self addStayUpIcons ]! !



More information about the Cuis-dev mailing list