readded flag as xpm. png are not (easily) found
9 QString qpointToString (const QPoint &p)
11 return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
14 ostream &operator<< (ostream &stream, QPoint const &p)
16 return (stream << qpointToString(p) );
19 float getAngle(const QPoint &p)
21 // Calculate angle of vector to y-axis
31 return (float)(M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
34 return (float)( 2*M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
36 return (float)( - atan ( (double)(p.x()) / (double)(p.y()) ) );
40 QPoint normalise(const QPoint &p)
42 // Calculate normalised position (fixed length)
70 return QPoint ((int) (x),(int) (y));
74 // returns masked "<" ">" "&"
75 QString quotemeta(const QString &s)
78 QRegExp rx("&(?!amp;)");
79 r.replace ( rx,"&");
81 r.replace ( rx,">");
83 r.replace ( rx,"<");
85 r.replace ( rx,""");
96 int xmlObj::actindent=0; // make instance of actindent
105 QString xmlObj::singleElement(QString s, QString at)
107 return indent() + "<" + s +" " + at +" " + "/>\n";
111 QString xmlObj::beginElement(QString s)
113 return indent() + "<" + s + ">\n";
117 QString xmlObj::beginElement(QString s, QString at)
119 return indent() + "<" + s + " " + at + ">\n";
123 QString xmlObj::endElement(QString s)
125 return indent() + "</" + s + ">\n";
129 QString xmlObj::attribut(QString at, QString val)
131 return " " + at + "=\"" + quotemeta (val) + "\"";
134 // returns <s> val </s>
135 QString xmlObj::valueElement(QString el, QString val)
137 return indent() + "<" + el + ">" + quotemeta(val) + "</" +el + ">\n";
140 // returns <s at> val </s>
141 QString xmlObj::valueElement(QString el, QString val, QString at)
143 return indent() + "<" + el + " " + at + ">" + quotemeta(val) + "</" +el + ">\n";
146 void xmlObj::incIndent()
151 void xmlObj::decIndent()
154 if (actindent<0) actindent=0;
157 QString xmlObj::indent()
161 for (i=0; i<actindent*indentwidth; i++)