2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GDKMM_DRAWABLE_H
4 #define _GDKMM_DRAWABLE_H
11 /* Copyright (C) 1998-2002 The gtkmm Development Team
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <gdk/gdkdrawable.h>
29 #include <gdk/gdkrgb.h>
30 #include <pangomm/font.h>
31 #include <pangomm/layout.h>
32 #include <pangomm/layoutline.h>
33 #include <pangomm/glyphstring.h>
35 #include <gdkmm/image.h>
36 #include <gdkmm/color.h>
37 #include <gdkmm/region.h>
38 #include <gdkmm/rgbcmap.h>
39 #include <gdkmm/types.h>
40 #include <cairomm/context.h>
41 //#include <gdkmm/pixbuf.h>
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 typedef struct _GdkDrawable GdkDrawable;
46 typedef struct _GdkDrawableClass GdkDrawableClass;
47 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
51 { class Drawable_Class; } // namespace Gdk
56 /** @addtogroup gdkmmEnums Enums and Flags */
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
76 class Value<Gdk::RgbDither> : public Glib::Value_Enum<Gdk::RgbDither>
79 static GType value_type() G_GNUC_CONST;
83 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
93 /** Drawing Primitives.
94 * Gdk::Drawable is the base class for all of the objects that accept drawing
95 * commands. The available drawables include pixmaps, windows, and bitmaps.
96 * Drawable is abstract as there is no such type on the server side.
98 * To use a drawable, create a concrete Drawable of the type you wish to use
99 * and a Gdk::GC (graphics context) for that Drawable. With the GC you can
100 * draw lines, text, arcs and such.
102 * An alternative is to create a Cairo::Context with get_cairo_context()
103 * while you handle the 'exposed' event of the drawable. For more about
104 * this, please see "Using cairo with GTK+" in the "Common questions" section
105 * of the GTK+ Reference Manual.
108 class Drawable : public Glib::Object
111 #ifndef DOXYGEN_SHOULD_SKIP_THIS
114 typedef Drawable CppObjectType;
115 typedef Drawable_Class CppClassType;
116 typedef GdkDrawable BaseObjectType;
117 typedef GdkDrawableClass BaseClassType;
119 private: friend class Drawable_Class;
120 static CppClassType drawable_class_;
124 Drawable(const Drawable&);
125 Drawable& operator=(const Drawable&);
128 explicit Drawable(const Glib::ConstructParams& construct_params);
129 explicit Drawable(GdkDrawable* castitem);
131 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
136 #ifndef DOXYGEN_SHOULD_SKIP_THIS
137 static GType get_type() G_GNUC_CONST;
138 static GType get_base_type() G_GNUC_CONST;
141 ///Provides access to the underlying C GObject.
142 GdkDrawable* gobj() { return reinterpret_cast<GdkDrawable*>(gobject_); }
144 ///Provides access to the underlying C GObject.
145 const GdkDrawable* gobj() const { return reinterpret_cast<GdkDrawable*>(gobject_); }
147 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
148 GdkDrawable* gobj_copy();
158 static Glib::RefPtr<Drawable> create();
161 /** Fills * @a width and * @a height with the size of @a drawable .
162 * @a width or @a height can be <tt>0</tt> if you only want the other one.
164 * On the X11 platform, if @a drawable is a Gdk::Window, the returned
165 * size is the size reported in the most-recently-processed configure
166 * event, rather than the current size on the X server.
167 * @param width Location to store drawable's width, or <tt>0</tt>.
168 * @param height Location to store drawable's height, or <tt>0</tt>.
170 void get_size(int& width, int& height);
172 /** Obtains the bit depth of the drawable, that is, the number of bits
173 * that make up a pixel in the drawable's visual. Examples are 8 bits
174 * per pixel, 24 bits per pixel, etc.
175 * @return Number of bits per pixel.
177 int get_depth() const;
180 /** Sets the colormap associated with @a drawable . Normally this will
181 * happen automatically when the drawable is created; you only need to
182 * use this function if the drawable-creating function did not have a
183 * way to determine the colormap, and you then use drawable operations
184 * that require a colormap. The colormap for all drawables and
185 * graphics contexts you intend to use together should match. i.e.
186 * when using a Gdk::GC to draw to a drawable, or copying one drawable
187 * to another, the colormaps should match.
188 * @param colormap A Gdk::Colormap.
190 void set_colormap(const Glib::RefPtr<Colormap>& colormap);
192 /** Gets the colormap for @a drawable , if one is set; returns
193 * <tt>0</tt> otherwise.
194 * @return The colormap, or <tt>0</tt>.
196 Glib::RefPtr<Colormap> get_colormap();
198 /** Gets the Gdk::Visual describing the pixel format of @a drawable .
199 * @return A Gdk::Visual.
201 Glib::RefPtr<Visual> get_visual();
204 /** Draws a point, using the foreground color and other attributes of
206 * @param gc A Gdk::GC.
207 * @param x The x coordinate of the point.
208 * @param y The y coordinate of the point.
210 void draw_point(const Glib::RefPtr<const GC>& gc, int x, int y);
211 void draw_points(const Glib::RefPtr<const GC>& gc, const Glib::ArrayHandle<Point>& points);
214 /** Draws a line, using the foreground color and other attributes of
216 * @param gc A Gdk::GC.
217 * @param x1 The x coordinate of the start point.
218 * @param y1 The y coordinate of the start point.
219 * @param x2 The x coordinate of the end point.
220 * @param y2 The y coordinate of the end point.
222 void draw_line(const Glib::RefPtr<const GC>& gc, int x1, int y1, int x2, int y2);
223 void draw_lines(const Glib::RefPtr<const GC>& gc, const Glib::ArrayHandle<Point>& points);
226 /** Draws a rectangular outline or filled rectangle, using the foreground color
227 * and other attributes of the Gdk::GC.
229 * A rectangle drawn filled is 1 pixel smaller in both dimensions than a
230 * rectangle outlined. Calling
231 * <tt>gdk_draw_rectangle (window, gc, <tt>true</tt>, 0, 0, 20, 20)</tt>
232 * results in a filled rectangle 20 pixels wide and 20 pixels high. Calling
233 * <tt>gdk_draw_rectangle (window, gc, <tt>false</tt>, 0, 0, 20, 20)</tt>
234 * results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20),
235 * and (20, 0), which makes it 21 pixels wide and 21 pixels high.
236 * @param gc A Gdk::GC.
237 * @param filled <tt>true</tt> if the rectangle should be filled.
238 * @param x The x coordinate of the left edge of the rectangle.
239 * @param y The y coordinate of the top edge of the rectangle.
240 * @param width The width of the rectangle.
241 * @param height The height of the rectangle.
243 void draw_rectangle(const Glib::RefPtr<const GC>& gc, bool filled, int x, int y, int width, int height);
245 /** Draws an arc or a filled 'pie slice'. The arc is defined by the bounding
246 * rectangle of the entire ellipse, and the start and end angles of the part
247 * of the ellipse to be drawn.
248 * @param gc A Gdk::GC.
249 * @param filled <tt>true</tt> if the arc should be filled, producing a 'pie slice'.
250 * @param x The x coordinate of the left edge of the bounding rectangle.
251 * @param y The y coordinate of the top edge of the bounding rectangle.
252 * @param width The width of the bounding rectangle.
253 * @param height The height of the bounding rectangle.
254 * @param angle1 The start angle of the arc, relative to the 3 o'clock position,
255 * counter-clockwise, in 1/64ths of a degree.
256 * @param angle2 The end angle of the arc, relative to @a angle1 , in 1/64ths
259 void draw_arc(const Glib::RefPtr<const GC>& gc, bool filled, int x, int y, int width, int height, int angle1, int angle2);
260 void draw_polygon(const Glib::RefPtr<const GC>& gc, bool filled, const Glib::ArrayHandle<Point>& points);
263 /** Copies the @a width x @a height region of @a src at coordinates ( @a xsrc ,
264 * @a ysrc ) to coordinates ( @a xdest , @a ydest ) in @a drawable .
265 * @a width and/or @a height may be given as -1, in which case the entire
266 * @a src drawable will be copied.
268 * Most fields in @a gc are not used for this operation, but notably the
269 * clip mask or clip region will be honored.
271 * The source and destination drawables must have the same visual and
272 * colormap, or errors will result. (On X11, failure to match
273 * visual/colormap results in a BadMatch error from the X server.)
274 * A common cause of this problem is an attempt to draw a bitmap to
275 * a color drawable. The way to draw a bitmap is to set the bitmap as
276 * the stipple on the Gdk::GC, set the fill mode to Gdk::STIPPLED, and
277 * then draw the rectangle.
278 * @param gc A Gdk::GC sharing the drawable's visual and colormap.
279 * @param src The source Gdk::Drawable, which may be the same as @a drawable .
280 * @param xsrc X position in @a src of rectangle to draw.
281 * @param ysrc Y position in @a src of rectangle to draw.
282 * @param xdest X position in @a drawable where the rectangle should be drawn.
283 * @param ydest Y position in @a drawable where the rectangle should be drawn.
284 * @param width Width of rectangle to draw, or -1 for entire @a src width.
285 * @param height Height of rectangle to draw, or -1 for entire @a src height.
287 void draw_drawable(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Drawable>& src, int xsrc, int ysrc, int xdest, int ydest, int width = -1, int height = -1);
289 /** Draws a Gdk::Image onto a drawable.
290 * The depth of the Gdk::Image must match the depth of the Gdk::Drawable.
291 * @param gc A Gdk::GC.
292 * @param image The Gdk::Image to draw.
293 * @param xsrc The left edge of the source rectangle within @a image .
294 * @param ysrc The top of the source rectangle within @a image .
295 * @param xdest The x coordinate of the destination within @a drawable .
296 * @param ydest The y coordinate of the destination within @a drawable .
297 * @param width The width of the area to be copied, or -1 to make the area
298 * extend to the right edge of @a image .
299 * @param height The height of the area to be copied, or -1 to make the area
300 * extend to the bottom edge of @a image .
302 void draw_image(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Image>& image, int xsrc, int ysrc, int xdest, int ydest, int width = -1, int height = -1);
304 //segs is an array, and this function will be used so little that it doesn't seem worth wrapping it to use a container of C++ types.
306 /** Draws a number of unconnected lines.
307 * @param gc A Gdk::GC.
308 * @param segs An array of Gdk::Segment structures specifying the start and
309 * end points of the lines to be drawn.
310 * @param nsegs The number of line segments to draw, i.e. the size of the
313 void draw_segments(const Glib::RefPtr<const GC>& gc, GdkSegment* segs, int nsegs); // TODO
315 //glyphs is not an array. I went down to pango_xft_render in pango and saw that PangoGlyphString here is not an array. -Bryan
317 /** This is a low-level function; 99% of text rendering should be done
318 * using gdk_draw_layout() instead.
320 * A glyph is a single image in a font. This function draws a sequence of
321 * glyphs. To obtain a sequence of glyphs you have to understand a
322 * lot about internationalized text handling, which you don't want to
323 * understand; thus, use gdk_draw_layout() instead of this function,
324 * gdk_draw_layout() handles the details.
325 * @param gc A Gdk::GC.
326 * @param font Font to be used.
327 * @param x X coordinate of baseline origin.
328 * @param y Y coordinate of baseline origin.
329 * @param glyphs The glyph string to draw.
331 void draw_glyphs(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Pango::Font>& font, int x, int y, const Pango::GlyphString& glyphs);
334 /** Render a Pango::LayoutLine onto an GDK drawable
336 * If the layout's Pango::Context has a transformation matrix set, then
337 * @a x and @a y specify the position of the left edge of the baseline
338 * (left is in before-tranform user coordinates) in after-transform
339 * device coordinates.
340 * @param gc Base graphics to use.
341 * @param x The x position of start of string (in pixels).
342 * @param y The y position of baseline (in pixels).
343 * @param line A Pango::LayoutLine.
345 void draw_layout_line(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::LayoutLine>& line);
347 /** Render a Pango::LayoutLine onto a Gdk::Drawable, overriding the
348 * layout's normal colors with @a foreground and/or @a background .
349 * @a foreground and @a background need not be allocated.
351 * If the layout's Pango::Context has a transformation matrix set, then
352 * @a x and @a y specify the position of the left edge of the baseline
353 * (left is in before-tranform user coordinates) in after-transform
354 * device coordinates.
355 * @param gc Base graphics to use.
356 * @param x The x position of start of string (in pixels).
357 * @param y The y position of baseline (in pixels).
358 * @param line A Pango::LayoutLine.
359 * @param foreground Foreground override color, or <tt>0</tt> for none.
360 * @param background Background override color, or <tt>0</tt> for none.
362 void draw_layout_line(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::LayoutLine>& line, const Color& foreground, const Color& background);
365 /** Render a Pango::Layout onto a GDK drawable
367 * If the layout's Pango::Context has a transformation matrix set, then
368 * @a x and @a y specify the position of the top left corner of the
369 * bounding box (in device space) of the transformed layout.
371 * If you're using GTK+, the usual way to obtain a Pango::Layout
372 * is gtk_widget_create_pango_layout().
373 * @param gc Base graphics context to use.
374 * @param x The X position of the left of the layout (in pixels).
375 * @param y The Y position of the top of the layout (in pixels).
376 * @param layout A Pango::Layout.
378 void draw_layout(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::Layout>& layout);
380 /** Render a Pango::Layout onto a Gdk::Drawable, overriding the
381 * layout's normal colors with @a foreground and/or @a background .
382 * @a foreground and @a background need not be allocated.
384 * If the layout's Pango::Context has a transformation matrix set, then
385 * @a x and @a y specify the position of the top left corner of the
386 * bounding box (in device space) of the transformed layout.
388 * If you're using GTK+, the ususal way to obtain a Pango::Layout
389 * is gtk_widget_create_pango_layout().
390 * @param gc Base graphics context to use.
391 * @param x The X position of the left of the layout (in pixels).
392 * @param y The Y position of the top of the layout (in pixels).
393 * @param layout A Pango::Layout.
394 * @param foreground Foreground override color, or <tt>0</tt> for none.
395 * @param background Background override color, or <tt>0</tt> for none.
397 void draw_layout(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::Layout>& layout, const Color& foreground, const Color& background);
400 /** Renders a rectangular portion of a pixbuf to a drawable. The destination
401 * drawable must have a colormap. All windows have a colormap, however, pixmaps
402 * only have colormap by default if they were created with a non-<tt>0</tt> window
403 * argument. Otherwise a colormap must be set on them with
404 * Gdk::Drawable::set_colormap().
406 * On older X servers, rendering pixbufs with an alpha channel involves round
407 * trips to the X server, and may be somewhat slow.
409 * The clip mask of @a gc is ignored, but clip rectangles and clip regions work
412 * If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf
413 * function is accelerated using mediaLib, which provides hardware
414 * acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib
415 * support can be turned off by setting the GDK_DISABLE_MEDIALIB environment
419 * @param gc A Gdk::GC, used for clipping, or <tt>0</tt>.
420 * @param pixbuf A Gdk::Pixbuf.
421 * @param src_x Source X coordinate within pixbuf.
422 * @param src_y Source Y coordinates within pixbuf.
423 * @param dest_x Destination X coordinate within drawable.
424 * @param dest_y Destination Y coordinate within drawable.
425 * @param width Width of region to render, in pixels, or -1 to use pixbuf width.
426 * @param height Height of region to render, in pixels, or -1 to use pixbuf height.
427 * @param dither Dithering mode for Gdk::RGB.
428 * @param x_dither X offset for dither.
429 * @param y_dither Y offset for dither.
431 void draw_pixbuf(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<Pixbuf>& pixbuf,
432 int src_x, int src_y, int dest_x, int dest_y,
433 int width, int height,
434 RgbDither dither, int x_dither, int y_dither);
436 // Note: This has no 'refreturn' because get_image() returns a newly created Image object.
438 /** A Gdk::Image stores client-side image data (pixels). In contrast,
439 * Gdk::Pixmap and Gdk::Window are server-side
440 * objects. get_image() obtains the pixels from a
441 * server-side drawable as a client-side Gdk::Image. The format of a
442 * Gdk::Image depends on the Gdk::Visual of the current display, which
443 * makes manipulating Gdk::Image extremely difficult; therefore, in
444 * most cases you should use the Gdk::Pixbuf::create() method that takes a Gdk::Drawable,
445 * instead of this lower-level function. A Gdk::Pixbuf contains image data in a
446 * canonicalized RGB format, rather than a display-dependent format.
447 * Of course, there's a convenience vs. speed tradeoff here, so you'll
448 * want to think about what makes sense for your application.
450 * @a x , @a y , @a width , and @a height define the region of @a drawable to
451 * obtain as an image.
453 * You would usually copy image data to the client side if you intend
454 * to examine the values of individual pixels, for example to darken
455 * an image or add a red tint. It would be prohibitively slow to
456 * make a round-trip request to the windowing system for each pixel,
457 * so instead you get all of them at once, modify them, then copy
458 * them all back at once.
460 * If the X server or other windowing system backend is on the local
461 * machine, this function may use shared memory to avoid copying
464 * If the source drawable is a Gdk::Window and partially offscreen
465 * or obscured, then the obscured portions of the returned image
466 * will contain undefined data.
467 * @param x X coordinate on @a drawable .
468 * @param y Y coordinate on @a drawable .
469 * @param width Width of region to get.
470 * @param height Height or region to get.
471 * @return A Gdk::Image containing the contents of @a drawable .
473 Glib::RefPtr<Image> get_image(int x, int y, int width, int height) const;
475 // gdk_drawable_copy_to_image() returns a new GdkImage when the image parameter is NULL, but that seems to be much the
476 // same as gdk_drawable_get_image().
477 void copy_to_image(const Glib::RefPtr<Image>& image, int src_x, int src_y, int dest_x, int dest_y, int width, int height) const;
480 /** Computes the region of a drawable that potentially can be written
481 * to by drawing primitives. This region will not take into account
482 * the clip region for the GC, and may also not take into account
483 * other factors such as if the window is obscured by other windows,
484 * but no area outside of this region will be affected by drawing
486 * @return A Gdk::Region. This must be freed with gdk_region_destroy()
489 Region get_clip_region() const;
491 /** Computes the region of a drawable that is potentially visible.
492 * This does not necessarily take into account if the window is
493 * obscured by other windows, but no area outside of this region
495 * @return A Gdk::Region. This must be freed with gdk_region_destroy()
498 Region get_visible_region() const;
501 // **** RGB stuff ****
505 const Glib::RefPtr<const GC>& gc,
506 int x, int y, int width, int height,
507 RgbDither dith, const guchar* rgb_buf, int rowstride);
510 void draw_rgb_image_dithalign(
511 const Glib::RefPtr<const GC>& gc,
512 int x, int y, int width, int height,
513 RgbDither dith, const guchar* rgb_buf, int rowstride,
514 int xdith, int ydith);
517 void draw_rgb_32_image(
518 const Glib::RefPtr<const GC>& gc,
519 int x, int y, int width, int height,
520 RgbDither dith, const guchar* rgb_buf, int rowstride);
523 /** Like gdk_draw_rgb_32_image(), but allows you to specify the dither
524 * offsets. See gdk_draw_rgb_image_dithalign() for more details.
525 * @param gc A Gdk::GC.
526 * @param x X coordinate on @a drawable where image should go.
527 * @param y Y coordinate on @a drawable where image should go.
528 * @param width Width of area of image to draw.
529 * @param height Height of area of image to draw.
530 * @param dith Dithering mode.
531 * @param buf RGB image data.
532 * @param rowstride Rowstride of RGB image data.
533 * @param xdith X dither offset.
534 * @param ydith Y dither offset.
536 void draw_rgb_32_image_dithalign(
537 const Glib::RefPtr<const GC>& gc,
538 int x, int y, int width, int height,
539 RgbDither dith, const guchar* buf, int rowstride,
540 int xdith, int ydith);
543 void draw_gray_image(
544 const Glib::RefPtr<const GC>& gc,
545 int x, int y, int width, int height,
546 RgbDither dith, const guchar* rgb_buf, int rowstride);
549 void draw_indexed_image(
550 const Glib::RefPtr<const GC>& gc,
551 int x, int y, int width, int height,
552 RgbDither dith, const guchar* rgb_buf, int rowstride,
553 const RgbCmap& cmap);
556 /** Gets the Gdk::Screen associated with a Gdk::Drawable.
557 * @return The Gdk::Screen associated with @a drawable
561 Glib::RefPtr<Screen> get_screen();
563 /** Gets the Gdk::Screen associated with a Gdk::Drawable.
564 * @return The Gdk::Screen associated with @a drawable
568 Glib::RefPtr<const Screen> get_screen() const;
571 /** Gets the Gdk::Display associated with a Gdk::Drawable.
572 * @return The Gdk::Display associated with @a drawable
576 Glib::RefPtr<Display> get_display();
578 /** Gets the Gdk::Display associated with a Gdk::Drawable.
579 * @return The Gdk::Display associated with @a drawable
583 Glib::RefPtr<const Display> get_display() const;
586 /** Creates a Cairo context for drawing to @a drawable .
587 * @return A newly created Cairo context.
591 Cairo::RefPtr<Cairo::Context> create_cairo_context();
597 //C++ methods used to invoke GTK+ virtual functions:
598 #ifdef GLIBMM_VFUNCS_ENABLED
599 #endif //GLIBMM_VFUNCS_ENABLED
602 //GTK+ Virtual Functions (override these to change behaviour):
603 #ifdef GLIBMM_VFUNCS_ENABLED
604 #endif //GLIBMM_VFUNCS_ENABLED
606 //Default Signal Handlers::
607 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
608 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
618 /** A Glib::wrap() method for this object.
620 * @param object The C instance.
621 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
622 * @result A C++ instance that wraps this C instance.
624 * @relates Gdk::Drawable
626 Glib::RefPtr<Gdk::Drawable> wrap(GdkDrawable* object, bool take_copy = false);
630 #endif /* _GDKMM_DRAWABLE_H */