--- a/2ColTxtV.st Sat Oct 26 13:15:46 1996 +0200
+++ b/2ColTxtV.st Wed Nov 06 12:50:14 1996 +0100
@@ -19,7 +19,7 @@
category:'Views-Text'
!
-!TwoColumnTextView class methodsFor:'documentation'!
+!TwoColumnTextView class methodsFor:'documentation'!
copyright
"
@@ -96,7 +96,7 @@
"Modified: 20.11.1995 / 13:23:12 / cg"
! !
-!TwoColumnTextView class methodsFor:'instance creation'!
+!TwoColumnTextView class methodsFor:'instance creation'!
openOn:firstText and:secondText
"open up a view showing firstText and secondText side-by-side.
@@ -105,12 +105,7 @@
|top v|
top := StandardSystemView label:'two texts'.
- v := HVScrollableView
- for:self
- miniScrollerH:true miniScrollerV:false
- in:top.
- v origin:0.0 @ 0.0 corner:1.0 @ 1.0.
- v scrolledView text1:firstText text2:secondText.
+ self openOn:firstText and:secondText in:top.
^ top open
"
@@ -127,6 +122,17 @@
"Modified: 25.4.1996 / 13:31:03 / cg"
!
+openOn:firstText and:secondText in:aView
+ "open up a view showing firstText and secondText side-by-side.
+ This does not make much sense for unrelated texts - of course."
+
+ self openOn:firstText
+ label:nil
+ and:secondText
+ label:nil
+ in:aView.
+!
+
openOn:firstText label:firstLabel and:secondText label:secondLabel
"open up a view showing firstText and secondText side-by-side,
and labels for both views.
@@ -135,19 +141,13 @@
|top v l1 l2|
top := StandardSystemView label:'two texts'.
- l1 := Label label:firstLabel in:top.
- l1 origin:0.0@0.0 corner:0.5@(l1 height).
- l1 borderWidth:0.
- l2 := Label label:secondLabel in:top.
- l2 origin:0.5@0.0 corner:1.0@(l1 height).
- l2 borderWidth:0.
- v := HVScrollableView
- for:self
- miniScrollerH:true miniScrollerV:false
- in:top.
- v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
- v scrolledView text1:firstText text2:secondText.
+ self openOn:firstText
+ label:firstLabel
+ and:secondText
+ label:secondLabel
+ in:top.
+
^ top open
"
@@ -159,9 +159,62 @@
"
"Modified: 15.8.1996 / 19:46:38 / cg"
+!
+
+openOn:firstText label:firstLabel and:secondText label:secondLabel in:aView
+ "open up a view showing firstText and secondText side-by-side,
+ and labels for both views.
+ This does not make much sense for unrelated texts - of course."
+
+ |hvs scr l1 l2 buttonPrev buttonNext panel|
+
+ hvs := HVScrollableView
+ for:self
+ miniScrollerH:true miniScrollerV:false
+ in:aView.
+
+ scr := hvs scrolledView.
+
+ (firstLabel notNil and:[secondLabel notNil]) ifTrue:[
+ l1 := Label label:firstLabel in:aView.
+ l1 origin:0.0@0.0 corner:0.5@(l1 height).
+ l1 borderWidth:0.
+ l2 := Label label:secondLabel in:aView.
+ l2 origin:0.5@0.0 corner:1.0@(l1 height).
+ l2 borderWidth:0.
+
+ hvs origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
+ ] ifFalse:[
+ hvs origin:0.0 @ 0.0 corner:1.0 @ 1.0
+ ].
+ scr text1:firstText text2:secondText.
+
+"set up-down buttons"
+
+ panel := VerticalPanelView in:scr.
+
+ buttonPrev := Button label:'-' in:panel.
+ buttonNext := Button label:'+' in:panel.
+ buttonPrev extent:15@22.
+ buttonNext extent:15@22.
+ panel origin:0.0 @ 1.0 corner:(15 + SimpleView viewSpacing) @ 1.0.
+ panel topInset:(2 * (buttonPrev preferredExtent y)) negated.
+
+"set actions"
+
+ buttonPrev pressAction:[
+ buttonPrev turnOff.
+ scr moveToPreviousChanged
+ ].
+
+ buttonNext pressAction:[
+ buttonNext turnOff.
+ scr moveToNextChanged
+ ].
+ scr moveToNextChanged.
! !
-!TwoColumnTextView class methodsFor:'specification'!
+!TwoColumnTextView class methodsFor:'specification'!
numberOfViews
^ 2
@@ -178,7 +231,84 @@
"Created: 20.11.1995 / 13:20:39 / cg"
! !
-!TwoColumnTextView class methodsFor:'documentation'!
+!TwoColumnTextView methodsFor:'actions'!
+
+moveToLine:aLineNr
+ |lnNr view nLinesShown|
+
+ view := textViews at:1.
+
+ view shown ifTrue:[
+ lnNr := (view lastLineShown - view firstLineShown) // 3.
+ ] ifFalse:[
+ lnNr := 5.
+ ].
+
+ (lnNr := aLineNr - lnNr) < 1 ifTrue:[
+ lnNr := 1
+ ].
+ self scrollToLine:lnNr.
+!
+
+moveToNextChanged
+ |start end|
+
+ start := ((textViews at:1) lastLineShown) + 1.
+
+ textViews do:[:v||list max lnNr|
+ list := v list.
+ max := list size.
+ lnNr := start.
+
+ [(lnNr > max or:[(list at:lnNr) isText])
+ ] whileFalse:[
+ lnNr := lnNr + 1
+ ].
+
+ (lnNr <= max) ifTrue:[
+ (end isNil or:[lnNr < end]) ifTrue:[
+ end := lnNr.
+ ]
+ ].
+ ].
+
+ end notNil ifTrue:[
+ self moveToLine:end
+ ].
+!
+
+moveToPreviousChanged
+ |start end found|
+
+ start := ((textViews at:1) firstLineShown) - 1.
+ end := 1.
+ found := false.
+
+ start > 1 ifTrue:[
+ textViews do:[:v||lnNr list|
+ list := v list.
+ lnNr := list size.
+
+ lnNr >= start ifTrue:[
+ lnNr := start
+ ].
+
+ [(lnNr == end or:[(list at:lnNr) isText])
+ ] whileFalse:[
+ lnNr := lnNr - 1
+ ].
+ (list at:lnNr) isText ifTrue:[
+ end := lnNr.
+ found := true
+ ]
+ ]
+ ].
+ found ifTrue:[
+ self moveToLine:end
+ ].
+! !
+
+!TwoColumnTextView class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libwidg2/Attic/2ColTxtV.st,v 1.14 1996-08-15 17:47:17 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libwidg2/Attic/2ColTxtV.st,v 1.15 1996-11-06 11:50:14 ca Exp $'! !
--- a/TwoColumnTextView.st Sat Oct 26 13:15:46 1996 +0200
+++ b/TwoColumnTextView.st Wed Nov 06 12:50:14 1996 +0100
@@ -19,7 +19,7 @@
category:'Views-Text'
!
-!TwoColumnTextView class methodsFor:'documentation'!
+!TwoColumnTextView class methodsFor:'documentation'!
copyright
"
@@ -96,7 +96,7 @@
"Modified: 20.11.1995 / 13:23:12 / cg"
! !
-!TwoColumnTextView class methodsFor:'instance creation'!
+!TwoColumnTextView class methodsFor:'instance creation'!
openOn:firstText and:secondText
"open up a view showing firstText and secondText side-by-side.
@@ -105,12 +105,7 @@
|top v|
top := StandardSystemView label:'two texts'.
- v := HVScrollableView
- for:self
- miniScrollerH:true miniScrollerV:false
- in:top.
- v origin:0.0 @ 0.0 corner:1.0 @ 1.0.
- v scrolledView text1:firstText text2:secondText.
+ self openOn:firstText and:secondText in:top.
^ top open
"
@@ -127,6 +122,17 @@
"Modified: 25.4.1996 / 13:31:03 / cg"
!
+openOn:firstText and:secondText in:aView
+ "open up a view showing firstText and secondText side-by-side.
+ This does not make much sense for unrelated texts - of course."
+
+ self openOn:firstText
+ label:nil
+ and:secondText
+ label:nil
+ in:aView.
+!
+
openOn:firstText label:firstLabel and:secondText label:secondLabel
"open up a view showing firstText and secondText side-by-side,
and labels for both views.
@@ -135,19 +141,13 @@
|top v l1 l2|
top := StandardSystemView label:'two texts'.
- l1 := Label label:firstLabel in:top.
- l1 origin:0.0@0.0 corner:0.5@(l1 height).
- l1 borderWidth:0.
- l2 := Label label:secondLabel in:top.
- l2 origin:0.5@0.0 corner:1.0@(l1 height).
- l2 borderWidth:0.
- v := HVScrollableView
- for:self
- miniScrollerH:true miniScrollerV:false
- in:top.
- v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
- v scrolledView text1:firstText text2:secondText.
+ self openOn:firstText
+ label:firstLabel
+ and:secondText
+ label:secondLabel
+ in:top.
+
^ top open
"
@@ -159,9 +159,62 @@
"
"Modified: 15.8.1996 / 19:46:38 / cg"
+!
+
+openOn:firstText label:firstLabel and:secondText label:secondLabel in:aView
+ "open up a view showing firstText and secondText side-by-side,
+ and labels for both views.
+ This does not make much sense for unrelated texts - of course."
+
+ |hvs scr l1 l2 buttonPrev buttonNext panel|
+
+ hvs := HVScrollableView
+ for:self
+ miniScrollerH:true miniScrollerV:false
+ in:aView.
+
+ scr := hvs scrolledView.
+
+ (firstLabel notNil and:[secondLabel notNil]) ifTrue:[
+ l1 := Label label:firstLabel in:aView.
+ l1 origin:0.0@0.0 corner:0.5@(l1 height).
+ l1 borderWidth:0.
+ l2 := Label label:secondLabel in:aView.
+ l2 origin:0.5@0.0 corner:1.0@(l1 height).
+ l2 borderWidth:0.
+
+ hvs origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
+ ] ifFalse:[
+ hvs origin:0.0 @ 0.0 corner:1.0 @ 1.0
+ ].
+ scr text1:firstText text2:secondText.
+
+"set up-down buttons"
+
+ panel := VerticalPanelView in:scr.
+
+ buttonPrev := Button label:'-' in:panel.
+ buttonNext := Button label:'+' in:panel.
+ buttonPrev extent:15@22.
+ buttonNext extent:15@22.
+ panel origin:0.0 @ 1.0 corner:(15 + SimpleView viewSpacing) @ 1.0.
+ panel topInset:(2 * (buttonPrev preferredExtent y)) negated.
+
+"set actions"
+
+ buttonPrev pressAction:[
+ buttonPrev turnOff.
+ scr moveToPreviousChanged
+ ].
+
+ buttonNext pressAction:[
+ buttonNext turnOff.
+ scr moveToNextChanged
+ ].
+ scr moveToNextChanged.
! !
-!TwoColumnTextView class methodsFor:'specification'!
+!TwoColumnTextView class methodsFor:'specification'!
numberOfViews
^ 2
@@ -178,7 +231,84 @@
"Created: 20.11.1995 / 13:20:39 / cg"
! !
-!TwoColumnTextView class methodsFor:'documentation'!
+!TwoColumnTextView methodsFor:'actions'!
+
+moveToLine:aLineNr
+ |lnNr view nLinesShown|
+
+ view := textViews at:1.
+
+ view shown ifTrue:[
+ lnNr := (view lastLineShown - view firstLineShown) // 3.
+ ] ifFalse:[
+ lnNr := 5.
+ ].
+
+ (lnNr := aLineNr - lnNr) < 1 ifTrue:[
+ lnNr := 1
+ ].
+ self scrollToLine:lnNr.
+!
+
+moveToNextChanged
+ |start end|
+
+ start := ((textViews at:1) lastLineShown) + 1.
+
+ textViews do:[:v||list max lnNr|
+ list := v list.
+ max := list size.
+ lnNr := start.
+
+ [(lnNr > max or:[(list at:lnNr) isText])
+ ] whileFalse:[
+ lnNr := lnNr + 1
+ ].
+
+ (lnNr <= max) ifTrue:[
+ (end isNil or:[lnNr < end]) ifTrue:[
+ end := lnNr.
+ ]
+ ].
+ ].
+
+ end notNil ifTrue:[
+ self moveToLine:end
+ ].
+!
+
+moveToPreviousChanged
+ |start end found|
+
+ start := ((textViews at:1) firstLineShown) - 1.
+ end := 1.
+ found := false.
+
+ start > 1 ifTrue:[
+ textViews do:[:v||lnNr list|
+ list := v list.
+ lnNr := list size.
+
+ lnNr >= start ifTrue:[
+ lnNr := start
+ ].
+
+ [(lnNr == end or:[(list at:lnNr) isText])
+ ] whileFalse:[
+ lnNr := lnNr - 1
+ ].
+ (list at:lnNr) isText ifTrue:[
+ end := lnNr.
+ found := true
+ ]
+ ]
+ ].
+ found ifTrue:[
+ self moveToLine:end
+ ].
+! !
+
+!TwoColumnTextView class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.14 1996-08-15 17:47:17 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.15 1996-11-06 11:50:14 ca Exp $'! !