1 //////////////////////////////////////////////////////////////////////////////
2 // Name:        SVGPointList.cpp
3 // Author:      Alex Thuering
4 // Copyright:   (c) 2005 Alex Thuering
5 // Licence:     wxWindows licence
6 // Notes:       generated by genList.py
7 //////////////////////////////////////////////////////////////////////////////
8 
9 #include "SVGPointList.h"
10 #include <wx/tokenzr.h>
11 #include <wx/arrimpl.cpp>
12 WX_DEFINE_OBJARRAY(wxSVGPointListBase);
13 
GetValueAsString() const14 wxString wxSVGPointList::GetValueAsString() const {
15 	wxString value;
16 	for (int i = 0; i < (int) GetCount(); i++) {
17 		if (i > 0) {
18 			value += wxT(" ");
19 		}
20 		value += wxString::Format(wxT("%g,%g"), Item(i).GetX(), Item(i).GetY());
21 	}
22 	return value;
23 }
24 
SetValueAsString(const wxString & value)25 void wxSVGPointList::SetValueAsString(const wxString& value) {
26 	Clear();
27 	double x, y;
28 	wxStringTokenizer tkz(value, wxT(" \t\r\n"));
29 	while (tkz.HasMoreTokens()) {
30 		wxString token = tkz.GetNextToken().Strip(wxString::both);
31 		if (token.length() && token.Find(wxT(',')) > 0
32 				&& token.BeforeFirst(wxT(',')).ToDouble(&x)
33 				&& token.AfterFirst(wxT(',')).ToDouble(&y)) {
34 			Add(wxSVGPoint(x, y));
35 		}
36 	}
37 }
38