Пример #1
0
void wxRectangleShape::SetSize(double x, double y, bool WXUNUSED(recursive))
{
	SetAttachmentSize(x, y);
	m_width = (double)wxMax(x, 1.0);
	m_height = (double)wxMax(y, 1.0);
	SetDefaultRegionSize();
}
Пример #2
0
// Really need to be able to reset the shape! Otherwise, if the
// points ever go to zero, we've lost it, and can't resize.
void wxPolygonShape::SetSize(double new_width, double new_height, bool WXUNUSED(recursive))
{
	SetAttachmentSize(new_width, new_height);

	// Multiply all points by proportion of new size to old size
	double x_proportion = (double)(fabs(new_width / m_originalWidth));
	double y_proportion = (double)(fabs(new_height / m_originalHeight));

	wxNode *node = m_points->GetFirst();
	wxNode *original_node = m_originalPoints->GetFirst();
	while (node && original_node)
	{
		wxRealPoint *point = (wxRealPoint *)node->GetData();
		wxRealPoint *original_point = (wxRealPoint *)original_node->GetData();

		point->x = (original_point->x * x_proportion);
		point->y = (original_point->y * y_proportion);

		node = node->GetNext();
		original_node = original_node->GetNext();
	}

//  CalculateBoundingBox();
	m_boundWidth = (double)fabs(new_width);
	m_boundHeight = (double)fabs(new_height);
	SetDefaultRegionSize();
}
Пример #3
0
void wxEllipseShape::SetSize(double x, double y, bool WXUNUSED(recursive))
{
	SetAttachmentSize(x, y);
	m_width = x;
	m_height = y;
	SetDefaultRegionSize();
}
Пример #4
0
void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive))
{
  if (m_bitmap.IsOk())
  {
    w = m_bitmap.GetWidth();
    h = m_bitmap.GetHeight();
  }

  SetAttachmentSize(w, h);

  m_width = w;
  m_height = h;
  SetDefaultRegionSize();
}
Пример #5
0
void wxCompositeShape::SetSize(double w, double h, bool recursive)
{
	SetAttachmentSize(w, h);

	double xScale = (double)(w / (wxMax(1.0, GetWidth())));
	double yScale = (double)(h / (wxMax(1.0, GetHeight())));

	m_width = w;
	m_height = h;

	if (!recursive) return;

	wxNode *node = m_children.GetFirst();

	wxClientDC dc(GetCanvas());
	GetCanvas()->PrepareDC(dc);

	double xBound, yBound;
	while (node)
	{
		wxShape *object = (wxShape *)node->GetData();

		// Scale the position first
		double newX = (double)(((object->GetX() - GetX()) * xScale) + GetX());
		double newY = (double)(((object->GetY() - GetY()) * yScale) + GetY());
		object->Show(FALSE);
		object->Move(newX, newY);
		object->Show(TRUE);

		// Now set the scaled size
		object->GetBoundingBoxMin(&xBound, &yBound);
		object->SetSize(object->GetFixedWidth() ? xBound : xScale * xBound,
		                object->GetFixedHeight() ? yBound : yScale * yBound);

		node = node->GetNext();
	}
	SetDefaultRegionSize();
}