213 |
215 |
214 new |
216 new |
215 "create a new empty Text instance. |
217 "create a new empty Text instance. |
216 Redefined for string-protocol compatibility" |
218 Redefined for string-protocol compatibility" |
217 |
219 |
218 ^ super new string:(String new) emphasis:nil |
220 ^ super new string:'' emphasis:nil |
219 |
221 |
220 "Text new" |
222 "Text new" |
221 |
223 |
222 "Modified: 12.5.1996 / 17:05:17 / cg" |
224 "Modified: 12.5.1996 / 17:05:17 / cg" |
223 "Modified: 31.12.1996 / 12:39:57 / stefan" |
225 "Modified: 31.12.1996 / 12:39:57 / stefan" |
723 "Created: 22.10.1996 / 21:01:16 / cg" |
725 "Created: 22.10.1996 / 21:01:16 / cg" |
724 ! |
726 ! |
725 |
727 |
726 postCopy |
728 postCopy |
727 string := string copy. |
729 string := string copy. |
728 runs := runs copy |
730 runs := runs copy. |
|
731 |
|
732 " |
|
733 |t| |
|
734 |
|
735 t := 'hello' emphasizeAllWith:#bold. |
|
736 t inspect. t copy inspect. |
|
737 t emphasisAllRemove:#bold. |
|
738 " |
729 ! ! |
739 ! ! |
730 |
740 |
731 !Text methodsFor:'displaying'! |
741 !Text methodsFor:'displaying'! |
732 |
742 |
733 displayOn:aGC x:x0 y:y opaque:opaqueWanted |
743 displayOn:aGC x:x0 y:y opaque:opaqueWanted |
751 device := aGC graphicsDevice. |
761 device := aGC graphicsDevice. |
752 |
762 |
753 pos := 1. |
763 pos := 1. |
754 x := x0. |
764 x := x0. |
755 bold := italic := underline := underwave := strikeout := reverse := false. |
765 bold := italic := underline := underwave := strikeout := reverse := false. |
|
766 |
|
767 runs size > string size ifTrue:[ |
|
768 Transcript showCR:'inconsistent text: runs size > string size'. |
|
769 runs := runs copyTo:(string size) |
|
770 ]. |
756 |
771 |
757 runs runsDo:[:len :emphasis | |
772 runs runsDo:[:len :emphasis | |
758 wasItalic := italic. |
773 wasItalic := italic. |
759 color := savedPaint. |
774 color := savedPaint. |
760 bold := italic := underline := underwave := strikeout := reverse := false. |
775 bold := italic := underline := underwave := strikeout := reverse := false. |
935 ]. |
950 ]. |
936 |
951 |
937 aGC basicFont:savedFont. |
952 aGC basicFont:savedFont. |
938 aGC paint:savedPaint on:savedBgPaint. |
953 aGC paint:savedPaint on:savedBgPaint. |
939 |
954 |
|
955 pos < string size ifTrue:[ |
|
956 "/ draw rest |
|
957 aGC displayString:string from:pos to:string size x:x y:y. |
|
958 ]. |
|
959 |
940 "Created: / 12.5.1996 / 11:14:30 / cg" |
960 "Created: / 12.5.1996 / 11:14:30 / cg" |
941 "Modified: / 7.7.1999 / 00:08:12 / cg" |
961 "Modified: / 7.7.1999 / 00:08:12 / cg" |
942 ! ! |
962 ! ! |
943 |
963 |
944 !Text methodsFor:'emphasis'! |
964 !Text methodsFor:'emphasis'! |
1521 |
1541 |
1522 emphasisCollection:emphasisCollection |
1542 emphasisCollection:emphasisCollection |
1523 "set the string and emphasis collection. |
1543 "set the string and emphasis collection. |
1524 The emphasis collection contains per-character information." |
1544 The emphasis collection contains per-character information." |
1525 |
1545 |
1526 runs := emphasisCollection |
1546 runs := emphasisCollection. |
1527 |
1547 |
1528 "Created: / 7.4.1998 / 08:52:03 / cg" |
1548 "Created: / 7.4.1998 / 08:52:03 / cg" |
1529 ! |
1549 ! |
1530 |
1550 |
1531 runs |
1551 runs |
1532 ^ runs |
1552 ^ runs |
1533 ! |
1553 ! |
1534 |
1554 |
1535 setRuns:anArrayOrRunArray |
1555 setRuns:anArrayOrRunArray |
1536 runs := anArrayOrRunArray |
1556 runs := anArrayOrRunArray. |
1537 ! |
1557 ! |
1538 |
1558 |
1539 setString:aString setRuns:anArrayOrRunArray |
1559 setString:aString setRuns:anArrayOrRunArray |
1540 string := aString. |
1560 string := aString. |
1541 runs := anArrayOrRunArray |
1561 runs := anArrayOrRunArray. |
1542 ! |
1562 ! |
1543 |
1563 |
1544 string:aString emphasis:emphasis |
1564 string:aString emphasis:emphasis |
1545 "set the string and emphasis. The emphasis is applied to all characters." |
1565 "set the string and emphasis. The emphasis is applied to all characters." |
1546 |
1566 |
1547 string := aString string. |
1567 string := aString string. |
1548 runs := RunArray new:string size withAll:emphasis |
1568 runs := RunArray new:string size withAll:emphasis. |
1549 |
1569 |
1550 " |
1570 " |
1551 |t| |
1571 |t| |
1552 |
1572 |
1553 t := Text new string:'hello' emphasis:#bold. |
1573 t := Text new string:'hello' emphasis:#bold. |
1851 string := maxCharacter stringSpecies fromString:string. |
1871 string := maxCharacter stringSpecies fromString:string. |
1852 ]. |
1872 ]. |
1853 ]. |
1873 ]. |
1854 |
1874 |
1855 string replaceFrom:start to:stop with:aCollection startingAt:startIndex. |
1875 string replaceFrom:start to:stop with:aCollection startingAt:startIndex. |
1856 self emphasizeFrom:start to:stop with:nil |
1876 self emphasizeFrom:start to:stop with:nil. |
1857 |
1877 |
1858 " |
1878 " |
1859 ((Text string:'hello') allBold emphasisAt:2 put:#italic) |
1879 ((Text string:'hello') allBold emphasisAt:2 put:#italic) |
1860 replaceFrom:1 to:3 with:'HEL' startingAt:1 |
1880 replaceFrom:1 to:3 with:'HEL' startingAt:1 |
1861 |
1881 |