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(); }
void wxPolygonShape::Create(wxList *the_points) { ClearPoints(); if (!the_points) { m_originalPoints = new wxList; m_points = new wxList; } else { m_originalPoints = the_points; // Duplicate the list of points m_points = new wxList; wxNode *node = the_points->GetFirst(); while (node) { wxRealPoint *point = (wxRealPoint *)node->GetData(); wxRealPoint *new_point = new wxRealPoint(point->x, point->y); m_points->Append((wxObject *) new_point); node = node->GetNext(); } CalculateBoundingBox(); m_originalWidth = m_boundWidth; m_originalHeight = m_boundHeight; SetDefaultRegionSize(); } }
wxRectangleShape::wxRectangleShape(double w, double h) { m_width = w; m_height = h; m_cornerRadius = 0.0; SetDefaultRegionSize(); }
// 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(); }
void wxEllipseShape::SetSize(double x, double y, bool WXUNUSED(recursive)) { SetAttachmentSize(x, y); m_width = x; m_height = y; SetDefaultRegionSize(); }
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(); }
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(); }
wxEllipseShape::wxEllipseShape(double w, double h) { m_width = w; m_height = h; SetDefaultRegionSize(); }