[ENH] Grow box for 2.6 (ignore previous version...)
Stephen Travis Pope
stp at create.ucsb.edu
Wed Dec 1 21:48:15 UTC 1999
--------------99832570D926C654DC44B87D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
(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
--------------99832570D926C654DC44B87D
Content-Type: text/plain; charset=us-ascii;
name="GrowBox.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GrowBox.cs"
'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]! !
--------------99832570D926C654DC44B87D--
More information about the Squeak-dev
mailing list
|