wxDC::DrawPolygon( wxList* list) dilemma

442 views
Skip to first unread message

Tamer El Nashar

unread,
Feb 12, 2005, 5:20:21 AM2/12/05
to wx-u...@lists.wxwidgets.org
wx: CVS
os: WinXP
compiler: VS 2003
wxDesigner: 2.11a

I am trying to draw polygon using the function wxDC::DrawPolygon( const wxList *list ).  However the dilemma I am in is: 

1.  If I define a variable of type wxList m_Polygon, and then try to add any wxPoint to it, it fails, since wxPoint doesn’t inherit from wxObject.
2.  If I then declare my own wxList using:

WX_DECLARE_LIST( wxPoint, wxPointList );
#include <wx/listimpl.cpp>
WX_DEFINE_LIST( wxPointList );

Which works fine and allows me to add wxPoints, except, I can't use it in DrawPolygon since I get the error: cannot convert parameter 1 from 'wxPointList *' to 'const wxList *'

My question is:  So how do I use wxDC::DrawPolygon( const wxList *list )?

Tamer El Nashar

unread,
Feb 12, 2005, 6:43:08 AM2/12/05
to wx-u...@lists.wxwidgets.org
i'd rather not use pointers, and was wondering how the second version of DrawPolygon would be used in general?

James Carroll wrote:
wxPoint in a c-style array []   worked for me:
   
    // a copy of the points in screen coordinates
    wxPoint *screenPoints = new wxPoint[GetNumVerticies()];

    for (int i = 0; i < GetNumVerticies(); i++)
    {
        screenPoints[i] = va.GetScreenPos((wxPoint&)GetVertex(i));
    }

    // the pen and brush of this color
    wxPen pen(GetColor(), 1, wxSOLID);
    pen.SetWidth(GetThickness_p());
    dc.SetPen(pen);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);

    if (GetClosed())
    {
        dc.DrawPolygon(GetNumVerticies(), screenPoints);
    }
    else
    {
        dc.DrawLines(GetNumVerticies(), screenPoints);
    }

-Jim

On Sat, 12 Feb 2005 12:20:21 +0200, Tamer El Nashar <te...@vrsonic.com> wrote:
  
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org



  

James Carroll

unread,
Feb 12, 2005, 6:01:45 AM2/12/05
to wx-u...@lists.wxwidgets.org
wxPoint in a c-style array [] worked for me:

// a copy of the points in screen coordinates
wxPoint *screenPoints = new wxPoint[GetNumVerticies()];

for (int i = 0; i < GetNumVerticies(); i++)
{
screenPoints[i] = va.GetScreenPos((wxPoint&)GetVertex(i));
}

// the pen and brush of this color
wxPen pen(GetColor(), 1, wxSOLID);
pen.SetWidth(GetThickness_p());
dc.SetPen(pen);
dc.SetBrush(*wxTRANSPARENT_BRUSH);

if (GetClosed())
{
dc.DrawPolygon(GetNumVerticies(), screenPoints);
}
else
{
dc.DrawLines(GetNumVerticies(), screenPoints);
}

-Jim

On Sat, 12 Feb 2005 12:20:21 +0200, Tamer El Nashar <te...@vrsonic.com> wrote:

Reply all
Reply to author
Forward
0 new messages