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