Exemple #1
0
void oglDrawFormattedText(wxDC& dc, wxList *text_list,
                          double m_xpos, double m_ypos, double width, double height,
                          int formatMode)
{
    double xoffset, yoffset;
    if (formatMode & FORMAT_CENTRE_HORIZ)
        xoffset = m_xpos;
    else
        xoffset = (double)(m_xpos - (width / 2.0));

    if (formatMode & FORMAT_CENTRE_VERT)
        yoffset = m_ypos;
    else
        yoffset = (double)(m_ypos - (height / 2.0));

    dc.SetClippingRegion(
        (long)(m_xpos - width/2.0), (long)(m_ypos - height/2.0),
        (long)width+1, (long)height+1); // +1 to allow for rounding errors

    wxObjectList::compatibility_iterator current = text_list->GetFirst();
    while (current)
    {
        wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();

        dc.DrawText(line->GetText(), WXROUND(xoffset + line->GetX()), WXROUND(yoffset + line->GetY()));
        current = current->GetNext();
    }

    dc.DestroyClippingRegion();
}
Exemple #2
0
void ExplainShape::OnDraw(wxDC &dc)
{
    wxBitmap &bmp = GetBitmap();
    if (!bmp.Ok())
        return;

    // We do not draw the root shape
    if (m_rootShape)
        return;

    int x, y;
    x = WXROUND(m_xpos - bmp.GetWidth() / 2.0);
    y = WXROUND(m_ypos - GetHeight() / 2.0);

    dc.DrawBitmap(bmp, x, y, true);

    int w, h;
    dc.SetFont(GetCanvas()->GetFont());
    dc.GetTextExtent(label, &w, &h);

    x = WXROUND(m_xpos - w / 2.0);
    y += bmp.GetHeight() + BMP_BORDER;

    dc.DrawText(label, x, y);
}
void wxBitmapShape::OnDraw(wxDC& dc)
{
  if (!m_bitmap.IsOk())
    return;

  int x, y;
  x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
  y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
  dc.DrawBitmap(m_bitmap, x, y, true);
}
Exemple #4
0
void wxDivisionShape::OnDraw(wxDC &dc)
{
	dc.SetBrush(* wxTRANSPARENT_BRUSH);
	dc.SetBackgroundMode(wxTRANSPARENT);

	double x1 = (double)(GetX() - (GetWidth() / 2.0));
	double y1 = (double)(GetY() - (GetHeight() / 2.0));
	double x2 = (double)(GetX() + (GetWidth() / 2.0));
	double y2 = (double)(GetY() + (GetHeight() / 2.0));

	// Should subtract 1 pixel if drawing under Windows
#ifdef __WXMSW__
	y2 -= (double)1.0;
#endif

	if (m_leftSide)
	{
		dc.SetPen(* m_leftSidePen);
		dc.DrawLine(WXROUND(x1), WXROUND(y2), WXROUND(x1), WXROUND(y1));
	}
	if (m_topSide)
	{
		dc.SetPen(* m_topSidePen);
		dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y1));
	}

	// For testing purposes, draw a rectangle so we know
	// how big the division is.
//    SetBrush(* wxCYAN_BRUSH);
//    wxRectangleShape::OnDraw(dc);
}
Exemple #5
0
void wxPolygonShape::OnDrawOutline(wxDC &dc, double x, double y, double w, double h)
{
	dc.SetBrush(* wxTRANSPARENT_BRUSH);
	// Multiply all points by proportion of new size to old size
	double x_proportion = (double)(fabs(w / m_originalWidth));
	double y_proportion = (double)(fabs(h / m_originalHeight));

	int n = m_originalPoints->GetCount();
	wxPoint *intPoints = new wxPoint[n];
	int i;
	for (i = 0; i < n; i++)
	{
		wxRealPoint *point = (wxRealPoint *) m_originalPoints->Item(i)->GetData();
		intPoints[i].x = WXROUND(x_proportion * point->x);
		intPoints[i].y = WXROUND(y_proportion * point->y);
	}
	dc.DrawPolygon(n, intPoints, WXROUND(x), WXROUND(y));
	delete[] intPoints;
}
Exemple #6
0
void wxPolygonShape::OnDraw(wxDC &dc)
{
	int n = m_points->GetCount();
	wxPoint *intPoints = new wxPoint[n];
	int i;
	for (i = 0; i < n; i++)
	{
		wxRealPoint *point = (wxRealPoint *) m_points->Item(i)->GetData();
		intPoints[i].x = WXROUND(point->x);
		intPoints[i].y = WXROUND(point->y);
	}

	if (m_shadowMode != SHADOW_NONE)
	{
		if (m_shadowBrush)
			dc.SetBrush(* m_shadowBrush);
		dc.SetPen(* g_oglTransparentPen);

		dc.DrawPolygon(n, intPoints, WXROUND(m_xpos + m_shadowOffsetX), WXROUND(m_ypos + m_shadowOffsetY));
	}

	if (m_pen)
	{
		if (m_pen->GetWidth() == 0)
			dc.SetPen(* g_oglTransparentPen);
		else
			dc.SetPen(* m_pen);
	}
	if (m_brush)
		dc.SetBrush(* m_brush);
	dc.DrawPolygon(n, intPoints, WXROUND(m_xpos), WXROUND(m_ypos));

	delete[] intPoints;
}
Exemple #7
0
void wxCompositeShape::OnDraw(wxDC &dc)
{
	double x1 = (double)(m_xpos - m_width / 2.0);
	double y1 = (double)(m_ypos - m_height / 2.0);

	if (m_shadowMode != SHADOW_NONE)
	{
		if (m_shadowBrush)
			dc.SetBrush(* m_shadowBrush);
		dc.SetPen(* g_oglTransparentPen);

		if (m_cornerRadius != 0.0)
			dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
			                        WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
		else
			dc.DrawRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY), WXROUND(m_width), WXROUND(m_height));
	}
}
Exemple #8
0
void ExplainLine::OnDraw(wxDC& dc)
{
    if (m_lineControlPoints)
    {
        dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID));
        dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxLIGHT_GREY, wxSOLID));

        wxPoint *points = new wxPoint[11];
        wxRealPoint *point0 = (wxRealPoint*) m_lineControlPoints->Item(0)->GetData();
        wxRealPoint *point1 = (wxRealPoint*) m_lineControlPoints->Item(1)->GetData();
        wxRealPoint *point2 = (wxRealPoint*) m_lineControlPoints->Item(2)->GetData();
        wxRealPoint *point3 = (wxRealPoint*) m_lineControlPoints->Item(3)->GetData();
    
        double phi  = atan2(point2->y - point1->y, point2->x - point1->x);
        double offs = width * tan(phi/2);

        points[0].x  = WXROUND(point0->x);
        points[0].y  = WXROUND(point0->y) - width;
        points[10].x = WXROUND(point0->x);
        points[10].y = WXROUND(point0->y) + width;

        points[1].x  = WXROUND(point1->x + offs);
        points[1].y  = WXROUND(point1->y) - width;
        points[9].x  = WXROUND(point1->x - offs);
        points[9].y  = WXROUND(point1->y) + width;

        points[2].x  = WXROUND(point2->x + offs);
        points[2].y  = WXROUND(point2->y) - width;
        points[8].x  = WXROUND(point2->x - offs);
        points[8].y  = WXROUND(point2->y) + width;

        points[3].x  = WXROUND(point3->x) - width - ARROWWIDTH;
        points[3].y  = WXROUND(point3->y) - width;
        points[7].x  = WXROUND(point3->x) - width - ARROWWIDTH;
        points[7].y  = WXROUND(point3->y) + width;

        points[4].x  = points[3].x;
        points[4].y  = points[3].y - ARROWWIDTH;
        points[6].x  = points[7].x;
        points[6].y  = points[7].y + ARROWWIDTH;

        points[5].x  = WXROUND(point3->x);
        points[5].y  = WXROUND(point3->y);

        dc.DrawPolygon(11, points, 0, 0);
    }
}