[ENH] Grow box for 2.6 (ignore previous version...)
Daniel V. Oppenheim
music at watson.ibm.com
Wed Dec 1 22:32:40 UTC 1999
All these are great!! Will these make it eventually into a release? So many
great enactments get posted over (short) time, but it would be very
cumbersome to manually file-out and file-in + check for conflicts from
release to release...
Danny
At 01:48 PM 12/1/99 -0800, you wrote:
>(I forgot to attach the code to the previous posting...)
>
>The enclosed change set is a new version of the grow-box goodie (works
>with the 2.6
>window-menu-button-in-title. This adds a button in the upper-right with
>the icon of a caret (^) that grows
>or shrinks (if shift is down) the window by 50%.
>
>--
>stp
>
>Stephen Travis Pope -- http://www.create.ucsb.edu/~stp
>stp at expertcity.com -- stp9 at cornell.edu'From Squeak 2.5 of August 6,
>1999 on 28 August 1999 at 11:36:28 am'!
>
>SystemWindow addInstVarName: 'growBox ' !
>
>!SystemWindow methodsFor: 'initialization' stamp: 'stp 08/28/1999 10:57'!
>initialize
> | aFont |
> super initialize.
> labelString ifNil: [labelString _ 'Untitled Window'].
> isCollapsed := false.
> activeOnlyOnTop := true.
> paneMorphs := Array new.
> paneRects := Array new.
> borderColor := #raised.
> borderWidth := 1.
> color := Color black.
> aFont := Preferences fontForScriptorButtons.
> stripes := Array with: (RectangleMorph newBounds: bounds) "see
> extent:"
> with: (RectangleMorph newBounds: bounds).
> self addMorph: (stripes first borderWidth: 1).
> self addMorph: (stripes second borderWidth: 2).
> self addMorph: (label := StringMorph new contents: labelString;
> font: (TextStyle default fontAt: 2) emphasis: 1).
> self setLabelWidgetAllowance.
> self addCloseBox.
> self addMenuControl.
> self addMorph: (collapseBox := SimpleButtonMorph new borderWidth: 0;
> label: 'O' font: aFont; color: Color transparent;
> actionSelector: #collapseOrExpand; target: self;
> extent: 16 at 16).
> self addMorph: (growBox _ SimpleButtonMorph new borderWidth: 0;
> label: '^' font: aFont; color: Color transparent;
> actionSelector: #growOrShrink; target: self;
> extent: 16 at 16).
> Preferences noviceMode ifTrue:
> [closeBox ifNotNil: [closeBox setBalloonText: 'close
> window'].
> menuBox ifNotNil: [menuBox setBalloonText: 'window menu'].
> collapseBox ifNotNil: [collapseBox setBalloonText:
> 'collapse/expand window']].
> self on: #mouseEnter send: #spawnReframeHandle: to: self.
> self on: #mouseLeave send: #spawnReframeHandle: to: self.
> label on: #mouseDown send: #relabelEvent: to: self.
> self extent: 300 at 200.
> mustNotClose := false.
> updatablePanes := Array new.! !
>
>!SystemWindow methodsFor: 'geometry' stamp: 'stp 09/02/1999 09:49'!
>extent: newExtent
> | inner labelRect |
> isCollapsed
> ifTrue: [super extent: newExtent x @ (self labelHeight + 2)]
> ifFalse: [super extent: newExtent].
> inner _ self innerBounds.
> labelRect _ self labelRect.
>
> stripes first bounds: (labelRect insetBy: 1).
> stripes second bounds: (labelRect insetBy: 3).
> self setStripeColorsFrom: self paneColor.
> closeBox ifNotNil:
> [closeBox align: closeBox topLeft with: inner topLeft +
> (4 at 0)].
> menuBox ifNotNil:
> [menuBox align: menuBox topLeft with: (inner topLeft +
> (19 at 1))].
> collapseBox align: collapseBox topRight with: inner topRight - (4 at 0).
> growBox ifNotNil:
> [growBox align: growBox topRight with: collapseBox topLeft].
> label align: label bounds topCenter with: inner topCenter.
> self setBoundsOfPaneMorphs.
> isCollapsed
> ifTrue: [collapsedFrame _ self bounds]
> ifFalse: [fullFrame _ self bounds]! !
>
>!SystemWindow methodsFor: 'resize/collapse' stamp: 'stp 08/28/1999 11:34'!
>growOrShrink
> "Expand (or shrink if shiftDown) the view by 50% in the X and
> 100% in the Y, clipping to the screen size and centering it.
> The minimum size is 120 at 120."
>
> | oldSize newSize |
> oldSize := self bounds.
> newSize := Sensor leftShiftDown
> ifTrue: [(oldSize scaleBy: 0.66 at 0.5) truncated]
> ifFalse: [(oldSize scaleBy: 1.5 at 2.0) truncated].
> newSize extent < (120 at 120)
> ifTrue: [^self].
> newSize := newSize translateBy: (newSize center - oldSize center)
> negated.
> newSize := newSize intersect: Display boundingBox.
> super bounds: newSize.
> paneMorphs reverseDo: [:m | self addMorph: m]! !
---
Dr. Daniel V.
Oppenheim
Computer Music Center
IBM T.J. Watson Research Center phone: (914) 945-1989
P. O. Box 218 (or Route 134) fax: (914) 945-3434
Yorktown Heights, NY 10598 www.research.ibm.com/music
More information about the Squeak-dev
mailing list
|