home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _a0f7f3d933961aeb29c898347489ab38 < prev    next >
Encoding:
Text File  |  2004-06-01  |  7.9 KB  |  155 lines

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