root/plgtkimageview/ImageView.xs

Revision 531, 17.0 kB (checked in by jeffrey, 9 months ago)

fixed some documentation issues

Line 
1 #include "gtkimageviewperl.h"
2
3 MODULE = Gtk2::ImageView  PACKAGE = Gtk2::ImageView  PREFIX = gtk_image_view_
4
5 BOOT:
6 #include "register.xsh"
7 #include "boot.xsh"
8
9 =for object Gtk2::ImageView General purpose image viewer for Gtk+
10 =cut
11
12 =for position SYNOPSIS
13
14 =head1 SYNOPSIS
15
16  use Gtk2::ImageView;
17  Gtk2->init;
18
19  $window = Gtk2::Window->new();
20
21  $view = Gtk2::ImageView->new;
22  $view->set_pixbuf($pixbuf, TRUE);
23  $window->add($view);
24
25  $window->show_all;
26
27 =cut
28
29 =for position DESCRIPTION
30
31 =head1 DESCRIPTION
32
33 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.
34
35 The Gtk2::ImageView module allows a perl developer to use the GtkImageView Widget.
36
37 =cut
38
39 =for position SEE_ALSO
40
41 =head1 SEE ALSO
42
43 GtkImageView Reference Manual at http://trac.bjourne.webfactional.com/
44
45 perl(1), Glib(3pm), Gtk2(3pm), Gtk2::ImageViewer - an alternative image viewer widget.
46
47 =cut
48
49 =for position COPYRIGHT
50
51 =head1 AUTHOR
52
53 Jeffrey Ratcliffe <Jeffrey dot Ratcliffe at gmail dot com>,
54 with patches from
55 muppet <scott at asofyet dot org>,
56 Torsten Schoenfeld <kaffetisch at web dot de> and
57 Emanuele Bassi <ebassi at gmail dot com>
58
59 The DESCRIPTION section of this page is adapted from the documentation of GtkImageView.
60
61 =head1 COPYRIGHT AND LICENSE
62
63 Copyright (c) 2007 -- 2008 by Jeffrey Ratcliffe <Jeffrey.Ratcliffe@gmail.com>
64 see AUTHORS for complete list of contributors
65
66 This library is free software; you can redistribute it and/or
67 modify it under the terms of the GNU Lesser General Public
68 License as published by the Free Software Foundation; either
69 version 3 of the License, or (at your option) any later version.
70
71 This library is distributed in the hope that it will be useful,
72 but WITHOUT ANY WARRANTY; without even the implied warranty of
73 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
74 Library General Public License for more details.
75
76 You should have received a copy of the GNU Lesser General Public License
77 along with this program.  If not, see <http://www.gnu.org/licenses/>.
78
79 =cut
80
81
82 =for apidoc
83
84 Creates a new Gtk2::ImageView with default values. The default values are:
85
86 =over
87
88 =item black bg : FALSE
89
90 =item fitting : TRUE
91
92 =item image tool : a Gtk2::ImageView::Tool::Dragger instance
93
94 =item interpolation mode : GDK_INTERP_BILINEAR
95
96 =item offset : (0, 0)
97
98 =item pixbuf : NULL
99
100 =item show cursor: TRUE
101
102 =item show frame : TRUE
103
104 =item transp : GTK_IMAGE_TRANSP_GRID
105
106 =item zoom : 1.0
107
108 =back
109
110 =head3 Returns
111
112 =over
113
114 =item a new Gtk2::ImageView.
115
116 =back
117
118 =cut
119 ## call as $widget = Gtk2::ImageView->new
120 GtkWidget_ornull *
121 gtk_image_view_new (class)
122         C_ARGS:
123                 /*void*/
124
125
126 =for apidoc
127
128 Returns a rectangle with the current viewport. If pixbuf is NULL, there is no viewport, undef is returned.
129
130 The current viewport is defined as the rectangle, in zoomspace coordinates as the area of the loaded pixbuf the Gtk2::ImageView is currently showing.
131
132 =over
133
134 =item view : a Gtk2::ImageView
135
136 =back
137
138 =head3 Returns
139
140 =over
141
142 =item rect : a Gtk2::Gdk::Rectangle with the current viewport or NULL.
143
144 =back
145
146 =cut
147 ## call as $viewport = $view->get_viewport
148 ## gboolean gtk_image_view_get_viewport (GtkImageView *view, GdkRectangle *rect);
149 GdkRectangle_copy *
150 gtk_image_view_get_viewport (view)
151         GtkImageView *  view
152         PREINIT:
153                 GdkRectangle    rect;
154         CODE:
155                 if (!gtk_image_view_get_viewport(view, &rect))
156                         XSRETURN_UNDEF;
157                 RETVAL = &rect;
158         OUTPUT:
159                 RETVAL
160
161 =for apidoc
162
163 Get the rectangle in the widget where the pixbuf is painted.
164
165 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].
166
167 This method is useful when converting from widget to image or zoom space coordinates.
168
169 =over
170
171 =item view : a Gtk2::ImageView
172
173 =item 
174
175 =back
176
177 =head3 Returns
178
179 =over
180
181 =item a Gtk2::Gdk::Rectangle with the area of the widget in which the pixbuf is drawn, or undef if the view is not allocated or has no pixbuf.
182
183 =back
184
185 =cut
186 ## call as $rectangle = $view->get_draw_rect
187 GdkRectangle_copy *
188 gtk_image_view_get_draw_rect (view);
189         GtkImageView *  view
190         PREINIT:
191                 GdkRectangle    rect;
192         CODE:
193                 if (!gtk_image_view_get_draw_rect(view, &rect))
194                         XSRETURN_UNDEF;
195                 RETVAL = &rect;
196         OUTPUT:
197                 RETVAL
198
199 =for apidoc
200
201 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.
202
203 =over
204
205 =item view : a Gtk2::ImageView
206
207 =back
208
209 =head3 Returns
210
211 =over
212
213 =item check_color1 :    A pointer to an integer where the first check color should be stored.
214
215 =item check_color2 :    A pointer to an integer wherer the second check color should be stored.
216
217 =back
218
219 =cut
220 ## call as @check_colors = $view->get_check_colors
221 void
222 gtk_image_view_get_check_colors (view)
223         GtkImageView *  view
224         PREINIT:
225                 int     check_color1;
226                 int     check_color2;
227         PPCODE:
228                 gtk_image_view_get_check_colors (view, &check_color1, &check_color2);
229                 XPUSHs(sv_2mortal(newSViv(check_color1)));
230                 XPUSHs(sv_2mortal(newSViv(check_color2)));
231
232
233 =for apidoc
234
235 Converts a rectangle in image space coordinates to widget space coordinates.
236 If the view is not realized, or if it contains no pixbuf, then the conversion
237 was unsuccessful, FALSE is returned and rect_out is left unmodified.
238
239 Note that this function may return a rectangle that is not visible on the
240 widget.
241
242 =over
243
244 =item view : a Gtk2::ImageView
245
246 =item rect_in : Gtk2::Gdk::Rectangle in image space coordinates to convert
247
248 =back
249
250 =head3 Returns
251
252 =over
253
254 =item rect_out : Gtk2::Gdk::Rectangle with the widget space coordinates or undef
255
256 =back
257
258 =cut
259 ## call as $rect_out = $view->image_to_widget_rect($rect_in)
260 ## gboolean gtk_image_view_image_to_widget_rect (GtkImageView *view, GdkRectangle *rect_in, GdkRectangle *rect_out);
261 GdkRectangle_copy *
262 gtk_image_view_image_to_widget_rect (view, rect_in)
263         GtkImageView *  view
264         GdkRectangle *  rect_in
265         PREINIT:
266                 GdkRectangle    rect_out;
267         CODE:
268                 if (!gtk_image_view_image_to_widget_rect(view, rect_in, &rect_out))
269                         XSRETURN_UNDEF;
270                 RETVAL = &rect_out;
271         OUTPUT:
272                 RETVAL
273
274
275 =for apidoc
276
277 Sets the offset of where in the image the GtkImageView should begin displaying image data.
278
279 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.
280
281 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.
282
283 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.
284
285 Normally, invalidate should always be FALSE because it is much faster to repaint immidately than invalidating.
286
287 =over
288
289 =item view : a Gtk2::ImageView
290
291 =item x : X-component of the offset in zoom space coordinates.
292
293 =item y : Y-component of the offset in zoom space coordinates.
294
295 =item invalidate : whether to invalidate the view or redraw immediately, default=FALSE.
296
297 =back
298
299 =cut
300 ## call as $view->set_offset($x, $y, $invalidate)
301 void
302 gtk_image_view_set_offset (view, x, y, invalidate=FALSE)
303                 GtkImageView *  view
304                 gdouble         x
305                 gdouble         y
306                 gboolean        invalidate
307         CODE:
308                 gtk_image_view_set_offset (view, x, y, invalidate);
309
310 =for apidoc
311
312 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.
313
314 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.
315
316 =over
317
318 =item view : a Gtk2::ImageView
319
320 =item transp : The Gtk2::ImageView::Transp to use when drawing transparent images, default GTK_IMAGE_TRANSP_GRID.
321
322 =item transp_color : Color to use when drawing transparent images, default 0x000000.
323
324 =back
325
326 =cut
327 ## call as $view->set_transp($transp, $transp_color)
328 void
329 gtk_image_view_set_transp (view, transp, transp_color=0x000000)
330                 GtkImageView *  view
331                 GtkImageTransp  transp
332                 int             transp_color
333         CODE:
334                 gtk_image_view_set_transp (view, transp, transp_color);
335
336 =for apidoc
337
338 Returns the fitting setting of the view.
339
340 =over
341
342 =item view : a Gtk2::ImageView
343
344 =back
345
346 =head3 Returns
347
348 =over
349
350 =item TRUE if the view is fitting the image, FALSE otherwise.
351
352 =back
353
354 =cut
355 ## call as $boolean = $view->get_fitting
356 gboolean
357 gtk_image_view_get_fitting (view)
358         GtkImageView *  view
359
360 =for apidoc
361
362 Sets whether to fit or not. If TRUE, then the view will adapt the zoom so that the whole pixbuf is visible.
363
364 Setting the fitting causes the widget to immediately repaint itself.
365
366 Fitting is by default TRUE.
367
368 =over
369
370 =item view : a Gtk2::ImageView
371
372 =item fitting : whether to fit the image or not
373
374 =back
375
376 =cut
377 ## call as $view->set_fitting($boolean)
378 void
379 gtk_image_view_set_fitting (view, fitting)
380         GtkImageView *  view
381         gboolean        fitting
382
383 =for apidoc
384
385 Returns the pixbuf this view shows.
386
387 =over
388
389 =item view : a Gtk2::ImageView
390
391 =back
392
393 =head3 Returns
394
395 =over
396
397 =item The pixbuf this view shows.
398
399 =back
400
401 =cut
402 ## call as $pixbuf = $view->get_pixbuf
403 GdkPixbuf_ornull *
404 gtk_image_view_get_pixbuf (view)
405         GtkImageView *  view
406
407 =for apidoc
408
409 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.
410
411 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.
412
413 This method should not be used if merely the contents of the pixbuf has changed. See gtk_image_view_damage_pixels() for that.
414
415 If reset_fit is TRUE, the zoom-changed signal is emitted, otherwise not. The pixbuf-changed signal is also emitted.
416
417 The default pixbuf is NULL.
418
419 =over
420
421 =item view : a Gtk2::ImageView
422
423 =item pixbuf : The pixbuf to display.
424
425 =item reset_fit : Whether to reset fitting or not.
426
427 =back
428
429 =cut
430 ## call as $view->set_pixbuf($pixbuf, $reset_fit)
431 void
432 gtk_image_view_set_pixbuf (view, pixbuf, reset_fit=TRUE)
433                 GtkImageView *          view
434                 GdkPixbuf_ornull *      pixbuf
435                 gboolean                reset_fit
436         CODE:
437                 gtk_image_view_set_pixbuf (view, pixbuf, reset_fit);
438
439 =for apidoc
440
441 Get the current zoom factor of the view.
442
443 =over
444
445 =item view : a Gtk2::ImageView
446
447 =back
448
449 =head3 Returns
450
451 =over
452
453 =item the current zoom factor
454
455 =back
456
457 =cut
458 ## call as $zoom = $view->get_zoom
459 gdouble
460 gtk_image_view_get_zoom (view)
461         GtkImageView *  view
462
463 =for apidoc
464
465 Sets the zoom of the view.
466
467 Fitting is always disabled after this method has run. The zoom-changed signal is unconditionally emitted.
468
469 =over
470
471 =item view : a Gtk2::ImageView
472
473 =item zoom : the new zoom factor
474
475 =back
476
477 =cut
478 ## call as $view->set_zoom($zoom)
479 void
480 gtk_image_view_set_zoom (view, zoom)
481         GtkImageView *  view
482         gdouble         zoom
483
484 =for apidoc
485
486 If TRUE, the view uses a black background. If FALSE, the view uses the default (normally gray) background.
487
488 The default value is FALSE.
489
490 =over
491
492 =item view : a Gtk2::ImageView
493
494 =item black_bg : Whether to use a black background or not.
495
496 =back
497
498 =cut
499 ## call as $view->set_black_bg($boolean)
500 void
501 gtk_image_view_set_black_bg (view, black_bg)
502         GtkImageView *  view
503         gboolean        black_bg
504
505 =for apidoc
506
507 Returns whether the view renders the widget on a black background or not.
508
509 =over
510
511 =item view : a Gtk2::ImageView
512
513 =back
514
515 =head3 Returns
516
517 =over
518
519 =item TRUE if a black background is used, otherwise FALSE.
520
521 =back
522
523 =cut
524 ## call as $boolean = $view->get_black_bg
525 gboolean
526 gtk_image_view_get_black_bg (view)
527         GtkImageView *  view
528
529 =for apidoc
530
531 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.
532
533 The default value is TRUE.
534
535 =over
536
537 =item view : a Gtk2::ImageView
538
539 =item show_frame : whether to show a frame around the pixbuf or not
540
541 =back
542
543 =cut
544 ## call as $view->set_show_frame($boolean)
545 void
546 gtk_image_view_set_show_frame (view, show_frame)
547         GtkImageView *  view
548         gboolean        show_frame
549
550 =for apidoc
551
552 Returns whether a one pixel frame