--- a/ArrButton.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ArrButton.st Mon Nov 21 17:46:30 1994 +0100
@@ -28,7 +28,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/ArrButton.st,v 1.8 1994-11-17 14:33:55 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ArrButton.st,v 1.9 1994-11-21 16:45:22 claus Exp $
'!
!ArrowButton class methodsFor:'documentation'!
@@ -49,7 +49,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/ArrButton.st,v 1.8 1994-11-17 14:33:55 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ArrButton.st,v 1.9 1994-11-21 16:45:22 claus Exp $
"
!
@@ -60,9 +60,22 @@
Beside the contents, their default behavior is to perform their action
when pressed - not (as is the default for normal buttons) when released.
- ArrowButtons are created by sending one of:
+ Indivdual ArrowButtons can be created by sending one of:
ArrowButton upIn:aView /downIn: / leftIn: or rightIn:
passing the parent view as argument.
+
+ styleSheet parameters:
+
+ arrowButtonStyle <Symbol> the style of the button;
+ #motif, #st80 or nil (default)
+ arrowButtonForegroundColor <nil | Color> foregroundColor
+ arrowButtonBackgroundColor <nil | Color> backgroundColor
+
+ arrowButtonActiveForegroundColor foregroundColor when pressed
+ arrowButtonActiveBackgroundColor backgroundColor when pressed
+
+ arrowButtonEnteredForegroundColor foregroundColor when mouse pointer entered
+ arrowButtonEnteredBackgroundColor backgroundColor when mouse pointer entered
"
!
@@ -123,7 +136,7 @@
v open
- example4 (not good style, to explicitely use a particulat style,
+ example4 (not good coding style, to explicitely use a particular style,
just a demonstration how it looks ..):
|v p b1 b2 b3 b4 oldStyle|
--- a/ArrowButton.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ArrowButton.st Mon Nov 21 17:46:30 1994 +0100
@@ -28,7 +28,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.8 1994-11-17 14:33:55 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.9 1994-11-21 16:45:22 claus Exp $
'!
!ArrowButton class methodsFor:'documentation'!
@@ -49,7 +49,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.8 1994-11-17 14:33:55 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.9 1994-11-21 16:45:22 claus Exp $
"
!
@@ -60,9 +60,22 @@
Beside the contents, their default behavior is to perform their action
when pressed - not (as is the default for normal buttons) when released.
- ArrowButtons are created by sending one of:
+ Indivdual ArrowButtons can be created by sending one of:
ArrowButton upIn:aView /downIn: / leftIn: or rightIn:
passing the parent view as argument.
+
+ styleSheet parameters:
+
+ arrowButtonStyle <Symbol> the style of the button;
+ #motif, #st80 or nil (default)
+ arrowButtonForegroundColor <nil | Color> foregroundColor
+ arrowButtonBackgroundColor <nil | Color> backgroundColor
+
+ arrowButtonActiveForegroundColor foregroundColor when pressed
+ arrowButtonActiveBackgroundColor backgroundColor when pressed
+
+ arrowButtonEnteredForegroundColor foregroundColor when mouse pointer entered
+ arrowButtonEnteredBackgroundColor backgroundColor when mouse pointer entered
"
!
@@ -123,7 +136,7 @@
v open
- example4 (not good style, to explicitely use a particulat style,
+ example4 (not good coding style, to explicitely use a particular style,
just a demonstration how it looks ..):
|v p b1 b2 b3 b4 oldStyle|
--- a/HPanelV.st Thu Nov 17 15:40:37 1994 +0100
+++ b/HPanelV.st Mon Nov 21 17:46:30 1994 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.6 1994-11-17 14:34:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.7 1994-11-21 16:45:24 claus Exp $
'!
!HorizontalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.6 1994-11-17 14:34:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.7 1994-11-21 16:45:24 claus Exp $
"
!
@@ -326,6 +326,14 @@
sumOfWidths := sumOfWidths + ((subViews size - 1) * horizontalSpace).
].
+ ((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[
+ maxHeight := maxHeight + verticalSpace
+ ] ifFalse:[
+ ((vLayout == #fit) or:[vLayout == #center]) ifTrue:[
+ maxHeight := maxHeight + (verticalSpace * 2)
+ ]
+ ].
+
^ sumOfWidths @ maxHeight
! !
--- a/HVScrView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/HVScrView.st Mon Nov 21 17:46:30 1994 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/HVScrView.st,v 1.8 1994-11-17 14:38:05 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HVScrView.st,v 1.9 1994-11-21 16:45:26 claus Exp $
written jan 91 by claus
'!
@@ -44,7 +44,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/HVScrView.st,v 1.8 1994-11-17 14:38:05 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HVScrView.st,v 1.9 1994-11-21 16:45:26 claus Exp $
"
!
@@ -165,36 +165,23 @@
!HVScrollableView methodsFor:'private'!
setScrollActions
- |lock|
-
- lock := false.
-
scrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollVerticalToPercent:position.
- lock := false
+ lockUpdates := false
].
scrollBar scrollUpAction:[scrolledView scrollUp].
scrollBar scrollDownAction:[scrolledView scrollDown].
hScrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollHorizontalToPercent:position.
- lock := false
+ lockUpdates := false
].
hScrollBar scrollLeftAction:[scrolledView scrollLeft].
hScrollBar scrollRightAction:[scrolledView scrollRight].
- scrolledView originChangeAction:[:aView |
- lock ifFalse:[
- scrollBar setThumbOriginFor:aView.
- hScrollBar setThumbOriginFor:aView
- ]
- ].
- scrolledView contentsChangeAction:[:aView |
- scrollBar setThumbFor:aView.
- hScrollBar setThumbFor:aView
- ]
+ scrolledView addDependent:self.
! !
!HVScrollableView methodsFor:'accessing'!
@@ -237,6 +224,28 @@
self setScrollActions
! !
+!HVScrollableView methodsFor:'changes '!
+
+update:something with:argument from:changedObject
+ "whenever the scrolledview changes its contents, we have to
+ update the scrollers too"
+
+ changedObject == scrolledView ifTrue:[
+ something == #sizeOfContents ifTrue:[
+ scrollBar setThumbFor:scrolledView.
+ hScrollBar setThumbFor:scrolledView.
+ ^ self
+ ].
+ something == #originOfContents ifTrue:[
+ lockUpdates ifFalse:[
+ scrollBar setThumbOriginFor:scrolledView.
+ hScrollBar setThumbOriginFor:scrolledView.
+ ].
+ ^ self
+ ].
+ ].
+! !
+
!HVScrollableView methodsFor:'event processing'!
sizeChanged:how
--- a/HVScrollableView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/HVScrollableView.st Mon Nov 21 17:46:30 1994 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.8 1994-11-17 14:38:05 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.9 1994-11-21 16:45:26 claus Exp $
written jan 91 by claus
'!
@@ -44,7 +44,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.8 1994-11-17 14:38:05 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.9 1994-11-21 16:45:26 claus Exp $
"
!
@@ -165,36 +165,23 @@
!HVScrollableView methodsFor:'private'!
setScrollActions
- |lock|
-
- lock := false.
-
scrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollVerticalToPercent:position.
- lock := false
+ lockUpdates := false
].
scrollBar scrollUpAction:[scrolledView scrollUp].
scrollBar scrollDownAction:[scrolledView scrollDown].
hScrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollHorizontalToPercent:position.
- lock := false
+ lockUpdates := false
].
hScrollBar scrollLeftAction:[scrolledView scrollLeft].
hScrollBar scrollRightAction:[scrolledView scrollRight].
- scrolledView originChangeAction:[:aView |
- lock ifFalse:[
- scrollBar setThumbOriginFor:aView.
- hScrollBar setThumbOriginFor:aView
- ]
- ].
- scrolledView contentsChangeAction:[:aView |
- scrollBar setThumbFor:aView.
- hScrollBar setThumbFor:aView
- ]
+ scrolledView addDependent:self.
! !
!HVScrollableView methodsFor:'accessing'!
@@ -237,6 +224,28 @@
self setScrollActions
! !
+!HVScrollableView methodsFor:'changes '!
+
+update:something with:argument from:changedObject
+ "whenever the scrolledview changes its contents, we have to
+ update the scrollers too"
+
+ changedObject == scrolledView ifTrue:[
+ something == #sizeOfContents ifTrue:[
+ scrollBar setThumbFor:scrolledView.
+ hScrollBar setThumbFor:scrolledView.
+ ^ self
+ ].
+ something == #originOfContents ifTrue:[
+ lockUpdates ifFalse:[
+ scrollBar setThumbOriginFor:scrolledView.
+ hScrollBar setThumbOriginFor:scrolledView.
+ ].
+ ^ self
+ ].
+ ].
+! !
+
!HVScrollableView methodsFor:'event processing'!
sizeChanged:how
--- a/HorizontalPanelView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/HorizontalPanelView.st Mon Nov 21 17:46:30 1994 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.6 1994-11-17 14:34:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.7 1994-11-21 16:45:24 claus Exp $
'!
!HorizontalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.6 1994-11-17 14:34:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.7 1994-11-21 16:45:24 claus Exp $
"
!
@@ -326,6 +326,14 @@
sumOfWidths := sumOfWidths + ((subViews size - 1) * horizontalSpace).
].
+ ((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[
+ maxHeight := maxHeight + verticalSpace
+ ] ifFalse:[
+ ((vLayout == #fit) or:[vLayout == #center]) ifTrue:[
+ maxHeight := maxHeight + (verticalSpace * 2)
+ ]
+ ].
+
^ sumOfWidths @ maxHeight
! !
--- a/ListView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ListView.st Mon Nov 21 17:46:30 1994 +0100
@@ -36,7 +36,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.12 1994-11-17 14:38:09 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.13 1994-11-21 16:45:30 claus Exp $
'!
!ListView class methodsFor:'documentation'!
@@ -57,7 +57,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.12 1994-11-17 14:38:09 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.13 1994-11-21 16:45:30 claus Exp $
"
!
@@ -194,6 +194,18 @@
textStartTop := topMargin + margin.
innerWidth := width - textStartLeft - margin.
self getFontParameters
+!
+
+realize
+ extentChanged ifTrue:[
+ self computeNumberOfLinesShown.
+ ].
+ firstLineShown ~~ 1 ifTrue:[
+ firstLineShown + nLinesShown > list size ifTrue:[
+ self scrollToLine:list size - nLinesShown.
+ ]
+ ].
+ super realize
! !
!ListView methodsFor:'accessing'!
@@ -2162,18 +2174,21 @@
self computeNumberOfLinesShown.
innerWidth := width - textStartLeft - margin.
- shown ifTrue:[
- list notNil ifTrue:[
- listSize := self numberOfLines.
- ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
- newOrigin := listSize - nFullLinesShown + 1.
- newOrigin < 1 ifTrue:[
- newOrigin := 1
- ].
- self scrollToLine: newOrigin
- ]
- ]
- ]
+ shown ifFalse:[^ self].
+ list isNil ifTrue:[^ self].
+
+ listSize := self numberOfLines.
+ "
+ if we are behond the end, scroll up a bit
+ "
+ ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
+ newOrigin := listSize - nFullLinesShown + 1.
+ newOrigin < 1 ifTrue:[
+ newOrigin := 1
+ ].
+ self scrollToLine: newOrigin.
+ ^ self
+ ].
!
redrawX:x y:y width:w height:h
--- a/MenuView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/MenuView.st Mon Nov 21 17:46:30 1994 +0100
@@ -32,7 +32,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.12 1994-11-17 14:38:13 claus Exp $
+$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.13 1994-11-21 16:45:34 claus Exp $
'!
!MenuView class methodsFor:'documentation'!
@@ -53,7 +53,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.12 1994-11-17 14:38:13 claus Exp $
+$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.13 1994-11-21 16:45:34 claus Exp $
"
!
@@ -410,10 +410,10 @@
"create onOff flags, if this label has a check-mark"
(aString startsWith:'\c') ifTrue:[
onOffFlags isNil ifTrue:[
- onOffFlags := Array new:(list size) withAll:false
+ onOffFlags := Array new:(list size)
] ifFalse:[
[onOffFlags size < list size] whileTrue:[
- onOffFlags := onOffFlags copyWith:false
+ onOffFlags := onOffFlags copyWith:nil
]
].
onOffFlags at:i put:false
@@ -721,11 +721,12 @@
|index|
- onOffFlags isNil ifTrue:[
- onOffFlags := Array new:(list size) withAll:false
- ].
index := self indexOf:indexOrName.
index == 0 ifTrue:[^ self].
+
+ onOffFlags isNil ifTrue:[
+ onOffFlags := Array new:(list size)
+ ].
onOffFlags at:index put:aBoolean.
shown ifTrue:[
self redrawLine:index
@@ -878,14 +879,12 @@
l := self visibleLineToListLine:visLineNr.
onOffFlags isNil ifTrue:[
- onOffFlags := Array new:(list size) withAll:false.
check := false
] ifFalse:[
- check := onOffFlags at:l.
+ check := (onOffFlags at:l) == true.
].
w := font widthOf:'\c'.
- h := font ascent.
x := (self xOfCol:1 inVisibleLine:visLineNr) - leftOffset.
y := self yOfVisibleLine:visLineNr.
@@ -895,6 +894,7 @@
self paint:fg.
check ifTrue:[
+ h := font ascent.
self paint:checkColor.
self displayLineFromX:x
y:(y + (h // 2))
@@ -1205,7 +1205,9 @@
!
buttonMotion:state x:x y:y
- self setSelectionForX:x y:y
+ state ~~ 0 ifTrue:[
+ self setSelectionForX:x y:y
+ ]
!
pointerLeave:state
--- a/ObjView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ObjView.st Mon Nov 21 17:46:30 1994 +0100
@@ -48,7 +48,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.11 1994-11-17 14:38:16 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.12 1994-11-21 16:45:37 claus Exp $
"
!
@@ -195,6 +195,26 @@
]
! !
+!ObjectView methodsFor:'scrolling'!
+
+horizontalScrollStep
+ "return the amount to scroll when stepping left/right."
+
+ scaleMetric == #inch ifTrue:[
+ ^ (device horizontalPixelPerInch * (1/2)) asInteger
+ ].
+ ^ (device horizontalPixelPerMillimeter * 20) asInteger
+!
+
+verticalScrollStep
+ "return the amount to scroll when stepping left/right."
+
+ scaleMetric == #inch ifTrue:[
+ ^ (device verticalPixelPerInch * (1/2)) asInteger
+ ].
+ ^ (device verticalPixelPerMillimeter * 20) asInteger
+! !
+
!ObjectView methodsFor:'queries'!
heightOfContents
--- a/ObjectView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ObjectView.st Mon Nov 21 17:46:30 1994 +0100
@@ -48,7 +48,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.11 1994-11-17 14:38:16 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.12 1994-11-21 16:45:37 claus Exp $
"
!
@@ -195,6 +195,26 @@
]
! !
+!ObjectView methodsFor:'scrolling'!
+
+horizontalScrollStep
+ "return the amount to scroll when stepping left/right."
+
+ scaleMetric == #inch ifTrue:[
+ ^ (device horizontalPixelPerInch * (1/2)) asInteger
+ ].
+ ^ (device horizontalPixelPerMillimeter * 20) asInteger
+!
+
+verticalScrollStep
+ "return the amount to scroll when stepping left/right."
+
+ scaleMetric == #inch ifTrue:[
+ ^ (device verticalPixelPerInch * (1/2)) asInteger
+ ].
+ ^ (device verticalPixelPerMillimeter * 20) asInteger
+! !
+
!ObjectView methodsFor:'queries'!
heightOfContents
--- a/ScrView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ScrView.st Mon Nov 21 17:46:30 1994 +0100
@@ -12,7 +12,7 @@
View subclass:#ScrollableView
instanceVariableNames:'scrolledView scrollBar helpView innerMargin
- scrollBarPosition'
+ scrollBarPosition lockUpdates'
classVariableNames:''
poolDictionaries:''
category:'Views-Basic'
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/ScrView.st,v 1.8 1994-11-17 14:38:28 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ScrView.st,v 1.9 1994-11-21 16:45:41 claus Exp $
'!
!ScrollableView class methodsFor:'documentation'!
@@ -43,31 +43,53 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/ScrView.st,v 1.8 1994-11-17 14:38:28 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ScrView.st,v 1.9 1994-11-21 16:45:41 claus Exp $
"
!
documentation
"
a view containing a scrollbar and some other (slave-)view.
+ This view wraps scrollbars around the view to be scrolled.
+ The scrollbars are setup to send scrollUp/scrollDown/scrollVerticalTo
+ and scrollLeft/scrollRight/scrollHorizontalTo- messages whenever moved.
+ The view itself has to omplement these (there is a default implementation
+ in the common View class for this.
+
+ For the scrollbars to know about the full (maximum) size, the view
+ must implement #heightOfContents and/or #widthOfContents.
+ The values returned by these are used to compute the fractio which is
+ visible (i.e. the scrollers thumb heights).
+
There are two ways to create a ScrollableView:
if the type of the view to be scrolled is known in advance,
use:
v := ScrollableView for:<ViewClass> in:someSuperView.
+
otherwise, create the scrollableView empty with:
v := ScrollableView in:someSuperView.
- ...
+ and define the view later with:
v scrolledView:aViewToBeScrolled
+
+ It is also possible to change the scrolledView multiple times,
+ for example if different views are needed to display different types
+ of data (see example2).
+
+ If you want to scroll views (instead of contents), you need a companion
+ class (ViewScroller). See the documentation there.
+
+ If you need horizontal scrolling too, use an instance of HVScrollableView.
"
!
examples
"
- example1:
+ example1 (simple scrolled text):
|top scr txt|
- top := StandardSystemView label:'example'.
+ top := StandardSystemView label:'scroll example1'.
+ top extent:200@100.
scr := ScrollableView for:EditTextView in:top.
scr origin:0.0@0.0 corner:1.0@1.0.
txt := scr scrolledView.
@@ -77,39 +99,50 @@
'line3'
'line4'
'line5'
- 'line6').
+ 'line7'
+ 'line8'
+ 'line9'
+ 'line10'
+ ).
top open
- example2:
+
+ example2 (changing the scrolledView later):
- |top scr txt1 txt2|
+ |top scr txtView1 txtView2|
- top := StandardSystemView label:'example'.
+ top := StandardSystemView label:'scroll example2'.
+ top extent:200@100.
scr := ScrollableView in:top.
scr origin:0.0@0.0 corner:1.0@1.0.
top open.
(Delay forSeconds:5) wait.
- txt1 := EditTextView new.
- txt1 list:#('line1'
- 'line2'
- 'line3'
- 'line4'
- 'line5'
- 'line6').
- scr scrolledView:txt1.
+ txtView1 := EditTextView new.
+ txtView1 list:#(
+ 'wait 5 seconds to see the other text'
+ 'line2'
+ 'line3'
+ 'line4'
+ 'line5'
+ 'line7'
+ 'line8'
+ 'line9'
+ 'line10'
+ ).
+ scr scrolledView:txtView1.
(Delay forSeconds:5) wait.
- txt2 := EditTextView new.
- txt2 list:#('alternative line1'
- 'alternative line2'
- 'alternative line3'
- 'alternative line4'
- 'alternative line5'
- 'alternative line6').
- scr scrolledView:txt2.
+ txtView2 := EditTextView new.
+ txtView2 list:#('this is the other text'
+ 'alternative line2'
+ 'alternative line3'
+ 'alternative line4'
+ 'alternative line5'
+ 'alternative line6').
+ scr scrolledView:txtView2.
"
! !
@@ -182,6 +215,8 @@
super initialize.
+ lockUpdates := false.
+
isST80 := StyleSheet name = #st80.
style == #openwin ifTrue:[self level:0].
@@ -315,8 +350,6 @@
!ScrollableView methodsFor:'private'!
setScrollActions
- |lock|
-
"lock prevents repositioning the scroller to the
actual (often rounded) position while scrolling,
and keeps it instead at the pointer position.
@@ -325,24 +358,17 @@
textviews, when the text is aligned line-wise).
Consider this as a kludge."
- lock := false.
+ lockUpdates := false.
scrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollVerticalToPercent:position.
- lock := false
+ lockUpdates := false
].
scrollBar scrollUpAction:[scrolledView scrollUp].
scrollBar scrollDownAction:[scrolledView scrollDown].
- scrolledView originChangeAction:[:aView |
- lock ifFalse:[
- scrollBar setThumbOriginFor:aView.
- ]
- ].
- scrolledView contentsChangeAction:[:aView |
- scrollBar setThumbFor:aView.
- ]
+ scrolledView addDependent:self.
! !
!ScrollableView methodsFor:'accessing'!
@@ -510,6 +536,26 @@
scrollBar pageDown
! !
+!ScrollableView methodsFor:'changes '!
+
+update:something with:argument from:changedObject
+ "whenever the scrolledView changes its contents, the scroller must
+ be updated"
+
+ changedObject == scrolledView ifTrue:[
+ something == #sizeOfContents ifTrue:[
+ scrollBar setThumbFor:scrolledView.
+ ^ self
+ ].
+ something == #originOfContents ifTrue:[
+ lockUpdates ifFalse:[
+ scrollBar setThumbOriginFor:scrolledView.
+ ].
+ ^ self
+ ].
+ ].
+! !
+
!ScrollableView methodsFor:'event processing'!
keyPress:key x:x y:y
--- a/ScrollableView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/ScrollableView.st Mon Nov 21 17:46:30 1994 +0100
@@ -12,7 +12,7 @@
View subclass:#ScrollableView
instanceVariableNames:'scrolledView scrollBar helpView innerMargin
- scrollBarPosition'
+ scrollBarPosition lockUpdates'
classVariableNames:''
poolDictionaries:''
category:'Views-Basic'
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/ScrollableView.st,v 1.8 1994-11-17 14:38:28 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ScrollableView.st,v 1.9 1994-11-21 16:45:41 claus Exp $
'!
!ScrollableView class methodsFor:'documentation'!
@@ -43,31 +43,53 @@
version
"
-$Header: /cvs/stx/stx/libwidg/ScrollableView.st,v 1.8 1994-11-17 14:38:28 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ScrollableView.st,v 1.9 1994-11-21 16:45:41 claus Exp $
"
!
documentation
"
a view containing a scrollbar and some other (slave-)view.
+ This view wraps scrollbars around the view to be scrolled.
+ The scrollbars are setup to send scrollUp/scrollDown/scrollVerticalTo
+ and scrollLeft/scrollRight/scrollHorizontalTo- messages whenever moved.
+ The view itself has to omplement these (there is a default implementation
+ in the common View class for this.
+
+ For the scrollbars to know about the full (maximum) size, the view
+ must implement #heightOfContents and/or #widthOfContents.
+ The values returned by these are used to compute the fractio which is
+ visible (i.e. the scrollers thumb heights).
+
There are two ways to create a ScrollableView:
if the type of the view to be scrolled is known in advance,
use:
v := ScrollableView for:<ViewClass> in:someSuperView.
+
otherwise, create the scrollableView empty with:
v := ScrollableView in:someSuperView.
- ...
+ and define the view later with:
v scrolledView:aViewToBeScrolled
+
+ It is also possible to change the scrolledView multiple times,
+ for example if different views are needed to display different types
+ of data (see example2).
+
+ If you want to scroll views (instead of contents), you need a companion
+ class (ViewScroller). See the documentation there.
+
+ If you need horizontal scrolling too, use an instance of HVScrollableView.
"
!
examples
"
- example1:
+ example1 (simple scrolled text):
|top scr txt|
- top := StandardSystemView label:'example'.
+ top := StandardSystemView label:'scroll example1'.
+ top extent:200@100.
scr := ScrollableView for:EditTextView in:top.
scr origin:0.0@0.0 corner:1.0@1.0.
txt := scr scrolledView.
@@ -77,39 +99,50 @@
'line3'
'line4'
'line5'
- 'line6').
+ 'line7'
+ 'line8'
+ 'line9'
+ 'line10'
+ ).
top open
- example2:
+
+ example2 (changing the scrolledView later):
- |top scr txt1 txt2|
+ |top scr txtView1 txtView2|
- top := StandardSystemView label:'example'.
+ top := StandardSystemView label:'scroll example2'.
+ top extent:200@100.
scr := ScrollableView in:top.
scr origin:0.0@0.0 corner:1.0@1.0.
top open.
(Delay forSeconds:5) wait.
- txt1 := EditTextView new.
- txt1 list:#('line1'
- 'line2'
- 'line3'
- 'line4'
- 'line5'
- 'line6').
- scr scrolledView:txt1.
+ txtView1 := EditTextView new.
+ txtView1 list:#(
+ 'wait 5 seconds to see the other text'
+ 'line2'
+ 'line3'
+ 'line4'
+ 'line5'
+ 'line7'
+ 'line8'
+ 'line9'
+ 'line10'
+ ).
+ scr scrolledView:txtView1.
(Delay forSeconds:5) wait.
- txt2 := EditTextView new.
- txt2 list:#('alternative line1'
- 'alternative line2'
- 'alternative line3'
- 'alternative line4'
- 'alternative line5'
- 'alternative line6').
- scr scrolledView:txt2.
+ txtView2 := EditTextView new.
+ txtView2 list:#('this is the other text'
+ 'alternative line2'
+ 'alternative line3'
+ 'alternative line4'
+ 'alternative line5'
+ 'alternative line6').
+ scr scrolledView:txtView2.
"
! !
@@ -182,6 +215,8 @@
super initialize.
+ lockUpdates := false.
+
isST80 := StyleSheet name = #st80.
style == #openwin ifTrue:[self level:0].
@@ -315,8 +350,6 @@
!ScrollableView methodsFor:'private'!
setScrollActions
- |lock|
-
"lock prevents repositioning the scroller to the
actual (often rounded) position while scrolling,
and keeps it instead at the pointer position.
@@ -325,24 +358,17 @@
textviews, when the text is aligned line-wise).
Consider this as a kludge."
- lock := false.
+ lockUpdates := false.
scrollBar scrollAction:[:position |
- lock := true.
+ lockUpdates := true.
scrolledView scrollVerticalToPercent:position.
- lock := false
+ lockUpdates := false
].
scrollBar scrollUpAction:[scrolledView scrollUp].
scrollBar scrollDownAction:[scrolledView scrollDown].
- scrolledView originChangeAction:[:aView |
- lock ifFalse:[
- scrollBar setThumbOriginFor:aView.
- ]
- ].
- scrolledView contentsChangeAction:[:aView |
- scrollBar setThumbFor:aView.
- ]
+ scrolledView addDependent:self.
! !
!ScrollableView methodsFor:'accessing'!
@@ -510,6 +536,26 @@
scrollBar pageDown
! !
+!ScrollableView methodsFor:'changes '!
+
+update:something with:argument from:changedObject
+ "whenever the scrolledView changes its contents, the scroller must
+ be updated"
+
+ changedObject == scrolledView ifTrue:[
+ something == #sizeOfContents ifTrue:[
+ scrollBar setThumbFor:scrolledView.
+ ^ self
+ ].
+ something == #originOfContents ifTrue:[
+ lockUpdates ifFalse:[
+ scrollBar setThumbOriginFor:scrolledView.
+ ].
+ ^ self
+ ].
+ ].
+! !
+
!ScrollableView methodsFor:'event processing'!
keyPress:key x:x y:y
--- a/Scroller.st Thu Nov 17 15:40:37 1994 +0100
+++ b/Scroller.st Mon Nov 21 17:46:30 1994 +0100
@@ -43,7 +43,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.10 1994-11-17 14:38:34 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.11 1994-11-21 16:46:30 claus Exp $
'!
!Scroller class methodsFor:'documentation'!
@@ -64,7 +64,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.10 1994-11-17 14:38:34 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.11 1994-11-21 16:46:30 claus Exp $
"
!
@@ -614,9 +614,13 @@
percentSize := 100.
percentOrigin := 100
] ifFalse:[
- viewsSize := (moveDirection == #y) ifTrue:[aView innerHeight] ifFalse:[aView innerWidth].
- contentsPosition := (moveDirection == #y) ifTrue:[aView yOriginOfContents] ifFalse:[aView xOriginOfContents].
-
+ (moveDirection == #y) ifTrue:[
+ viewsSize := aView innerHeight.
+ contentsPosition := aView yOriginOfContents.
+ ] ifFalse:[
+ viewsSize := aView innerWidth.
+ contentsPosition := aView xOriginOfContents
+ ].
percentSize := viewsSize * 100.0 / contentsSize.
percentOrigin := contentsPosition * 100.0 / contentsSize.
--- a/SelListV.st Thu Nov 17 15:40:37 1994 +0100
+++ b/SelListV.st Mon Nov 21 17:46:30 1994 +0100
@@ -37,7 +37,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.13 1994-11-17 14:38:36 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.14 1994-11-21 16:45:43 claus Exp $
'!
!SelectionInListView class methodsFor:'documentation'!
@@ -58,7 +58,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.13 1994-11-17 14:38:36 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.14 1994-11-21 16:45:43 claus Exp $
"
!
@@ -1319,7 +1319,7 @@
Must check, if any is in the selection and handle this case.
Otherwise draw using supers method."
- |listLine fg bg attr oldFont|
+ |listLine fg bg attr oldFont newFont|
fg := fgColor.
bg := bgColor.
@@ -1333,14 +1333,18 @@
] ifFalse:[
(self line:listLine hasAttribute:#disabled) ifTrue:[
fg := halfIntensityFgColor
+ ].
+ ].
+ (self line:listLine hasAttribute:#bold) ifTrue:[
+ font bold ifTrue:[
+ newFont := font asItalic
] ifFalse:[
- (self line:listLine hasAttribute:#bold) ifTrue:[
-device setFont:(font asBold on:device) fontId in:gcId.
- self drawVisibleLine:visLineNr with:fg and:bg.
-device setFont:(font on:device) fontId in:gcId.
- ^ self
- ]
- ]
+ newFont := font asBold
+ ].
+ device setFont:(newFont on:device) fontId in:gcId.
+ self drawVisibleLine:visLineNr with:fg and:bg.
+ device setFont:(font on:device) fontId in:gcId.
+ ^ self
]
].
^ self drawVisibleLine:visLineNr with:fg and:bg
@@ -1431,17 +1435,16 @@
shown ifTrue:[
selection notNil ifTrue:[
(selection isKindOf:Collection) ifTrue:[
- selection isEmpty ifTrue:[
- first := 1
- ] ifFalse:[
+ selection notEmpty ifTrue:[
first := selection first
]
] ifFalse:[
first := selection
].
- self makeLineVisible:first
+ first notNil ifTrue:[self makeLineVisible:first]
] ifFalse:[
- "if we where at the end before, move to the end again.
+ "
+ if we where at the end before, move to the end again.
Still to be seen, if this is better in real life ...
"
wasAtEnd ifTrue:[
--- a/SelectionInListView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/SelectionInListView.st Mon Nov 21 17:46:30 1994 +0100
@@ -37,7 +37,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.13 1994-11-17 14:38:36 claus Exp $
+$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.14 1994-11-21 16:45:43 claus Exp $
'!
!SelectionInListView class methodsFor:'documentation'!
@@ -58,7 +58,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.13 1994-11-17 14:38:36 claus Exp $
+$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.14 1994-11-21 16:45:43 claus Exp $
"
!
@@ -1319,7 +1319,7 @@
Must check, if any is in the selection and handle this case.
Otherwise draw using supers method."
- |listLine fg bg attr oldFont|
+ |listLine fg bg attr oldFont newFont|
fg := fgColor.
bg := bgColor.
@@ -1333,14 +1333,18 @@
] ifFalse:[
(self line:listLine hasAttribute:#disabled) ifTrue:[
fg := halfIntensityFgColor
+ ].
+ ].
+ (self line:listLine hasAttribute:#bold) ifTrue:[
+ font bold ifTrue:[
+ newFont := font asItalic
] ifFalse:[
- (self line:listLine hasAttribute:#bold) ifTrue:[
-device setFont:(font asBold on:device) fontId in:gcId.
- self drawVisibleLine:visLineNr with:fg and:bg.
-device setFont:(font on:device) fontId in:gcId.
- ^ self
- ]
- ]
+ newFont := font asBold
+ ].
+ device setFont:(newFont on:device) fontId in:gcId.
+ self drawVisibleLine:visLineNr with:fg and:bg.
+ device setFont:(font on:device) fontId in:gcId.
+ ^ self
]
].
^ self drawVisibleLine:visLineNr with:fg and:bg
@@ -1431,17 +1435,16 @@
shown ifTrue:[
selection notNil ifTrue:[
(selection isKindOf:Collection) ifTrue:[
- selection isEmpty ifTrue:[
- first := 1
- ] ifFalse:[
+ selection notEmpty ifTrue:[
first := selection first
]
] ifFalse:[
first := selection
].
- self makeLineVisible:first
+ first notNil ifTrue:[self makeLineVisible:first]
] ifFalse:[
- "if we where at the end before, move to the end again.
+ "
+ if we where at the end before, move to the end again.
Still to be seen, if this is better in real life ...
"
wasAtEnd ifTrue:[
--- a/VPanelV.st Thu Nov 17 15:40:37 1994 +0100
+++ b/VPanelV.st Mon Nov 21 17:46:30 1994 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.6 1994-11-17 14:38:46 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.7 1994-11-21 16:45:46 claus Exp $
'!
!VerticalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.6 1994-11-17 14:38:46 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.7 1994-11-21 16:45:46 claus Exp $
"
!
@@ -270,6 +270,7 @@
sumOfHeights := 0.
maxWidth := 0.
+ maxHeight := 0.
subViews do:[:child |
|childsPreference|
@@ -287,8 +288,22 @@
sumOfHeights := sumOfHeights + (horizontalSpace * 2).
maxWidth := maxWidth + (horizontalSpace * 2).
].
- sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
+ vLayout == #fit ifTrue:[
+ sumOfHeights := maxHeight * subViews size.
+ borderWidth ~~ 0 ifTrue:[
+ sumOfHeights := sumOfHeights + (verticalSpace * 2).
+ ]
+ ] ifFalse:[
+ sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
+ ].
+ ((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
+ maxWidth := maxWidth + horizontalSpace
+ ] ifFalse:[
+ ((hLayout == #fit) or:[hLayout == #center]) ifTrue:[
+ maxWidth := maxWidth + (horizontalSpace * 2)
+ ]
+ ].
^ maxWidth @ sumOfHeights
! !
--- a/VerticalPanelView.st Thu Nov 17 15:40:37 1994 +0100
+++ b/VerticalPanelView.st Mon Nov 21 17:46:30 1994 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.6 1994-11-17 14:38:46 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.7 1994-11-21 16:45:46 claus Exp $
'!
!VerticalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.6 1994-11-17 14:38:46 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.7 1994-11-21 16:45:46 claus Exp $
"
!
@@ -270,6 +270,7 @@
sumOfHeights := 0.
maxWidth := 0.
+ maxHeight := 0.
subViews do:[:child |
|childsPreference|
@@ -287,8 +288,22 @@
sumOfHeights := sumOfHeights + (horizontalSpace * 2).
maxWidth := maxWidth + (horizontalSpace * 2).
].
- sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
+ vLayout == #fit ifTrue:[
+ sumOfHeights := maxHeight * subViews size.
+ borderWidth ~~ 0 ifTrue:[
+ sumOfHeights := sumOfHeights + (verticalSpace * 2).
+ ]
+ ] ifFalse:[
+ sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
+ ].
+ ((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
+ maxWidth := maxWidth + horizontalSpace
+ ] ifFalse:[
+ ((hLayout == #fit) or:[hLayout == #center]) ifTrue:[
+ maxWidth := maxWidth + (horizontalSpace * 2)
+ ]
+ ].
^ maxWidth @ sumOfHeights
! !