Ejemplo n.º 1
0
void wxRegionIterator::CreateRects( const wxRegion& region )
{
    wxDELETEA(m_rects);
    m_numRects = 0;

#ifdef __WXGTK3__
    cairo_region_t* cairoRegion = region.GetRegion();
    if (cairoRegion == NULL)
        return;
    m_numRects = cairo_region_num_rectangles(cairoRegion);
     
    if (m_numRects)
    {
        m_rects = new wxRect[m_numRects];
        for (int i = 0; i < m_numRects; i++)
        {
            GdkRectangle gr;
            cairo_region_get_rectangle(cairoRegion, i, &gr);
            wxRect &wr = m_rects[i];
            wr.x = gr.x;
            wr.y = gr.y;
            wr.width = gr.width;
            wr.height = gr.height;
        }
    }
#else
    GdkRegion *gdkregion = region.GetRegion();
    if (!gdkregion)
        return;

    GdkRectangle* gdkrects;
    gdk_region_get_rectangles(gdkregion, &gdkrects, &m_numRects);

    if (m_numRects)
    {
        m_rects = new wxRect[m_numRects];
        for (int i = 0; i < m_numRects; ++i)
        {
            GdkRectangle &gr = gdkrects[i];
            wxRect &wr = m_rects[i];
            wr.x = gr.x;
            wr.y = gr.y;
            wr.width = gr.width;
            wr.height = gr.height;
        }
    }
    g_free( gdkrects );
#endif
}
Ejemplo n.º 2
0
void wxRIRefData::CreateRects( const wxRegion& region )
{
    delete [] m_rects;

    Init();

    GdkRegion *gdkregion = region.GetRegion();
    if (!gdkregion)
        return;

    Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
    if (r)
    {
        m_numRects = r->numRects;
        if (m_numRects)
        {
            m_rects = new wxRect[m_numRects];
            for (size_t i=0; i < m_numRects; ++i)
            {
                _XBox &xr = r->rects[i];
                wxRect &wr = m_rects[i];
                wr.x = xr.x1;
                wr.y = xr.y1;
                wr.width = xr.x2-xr.x1;
                wr.height = xr.y2-xr.y1;
            }
        }
    }
}
Ejemplo n.º 3
0
void wxRegionIterator::CreateRects( const wxRegion& region )
{
    wxDELETEA(m_rects);
    m_numRects = 0;

    GdkRegion *gdkregion = region.GetRegion();
    if (!gdkregion)
        return;

    GdkRectangle *gdkrects = NULL;
    gint numRects = 0;
    gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );

    m_numRects = numRects;
    if (numRects)
    {
        m_rects = new wxRect[m_numRects];
        for (size_t i=0; i < m_numRects; ++i)
        {
            GdkRectangle &gr = gdkrects[i];
            wxRect &wr = m_rects[i];
            wr.x = gr.x;
            wr.y = gr.y;
            wr.width = gr.width;
            wr.height = gr.height;
        }
    }
    g_free( gdkrects );
}
Ejemplo n.º 4
0
bool wxRegion::DoXor( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        return false;
    }

    AllocExclusive();

    gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );

    return true;
}
Ejemplo n.º 5
0
bool wxRegion::DoSubtract( const wxRegion& region )
{
    if (region.m_refData == NULL || m_refData == NULL)
        return false;

    AllocExclusive();

#ifdef __WXGTK3__
    cairo_region_subtract(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
    gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );
#endif

    return true;
}
Ejemplo n.º 6
0
bool wxRegion::DoSubtract( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        // subtracting from an invalid region doesn't make sense
        return false;
    }

    AllocExclusive();

    gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );

    return true;
}
Ejemplo n.º 7
0
bool wxRegion::DoIntersect( const wxRegion& region )
{
    wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );

    if (!m_refData)
    {
        // intersecting with invalid region doesn't make sense
        return false;
    }

    AllocExclusive();

    gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() );

    return true;
}
Ejemplo n.º 8
0
// helper
static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
{
    if (window)
    {
        if (region.IsEmpty())
        {
            gdk_window_shape_combine_mask(window, NULL, 0, 0);
        }
        else
        {
            gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
            return true;
        }
    }
    return false;
}
Ejemplo n.º 9
0
bool wxRegion::DoXor( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        return FALSE;
    }

    AllocExclusive();

    GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
    gdk_region_destroy( M_REGIONDATA->m_region );
    M_REGIONDATA->m_region = reg;

    return TRUE;
}
Ejemplo n.º 10
0
bool wxRegion::DoSubtract( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        // subtracting from an invalid region doesn't make sense
        return FALSE;
    }

    AllocExclusive();

    GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
    gdk_region_destroy( M_REGIONDATA->m_region );
    M_REGIONDATA->m_region = reg;

    return TRUE;
}
Ejemplo n.º 11
0
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = gdk_region_new();
    }
    else
    {
        AllocExclusive();
    }

    gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );

    return true;
}
Ejemplo n.º 12
0
bool wxRegion::DoIntersect( const wxRegion& region )
{
    wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );

    if (!m_refData)
    {
        // intersecting with invalid region doesn't make sense
        return FALSE;
    }

    AllocExclusive();

    GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
    gdk_region_destroy( M_REGIONDATA->m_region );
    M_REGIONDATA->m_region = reg;

    return TRUE;
}
Ejemplo n.º 13
0
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
    if (region.m_refData == NULL)
        { }
    else if (m_refData == NULL)
    {
        m_refData = new wxRegionRefData(*M_REGIONDATA_OF(region));
    }
    else
    {
        AllocExclusive();
#ifdef __WXGTK3__
        cairo_region_union(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
        gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );
#endif
    }

    return true;
}
Ejemplo n.º 14
0
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
    if (region.IsNull())
        return FALSE;

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = gdk_region_new();
    }
    else
    {
        AllocExclusive();
    }

    GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
    gdk_region_destroy( M_REGIONDATA->m_region );
    M_REGIONDATA->m_region = reg;

    return TRUE;
}
Ejemplo n.º 15
0
bool wxRegion::DoXor( const wxRegion& region )
{
    if (region.m_refData == NULL)
        { }
    else if (m_refData == NULL)
    {
        // XOR-ing with an invalid region is the same as XOR-ing with an empty
        // one, i.e. it is simply a copy.
        m_refData = new wxRegionRefData(*M_REGIONDATA_OF(region));
    }
    else
    {
        AllocExclusive();

#ifdef __WXGTK3__
        cairo_region_xor(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
        gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );
#endif
    }

    return true;
}