gtkmm: Gdk::Drawable Class Reference
Drawing Primitives. More...
Public Member Functions | |
Drawable (Drawable&& src) noexcept | |
Drawable& | operator= (Drawable&& src) noexcept |
~Drawable () noexceptoverride | |
GdkDrawable* | gobj () |
Provides access to the underlying C GObject. More... | |
const GdkDrawable* | gobj () const |
Provides access to the underlying C GObject. More... | |
GdkDrawable* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
void | get_size (int& width, int& height) |
Fills * width and * height with the size of drawable. More... | |
void | get_size (int& width, int& height) const |
Fills * width and * height with the size of drawable. More... | |
int | get_depth () const |
Obtains the bit depth of the drawable, that is, the number of bits that make up a pixel in the drawable's visual. More... | |
void | set_colormap (const Glib::RefPtr< Colormap >& colormap) |
Sets the colormap associated with drawable. More... | |
Glib::RefPtr< Colormap > | get_colormap () |
Gets the colormap for drawable, if one is set; returns nullptr otherwise. More... | |
Glib::RefPtr< Visual > | get_visual () |
Gets the Gdk::Visual describing the pixel format of drawable. More... | |
void | draw_point (const Glib::RefPtr< const GC >& gc, int x, int y) |
Draws a point, using the foreground color and other attributes of the Gdk::GC. More... | |
void | draw_points (const Glib::RefPtr< const GC >& gc, const Glib::ArrayHandle< Point >& points) |
void | draw_line (const Glib::RefPtr< const GC >& gc, int x1, int y1, int x2, int y2) |
Draws a line, using the foreground color and other attributes of the Gdk::GC. More... | |
void | draw_lines (const Glib::RefPtr< const GC >& gc, const Glib::ArrayHandle< Point >& points) |
void | draw_rectangle (const Glib::RefPtr< const GC >& gc, bool filled, int x, int y, int width, int height) |
Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the Gdk::GC. More... | |
void | draw_arc (const Glib::RefPtr< const GC >& gc, bool filled, int x, int y, int width, int height, int angle1, int angle2) |
Draws an arc or a filled 'pie slice'. More... | |
void | draw_polygon (const Glib::RefPtr< const GC >& gc, bool filled, const Glib::ArrayHandle< Point >& points) |
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) |
Copies the width x height region of src at coordinates ( xsrc, ysrc) to coordinates ( xdest, ydest) in drawable. More... | |
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) |
Draws a Gdk::Image onto a drawable. More... | |
void | draw_segments (const Glib::RefPtr< const GC >& gc, GdkSegment* segs, int nsegs) |
Draws a number of unconnected lines. More... | |
void | draw_glyphs (const Glib::RefPtr< const GC >& gc, const Glib::RefPtr< const Pango::Font >& font, int x, int y, const Pango::GlyphString& glyphs) |
This is a low-level function; 99% of text rendering should be done using gdk_draw_layout() instead. More... | |
void | draw_layout_line (const Glib::RefPtr< const GC >& gc, int x, int y, const Glib::RefPtr< const Pango::LayoutLine >& line) |
Render a Pango::LayoutLine onto an GDK drawable. More... | |
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) |
Render a Pango::LayoutLine onto a Gdk::Drawable, overriding the layout's normal colors with foreground and/or background. More... | |
void | draw_layout (const Glib::RefPtr< const GC >& gc, int x, int y, const Glib::RefPtr< const Pango::Layout >& layout) |
Render a Pango::Layout onto a GDK drawable. More... | |
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) |
Render a Pango::Layout onto a Gdk::Drawable, overriding the layout's normal colors with foreground and/or background. More... | |
void | draw_pixbuf (const Glib::RefPtr< const GC >& gc, const Glib::RefPtr< Pixbuf >& pixbuf, int src_x, int src_y, int dest_x, int dest_y, int width, int height, RgbDither dither, int x_dither, int y_dither) |
Renders a rectangular portion of a pixbuf to a drawable. More... | |
void | draw_pixbuf (const Glib::RefPtr< Pixbuf >& pixbuf, int src_x, int src_y, int dest_x, int dest_y, int width, int height, RgbDither dither, int x_dither, int y_dither) |
Renders a rectangular portion of a pixbuf to a drawable. More... | |
Glib::RefPtr< Image > | get_image (int x, int y, int width, int height) const |
A Gdk::Image stores client-side image data (pixels). More... | |
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 |
Region | get_clip_region () const |
Computes the region of a drawable that potentially can be written to by drawing primitives. More... | |
Region | get_visible_region () const |
Computes the region of a drawable that is potentially visible. More... | |
void | draw_rgb_image (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride) |
void | draw_rgb_image_dithalign (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride, int xdith, int ydith) |
void | draw_rgb_32_image (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride) |
void | draw_rgb_32_image_dithalign (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* buf, int rowstride, int xdith, int ydith) |
Like gdk_draw_rgb_32_image(), but allows you to specify the dither offsets. More... | |
void | draw_gray_image (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride) |
void | draw_indexed_image (const Glib::RefPtr< const GC >& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride, const RgbCmap& cmap) |
Glib::RefPtr< Screen > | get_screen () |
Gets the Gdk::Screen associated with a Gdk::Drawable. More... | |
Glib::RefPtr< const Screen > | get_screen () const |
Gets the Gdk::Screen associated with a Gdk::Drawable. More... | |
Glib::RefPtr< Display > | get_display () |
Gets the Gdk::Display associated with a Gdk::Drawable. More... | |
Glib::RefPtr< const Display > | get_display () const |
Gets the Gdk::Display associated with a Gdk::Drawable. More... | |
Cairo::RefPtr< Cairo::Context > | create_cairo_context () |
Creates a Cairo context for drawing to drawable. More... | |
Public Member Functions inherited from Glib::Object | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark &key) |
void | set_data (const Quark &key, void *data) |
void | set_data (const Quark &key, void *data, DestroyNotify notify) |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value) |
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const |
void | set_property (const Glib::ustring &property_name, const PropertyType &value) |
void | get_property (const Glib::ustring &property_name, PropertyType &value) const |
void | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot) |
void | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot) |
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot) |
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot) |
void | freeze_notify () |
void | thaw_notify () |
virtual void | reference () const |
virtual void | unreference () const |
GObject * | gobj () |
const GObject * | gobj () const |
GObject * | gobj_copy () const |
Public Member Functions inherited from sigc::trackable | |
trackable () noexcept | |
trackable (const trackable &src) noexcept | |
trackable (trackable &&src) | |
~trackable () | |
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const |
void | notify_callbacks () |
trackable & | operator= (const trackable &src) |
trackable & | operator= (trackable &&src) |
void | remove_destroy_notify_callback (void *data) const |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
static Glib::RefPtr< Drawable > | create () |
Protected Member Functions | |
Drawable () | |
Protected Member Functions inherited from Glib::Object | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexceptoverride | |
Protected Member Functions inherited from Glib::ObjectBase | |
ObjectBase () | |
ObjectBase (const char *custom_type_name) | |
ObjectBase (const std::type_info &custom_type_info) | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gdk::Drawable > | wrap (GdkDrawable* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Additional Inherited Members | |
Public Types inherited from Glib::Object | |
typedef void(*)(gpointer data | DestroyNotify) |
Public Types inherited from sigc::trackable | |
typedef internal::func_destroy_notify | func_destroy_notify |
Detailed Description
Drawing Primitives.
Gdk::Drawable is the base class for all of the objects that accept drawing commands. The available drawables include pixmaps, windows, and bitmaps. Drawable is abstract as there is no such type on the server side.
To use a drawable, create a concrete Drawable of the type you wish to use and a Gdk::GC (graphics context) for that Drawable. With the GC you can draw lines, text, arcs and such.
An alternative is to create a Cairo::Context with get_cairo_context() while you handle the 'exposed' event of the drawable. For more about this, please see "Using cairo with GTK+" in the "Common questions" section of the GTK+ Reference Manual.
Constructor & Destructor Documentation
|
noexcept |
|
overridenoexcept |
|
protected |
Member Function Documentation
void Gdk::Drawable::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 |
|
static |
Cairo::RefPtr<Cairo::Context> Gdk::Drawable::create_cairo_context | ( | ) |
void Gdk::Drawable::draw_arc | ( | const Glib::RefPtr< const GC >& | gc, |
bool | filled, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | angle1, | ||
int | angle2 | ||
) |
Draws an arc or a filled 'pie slice'.
The arc is defined by the bounding rectangle of the entire ellipse, and the start and end angles of the part of the ellipse to be drawn.
Deprecated: 2.22: Use cairo_arc() and cairo_fill() or cairo_stroke() instead. Note that arcs just like any drawing operation in Cairo are antialiased unless you call cairo_set_antialias().
- Parameters
-
gc A Gdk::GC. filled true
if the arc should be filled, producing a 'pie slice'.x The x coordinate of the left edge of the bounding rectangle. y The y coordinate of the top edge of the bounding rectangle. width The width of the bounding rectangle. height The height of the bounding rectangle. angle1 The start angle of the arc, relative to the 3 o'clock position, counter-clockwise, in 1/64ths of a degree. angle2 The end angle of the arc, relative to angle1, in 1/64ths of a degree.
void Gdk::Drawable::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 |
||
) |
Copies the width x height region of src at coordinates ( xsrc, ysrc) to coordinates ( xdest, ydest) in drawable.
width and/or height may be given as -1, in which case the entire src drawable will be copied.
Most fields in gc are not used for this operation, but notably the clip mask or clip region will be honored.
The source and destination drawables must have the same visual and colormap, or errors will result. (On X11, failure to match visual/colormap results in a BadMatch error from the X server.) A common cause of this problem is an attempt to draw a bitmap to a color drawable. The way to draw a bitmap is to set the bitmap as the stipple on the Gdk::GC, set the fill mode to Gdk::STIPPLED, and then draw the rectangle.
Deprecated: 2.22: Use gdk_cairo_set_source_pixmap(), cairo_rectangle() and cairo_fill() to draw pixmap on top of other drawables. Also keep in mind that the limitations on allowed sources do not apply to Cairo.
- Parameters
-
gc A Gdk::GC sharing the drawable's visual and colormap. src The source Gdk::Drawable, which may be the same as drawable. xsrc X position in src of rectangle to draw. ysrc Y position in src of rectangle to draw. xdest X position in drawable where the rectangle should be drawn. ydest Y position in drawable where the rectangle should be drawn. width Width of rectangle to draw, or -1 for entire src width. height Height of rectangle to draw, or -1 for entire src height.
void Gdk::Drawable::draw_glyphs | ( | const Glib::RefPtr< const GC >& | gc, |
const Glib::RefPtr< const Pango::Font > & | font, | ||
int | x, | ||
int | y, | ||
const Pango::GlyphString & | glyphs | ||
) |
This is a low-level function; 99% of text rendering should be done using gdk_draw_layout() instead.
A glyph is a single image in a font. This function draws a sequence of glyphs. To obtain a sequence of glyphs you have to understand a lot about internationalized text handling, which you don't want to understand; thus, use gdk_draw_layout() instead of this function, gdk_draw_layout() handles the details.
Deprecated: 2.22: Use pango_cairo_show_glyphs() instead.
- Parameters
-
gc A Gdk::GC. font Font to be used. x X coordinate of baseline origin. y Y coordinate of baseline origin. glyphs The glyph string to draw.
void Gdk::Drawable::draw_gray_image | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | rgb_buf, | ||
int | rowstride | ||
) |
void Gdk::Drawable::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 |
||
) |
Draws a Gdk::Image onto a drawable.
The depth of the Gdk::Image must match the depth of the Gdk::Drawable.
Deprecated: 2.22: Do not use Gdk::Image anymore, instead use Cairo image surfaces.
- Parameters
-
gc A Gdk::GC. image The Gdk::Image to draw. xsrc The left edge of the source rectangle within image. ysrc The top of the source rectangle within image. xdest The x coordinate of the destination within drawable. ydest The y coordinate of the destination within drawable. width The width of the area to be copied, or -1 to make the area extend to the right edge of image. height The height of the area to be copied, or -1 to make the area extend to the bottom edge of image.
void Gdk::Drawable::draw_indexed_image | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | rgb_buf, | ||
int | rowstride, | ||
const RgbCmap& | cmap | ||
) |
void Gdk::Drawable::draw_layout | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
const Glib::RefPtr< const Pango::Layout > & | layout | ||
) |
Render a Pango::Layout onto a GDK drawable.
If the layout's Pango::Context has a transformation matrix set, then x and y specify the position of the top left corner of the bounding box (in device space) of the transformed layout.
If you're using GTK+, the usual way to obtain a Pango::Layout is gtk_widget_create_pango_layout().
- Parameters
-
gc Base graphics context to use. x The X position of the left of the layout (in pixels). y The Y position of the top of the layout (in pixels). layout A Pango::Layout.
void Gdk::Drawable::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 | ||
) |
Render a Pango::Layout onto a Gdk::Drawable, overriding the layout's normal colors with foreground and/or background.
foreground and background need not be allocated.
If the layout's Pango::Context has a transformation matrix set, then x and y specify the position of the top left corner of the bounding box (in device space) of the transformed layout.
If you're using GTK+, the ususal way to obtain a Pango::Layout is gtk_widget_create_pango_layout().
- Parameters
-
gc Base graphics context to use. x The X position of the left of the layout (in pixels). y The Y position of the top of the layout (in pixels). layout A Pango::Layout. foreground Foreground override color, or nullptr
for none.background Background override color, or nullptr
for none.
void Gdk::Drawable::draw_layout_line | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
const Glib::RefPtr< const Pango::LayoutLine > & | line | ||
) |
Render a Pango::LayoutLine onto an GDK drawable.
If the layout's Pango::Context has a transformation matrix set, then x and y specify the position of the left edge of the baseline (left is in before-tranform user coordinates) in after-transform device coordinates.
- Parameters
-
gc Base graphics to use. x The x position of start of string (in pixels). y The y position of baseline (in pixels). line A Pango::LayoutLine.
void Gdk::Drawable::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 | ||
) |
Render a Pango::LayoutLine onto a Gdk::Drawable, overriding the layout's normal colors with foreground and/or background.
foreground and background need not be allocated.
If the layout's Pango::Context has a transformation matrix set, then x and y specify the position of the left edge of the baseline (left is in before-tranform user coordinates) in after-transform device coordinates.
- Parameters
-
gc Base graphics to use. x The x position of start of string (in pixels). y The y position of baseline (in pixels). line A Pango::LayoutLine. foreground Foreground override color, or nullptr
for none.background Background override color, or nullptr
for none.
void Gdk::Drawable::draw_line | ( | const Glib::RefPtr< const GC >& | gc, |
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Draws a line, using the foreground color and other attributes of the Gdk::GC.
Deprecated: 2.22: Use cairo_line_to() and cairo_stroke() instead. Be aware that the default line width in Cairo is 2 pixels and that your coordinates need to describe the center of the line. To draw a single pixel wide pixel-aligned line, you would use:
[C example ellipted] See also the Cairo FAQ on this topic.
- Parameters
-
gc A Gdk::GC. x1 The x coordinate of the start point. y1 The y coordinate of the start point. x2 The x coordinate of the end point. y2 The y coordinate of the end point.
void Gdk::Drawable::draw_lines | ( | const Glib::RefPtr< const GC >& | gc, |
const Glib::ArrayHandle< Point >& | points | ||
) |
- Deprecated:
- Use cairo_line_to() and cairo_stroke() instead.
See the documentation of gdk_draw_line() for notes on line drawing with Cairo.
void Gdk::Drawable::draw_pixbuf | ( | const Glib::RefPtr< const GC >& | gc, |
const Glib::RefPtr< Pixbuf >& | pixbuf, | ||
int | src_x, | ||
int | src_y, | ||
int | dest_x, | ||
int | dest_y, | ||
int | width, | ||
int | height, | ||
RgbDither | dither, | ||
int | x_dither, | ||
int | y_dither | ||
) |
Renders a rectangular portion of a pixbuf to a drawable.
The destination drawable must have a colormap. All windows have a colormap, however, pixmaps only have colormap by default if they were created with a non-nullptr
window argument. Otherwise a colormap must be set on them with Gdk::Drawable::set_colormap().
On older X servers, rendering pixbufs with an alpha channel involves round trips to the X server, and may be somewhat slow.
The clip mask of gc is ignored, but clip rectangles and clip regions work fine.
If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf function is accelerated using mediaLib, which provides hardware acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib support can be turned off by setting the GDK_DISABLE_MEDIALIB environment variable.
- Parameters
-
gc A Gdk::GC, used for clipping. pixbuf A Gdk::Pixbuf. src_x Source X coordinate within pixbuf. src_y Source Y coordinates within pixbuf. dest_x Destination X coordinate within drawable. dest_y Destination Y coordinate within drawable. width Width of region to render, in pixels, or -1 to use pixbuf width. height Height of region to render, in pixels, or -1 to use pixbuf height. dither Dithering mode for Gdk::RGB. x_dither X offset for dither. y_dither Y offset for dither.
void Gdk::Drawable::draw_pixbuf | ( | const Glib::RefPtr< Pixbuf >& | pixbuf, |
int | src_x, | ||
int | src_y, | ||
int | dest_x, | ||
int | dest_y, | ||
int | width, | ||
int | height, | ||
RgbDither | dither, | ||
int | x_dither, | ||
int | y_dither | ||
) |
Renders a rectangular portion of a pixbuf to a drawable.
The destination drawable must have a colormap. All windows have a colormap, however, pixmaps only have colormap by default if they were created with a non-0
window argument. Otherwise a colormap must be set on them with Gdk::Drawable::set_colormap().
On older X servers, rendering pixbufs with an alpha channel involves round trips to the X server, and may be somewhat slow.
If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf function is accelerated using mediaLib, which provides hardware acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib support can be turned off by setting the GDK_DISABLE_MEDIALIB environment variable.
- Parameters
-
pixbuf A Gdk::Pixbuf. src_x Source X coordinate within pixbuf. src_y Source Y coordinates within pixbuf. dest_x Destination X coordinate within drawable. dest_y Destination Y coordinate within drawable. width Width of region to render, in pixels, or -1 to use pixbuf width. height Height of region to render, in pixels, or -1 to use pixbuf height. dither Dithering mode for Gdk::RGB. x_dither X offset for dither. y_dither Y offset for dither.
- Deprecated:
- Use gdk_cairo_set_source_pixbuf() and cairo_paint() or cairo_rectangle() and cairo_fill() instead.
void Gdk::Drawable::draw_point | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y | ||
) |
void Gdk::Drawable::draw_points | ( | const Glib::RefPtr< const GC >& | gc, |
const Glib::ArrayHandle< Point >& | points | ||
) |
- Deprecated:
- Use n_points calls to cairo_rectangle() and cairo_fill() instead.
void Gdk::Drawable::draw_polygon | ( | const Glib::RefPtr< const GC >& | gc, |
bool | filled, | ||
const Glib::ArrayHandle< Point >& | points | ||
) |
void Gdk::Drawable::draw_rectangle | ( | const Glib::RefPtr< const GC >& | gc, |
bool | filled, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the Gdk::GC.
A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle outlined. Calling gdk_draw_rectangle (window, gc,
results in a filled rectangle 20 pixels wide and 20 pixels high. Calling true
, 0, 0, 20, 20)gdk_draw_rectangle (window, gc,
results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high.false
, 0, 0, 20, 20)
Deprecated: 2.22: Use cairo_rectangle() and cairo_fill() or cairo_stroke() instead. For stroking, the same caveats for converting code apply as for gdk_draw_line().
- Parameters
-
gc A Gdk::GC. filled true
if the rectangle should be filled.x The x coordinate of the left edge of the rectangle. y The y coordinate of the top edge of the rectangle. width The width of the rectangle. height The height of the rectangle.
void Gdk::Drawable::draw_rgb_32_image | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | rgb_buf, | ||
int | rowstride | ||
) |
void Gdk::Drawable::draw_rgb_32_image_dithalign | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | buf, | ||
int | rowstride, | ||
int | xdith, | ||
int | ydith | ||
) |
Like gdk_draw_rgb_32_image(), but allows you to specify the dither offsets.
See gdk_draw_rgb_image_dithalign() for more details.
Deprecated: 2.22: Cairo handles colors automatically.
- Parameters
-
gc A Gdk::GC. x X coordinate on drawable where image should go. y Y coordinate on drawable where image should go. width Width of area of image to draw. height Height of area of image to draw. dith Dithering mode. buf RGB image data. rowstride Rowstride of RGB image data. xdith X dither offset. ydith Y dither offset.
void Gdk::Drawable::draw_rgb_image | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | rgb_buf, | ||
int | rowstride | ||
) |
void Gdk::Drawable::draw_rgb_image_dithalign | ( | const Glib::RefPtr< const GC >& | gc, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
RgbDither | dith, | ||
const guchar * | rgb_buf, | ||
int | rowstride, | ||
int | xdith, | ||
int | ydith | ||
) |
void Gdk::Drawable::draw_segments | ( | const Glib::RefPtr< const GC >& | gc, |
GdkSegment * | segs, | ||
int | nsegs | ||
) |
Draws a number of unconnected lines.
Deprecated: 2.22: Use cairo_move_to(), cairo_line_to() and cairo_stroke() instead. See the documentation of gdk_draw_line() for notes on line drawing with Cairo.
- Parameters
-
gc A Gdk::GC. segs An array of Gdk::Segment structures specifying the start and end points of the lines to be drawn. nsegs The number of line segments to draw, i.e. the size of the segs array.
Region Gdk::Drawable::get_clip_region | ( | ) | const |
Computes the region of a drawable that potentially can be written to by drawing primitives.
This region will not take into account the clip region for the GC, and may also not take into account other factors such as if the window is obscured by other windows, but no area outside of this region will be affected by drawing primitives.
- Returns
- A Gdk::Region. This must be freed with Gdk::Region::destroy() when you are done.
Glib::RefPtr<Colormap> Gdk::Drawable::get_colormap | ( | ) |
Gets the colormap for drawable, if one is set; returns nullptr
otherwise.
- Returns
- The colormap, or
nullptr
.
int Gdk::Drawable::get_depth | ( | ) | const |
Obtains the bit depth of the drawable, that is, the number of bits that make up a pixel in the drawable's visual.
Examples are 8 bits per pixel, 24 bits per pixel, etc.
- Returns
- Number of bits per pixel.
Glib::RefPtr<Display> Gdk::Drawable::get_display | ( | ) |
Gets the Gdk::Display associated with a Gdk::Drawable.
Deprecated: 2.24: Use Gdk::Window::get_display() instead
- Returns
- The Gdk::Display associated with drawable.
Glib::RefPtr<const Display> Gdk::Drawable::get_display | ( | ) | const |
Gets the Gdk::Display associated with a Gdk::Drawable.
Deprecated: 2.24: Use Gdk::Window::get_display() instead
- Returns
- The Gdk::Display associated with drawable.
Glib::RefPtr<Image> Gdk::Drawable::get_image | ( | int | x, |
int | y, | ||
int | width, | ||
int | height | ||
) | const |
A Gdk::Image stores client-side image data (pixels).
In contrast, Gdk::Pixmap and Gdk::Window are server-side objects. get_image() obtains the pixels from a server-side drawable as a client-side Gdk::Image. The format of a Gdk::Image depends on the Gdk::Visual of the current display, which makes manipulating Gdk::Image extremely difficult; therefore, in most cases you should use the Gdk::Pixbuf::create() method that takes a Gdk::Drawable, instead of this lower-level function. A Gdk::Pixbuf contains image data in a canonicalized RGB format, rather than a display-dependent format. Of course, there's a convenience vs. speed tradeoff here, so you'll want to think about what makes sense for your application.
x, y, width, and height define the region of drawable to obtain as an image.
You would usually copy image data to the client side if you intend to examine the values of individual pixels, for example to darken an image or add a red tint. It would be prohibitively slow to make a round-trip request to the windowing system for each pixel, so instead you get all of them at once, modify them, then copy them all back at once.
If the X server or other windowing system backend is on the local machine, this function may use shared memory to avoid copying the image data.
If the source drawable is a Gdk::Window and partially offscreen or obscured, then the obscured portions of the returned image will contain undefined data.
- Parameters
-
x X coordinate on drawable. y Y coordinate on drawable. width Width of region to get. height Height or region to get.
- Returns
- A Gdk::Image containing the contents of drawable.
Glib::RefPtr<Screen> Gdk::Drawable::get_screen | ( | ) |
Gets the Gdk::Screen associated with a Gdk::Drawable.
Deprecated: 2.24: Use Gdk::Window::get_screen() instead
- Returns
- The Gdk::Screen associated with drawable.
Glib::RefPtr<const Screen> Gdk::Drawable::get_screen | ( | ) | const |
Gets the Gdk::Screen associated with a Gdk::Drawable.
Deprecated: 2.24: Use Gdk::Window::get_screen() instead
- Returns
- The Gdk::Screen associated with drawable.
void Gdk::Drawable::get_size | ( | int & | width, |
int & | height | ||
) |
Fills * width and * height with the size of drawable.
width or height can be nullptr
if you only want the other one.
On the X11 platform, if drawable is a Gdk::Window, the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
Deprecated: 2.24: Use Gdk::Window::get_width() and Gdk::Window::get_height() for Gdk::Windows. Use gdk_pixmap_get_size() for Gdk::Pixmaps.
- Deprecated:
- Use the const version of this method.
- Parameters
-
width Location to store drawable's width, or nullptr
.height Location to store drawable's height, or nullptr
.
void Gdk::Drawable::get_size | ( | int & | width, |
int & | height | ||
) | const |
Fills * width and * height with the size of drawable.
width or height can be nullptr
if you only want the other one.
On the X11 platform, if drawable is a Gdk::Window, the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
Deprecated: 2.24: Use Gdk::Window::get_width() and Gdk::Window::get_height() for Gdk::Windows. Use gdk_pixmap_get_size() for Gdk::Pixmaps.
- Parameters
-
width Location to store drawable's width, or nullptr
.height Location to store drawable's height, or nullptr
.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
Region Gdk::Drawable::get_visible_region | ( | ) | const |
Computes the region of a drawable that is potentially visible.
This does not necessarily take into account if the window is obscured by other windows, but no area outside of this region is visible.
- Returns
- A Gdk::Region. This must be freed with Gdk::Region::destroy() when you are done.
Glib::RefPtr<Visual> Gdk::Drawable::get_visual | ( | ) |
Gets the Gdk::Visual describing the pixel format of drawable.
Deprecated: 2.24: Use Gdk::Window::get_visual()
- Returns
- A Gdk::Visual.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GdkDrawable* Gdk::Drawable::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void Gdk::Drawable::set_colormap | ( | const Glib::RefPtr< Colormap >& | colormap | ) |
Sets the colormap associated with drawable.
Normally this will happen automatically when the drawable is created; you only need to use this function if the drawable-creating function did not have a way to determine the colormap, and you then use drawable operations that require a colormap. The colormap for all drawables and graphics contexts you intend to use together should match. i.e. when using a Gdk::GC to draw to a drawable, or copying one drawable to another, the colormaps should match.
- Parameters
-
colormap A Gdk::Colormap.
Friends And Related Function Documentation
|
related |
A Glib::wrap() method for this object.
- Parameters
-
object The C instance. take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
- Returns
- A C++ instance that wraps this C instance.
The documentation for this class was generated from the following file:
- gdkmm/drawable.h