Exemple #1
0
/// Get the overall rect of the given item
bool InstanceCtrl::GetItemRect( VisualCoord item, wxRect& rect, bool view_relative )
{
	if (item.groupIndex < GetCount())
	{
		int row, col;
		if (!GetRowCol(item, row, col))
			return false;
		GroupVisual & gv = m_groups[item.groupIndex];
		
		wxSize bsz = GetWindowBorderSize();
		int x = col * (m_itemWidth + m_spacing) + m_spacing + bsz.GetWidth() / 2;
		int y = gv.y_position + gv.row_ys[row] + m_spacing;
		
		if (view_relative)
		{
			int startX, startY;
			int xppu, yppu;
			GetScrollPixelsPerUnit(& xppu, & yppu);
			GetViewStart(& startX, & startY);
			x = x - startX * xppu;
			y = y - startY * yppu;
		}
		
		rect.x = x;
		rect.y = y;
		rect.width = m_itemWidth;
		rect.height = GetItemHeight(item);
		return true;
	}
	return false;
}
wxSize wxTreeCtrlBase::DoGetBestSize() const
{
    wxSize size;

    // this doesn't really compute the total bounding rectangle of all items
    // but a not too bad guess of it which has the advantage of not having to
    // examine all (potentially hundreds or thousands) items in the control

    if (GetQuickBestSize())
    {
#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 ( wxTreeItemId item = GetRootItem();
              item.IsOk();
              item = GetLastChild(item) )
        {
            wxRect rect;

            // last parameter is "true" to get only the dimensions of the text
            // label, we don't want to get the entire item width as it's determined
            // by the current size
            if ( GetBoundingRect(item, rect, true) )
            {
                if ( size.x < rect.x + rect.width )
                    size.x = rect.x + rect.width;
                if ( size.y < rect.y + rect.height )
                    size.y = rect.y + rect.height;
            }
        }
    }
    else // use precise, if potentially slow, size computation method
    {
        // iterate over all items recursively
        wxTreeItemId idRoot = GetRootItem();
        if ( idRoot.IsOk() )
            wxGetBestTreeSize(this, idRoot, size);
    }

    // need some minimal size even for empty tree
    if ( !size.x || !size.y )
        size = wxControl::DoGetBestSize();
    else
    {
        // Add border size
        size += GetWindowBorderSize();

        CacheBestSize(size);
    }

    return size;
}
Exemple #3
0
wxSize InstanceCtrl::DoGetBestSize() const
{
	wxSize bsz = GetWindowBorderSize();
	int best_width = m_spacing + (m_itemWidth + m_spacing) * GetItemsPerRow() +
	                 bsz.GetWidth() * 2 +
	                 wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
	wxSize sz(best_width, 0);
	return sz;
}
Exemple #4
0
// TODO: handle WM_WININICHANGE
wxSize wxCalendarCtrl::DoGetBestSize() const
{
    RECT rc;
    if ( !GetHwnd() || !MonthCal_GetMinReqRect(GetHwnd(), &rc) )
    {
        return wxCalendarCtrlBase::DoGetBestSize();
    }

    return wxRectFromRECT(rc).GetSize() + GetWindowBorderSize();
}
HRGN FWindowsWindow::MakeWindowRegionObject() const
{
	HRGN Region;
	if ( RegionWidth != INDEX_NONE && RegionHeight != INDEX_NONE )
	{
		if (IsMaximized())
		{
			int32 WindowBorderSize = GetWindowBorderSize();
			Region = CreateRectRgn( WindowBorderSize, WindowBorderSize, RegionWidth - WindowBorderSize, RegionHeight - WindowBorderSize );
		}
		else
		{
			const bool bUseCornerRadius  = 
#if ALPHA_BLENDED_WINDOWS
				// Corner radii cause DWM window composition blending to fail, so we always set regions to full size rectangles
				Definition->TransparencySupport != EWindowTransparency::PerPixel &&
#endif
				Definition->CornerRadius > 0;

			if( bUseCornerRadius )
			{
				// @todo mac: Corner radius not applied on Mac platform yet

				// CreateRoundRectRgn gives you a duff region that's 1 pixel smaller than you ask for. CreateRectRgn behaves correctly.
				// This can be verified by uncommenting the assert below
				Region = CreateRoundRectRgn( 0, 0, RegionWidth+1, RegionHeight+1, Definition->CornerRadius, Definition->CornerRadius );

				// Test that a point that should be in the region, is in the region
				// check(!!PtInRegion(Region, RegionWidth-1, RegionHeight/2));
			}
			else
			{
				Region = CreateRectRgn( 0, 0, RegionWidth, RegionHeight );
			}
		}
	}
	else
	{
		RECT rcWnd;
		GetWindowRect( HWnd, &rcWnd );
		Region = CreateRectRgn( 0, 0, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top );
	}

	return Region;
}
HRGN FWindowsWindow::MakeWindowRegionObject() const
{
	HRGN Region;
	if ( RegionWidth != INDEX_NONE && RegionHeight != INDEX_NONE )
	{
		if (IsMaximized())
		{
			int32 WindowBorderSize = GetWindowBorderSize();
			Region = CreateRectRgn( WindowBorderSize, WindowBorderSize, RegionWidth - WindowBorderSize, RegionHeight - WindowBorderSize );
		}
		else
		{
			if( Definition->CornerRadius > 0 )
			{
				// @todo mac: Corner radius not applied on Mac platform yet

				// CreateRoundRectRgn gives you a duff region that's 1 pixel smaller than you ask for. CreateRectRgn behaves correctly.
				// This can be verified by uncommenting the assert below
				Region = CreateRoundRectRgn( 0, 0, RegionWidth+1, RegionHeight+1, Definition->CornerRadius, Definition->CornerRadius );

				// Test that a point that should be in the region, is in the region
				// check(!!PtInRegion(Region, RegionWidth-1, RegionHeight/2));
			}
			else
			{
				Region = CreateRectRgn( 0, 0, RegionWidth, RegionHeight );
			}
		}
	}
	else
	{
		RECT rcWnd;
		GetWindowRect( HWnd, &rcWnd );
		Region = CreateRectRgn( 0, 0, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top );
	}

	return Region;
}