home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libgnome2-canvas-perl / examples / canvas-rich-text.pm < prev    next >
Encoding:
Perl POD Document  |  2004-03-20  |  3.1 KB  |  115 lines

  1. package CanvasRichText;
  2. use strict;
  3. use utf8;
  4. use Gnome2::Canvas;
  5. use Glib qw(TRUE FALSE);
  6.  
  7. sub setup_text {
  8.     my $root = shift;
  9.     Gnome2::Canvas::Item->new ($root,
  10.                    'Gnome2::Canvas::Rect',
  11.                    "x1", -90.0,
  12.                    "y1", -50.0,
  13.                    "x2", 110.0,
  14.                    "y2", 50.0,
  15.                    "fill_color", "green",
  16.                    "outline_color", "green",
  17.                    );
  18.  
  19.     Gnome2::Canvas::Item->new ($root,
  20.                    'Gnome2::Canvas::RichText',
  21.                    "x", -90.0,
  22.                    "y", -50.0,
  23.                    "width", 200.0,
  24.                    "height", 100.0,
  25.                    "text", 
  26.                    "English is so boring because everyone uses it.\n"
  27.                    ."Here is something exciting:  "
  28.                    ."┘ê┘é╪» ╪¿╪»╪ú ╪½┘ä╪º╪½ ┘à┘å ╪ú┘â╪½╪▒ ╪º┘ä┘à╪ñ╪│╪│╪º╪¬ ╪¬┘é╪»┘à╪º ┘ü┘è ╪┤╪¿┘â╪⌐ ╪º┘â╪│┘è┘ê┘å ╪¿╪▒╪º┘à╪¼┘ç╪º ┘â┘à┘å╪╕┘à╪º╪¬ ┘ä╪º ╪¬╪│╪╣┘ë ┘ä┘ä╪▒╪¿╪¡╪î ╪½┘à ╪¬╪¡┘ê┘ä╪¬ ┘ü┘è ╪º┘ä╪│┘å┘ê╪º╪¬ ╪º┘ä╪«┘à╪│ ╪º┘ä┘à╪º╪╢┘è╪⌐ ╪Ñ┘ä┘ë ┘à╪ñ╪│╪│╪º╪¬ ┘à╪º┘ä┘è╪⌐ ┘à┘å╪╕┘à╪⌐╪î ┘ê╪¿╪º╪¬╪¬ ╪¼╪▓╪í╪º ┘à┘å ╪º┘ä┘å╪╕╪º┘à ╪º┘ä┘à╪º┘ä┘è ┘ü┘è ╪¿┘ä╪»╪º┘å┘ç╪º╪î ┘ê┘ä┘â┘å┘ç╪º ╪¬╪¬╪«╪╡╪╡ ┘ü┘è ╪«╪»┘à╪⌐ ┘é╪╖╪º╪╣ ╪º┘ä┘à╪┤╪▒┘ê╪╣╪º╪¬ ╪º┘ä╪╡╪║┘è╪▒╪⌐. ┘ê╪ú╪¡╪» ╪ú┘â╪½╪▒ ┘ç╪░┘ç ╪º┘ä┘à╪ñ╪│╪│╪º╪¬ ┘å╪¼╪º╪¡╪º ┘ç┘ê ┬╗╪¿╪º┘å┘â┘ê╪│┘ê┘ä┬½ ┘ü┘è ╪¿┘ê┘ä┘è┘ü┘è╪º.\n"
  29.                    ."And here is some more plain, boring English.",
  30.                    "grow_height", TRUE,
  31.                    );
  32.  
  33.     Gnome2::Canvas::Item->new ($root,
  34.                    'Gnome2::Canvas::Ellipse',
  35.                    "x1", -5.0,
  36.                    "y1", -5.0,
  37.                    "x2", 5.0,
  38.                    "y2", 5.0,
  39.                    "fill_color", "white",
  40.                    );
  41.  
  42.     Gnome2::Canvas::Item->new ($root,
  43.                    'Gnome2::Canvas::Rect',
  44.                    "x1", 100.0,
  45.                    "y1", -30.0,
  46.                    "x2", 200.0,
  47.                    "y2", 30.0,
  48.                    "fill_color", "yellow",
  49.                    "outline_color", "yellow",
  50.                    );
  51.  
  52.     Gnome2::Canvas::Item->new ($root,
  53.                    'Gnome2::Canvas::RichText',
  54.                    "x", 100.0,
  55.                    "y", -30.0,
  56.                    "width", 100.0,
  57.                    "height", 60.0,
  58.                    "text", "The quick brown fox jumped over the lazy dog.\n",
  59.                    "cursor_visible", TRUE,
  60.                    "cursor_blink", TRUE,
  61.                    "grow_height", TRUE, 
  62.                    );
  63.  
  64.     Gnome2::Canvas::Item->new ($root,
  65.                    'Gnome2::Canvas::Rect',
  66.                    "x1", 50.0,
  67.                    "y1", 70.0,
  68.                    "x2", 150.0,
  69.                    "y2", 100.0,
  70.                    "fill_color", "pink",
  71.                    "outline_color", "pink",
  72.                    );
  73.  
  74.     Gnome2::Canvas::Item->new ($root,
  75.                    'Gnome2::Canvas::RichText',
  76.                    "x", 50.0,
  77.                    "y", 70.0,
  78.                    "width", 100.0,
  79.                    "height", 30.0,
  80.                    "text", "This is a test.\nI enjoy tests a great deal\nThree lines!",
  81.                    "cursor_visible", TRUE,
  82.                    "cursor_blink", TRUE,
  83.                    );
  84. }
  85.  
  86. sub create {
  87.     my $vbox = Gtk2::VBox->new (FALSE, 4);
  88.     $vbox->set_border_width (4);
  89.     $vbox->show;
  90.  
  91.     my $alignment = Gtk2::Alignment->new (0.5, 0.5, 0.0, 0.0);
  92.     $vbox->pack_start ($alignment, TRUE, TRUE, 0);
  93.     $alignment->show;
  94.  
  95.     my $frame = Gtk2::Frame->new;
  96.     $frame->set_shadow_type ('in');
  97.     $alignment->add ($frame);
  98.     $frame->show;
  99.  
  100.     # Create the canvas and board
  101.  
  102.     my $canvas = Gnome2::Canvas->new;
  103.     $canvas->set_size_request (600, 450);
  104.     $frame->add ($canvas);
  105.     $canvas->show;
  106.  
  107.     my $root = $canvas->root;
  108.  
  109.     setup_text ($root);
  110.  
  111.     return $vbox;
  112. }
  113.  
  114. 1;
  115.