gtk.gdk.Region
Prev | The gtk.gdk Class Reference | Next

## gtk.gdk.Region

gtk.gdk.Region — an object representing a set of pixels on the screen (new in PyGTK 2.10)

## Synopsis

    class gtk.gdk.Region(gobject.GBoxed):
        gtk.gdk.Region()
        def get_clipbox()
        def empty()
        def equal(other)
        def point_in(x, y)
        def rect_in(rect)
        def copy()
        def offset(dx, dy)
        def shrink(dx, dy)
        def union_with_rect(rect)
        def intersect(source2)
        def union(source2)
        def subtract(source2)
        def xor(source2)

    Functions

        def gtk.gdk.region_rectangle(rectangle)

## Description

A `gtk.gdk.Region` is an objrect holding a set of arbitrary pixels, and is usually used for clipping graphical operations (see the `gtk.gdk.GC.set_clip_region`() method).

Starting with PyGTK 2.14 `gtk.gdk.Region` objects are properly comparable. By Python rules, regions (being mutable) are now unhashable.

## Constructor

        gtk.gdk.Region()

Returns : | a new `gtk.gdk.Region` object

### Note

This constructor is available in PyGTK 2.10 and above.

Creates a new `gtk.gdk.Region`.

## Methods

### gtk.gdk.Region.get_clipbox

        def get_clipbox()

Returns : | returns the smallest rectangle which includes all of the region.

### Note

This method is available in PyGTK 2.10 and above.

The `get_clipbox`() method returns the smallest rectangle which includes the entire region.

### gtk.gdk.Region.empty

        def empty()

Returns : | True if the region is empty.

### Note

This method is available in PyGTK 2.10 and above.

The `empty`() method returns True if the region is empty.

### gtk.gdk.Region.equal

        def equal(other)

`other` : | a `gtk.gdk.Region`
Returns : | True if the region is equal to `other`

### Note

This method is available in PyGTK 2.10 and above.

The `equal`() method returns True if the region specified by `other` is equal to this region.

### Note

Since PyGTK 2.14 Python comparison operator (`==`) can be used for the same result.

### gtk.gdk.Region.point_in

        def point_in(x, y)

`x` : | the x coordinate of a point.
`y` : | the y coordinate of a point.
Returns : | True if the point (x,y) is in the region.

### Note

This method is available in PyGTK 2.10 and above.

The ``() method returns True if the point specified by the coordinates `x` and `y` is in a region.

### gtk.gdk.Region.rect_in

        def rect_in(rect)

`rect` : | a rectangle (`gtk.gdk.Rectangle` or 4-tuple representing a rectangle)
Returns : | a value indicating whether `rectangle` is inside or outside the region.

### Note

This method is available in PyGTK 2.10 and above.

The `rect_in`() method returns one of the GDK Overlap Type Constants depending whether the rectangle specified by `rect` is inside, outside, or partly inside this region.

### gtk.gdk.Region.copy

        def copy()

Returns : | a new `gtk.gdk.Region` identical to the region

### Note

This method is available in PyGTK 2.10 and above.

The `copy`() method returns a new `gtk.gdk.Region` identical to this region.

### gtk.gdk.Region.offset

        def offset(dx, dy)

`dx` : | the distance to move this region horizontally.
`dy` : | the distance to move this region vertically.

### Note

This method is available in PyGTK 2.10 and above.

The `offset`() method moves this region the distance specified by `dx` and `dy`.

### gtk.gdk.Region.shrink

        def shrink(dx, dy)

`dx` : | the number of pixels to shrink this region horizontally.
`dy` : | the number of pixels to shrink this region vertically.

### Note

This method is available in PyGTK 2.10 and above.

The `shrink`() method resizes this region by the amount specified by `dx` and `dy`. Positive values shrink the region. Negative values expand it.

### gtk.gdk.Region.union_with_rect

        def union_with_rect(rect)

`rect` : | a rectangle

### Note

This method is available in PyGTK 2.10 and above.

The `union_with_rect`() method sets the area of this region to the union of the areas of this region and the rectangle specified by `rect`. The resulting area is the set of pixels contained in either the region or `rect`. The value of `rect` is either a `gtk.gdk.Rectangle` or a 4-tuple containing the position and size of a rectangle.

### gtk.gdk.Region.intersect

        def intersect(source2)

`source2` : | a `gtk.gdk.Region`

### Note

This method is available in PyGTK 2.10 and above.

The `intersect`() method sets the area of this region to the intersection of the areas of this region and the region specified by `source2`. The resulting area is the set of pixels contained in both this region and `source2`.

### gtk.gdk.Region.union

        def union(source2)

`source2` : | a `gtk.gdk.Region`.

### Note

This method is available in PyGTK 2.10 and above.

The `union`() method sets the area of this region to the union of the areas of this region and the region specified by `source2`. The resulting area is the set of pixels contained in either this region or `source2`.

### gtk.gdk.Region.subtract

        def subtract(source2)

`source2` : | a `gtk.gdk.Region`.

### Note

This method is available in PyGTK 2.10 and above.

The `subtract`() method sets the area of this region to the subtraction of the areas of this region and the region specified by `source2`. The resulting area is the set of pixels contained in this region but not in `source2`.

### gtk.gdk.Region.xor

        def xor(source2)

`source2` : | a `gtk.gdk.Region`.

### Note

This method is available in PyGTK 2.10 and above.

The `xor`() method sets the area of this region to the exclusive-OR of the areas of this region and the region specified by `source2`. The resulting area is the set of pixels contained in either this region or `source2` but not both.

## Functions

### gtk.gdk.region_rectangle

        def gtk.gdk.region_rectangle(rectangle)

`rectangle` : | a `gtk.gdk.Rectangle` or a 4-tuple representing a rectangle.
Returns : | a new `gtk.gdk.Region`

### Note

This function is available in PyGTK 2.10 and above.

The `gtk.gdk.region_rectangle`() function creates a new `gtk.gdk.Region` containing the area specified by `rectangle`.

Prev | Up | Next
gtk.gdk.Rectangle | Home | gtk.gdk.Screen