void WayPointShape::draw( wxDC& dc)
{
	// The minimum size of the RectangleShape is the size of the title
	titleSize = dc.GetTextExtent( WXSTRING( title));
	if (size.x < (titleSize.x + 2 * spacing + 2 * borderWidth))
	{
		size.x = titleSize.x + 2 * spacing + 2 * borderWidth;
	}
	if (size.y < (titleSize.y + 2 * spacing + 2 * borderWidth))
	{
		size.y = titleSize.y + 2 * spacing + 2 * borderWidth;
	}

	if (getWayPoint()->getSize() != size)
	{
		getWayPoint()->setSize( size, false);
	}

	// Draws a rectangle with the given top left corner, and with the given size.
	dc.SetBrush( *wxWHITE_BRUSH);
	if (isSelected())
	{
		dc.SetPen( wxPen( WXSTRING( getSelectionColour()), borderWidth, wxSOLID));
	} else
	{
		dc.SetPen( wxPen( WXSTRING( getNormalColour()), borderWidth, wxSOLID));
	}

	int x = centre.x - (size.x / 2);
	int y = centre.y - (size.y / 2);
	dc.DrawRectangle( x, y, size.x, size.y);

	dc.SetPen( wxPen( WXSTRING( "BLACK"), borderWidth, wxSOLID));
	dc.DrawText( WXSTRING( title), centre.x - titleSize.x / 2, y + spacing + borderWidth);
}
示例#2
0
void AI_Movement::changeWayPointID(uint32 oldwpid, uint32 newwpid)
{
	ASSERT(m_Unit != NULL);

	if(!m_waypoints)return;
	if(newwpid <= 0)
		return; //not valid id
	if(newwpid > m_waypoints->size())
		return; //not valid id
	if(oldwpid > m_waypoints->size())
		return;

	if(newwpid == oldwpid)
		return; //same spot

	//already wp with that id ?
	WayPoint* originalwp = getWayPoint(newwpid);
	if(!originalwp)
		return;
	WayPoint* oldwp = getWayPoint(oldwpid);
	if(!oldwp)
		return;

	oldwp->id = newwpid;
	originalwp->id = oldwpid;
	(*m_waypoints)[oldwp->id-1] = oldwp;
	(*m_waypoints)[originalwp->id-1] = originalwp;

	//SaveAll to db
	saveWayPoints();
}
std::string WayPointShape::asDebugString() const
{
	std::ostringstream os;

	os << "WayPointShape:\n";
	os << RectangleShape::asDebugString() << "\n";
	if (getWayPoint()) {
		os << getWayPoint()->asDebugString();
	}

	return os.str();
}
void WayPointShape::setCentre( const Point& aPoint)
{
	getWayPoint()->setPosition( aPoint, false);
	RectangleShape::setCentre( getWayPoint()->getPosition());
}