GDK 2 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <gdk/gdk.h> struct GdkPoint; struct GdkRectangle; gboolean gdk_rectangle_intersect (const GdkRectangle *src1
,const GdkRectangle *src2
,GdkRectangle *dest
); void gdk_rectangle_union (const GdkRectangle *src1
,const GdkRectangle *src2
,GdkRectangle *dest
); GdkRegion; GdkRegion * gdk_region_new (void
); GdkRegion * gdk_region_polygon (const GdkPoint *points
,gint n_points
,GdkFillRule fill_rule
); enum GdkFillRule; GdkRegion * gdk_region_copy (const GdkRegion *region
); GdkRegion * gdk_region_rectangle (const GdkRectangle *rectangle
); void gdk_region_destroy (GdkRegion *region
); void gdk_region_get_clipbox (const GdkRegion *region
,GdkRectangle *rectangle
); void gdk_region_get_rectangles (const GdkRegion *region
,GdkRectangle **rectangles
,gint *n_rectangles
); gboolean gdk_region_empty (const GdkRegion *region
); gboolean gdk_region_equal (const GdkRegion *region1
,const GdkRegion *region2
); gboolean gdk_region_rect_equal (const GdkRegion *region
,const GdkRectangle *rectangle
); gboolean gdk_region_point_in (const GdkRegion *region
,int x
,int y
); GdkOverlapType gdk_region_rect_in (const GdkRegion *region
,const GdkRectangle *rectangle
); enum GdkOverlapType; void gdk_region_offset (GdkRegion *region
,gint dx
,gint dy
); void gdk_region_shrink (GdkRegion *region
,gint dx
,gint dy
); void gdk_region_union_with_rect (GdkRegion *region
,const GdkRectangle *rect
); void gdk_region_intersect (GdkRegion *source1
,const GdkRegion *source2
); void gdk_region_union (GdkRegion *source1
,const GdkRegion *source2
); void gdk_region_subtract (GdkRegion *source1
,const GdkRegion *source2
); void gdk_region_xor (GdkRegion *source1
,const GdkRegion *source2
); struct GdkSpan; void (*GdkSpanFunc) (GdkSpan *span
,gpointer data
); void gdk_region_spans_intersect_foreach (GdkRegion *region
,const GdkSpan *spans
,int n_spans
,gboolean sorted
,GdkSpanFunc function
,gpointer data
);
GDK provides the GdkPoint, GdkRectangle, GdkRegion and GdkSpan data types for representing pixels and sets of pixels on the screen.
GdkPoint is a simple structure containing an x and y coordinate of a point.
GdkRectangle is a structure holding the position and size of a rectangle.
The intersection of two rectangles can be computed with
gdk_rectangle_intersect()
. To find the union of two rectangles use
gdk_rectangle_union()
.
GdkRegion is an opaque data type holding a set of arbitrary pixels, and is
usually used for clipping graphical operations (see gdk_gc_set_clip_region()
).
GdkSpan is a structure holding a spanline. A spanline is a horizontal line that
is one pixel wide. It is mainly used when rasterizing other graphics primitives.
It can be intersected to regions by using gdk_region_spans_intersect_foreach()
.
struct GdkRectangle { gint x; gint y; gint width; gint height; };
Defines the position and size of a rectangle.
gboolean gdk_rectangle_intersect (const GdkRectangle *src1
,const GdkRectangle *src2
,GdkRectangle *dest
);
Calculates the intersection of two rectangles. It is allowed for
dest
to be the same as either src1
or src2
. If the rectangles
do not intersect, dest
's width and height is set to 0 and its x
and y values are undefined. If you are only interested in whether
the rectangles intersect, but not in the intersecting area itself,
pass NULL
for dest
.
|
a GdkRectangle |
|
a GdkRectangle |
|
return location for the
intersection of src1 and src2 , or NULL . [out caller-allocates][allow-none]
|
Returns : |
TRUE if the rectangles intersect. |
void gdk_rectangle_union (const GdkRectangle *src1
,const GdkRectangle *src2
,GdkRectangle *dest
);
Calculates the union of two rectangles.
The union of rectangles src1
and src2
is the smallest rectangle which
includes both src1
and src2
within it.
It is allowed for dest
to be the same as either src1
or src2
.
|
a GdkRectangle |
|
a GdkRectangle |
|
return location for the union of src1 and src2 . [out]
|
typedef struct _GdkRegion GdkRegion;
A GdkRegion represents a set of pixels on the screen.
In GTK3, GdkRegion will be replaced by cairo_region_t. All the functions listed in this section will go away and you will have to use the relevant Cairo functions. The conversion can be done using simple serch and replace.
GdkRegion * gdk_region_new (void
);
Creates a new empty GdkRegion.
Returns : |
a new empty GdkRegion |
GdkRegion * gdk_region_polygon (const GdkPoint *points
,gint n_points
,GdkFillRule fill_rule
);
gdk_region_polygon
has been deprecated since version 2.22 and should not be used in newly-written code. There is no replacement. For working with paths, please
use Cairo.
Creates a new GdkRegion using the polygon defined by a number of points.
typedef enum { GDK_EVEN_ODD_RULE, GDK_WINDING_RULE } GdkFillRule;
GdkFillRule
is deprecated and should not be used in newly-written code.
The method for determining which pixels are included in a region, when creating a GdkRegion from a polygon. The fill rule is only relevant for polygons which overlap themselves.
GdkRegion * gdk_region_copy (const GdkRegion *region
);
Copies region
, creating an identical new region.
|
a GdkRegion |
Returns : |
a new region identical to region
|
GdkRegion * gdk_region_rectangle (const GdkRectangle *rectangle
);
Creates a new region containing the area rectangle
.
|
a GdkRectangle |
Returns : |
a new region |
void gdk_region_destroy (GdkRegion *region
);
Destroys a GdkRegion.
|
a GdkRegion |
void gdk_region_get_clipbox (const GdkRegion *region
,GdkRectangle *rectangle
);
Obtains the smallest rectangle which includes the entire GdkRegion.
|
a GdkRegion |
|
return location for the clipbox |
void gdk_region_get_rectangles (const GdkRegion *region
,GdkRectangle **rectangles
,gint *n_rectangles
);
Obtains the area covered by the region as a list of rectangles.
The array returned in rectangles
must be freed with g_free()
.
|
a GdkRegion |
|
return location for an array of rectangles. [array length=n_rectangles][transfer container] |
|
length of returned array |
gboolean gdk_region_empty (const GdkRegion *region
);
Finds out if the GdkRegion is empty.
gboolean gdk_region_equal (const GdkRegion *region1
,const GdkRegion *region2
);
Finds out if the two regions are the same.
gboolean gdk_region_rect_equal (const GdkRegion *region
,const GdkRectangle *rectangle
);
gdk_region_rect_equal
has been deprecated since version 2.22 and should not be used in newly-written code. Use gdk_region_new_rect()
and gdk_region_equal()
to
achieve the same effect.
Finds out if a regions is the same as a rectangle.
|
a GdkRegion |
|
a GdkRectangle |
Returns : |
TRUE if region and rectangle are equal. |
Since 2.18
gboolean gdk_region_point_in (const GdkRegion *region
,int x
,int y
);
Finds out if a point is in a region.
GdkOverlapType gdk_region_rect_in (const GdkRegion *region
,const GdkRectangle *rectangle
);
Tests whether a rectangle is within a region.
|
a GdkRegion. |
|
a GdkRectangle. |
Returns : |
GDK_OVERLAP_RECTANGLE_IN , GDK_OVERLAP_RECTANGLE_OUT , or
GDK_OVERLAP_RECTANGLE_PART , depending on whether the rectangle is inside,
outside, or partly inside the GdkRegion, respectively. |
typedef enum { GDK_OVERLAP_RECTANGLE_IN, GDK_OVERLAP_RECTANGLE_OUT, GDK_OVERLAP_RECTANGLE_PART } GdkOverlapType;
Specifies the possible values returned by gdk_region_rect_in()
.
void gdk_region_offset (GdkRegion *region
,gint dx
,gint dy
);
Moves a region the specified distance.
|
a GdkRegion |
|
the distance to move the region horizontally |
|
the distance to move the region vertically |
void gdk_region_shrink (GdkRegion *region
,gint dx
,gint dy
);
gdk_region_shrink
has been deprecated since version 2.22 and should not be used in newly-written code. There is no replacement for this function.
Resizes a region by the specified amount. Positive values shrink the region. Negative values expand it.
|
a GdkRegion |
|
the number of pixels to shrink the region horizontally |
|
the number of pixels to shrink the region vertically |
void gdk_region_union_with_rect (GdkRegion *region
,const GdkRectangle *rect
);
Sets the area of region
to the union of the areas of region
and
rect
. The resulting area is the set of pixels contained in
either region
or rect
.
|
a GdkRegion. |
|
a GdkRectangle. |
void gdk_region_intersect (GdkRegion *source1
,const GdkRegion *source2
);
Sets the area of source1
to the intersection of the areas of source1
and source2
. The resulting area is the set of pixels contained in
both source1
and source2
.
void gdk_region_union (GdkRegion *source1
,const GdkRegion *source2
);
Sets the area of source1
to the union of the areas of source1
and
source2
. The resulting area is the set of pixels contained in
either source1
or source2
.
void gdk_region_subtract (GdkRegion *source1
,const GdkRegion *source2
);
Subtracts the area of source2
from the area source1
. The resulting
area is the set of pixels contained in source1
but not in source2
.
void gdk_region_xor (GdkRegion *source1
,const GdkRegion *source2
);
Sets the area of source1
to the exclusive-OR of the areas of source1
and source2
. The resulting area is the set of pixels contained in one
or the other of the two sources but not in both.
struct GdkSpan { gint x; gint y; gint width; };
A GdkSpan represents a horizontal line of pixels starting
at the pixel with coordinates x
, y
and ending before x
+ width
, y
.
void (*GdkSpanFunc) (GdkSpan *span
,gpointer data
);
GdkSpanFunc
is deprecated and should not be used in newly-written code.
This defines the type of the function passed to
gdk_region_spans_intersect_foreach()
.
|
a GdkSpan. |
|
the user data passed to gdk_region_spans_intersect_foreach() . |
void gdk_region_spans_intersect_foreach (GdkRegion *region
,const GdkSpan *spans
,int n_spans
,gboolean sorted
,GdkSpanFunc function
,gpointer data
);
gdk_region_spans_intersect_foreach
has been deprecated since version 2.22 and should not be used in newly-written code. There is no replacement.
Calls a function on each span in the intersection of region
and spans
.