Beispiel #1
0
bool UI::MouseOverable::inside(const ScreenPoint& mouse) const
{
	return mouse[0] >= GetLeft()
		&& mouse[1] >= GetBottom()
		&& mouse[0] < GetLeft() + GetWidth()
		&& mouse[1] < GetBottom() + GetHeight();
}
Beispiel #2
0
bool wxSheetBlock::UpdateRows( size_t row_, int numRows )
{
    int row = row_;
    if ((numRows == 0) || (GetBottom() < row)) return false;
    bool remove = numRows < 0;

    // this starts above the deleted rows
    if (m_row < row)
    {
        // this ends within deleted rows, trim to row
        if (remove && (GetBottom() < row - numRows))
            SetBottom(row-1);
        // this straddles the inserted/deleted rows - resize
        else 
            m_height += numRows;
    }
    // This is fully below it or an insert - shift coord
    else if (!remove || (m_row > row + labs(numRows)))
    {
        m_row += numRows;
    }
    // a remove and this's row is in deleted rows
    else 
    {
        m_height += m_row - (row - numRows);
        m_row = row;
    }

    return true;
}        
Beispiel #3
0
int wxSheetBlock::Delete( const wxSheetBlock &block, 
                          wxSheetBlock &top, wxSheetBlock &bottom, 
                          wxSheetBlock &left, wxSheetBlock &right ) const
{
    wxSheetBlock iBlock(Intersect(block));    
    if (iBlock.IsEmpty()) return wxSHEET_BLOCK_NONE; // nothing to delete
    if (block.Contains(*this)) return wxSHEET_BLOCK_ALL; // can delete all of this, no leftover

    int deleted = wxSHEET_BLOCK_NONE;
    
    if ( GetTop() < iBlock.GetTop() )
    {
        top.SetCoords( GetTop(), GetLeft(), iBlock.GetTop()-1, GetRight() );
        deleted |= wxSHEET_BLOCK_TOP;
    }
    if ( GetBottom() > iBlock.GetBottom() )
    {
        bottom.SetCoords( iBlock.GetBottom()+1, GetLeft(), GetBottom(), GetRight() );
        deleted |= wxSHEET_BLOCK_BOTTOM;
    }
    if ( GetLeft() < iBlock.GetLeft() )
    {
        left.SetCoords( iBlock.GetTop(), GetLeft(), iBlock.GetBottom(), iBlock.GetLeft()-1 );
        deleted |= wxSHEET_BLOCK_LEFT;
    }
    if ( GetRight() > iBlock.GetRight() )
    {
        right.SetCoords( iBlock.GetTop(), iBlock.GetRight()+1, iBlock.GetBottom(), GetRight() );
        deleted |= wxSHEET_BLOCK_RIGHT;
    }
    
    return deleted;
}
Beispiel #4
0
int wxSheetBlock::Combine( const wxSheetBlock &block, 
                           wxSheetBlock &top, wxSheetBlock &bottom, 
                           wxSheetBlock &left, wxSheetBlock &right ) const
{       
    wxSheetBlock iBlock(Intersect(block));
    if (iBlock.IsEmpty()) return wxSHEET_BLOCK_NONE; // nothing to combine
    if (Contains(block)) return wxSHEET_BLOCK_ALL; // can combine all of block, no leftover
    
    int combined = wxSHEET_BLOCK_NONE;

    if ( block.GetTop() < GetTop() )
    {
        top.SetCoords( block.GetTop(), block.GetLeft(), GetTop()-1, block.GetRight() );
        combined |= wxSHEET_BLOCK_TOP;
    }
    if ( block.GetBottom() > GetBottom() )
    {
        bottom.SetCoords( GetBottom()+1, block.GetLeft(), block.GetBottom(), block.GetRight() );
        combined |= wxSHEET_BLOCK_BOTTOM;
    }
    if ( block.GetLeft() < GetLeft() )
    {
        left.SetCoords(iBlock.GetTop(), block.GetLeft(), iBlock.GetBottom(), GetLeft()-1 );
        combined |= wxSHEET_BLOCK_LEFT;
    }
    if ( block.GetRight() > GetRight() )
    {
        right.SetCoords( iBlock.GetTop(), GetRight()+1, iBlock.GetBottom(), block.GetRight() );
        combined |= wxSHEET_BLOCK_RIGHT;
    }

    return combined;
}
Beispiel #5
0
//-----------------------------------------------------------------------
bool Rectangle::Intersects(Rectangle const& rect) const
{
    POMDOG_ASSERT(GetLeft() <= GetRight());
    POMDOG_ASSERT(GetTop() <= GetBottom());
    POMDOG_ASSERT(rect.GetLeft() <= rect.GetRight());

    return (GetLeft() < rect.GetRight()
        && GetRight() > rect.GetLeft()
        && GetTop() < rect.GetBottom()
        && GetBottom() > rect.GetTop());
}
void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC)
/**************************************************************/
{
    int w = GetWidth()/panel->GetZoom();
    int h = GetHeight()/panel->GetZoom();
    if (  w == 0 || h == 0 )
        GRLine(&panel->m_ClipBox, DC, GetX(), GetY(),
               GetRight(), GetBottom(), m_Color);
    else
        GRRect(&panel->m_ClipBox, DC,  GetX(), GetY(),
               GetRight(), GetBottom(), m_Color);
}
Beispiel #7
0
int CPlayer::CollTikei()
{
	return
		g_pStage->CollTikei(VECT(GetLeft()+PL_OFFSET,GetTop()+PL_OFFSET))||
		g_pStage->CollTikei(VECT(GetLeft()+PL_OFFSET,GetBottom()-PL_OFFSET))||
		g_pStage->CollTikei(VECT(GetRight()-PL_OFFSET,GetTop()+PL_OFFSET))||
		g_pStage->CollTikei(VECT(GetRight()-PL_OFFSET,GetBottom()-PL_OFFSET))||
		g_pStage->CollTikei(VECT(GetLeft()+GetWidth()/2,GetTop()))||
		g_pStage->CollTikei(VECT(GetLeft()+GetWidth()/2,GetBottom()))||
		g_pStage->CollTikei(VECT(GetLeft(),GetTop()+GetHeight()/2))||
		g_pStage->CollTikei(VECT(GetRight(),GetTop()+GetHeight()/2));
}
Beispiel #8
0
// -----------------------------------------------------------------------------
// Draws function text (spec+args) for [context] at [left,top].
// Returns a rect of the bounds of the drawn text
// -----------------------------------------------------------------------------
wxRect SCallTip::drawFunctionContext(
	wxDC&                      dc,
	const TLFunction::Context& context,
	int                        left,
	int                        top,
	wxColour&                  col_faded,
	wxFont&                    bold) const
{
	auto rect_func = drawFunctionSpec(dc, context, left, top);
	auto rect_args = drawArgs(dc, context, rect_func.GetRight() + 1, rect_func.GetTop(), col_faded, bold);

	return wxRect{ rect_func.GetTopLeft(),
				   wxPoint{ std::max(rect_func.GetRight(), rect_args.GetRight()),
							std::max(rect_func.GetBottom(), rect_args.GetBottom()) } };
}
Beispiel #9
0
PRUint32 nsDisplayList::Count() const {
  PRUint32 count = 0;
  for (nsDisplayItem* i = GetBottom(); i; i = i->GetAbove()) {
    ++count;
  }
  return count;
}
Beispiel #10
0
hdMultiPosRect &hdMultiPosRect::Intersect(int posIdx, const hdMultiPosRect &rect)
{
	int x2 = GetRight(posIdx),
	    y2 = GetBottom(posIdx);

	if ( x[posIdx] < rect.x[posIdx] )
		x[posIdx] = rect.x[posIdx];
	if ( y[posIdx] < rect.y[posIdx] )
		y[posIdx] = rect.y[posIdx];
	if ( x2 > rect.GetRight(posIdx) )
		x2 = rect.GetRight(posIdx);
	if ( y2 > rect.GetBottom(posIdx) )
		y2 = rect.GetBottom(posIdx);

	width = x2 - x[posIdx] + 1;
	height = y2 - y[posIdx] + 1;

	if ( width <= 0 || height <= 0 )
	{
		width =
		    height = 0;
	}

	return *this;
}
Beispiel #11
0
bool Rectangle::Intersects(const Circle& circle) const {

    double radius = circle.GetRadius();

    auto cp = circle.GetPosition();

    auto t = GetTop();
    double distTop = Math::GetDistance(cp, t.GetPointOne(), t.GetPointTwo());

    auto l = GetLeft();
    double distLeft = Math::GetDistance(cp, l.GetPointOne(), l.GetPointTwo());

    auto r = GetRight();
    double distRight = Math::GetDistance(cp, r.GetPointOne(), r.GetPointTwo());

    auto b = GetBottom();
    double distBottom = Math::GetDistance(cp, b.GetPointOne(), b.GetPointTwo());

    bool resultTop = distTop <= radius;
    bool resultLeft = distLeft <= radius;
    bool resultRight = distRight <= radius;
    bool resultBottom = distBottom <= radius;
    bool isInside = Intersects(Point(circle.GetPosition()));
    return (isInside || resultTop || resultLeft || resultRight || resultBottom);
}
Beispiel #12
0
//-----------------------------------------------------------------------
bool Rectangle::Contains(Rectangle const& rect) const
{
    return (rect.GetLeft() >= GetLeft()
        && rect.GetRight() <= GetRight()
        && rect.GetTop() >= GetTop()
        && rect.GetBottom() <= GetBottom());
}
Beispiel #13
0
bool Rectangle::Intersects(const Ellipse& ellipse) const {

    auto eeh = ellipse.GetHalfExtents();
    double ellipseResultWidth = eeh.GetX();
    double ellipseResultHeight = eeh.GetY();

    auto ep = ellipse.GetPosition();

    auto t = GetTop();
    double distTop = Math::GetDistance(ep, t.GetPointOne(), t.GetPointTwo());

    auto l = GetLeft();
    double distLeft = Math::GetDistance(ep, l.GetPointOne(), l.GetPointTwo());

    auto r = GetRight();
    double distRight = Math::GetDistance(ep, r.GetPointOne(), r.GetPointTwo());

    auto b = GetBottom();
    double distBottom = Math::GetDistance(ep, b.GetPointOne(), b.GetPointTwo());

    bool resultTop = (distTop <= ellipseResultWidth) || (distTop <= ellipseResultHeight);
    bool resultLeft = (distLeft <= ellipseResultWidth) || (distLeft <= ellipseResultHeight);
    bool resultRight = (distRight <= ellipseResultWidth) || (distRight <= ellipseResultHeight);
    bool resultBottom = (distBottom <= ellipseResultWidth) || (distBottom <= ellipseResultHeight);

    return (resultTop || resultLeft || resultRight || resultBottom);
}
Beispiel #14
0
JvRect JvCamera::getCameraRect()
{
	//printf("%d\n",_fllowObjP);
	if (_fllowObjP == NULL)
	{
		return JvRect(x,y,width,height);
	}

	if (_shakeTimer!=0)
	{
		return JvRect(x,y,width,height);
	}

	if (x<_fllowBound.x)
	{
		x=_fllowBound.x;
	}

	if (y<_fllowBound.y)
	{
		y=_fllowBound.y;
	}

	if (GetRight()>_fllowBound.GetRight())
	{
		x=_fllowBound.GetRight() - width;
	}

	if (GetBottom()>_fllowBound.GetBottom())
	{
		y=_fllowBound.GetBottom()- height;
	}

	return JvRect(x,y,width,height);
}
Beispiel #15
0
wxRect& wxRect::Intersect(const wxRect& rect)
{
    int x2 = GetRight(),
        y2 = GetBottom();

    if ( x < rect.x )
        x = rect.x;
    if ( y < rect.y )
        y = rect.y;
    if ( x2 > rect.GetRight() )
        x2 = rect.GetRight();
    if ( y2 > rect.GetBottom() )
        y2 = rect.GetBottom();

    width = x2 - x + 1;
    height = y2 - y + 1;

    if ( width <= 0 || height <= 0 )
    {
        width =
        height = 0;
    }

    return *this;
}
Beispiel #16
0
bool VRect::HitTest (const VPoint& inPoint) const
{
	return ((inPoint.GetX() - fX) > -kREAL_PIXEL_PRECISION
			&& (inPoint.GetX() - GetRight()) < kREAL_PIXEL_PRECISION
			&& (inPoint.GetY() - fY) > -kREAL_PIXEL_PRECISION
			&& (inPoint.GetY() - GetBottom()) < kREAL_PIXEL_PRECISION);
}
Beispiel #17
0
wxSheetBlock wxSheetBlock::ExpandUnion( const wxSheetBlock &other ) const
{
    if (IsEmpty()) return other;        // preserve other block
    if (other.IsEmpty()) return *this;  // preserve this

    // ugly code, but fastest in gcc
    int l = other.GetRight();
    int r = GetRight();
    r = wxMax(r, l);
    l = wxMin(m_col, other.m_col);
    int t = other.GetBottom();
    int b = GetBottom();
    b = wxMax(b, t);
    t = wxMin(m_row, other.m_row);
    return wxSheetBlock(t, l, b-t+1, r-l+1);
    
/*        
    // simplier code, but slower        
    //int l = wxMin(m_col,       other.m_col);
    //int r = wxMax(GetRight(),  other.GetRight());
    //int t = wxMin(m_row,       other.m_row);
    //int b = wxMax(GetBottom(), other.GetBottom());
    //return wxSheetBlock(t, l, b-t+1, r-l+1);
*/        
}
Beispiel #18
0
	void PrintAllocations( )
	{
		GetLock( ).lock( );
#ifdef DEBUG_MEMORY
		Header* header = GetBottom( )->Next;

		std::string str = "\n";
		while ( header )
		{
			if ( !header->Free )
				str += "\tMEMORY LEAK\t\t" + std::string( header->File ) + ":" + std::to_string( header->Line ) + "\t\t" + std::to_string( header->Size ) + "\n";

			header = header->Next;
		}
		header = GetTop( )->Next;
		while ( header )
		{
			if ( !header->Free )
				str += "\tMEMORY LEAK\t\t" + std::string( header->File ) + ":" + std::to_string( header->Line ) + "\t\t" + std::to_string( header->Size ) + "\n";

			header = header->Next;
		}
		str += "\n";
#if PLATFORM == PLATFORM_WINDOWS
		OutputDebugStringA( str.c_str( ) );
#else
		printf( "%s", str.c_str( ) );
#endif
#endif
		GetLock( ).unlock( );
	}
Beispiel #19
0
void nsDisplayList::Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
                          const nsRect& aDirtyRect) const {
  for (nsDisplayItem* i = GetBottom(); i != nsnull; i = i->GetAbove()) {
    i->Paint(aBuilder, aCtx, aDirtyRect);
  }
  nsCSSRendering::DidPaint();
}
BOOL CReportEntityPicture::FromString( const CString& str )
/* ============================================================
	Function :		CReportEntityPicture::FromString
	Description :	Sets the data of the object from "str".
	Access :		Public

	Return :		BOOL				-	"TRUE" if the string
											represents an object 
											of this type.
	Parameters :	const CString& str	-	String to parse
					
	Usage :			Call to load objects from a file.

   ============================================================*/
{

	BOOL result = FALSE;
	CString data( str );
	if( LoadFromString( data ) )
	{

		CTokenizer tok( data );

		double		 borderthickness;
		unsigned int borderstyle;
		unsigned int  bordercolor;
		CString		filename;

		int	count = 0;
		tok.GetAt( count++, borderthickness );
		int aaa;
		tok.GetAt( count++, aaa );
		borderstyle=aaa;
		tok.GetAt( count++, aaa );
		bordercolor=aaa;
		tok.GetAt( count++, filename );

		int bt = CUnitConversion::InchesToPixels( borderthickness );
		SetBorderThickness( bt );
		SetBorderStyle( borderstyle );
		SetBorderColor( bordercolor );
		UnmakeSaveString( filename );

		SetFilename( filename );

		int left = CUnitConversion::InchesToPixels( GetLeft() );
		int right = CUnitConversion::InchesToPixels( GetRight() );
		int top = CUnitConversion::InchesToPixels( GetTop() );
		int bottom = CUnitConversion::InchesToPixels( GetBottom() );

		CRect rect( left, top, right, bottom );
		SetRect( rect );

		result = TRUE;

	}

	return result;

}
Beispiel #21
0
bool	VRect::Contains (const VRect& inRect) const
{
	return ((inRect.GetLeft() - GetLeft()) > -kREAL_PIXEL_PRECISION &&
			(inRect.GetRight() - GetRight()) < kREAL_PIXEL_PRECISION &&
			(inRect.GetTop() - GetTop()) > -kREAL_PIXEL_PRECISION &&
			(inRect.GetBottom() - GetBottom()) < kREAL_PIXEL_PRECISION);
}
Beispiel #22
0
wxSheetBlock wxSheetBlock::Union( const wxSheetBlock &other ) const
{
    // no need to check if IsEmpty since wxMin(Right/Bottom) does it
    // ugly code, but fastest in gcc
    int l = other.GetRight();
    int r = GetRight();
    r = wxMax(r, l);
    l = wxMin(m_col, other.m_col);
    int w = r-l+1;
    if (w < 0) return wxSheetBlock();
    int t = other.GetBottom();
    int b = GetBottom();
    b = wxMax(b, t);
    t = wxMin(m_row, other.m_row);
    int h = b-t+1;
    if (h < 0) return wxSheetBlock();
    return wxSheetBlock(t, l, h, w);
    
/*  
    // simplier code, but slower        
    //int l = wxMin(m_col,       other.m_col);
    //int r = wxMax(GetRight(),  other.GetRight());
    //int t = wxMin(m_row,       other.m_row);
    //int b = wxMax(GetBottom(), other.GetBottom());
    //return wxSheetBlock(t, l, wxMax(b-t+1, 0), wxMax(r-l+1, 0));
*/        
}
Beispiel #23
0
nsIFrame* nsDisplayList::HitTest(nsDisplayListBuilder* aBuilder, nsPoint aPt,
                                 nsDisplayItem::HitTestState* aState) const {
  PRInt32 itemBufferStart = aState->mItemBuffer.Length();
  nsDisplayItem* item;
  for (item = GetBottom(); item; item = item->GetAbove()) {
    aState->mItemBuffer.AppendElement(item);
  }
  for (PRInt32 i = aState->mItemBuffer.Length() - 1; i >= itemBufferStart; --i) {
    // Pop element off the end of the buffer. We want to shorten the buffer
    // so that recursive calls to HitTest have more buffer space.
    item = aState->mItemBuffer[i];
    aState->mItemBuffer.SetLength(i);

    if (item->GetBounds(aBuilder).Contains(aPt)) {
      nsIFrame* f = item->HitTest(aBuilder, aPt, aState);
      // Handle the XUL 'mousethrough' feature.
      if (f) {
        if (!f->GetMouseThrough()) {
          aState->mItemBuffer.SetLength(itemBufferStart);
          return f;
        }
      }
    }
  }
  NS_ASSERTION(aState->mItemBuffer.Length() == itemBufferStart,
               "How did we forget to pop some elements?");
  return nsnull;
}
Beispiel #24
0
void nsDisplayList::ExplodeAnonymousChildLists(nsDisplayListBuilder* aBuilder) {
  // See if there's anything to do
  PRBool anyAnonymousItems = PR_FALSE;
  nsDisplayItem* i;
  for (i = GetBottom(); i != nsnull; i = i->GetAbove()) {
    if (!i->GetUnderlyingFrame()) {
      anyAnonymousItems = PR_TRUE;
      break;
    }
  }
  if (!anyAnonymousItems)
    return;

  nsDisplayList tmp;
  while ((i = RemoveBottom()) != nsnull) {
    if (i->GetUnderlyingFrame()) {
      tmp.AppendToTop(i);
    } else {
      nsDisplayList* list = i->GetList();
      NS_ASSERTION(list, "leaf items can't be anonymous");
      list->ExplodeAnonymousChildLists(aBuilder);
      nsDisplayItem* j;
      while ((j = list->RemoveBottom()) != nsnull) {
        tmp.AppendToTop(static_cast<nsDisplayWrapList*>(i)->
            WrapWithClone(aBuilder, j));
      }
      i->~nsDisplayItem();
    }
  }
  
  AppendToTop(&tmp);
}
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                           GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{

    int w = GetWidth();
    int h = GetHeight();

    GRSetDrawMode( aDC, aDrawMode );

    if(  w == 0 || h == 0 )
        GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
                GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
    else
        GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
                GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
}
void CDiagramEntity::DrawObject( CDC* dc, double zoom )
/* ============================================================
	Function :		CDiagramEntity::DrawObject
	Description :	Top-level drawing function for the object.
					
	Return :		void
	Parameters :	CDC* dc		-	
					double zoom	-	
					
	Usage :			Even though virtual, this function should 
					normally not be overridden (use Draw 
					instead). The function stores the zoom and 
					calculates the true drawing rectangle.

   ============================================================*/
{

	SetZoom( zoom );
	CRect rect( round( GetLeft() * zoom ), 
				round( GetTop() * zoom ), 
				round( GetRight() * zoom ), 
				round( GetBottom() * zoom ) );

	Draw( dc, rect );

	if( IsSelected() )
		DrawSelectionMarkers( dc, rect );

}
Beispiel #27
0
void CCreateToySourcePanel::Layout()
{
	float flTop = 20;
	m_pToyFileLabel->SetLeft(15);
	m_pToyFileLabel->SetTop(flTop);
	m_pToyFileText->SetWidth(GetWidth()-30);
	m_pToyFileText->CenterX();
	m_pToyFileText->SetTop(flTop+12);

	flTop += 43;

	m_pSourceFileLabel->SetLeft(15);
	m_pSourceFileLabel->SetTop(flTop);
	m_pSourceFileText->SetWidth(GetWidth()-30);
	m_pSourceFileText->CenterX();
	m_pSourceFileText->SetTop(flTop+12);

	flTop += 43;

	m_pWarnings->SetLeft(15);
	m_pWarnings->SetTop(flTop);
	m_pWarnings->SetWidth(GetWidth()-30);
	m_pWarnings->CenterX();
	m_pWarnings->SetWrap(true);
	m_pWarnings->SetBottom(GetBottom() - 60);

	m_pCreate->SetTop(GetHeight() - 45);
	m_pCreate->CenterX();

	BaseClass::Layout();

	FileNamesChanged();
}
Beispiel #28
0
int wxSheetBlock::CmpRightBottom(const wxSheetBlock& b) const 
{
    int cmp = GetRight()  - b.GetRight();  if (cmp != 0) return cmp;
        cmp = GetBottom() - b.GetBottom(); if (cmp != 0) return cmp;
        cmp = m_col - b.m_col;             if (cmp != 0) return cmp;
        cmp = m_row - b.m_row;                           return cmp;
}
Beispiel #29
0
  /**
   * Returns the position within the parent window.
   */
  gcc_pure
  const PixelRect GetPosition() const
  {
#ifndef USE_GDI
    return { GetLeft(), GetTop(), GetRight(), GetBottom() };
#else
    PixelRect rc = GetScreenPosition();

    HWND parent = ::GetParent(hWnd);
    if (parent != NULL) {
      POINT pt;

      pt.x = rc.left;
      pt.y = rc.top;
      ::ScreenToClient(parent, &pt);
      rc.left = pt.x;
      rc.top = pt.y;

      pt.x = rc.right;
      pt.y = rc.bottom;
      ::ScreenToClient(parent, &pt);
      rc.right = pt.x;
      rc.bottom = pt.y;
    }
    return rc;
#endif
  }
Beispiel #30
0
bool JvRect::checkPointIn(double pointX,double pointY)
{
	if (pointX < x || pointX > GetRight() || pointY<y || pointY>GetBottom())
	{
		return false;
	}
	return true;
}