void wxRIRefData::CreateRects( const wxRegion& region )
{
    if (m_rects)
      delete [] m_rects;

    m_rects = 0;
    m_numRects = 0;
    
    if (region.IsEmpty()) return;
    
#if 0
    Region r = (Region) region.GetX11Region();
    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;
            }
        }
    }
#endif    
}
Exemple #2
0
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
{
    wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
                 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));

#if TARGET_CARBON
    // The empty region signifies that the shape should be removed from the
    // window.
    if ( region.IsEmpty() )
    {
        wxSize sz = GetClientSize();
        wxRegion rgn(0, 0, sz.x, sz.y);
        return SetShape(rgn);
    }

    // Make a copy of the region
    RgnHandle  shapeRegion = NewRgn();
    CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );

    // Dispose of any shape region we may already have
    RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
    if ( oldRgn )
        DisposeRgn(oldRgn);

    // Save the region so we can use it later
    SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion);

    // Tell the window manager that the window has changed shape
    ReshapeCustomWindow((WindowRef)MacGetWindowRef());
    return TRUE;
#else
    return FALSE;
#endif
}
Exemple #3
0
void WxGraphs::DrawWindowInfo(wxDC * dc, const wxRegion & repainted_region)
{

	if (repainted_region.IsEmpty())
		return;

	int info_left_marg = m_screen_margins.leftmargin + 8;
	int param_name_shift = 5;

	if (m_draws.size() < 1)
		return;

	int w, h;
	dc->GetSize(&w, &h);

	DrawInfo *info = m_draws[0]->GetDrawInfo();
	wxString name = info->GetSetName().c_str();

	int namew, nameh;
	dc->GetTextExtent(name, &namew, &nameh);

	if (repainted_region.Contains(info_left_marg, m_screen_margins.infotopmargin, w - m_screen_margins.infotopmargin, nameh) == wxOutRegion)
		return;

	dc->SetTextForeground(*wxWHITE);

	dc->DrawText(name, info_left_marg, m_screen_margins.infotopmargin);

	wxColor color = dc->GetTextForeground();

	int xpos = info_left_marg + namew + param_name_shift;

	for (int i = 0; i < (int)m_draws.size(); ++i) {

		if (!m_draws[i]->GetEnable())
			continue;

		DrawInfo *info = m_draws[i]->GetDrawInfo();

		dc->SetTextForeground(info->GetDrawColor());

		name = info->GetShortName().c_str();
		dc->GetTextExtent(name, &namew, &nameh);

		dc->DrawText(name, xpos, m_screen_margins.infotopmargin);
		xpos += namew + param_name_shift;
	}

	dc->SetTextForeground(color);

}
void wxRIRefData::CreateRects( const wxRegion& region )
{
    if (m_rects)
      delete [] m_rects;

    m_rects = 0;
    m_numRects = 0;

    if (region.IsEmpty()) return;

    Region r = (Region) region.GetX11Region();
    if (r)
    {
#if wxUSE_NANOX
        GR_RECT rect;
        GrGetRegionBox(r, & rect);
        m_numRects = 1;
        m_rects = new wxRect[1];
        m_rects[0].x = rect.x;
        m_rects[0].y = rect.y;
        m_rects[0].width = rect.width;
        m_rects[0].height = rect.height;
#else
        m_numRects = r->numRects;
        if (m_numRects)
        {
            m_rects = new wxRect[m_numRects];
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            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;
            }
        }
#endif
    }
}
Exemple #5
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;
}
Exemple #6
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
        {
            wxBitmap bmp = region.ConvertToBitmap();
            bmp.SetMask(new wxMask(bmp, *wxBLACK));
            GdkBitmap* mask = bmp.GetMask()->GetBitmap();
            gdk_window_shape_combine_mask(window, mask, 0, 0);
            return true;
        }
    }
    return false;
}
void wxRIRefData::CreateRects( const wxRegion& region )
{
    if (m_rects)
      delete [] m_rects;

    m_rects = 0;
    m_numRects = 0;

    if (region.IsEmpty()) return;

    Region r = (Region) region.GetX11Region();
    if (r)
    {
#if wxUSE_NANOX
        GR_RECT rect;
        GrGetRegionBox(r, & rect);
        m_numRects = 1;
        m_rects = new wxRect[1];
        m_rects[0].x = rect.x;
        m_rects[0].y = rect.y;
        m_rects[0].width = rect.width;
        m_rects[0].height = rect.height;
#else
        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;
            }
        }
#endif
    }
}
Exemple #8
0
void wxQtDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)
{
    if ( region.IsEmpty() )
    {
        DestroyClippingRegion();
    }
    else
    {
        QRegion qregion = region.GetHandle();
        // Save current origin / scale (logical coordinates)
        QTransform qtrans = m_qtPainter->worldTransform();
        // Reset transofrmation to match device coordinates
        m_qtPainter->setWorldTransform( QTransform() );
        wxLogDebug(wxT("wxQtDCImpl::DoSetDeviceClippingRegion rect %d %d %d %d"),
                   qregion.boundingRect().x(), qregion.boundingRect().y(),
                   qregion.boundingRect().width(), qregion.boundingRect().height());
        // Set QPainter clipping (intersection if not the first one)
        m_qtPainter->setClipRegion( qregion,
                                 m_clipping ? Qt::IntersectClip : Qt::ReplaceClip );

        // Restore the transformation (translation / scale):
        m_qtPainter->setWorldTransform( qtrans );

        // Set internal state for getters
        /* Note: Qt states that QPainter::clipRegion() may be slow, so we
        * keep the region manually, which should be faster */
        if ( m_clipping )
            m_clippingRegion->Union( region );
        else
            m_clippingRegion->Intersect( region );

        wxRect clipRect = m_clippingRegion->GetBox();

        m_clipX1 = clipRect.GetLeft();
        m_clipX2 = clipRect.GetRight();
        m_clipY1 = clipRect.GetTop();
        m_clipY2 = clipRect.GetBottom();
        m_clipping = true;
    }
}
Exemple #9
0
void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
{
    // region is in device coordinates
    wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") );

    // Convert device coordinates to logical coordinates
    // for all region components.
    wxRegion logRegion;
    if ( region.IsEmpty() )
    {
        // Empty region is skipped by iterator
        // so we have to copy it directly.
        logRegion = region;
    }
    else
    {
        wxRegionIterator ri(region);
        while (ri)
        {
            logRegion.Union(DeviceToLogicalX(ri.GetX()),
                            DeviceToLogicalY(ri.GetY()),
                            DeviceToLogicalXRel(ri.GetWidth()),
                            DeviceToLogicalYRel(ri.GetHeight()));
            ++ri;
        }
    }

    m_graphicContext->Clip(logRegion);

    wxRect newRegion = logRegion.GetBox();

    wxRect clipRegion;
    if ( m_clipping )
    {
        // New clipping box is an intersection
        // of required clipping box and the current one.
        wxRect curRegion(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1);
        clipRegion = curRegion.Intersect(newRegion);
    }
    else
    {
        // Effective clipping box is an intersection
        // of required clipping box and DC surface.
        int dcWidth, dcHeight;
        DoGetSize(&dcWidth, &dcHeight);
        wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0),
                      DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight));
        clipRegion = dcRect.Intersect(newRegion);

        m_clipping = true;
    }

    if ( clipRegion.IsEmpty() )
    {
        m_clipX1 = m_clipY1 = m_clipX2 = m_clipY2 = 0;
    }
    else
    {
        m_clipX1 = clipRegion.GetLeft();
        m_clipY1 = clipRegion.GetTop();
        m_clipX2 = clipRegion.GetRight() + 1;
        m_clipY2 = clipRegion.GetBottom() + 1;
    }
}
Exemple #10
0
void WxGraphs::UpdateArea(const wxRegion & region)
{
	if (region.IsEmpty())
		return;
	m_invalid_region.Union(region);
}
Exemple #11
0
bool wxSkinWindow::SetShape(const wxRegion& region)
{
	
#if defined(__WXMSW__) && !defined(__WXWINCE__)
	// The empty region signifies that the shape should be removed from the
    // window.
    if ( region.IsEmpty() )
    {
        if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
        {
            wxLogLastError(_T("SetWindowRgn"));
            return false;
        }
        return true;
    }

    DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL);
    RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
    ::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
    HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData);
    delete[] (char*) rgnData;
   
    RECT rect;
    DWORD dwStyle =   ::GetWindowLong(GetHwnd(), GWL_STYLE);
    DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
    ::GetClientRect(GetHwnd(), &rect);
    ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
    ::OffsetRgn(hrgn, -rect.left, -rect.top);

    if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
    {
        wxLogLastError(_T("SetWindowRgn"));
        return false;
    }
    return true;
#elif defined(__WXMAC__)
	if ( region.IsEmpty() )
    {
        wxSize sz = GetClientSize();
        wxRegion rgn(0, 0, sz.x, sz.y);
        return SetShape(rgn);
    }

    // Make a copy of the region
    RgnHandle  shapeRegion = NewRgn();
    CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );

    // Dispose of any shape region we may already have
    RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)GetHandle() );
    if ( oldRgn )
        DisposeRgn(oldRgn);

    // Save the region so we can use it later
    SetWRefCon((WindowRef)GetHandle(), (SInt32)shapeRegion);

    // Tell the window manager that the window has changed shape
    ReshapeCustomWindow((WindowRef)GetHandle());
    return true;
#elif defined(__WXGTK__)
	if(region.IsEmpty())
	{
		if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
			gtk_widget_shape_combine_mask(m_wxwindow,NULL,0,0);
		if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
			gtk_widget_shape_combine_mask(m_widget,NULL,0,0);
	}
	else
	{	wxBitmap bmp = region.ConvertToBitmap();
		bmp.SetMask(new wxMask(bmp, *wxBLACK));
		GdkBitmap* mask = bmp.GetMask()->GetBitmap();

		if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
			gtk_widget_shape_combine_mask(m_wxwindow,mask,0,0);
		if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
			gtk_widget_shape_combine_mask(m_widget,mask,0,0);
	}
	return true;
#else
	return false;
#endif
}