=head1 NAME

Gtk2::ImageView -  General purpose image viewer for Gtk+

=cut

=for position SYNOPSIS

=head1 SYNOPSIS

 use Gtk2::ImageView;
 Gtk2->init;

 $window = Gtk2::Window->new();

 $view = Gtk2::ImageView->new;
 $view->set_pixbuf($pixbuf, TRUE);
 $window->add($view);

 $window->show_all;

=cut



=for position DESCRIPTION

=head1 DESCRIPTION

GtkImageView is a full-featured general purpose image viewer widget for GTK.
It provides a scrollable, zoomable pane in which a pixbuf can be displayed.

The Gtk2::ImageView module allows a perl developer to use the GtkImageView
Widget.

=cut



=head1 HIERARCHY

  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::ImageView



=cut

=head1 INTERFACES

  Glib::Object::_Unregistered::AtkImplementorIface
  Gtk2::Buildable



=cut

=for object Gtk2::ImageView General purpose image viewer for Gtk+
=cut




=head1 METHODS

=head2 widget or undef = Gtk2::ImageView-E<gt>B<new> 

Returns a new Gtk2::ImageView with the following default values.

=over

=item black bg : FALSE

=item fitting : TRUE

=item image tool : a Gtk2::ImageView::Tool::Dragger instance

=item interpolation mode : GDK_INTERP_BILINEAR

=item offset : (0, 0)

=item pixbuf : NULL

=item show cursor: TRUE

=item show frame : TRUE

=item transp : GTK_IMAGE_TRANSP_GRID

=item zoom : 1.0

=back


=head2 boolean = $view-E<gt>B<get_black_bg> 

Returns TRUE if the view renders the widget on a black background, otherwise
FALSE.

=head2 $view-E<gt>B<set_black_bg> ($black_bg)

=over

=item * $black_bg (boolean) 

=back

If TRUE, the view uses a black background. If FALSE, the view uses the default
(normally gray) background.

The default value is FALSE.

=head2 list = $view-E<gt>B<get_check_colors> 

Reads the two colors used to draw transparent parts of images with an alpha
channel. Note that if the transp setting of the view is
GTK_IMAGE_TRANSP_BACKGROUND or GTK_IMAGE_TRANSP_COLOR, then both colors will be
equal.

=head2 $view-E<gt>B<damage_pixels> ($rect)

=over

=item * $rect (Gtk2::Gdk::Rectangle) 

=back

Mark the pixels in the rectangle as damaged. That the pixels are damaged means
that they have been modified and that the view must redraw them to ensure that
the visible part of the image corresponds to the pixels in that image. Calling
this method emits the ::pixbuf-changed signal.

This method must be used when modifying the image data:

    // Drawing something cool in the area 20,20 - 60,60 here...
    ...
    // And force an update
    $view->damage_pixels (Gtk2::Gdk::Rectangle->new(20, 20, 40, 40);

If the whole pixbuf has been modified then rect should be NULL to indicate that
a total update is needed.

See also gtk_image_view_set_pixbuf().

=over

=item view : a Gtk2::ImageView

=item view : a Gtk2::Gdk::Rectangle in image space coordinates to mark as
damaged or NULL, to mark the whole pixbuf as damaged.

=back


=head2 rectangle = $view-E<gt>B<get_draw_rect> 

Get the rectangle in the widget where the pixbuf is painted, or undef if the
view is not allocated or has no pixbuf.

For example, if the widgets allocated size is 100, 100 and the pixbufs size is
50, 50 and the zoom factor is 1.0, then the pixbuf will be drawn centered on the
widget. rect will then be (25,25)-[50,50].

This method is useful when converting from widget to image or zoom space
coordinates.

=head2 boolean = $view-E<gt>B<get_fitting> 

Returns TRUE if the view fits the image, FALSE otherwise.

=head2 $view-E<gt>B<set_fitting> ($fitting)

=over

=item * $fitting (boolean) 

=back

Sets whether to fit or not. If TRUE, then the view will adapt the zoom so that
the whole pixbuf is visible.

Setting the fitting causes the widget to immediately repaint itself.

Fitting is by default TRUE.

=over

=item view : a Gtk2::ImageView

=item fitting : whether to fit the image or not

=back


=head2 rectangle = $view-E<gt>B<image_to_widget_rect> ($rect_in)

=over

=item * $rect_in (Gtk2::Gdk::Rectangle) 

=back

Converts a rectangle in image space coordinates to widget space coordinates.
If the view is not realized, or if it contains no pixbuf, then the conversion
was unsuccessful, FALSE is returned and rect_out is left unmodified.

Note that this function may return a rectangle that is not visible on the
widget.

=head2 interptype = $view-E<gt>B<get_interpolation> 

Returns the current interpolation mode of the view.

=head2 $view-E<gt>B<set_interpolation> ($interp)

=over

=item * $interp (Gtk2::Gdk::InterpType) 

=back

Sets the interpolation mode of how the view. GDK_INTERP_HYPER is the slowest,
but produces the best results. GDK_INTERP_NEAREST is the fastest, but provides
bad rendering quality. GDK_INTERP_BILINEAR is a good compromise.

Setting the interpolation mode causes the widget to immidiately repaint itself.

The default interpolation mode is GDK_INTERP_BILINEAR.

=over

=item view : a Gtk2::ImageView

=item interp : The Gtk2::Gdk::InterpType to use. One of GDK_INTERP_NEAREST,
GDK_INTERP_BILINEAR and GDK_INTERP_HYPER.

=back


=head2 string = Gtk2::ImageView-E<gt>B<library_version> 


Returns the version of the underlying GtkImageView C library


=head2 $view-E<gt>B<set_offset> ($x, $y, $invalidate=FALSE)

=over

=item * $x (double) 

=item * $y (double) 

=item * $invalidate (boolean) 

=back

Sets the offset of where in the image the GtkImageView should begin displaying
image data.

The offset is clamped so that it will never cause the GtkImageView to display
pixels outside the pixbuf. Setting this attribute causes the widget to repaint
itself if it is realized.

If invalidate is TRUE, the views entire area will be invalidated instead of
redrawn immidiately. The view is then queued for redraw, which means that
additional operations can be performed on it before it is redrawn.

The difference can sometimes be important like when you are overlaying data and
get flicker or artifacts when setting the offset. If that happens, setting
invalidate to TRUE could fix the problem. See the source code to
GtkImageToolSelector for an example.

Normally, invalidate should always be FALSE because it is much faster to repaint
immidately than invalidating.

=over

=item view : a Gtk2::ImageView

=item x : X-component of the offset in zoom space coordinates.

=item y : Y-component of the offset in zoom space coordinates.

=item invalidate : whether to invalidate the view or redraw immediately,
default=FALSE.

=back


=head2 pixbuf or undef = $view-E<gt>B<get_pixbuf> 

Returns the pixbuf this view shows.

=head2 $view-E<gt>B<set_pixbuf> ($pixbuf, $reset_fit=TRUE)

=over

=item * $pixbuf (Gtk2::Gdk::Pixbuf or undef) 

=item * $reset_fit (boolean) 

=back

Sets the pixbuf to display, or NULL to not display any pixbuf. Normally,
reset_fit should be TRUE which enables fitting. Which means that, initially, the
whole pixbuf will be shown.

Sometimes, the fit mode should not be reset. For example, if GtkImageView is
showing an animation, it would be bad to reset the fit mode for each new frame.
The parameter should then be FALSE which leaves the fit mode of the view
untouched.

This method should not be used if merely the contents of the pixbuf has changed.
See gtk_image_view_damage_pixels() for that.

If reset_fit is TRUE, the zoom-changed signal is emitted, otherwise not. The
pixbuf-changed signal is also emitted.

The default pixbuf is NULL.

=over

=item view : a Gtk2::ImageView

=item pixbuf : The pixbuf to display.

=item reset_fit : Whether to reset fitting or not.

=back


=head2 boolean = $view-E<gt>B<get_show_cursor> 

Returns TRUE if the cursor is shown when the mouse is over the widget,
otherwise FALSE.

=head2 $view-E<gt>B<set_show_cursor> ($show_cursor)

=over

=item * $show_cursor (boolean) 

=back

Sets whether to show the mouse cursor when the mouse is over the widget or not.
Hiding the cursor is useful when the widget is fullscreened.

The default value is TRUE.

=over

=item view : a Gtk2::ImageView

=item show_cursor : whether to show the cursor or not

=back


=head2 boolean = $view-E<gt>B<get_show_frame> 

Returns TRUE if a one pixel frame is drawn around the pixbuf, otherwise FALSE.

=head2 $view-E<gt>B<set_show_frame> ($show_frame)

=over

=item * $show_frame (boolean) 

=back

Sets whether to draw a frame around the image or not. When TRUE, a one pixel
wide frame is shown around the image. Setting this attribute causes the widget
to immediately repaint itself.

The default value is TRUE.

=head2 tool = $view-E<gt>B<get_tool> 

Returns the currently bound image tool

=head2 $view-E<gt>B<set_tool> ($tool)

=over

=item * $tool (Gtk2::ImageView::Tool) 

=back

Set the image tool to use. If the new tool is the same as the current tool,
then nothing will be done. Otherwise Gtk2::ImageView::Tool::pixbuf_changed() is
called so that the tool has a chance to generate initial data for the pixbuf.

Setting the tool causes the widget to immediately repaint itself.

The default image tool is a Gtk2::ImageView::Tool::Dragger instance. See also
Gtk2::ImageView::Tool.

=over

=item view : a Gtk2::ImageView

=item tool : The image tool to use (must not be NULL)

=back


=head2 $view-E<gt>B<set_transp> ($transp, $transp_color=0x000000)

=over

=item * $transp (Gtk2::ImageView::Transp) 

=item * $transp_color (integer) 

=back

Sets how the view should draw transparent parts of images with an alpha channel.
If transp is GTK_IMAGE_TRANSP_COLOR, the specified color will be used. Otherwise
the transp_color argument is ignored. If it is GTK_IMAGE_TRANSP_BACKGROUND, the
background color of the widget will be used. If it is GTK_IMAGE_TRANSP_GRID,
then a grid with light and dark gray boxes will be drawn on the transparent
parts.

Calling this method causes the widget to immediately repaint. It also causes the
pixbuf-changed signal to be emitted. This is done so that other widgets (such as
GtkImageNav) will have a chance to render a view of the pixbuf with the new
transparency settings.

=over

=item view : a Gtk2::ImageView

=item transp : The Gtk2::ImageView::Transp to use when drawing transparent
images, default GTK_IMAGE_TRANSP_GRID.

=item transp_color : Color to use when drawing transparent images, default
0x000000.

=back


=head2 rectangle = $view-E<gt>B<get_viewport> 

Returns a rectangle with the current viewport. If pixbuf is NULL or there is no
viewport, undef is returned.

The current viewport is defined as the rectangle, in zoomspace coordinates as
the area of the loaded pixbuf the Gtk2::ImageView is currently showing.

=head2 double = $view-E<gt>B<get_zoom> 

Get the current zoom factor of the view.

=head2 $view-E<gt>B<zoom_in> 

Zoom in the view one step. Calling this method causes the widget to immediately
repaint itself.

=over

=item view : a Gtk2::ImageView

=back


=head2 $view-E<gt>B<zoom_out> 

Zoom out the view one step. Calling this method causes the widget to immediately
repaint itself.

=over

=item view : a Gtk2::ImageView

=back


=head2 $view-E<gt>B<set_zoom> ($zoom)

=over

=item * $zoom (double) 

=back

Sets the zoom of the view.

Fitting is always disabled after this method has run. The zoom-changed signal
is unconditionally emitted.

=over

=item view : a Gtk2::ImageView

=item zoom : the new zoom factor

=back




=cut


=head1 SIGNALS

=over

=item B<mouse-wheel-scroll> (Gtk2::ImageView, Gtk2::Gdk::ScrollDirection)

=item B<pixbuf-changed> (Gtk2::ImageView)

=item B<scroll> (Gtk2::ImageView, Gtk2::ScrollType, Gtk2::ScrollType)

=item B<set-fitting> (Gtk2::ImageView, integer)

=item B<set-scroll-adjustments> (Gtk2::ImageView, Gtk2::Adjustment, Gtk2::Adjustment)

=item B<set-zoom> (Gtk2::ImageView, double)

=item B<zoom-changed> (Gtk2::ImageView)

=item B<zoom-in> (Gtk2::ImageView)

=item B<zoom-out> (Gtk2::ImageView)

=back



=cut


=head1 ENUMS AND FLAGS

=head2 enum Gtk2::Gdk::InterpType

=over

=item * 'nearest' / 'GDK_INTERP_NEAREST'

=item * 'tiles' / 'GDK_INTERP_TILES'

=item * 'bilinear' / 'GDK_INTERP_BILINEAR'

=item * 'hyper' / 'GDK_INTERP_HYPER'

=back


=head2 enum Gtk2::Gdk::ScrollDirection

=over

=item * 'up' / 'GDK_SCROLL_UP'

=item * 'down' / 'GDK_SCROLL_DOWN'

=item * 'left' / 'GDK_SCROLL_LEFT'

=item * 'right' / 'GDK_SCROLL_RIGHT'

=back


=head2 enum Gtk2::ImageView::Transp

=over

=item * 'color' / 'GTK_IMAGE_TRANSP_COLOR'

=item * 'background' / 'GTK_IMAGE_TRANSP_BACKGROUND'

=item * 'grid' / 'GTK_IMAGE_TRANSP_GRID'

=back


=head2 enum Gtk2::ScrollType

=over

=item * 'none' / 'GTK_SCROLL_NONE'

=item * 'jump' / 'GTK_SCROLL_JUMP'

=item * 'step-backward' / 'GTK_SCROLL_STEP_BACKWARD'

=item * 'step-forward' / 'GTK_SCROLL_STEP_FORWARD'

=item * 'page-backward' / 'GTK_SCROLL_PAGE_BACKWARD'

=item * 'page-forward' / 'GTK_SCROLL_PAGE_FORWARD'

=item * 'step-up' / 'GTK_SCROLL_STEP_UP'

=item * 'step-down' / 'GTK_SCROLL_STEP_DOWN'

=item * 'page-up' / 'GTK_SCROLL_PAGE_UP'

=item * 'page-down' / 'GTK_SCROLL_PAGE_DOWN'

=item * 'step-left' / 'GTK_SCROLL_STEP_LEFT'

=item * 'step-right' / 'GTK_SCROLL_STEP_RIGHT'

=item * 'page-left' / 'GTK_SCROLL_PAGE_LEFT'

=item * 'page-right' / 'GTK_SCROLL_PAGE_RIGHT'

=item * 'start' / 'GTK_SCROLL_START'

=item * 'end' / 'GTK_SCROLL_END'

=back




=cut

=for position SEE_ALSO

=head1 SEE ALSO

GtkImageView Reference Manual at http://trac.bjourne.webfactional.com/

perl(1), Glib(3pm), Gtk2(3pm), Gtk2::ImageViewer - an alternative image viewer
widget.


=for position AUTHOR

=head1 AUTHOR

Jeffrey Ratcliffe <Jeffrey dot Ratcliffe at gmail dot com>,
with patches from
muppet <scott at asofyet dot org>,
Torsten Schoenfeld <kaffetisch at web dot de> and
Emanuele Bassi <ebassi at gmail dot com>
Kevin Ryde <user42 at zip.com.au>

The DESCRIPTION section of this page is adapted from the documentation of
GtkImageView.

=for position COPYRIGHT AND LICENSE

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2007 -- 2008 by Jeffrey Ratcliffe <Jeffrey.Ratcliffe@gmail.com>
see AUTHORS for complete list of contributors

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
=cut




=head1 COPYRIGHT

Copyright (C) 2007 by Jeffrey Ratcliffe.

This software is licensed under the GPL-3; see L<Gtk2::ImageView> for a full notice.


=cut

