home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / perl5 / Gnome2 / Canvas.pod < prev    next >
Encoding:
Text File  |  2005-12-16  |  12.1 KB  |  618 lines

  1. =head1 NAME
  2.  
  3. Gnome2::Canvas -  A structured graphics canvas
  4.  
  5. =for position SYNOPSIS
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.   use strict;
  10.   use Gtk2 -init;
  11.   use Gnome2::Canvas;
  12.   my $window = Gtk2::Window->new;
  13.   my $scroller = Gtk2::ScrolledWindow->new;
  14.   my $canvas = Gnome2::Canvas->new;
  15.   $scroller->add ($canvas);
  16.   $window->add ($scroller);
  17.   $window->set_default_size (150, 150);
  18.   $canvas->set_scroll_region (0, 0, 200, 200);
  19.   $window->show_all;
  20.  
  21.   my $root = $canvas->root;
  22.   Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Text',
  23.                              x => 20,
  24.                              y => 15,
  25.                              fill_color => 'black',
  26.                              font => 'Sans 14',
  27.                              anchor => 'GTK_ANCHOR_NW',
  28.                              text => 'Hello, World!');
  29.   my $box = Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Rect',
  30.                                        x1 => 10, y1 => 5,
  31.                                        x2 => 150, y2 => 135,
  32.                                        fill_color => 'red',
  33.                                        outline_color => 'black');
  34.   $box->lower_to_bottom;
  35.   $box->signal_connect (event => sub {
  36.           my ($item, $event) = @_;
  37.           warn "event ".$event->type."\n";
  38.   });
  39.  
  40.   Gtk2->main;
  41.  
  42. =cut
  43.  
  44.  
  45.  
  46. =for position DESCRIPTION
  47.  
  48. =head1 DESCRIPTION
  49.  
  50. The Gnome Canvas is an engine for structured graphics that offers a
  51. rich imaging model, high-performance rendering, and a powerful,
  52. high level API.  It offers a choice of two rendering back-ends,
  53. one based on GDK for extremely fast display, and another based on
  54. Libart, a sophisticated, antialiased, alpha-compositing engine.
  55. This widget can be used for flexible display of graphics and for
  56. creating interactive user interface elements.
  57.  
  58. To create a new Gnome2::Canvas widget call C<< Gnome2::Canvas->new >> or
  59. C<< Gnome2::Canvas->new_aa >> for an anti-aliased mode canvas.
  60.  
  61. A Gnome2::Canvas contains one or more Gnome2::CanvasItem
  62. objects. Items consist of graphing elements like lines, ellipses,
  63. polygons, images, text, and curves.  These items are organized using
  64. Gnome2::CanvasGroup objects, which are themselves derived from
  65. Gnome2::CanvasItem.  Since a group is an item it can be contained within
  66. other groups, forming a tree of canvas items.  Certain operations, like
  67. translating and scaling, can be performed on all items in a group.
  68.  
  69. There is a special root group created by a Gnome2::Canvas.  This is the top
  70. level group under which all items in a canvas are contained.  The root group
  71. is available as C<< $canvas->root >>.
  72.  
  73. There are several different coordinate systems used by Gnome2::Canvas
  74. widgets.  The primary system is a logical, abstract coordinate space
  75. called world coordinates.  World coordinates are expressed as unbounded
  76. double floating point numbers.  When it comes to rendering to a screen
  77. the canvas pixel coordinate system (also referred to as just canvas
  78. coordinates) is used.  This system uses integers to specify screen
  79. pixel positions.  A user defined scaling factor and offset are used to
  80. convert between world coordinates and canvas coordinates.  Each item in
  81. a canvas has its own coordinate system called item coordinates.  This
  82. system is specified in world coordinates but they are relative to an
  83. item (0.0, 0.0 would be the top left corner of the item).  The final
  84. coordinate system of interest is window coordinates.  These are like
  85. canvas coordinates but are offsets from within a window a canvas is
  86. displayed in.  This last system is rarely used, but is useful when
  87. manually handling GDK events (such as drag and drop) which are 
  88. specified in window coordinates (the events processed by the canvas
  89. are already converted for you).
  90.  
  91. Along with different coordinate systems come methods to convert
  92. between them.  C<< $canvas->w2c >> converts world to canvas pixel
  93. coordinates and C<< canvas->c2w >> converts from canvas to
  94. world.  To get the affine transform matrix for converting
  95. from world coordinates to canvas coordinates call C<< $canvas->w2c_affine >>.
  96. C<< $canvas->window_to_world >> converts from window to world
  97. coordinates and C<< $canvas->world_to_window >> converts in the other
  98. direction.  There are no methods for converting between canvas and
  99. window coordinates, since this is just a matter of subtracting the
  100. canvas scrolling offset.  To convert to/from item coordinates use the
  101. methods defined for Gnome2::CanvasItem objects.
  102.  
  103. To set the canvas zoom factor (canvas pixels per world unit, the
  104. scaling factor) call C<< $canvas->set_pixels_per_unit >>; setting this
  105. to 1.0 will cause the two coordinate systems to correspond (e.g., [5, 6]
  106. in pixel units would be [5.0, 6.0] in world units).
  107.  
  108. Defining the scrollable area of a canvas widget is done by calling
  109. C<< $canvas->set_scroll_region >> and to get the current region
  110. C<< $canvas->get_scroll_region >> can be used.  If the window is
  111. larger than the canvas scrolling region it can optionally be centered
  112. in the window.  Use C<< $canvas->set_center_scroll_region >> to enable or
  113. disable this behavior.  To scroll to a particular canvas pixel coordinate
  114. use C<< $canvas->scroll_to >> (typically not used since scrollbars are
  115. usually set up to handle the scrolling), and to get the current canvas pixel
  116. scroll offset call C<< $canvas->get_scroll_offsets >>.
  117.  
  118. =cut
  119.  
  120.  
  121.  
  122. =head1 HIERARCHY
  123.  
  124.   Glib::Object
  125.   +----Gtk2::Object
  126.        +----Gtk2::Widget
  127.             +----Gtk2::Container
  128.                  +----Gtk2::Layout
  129.                       +----Gnome2::Canvas
  130.  
  131. =head1 INTERFACES
  132.  
  133.   Gtk2::Atk::ImplementorIface
  134.  
  135. =for object Gnome2::Canvas A structured graphics canvas
  136.  
  137. =cut
  138.  
  139.  
  140.  
  141.  
  142. =head1 METHODS
  143.  
  144. =head2 widget = Gnome2::Canvas-E<gt>B<new> 
  145.  
  146. =over
  147.  
  148. Create a new empty canvas in non-antialiased mode.
  149.  
  150. =back
  151.  
  152. =head2 widget = Gnome2::Canvas-E<gt>B<new_aa> 
  153.  
  154. =over
  155.  
  156. Create a new empty canvas in antialiased mode.
  157.  
  158. =back
  159.  
  160. =head2 boolean = $canvas->B<aa>
  161.  
  162. =over
  163.  
  164.  
  165. Returns true if I<$canvas> was created in anti-aliased mode.
  166.  
  167.  
  168. =back
  169.  
  170. =head2 ($bx1, $by1, $bx2, $by2) = Gnome2::Canvas->B<get_butt_points> ($x1, $y1, $x2, $y2, $width, $project)
  171.  
  172. =over
  173.  
  174. =over
  175.  
  176. =item * $x1 (double) 
  177.  
  178. =item * $y1 (double) 
  179.  
  180. =item * $x2 (double) 
  181.  
  182. =item * $y2 (double) 
  183.  
  184. =item * $width (double) 
  185.  
  186. =item * $project (integer) 
  187.  
  188. =back
  189.  
  190.  
  191.  
  192. =back
  193.  
  194. =head2 (wx, wy) = $canvas-E<gt>B<c2w> ($cx, $cy)
  195.  
  196. =over
  197.  
  198. =over
  199.  
  200. =item * $cx (integer) 
  201.  
  202. =item * $cy (integer) 
  203.  
  204. =back
  205.  
  206. =back
  207.  
  208. =head2 boolean = $canvas-E<gt>B<get_center_scroll_region> 
  209.  
  210. =over
  211.  
  212. =back
  213.  
  214. =head2 $canvas-E<gt>B<set_center_scroll_region> ($center_scroll_region)
  215.  
  216. =over
  217.  
  218. =over
  219.  
  220. =item * $center_scroll_region (boolean) 
  221.  
  222. =back
  223.  
  224. =back
  225.  
  226. =head2 list = $canvas-E<gt>B<get_color> ($spec)
  227.  
  228. =over
  229.  
  230. =over
  231.  
  232. =item * $spec (string) 
  233.  
  234. =back
  235.  
  236.  
  237. Returns an integer indicating the success of the color allocation and a
  238. GdkColor.
  239.  
  240.  
  241. =back
  242.  
  243. =head2 unsigned = $canvas-E<gt>B<get_color_pixel> ($rgba)
  244.  
  245. =over
  246.  
  247. =over
  248.  
  249. =item * $rgba (integer) 
  250.  
  251. =back
  252.  
  253. =back
  254.  
  255. =head2 rgbdither = $canvas-E<gt>B<get_dither> 
  256.  
  257. =over
  258.  
  259. =back
  260.  
  261. =head2 $canvas-E<gt>B<set_dither> ($dither)
  262.  
  263. =over
  264.  
  265. =over
  266.  
  267. =item * $dither (Gtk2::Gdk::RgbDither) 
  268.  
  269. =back
  270.  
  271. =back
  272.  
  273. =head2 item = $canvas-E<gt>B<get_item_at> ($x, $y)
  274.  
  275. =over
  276.  
  277. =over
  278.  
  279. =item * $x (double) 
  280.  
  281. =item * $y (double) 
  282.  
  283. =back
  284.  
  285. =back
  286.  
  287. =head2 ($mx1, $my1, $mx2, $my2) = Gnome2::Canvas->B<get_miter_points> ($x1, $y1, $x2, $y2, $x3, $y3, $width)
  288.  
  289. =over
  290.  
  291. =over
  292.  
  293. =item * $x1 (double) 
  294.  
  295. =item * $y1 (double) 
  296.  
  297. =item * $x2 (double) 
  298.  
  299. =item * $y2 (double) 
  300.  
  301. =item * $x3 (double) 
  302.  
  303. =item * $y3 (double) 
  304.  
  305. =item * $width (double) 
  306.  
  307. =back
  308.  
  309.  
  310.  
  311. =back
  312.  
  313. =head2 double = $canvas->B<get_pixels_per_unit>
  314.  
  315. =over
  316.  
  317. Fetch I<$canvas>' scale factor.
  318.  
  319. =back
  320.  
  321. =head2 $canvas-E<gt>B<set_pixels_per_unit> ($n)
  322.  
  323. =over
  324.  
  325. =over
  326.  
  327. =item * $n (double) 
  328.  
  329. =back
  330.  
  331.  
  332. Set the zooming factor of I<$canvas> by specifying the number of screen
  333. pixels that correspond to one canvas unit.
  334.  
  335.  
  336. =back
  337.  
  338. =head2 double = Gnome2::Canvas-E<gt>B<polygon_to_point> ($poly_ref, $x, $y)
  339.  
  340. =over
  341.  
  342. =over
  343.  
  344. =item * $poly_ref (arrayref) coordinate pairs that make up the polygon
  345.  
  346. =item * $x (double) 
  347.  
  348. =item * $y (double) 
  349.  
  350. =back
  351.  
  352. Return the distance from the point I<$x>,I<$y> to the polygon described by
  353. the vertices in I<$poly_ref>, or zero if the point is inside the polygon.
  354.  
  355. =back
  356.  
  357. =head2 $canvas-E<gt>B<request_redraw> ($x1, $y1, $x2, $y2)
  358.  
  359. =over
  360.  
  361. =over
  362.  
  363. =item * $x1 (integer) 
  364.  
  365. =item * $y1 (integer) 
  366.  
  367. =item * $x2 (integer) 
  368.  
  369. =item * $y2 (integer) 
  370.  
  371. =back
  372.  
  373. =back
  374.  
  375. =head2 group = $canvas-E<gt>B<root> 
  376.  
  377. =over
  378.  
  379. =back
  380.  
  381. =head2 (cx, cy) = $canvas-E<gt>B<get_scroll_offsets> 
  382.  
  383. =over
  384.  
  385. =back
  386.  
  387. =head2 (x1, y1, x2, y2) = $canvas-E<gt>B<get_scroll_region> 
  388.  
  389. =over
  390.  
  391. =back
  392.  
  393. =head2 $canvas-E<gt>B<set_scroll_region> ($x1, $y1, $x2, $y2)
  394.  
  395. =over
  396.  
  397. =over
  398.  
  399. =item * $x1 (double) 
  400.  
  401. =item * $y1 (double) 
  402.  
  403. =item * $x2 (double) 
  404.  
  405. =item * $y2 (double) 
  406.  
  407. =back
  408.  
  409. =back
  410.  
  411. =head2 $canvas-E<gt>B<scroll_to> ($cx, $cy)
  412.  
  413. =over
  414.  
  415. =over
  416.  
  417. =item * $cx (integer) 
  418.  
  419. =item * $cy (integer) 
  420.  
  421. =back
  422.  
  423. =back
  424.  
  425. =head2 $canvas-E<gt>B<set_stipple_origin> ($gc)
  426.  
  427. =over
  428.  
  429. =over
  430.  
  431. =item * $gc (Gtk2::Gdk::GC) 
  432.  
  433. =back
  434.  
  435. =back
  436.  
  437. =head2 $canvas-E<gt>B<update_now> 
  438.  
  439. =over
  440.  
  441. =back
  442.  
  443. =head2 (cx, cy) = $canvas-E<gt>B<w2c> ($wx, $wy)
  444.  
  445. =over
  446.  
  447. =over
  448.  
  449. =item * $wx (double) 
  450.  
  451. =item * $wy (double) 
  452.  
  453. =back
  454.  
  455. =back
  456.  
  457. =head2 $affine = $canvas->B<w2c_affine>
  458.  
  459. =over
  460.  
  461. =over
  462.  
  463. =back
  464.  
  465. Fetch the affine transform that converts from world coordinates to canvas
  466. pixel coordinates.
  467.  
  468. Note: This method was completely broken for all
  469. $Gnome2::Canvas::VERSION < 1.002.
  470.  
  471. =back
  472.  
  473. =head2 (cx, cy) = $canvas-E<gt>B<w2c_d> ($wx, $wy)
  474.  
  475. =over
  476.  
  477. =over
  478.  
  479. =item * $wx (double) 
  480.  
  481. =item * $wy (double) 
  482.  
  483. =back
  484.  
  485. =back
  486.  
  487. =head2 (worldx, worldy) = $canvas-E<gt>B<window_to_world> ($winx, $winy)
  488.  
  489. =over
  490.  
  491. =over
  492.  
  493. =item * $winx (double) 
  494.  
  495. =item * $winy (double) 
  496.  
  497. =back
  498.  
  499. =back
  500.  
  501. =head2 (winx, winy) = $canvas-E<gt>B<world_to_window> ($worldx, $worldy)
  502.  
  503. =over
  504.  
  505. =over
  506.  
  507. =item * $worldx (double) 
  508.  
  509. =item * $worldy (double) 
  510.  
  511. =back
  512.  
  513. =back
  514.  
  515.  
  516. =head1 PROPERTIES
  517.  
  518. =over
  519.  
  520. =item 'aa' (boolean : readable / writable / construct-only)
  521.  
  522. The antialiasing mode of the canvas.
  523.  
  524. =back
  525.  
  526.  
  527. =head1 SIGNALS
  528.  
  529. =over
  530.  
  531. =item B<draw-background> (Gnome2::Canvas, Gtk2::Gdk::Drawable, integer, integer, integer, integer)
  532.  
  533. =item B<render-background> (Gnome2::Canvas, gpointer)
  534.  
  535. =back
  536.  
  537.  
  538. =head1 ENUMS AND FLAGS
  539.  
  540. =head2 enum Gtk2::Gdk::RgbDither
  541.  
  542. =over
  543.  
  544. =item * 'none' / 'GDK_RGB_DITHER_NONE'
  545.  
  546. =item * 'normal' / 'GDK_RGB_DITHER_NORMAL'
  547.  
  548. =item * 'max' / 'GDK_RGB_DITHER_MAX'
  549.  
  550. =back
  551.  
  552.  
  553. =for position SEE_ALSO
  554.  
  555. =head1 SEE ALSO
  556.  
  557. Gnome2::Canvas::index(3pm) lists the generated Perl API reference PODs.
  558.  
  559. Frederico Mena Quintero's whitepaper on the GNOME Canvas:
  560. http://developer.gnome.org/doc/whitepapers/canvas/canvas.html
  561.  
  562. The real GnomeCanvas is implemented in a C library; the Gnome2::Canvas module
  563. allows a Perl developer to use the canvas like a normal gtk2-perl object.
  564. Like the Gtk2 module on which it depends, Gnome2::Canvas follows the C API of
  565. libgnomecanvas-2.0 as closely as possible while still being perlish.
  566. Thus, the C API reference remains the canonical documentation; the Perl
  567. reference documentation lists call signatures and argument types, and is
  568. meant to be used in conjunction with the C API reference.
  569.  
  570. GNOME Canvas Library Reference Manual
  571. http://developer.gnome.org/doc/API/2.0/libgnomecanvas/index.html
  572.  
  573. perl(1), Glib(3pm), Gtk2(3pm).
  574.  
  575. To discuss gtk2-perl, ask questions and flame/praise the authors,
  576. join gtk-perl-list@gnome.org at lists.gnome.org.
  577.  
  578. =cut
  579.  
  580.  
  581.  
  582. =for position COPYRIGHT
  583.  
  584. =head1 AUTHOR
  585.  
  586. muppet <scott at asofyet dot org>, with patches from
  587. Torsten Schoenfeld <kaffetisch at web dot de>.
  588.  
  589. The DESCRIPTION section of this page is adapted from the documentation of
  590. libgnomecanvas.
  591.  
  592. =head1 COPYRIGHT AND LICENSE
  593.  
  594. Copyright 2003-2004 by the gtk2-perl team.
  595.  
  596. This library is free software; you can redistribute it and/or
  597. modify it under the terms of the GNU Library General Public
  598. License as published by the Free Software Foundation; either
  599. version 2 of the License, or (at your option) any later version.
  600.  
  601. This library is distributed in the hope that it will be useful,
  602. but WITHOUT ANY WARRANTY; without even the implied warranty of
  603. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  604. Library General Public License for more details.
  605.  
  606. You should have received a copy of the GNU Library General Public
  607. License along with this library; if not, write to the 
  608. Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
  609. Boston, MA  02111-1307  USA.
  610.  
  611. =cut
  612.  
  613.  
  614.  
  615.  
  616. =cut
  617.  
  618.