home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl5 / Gnome2 / Canvas.pod < prev    next >
Encoding:
Text File  |  2007-02-26  |  12.2 KB  |  619 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.   +----Glib::InitiallyUnowned
  126.        +----Gtk2::Object
  127.             +----Gtk2::Widget
  128.                  +----Gtk2::Container
  129.                       +----Gtk2::Layout
  130.                            +----Gnome2::Canvas
  131.  
  132. =head1 INTERFACES
  133.  
  134.   Glib::Object::_Unregistered::AtkImplementorIface
  135.  
  136. =for object Gnome2::Canvas A structured graphics canvas
  137.  
  138. =cut
  139.  
  140.  
  141.  
  142.  
  143. =head1 METHODS
  144.  
  145. =head2 widget = Gnome2::Canvas-E<gt>B<new> 
  146.  
  147. =over
  148.  
  149. Create a new empty canvas in non-antialiased mode.
  150.  
  151. =back
  152.  
  153. =head2 widget = Gnome2::Canvas-E<gt>B<new_aa> 
  154.  
  155. =over
  156.  
  157. Create a new empty canvas in antialiased mode.
  158.  
  159. =back
  160.  
  161. =head2 boolean = $canvas->B<aa>
  162.  
  163. =over
  164.  
  165.  
  166. Returns true if I<$canvas> was created in anti-aliased mode.
  167.  
  168.  
  169. =back
  170.  
  171. =head2 ($bx1, $by1, $bx2, $by2) = Gnome2::Canvas->B<get_butt_points> ($x1, $y1, $x2, $y2, $width, $project)
  172.  
  173. =over
  174.  
  175. =over
  176.  
  177. =item * $x1 (double) 
  178.  
  179. =item * $y1 (double) 
  180.  
  181. =item * $x2 (double) 
  182.  
  183. =item * $y2 (double) 
  184.  
  185. =item * $width (double) 
  186.  
  187. =item * $project (integer) 
  188.  
  189. =back
  190.  
  191.  
  192.  
  193. =back
  194.  
  195. =head2 (wx, wy) = $canvas-E<gt>B<c2w> ($cx, $cy)
  196.  
  197. =over
  198.  
  199. =over
  200.  
  201. =item * $cx (integer) 
  202.  
  203. =item * $cy (integer) 
  204.  
  205. =back
  206.  
  207. =back
  208.  
  209. =head2 boolean = $canvas-E<gt>B<get_center_scroll_region> 
  210.  
  211. =over
  212.  
  213. =back
  214.  
  215. =head2 $canvas-E<gt>B<set_center_scroll_region> ($center_scroll_region)
  216.  
  217. =over
  218.  
  219. =over
  220.  
  221. =item * $center_scroll_region (boolean) 
  222.  
  223. =back
  224.  
  225. =back
  226.  
  227. =head2 list = $canvas-E<gt>B<get_color> ($spec)
  228.  
  229. =over
  230.  
  231. =over
  232.  
  233. =item * $spec (string) 
  234.  
  235. =back
  236.  
  237.  
  238. Returns an integer indicating the success of the color allocation and a
  239. GdkColor.
  240.  
  241.  
  242. =back
  243.  
  244. =head2 unsigned = $canvas-E<gt>B<get_color_pixel> ($rgba)
  245.  
  246. =over
  247.  
  248. =over
  249.  
  250. =item * $rgba (integer) 
  251.  
  252. =back
  253.  
  254. =back
  255.  
  256. =head2 rgbdither = $canvas-E<gt>B<get_dither> 
  257.  
  258. =over
  259.  
  260. =back
  261.  
  262. =head2 $canvas-E<gt>B<set_dither> ($dither)
  263.  
  264. =over
  265.  
  266. =over
  267.  
  268. =item * $dither (Gtk2::Gdk::RgbDither) 
  269.  
  270. =back
  271.  
  272. =back
  273.  
  274. =head2 item = $canvas-E<gt>B<get_item_at> ($x, $y)
  275.  
  276. =over
  277.  
  278. =over
  279.  
  280. =item * $x (double) 
  281.  
  282. =item * $y (double) 
  283.  
  284. =back
  285.  
  286. =back
  287.  
  288. =head2 ($mx1, $my1, $mx2, $my2) = Gnome2::Canvas->B<get_miter_points> ($x1, $y1, $x2, $y2, $x3, $y3, $width)
  289.  
  290. =over
  291.  
  292. =over
  293.  
  294. =item * $x1 (double) 
  295.  
  296. =item * $y1 (double) 
  297.  
  298. =item * $x2 (double) 
  299.  
  300. =item * $y2 (double) 
  301.  
  302. =item * $x3 (double) 
  303.  
  304. =item * $y3 (double) 
  305.  
  306. =item * $width (double) 
  307.  
  308. =back
  309.  
  310.  
  311.  
  312. =back
  313.  
  314. =head2 double = $canvas->B<get_pixels_per_unit>
  315.  
  316. =over
  317.  
  318. Fetch I<$canvas>' scale factor.
  319.  
  320. =back
  321.  
  322. =head2 $canvas-E<gt>B<set_pixels_per_unit> ($n)
  323.  
  324. =over
  325.  
  326. =over
  327.  
  328. =item * $n (double) 
  329.  
  330. =back
  331.  
  332.  
  333. Set the zooming factor of I<$canvas> by specifying the number of screen
  334. pixels that correspond to one canvas unit.
  335.  
  336.  
  337. =back
  338.  
  339. =head2 double = Gnome2::Canvas-E<gt>B<polygon_to_point> ($poly_ref, $x, $y)
  340.  
  341. =over
  342.  
  343. =over
  344.  
  345. =item * $poly_ref (arrayref) coordinate pairs that make up the polygon
  346.  
  347. =item * $x (double) 
  348.  
  349. =item * $y (double) 
  350.  
  351. =back
  352.  
  353. Return the distance from the point I<$x>,I<$y> to the polygon described by
  354. the vertices in I<$poly_ref>, or zero if the point is inside the polygon.
  355.  
  356. =back
  357.  
  358. =head2 $canvas-E<gt>B<request_redraw> ($x1, $y1, $x2, $y2)
  359.  
  360. =over
  361.  
  362. =over
  363.  
  364. =item * $x1 (integer) 
  365.  
  366. =item * $y1 (integer) 
  367.  
  368. =item * $x2 (integer) 
  369.  
  370. =item * $y2 (integer) 
  371.  
  372. =back
  373.  
  374. =back
  375.  
  376. =head2 group = $canvas-E<gt>B<root> 
  377.  
  378. =over
  379.  
  380. =back
  381.  
  382. =head2 (cx, cy) = $canvas-E<gt>B<get_scroll_offsets> 
  383.  
  384. =over
  385.  
  386. =back
  387.  
  388. =head2 (x1, y1, x2, y2) = $canvas-E<gt>B<get_scroll_region> 
  389.  
  390. =over
  391.  
  392. =back
  393.  
  394. =head2 $canvas-E<gt>B<set_scroll_region> ($x1, $y1, $x2, $y2)
  395.  
  396. =over
  397.  
  398. =over
  399.  
  400. =item * $x1 (double) 
  401.  
  402. =item * $y1 (double) 
  403.  
  404. =item * $x2 (double) 
  405.  
  406. =item * $y2 (double) 
  407.  
  408. =back
  409.  
  410. =back
  411.  
  412. =head2 $canvas-E<gt>B<scroll_to> ($cx, $cy)
  413.  
  414. =over
  415.  
  416. =over
  417.  
  418. =item * $cx (integer) 
  419.  
  420. =item * $cy (integer) 
  421.  
  422. =back
  423.  
  424. =back
  425.  
  426. =head2 $canvas-E<gt>B<set_stipple_origin> ($gc)
  427.  
  428. =over
  429.  
  430. =over
  431.  
  432. =item * $gc (Gtk2::Gdk::GC) 
  433.  
  434. =back
  435.  
  436. =back
  437.  
  438. =head2 $canvas-E<gt>B<update_now> 
  439.  
  440. =over
  441.  
  442. =back
  443.  
  444. =head2 (cx, cy) = $canvas-E<gt>B<w2c> ($wx, $wy)
  445.  
  446. =over
  447.  
  448. =over
  449.  
  450. =item * $wx (double) 
  451.  
  452. =item * $wy (double) 
  453.  
  454. =back
  455.  
  456. =back
  457.  
  458. =head2 $affine = $canvas->B<w2c_affine>
  459.  
  460. =over
  461.  
  462. =over
  463.  
  464. =back
  465.  
  466. Fetch the affine transform that converts from world coordinates to canvas
  467. pixel coordinates.
  468.  
  469. Note: This method was completely broken for all
  470. $Gnome2::Canvas::VERSION < 1.002.
  471.  
  472. =back
  473.  
  474. =head2 (cx, cy) = $canvas-E<gt>B<w2c_d> ($wx, $wy)
  475.  
  476. =over
  477.  
  478. =over
  479.  
  480. =item * $wx (double) 
  481.  
  482. =item * $wy (double) 
  483.  
  484. =back
  485.  
  486. =back
  487.  
  488. =head2 (worldx, worldy) = $canvas-E<gt>B<window_to_world> ($winx, $winy)
  489.  
  490. =over
  491.  
  492. =over
  493.  
  494. =item * $winx (double) 
  495.  
  496. =item * $winy (double) 
  497.  
  498. =back
  499.  
  500. =back
  501.  
  502. =head2 (winx, winy) = $canvas-E<gt>B<world_to_window> ($worldx, $worldy)
  503.  
  504. =over
  505.  
  506. =over
  507.  
  508. =item * $worldx (double) 
  509.  
  510. =item * $worldy (double) 
  511.  
  512. =back
  513.  
  514. =back
  515.  
  516.  
  517. =head1 PROPERTIES
  518.  
  519. =over
  520.  
  521. =item 'aa' (boolean : readable / writable / construct-only)
  522.  
  523. The antialiasing mode of the canvas.
  524.  
  525. =back
  526.  
  527.  
  528. =head1 SIGNALS
  529.  
  530. =over
  531.  
  532. =item B<draw-background> (Gnome2::Canvas, Gtk2::Gdk::Drawable, integer, integer, integer, integer)
  533.  
  534. =item B<render-background> (Gnome2::Canvas, gpointer)
  535.  
  536. =back
  537.  
  538.  
  539. =head1 ENUMS AND FLAGS
  540.  
  541. =head2 enum Gtk2::Gdk::RgbDither
  542.  
  543. =over
  544.  
  545. =item * 'none' / 'GDK_RGB_DITHER_NONE'
  546.  
  547. =item * 'normal' / 'GDK_RGB_DITHER_NORMAL'
  548.  
  549. =item * 'max' / 'GDK_RGB_DITHER_MAX'
  550.  
  551. =back
  552.  
  553.  
  554. =for position SEE_ALSO
  555.  
  556. =head1 SEE ALSO
  557.  
  558. Gnome2::Canvas::index(3pm) lists the generated Perl API reference PODs.
  559.  
  560. Frederico Mena Quintero's whitepaper on the GNOME Canvas:
  561. http://developer.gnome.org/doc/whitepapers/canvas/canvas.html
  562.  
  563. The real GnomeCanvas is implemented in a C library; the Gnome2::Canvas module
  564. allows a Perl developer to use the canvas like a normal gtk2-perl object.
  565. Like the Gtk2 module on which it depends, Gnome2::Canvas follows the C API of
  566. libgnomecanvas-2.0 as closely as possible while still being perlish.
  567. Thus, the C API reference remains the canonical documentation; the Perl
  568. reference documentation lists call signatures and argument types, and is
  569. meant to be used in conjunction with the C API reference.
  570.  
  571. GNOME Canvas Library Reference Manual
  572. http://developer.gnome.org/doc/API/2.0/libgnomecanvas/index.html
  573.  
  574. perl(1), Glib(3pm), Gtk2(3pm).
  575.  
  576. To discuss gtk2-perl, ask questions and flame/praise the authors,
  577. join gtk-perl-list@gnome.org at lists.gnome.org.
  578.  
  579. =cut
  580.  
  581.  
  582.  
  583. =for position COPYRIGHT
  584.  
  585. =head1 AUTHOR
  586.  
  587. muppet <scott at asofyet dot org>, with patches from
  588. Torsten Schoenfeld <kaffetisch at web dot de>.
  589.  
  590. The DESCRIPTION section of this page is adapted from the documentation of
  591. libgnomecanvas.
  592.  
  593. =head1 COPYRIGHT AND LICENSE
  594.  
  595. Copyright 2003-2004 by the gtk2-perl team.
  596.  
  597. This library is free software; you can redistribute it and/or
  598. modify it under the terms of the GNU Library General Public
  599. License as published by the Free Software Foundation; either
  600. version 2 of the License, or (at your option) any later version.
  601.  
  602. This library is distributed in the hope that it will be useful,
  603. but WITHOUT ANY WARRANTY; without even the implied warranty of
  604. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  605. Library General Public License for more details.
  606.  
  607. You should have received a copy of the GNU Library General Public
  608. License along with this library; if not, write to the 
  609. Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
  610. Boston, MA  02111-1307  USA.
  611.  
  612. =cut
  613.  
  614.  
  615.  
  616.  
  617. =cut
  618.  
  619.