--- a/Make.proto Thu Nov 17 15:42:58 1994 +0100
+++ b/Make.proto Mon Nov 21 17:49:32 1994 +0100
@@ -12,7 +12,6 @@
objs:: \
Ruler.$(O) \
- TextRuler.$(O) \
Slider.$(O) \
HSlider.$(O) \
LEnterFld.$(O) \
@@ -22,6 +21,11 @@
FNmEdtFld.$(O) \
TextBox.$(O)
+moreObjs:
+ TextRuler.$(O) \
+ TabSpec.$(O) \
+ ParSpec.$(O)
+
obsolete: \
RetButton.$(O) \
MenuButt.$(O) \
@@ -101,3 +105,6 @@
TabSpec.$(O): $(OBJECT)
TextBox.$(O): TextBox.st $(ENTERBOX)
+
+TabSpec.$(O): TabSpec.st $(OBJECT)
+ParSpec.$(O): ParSpec.st $(I)/TabSpec.H $(OBJECT)
--- a/Ruler.st Thu Nov 17 15:42:58 1994 +0100
+++ b/Ruler.st Mon Nov 21 17:49:32 1994 +0100
@@ -23,7 +23,7 @@
a Ruler for page layout.
-$Header: /cvs/stx/stx/libwidg2/Ruler.st,v 1.8 1994-11-17 14:42:26 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/Ruler.st,v 1.9 1994-11-21 16:49:32 claus Exp $
written oct 91 by claus
'!
@@ -73,19 +73,26 @@
viewOrigin:origin
super setViewOrigin:origin.
self redraw
+!
+
+widthOfContents
+ ^ (device horizontalPixelPerInch * paperWidth) rounded
+!
+
+heightOfContents
+ ^ (device verticalPixelPerInch * paperHeight) rounded
! !
!Ruler methodsFor:'redrawing'!
redraw
- "redraw scale"
+ "redraw the scale"
|x pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charY
top paperWidthMM paperWidthPixel xOrigin labelRight stringRight marg|
shown ifFalse:[^ self].
-"/ self fill:viewBackground.
self clear.
xOrigin := self viewOrigin x.
@@ -116,31 +123,27 @@
paperWidthMM := self inchToMillimeter:paperWidth.
pixelPerMM := (self millimeterToPixel:1) * scale.
pos := 5.
- labelRight := stringRight := marg + (font widthOf:'cm').
+ labelRight := stringRight := marg + (font widthOf:'cm') + 3.
x := (pixelPerMM * pos - xOrigin) rounded.
[(x < width) and:[pos <= paperWidthMM]] whileTrue:[
|l|
- (mod == 1) ifTrue:[
- self displayLineFromX:x y:top
- toX:x y:(top + shortLen)
- ] ifFalse:[
- x < stringRight ifTrue:[
- l := shortLen
- ] ifFalse:[
+ l := shortLen.
+ (mod ~~ 1) ifTrue:[
+ x < stringRight ifFalse:[
l := longLen
].
- self displayLineFromX:x y:top
- toX:x y:(top + l).
+ ].
+ self displayLineFromX:x y:top
+ toX:x y:(top + l).
- x < stringRight ifFalse:[
- self displayString:(pos // 10) printString
- x:(x + marg)
- y:charY.
- stringRight := x + marg
- + (font widthOf:(pos // 10) printString)
- ]
+ ((x < stringRight) or:[mod == 1]) ifFalse:[
+ self displayString:(pos // 10) printString
+ x:(x + marg)
+ y:charY.
+ stringRight := x + marg
+ + (font widthOf:(pos // 10) printString)
].
mod := (mod + 1) \\ 2.
pos := pos + 5.
@@ -154,28 +157,31 @@
pixelPerInch := (self inchToPixel:1) * scale.
pos := 0.25.
- labelRight := marg + (font widthOf:'inch').
+ labelRight := marg + (font widthOf:'inch') + 3.
x := (pixelPerInch * pos - xOrigin) rounded.
veryShortLen := longLen // 4.
[(x < width) and:[pos <= paperWidth]] whileTrue:[
+ |l|
+
+ l := shortLen.
(mod == 0) ifTrue:[
x < labelRight ifFalse:[
- self displayLineFromX:x y:top
- toX:x y:(top + longLen).
- self displayString:pos asInteger printString
- x:(x + marg)
- y:charY
+ l := longLen
]
] ifFalse:[
- (mod == 2) ifTrue:[
- self displayLineFromX:x y:top
- toX:x y:(top + shortLen)
- ] ifFalse:[
- self displayLineFromX:x y:top
- toX:x y:(top + veryShortLen)
+ (mod == 2) ifFalse:[
+ l := veryShortLen
]
].
+ self displayLineFromX:x y:top
+ toX:x y:(top + l).
+
+ (mod == 0 and:[x >= labelRight]) ifTrue:[
+ self displayString:pos asInteger printString
+ x:(x + marg)
+ y:charY
+ ].
mod := (mod + 1) \\ 4.
pos := pos + 0.25.
x := (pixelPerInch * pos - xOrigin) rounded
@@ -193,7 +199,7 @@
fgColor := Black.
bitGravity := #NorthWest.
- self height:(font height + font descent + font descent).
+ self height:(font height + (2 * font descent)).
(Language == #english) ifTrue:[
metric := #inch
] ifFalse:[
--- a/TabSpec.st Thu Nov 17 15:42:58 1994 +0100
+++ b/TabSpec.st Mon Nov 21 17:49:32 1994 +0100
@@ -9,6 +9,26 @@
!TabulatorSpecification class methodsFor:'documentation'!
+copyright
+"
+ COPYRIGHT (c) 1994 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libwidg2/Attic/TabSpec.st,v 1.3 1994-11-21 16:49:03 claus Exp $
+"
+!
+
documentation
"
This is a helper class for table widgets and tabular data in
@@ -16,7 +36,11 @@
A tabulatorSpecification keeps track of where the tabs are,
and how they align. They are to be used un conjunction with
MultiColumnListEntry or the upcoming tableWidget.
+"
+!
+examples
+"
Example use (in a ListView):
|listView tabSpec entry|
@@ -62,8 +86,99 @@
listView at:3 put:entry.
listView open
- tabSpec widths: #(2 0.3 2 1 0.7 0.5 1).
- " name type mode owner group size type"
+
+ defining field positions in millimeter :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#mm.
+ tabSpec positions:#(0 10 20 40).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
+
+ defining field widths in millimeter :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#mm.
+ tabSpec widths:#(10 10 20 10).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
+
+ defining field widths in pixels :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#pixel.
+ tabSpec widths:#(50 30 30 50).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
"
! !
@@ -98,6 +213,20 @@
^ 1.
!
+typeOfTab:index
+ "return the type of the tab at position index."
+
+ tabPositions isNil ifTrue:[^ #left].
+ tabTypes notNil ifTrue:[
+ (tabTypes isMemberOf:Symbol) ifTrue:[
+ ^ tabTypes
+ ].
+ ^ tabTypes at:index.
+ ].
+ "default is left"
+ ^ #left
+!
+
positionOfTab:index on:aGC
"return the position (in device units) of the tab at index"
@@ -119,15 +248,7 @@
pos := self positionOfTab:index on:aGC.
pos isNil ifTrue:[^ nil].
- tabTypes notNil ifTrue:[
- (tabTypes isMemberOf:Symbol) ifTrue:[
- type := tabTypes
- ] ifFalse:[
- type := tabTypes at:(index).
- ].
- ] ifFalse:[
- type := #left
- ].
+ type := self typeOfTab:index.
type == #right ifTrue:[
^ pos - (aGC font widthOf:aString).
@@ -145,11 +266,16 @@
].
"default is left"
^ pos
-
! !
!TabulatorSpecification methodsFor:'accessing'!
+size
+ "return the number of tabs in this spec"
+
+ ^ tabPositions size
+!
+
unit:aSymbol
"set the unit.
allowed are: #inch, #mm, #cm, #pixel and #col"
@@ -190,6 +316,25 @@
^ tabTypes
!
+widths
+ "return a width-vector"
+
+ |prev|
+
+ prev := 0.
+ ^ tabPositions collect:[:p | |w| w := p - prev. prev := p. w].
+
+ "
+ |spec|
+
+ spec := TabulatorSpecification new.
+ spec unit:#inch.
+ spec positions:#(0 1 2.5 3.5 4 5 ).
+ spec align: #(#left #left #right #right #center #decimal ).
+ spec widths
+ "
+!
+
widths:fieldWidths
"set the position-vector from a vector of field widths"
--- a/TabulatorSpecification.st Thu Nov 17 15:42:58 1994 +0100
+++ b/TabulatorSpecification.st Mon Nov 21 17:49:32 1994 +0100
@@ -9,6 +9,26 @@
!TabulatorSpecification class methodsFor:'documentation'!
+copyright
+"
+ COPYRIGHT (c) 1994 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libwidg2/TabulatorSpecification.st,v 1.3 1994-11-21 16:49:03 claus Exp $
+"
+!
+
documentation
"
This is a helper class for table widgets and tabular data in
@@ -16,7 +36,11 @@
A tabulatorSpecification keeps track of where the tabs are,
and how they align. They are to be used un conjunction with
MultiColumnListEntry or the upcoming tableWidget.
+"
+!
+examples
+"
Example use (in a ListView):
|listView tabSpec entry|
@@ -62,8 +86,99 @@
listView at:3 put:entry.
listView open
- tabSpec widths: #(2 0.3 2 1 0.7 0.5 1).
- " name type mode owner group size type"
+
+ defining field positions in millimeter :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#mm.
+ tabSpec positions:#(0 10 20 40).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
+
+ defining field widths in millimeter :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#mm.
+ tabSpec widths:#(10 10 20 10).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
+
+ defining field widths in pixels :
+
+ |listView tabSpec entry|
+
+ listView := ListView new.
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#pixel.
+ tabSpec widths:#(50 30 30 50).
+ tabSpec align: #left.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'1';
+ colAt:2 put:'2';
+ colAt:3 put:'3';
+ colAt:4 put:'4'.
+
+ listView at:1 put:entry.
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:'aa';
+ colAt:2 put:'bb';
+ colAt:3 put:'cc';
+ colAt:4 put:'dd'.
+
+ listView at:2 put:entry.
+
+ listView open
"
! !
@@ -98,6 +213,20 @@
^ 1.
!
+typeOfTab:index
+ "return the type of the tab at position index."
+
+ tabPositions isNil ifTrue:[^ #left].
+ tabTypes notNil ifTrue:[
+ (tabTypes isMemberOf:Symbol) ifTrue:[
+ ^ tabTypes
+ ].
+ ^ tabTypes at:index.
+ ].
+ "default is left"
+ ^ #left
+!
+
positionOfTab:index on:aGC
"return the position (in device units) of the tab at index"
@@ -119,15 +248,7 @@
pos := self positionOfTab:index on:aGC.
pos isNil ifTrue:[^ nil].
- tabTypes notNil ifTrue:[
- (tabTypes isMemberOf:Symbol) ifTrue:[
- type := tabTypes
- ] ifFalse:[
- type := tabTypes at:(index).
- ].
- ] ifFalse:[
- type := #left
- ].
+ type := self typeOfTab:index.
type == #right ifTrue:[
^ pos - (aGC font widthOf:aString).
@@ -145,11 +266,16 @@
].
"default is left"
^ pos
-
! !
!TabulatorSpecification methodsFor:'accessing'!
+size
+ "return the number of tabs in this spec"
+
+ ^ tabPositions size
+!
+
unit:aSymbol
"set the unit.
allowed are: #inch, #mm, #cm, #pixel and #col"
@@ -190,6 +316,25 @@
^ tabTypes
!
+widths
+ "return a width-vector"
+
+ |prev|
+
+ prev := 0.
+ ^ tabPositions collect:[:p | |w| w := p - prev. prev := p. w].
+
+ "
+ |spec|
+
+ spec := TabulatorSpecification new.
+ spec unit:#inch.
+ spec positions:#(0 1 2.5 3.5 4 5 ).
+ spec align: #(#left #left #right #right #center #decimal ).
+ spec widths
+ "
+!
+
widths:fieldWidths
"set the position-vector from a vector of field widths"
--- a/TextRuler.st Thu Nov 17 15:42:58 1994 +0100
+++ b/TextRuler.st Mon Nov 21 17:49:32 1994 +0100
@@ -1,130 +1,368 @@
-"
- COPYRIGHT (c) 1991 by Claus Gittinger
- All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice. This software may not
- be provided or otherwise made available to, or used by, any
- other person. No title to or ownership of the software is
- hereby transferred.
-"
+'From Smalltalk/X, Version:2.10.4 on 18-nov-1994 at 16:11:48'!
Ruler subclass:#TextRuler
- instanceVariableNames:'leftMargin rightMargin tabSpec moving'
- classVariableNames:'LeftAlignForm RightAlignForm
- AlignForm CenterForm LeftMarginForm
- RightMarginForm LeftTabForm RightTabForm
- CenterTabForm DecimalTabForm'
- poolDictionaries:''
- category:'Views-Interactors'
+ instanceVariableNames:'leftMargin rightMargin spec moving settingTab'
+ classVariableNames:'LeftAlignForm RightAlignForm AlignForm CenterForm LeftMarginForm
+ RightMarginForm LeftTabForm RightTabForm CenterTabForm
+ DecimalTabForm'
+ poolDictionaries:''
+ category:'Views-Interactors'
!
TextRuler comment:'
COPYRIGHT (c) 1991 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
a Ruler for page layout showing tabs., margins etc.
-$Header: /cvs/stx/stx/libwidg2/TextRuler.st,v 1.7 1994-08-23 23:44:32 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/TextRuler.st,v 1.8 1994-11-21 16:48:42 claus Exp $
written oct 91 by claus
'!
+!TextRuler class methodsFor:'documentation'!
+
+documentation
+"
+ This is a special ruler built for text processing
+ applications. Currently, it is not used in the system.
+ It allows setting of margins, tabs and text-layout.
+
+ TextRuler new open
+"
+
+! !
+
!TextRuler class methodsFor:'defaults'!
-alignForm
- "return the form displayed in the align-button"
+rightMarginForm
+ "return the form displayed for the right margin marker"
+
+ RightMarginForm isNil ifTrue:[
+ RightMarginForm := Form fromFile:'rightMarg.xbm' resolution:100
+ ].
+ ^ RightMarginForm
+!
+
+leftMarginForm
+ "return the form displayed for the left margin marker"
- AlignForm isNil ifTrue:[
- AlignForm := Form fromFile:'align.xbm' resolution:100
+ LeftMarginForm isNil ifTrue:[
+ LeftMarginForm := Form fromFile:'leftMargin.xbm' resolution:100
].
- ^ AlignForm
+ ^ LeftMarginForm
+!
+
+rightAlignForm
+ "return the form displayed in the rightAlign-button"
+
+ RightAlignForm isNil ifTrue:[
+ RightAlignForm := Form fromFile:'rightAlign.xbm' resolution:100
+ ].
+ ^ RightAlignForm
+!
+
+leftTabForm
+ "return the form displayed in the leftTab-button"
+
+ LeftTabForm isNil ifTrue:[
+ LeftTabForm := Form fromFile:'leftTab.xbm' resolution:100
+ ].
+ ^ LeftTabForm
!
centerForm
"return the form displayed in the center-button"
CenterForm isNil ifTrue:[
- CenterForm := Form fromFile:'center.xbm' resolution:100
+ CenterForm := Form fromFile:'center.xbm' resolution:100
].
^ CenterForm
!
+alignForm
+ "return the form displayed in the align-button"
+
+ AlignForm isNil ifTrue:[
+ AlignForm := Form fromFile:'align.xbm' resolution:100
+ ].
+ ^ AlignForm
+!
+
+rightTabForm
+ "return the form displayed in the rightTab-button"
+
+ RightTabForm isNil ifTrue:[
+ RightTabForm := Form fromFile:'rightTab.xbm' resolution:100
+ ].
+ ^ RightTabForm
+!
+
leftAlignForm
"return the form displayed in the leftAlign-button"
LeftAlignForm isNil ifTrue:[
- LeftAlignForm := Form fromFile:'leftAlign.xbm' resolution:100
+ LeftAlignForm := Form fromFile:'leftAlign.xbm' resolution:100
].
^ LeftAlignForm
!
-rightAlignForm
- "return the form displayed in the rightAlign-button"
-
- RightAlignForm isNil ifTrue:[
- RightAlignForm := Form fromFile:'rightAlign.xbm' resolution:100
- ].
- ^ RightAlignForm
-!
-
-rightTabForm
- "return the form displayed in the rightTab-button"
+decimalTabForm
+ "return the form displayed in the decimalTab-button"
- RightTabForm isNil ifTrue:[
- RightTabForm := Form fromFile:'rightTab.xbm' resolution:100
+ DecimalTabForm isNil ifTrue:[
+ DecimalTabForm := Form fromFile:'decimalTab.xbm' resolution:100
].
- ^ RightTabForm
-!
-
-leftTabForm
- "return the form displayed in the leftTab-button"
-
- LeftTabForm isNil ifTrue:[
- LeftTabForm := Form fromFile:'leftTab.xbm' resolution:100
- ].
- ^ LeftTabForm
+ ^ DecimalTabForm
!
centerTabForm
"return the form displayed in the centerTab-button"
CenterTabForm isNil ifTrue:[
- CenterTabForm := Form fromFile:'centerTab.xbm' resolution:100
+ CenterTabForm := Form fromFile:'centerTab.xbm' resolution:100
].
^ CenterTabForm
+! !
+
+!TextRuler methodsFor:'accessing'!
+
+paragraphSpecification:aSpec
+ spec := aSpec
+! !
+
+!TextRuler methodsFor:'redrawing'!
+
+redraw
+ "redraw margin & tab marks"
+
+ |x top form tab type tabStops tabAlign viewOrigin orgX orgY|
+
+ super redraw.
+
+ viewOrigin := self viewOrigin.
+ orgX := viewOrigin x.
+ orgY := viewOrigin y.
+
+ self paint:fgColor.
+
+ top := height - (font height) - (font ascent).
+
+ x := (self inchToPixel:leftMargin) rounded.
+ form := self class leftMarginForm.
+ self displayForm:form
+ x:(x - (form width // 2) - orgX)
+ y:(top - form height - orgY).
+
+ x := (self inchToPixel:rightMargin) rounded.
+ form := self class rightMarginForm.
+ self displayForm:form
+ x:(x - (form width // 2) - orgX)
+ y:(top - form height - orgY).
+
+ spec notNil ifTrue:[
+ tabStops := spec positions.
+ tabAlign := spec align.
+ tabStops notNil ifTrue:[
+ 1 to:tabStops size do:[:tabNr |
+ tab := tabStops at:tabNr.
+ type := tabAlign at:tabNr.
+ x := (spec positionOfTab:tabNr on:self) rounded.
+ (type == #left) ifTrue:[
+ form := self class leftTabForm
+ ] ifFalse:[
+ (type == #right) ifTrue:[
+ form := self class rightTabForm
+ ] ifFalse:[
+ (type == #center) ifTrue:[
+ form := self class centerTabForm
+ ] ifFalse:[
+ (type == #decimal) ifTrue:[
+ form := self class decimalTabForm
+ ]
+ ]
+ ]
+ ].
+ self displayForm:form
+ x:(x - (form width // 2) - orgX)
+ y:(top - form height - orgY)
+ ]
+ ]
+ ]
!
+clearMargin:which
+ "clear margin"
-decimalTabForm
- "return the form displayed in the decimalTab-button"
+ |this other otherX otherX2 x x2 top form symOther viewOrigin|
+
+ self paint:viewBackground.
+
+ top := height - (font height) - (font ascent).
- DecimalTabForm isNil ifTrue:[
- DecimalTabForm := Form fromFile:'decimalTab.xbm' resolution:100
+ (which == #left) ifTrue:[
+ this := leftMargin.
+ other := rightMargin. symOther := #right.
+ form := self class leftMarginForm
+ ].
+ (which == #right) ifTrue:[
+ this := rightMargin.
+ other := leftMargin. symOther := #left.
+ form := self class rightMarginForm
].
- ^ DecimalTabForm
+
+ x := (self inchToPixel:this) rounded - (form width // 2).
+ viewOrigin := self viewOrigin.
+ self displayForm:form
+ x:x + viewOrigin x
+ y:(top - form height - viewOrigin y).
+
+ "
+ if it covers any other, redraw them
+ "
+ x2 := x + form width.
+ otherX := (self inchToPixel:other) rounded - (form width // 2).
+ otherX2 := otherX + form width.
+
+ otherX > x2 ifFalse:[
+ otherX2 < x ifFalse:[
+ self drawMargin:symOther
+ ]
+ ].
!
-leftMarginForm
- "return the form displayed for the left margin marker"
+drawMargin:which
+ "clear margin"
+
+ |x top form viewOrigin|
+
+ self paint:fgColor.
+
+ top := height - (font height) - (font ascent).
- LeftMarginForm isNil ifTrue:[
- LeftMarginForm := Form fromFile:'leftMargin.xbm' resolution:100
+ (which == #left) ifTrue:[
+ x := (self inchToPixel:leftMargin) rounded.
+ form := self class leftMarginForm
+ ].
+ (which == #right) ifTrue:[
+ x := (self inchToPixel:rightMargin) rounded.
+ form := self class rightMarginForm
].
- ^ LeftMarginForm
+
+ viewOrigin := self viewOrigin.
+ self displayForm:form
+ x:(x - (form width // 2) - viewOrigin x)
+ y:(top - form height - viewOrigin y).
+
+! !
+
+!TextRuler methodsFor:'user interaction'!
+
+buttonRelease:button x:x y:y
+ "position a tab or start moving a ruler"
+
+ moving := nil
!
-rightMarginForm
- "return the form displayed for the right margin marker"
+buttonPress:button x:pX y:y
+ "position a tab or start moving a ruler"
+
+ |mpos x|
+
+ ((button == #select) or:[button == 1]) ifFalse:[
+ ^ super buttonPress:button x:pX y:y
+ ].
+
+ x := pX + self viewOrigin x.
+ settingTab notNil ifTrue:[
+ self setTabX:x.
+ settingTab := nil.
+ ^ self
+ ].
+
+ mpos := self inchToPixel:leftMargin.
+ (((mpos - 4) <= x) and:[x <= (mpos + 4)]) ifTrue:[
+ "start moving left margin"
+ moving := #left.
+ ^ self
+ ].
+ mpos := self inchToPixel:rightMargin.
+ (((mpos - 4) <= x) and:[x <= (mpos + 4)]) ifTrue:[
+ "start moving right margin"
+ moving := #right.
+ ^ self
+ ].
+
+ ^ self
+!
+
+buttonMotion:state x:x y:y
+ "position a tab or start moving a ruler"
+
+ |mpos|
- RightMarginForm isNil ifTrue:[
- RightMarginForm := Form fromFile:'rightMarg.xbm' resolution:100
- ].
- ^ RightMarginForm
+ moving notNil ifTrue:[
+ self clearMargin:moving.
+ mpos := self pixelToInch:x + self viewOrigin x.
+ (mpos < 0) ifTrue:[
+ mpos := 0
+ ].
+ (mpos > paperWidth) ifTrue:[
+ mpos := paperWidth
+ ].
+ (moving == #left) ifTrue:[
+ leftMargin := mpos
+ ].
+ (moving == #right) ifTrue:[
+ rightMargin := mpos
+ ].
+ self drawMargin:moving
+ ]
+!
+
+leftAlign
+ ^ self
+!
+
+rightAlign
+ ^ self
+!
+
+leftTab
+ settingTab := #left.
+
+!
+
+align
+ ^ self
+!
+
+center
+ ^ self
+!
+
+centerTab
+ settingTab := #center.
+!
+
+rightTab
+ settingTab := #right.
+
+!
+
+decimalTab
+ settingTab := #decimal.
+
! !
!TextRuler methodsFor:'initializing'!
+initEvents
+ super initEvents.
+ self enableButtonEvents.
+ self enableButtonMotionEvents
+
+!
+
initialize
|leftAlignToggle alignToggle centerToggle rightAlignToggle
leftTabButton centerTabButton rightTabButton decimalTabButton
@@ -137,251 +375,59 @@
h := self class leftAlignForm height.
panel1 := HorizontalPanelView
- origin:(0.0 @ 0.0)
- extent:[(width // 3) @ (h*2) "(height - scaleHeight)"]
- in:self.
+ origin:(0.0 @ 0.0)
+ extent:[(width // 3 * 2) @ (h*2)]
+ in:self.
panel1 borderWidth:0.
- panel1 layout:#left.
-
- panel2 := HorizontalPanelView
- origin:[(width // 3) @ margin]
- extent:[(width // 3) @ (h*2) "(height - scaleHeight)"]
- in:self.
- panel2 borderWidth:0.
- panel2 layout:#center.
+ panel1 layout:#leftSpace.
panel3 := HorizontalPanelView
- origin:[(width // 3 * 2) @ margin]
- extent:[((width // 3)-margin) @ (h*2) "(height - scaleHeight)"]
- in:self.
+ origin:[(width // 3 * 2) @ margin]
+ extent:[((width // 3)-margin) @ (h*2) "(height - scaleHeight)"]
+ in:self.
panel3 borderWidth:0.
panel3 layout:#right.
leftAlignToggle := RadioButton form:(self class leftAlignForm)
- action:[self leftAlign]
- in:panel1.
+ action:[self leftAlign]
+ in:panel1.
alignToggle := RadioButton form:(self class alignForm)
- action:[self align]
- in:panel1.
+ action:[self align]
+ in:panel1.
centerToggle := RadioButton form:(self class centerForm)
- action:[self center]
- in:panel1.
+ action:[self center]
+ in:panel1.
rightAlignToggle := RadioButton form:(self class rightAlignForm)
- action:[self rightAlign]
- in:panel1.
+ action:[self rightAlign]
+ in:panel1.
group := RadioButtonGroup new.
group add:leftAlignToggle.
group add:alignToggle.
group add:centerToggle.
group add:rightAlignToggle.
+ "separator"
+ (View in:panel1) extent:(50 @ 2); borderWidth:0; level:0.
+
leftTabButton := Button form:(self class leftTabForm)
- action:[self leftTab]
- in:panel2.
+ action:[self leftTab]
+ in:panel1.
centerTabButton := Button form:(self class centerTabForm)
- action:[self centerTab]
- in:panel2.
+ action:[self centerTab]
+ in:panel1.
rightTabButton := Button form:(self class rightTabForm)
- action:[self rightTab]
- in:panel2.
+ action:[self rightTab]
+ in:panel1.
decimalTabButton := Button form:(self class decimalTabForm)
- action:[self decimalTab]
- in:panel2.
+ action:[self decimalTab]
+ in:panel1.
- lineSpacingField := EditField in:panel3.
+"/ lineSpacingField := EditField in:panel3.
- leftMargin := 0.25.
- rightMargin := 8.25
-
- "TextRuler new realize"
-!
+ leftMargin := 0.0.
+ rightMargin := 8.5
-initEvents
- super initEvents.
- self enableButtonEvents.
- self enableButtonMotionEvents
-
+ "TextRuler new open"
! !
-!TextRuler methodsFor:'user interaction'!
-
-leftAlign
- ^ self
-!
-
-rightAlign
- ^ self
-!
-
-align
- ^ self
-!
-
-center
- ^ self
-!
-
-leftTab
- ^ self
-!
-
-rightTab
- ^ self
-!
-
-centerTab
- ^ self
-!
-
-decimalTab
- ^ self
-!
-
-buttonPress:button x:x y:y
- "position a tab or start moving a ruler"
-
- |mpos|
-
- mpos := self inchToPixel:leftMargin.
- (((mpos - 4) <= x) and:[x <= (mpos + 4)]) ifTrue:[
- "start moving left margin"
- moving := #left.
- ^ self
- ].
- mpos := self inchToPixel:rightMargin.
- (((mpos - 4) <= x) and:[x <= (mpos + 4)]) ifTrue:[
- "start moving right margin"
- moving := #right.
- ^ self
- ].
-
- ^ self
-!
-
-buttonMotion:state x:x y:y
- "position a tab or start moving a ruler"
-
- |mpos|
-
- moving notNil ifTrue:[
- self clearMargin:moving.
- mpos := self pixelToInch:x.
- (mpos < 0) ifTrue:[
- mpos := 0
- ].
- (mpos > paperWidth) ifTrue:[
- mpos := paperWidth
- ].
- (moving == #left) ifTrue:[
- leftMargin := mpos
- ].
- (moving == #right) ifTrue:[
- rightMargin := mpos
- ].
- self drawMargin:moving
- ]
-!
-
-buttonRelease:button x:x y:y
- "position a tab or start moving a ruler"
-
- moving := nil
-! !
-
-!TextRuler methodsFor:'redrawing'!
-
-clearMargin:which
- "clear margin"
-
- |x top form|
-
- self paint:viewBackground.
- self background:viewBackground.
-
- top := height - (font height) - (font ascent).
-
- (which == #left) ifTrue:[
- x := (self inchToPixel:leftMargin) rounded.
- form := self class leftMarginForm
- ].
- (which == #right) ifTrue:[
- x := (self inchToPixel:rightMargin) rounded.
- form := self class rightMarginForm
- ].
-
- self displayOpaqueForm:form x:(x - (form width // 2))
-!
-
-drawMargin:which
- "clear margin"
-
- |x top form|
-
- self paint:fgColor.
- self background:viewBackground.
-
- top := height - (font height) - (font ascent).
-
- (which == #left) ifTrue:[
- x := (self inchToPixel:leftMargin) rounded.
- form := self class leftMarginForm
- ].
- (which == #right) ifTrue:[
- x := (self inchToPixel:rightMargin) rounded.
- form := self class rightMarginForm
- ].
-
- self displayOpaqueForm:form x:(x - (form width // 2))
-!
-
-redraw
- "redraw margin & tab marks"
-
- |x top form tab type tabStops tabAlign|
-
- super redraw.
-
- self paint:fgColor.
- self background:viewBackground.
-
- top := height - (font height) - (font ascent).
-
- x := (self inchToPixel:leftMargin) rounded.
- form := self class leftMarginForm.
- self displayOpaqueForm:form x:(x - (form width // 2))
- y:(top - form height).
- x := (self inchToPixel:rightMargin) rounded.
- form := self class rightMarginForm.
- self displayOpaqueForm:form
- x:(x - (form width // 2))
- y:(top - form height).
-
- tabStops := tabSpec positions.
- tabAlign := tabSpec align.
- tabStops notNil ifTrue:[
- 1 to:tabStops size do:[:tabNr |
- tab := tabStops at:tabNr.
- type := tabAlign at:tabNr.
- x := (tabSpec positionOfTab:tabNr on:self) rounded.
- (type == #left) ifTrue:[
- form := self class leftTabForm
- ] ifFalse:[
- (type == #right) ifTrue:[
- form := self class rightTabForm
- ] ifFalse:[
- (type == #center) ifTrue:[
- form := self class centerTabForm
- ] ifFalse:[
- (type == #decimal) ifTrue:[
- form := self class decimalTabForm
- ]
- ]
- ]
- ].
- self displayOpaqueForm:form
- x:(x - (form width // 2))
- y:(top - form height)
- ]
- ]
-! !
--- a/VRuler.st Thu Nov 17 15:42:58 1994 +0100
+++ b/VRuler.st Mon Nov 21 17:49:32 1994 +0100
@@ -23,7 +23,7 @@
a VerticalRuler for page layout.
-$Header: /cvs/stx/stx/libwidg2/Attic/VRuler.st,v 1.1 1994-11-17 14:42:58 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/Attic/VRuler.st,v 1.2 1994-11-21 16:48:22 claus Exp $
written oct 91 by claus
'!
@@ -51,14 +51,13 @@
!VerticalRuler methodsFor:'redrawing'!
redraw
- "redraw scale"
+ "redraw the scale"
|y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX
left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight|
shown ifFalse:[^ self].
-"/ self fill:viewBackground.
self clear.
yOrigin := self viewOrigin y.
@@ -95,18 +94,21 @@
y := (pixelPerMM * pos - yOrigin) rounded.
[(y < height) and:[pos <= paperHeightMM]] whileTrue:[
- (mod == 1) ifTrue:[
- self displayLineFromX:left y:y
- toX:(left + shortLen) y:y
- ] ifFalse:[
+ |l|
+
+ l := shortLen.
+ (mod ~~ 1) ifTrue:[
y < labelBot ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + longLen) y:y.
- self displayString:(pos // 10) printString
- x:charX
- y:(y + marg + fontHeight)
+ l := longLen
]
].
+ self displayLineFromX:left y:y toX:(left + l) y:y.
+
+ (mod ~~ 1 and:[y >= labelBot]) ifTrue:[
+ self displayString:(pos // 10) printString
+ x:charX
+ y:(y + marg + fontHeight)
+ ].
mod := (mod + 1) \\ 2.
pos := pos + 5.
y := (pixelPerMM * pos - yOrigin) rounded
@@ -124,22 +126,26 @@
y := (pixelPerInch * pos - yOrigin) rounded.
veryShortLen := longLen // 4.
[(y < height) and:[pos <= paperHeight]] whileTrue:[
+ |l|
+
+ l := shortLen.
(mod == 0) ifTrue:[
y < labelBot ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + longLen) y:y.
+ l := longLen.
+ ]
+ ] ifFalse:[
+ (mod == 2) ifFalse:[
+ l := veryShortLen
+ ]
+ ].
+ self displayLineFromX:left y:y toX:(left + l) y:y.
+
+ (mod == 0) ifTrue:[
+ y < labelBot ifFalse:[
self displayString:pos asInteger printString
x:charX
y:(y + marg + fontHeight)
]
- ] ifFalse:[
- (mod == 2) ifTrue:[
- self displayLineFromX:left y:y
- toX:(left + shortLen) y:y
- ] ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + veryShortLen) y:y
- ]
].
mod := (mod + 1) \\ 4.
pos := pos + 0.25.
--- a/VerticalRuler.st Thu Nov 17 15:42:58 1994 +0100
+++ b/VerticalRuler.st Mon Nov 21 17:49:32 1994 +0100
@@ -23,7 +23,7 @@
a VerticalRuler for page layout.
-$Header: /cvs/stx/stx/libwidg2/VerticalRuler.st,v 1.1 1994-11-17 14:42:58 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/VerticalRuler.st,v 1.2 1994-11-21 16:48:22 claus Exp $
written oct 91 by claus
'!
@@ -51,14 +51,13 @@
!VerticalRuler methodsFor:'redrawing'!
redraw
- "redraw scale"
+ "redraw the scale"
|y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX
left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight|
shown ifFalse:[^ self].
-"/ self fill:viewBackground.
self clear.
yOrigin := self viewOrigin y.
@@ -95,18 +94,21 @@
y := (pixelPerMM * pos - yOrigin) rounded.
[(y < height) and:[pos <= paperHeightMM]] whileTrue:[
- (mod == 1) ifTrue:[
- self displayLineFromX:left y:y
- toX:(left + shortLen) y:y
- ] ifFalse:[
+ |l|
+
+ l := shortLen.
+ (mod ~~ 1) ifTrue:[
y < labelBot ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + longLen) y:y.
- self displayString:(pos // 10) printString
- x:charX
- y:(y + marg + fontHeight)
+ l := longLen
]
].
+ self displayLineFromX:left y:y toX:(left + l) y:y.
+
+ (mod ~~ 1 and:[y >= labelBot]) ifTrue:[
+ self displayString:(pos // 10) printString
+ x:charX
+ y:(y + marg + fontHeight)
+ ].
mod := (mod + 1) \\ 2.
pos := pos + 5.
y := (pixelPerMM * pos - yOrigin) rounded
@@ -124,22 +126,26 @@
y := (pixelPerInch * pos - yOrigin) rounded.
veryShortLen := longLen // 4.
[(y < height) and:[pos <= paperHeight]] whileTrue:[
+ |l|
+
+ l := shortLen.
(mod == 0) ifTrue:[
y < labelBot ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + longLen) y:y.
+ l := longLen.
+ ]
+ ] ifFalse:[
+ (mod == 2) ifFalse:[
+ l := veryShortLen
+ ]
+ ].
+ self displayLineFromX:left y:y toX:(left + l) y:y.
+
+ (mod == 0) ifTrue:[
+ y < labelBot ifFalse:[
self displayString:pos asInteger printString
x:charX
y:(y + marg + fontHeight)
]
- ] ifFalse:[
- (mod == 2) ifTrue:[
- self displayLineFromX:left y:y
- toX:(left + shortLen) y:y
- ] ifFalse:[
- self displayLineFromX:left y:y
- toX:(left + veryShortLen) y:y
- ]
].
mod := (mod + 1) \\ 4.
pos := pos + 0.25.