equal
deleted
inserted
replaced
1203 initialText:aString selected:aBoolean |
1203 initialText:aString selected:aBoolean |
1204 "set the initialText and select it if aBoolean is true" |
1204 "set the initialText and select it if aBoolean is true" |
1205 |
1205 |
1206 |len s| |
1206 |len s| |
1207 |
1207 |
1208 leftOffset := 0. |
1208 viewOrigin := 0 @ viewOrigin y. |
|
1209 |
1209 (s := aString) notNil ifTrue:[ |
1210 (s := aString) notNil ifTrue:[ |
1210 s := s asString |
1211 s := s asString |
1211 ]. |
1212 ]. |
1212 self contents:s. |
1213 self contents:s. |
1213 aBoolean ifTrue:[ |
1214 aBoolean ifTrue:[ |
1214 (len := s size) ~~ 0 ifTrue:[ |
1215 (len := s size) ~~ 0 ifTrue:[ |
1215 self selectFromLine:1 col:1 toLine:1 col:len |
1216 self selectFromLine:1 col:1 toLine:1 col:len |
1216 ] |
1217 ] |
1217 ] |
1218 ] |
1218 ! |
1219 ! |
1219 |
1220 |
1220 list:someText |
1221 list:someText |
1221 "low level access to the underlying contents' list. |
1222 "low level access to the underlying contents' list. |
1582 newWidth := self widthOfContents. |
1583 newWidth := self widthOfContents. |
1583 |
1584 |
1584 " |
1585 " |
1585 should (& can) we resize ? |
1586 should (& can) we resize ? |
1586 " |
1587 " |
1587 xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
1588 xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
1588 (xCol > (width * (5/6))) ifTrue:[ |
1589 (xCol > (width * (5/6))) ifTrue:[ |
1589 self changedPreferredBounds:nil |
1590 self changedPreferredBounds:nil |
1590 ] ifFalse:[ |
1591 ] ifFalse:[ |
1591 newWidth < (width * (1/6)) ifTrue:[ |
1592 newWidth < (width * (1/6)) ifTrue:[ |
1592 self changedPreferredBounds:nil |
1593 self changedPreferredBounds:nil |
1603 ifTrue:[ |
1604 ifTrue:[ |
1604 ^ self |
1605 ^ self |
1605 ]. |
1606 ]. |
1606 ]. |
1607 ]. |
1607 |
1608 |
1608 xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
1609 xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
1609 (xCol > (width * (5/6))) ifTrue:[ |
1610 (xCol > (width * (5/6))) ifTrue:[ |
1610 newOffset := leftOffset + (width // 2). |
1611 newOffset := viewOrigin x + (width // 2). |
1611 ] ifFalse:[ |
1612 ] ifFalse:[ |
1612 (xCol < (width * (1/6))) ifTrue:[ |
1613 (xCol < (width * (1/6))) ifTrue:[ |
1613 newOffset := 0 max: leftOffset - (width // 2). |
1614 newOffset := 0 max: viewOrigin x - (width // 2). |
1614 ] ifFalse:[ |
1615 ] ifFalse:[ |
1615 newOffset := leftOffset |
1616 newOffset := viewOrigin x |
1616 ] |
1617 ] |
1617 ]. |
1618 ]. |
1618 newOffset ~~ leftOffset ifTrue:[ |
1619 newOffset ~~ viewOrigin x ifTrue:[ |
1619 self scrollHorizontalTo:newOffset. |
1620 self scrollHorizontalTo:newOffset. |
1620 ] |
1621 ] |
1621 ]. |
1622 ]. |
1622 |
1623 |
1623 "Modified: 6.3.1997 / 16:13:59 / cg" |
1624 "Modified: 6.3.1997 / 16:13:59 / cg" |
1626 sizeChanged:how |
1627 sizeChanged:how |
1627 "scroll to origin, if all fits" |
1628 "scroll to origin, if all fits" |
1628 |
1629 |
1629 |xCol| |
1630 |xCol| |
1630 |
1631 |
1631 leftOffset ~~ 0 ifTrue:[ |
1632 viewOrigin x ~~ 0 ifTrue:[ |
1632 xCol := self xOfCol:cursorCol inVisibleLine:cursorLine. |
1633 xCol := self xOfCol:cursorCol inVisibleLine:cursorLine. |
1633 (xCol < (width * (5/6))) ifTrue:[ |
1634 (xCol < (width * (5/6))) ifTrue:[ |
1634 self scrollHorizontalTo:0 |
1635 self scrollHorizontalTo:0 |
1635 ]. |
1636 ]. |
1636 ]. |
1637 ]. |
2004 !EditField methodsFor:'realization'! |
2005 !EditField methodsFor:'realization'! |
2005 |
2006 |
2006 realize |
2007 realize |
2007 "scroll back to beginning when realized" |
2008 "scroll back to beginning when realized" |
2008 |
2009 |
2009 leftOffset := 0. |
2010 viewOrigin := 0 @ viewOrigin y. |
2010 super realize |
2011 super realize |
2011 |
2012 |
2012 "Created: 24.7.1997 / 18:23:15 / cg" |
2013 "Created: 24.7.1997 / 18:23:15 / cg" |
2013 ! ! |
2014 ! ! |
2014 |
2015 |
2040 ]. |
2041 ]. |
2041 ]. |
2042 ]. |
2042 |
2043 |
2043 "/ new: |
2044 "/ new: |
2044 "/ care to make the most possible visible |
2045 "/ care to make the most possible visible |
2045 leftOffset > 0 ifTrue:[ |
2046 viewOrigin x > 0 ifTrue:[ |
2046 wText := self widthOfLine:lineNr. |
2047 wText := self widthOfLine:lineNr. |
2047 wText <= innerWidth ifTrue:[ |
2048 wText <= innerWidth ifTrue:[ |
2048 self scrollHorizontalTo:0 |
2049 self scrollHorizontalTo:0 |
2049 "/ ] ifFalse:[ |
|
2050 "/ wText < (leftOffset+self innerWidth) ifTrue:[ |
|
2051 "/ self scrollHorizontalTo:(wText - self innerWidth) |
|
2052 "/ ] |
|
2053 ] |
2050 ] |
2054 ] |
2051 ] |
2055 |
2052 |
2056 "Modified: 6.9.1995 / 13:57:53 / claus" |
2053 "Modified: 6.9.1995 / 13:57:53 / claus" |
2057 ! ! |
2054 ! ! |
2089 ! ! |
2086 ! ! |
2090 |
2087 |
2091 !EditField class methodsFor:'documentation'! |
2088 !EditField class methodsFor:'documentation'! |
2092 |
2089 |
2093 version |
2090 version |
2094 ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.154 2001-10-04 12:58:10 cg Exp $' |
2091 ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.155 2001-10-05 08:55:40 cg Exp $' |
2095 ! ! |
2092 ! ! |