# HG changeset patch # User Jan Vrany # Date 1562448730 -3600 # Node ID 8c420069d4cb7d2703a7f6e01d397ff5972d319a # Parent 5182891c9a14211ccf354285e4b22d853a38285d# Parent a0e88386e17c44f2983a6810544e55ea0f9ca1be Merge diff -r 5182891c9a14 -r 8c420069d4cb MenuPanel.st --- a/MenuPanel.st Sun Jun 23 23:04:24 2019 +0000 +++ b/MenuPanel.st Sat Jul 06 22:32:10 2019 +0100 @@ -2087,9 +2087,10 @@ stringOffsetX isNil ifTrue:[ stringOffsetX := 0. - (self isPopUpView or:[self verticalLayout]) ifTrue:[ + stringOffsetX := self font height + Item horizontalInset. self do:[:el| + stringOffsetX := stringOffsetX max: el preferredExtent y. el isVisible ifTrue:[ ( (label := el indicatorForm) notNil or:[(label := el choiceForm) notNil] @@ -2097,7 +2098,7 @@ stringOffsetX := stringOffsetX max:(label width + 2). ] ifFalse:[ label := el displayLabel. - label class == LabelAndIcon ifTrue:[ + label isLabelAndIcon ifTrue:[ stringOffsetX := stringOffsetX max:(label xOfString). ]. ]. @@ -2118,13 +2119,13 @@ w == 0 ifTrue:[ label := anItem displayLabel. - label class == LabelAndIcon ifTrue:[ + label isLabelAndIcon ifTrue:[ ^ stringOffsetX - label xOfString ]. ]. ^ stringOffsetX. - "Modified: / 14-03-2018 / 10:55:28 / Jan Vrany " + "Modified: / 17-06-2019 / 10:58:50 / Jan Vrany " ! subMenuIndicationWidth @@ -6463,12 +6464,12 @@ |myFont prevFont w h| displayLabelExtent notNil ifTrue:[ - ^ displayLabelExtent + ^ displayLabelExtent ]. displayLabel isNil ifTrue:[ - displayLabelExtent := 0@0. - ^ displayLabelExtent + displayLabelExtent := 0@0. + ^ displayLabelExtent ]. myFont := self font. @@ -6478,38 +6479,39 @@ prevFont := menuPanel setFont:myFont. displayLabel isString ifTrue:[ - w := displayLabel widthOn:menuPanel. - h := displayLabel heightOn:menuPanel. + w := displayLabel widthOn:menuPanel. + h := displayLabel heightOn:menuPanel. "/ w := myFont widthOf:displayLabel. "/ h := myFont heightOf:displayLabel. ] ifFalse:[ - displayLabel isArray ifTrue:[ - w := h := 0. - - displayLabel do:[:aSubLabel| - aSubLabel notNil ifTrue:[ - w := w max:(aSubLabel widthOn:menuPanel). - h := h + 1 + (aSubLabel heightOn:menuPanel). - ] ifFalse:[ - h := h + (self spaceBetweenEmptyLines) - ] - ] - ] ifFalse:[ - w := displayLabel widthOn:menuPanel. - h := displayLabel heightOn:menuPanel. - ]. + displayLabel isArray ifTrue:[ + w := h := 0. + + displayLabel do:[:aSubLabel| + aSubLabel notNil ifTrue:[ + w := w max:(aSubLabel widthOn:menuPanel). + h := h + 1 + (aSubLabel heightOn:menuPanel). + ] ifFalse:[ + h := h + (self spaceBetweenEmptyLines) + ] + ] + ] ifFalse:[ + w := displayLabel widthOn:menuPanel. + h := displayLabel heightOn:menuPanel. + ]. ]. menuPanel setFont:prevFont. "/ restore previous font - "/ care for italic fonts - give a few more pixels at the end - myFont italic ifTrue:[ - w := w + 2. - ]. + "/ Add some extra space at the end so the text does not end + "/ right before view's boundady (looks rather bad) + w := w + myFont width. + displayLabelExtent := w@h. ^ displayLabelExtent "Modified: / 17-08-2010 / 10:46:06 / cg" + "Modified: / 17-06-2019 / 11:05:01 / Jan Vrany " ! font @@ -7072,12 +7074,12 @@ isButton := menuItem isButton. isButton ifTrue:[ - s := menuPanel maxAbsoluteButtonLevel ? 0. - x := s + HorizontalButtonInset. - y := s + VerticalButtonInset. + s := menuPanel maxAbsoluteButtonLevel ? 0. + x := s + HorizontalButtonInset. + y := s + VerticalButtonInset. ] ifFalse:[ - x := HorizontalInset. - y := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2. + x := HorizontalInset. + y := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2. ]. x := x * 2. y := y * 2. @@ -7085,47 +7087,50 @@ isVertical := menuPanel verticalLayout. self isSeparator ifTrue:[ - s := self class separatorSize. - label = '' ifTrue:[ - s := self class halfSeparatorSize. - ]. - - "width of doubleSeparator is 5 !!!!" - isVertical ifFalse:[ - x := x max:s. - y := y + 5. - ] ifTrue:[ - y := y max:s. - x := x + 5. - ]. + s := self class separatorSize. + label = '' ifTrue:[ + s := self class halfSeparatorSize. + ]. + + "width of doubleSeparator is 5 !!!!" + isVertical ifFalse:[ + x := x max:s. + y := y + 5. + ] ifTrue:[ + y := y max:s. + x := x + 5. + ]. ] ifFalse:[ - labelExtent := self displayLabelExtent. - - x := x + labelExtent x. - y := y + labelExtent y. - x := x + (menuPanel stringOffsetXfor:self). - - isButton ifFalse:[ - menuPanel showSeparatingLines ifTrue:[ - "width of separator is 2 plus right offset 1 := 3" - isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3]. - ]. - ]. - wIcon := 0. - self hasMenuIndicator ifTrue:[ - icon := MenuPanel menuIndicator. - wIcon := MenuPanel menuIndicatorOffset + icon width. - ] ifFalse:[ - self hasDelayedMenuIndicator ifTrue:[ - icon := MenuPanel delayedMenuIndicator. - wIcon := MenuPanel delayedMenuIndicatorOffset + icon width. - ] - ]. - x := x + wIcon. + labelExtent := self displayLabelExtent. + + x := x + labelExtent x. + y := y + labelExtent y. + x := x + (menuPanel stringOffsetXfor:self). + + isButton ifFalse:[ + menuPanel showSeparatingLines ifTrue:[ + "width of separator is 2 plus right offset 1 := 3" + isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3]. + ]. + ]. + wIcon := 0. + self hasMenuIndicator ifTrue:[ + icon := MenuPanel menuIndicator. + wIcon := MenuPanel menuIndicatorOffset + icon width. + ] ifFalse:[ + self hasDelayedMenuIndicator ifTrue:[ + icon := MenuPanel delayedMenuIndicator. + wIcon := MenuPanel delayedMenuIndicatorOffset + icon width. + ] ifFalse:[ + x := x + (menuPanel font width // 2) + ]. + ]. + x := x + wIcon. ]. ^ x@y "Modified: / 19-01-2011 / 21:20:35 / cg" + "Modified: / 17-06-2019 / 11:01:01 / Jan Vrany " ! preferredHeight