home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / cp2b2x.exe / DATA.Z / style.tcl < prev    next >
Text File  |  1996-04-23  |  7KB  |  152 lines

  1. # style.tcl --
  2. #
  3. # This demonstration script creates a text widget that illustrates the
  4. # various display styles that may be set for tags.
  5. #
  6. # @(#) style.tcl 1.3 95/08/28 14:14:07
  7.  
  8. set w .style
  9. catch {destroy $w}
  10. toplevel $w
  11. wm title $w "Text Demonstration - Display Styles"
  12. wm iconname $w "style"
  13. positionWindow $w
  14.  
  15. frame $w.buttons
  16. pack  $w.buttons -side bottom -expand y -fill x -pady 2m
  17. button $w.buttons.dismiss -text Dismiss -command "destroy $w"
  18. button $w.buttons.code -text "See Code" -command "showCode $w"
  19. pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
  20.  
  21. text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
  22.     -width 70 -height 32 -wrap word
  23. scrollbar $w.scroll -command "$w.text yview"
  24. pack $w.scroll -side right -fill y
  25. pack $w.text -expand yes -fill both
  26.  
  27. # Set up display styles
  28.  
  29. $w.text tag configure bold -font -*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*
  30. $w.text tag configure big -font -*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*
  31. $w.text tag configure verybig -font \
  32.     -*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*
  33. if {[winfo depth $w] > 1} {
  34.     $w.text tag configure color1 -background #a0b7ce
  35.     $w.text tag configure color2 -foreground red
  36.     $w.text tag configure raised -relief raised -borderwidth 1
  37.     $w.text tag configure sunken -relief sunken -borderwidth 1
  38. } else {
  39.     $w.text tag configure color1 -background black -foreground white
  40.     $w.text tag configure color2 -background black -foreground white
  41.     $w.text tag configure raised -background white -relief raised \
  42.         -borderwidth 1
  43.     $w.text tag configure sunken -background white -relief sunken \
  44.         -borderwidth 1
  45. }
  46. $w.text tag configure bgstipple -background black -borderwidth 0 \
  47.     -bgstipple gray12
  48. $w.text tag configure fgstipple -fgstipple gray50
  49. $w.text tag configure underline -underline on
  50. $w.text tag configure overstrike -overstrike on
  51. $w.text tag configure right -justify right
  52. $w.text tag configure center -justify center
  53. $w.text tag configure super -offset 4p \
  54.     -font -Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*
  55. $w.text tag configure sub -offset -2p \
  56.     -font -Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*
  57. $w.text tag configure margins -lmargin1 12m -lmargin2 6m -rmargin 10m
  58. $w.text tag configure spacing -spacing1 10p -spacing2 2p \
  59.     -lmargin1 12m -lmargin2 6m -rmargin 10m
  60.  
  61. $w.text insert end {Text widgets like this one allow you to display information in a
  62. variety of styles.  Display styles are controlled using a mechanism
  63. called }
  64. $w.text insert end tags bold
  65. $w.text insert end {. Tags are just textual names that you can apply to one
  66. or more ranges of characters within a text widget.  You can configure
  67. tags with various display styles.  If you do this, then the tagged
  68. characters will be displayed with the styles you chose.  The
  69. available display styles are:
  70. }
  71. $w.text insert end "\n1. Font." big
  72. $w.text insert end "  You can choose any X font, "
  73. $w.text insert end large verybig
  74. $w.text insert end " or "
  75. $w.text insert end "small.\n"
  76. $w.text insert end "\n2. Color." big
  77. $w.text insert end "  You can change either the "
  78. $w.text insert end background color1
  79. $w.text insert end " or "
  80. $w.text insert end foreground color2
  81. $w.text insert end "\ncolor, or "
  82. $w.text insert end both {color1 color2}
  83. $w.text insert end ".\n"
  84. $w.text insert end "\n3. Stippling." big
  85. $w.text insert end "  You can cause either the "
  86. $w.text insert end background bgstipple
  87. $w.text insert end " or "
  88. $w.text insert end foreground fgstipple
  89. $w.text insert end {
  90. information to be drawn with a stipple fill instead of a solid fill.
  91. }
  92. $w.text insert end "\n4. Underlining." big
  93. $w.text insert end "  You can "
  94. $w.text insert end underline underline
  95. $w.text insert end " ranges of text.\n"
  96. $w.text insert end "\n5. Overstrikes." big
  97. $w.text insert end "  You can "
  98. $w.text insert end "draw lines through" overstrike
  99. $w.text insert end " ranges of text.\n"
  100. $w.text insert end "\n6. 3-D effects." big
  101. $w.text insert end {  You can arrange for the background to be drawn
  102. with a border that makes characters appear either }
  103. $w.text insert end raised raised
  104. $w.text insert end " or "
  105. $w.text insert end sunken sunken
  106. $w.text insert end ".\n"
  107. $w.text insert end "\n7. Justification." big
  108. $w.text insert end " You can arrange for lines to be displayed\n"
  109. $w.text insert end "left-justified,\n"
  110. $w.text insert end "right-justified, or\n" right
  111. $w.text insert end "centered.\n" center
  112. $w.text insert end "\n8. Superscripts and subscripts."  big
  113. $w.text insert end " You can control the vertical\n"
  114. $w.text insert end "position of text to generate superscript effects like 10"
  115. $w.text insert end "n" super
  116. $w.text insert end " or\nsubscript effects like X"
  117. $w.text insert end "i" sub
  118. $w.text insert end ".\n"
  119. $w.text insert end "\n9. Margins." big
  120. $w.text insert end " You can control the amount of extra space left"
  121. $w.text insert end " on\neach side of the text:\n"
  122. $w.text insert end "This paragraph is an example of the use of " margins
  123. $w.text insert end "margins.  It consists of a single line of text " margins
  124. $w.text insert end "that wraps around on the screen.  There are two " margins
  125. $w.text insert end "separate left margin values, one for the first " margins
  126. $w.text insert end "display line associated with the text line, " margins
  127. $w.text insert end "and one for the subsequent display lines, which " margins
  128. $w.text insert end "occur because of wrapping.  There is also a " margins
  129. $w.text insert end "separate specification for the right margin, " margins
  130. $w.text insert end "which is used to choose wrap points for lines.\n" margins
  131. $w.text insert end "\n10. Spacing." big
  132. $w.text insert end " You can control the spacing of lines with three\n"
  133. $w.text insert end "separate parameters.  \"Spacing1\" tells how much "
  134. $w.text insert end "extra space to leave\nabove a line, \"spacing3\" "
  135. $w.text insert end "tells how much space to leave below a line,\nand "
  136. $w.text insert end "if a text line wraps, \"spacing2\" tells how much "
  137. $w.text insert end "space to leave\nbetween the display lines that "
  138. $w.text insert end "make up the text line.\n"
  139. $w.text insert end "These indented paragraphs illustrate how spacing " spacing
  140. $w.text insert end "can be used.  Each paragraph is actually a " spacing
  141. $w.text insert end "single line in the text widget, which is " spacing
  142. $w.text insert end "word-wrapped by the widget.\n" spacing
  143. $w.text insert end "Spacing1 is set to 10 points for this text, " spacing
  144. $w.text insert end "which results in relatively large gaps between " spacing
  145. $w.text insert end "the paragraphs.  Spacing2 is set to 2 points, " spacing
  146. $w.text insert end "which results in just a bit of extra space " spacing
  147. $w.text insert end "within a pararaph.  Spacing3 isn't used " spacing
  148. $w.text insert end "in this example.\n" spacing
  149. $w.text insert end "To see where the space is, select ranges of " spacing
  150. $w.text insert end "text within these paragraphs.  The selection " spacing
  151. $w.text insert end "highlight will cover the extra space." spacing
  152.