• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
  • svgicons
ksvgiconpainter.cpp
1 /*
2  Copyright (C) 2002 Nikolas Zimmermann <wildfox@kde.org>
3  This file is part of the KDE project
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  aint with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <tqvaluevector.h>
22 #include <tqstringlist.h>
23 #include <tqwmatrix.h>
24 #include <tqregexp.h>
25 #include <tqimage.h>
26 #include <tqdict.h>
27 #include <tqmap.h>
28 #include <tqdom.h>
29 
30 #include <math.h>
31 
32 #include <kdebug.h>
33 
34 #include <libart_lgpl/art_rgba.h>
35 #include <libart_lgpl/art_bpath.h>
36 #include <libart_lgpl/art_vpath.h>
37 #include <libart_lgpl/art_vpath_dash.h>
38 #include <libart_lgpl/art_affine.h>
39 #include <libart_lgpl/art_render_svp.h>
40 #include <libart_lgpl/art_svp.h>
41 #include <libart_lgpl/art_svp_vpath.h>
42 #include <libart_lgpl/art_svp_intersect.h>
43 #include <libart_lgpl/art_svp_vpath_stroke.h>
44 
45 #include "ksvgiconpainter.h"
46 
47 #define ART_END2 10
48 
49 const double deg2rad = 0.017453292519943295769; // pi/180
50 
51 class KSVGIconPainterHelper
52 {
53 public:
54  KSVGIconPainterHelper(int width, int height, KSVGIconPainter *painter)
55  {
56  m_painter = painter;
57 
58  m_clipSVP = 0;
59 
60  m_fillColor = Qt::black;
61 
62  m_useFill = true;
63  m_useStroke = false;
64 
65  m_useFillGradient = false;
66  m_useStrokeGradient = false;
67 
68  m_worldMatrix = new TQWMatrix();
69 
70  // Create new image with alpha support
71  m_image = new TQImage(width, height, 32);
72  m_image->setAlphaBuffer(true);
73 
74  m_strokeWidth = 1.0;
75  m_strokeMiterLimit = 4;
76  m_dashOffset = 0;
77  m_dashes = "";
78 
79  m_opacity = 0xff;
80  m_fillOpacity = 0xff;
81  m_strokeOpacity = 0xff;
82 
83  m_fillRule = "nonzero";
84 
85  m_width = width;
86  m_height = height;
87 
88  m_rowstride = m_width * 4;
89 
90  // Make internal libart rendering buffer transparent
91  m_buffer = art_new(art_u8, m_rowstride * m_height);
92  memset(m_buffer, 0, m_rowstride * m_height);
93 
94  m_tempBuffer = 0;
95  }
96 
97  ~KSVGIconPainterHelper()
98  {
99  if(m_clipSVP)
100  art_svp_free(m_clipSVP);
101 
102  art_free(m_buffer);
103 
104  delete m_image;
105  delete m_worldMatrix;
106 
107  for(TQMap<TQString, ArtGradientLinear *>::Iterator it = m_linearGradientMap.begin(); it != m_linearGradientMap.end(); ++it)
108  {
109  if (!it.data())
110  continue;
111  delete [] it.data()->stops;
112  delete it.data();
113  }
114  for(TQMap<TQString, ArtGradientRadial *>::Iterator it = m_radialGradientMap.begin(); it != m_radialGradientMap.end(); ++it)
115  {
116  if (!it.data())
117  continue;
118  delete [] it.data()->stops;
119  delete it.data();
120  }
121  }
122 
123  ArtVpath *allocVPath(int number)
124  {
125  return art_new(ArtVpath, number);
126  }
127 
128  ArtBpath *allocBPath(int number)
129  {
130  return art_new(ArtBpath, number);
131  }
132 
133  void ensureSpace(TQMemArray<ArtBpath> &vec, int index)
134  {
135  if(vec.size() == (unsigned int) index)
136  vec.resize(index + 1);
137  }
138 
139  void createBuffer()
140  {
141  m_tempBuffer = art_new(art_u8, m_rowstride * m_height);
142  memset(m_tempBuffer, 0, m_rowstride * m_height);
143 
144  // Swap buffers, so we work with the new one internally...
145  art_u8 *temp = m_buffer;
146  m_buffer = m_tempBuffer;
147  m_tempBuffer = temp;
148  }
149 
150  void mixBuffer(int opacity)
151  {
152  art_u8 *srcPixel = m_buffer;
153  art_u8 *dstPixel = m_tempBuffer;
154 
155  for(int y = 0; y < m_height; y++)
156  {
157  for(int x = 0; x < m_width; x++)
158  {
159  art_u8 r, g, b, a;
160 
161  a = srcPixel[4 * x + 3];
162 
163  if(a)
164  {
165  r = srcPixel[4 * x];
166  g = srcPixel[4 * x + 1];
167  b = srcPixel[4 * x + 2];
168 
169  int temp = a * opacity + 0x80;
170  a = (temp + (temp >> 8)) >> 8;
171  art_rgba_run_alpha(dstPixel + 4 * x, r, g, b, a, 1);
172  }
173  }
174 
175  srcPixel += m_rowstride;
176  dstPixel += m_rowstride;
177  }
178 
179  // Re-swap again...
180  art_u8 *temp = m_buffer;
181  m_buffer = m_tempBuffer;
182  m_tempBuffer = temp;
183 
184  art_free(m_tempBuffer);
185  m_tempBuffer = 0;
186  }
187 
188  TQ_UINT32 toArtColor(const TQColor &color)
189  {
190  // Convert in a libart suitable form
191  TQString tempName = color.name();
192  const char *str = tempName.latin1();
193 
194  int result = 0;
195 
196  for(int i = 1; str[i]; i++)
197  {
198  int hexval;
199  if(str[i] >= '0' && str[i] <= '9')
200  hexval = str[i] - '0';
201  else if (str[i] >= 'A' && str[i] <= 'F')
202  hexval = str[i] - 'A' + 10;
203  else if (str[i] >= 'a' && str[i] <= 'f')
204  hexval = str[i] - 'a' + 10;
205  else
206  break;
207 
208  result = (result << 4) + hexval;
209  }
210 
211  return result;
212  }
213 
214  void drawSVP(ArtSVP *svp, TQ_UINT32 rgb, int opacity)
215  {
216  if(!svp)
217  return;
218 
219  ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0);
220  art_render_svp(render, svp);
221 
222  art_render_mask_solid(render, (opacity << 8) + opacity + (opacity >> 7));
223 
224  ArtPixMaxDepth color[3];
225  color[0] = ART_PIX_MAX_FROM_8(rgb >> 16);
226  color[1] = ART_PIX_MAX_FROM_8((rgb >> 8) & 0xff);
227  color[2] = ART_PIX_MAX_FROM_8(rgb & 0xff);
228 
229  art_render_image_solid(render, color);
230  art_render_invoke(render);
231  }
232 
233  void drawBPath(ArtBpath *bpath)
234  {
235  double affine[6];
236  affine[0] = m_worldMatrix->m11();
237  affine[1] = m_worldMatrix->m12();
238  affine[2] = m_worldMatrix->m21();
239  affine[3] = m_worldMatrix->m22();
240  affine[4] = m_worldMatrix->dx();
241  affine[5] = m_worldMatrix->dy();
242 
243  ArtBpath *temp = art_bpath_affine_transform(bpath, affine);
244  ArtVpath *vec = art_bez_path_to_vec(temp, 0.25);
245  art_free(temp);
246  drawPathInternal(vec, affine);
247  }
248 
249  void drawVPath(ArtVpath *vec)
250  {
251  double affine[6];
252  affine[0] = m_worldMatrix->m11();
253  affine[1] = m_worldMatrix->m12();
254  affine[2] = m_worldMatrix->m21();
255  affine[3] = m_worldMatrix->m22();
256  affine[4] = m_worldMatrix->dx();
257  affine[5] = m_worldMatrix->dy();
258 
259  ArtVpath *temp = art_vpath_affine_transform(vec, affine);
260  art_free(vec);
261  vec = temp;
262  drawPathInternal(vec, affine);
263  }
264 
265  void drawPathInternal(ArtVpath *vec, double *affine)
266  {
267  ArtSVP *svp;
268  ArtSVP *fillSVP = 0, *strokeSVP = 0;
269 
270  TQ_UINT32 fillColor = 0, strokeColor = 0;
271 
272  // Filling
273  {
274  int index = -1;
275  TQValueVector<int> toCorrect;
276  while(vec[++index].code != ART_END)
277  {
278  if(vec[index].code == ART_END2)
279  {
280  vec[index].code = ART_LINETO;
281  toCorrect.push_back(index);
282  }
283  }
284 
285  fillColor = toArtColor(m_fillColor);
286 
287  ArtSvpWriter *swr;
288  ArtSVP *temp;
289  temp = art_svp_from_vpath(vec);
290 
291  if(m_fillRule == "evenodd")
292  swr = art_svp_writer_rewind_new(ART_WIND_RULE_ODDEVEN);
293  else
294  swr = art_svp_writer_rewind_new(ART_WIND_RULE_NONZERO);
295 
296  art_svp_intersector(temp, swr);
297  svp = art_svp_writer_rewind_reap(swr);
298 
299  fillSVP = svp;
300 
301  art_svp_free(temp);
302 
303  TQValueVector<int>::iterator it;
304  for(it = toCorrect.begin(); it != toCorrect.end(); ++it)
305  vec[(*it)].code = (ArtPathcode)ART_END2;
306  }
307 
308  // There seems to be a problem when stroke width is zero, this is a quick
309  // fix (Rob).
310  if(m_strokeWidth <= 0)
311  m_useStroke = m_useStrokeGradient = false;
312 
313  // Stroking
314  if(m_useStroke || m_useStrokeGradient)
315  {
316  strokeColor = toArtColor(m_strokeColor);
317 
318  double ratio = art_affine_expansion(affine);
319  double strokeWidth = m_strokeWidth * ratio;
320 
321  ArtPathStrokeJoinType joinStyle = ART_PATH_STROKE_JOIN_MITER;
322  ArtPathStrokeCapType capStyle = ART_PATH_STROKE_CAP_BUTT;
323 
324  if(m_joinStyle == "miter")
325  joinStyle = ART_PATH_STROKE_JOIN_MITER;
326  else if(m_joinStyle == "round")
327  joinStyle = ART_PATH_STROKE_JOIN_ROUND;
328  else if(m_joinStyle == "bevel")
329  joinStyle = ART_PATH_STROKE_JOIN_BEVEL;
330 
331  if(m_capStyle == "butt")
332  capStyle = ART_PATH_STROKE_CAP_BUTT;
333  else if(m_capStyle == "round")
334  capStyle = ART_PATH_STROKE_CAP_ROUND;
335  else if(m_capStyle == "square")
336  capStyle = ART_PATH_STROKE_CAP_SQUARE;
337 
338  if(m_dashes.length() > 0)
339  {
340  TQRegExp reg("[, ]");
341  TQStringList dashList = TQStringList::split(reg, m_dashes);
342 
343  double *dashes = new double[dashList.count()];
344  for(unsigned int i = 0; i < dashList.count(); i++)
345  dashes[i] = m_painter->toPixel(dashList[i], true);
346 
347  ArtVpathDash dash;
348  dash.offset = m_dashOffset;
349  dash.n_dash = dashList.count();
350 
351  dash.dash = dashes;
352 
353  ArtVpath *vec2 = art_vpath_dash(vec, &dash);
354  art_free(vec);
355 
356  delete[] dashes;
357 
358  vec = vec2;
359  }
360 
361  svp = art_svp_vpath_stroke(vec, joinStyle, capStyle, strokeWidth, m_strokeMiterLimit, 0.25);
362 
363  strokeSVP = svp;
364  }
365 
366  // Apply opacity
367  int fillOpacity = static_cast<int>(m_fillOpacity);
368  int strokeOpacity = static_cast<int>(m_strokeOpacity);
369  int opacity = static_cast<int>(m_opacity);
370 
371  // Needed hack, to support both transparent
372  // paths and transparent gradients
373  if(fillOpacity == strokeOpacity && fillOpacity == opacity && !m_useFillGradient && !m_useStrokeGradient)
374  opacity = 255;
375 
376  if(fillOpacity != 255)
377  {
378  int temp = fillOpacity * opacity + 0x80;
379  fillOpacity = (temp + (temp >> 8)) >> 8;
380  }
381 
382  if(strokeOpacity != 255)
383  {
384  int temp = strokeOpacity * opacity + 0x80;
385  strokeOpacity = (temp + (temp >> 8)) >> 8;
386  }
387 
388  // Create temporary buffer if necessary
389  bool tempDone = false;
390  if(m_opacity != 0xff)
391  {
392  tempDone = true;
393  createBuffer();
394  }
395 
396  // Apply Gradients on fill/stroke
397  if(m_useFillGradient)
398  applyGradient(fillSVP, true);
399  else if(m_useFill)
400  drawSVP(fillSVP, fillColor, fillOpacity);
401 
402  if(m_useStrokeGradient)
403  applyGradient(strokeSVP, false);
404  else if(m_useStroke)
405  drawSVP(strokeSVP, strokeColor, strokeOpacity);
406 
407  // Mix in temporary buffer, if possible
408  if(tempDone)
409  mixBuffer(opacity);
410 
411  if(m_clipSVP)
412  {
413  art_svp_free(m_clipSVP);
414  m_clipSVP = 0;
415  }
416 
417  if(fillSVP)
418  art_svp_free(fillSVP);
419 
420  if(strokeSVP)
421  art_svp_free(strokeSVP);
422 
423  // Reset opacity values
424  m_opacity = 255.0;
425  m_fillOpacity = 255.0;
426  m_strokeOpacity = 255.0;
427 
428  art_free(vec);
429  }
430 
431  void applyLinearGradient(ArtSVP *svp, const TQString &ref)
432  {
433  ArtGradientLinear *linear = m_linearGradientMap[ref];
434  if(linear)
435  {
436  TQDomElement element = m_linearGradientElementMap[linear];
437 
438  double x1, y1, x2, y2;
439  if(element.hasAttribute("x1"))
440  x1 = m_painter->toPixel(element.attribute("x1"), true);
441  else
442  x1 = 0;
443 
444  if(element.hasAttribute("y1"))
445  y1 = m_painter->toPixel(element.attribute("y1"), false);
446  else
447  y1 = 0;
448 
449  if(element.hasAttribute("x2"))
450  x2 = m_painter->toPixel(element.attribute("x2"), true);
451  else
452  x2 = 100;
453 
454  if(element.hasAttribute("y2"))
455  y2 = m_painter->toPixel(element.attribute("y2"), false);
456  else
457  y2 = 0;
458 
459  // Adjust to gradientTransform
460  TQWMatrix m = m_painter->parseTransform(element.attribute("gradientTransform"));
461  m.map(x1, y1, &x1, &y1);
462  m.map(x2, y2, &x2, &y2);
463 
464  double x1n = x1 * m_worldMatrix->m11() + y1 * m_worldMatrix->m21() + m_worldMatrix->dx();
465  double y1n = x1 * m_worldMatrix->m12() + y1 * m_worldMatrix->m22() + m_worldMatrix->dy();
466  double x2n = x2 * m_worldMatrix->m11() + y2 * m_worldMatrix->m21() + m_worldMatrix->dx();
467  double y2n = x2 * m_worldMatrix->m12() + y2 * m_worldMatrix->m22() + m_worldMatrix->dy();
468 
469  double dx = x2n - x1n;
470  double dy = y2n - y1n;
471  double scale = 1.0 / (dx * dx + dy * dy);
472 
473  linear->a = dx * scale;
474  linear->b = dy * scale;
475  linear->c = -(x1n * linear->a + y1n * linear->b);
476 
477  ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0);
478  art_render_svp(render, svp);
479 
480  art_render_gradient_linear(render, linear, ART_FILTER_HYPER);
481  art_render_invoke(render);
482  }
483  }
484 
485  void applyRadialGradient(ArtSVP *svp, const TQString &ref)
486  {
487  ArtGradientRadial *radial = m_radialGradientMap[ref];
488  if(radial)
489  {
490  TQDomElement element = m_radialGradientElementMap[radial];
491 
492  double cx, cy, r, fx, fy;
493  if(element.hasAttribute("cx"))
494  cx = m_painter->toPixel(element.attribute("cx"), true);
495  else
496  cx = 50;
497 
498  if(element.hasAttribute("cy"))
499  cy = m_painter->toPixel(element.attribute("cy"), false);
500  else
501  cy = 50;
502 
503  if(element.hasAttribute("r"))
504  r = m_painter->toPixel(element.attribute("r"), true);
505  else
506  r = 50;
507 
508  if(element.hasAttribute("fx"))
509  fx = m_painter->toPixel(element.attribute("fx"), false);
510  else
511  fx = cx;
512 
513  if(element.hasAttribute("fy"))
514  fy = m_painter->toPixel(element.attribute("fy"), false);
515  else
516  fy = cy;
517 
518  radial->affine[0] = m_worldMatrix->m11();
519  radial->affine[1] = m_worldMatrix->m12();
520  radial->affine[2] = m_worldMatrix->m21();
521  radial->affine[3] = m_worldMatrix->m22();
522  radial->affine[4] = m_worldMatrix->dx();
523  radial->affine[5] = m_worldMatrix->dy();
524 
525  radial->fx = (fx - cx) / r;
526  radial->fy = (fy - cy) / r;
527 
528  double aff1[6], aff2[6], gradTransform[6];
529 
530  // Respect gradientTransform
531  TQWMatrix m = m_painter->parseTransform(element.attribute("gradientTransform"));
532 
533  gradTransform[0] = m.m11();
534  gradTransform[1] = m.m12();
535  gradTransform[2] = m.m21();
536  gradTransform[3] = m.m22();
537  gradTransform[4] = m.dx();
538  gradTransform[5] = m.dy();
539 
540  art_affine_scale(aff1, r, r);
541  art_affine_translate(aff2, cx, cy);
542 
543  art_affine_multiply(aff1, aff1, aff2);
544  art_affine_multiply(aff1, aff1, gradTransform);
545  art_affine_multiply(aff1, aff1, radial->affine);
546  art_affine_invert(radial->affine, aff1);
547 
548  ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0);
549  art_render_svp(render, svp);
550 
551  art_render_gradient_radial(render, radial, ART_FILTER_HYPER);
552  art_render_invoke(render);
553  }
554  }
555 
556  void applyGradient(ArtSVP *svp, const TQString &ref)
557  {
558  ArtGradientLinear *linear = m_linearGradientMap[ref];
559  if(linear)
560  {
561  TQDomElement element = m_linearGradientElementMap[linear];
562 
563  if(!element.hasAttribute("xlink:href"))
564  {
565  applyLinearGradient(svp, ref);
566  return;
567  }
568  else
569  {
570  ArtGradientLinear *linear = m_linearGradientMap[element.attribute("xlink:href").mid(1)];
571  TQDomElement newElement = m_linearGradientElementMap[linear];
572 
573  // Saved 'old' attributes
574  TQDict<TQString> refattrs;
575  refattrs.setAutoDelete(true);
576 
577  for(unsigned int i = 0; i < newElement.attributes().length(); ++i)
578  refattrs.insert(newElement.attributes().item(i).nodeName(), new TQString(newElement.attributes().item(i).nodeValue()));
579 
580  // Copy attributes
581  if(!newElement.isNull())
582  {
583  TQDomNamedNodeMap attr = element.attributes();
584 
585  for(unsigned int i = 0; i < attr.length(); i++)
586  {
587  TQString name = attr.item(i).nodeName();
588  if(name != "xlink:href" && name != "id")
589  newElement.setAttribute(name, attr.item(i).nodeValue());
590  }
591  }
592 
593  applyGradient(svp, element.attribute("xlink:href").mid(1));
594 
595  // Restore attributes
596  TQDictIterator<TQString> itr(refattrs);
597  for(; itr.current(); ++itr)
598  newElement.setAttribute(itr.currentKey(), *(itr.current()));
599 
600  return;
601  }
602  }
603 
604  ArtGradientRadial *radial = m_radialGradientMap[ref];
605  if(radial)
606  {
607  TQDomElement element = m_radialGradientElementMap[radial];
608 
609  if(!element.hasAttribute("xlink:href"))
610  {
611  applyRadialGradient(svp, ref);
612  return;
613  }
614  else
615  {
616  ArtGradientRadial *radial = m_radialGradientMap[element.attribute("xlink:href").mid(1)];
617  TQDomElement newElement = m_radialGradientElementMap[radial];
618 
619  // Saved 'old' attributes
620  TQDict<TQString> refattrs;
621  refattrs.setAutoDelete(true);
622 
623  for(unsigned int i = 0; i < newElement.attributes().length(); ++i)
624  refattrs.insert(newElement.attributes().item(i).nodeName(), new TQString(newElement.attributes().item(i).nodeValue()));
625 
626  // Copy attributes
627  if(!newElement.isNull())
628  {
629  TQDomNamedNodeMap attr = element.attributes();
630 
631  for(unsigned int i = 0; i < attr.length(); i++)
632  {
633  TQString name = attr.item(i).nodeName();
634  if(name != "xlink:href" && name != "id")
635  newElement.setAttribute(name, attr.item(i).nodeValue());
636  }
637  }
638 
639  applyGradient(svp, element.attribute("xlink:href").mid(1));
640 
641  // Restore attributes
642  TQDictIterator<TQString> itr(refattrs);
643  for(; itr.current(); ++itr)
644  newElement.setAttribute(itr.currentKey(), *(itr.current()));
645 
646  return;
647  }
648  }
649  }
650 
651  void applyGradient(ArtSVP *svp, bool fill)
652  {
653  TQString ref;
654 
655  if(fill)
656  {
657  m_useFillGradient = false;
658  ref = m_fillGradientReference;
659  }
660  else
661  {
662  m_useStrokeGradient = false;
663  ref = m_strokeGradientReference;
664  }
665 
666  applyGradient(svp, ref);
667  }
668 
669  void blit()
670  {
671  unsigned char *line = m_buffer;
672 
673  for(int y = 0; y < m_height; y++)
674  {
675  TQRgb *sl = reinterpret_cast<TQRgb *>(m_image->scanLine(y));
676  for(int x = 0; x < m_width; x++)
677  sl[x] = tqRgba(line[x * 4], line[x * 4 + 1], line[x * 4 + 2], line[x * 4 + 3]);
678 
679  line += m_rowstride;
680  }
681  }
682 
683  void calculateArc(bool relative, TQMemArray<ArtBpath> &vec, int &index, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag)
684  {
685  double sin_th, cos_th;
686  double a00, a01, a10, a11;
687  double x0, y0, x1, y1, xc, yc;
688  double d, sfactor, sfactor_sq;
689  double th0, th1, th_arc;
690  int i, n_segs;
691 
692  sin_th = sin(angle * (M_PI / 180.0));
693  cos_th = cos(angle * (M_PI / 180.0));
694 
695  double dx;
696 
697  if(!relative)
698  dx = (curx - x) / 2.0;
699  else
700  dx = -x / 2.0;
701 
702  double dy;
703 
704  if(!relative)
705  dy = (cury - y) / 2.0;
706  else
707  dy = -y / 2.0;
708 
709  double _x1 = cos_th * dx + sin_th * dy;
710  double _y1 = -sin_th * dx + cos_th * dy;
711  double Pr1 = r1 * r1;
712  double Pr2 = r2 * r2;
713  double Px = _x1 * _x1;
714  double Py = _y1 * _y1;
715 
716  // Spec : check if radii are large enough
717  double check = Px / Pr1 + Py / Pr2;
718  if(check > 1)
719  {
720  r1 = r1 * sqrt(check);
721  r2 = r2 * sqrt(check);
722  }
723 
724  a00 = cos_th / r1;
725  a01 = sin_th / r1;
726  a10 = -sin_th / r2;
727  a11 = cos_th / r2;
728 
729  x0 = a00 * curx + a01 * cury;
730  y0 = a10 * curx + a11 * cury;
731 
732  if(!relative)
733  x1 = a00 * x + a01 * y;
734  else
735  x1 = a00 * (curx + x) + a01 * (cury + y);
736 
737  if(!relative)
738  y1 = a10 * x + a11 * y;
739  else
740  y1 = a10 * (curx + x) + a11 * (cury + y);
741 
742  /* (x0, y0) is current point in transformed coordinate space.
743  (x1, y1) is new point in transformed coordinate space.
744 
745  The arc fits a unit-radius circle in this space.
746  */
747 
748  d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
749 
750  sfactor_sq = 1.0 / d - 0.25;
751 
752  if(sfactor_sq < 0)
753  sfactor_sq = 0;
754 
755  sfactor = sqrt(sfactor_sq);
756 
757  if(sweepFlag == largeArcFlag)
758  sfactor = -sfactor;
759 
760  xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
761  yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
762 
763  /* (xc, yc) is center of the circle. */
764  th0 = atan2(y0 - yc, x0 - xc);
765  th1 = atan2(y1 - yc, x1 - xc);
766 
767  th_arc = th1 - th0;
768  if(th_arc < 0 && sweepFlag)
769  th_arc += 2 * M_PI;
770  else if(th_arc > 0 && !sweepFlag)
771  th_arc -= 2 * M_PI;
772 
773  n_segs = (int) (int) ceil(fabs(th_arc / (M_PI * 0.5 + 0.001)));
774 
775  for(i = 0; i < n_segs; i++)
776  {
777  index++;
778 
779  ensureSpace(vec, index);
780 
781  {
782  double sin_th, cos_th;
783  double a00, a01, a10, a11;
784  double x1, y1, x2, y2, x3, y3;
785  double t;
786  double th_half;
787 
788  double _th0 = th0 + i * th_arc / n_segs;
789  double _th1 = th0 + (i + 1) * th_arc / n_segs;
790 
791  sin_th = sin(angle * (M_PI / 180.0));
792  cos_th = cos(angle * (M_PI / 180.0));
793 
794  /* inverse transform compared with rsvg_path_arc */
795  a00 = cos_th * r1;
796  a01 = -sin_th * r2;
797  a10 = sin_th * r1;
798  a11 = cos_th * r2;
799 
800  th_half = 0.5 * (_th1 - _th0);
801  t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half);
802  x1 = xc + cos(_th0) - t * sin(_th0);
803  y1 = yc + sin(_th0) + t * cos(_th0);
804  x3 = xc + cos(_th1);
805  y3 = yc + sin(_th1);
806  x2 = x3 + t * sin(_th1);
807  y2 = y3 - t * cos(_th1);
808 
809  ensureSpace(vec, index);
810 
811  vec[index].code = ART_CURVETO;
812  vec[index].x1 = a00 * x1 + a01 * y1;
813  vec[index].y1 = a10 * x1 + a11 * y1;
814  vec[index].x2 = a00 * x2 + a01 * y2;
815  vec[index].y2 = a10 * x2 + a11 * y2;
816  vec[index].x3 = a00 * x3 + a01 * y3;
817  vec[index].y3 = a10 * x3 + a11 * y3;
818  }
819  }
820 
821  if(!relative)
822  curx = x;
823  else
824  curx += x;
825 
826  if(!relative)
827  cury = y;
828  else
829  cury += y;
830  }
831 
832  // For any docs, see the libart library
833  static void art_vpath_render_bez(ArtVpath **p_vpath, int *pn, int *pn_max,
834  double x0, double y0,
835  double x1, double y1,
836  double x2, double y2,
837  double x3, double y3,
838  double flatness)
839  {
840  double x3_0, y3_0, z3_0_dot, z1_dot, z2_dot;
841  double z1_perp, z2_perp, max_perp_sq;
842 
843  double x_m, y_m, xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
844 
845  x3_0 = x3 - x0;
846  y3_0 = y3 - y0;
847 
848  z3_0_dot = x3_0 * x3_0 + y3_0 * y3_0;
849 
850  if (z3_0_dot < 0.001)
851  goto nosubdivide;
852 
853  max_perp_sq = flatness * flatness * z3_0_dot;
854 
855  z1_perp = (y1 - y0) * x3_0 - (x1 - x0) * y3_0;
856  if (z1_perp * z1_perp > max_perp_sq)
857  goto subdivide;
858 
859  z2_perp = (y3 - y2) * x3_0 - (x3 - x2) * y3_0;
860  if (z2_perp * z2_perp > max_perp_sq)
861  goto subdivide;
862 
863  z1_dot = (x1 - x0) * x3_0 + (y1 - y0) * y3_0;
864  if (z1_dot < 0 && z1_dot * z1_dot > max_perp_sq)
865  goto subdivide;
866 
867  z2_dot = (x3 - x2) * x3_0 + (y3 - y2) * y3_0;
868  if (z2_dot < 0 && z2_dot * z2_dot > max_perp_sq)
869  goto subdivide;
870 
871  if (z1_dot + z1_dot > z3_0_dot)
872  goto subdivide;
873 
874  if (z2_dot + z2_dot > z3_0_dot)
875  goto subdivide;
876 
877  nosubdivide:
878  art_vpath_add_point (p_vpath, pn, pn_max, ART_LINETO, x3, y3);
879  return;
880 
881  subdivide:
882  xa1 = (x0 + x1) * 0.5;
883  ya1 = (y0 + y1) * 0.5;
884  xa2 = (x0 + 2 * x1 + x2) * 0.25;
885  ya2 = (y0 + 2 * y1 + y2) * 0.25;
886  xb1 = (x1 + 2 * x2 + x3) * 0.25;
887  yb1 = (y1 + 2 * y2 + y3) * 0.25;
888  xb2 = (x2 + x3) * 0.5;
889  yb2 = (y2 + y3) * 0.5;
890  x_m = (xa2 + xb1) * 0.5;
891  y_m = (ya2 + yb1) * 0.5;
892  art_vpath_render_bez (p_vpath, pn, pn_max, x0, y0, xa1, ya1, xa2, ya2, x_m, y_m, flatness);
893  art_vpath_render_bez (p_vpath, pn, pn_max, x_m, y_m, xb1, yb1, xb2, yb2, x3, y3, flatness);
894  }
895 
896  ArtVpath *art_bez_path_to_vec(const ArtBpath *bez, double flatness)
897  {
898  ArtVpath *vec;
899  int vec_n, vec_n_max;
900  int bez_index;
901  double x, y;
902 
903  vec_n = 0;
904  vec_n_max = (1 << 4);
905  vec = art_new (ArtVpath, vec_n_max);
906 
907  x = 0;
908  y = 0;
909 
910  bez_index = 0;
911  do
912  {
913  if(vec_n >= vec_n_max)
914  art_expand (vec, ArtVpath, vec_n_max);
915 
916  switch (bez[bez_index].code)
917  {
918  case ART_MOVETO_OPEN:
919  case ART_MOVETO:
920  case ART_LINETO:
921  x = bez[bez_index].x3;
922  y = bez[bez_index].y3;
923  vec[vec_n].code = bez[bez_index].code;
924  vec[vec_n].x = x;
925  vec[vec_n].y = y;
926  vec_n++;
927  break;
928  case ART_END:
929  vec[vec_n].code = ART_END;
930  vec[vec_n].x = 0;
931  vec[vec_n].y = 0;
932  vec_n++;
933  break;
934  case ART_END2:
935  vec[vec_n].code = (ArtPathcode)ART_END2;
936  vec[vec_n].x = bez[bez_index].x3;
937  vec[vec_n].y = bez[bez_index].y3;
938  vec_n++;
939  break;
940  case ART_CURVETO:
941  art_vpath_render_bez (&vec, &vec_n, &vec_n_max,
942  x, y,
943  bez[bez_index].x1, bez[bez_index].y1,
944  bez[bez_index].x2, bez[bez_index].y2,
945  bez[bez_index].x3, bez[bez_index].y3,
946  flatness);
947  x = bez[bez_index].x3;
948  y = bez[bez_index].y3;
949  break;
950  }
951  }
952 
953  while (bez[bez_index++].code != ART_END);
954  return vec;
955  }
956 
957  static void art_rgb_affine_run(int *p_x0, int *p_x1, int y,
958  int src_width, int src_height,
959  const double affine[6])
960  {
961  int x0, x1;
962  double z;
963  double x_intercept;
964  int xi;
965 
966  x0 = *p_x0;
967  x1 = *p_x1;
968 
969  if (affine[0] > 1e-6)
970  {
971  z = affine[2] * (y + 0.5) + affine[4];
972  x_intercept = -z / affine[0];
973  xi = (int) (int) ceil (x_intercept + 1e-6 - 0.5);
974  if (xi > x0)
975  x0 = xi;
976  x_intercept = (-z + src_width) / affine[0];
977  xi = (int) ceil (x_intercept - 1e-6 - 0.5);
978  if (xi < x1)
979  x1 = xi;
980  }
981  else if (affine[0] < -1e-6)
982  {
983  z = affine[2] * (y + 0.5) + affine[4];
984  x_intercept = (-z + src_width) / affine[0];
985  xi = (int) ceil (x_intercept + 1e-6 - 0.5);
986  if (xi > x0)
987  x0 = xi;
988  x_intercept = -z / affine[0];
989  xi = (int) ceil (x_intercept - 1e-6 - 0.5);
990  if (xi < x1)
991  x1 = xi;
992  }
993  else
994  {
995  z = affine[2] * (y + 0.5) + affine[4];
996  if (z < 0 || z >= src_width)
997  {
998  *p_x1 = *p_x0;
999  return;
1000  }
1001  }
1002  if (affine[1] > 1e-6)
1003  {
1004  z = affine[3] * (y + 0.5) + affine[5];
1005  x_intercept = -z / affine[1];
1006  xi = (int) ceil (x_intercept + 1e-6 - 0.5);
1007  if (xi > x0)
1008  x0 = xi;
1009  x_intercept = (-z + src_height) / affine[1];
1010  xi = (int) ceil (x_intercept - 1e-6 - 0.5);
1011  if (xi < x1)
1012  x1 = xi;
1013  }
1014  else if (affine[1] < -1e-6)
1015  {
1016  z = affine[3] * (y + 0.5) + affine[5];
1017  x_intercept = (-z + src_height) / affine[1];
1018  xi = (int) ceil (x_intercept + 1e-6 - 0.5);
1019  if (xi > x0)
1020  x0 = xi;
1021  x_intercept = -z / affine[1];
1022  xi = (int) ceil (x_intercept - 1e-6 - 0.5);
1023  if (xi < x1)
1024  x1 = xi;
1025  }
1026  else
1027  {
1028  z = affine[3] * (y + 0.5) + affine[5];
1029  if (z < 0 || z >= src_height)
1030  {
1031  *p_x1 = *p_x0;
1032  return;
1033  }
1034  }
1035 
1036  *p_x0 = x0;
1037  *p_x1 = x1;
1038  }
1039 
1040  // Slightly modified version to support RGBA buffers, copied from gnome-print
1041  static void art_rgba_rgba_affine(art_u8 *dst,
1042  int x0, int y0, int x1, int y1, int dst_rowstride,
1043  const art_u8 *src,
1044  int src_width, int src_height, int src_rowstride,
1045  const double affine[6])
1046  {
1047  int x, y;
1048  double inv[6];
1049  art_u8 *dst_p, *dst_linestart;
1050  const art_u8 *src_p;
1051  ArtPoint pt, src_pt;
1052  int src_x, src_y;
1053  int alpha;
1054  art_u8 bg_r, bg_g, bg_b, bg_a, cr, cg, cb;
1055  art_u8 fg_r, fg_g, fg_b;
1056  int tmp;
1057  int run_x0, run_x1;
1058 
1059  dst_linestart = dst;
1060  art_affine_invert (inv, affine);
1061  for (y = y0; y < y1; y++)
1062  {
1063  pt.y = y + 0.5;
1064  run_x0 = x0;
1065  run_x1 = x1;
1066  art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height,
1067  inv);
1068  dst_p = dst_linestart + (run_x0 - x0) * 4;
1069  for (x = run_x0; x < run_x1; x++)
1070  {
1071  pt.x = x + 0.5;
1072  art_affine_point (&src_pt, &pt, inv);
1073  src_x = (int) floor (src_pt.x);
1074  src_y = (int) floor (src_pt.y);
1075  src_p = src + (src_y * src_rowstride) + src_x * 4;
1076  if (src_x >= 0 && src_x < src_width &&
1077  src_y >= 0 && src_y < src_height)
1078  {
1079 
1080  alpha = src_p[3];
1081  if (alpha)
1082  {
1083  if (alpha == 255)
1084  {
1085  dst_p[0] = src_p[0];
1086  dst_p[1] = src_p[1];
1087  dst_p[2] = src_p[2];
1088  dst_p[3] = 255;
1089  }
1090  else
1091  {
1092  bg_r = dst_p[0];
1093  bg_g = dst_p[1];
1094  bg_b = dst_p[2];
1095  bg_a = dst_p[3];
1096 
1097  cr = (bg_r * bg_a + 0x80) >> 8;
1098  cg = (bg_g * bg_g + 0x80) >> 8;
1099  cb = (bg_b * bg_b + 0x80) >> 8;
1100 
1101  tmp = (src_p[0] - bg_r) * alpha;
1102  fg_r = bg_r + ((tmp + (tmp >> 8) + 0x80) >> 8);
1103  tmp = (src_p[1] - bg_g) * alpha;
1104  fg_g = bg_g + ((tmp + (tmp >> 8) + 0x80) >> 8);
1105  tmp = (src_p[2] - bg_b) * alpha;
1106  fg_b = bg_b + ((tmp + (tmp >> 8) + 0x80) >> 8);
1107 
1108  dst_p[0] = fg_r;
1109  dst_p[1] = fg_g;
1110  dst_p[2] = fg_b;
1111  dst_p[3] = bg_a + (((255 - bg_a) * alpha + 0x80) >> 8);
1112  }
1113  }
1114  } else { dst_p[0] = 255; dst_p[1] = 0; dst_p[2] = 0; dst_p[3] = 255;}
1115  dst_p += 4;
1116  }
1117  dst_linestart += dst_rowstride;
1118  }
1119  }
1120 
1121 private:
1122  friend class KSVGIconPainter;
1123  ArtSVP *m_clipSVP;
1124 
1125  TQImage *m_image;
1126  TQWMatrix *m_worldMatrix;
1127 
1128  TQString m_fillRule;
1129  TQString m_joinStyle;
1130  TQString m_capStyle;
1131 
1132  int m_strokeMiterLimit;
1133 
1134  TQString m_dashes;
1135  unsigned short m_dashOffset;
1136 
1137  TQColor m_fillColor;
1138  TQColor m_strokeColor;
1139 
1140  art_u8 *m_buffer;
1141  art_u8 *m_tempBuffer;
1142 
1143  int m_width;
1144  int m_height;
1145 
1146  int m_rowstride;
1147 
1148  double m_opacity;
1149  double m_fillOpacity;
1150  double m_strokeOpacity;
1151 
1152  bool m_useFill;
1153  bool m_useStroke;
1154 
1155  bool m_useFillGradient;
1156  bool m_useStrokeGradient;
1157 
1158  TQString m_fillGradientReference;
1159  TQString m_strokeGradientReference;
1160 
1161  TQMap<TQString, ArtGradientLinear *> m_linearGradientMap;
1162  TQMap<ArtGradientLinear *, TQDomElement> m_linearGradientElementMap;
1163 
1164  TQMap<TQString, ArtGradientRadial *> m_radialGradientMap;
1165  TQMap<ArtGradientRadial *, TQDomElement> m_radialGradientElementMap;
1166 
1167  KSVGIconPainter *m_painter;
1168 
1169  double m_strokeWidth;
1170 };
1171 
1172 struct KSVGIconPainter::Private
1173 {
1174  KSVGIconPainterHelper *helper;
1175 
1176  int drawWidth;
1177  int drawHeight;
1178 };
1179 
1180 KSVGIconPainter::KSVGIconPainter(int width, int height) : d(new Private())
1181 {
1182  d->helper = new KSVGIconPainterHelper(width, height, this);
1183 
1184  d->drawWidth = width;
1185  d->drawHeight = height;
1186 }
1187 
1188 KSVGIconPainter::~KSVGIconPainter()
1189 {
1190  delete d->helper;
1191  delete d;
1192 }
1193 
1194 void KSVGIconPainter::setDrawWidth(int dwidth)
1195 {
1196  d->drawWidth = dwidth;
1197 }
1198 
1199 void KSVGIconPainter::setDrawHeight(int dheight)
1200 {
1201  d->drawHeight = dheight;
1202 }
1203 
1204 void KSVGIconPainter::finish()
1205 {
1206  d->helper->blit();
1207 }
1208 
1209 TQImage *KSVGIconPainter::image()
1210 {
1211  return new TQImage(*d->helper->m_image);
1212 }
1213 
1214 TQWMatrix *KSVGIconPainter::worldMatrix()
1215 {
1216  return d->helper->m_worldMatrix;
1217 }
1218 
1219 void KSVGIconPainter::setWorldMatrix(TQWMatrix *matrix)
1220 {
1221  if(d->helper->m_worldMatrix)
1222  delete d->helper->m_worldMatrix;
1223 
1224  d->helper->m_worldMatrix = matrix;
1225 }
1226 
1227 void KSVGIconPainter::setStrokeWidth(double width)
1228 {
1229  d->helper->m_strokeWidth = width;
1230 }
1231 
1232 void KSVGIconPainter::setStrokeMiterLimit(const TQString &miter)
1233 {
1234  d->helper->m_strokeMiterLimit = miter.toInt();
1235 }
1236 
1237 void KSVGIconPainter::setStrokeDashOffset(const TQString &dashOffset)
1238 {
1239  d->helper->m_dashOffset = dashOffset.toUInt();
1240 }
1241 
1242 void KSVGIconPainter::setStrokeDashArray(const TQString &dashes)
1243 {
1244  d->helper->m_dashes = dashes;
1245 }
1246 
1247 void KSVGIconPainter::setCapStyle(const TQString &cap)
1248 {
1249  d->helper->m_capStyle = cap;
1250 }
1251 
1252 void KSVGIconPainter::setJoinStyle(const TQString &join)
1253 {
1254  d->helper->m_joinStyle = join;
1255 }
1256 
1257 void KSVGIconPainter::setStrokeColor(const TQString &stroke)
1258 {
1259  if(stroke.startsWith("url"))
1260  {
1261  d->helper->m_useStroke = false;
1262  d->helper->m_useStrokeGradient = true;
1263 
1264  TQString url = stroke;
1265 
1266  unsigned int start = url.find("#") + 1;
1267  unsigned int end = url.findRev(")");
1268 
1269  d->helper->m_strokeGradientReference = url.mid(start, end - start);
1270  }
1271  else
1272  {
1273  d->helper->m_strokeColor = parseColor(stroke);
1274 
1275  d->helper->m_useStrokeGradient = false;
1276  d->helper->m_strokeGradientReference = TQString::null;
1277 
1278  if(stroke.stripWhiteSpace().lower() != "none")
1279  setUseStroke(true);
1280  else
1281  setUseStroke(false);
1282  }
1283 }
1284 
1285 void KSVGIconPainter::setFillColor(const TQString &fill)
1286 {
1287  if(fill.startsWith("url"))
1288  {
1289  d->helper->m_useFill = false;
1290  d->helper->m_useFillGradient = true;
1291 
1292  TQString url = fill;
1293 
1294  unsigned int start = url.find("#") + 1;
1295  unsigned int end = url.findRev(")");
1296 
1297  d->helper->m_fillGradientReference = url.mid(start, end - start);
1298  }
1299  else
1300  {
1301  d->helper->m_fillColor = parseColor(fill);
1302 
1303  d->helper->m_useFillGradient = false;
1304  d->helper->m_fillGradientReference = TQString::null;
1305 
1306  if(fill.stripWhiteSpace().lower() != "none")
1307  setUseFill(true);
1308  else
1309  setUseFill(false);
1310  }
1311 }
1312 
1313 void KSVGIconPainter::setFillRule(const TQString &fillRule)
1314 {
1315  d->helper->m_fillRule = fillRule;
1316 }
1317 
1318 TQ_UINT32 KSVGIconPainter::parseOpacity(const TQString &data)
1319 {
1320  int opacity = 255;
1321 
1322  if(!data.isEmpty())
1323  {
1324  double temp;
1325 
1326  if(data.contains("%"))
1327  {
1328  TQString tempString = data.left(data.length() - 1);
1329  temp = double(255 * tempString.toDouble()) / 100.0;
1330  }
1331  else
1332  temp = data.toDouble();
1333 
1334  opacity = (int) floor(temp * 255 + 0.5);
1335  }
1336 
1337  return opacity;
1338 }
1339 
1340 void KSVGIconPainter::setFillOpacity(const TQString &fillOpacity)
1341 {
1342  d->helper->m_fillOpacity = parseOpacity(fillOpacity);
1343 }
1344 
1345 void KSVGIconPainter::setStrokeOpacity(const TQString &strokeOpacity)
1346 {
1347  d->helper->m_strokeOpacity = parseOpacity(strokeOpacity);
1348 }
1349 
1350 void KSVGIconPainter::setOpacity(const TQString &opacity)
1351 {
1352  d->helper->m_opacity = parseOpacity(opacity);
1353 }
1354 
1355 void KSVGIconPainter::setUseFill(bool fill)
1356 {
1357  d->helper->m_useFill = fill;
1358 }
1359 
1360 void KSVGIconPainter::setUseStroke(bool stroke)
1361 {
1362  d->helper->m_useStroke = stroke;
1363 }
1364 
1365 void KSVGIconPainter::setClippingRect(int x, int y, int w, int h)
1366 {
1367  ArtVpath *vec = d->helper->allocVPath(6);
1368 
1369  vec[0].code = ART_MOVETO;
1370  vec[0].x = x;
1371  vec[0].y = y;
1372 
1373  vec[1].code = ART_LINETO;
1374  vec[1].x = x;
1375  vec[1].y = y + h;
1376 
1377  vec[2].code = ART_LINETO;
1378  vec[2].x = x + w;
1379  vec[2].y = y + h;
1380 
1381  vec[3].code = ART_LINETO;
1382  vec[3].x = x + w;
1383  vec[3].y = y;
1384 
1385  vec[4].code = ART_LINETO;
1386  vec[4].x = x;
1387  vec[4].y = y;
1388 
1389  vec[5].code = ART_END;
1390 
1391  if(d->helper->m_clipSVP)
1392  art_svp_free(d->helper->m_clipSVP);
1393 
1394  d->helper->m_clipSVP = art_svp_from_vpath(vec);
1395 
1396  art_free(vec);
1397 }
1398 
1399 void KSVGIconPainter::drawRectangle(double x, double y, double w, double h, double rx, double ry)
1400 {
1401  if((int) rx != 0 && (int) ry != 0)
1402  {
1403  ArtVpath *res;
1404  ArtBpath *vec = d->helper->allocBPath(10);
1405 
1406  int i = 0;
1407 
1408  if(rx > w / 2)
1409  rx = w / 2;
1410 
1411  if(ry > h / 2)
1412  ry = h / 2;
1413 
1414  vec[i].code = ART_MOVETO_OPEN;
1415  vec[i].x3 = x + rx;
1416  vec[i].y3 = y;
1417 
1418  i++;
1419 
1420  vec[i].code = ART_CURVETO;
1421  vec[i].x1 = x + rx * (1 - 0.552);
1422  vec[i].y1 = y;
1423  vec[i].x2 = x;
1424  vec[i].y2 = y + ry * (1 - 0.552);
1425  vec[i].x3 = x;
1426  vec[i].y3 = y + ry;
1427 
1428  i++;
1429 
1430  if(ry < h / 2)
1431  {
1432  vec[i].code = ART_LINETO;
1433  vec[i].x3 = x;
1434  vec[i].y3 = y + h - ry;
1435 
1436  i++;
1437  }
1438 
1439  vec[i].code = ART_CURVETO;
1440  vec[i].x1 = x;
1441  vec[i].y1 = y + h - ry * (1 - 0.552);
1442  vec[i].x2 = x + rx * (1 - 0.552);
1443  vec[i].y2 = y + h;
1444  vec[i].x3 = x + rx;
1445  vec[i].y3 = y + h;
1446 
1447  i++;
1448 
1449  if(rx < w / 2)
1450  {
1451  vec[i].code = ART_LINETO;
1452  vec[i].x3 = x + w - rx;
1453  vec[i].y3 = y + h;
1454 
1455  i++;
1456  }
1457 
1458  vec[i].code = ART_CURVETO;
1459  vec[i].x1 = x + w - rx * (1 - 0.552);
1460  vec[i].y1 = y + h;
1461  vec[i].x2 = x + w;
1462  vec[i].y2 = y + h - ry * (1 - 0.552);
1463  vec[i].x3 = x + w;
1464 
1465  vec[i].y3 = y + h - ry;
1466 
1467  i++;
1468 
1469  if(ry < h / 2)
1470  {
1471  vec[i].code = ART_LINETO;
1472  vec[i].x3 = x + w;
1473  vec[i].y3 = y + ry;
1474 
1475  i++;
1476  }
1477 
1478  vec[i].code = ART_CURVETO;
1479  vec[i].x1 = x + w;
1480  vec[i].y1 = y + ry * (1 - 0.552);
1481  vec[i].x2 = x + w - rx * (1 - 0.552);
1482  vec[i].y2 = y;
1483  vec[i].x3 = x + w - rx;
1484  vec[i].y3 = y;
1485 
1486  i++;
1487 
1488  if(rx < w / 2)
1489  {
1490  vec[i].code = ART_LINETO;
1491  vec[i].x3 = x + rx;
1492  vec[i].y3 = y;
1493 
1494  i++;
1495  }
1496 
1497  vec[i].code = ART_END;
1498 
1499  res = d->helper->art_bez_path_to_vec(vec, 0.25);
1500  art_free(vec);
1501  d->helper->drawVPath(res);
1502  }
1503  else
1504  {
1505  ArtVpath *vec = d->helper->allocVPath(6);
1506 
1507  vec[0].code = ART_MOVETO;
1508  vec[0].x = x;
1509  vec[0].y = y;
1510 
1511  vec[1].code = ART_LINETO;
1512  vec[1].x = x;
1513  vec[1].y = y + h;
1514 
1515  vec[2].code = ART_LINETO;
1516  vec[2].x = x + w;
1517  vec[2].y = y + h;
1518 
1519  vec[3].code = ART_LINETO;
1520  vec[3].x = x + w;
1521  vec[3].y = y;
1522 
1523  vec[4].code = ART_LINETO;
1524  vec[4].x = x;
1525  vec[4].y = y;
1526 
1527  vec[5].code = ART_END;
1528 
1529  d->helper->drawVPath(vec);
1530  }
1531 }
1532 
1533 void KSVGIconPainter::drawEllipse(double cx, double cy, double rx, double ry)
1534 {
1535  ArtBpath *temp;
1536 
1537  temp = d->helper->allocBPath(6);
1538 
1539  double x1, y1, x2, y2, x3, y3;
1540  double len = 0.55228474983079356;
1541  double cos4[] = {1.0, 0.0, -1.0, 0.0, 1.0};
1542  double sin4[] = {0.0, 1.0, 0.0, -1.0, 0.0};
1543  int i = 0;
1544 
1545  temp[i].code = ART_MOVETO;
1546  temp[i].x3 = cx + rx;
1547  temp[i].y3 = cy;
1548 
1549  i++;
1550 
1551  while(i < 5)
1552  {
1553  x1 = cos4[i-1] + len * cos4[i];
1554  y1 = sin4[i-1] + len * sin4[i];
1555  x2 = cos4[i] + len * cos4[i-1];
1556  y2 = sin4[i] + len * sin4[i-1];
1557  x3 = cos4[i];
1558  y3 = sin4[i];
1559 
1560  temp[i].code = ART_CURVETO;
1561  temp[i].x1 = cx + x1 * rx;
1562  temp[i].y1 = cy + y1 * ry;
1563  temp[i].x2 = cx + x2 * rx;
1564  temp[i].y2 = cy + y2 * ry;
1565  temp[i].x3 = cx + x3 * rx;
1566  temp[i].y3 = cy + y3 * ry;
1567 
1568  i++;
1569  }
1570 
1571  temp[i].code = ART_END;
1572 
1573  d->helper->drawBPath(temp);
1574 
1575  art_free(temp);
1576 }
1577 
1578 void KSVGIconPainter::drawLine(double x1, double y1, double x2, double y2)
1579 {
1580  ArtVpath *vec;
1581 
1582  vec = d->helper->allocVPath(3);
1583 
1584  vec[0].code = ART_MOVETO_OPEN;
1585  vec[0].x = x1;
1586  vec[0].y = y1;
1587 
1588  vec[1].code = ART_LINETO;
1589  vec[1].x = x2;
1590  vec[1].y = y2;
1591 
1592  vec[2].code = ART_END;
1593 
1594  d->helper->drawVPath(vec);
1595 }
1596 
1597 void KSVGIconPainter::drawPolyline(TQPointArray polyArray, int points)
1598 {
1599  if(polyArray.point(0).x() == -1 || polyArray.point(0).y() == -1)
1600  return;
1601 
1602  ArtVpath *polyline;
1603 
1604  if(points == -1)
1605  points = polyArray.count();
1606 
1607  polyline = d->helper->allocVPath(3 + points);
1608  polyline[0].code = ART_MOVETO;
1609  polyline[0].x = polyArray.point(0).x();
1610  polyline[0].y = polyArray.point(0).y();
1611 
1612  int index;
1613  for(index = 1; index < points; index++)
1614  {
1615  TQPoint point = polyArray.point(index);
1616  polyline[index].code = ART_LINETO;
1617  polyline[index].x = point.x();
1618  polyline[index].y = point.y();
1619  }
1620 
1621  if(d->helper->m_useFill) // if the polyline must be filled, inform libart that it should not be closed.
1622  {
1623  polyline[index].code = (ArtPathcode)ART_END2;
1624  polyline[index].x = polyArray.point(0).x();
1625  polyline[index++].y = polyArray.point(0).y();
1626  }
1627 
1628  polyline[index].code = ART_END;
1629 
1630  d->helper->drawVPath(polyline);
1631 }
1632 
1633 void KSVGIconPainter::drawPolygon(TQPointArray polyArray)
1634 {
1635  ArtVpath *polygon;
1636 
1637  polygon = d->helper->allocVPath(3 + polyArray.count());
1638  polygon[0].code = ART_MOVETO;
1639  polygon[0].x = polyArray.point(0).x();
1640  polygon[0].y = polyArray.point(0).y();
1641 
1642  unsigned int index;
1643  for(index = 1; index < polyArray.count(); index++)
1644  {
1645  TQPoint point = polyArray.point(index);
1646  polygon[index].code = ART_LINETO;
1647  polygon[index].x = point.x();
1648  polygon[index].y = point.y();
1649  }
1650 
1651  polygon[index].code = ART_LINETO;
1652  polygon[index].x = polyArray.point(0).x();
1653  polygon[index].y = polyArray.point(0).y();
1654 
1655  index++;
1656  polygon[index].code = ART_END;
1657 
1658  d->helper->drawVPath(polygon);
1659 }
1660 
1661 // Path parsing tool
1662 // parses the coord into number and forwards to the next token
1663 static const char *getCoord(const char *ptr, double &number)
1664 {
1665  int integer, exponent;
1666  double decimal, frac;
1667  int sign, expsign;
1668 
1669  exponent = 0;
1670  integer = 0;
1671  frac = 1.0;
1672  decimal = 0;
1673  sign = 1;
1674  expsign = 1;
1675 
1676  // read the sign
1677  if(*ptr == '+')
1678  ptr++;
1679  else if(*ptr == '-')
1680  {
1681  ptr++;
1682  sign = -1;
1683  }
1684  // read the integer part
1685  while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
1686  integer = (integer * 10) + *(ptr++) - '0';
1687 
1688  if(*ptr == '.') // read the decimals
1689  {
1690  ptr++;
1691  while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
1692  decimal += (*(ptr++) - '0') * (frac *= 0.1);
1693  }
1694 
1695  if(*ptr == 'e' || *ptr == 'E') // read the exponent part
1696  {
1697  ptr++;
1698 
1699  // read the sign of the exponent
1700  if(*ptr == '+')
1701  ptr++;
1702  else if(*ptr == '-')
1703  {
1704  ptr++;
1705  expsign = -1;
1706  }
1707 
1708  exponent = 0;
1709  while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
1710  {
1711  exponent *= 10;
1712  exponent += *ptr - '0';
1713  ptr++;
1714  }
1715  }
1716 
1717  number = integer + decimal;
1718  number *= sign * pow(10.0, expsign * exponent);
1719 
1720  // skip the following space
1721  if(*ptr == ' ')
1722  ptr++;
1723 
1724  return ptr;
1725 }
1726 
1727 void KSVGIconPainter::drawPath(const TQString &data, bool filled)
1728 {
1729  if (!data.isEmpty())
1730  {
1731  TQString value = data;
1732 
1733  TQMemArray<ArtBpath> vec;
1734  int index = -1;
1735 
1736  double curx = 0.0, cury = 0.0, contrlx = 0.0, contrly = 0.0, xc, yc;
1737  unsigned int lastCommand = 0;
1738 
1739  TQString _d = value.replace(",", " ");
1740  _d = _d.simplifyWhiteSpace();
1741  const char *ptr = _d.latin1();
1742  const char *end = _d.latin1() + _d.length() + 1;
1743 
1744  double tox, toy, x1, y1, x2, y2, rx, ry, angle;
1745  bool largeArc, sweep;
1746  char command = *(ptr++);
1747 
1748  while(ptr < end)
1749  {
1750  if(*ptr == ' ')
1751  ptr++;
1752 
1753  switch(command)
1754  {
1755  case 'm':
1756  ptr = getCoord(ptr, tox);
1757  ptr = getCoord(ptr, toy);
1758 
1759  if(index != -1 && lastCommand != 'z')
1760  {
1761  // Find last subpath
1762  int find = -1;
1763  for(int i = index; i >= 0; i--)
1764  {
1765  if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO)
1766  {
1767  find = i;
1768  break;
1769  }
1770  }
1771 
1772  index++;
1773 
1774  if(vec.size() == (unsigned int) index)
1775  vec.resize(index + 1);
1776 
1777  vec[index].code = (ArtPathcode)ART_END2;
1778  vec[index].x3 = vec[find].x3;
1779  vec[index].y3 = vec[find].y3;
1780  }
1781 
1782  curx += tox;
1783  cury += toy;
1784 
1785  index++;
1786 
1787  d->helper->ensureSpace(vec, index);
1788 
1789  vec[index].code = (index == 0) ? ART_MOVETO : ART_MOVETO_OPEN;
1790  vec[index].x3 = curx;
1791  vec[index].y3 = cury;
1792 
1793  lastCommand = 'm';
1794  break;
1795  case 'M':
1796  ptr = getCoord(ptr, tox);
1797  ptr = getCoord(ptr, toy);
1798  if(index != -1 && lastCommand != 'z')
1799  {
1800  // Find last subpath
1801  int find = -1;
1802  for(int i = index; i >= 0; i--)
1803  {
1804  if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO)
1805  {
1806  find = i;
1807  break;
1808  }
1809  }
1810 
1811  index++;
1812 
1813  if(vec.size() == (unsigned int) index)
1814  vec.resize(index + 1);
1815 
1816  vec[index].code = (ArtPathcode)ART_END2;
1817  vec[index].x3 = vec[find].x3;
1818  vec[index].y3 = vec[find].y3;
1819  }
1820 
1821  curx = tox;
1822  cury = toy;
1823 
1824  index++;
1825 
1826  d->helper->ensureSpace(vec, index);
1827 
1828  vec[index].code = (index == 0) ? ART_MOVETO : ART_MOVETO_OPEN;
1829  vec[index].x3 = curx;
1830  vec[index].y3 = cury;
1831 
1832  lastCommand = 'M';
1833  break;
1834  case 'l':
1835  ptr = getCoord(ptr, tox);
1836  ptr = getCoord(ptr, toy);
1837 
1838  index++;
1839 
1840  d->helper->ensureSpace(vec, index);
1841 
1842  vec[index].code = ART_LINETO;
1843  vec[index].x3 = curx + tox;
1844  vec[index].y3 = cury + toy;
1845 
1846  curx += tox;
1847  cury += toy;
1848 
1849  lastCommand = 'l';
1850  break;
1851  case 'L':
1852  ptr = getCoord(ptr, tox);
1853  ptr = getCoord(ptr, toy);
1854 
1855  index++;
1856 
1857  d->helper->ensureSpace(vec, index);
1858 
1859  vec[index].code = ART_LINETO;
1860  vec[index].x3 = tox;
1861  vec[index].y3 = toy;
1862 
1863  curx = tox;
1864  cury = toy;
1865 
1866  lastCommand = 'L';
1867  break;
1868  case 'h':
1869  ptr = getCoord(ptr, tox);
1870 
1871  index++;
1872 
1873  curx += tox;
1874 
1875  d->helper->ensureSpace(vec, index);
1876 
1877  vec[index].code = ART_LINETO;
1878  vec[index].x3 = curx;
1879  vec[index].y3 = cury;
1880 
1881  lastCommand = 'h';
1882  break;
1883  case 'H':
1884  ptr = getCoord(ptr, tox);
1885 
1886  index++;
1887 
1888  curx = tox;
1889 
1890  d->helper->ensureSpace(vec, index);
1891 
1892  vec[index].code = ART_LINETO;
1893  vec[index].x3 = curx;
1894  vec[index].y3 = cury;
1895 
1896  lastCommand = 'H';
1897  break;
1898  case 'v':
1899  ptr = getCoord(ptr, toy);
1900 
1901  index++;
1902 
1903  cury += toy;
1904 
1905  d->helper->ensureSpace(vec, index);
1906 
1907  vec[index].code = ART_LINETO;
1908  vec[index].x3 = curx;
1909  vec[index].y3 = cury;
1910 
1911  lastCommand = 'v';
1912  break;
1913  case 'V':
1914  ptr = getCoord(ptr, toy);
1915 
1916  index++;
1917 
1918  cury = toy;
1919 
1920  d->helper->ensureSpace(vec, index);
1921 
1922  vec[index].code = ART_LINETO;
1923  vec[index].x3 = curx;
1924  vec[index].y3 = cury;
1925 
1926  lastCommand = 'V';
1927  break;
1928  case 'c':
1929  ptr = getCoord(ptr, x1);
1930  ptr = getCoord(ptr, y1);
1931  ptr = getCoord(ptr, x2);
1932  ptr = getCoord(ptr, y2);
1933  ptr = getCoord(ptr, tox);
1934  ptr = getCoord(ptr, toy);
1935 
1936  index++;
1937 
1938  d->helper->ensureSpace(vec, index);
1939 
1940  vec[index].code = ART_CURVETO;
1941  vec[index].x1 = curx + x1;
1942  vec[index].y1 = cury + y1;
1943  vec[index].x2 = curx + x2;
1944  vec[index].y2 = cury + y2;
1945  vec[index].x3 = curx + tox;
1946  vec[index].y3 = cury + toy;
1947 
1948  curx += tox;
1949  cury += toy;
1950 
1951  contrlx = vec[index].x2;
1952  contrly = vec[index].y2;
1953 
1954  lastCommand = 'c';
1955  break;
1956  case 'C':
1957  ptr = getCoord(ptr, x1);
1958  ptr = getCoord(ptr, y1);
1959  ptr = getCoord(ptr, x2);
1960  ptr = getCoord(ptr, y2);
1961  ptr = getCoord(ptr, tox);
1962  ptr = getCoord(ptr, toy);
1963 
1964  index++;
1965 
1966  d->helper->ensureSpace(vec, index);
1967 
1968  vec[index].code = ART_CURVETO;
1969  vec[index].x1 = x1;
1970  vec[index].y1 = y1;
1971  vec[index].x2 = x2;
1972  vec[index].y2 = y2;
1973  vec[index].x3 = tox;
1974  vec[index].y3 = toy;
1975 
1976  curx = vec[index].x3;
1977  cury = vec[index].y3;
1978  contrlx = vec[index].x2;
1979  contrly = vec[index].y2;
1980 
1981  lastCommand = 'C';
1982  break;
1983  case 's':
1984  ptr = getCoord(ptr, x2);
1985  ptr = getCoord(ptr, y2);
1986  ptr = getCoord(ptr, tox);
1987  ptr = getCoord(ptr, toy);
1988 
1989  index++;
1990 
1991  d->helper->ensureSpace(vec, index);
1992 
1993  vec[index].code = ART_CURVETO;
1994  vec[index].x1 = 2 * curx - contrlx;
1995  vec[index].y1 = 2 * cury - contrly;
1996  vec[index].x2 = curx + x2;
1997  vec[index].y2 = cury + y2;
1998  vec[index].x3 = curx + tox;
1999  vec[index].y3 = cury + toy;
2000 
2001  curx += tox;
2002  cury += toy;
2003 
2004  contrlx = vec[index].x2;
2005  contrly = vec[index].y2;
2006 
2007  lastCommand = 's';
2008  break;
2009  case 'S':
2010  ptr = getCoord(ptr, x2);
2011  ptr = getCoord(ptr, y2);
2012  ptr = getCoord(ptr, tox);
2013  ptr = getCoord(ptr, toy);
2014 
2015  index++;
2016 
2017  d->helper->ensureSpace(vec, index);
2018 
2019  vec[index].code = ART_CURVETO;
2020  vec[index].x1 = 2 * curx - contrlx;
2021  vec[index].y1 = 2 * cury - contrly;
2022  vec[index].x2 = x2;
2023  vec[index].y2 = y2;
2024  vec[index].x3 = tox;
2025  vec[index].y3 = toy;
2026 
2027  curx = vec[index].x3;
2028  cury = vec[index].y3;
2029  contrlx = vec[index].x2;
2030  contrly = vec[index].y2;
2031 
2032  lastCommand = 'S';
2033  break;
2034  case 'q':
2035  ptr = getCoord(ptr, x1);
2036  ptr = getCoord(ptr, y1);
2037  ptr = getCoord(ptr, tox);
2038  ptr = getCoord(ptr, toy);
2039 
2040  index++;
2041 
2042  d->helper->ensureSpace(vec, index);
2043 
2044  vec[index].code = ART_CURVETO;
2045  vec[index].x1 = (curx + 2 * (x1 + curx)) * (1.0 / 3.0);
2046  vec[index].y1 = (cury + 2 * (y1 + cury)) * (1.0 / 3.0);
2047  vec[index].x2 = ((curx + tox) + 2 * (x1 + curx)) * (1.0 / 3.0);
2048  vec[index].y2 = ((cury + toy) + 2 * (y1 + cury)) * (1.0 / 3.0);
2049  vec[index].x3 = curx + tox;
2050  vec[index].y3 = cury + toy;
2051 
2052  contrlx = curx + x1;
2053  contrly = cury + y1;
2054  curx += tox;
2055  cury += toy;
2056 
2057  lastCommand = 'q';
2058  break;
2059  case 'Q':
2060  ptr = getCoord(ptr, x1);
2061  ptr = getCoord(ptr, y1);
2062  ptr = getCoord(ptr, tox);
2063  ptr = getCoord(ptr, toy);
2064 
2065  index++;
2066 
2067  d->helper->ensureSpace(vec, index);
2068 
2069  // TODO : if this fails make it more like QuadraticRel
2070  vec[index].code = ART_CURVETO;
2071  vec[index].x1 = (curx + 2 * x1) * (1.0 / 3.0);
2072  vec[index].y1 = (cury + 2 * y1) * (1.0 / 3.0);
2073  vec[index].x2 = (tox + 2 * x1) * (1.0 / 3.0);
2074  vec[index].y2 = (toy + 2 * y1) * (1.0 / 3.0);
2075  vec[index].x3 = tox;
2076  vec[index].y3 = toy;
2077 
2078  curx = vec[index].x3;
2079  cury = vec[index].y3;
2080  contrlx = vec[index].x2;
2081  contrly = vec[index].y2;
2082 
2083  lastCommand = 'Q';
2084  break;
2085  case 't':
2086  ptr = getCoord(ptr, tox);
2087  ptr = getCoord(ptr, toy);
2088 
2089  xc = 2 * curx - contrlx;
2090  yc = 2 * cury - contrly;
2091 
2092  index++;
2093 
2094  d->helper->ensureSpace(vec, index);
2095 
2096  vec[index].code = ART_CURVETO;
2097  vec[index].x1 = (curx + 2 * xc) * (1.0 / 3.0);
2098  vec[index].y1 = (cury + 2 * yc) * (1.0 / 3.0);
2099  vec[index].x2 = ((curx + tox) + 2 * xc) * (1.0 / 3.0);
2100  vec[index].y2 = ((cury + toy) + 2 * yc) * (1.0 / 3.0);
2101 
2102  vec[index].x3 = curx + tox;
2103  vec[index].y3 = cury + toy;
2104 
2105  curx += tox;
2106  cury += toy;
2107  contrlx = xc;
2108  contrly = yc;
2109 
2110  lastCommand = 't';
2111  break;
2112  case 'T':
2113  ptr = getCoord(ptr, tox);
2114  ptr = getCoord(ptr, toy);
2115 
2116  xc = 2 * curx - contrlx;
2117  yc = 2 * cury - contrly;
2118 
2119  index++;
2120 
2121  d->helper->ensureSpace(vec, index);
2122 
2123  vec[index].code = ART_CURVETO;
2124  vec[index].x1 = (curx + 2 * xc) * (1.0 / 3.0);
2125  vec[index].y1 = (cury + 2 * yc) * (1.0 / 3.0);
2126  vec[index].x2 = (tox + 2 * xc) * (1.0 / 3.0);
2127  vec[index].y2 = (toy + 2 * yc) * (1.0 / 3.0);
2128  vec[index].x3 = tox;
2129  vec[index].y3 = toy;
2130 
2131  curx = tox;
2132  cury = toy;
2133  contrlx = xc;
2134  contrly = yc;
2135 
2136  lastCommand = 'T';
2137  break;
2138  case 'z':
2139  case 'Z':
2140  int find;
2141  find = -1;
2142  for(int i = index; i >= 0; i--)
2143  {
2144  if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO)
2145  {
2146  find = i;
2147  break;
2148  }
2149  }
2150 
2151  if(find != -1)
2152  {
2153  if(vec[find].x3 != curx || vec[find].y3 != cury)
2154  {
2155  index++;
2156 
2157  d->helper->ensureSpace(vec, index);
2158 
2159  vec[index].code = ART_LINETO;
2160  vec[index].x3 = vec[find].x3;
2161  vec[index].y3 = vec[find].y3;
2162  }
2163  }
2164 
2165  // reset for next (sub)path
2166  curx = vec[find].x3;
2167  cury = vec[find].y3;
2168 
2169  lastCommand = 'z';
2170  break;
2171  case 'a':
2172  ptr = getCoord(ptr, rx);
2173  ptr = getCoord(ptr, ry);
2174  ptr = getCoord(ptr, angle);
2175  ptr = getCoord(ptr, tox);
2176  largeArc = tox == 1;
2177  ptr = getCoord(ptr, tox);
2178  sweep = tox == 1;
2179  ptr = getCoord(ptr, tox);
2180  ptr = getCoord(ptr, toy);
2181 
2182  // Spec: radii are nonnegative numbers
2183  rx = fabs(rx);
2184  ry = fabs(ry);
2185 
2186  d->helper->calculateArc(true, vec, index, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep);
2187 
2188  lastCommand = 'a';
2189  break;
2190  case 'A':
2191  ptr = getCoord(ptr, rx);
2192  ptr = getCoord(ptr, ry);
2193  ptr = getCoord(ptr, angle);
2194  ptr = getCoord(ptr, tox);
2195  largeArc = tox == 1;
2196  ptr = getCoord(ptr, tox);
2197  sweep = tox == 1;
2198  ptr = getCoord(ptr, tox);
2199  ptr = getCoord(ptr, toy);
2200 
2201  // Spec: radii are nonnegative numbers
2202  rx = fabs(rx);
2203  ry = fabs(ry);
2204 
2205  d->helper->calculateArc(false, vec, index, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep);
2206 
2207  lastCommand = 'A';
2208  break;
2209  }
2210 
2211  if(*ptr == '+' || *ptr == '-' || *ptr == '.' || (*ptr >= '0' && *ptr <= '9'))
2212  {
2213  // there are still coords in this command
2214  if(command == 'M')
2215  {
2216  command = 'L';
2217  }
2218  else if(command == 'm')
2219  {
2220  command = 'l';
2221  }
2222  }
2223  else
2224  {
2225  command = *(ptr++);
2226  }
2227 
2228  // Detect reflection points
2229  if(lastCommand != 'C' && lastCommand != 'c' &&
2230  lastCommand != 'S' && lastCommand != 's' &&
2231  lastCommand != 'Q' && lastCommand != 'q' &&
2232  lastCommand != 'T' && lastCommand != 't')
2233  {
2234  contrlx = curx;
2235  contrly = cury;
2236  }
2237  }
2238 
2239  // Find last subpath
2240  int find = -1;
2241  for(int i = index; i >= 0; i--)
2242  {
2243  if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO)
2244  {
2245  find = i;
2246  break;
2247  }
2248  }
2249 
2250  // Fix a problem where the .svg file used doubles as values... (sofico.svg)
2251  if(curx != vec[find].x3 && cury != vec[find].y3)
2252  {
2253  if((int) curx == (int) vec[find].x3 && (int) cury == (int) vec[find].y3)
2254  {
2255  index++;
2256 
2257  if(vec.size() == (unsigned int) index)
2258  vec.resize(index + 1);
2259 
2260  vec[index].code = ART_LINETO;
2261  vec[index].x3 = vec[find].x3;
2262  vec[index].y3 = vec[find].y3;
2263 
2264  curx = vec[find].x3;
2265  cury = vec[find].y3;
2266  }
2267  }
2268 
2269  // Handle filled paths that are not closed explicitly
2270  if(filled)
2271  {
2272  if((int) curx != (int) vec[find].x3 || (int) cury != (int) vec[find].y3)
2273  {
2274  index++;
2275 
2276  if(vec.size() == (unsigned int) index)
2277  vec.resize(index + 1);
2278 
2279  vec[index].code = (ArtPathcode)ART_END2;
2280  vec[index].x3 = vec[find].x3;
2281  vec[index].y3 = vec[find].y3;
2282 
2283  curx = vec[find].x3;
2284  cury = vec[find].y3;
2285  }
2286  }
2287 
2288  // Close
2289  index++;
2290 
2291  if(vec.size() == (unsigned int) index)
2292  vec.resize(index + 1);
2293 
2294  vec[index].code = ART_END;
2295 
2296  // There are pure-moveto paths which reference paint servers *bah*
2297  // Do NOT render them
2298  bool render = false;
2299  for(int i = index; i >= 0; i--)
2300  {
2301  if(vec[i].code != ART_MOVETO_OPEN && vec[i].code != ART_MOVETO && !(vec[i].code >= ART_END))
2302  {
2303  render = true;
2304  break;
2305  }
2306  }
2307 
2308  if(render)
2309  d->helper->drawBPath(vec.data());
2310  }
2311 }
2312 
2313 void KSVGIconPainter::drawImage(double x, double y, TQImage &image)
2314 {
2315  if(image.depth() != 32)
2316  image = image.convertDepth(32);
2317 
2318  double affine[6];
2319  affine[0] = d->helper->m_worldMatrix->m11();
2320  affine[1] = d->helper->m_worldMatrix->m12();
2321  affine[2] = d->helper->m_worldMatrix->m21();
2322  affine[3] = d->helper->m_worldMatrix->m22();
2323  // use the world matrix to convert the coordinates
2324  d->helper->m_worldMatrix->map(x, y, &affine[4], &affine[5]);
2325 
2326  d->helper->art_rgba_rgba_affine(d->helper->m_buffer, 0, 0, d->helper->m_width, d->helper->m_height,
2327  d->helper->m_rowstride, image.bits(), image.width(), image.height(),
2328  image.width() * 4, affine);
2329 }
2330 
2331 TQColor KSVGIconPainter::parseColor(const TQString &param)
2332 {
2333  if(param.stripWhiteSpace().startsWith("#"))
2334  {
2335  TQColor color;
2336  color.setNamedColor(param.stripWhiteSpace());
2337  return color;
2338  }
2339  else if(param.stripWhiteSpace().startsWith("rgb("))
2340  {
2341  TQString parse = param.stripWhiteSpace();
2342  TQStringList colors = TQStringList::split(',', parse);
2343  TQString r = colors[0].right((colors[0].length() - 4));
2344  TQString g = colors[1];
2345  TQString b = colors[2].left((colors[2].length() - 1));
2346 
2347  if(r.contains("%"))
2348  {
2349  r = r.left(r.length() - 1);
2350  r = TQString::number(int((double(255 * r.toDouble()) / 100.0)));
2351  }
2352 
2353  if(g.contains("%"))
2354  {
2355  g = g.left(g.length() - 1);
2356  g = TQString::number(int((double(255 * g.toDouble()) / 100.0)));
2357  }
2358 
2359  if(b.contains("%"))
2360  {
2361  b = b.left(b.length() - 1);
2362  b = TQString::number(int((double(255 * b.toDouble()) / 100.0)));
2363  }
2364 
2365  return TQColor(r.toInt(), g.toInt(), b.toInt());
2366  }
2367  else
2368  {
2369  TQString rgbColor = param.stripWhiteSpace();
2370 
2371  if(rgbColor == "aliceblue")
2372  return TQColor(240, 248, 255);
2373  else if(rgbColor == "antiquewhite")
2374  return TQColor(250, 235, 215);
2375  else if(rgbColor == "aqua")
2376  return TQColor(0, 255, 255);
2377  else if(rgbColor == "aquamarine")
2378  return TQColor(127, 255, 212);
2379  else if(rgbColor == "azure")
2380  return TQColor(240, 255, 255);
2381  else if(rgbColor == "beige")
2382  return TQColor(245, 245, 220);
2383  else if(rgbColor == "bisque")
2384  return TQColor(255, 228, 196);
2385  else if(rgbColor == "black")
2386  return TQColor(0, 0, 0);
2387  else if(rgbColor == "blanchedalmond")
2388  return TQColor(255, 235, 205);
2389  else if(rgbColor == "blue")
2390  return TQColor(0, 0, 255);
2391  else if(rgbColor == "blueviolet")
2392  return TQColor(138, 43, 226);
2393  else if(rgbColor == "brown")
2394  return TQColor(165, 42, 42);
2395  else if(rgbColor == "burlywood")
2396  return TQColor(222, 184, 135);
2397  else if(rgbColor == "cadetblue")
2398  return TQColor(95, 158, 160);
2399  else if(rgbColor == "chartreuse")
2400  return TQColor(127, 255, 0);
2401  else if(rgbColor == "chocolate")
2402  return TQColor(210, 105, 30);
2403  else if(rgbColor == "coral")
2404  return TQColor(255, 127, 80);
2405  else if(rgbColor == "cornflowerblue")
2406  return TQColor(100, 149, 237);
2407  else if(rgbColor == "cornsilk")
2408  return TQColor(255, 248, 220);
2409  else if(rgbColor == "crimson")
2410  return TQColor(220, 20, 60);
2411  else if(rgbColor == "cyan")
2412  return TQColor(0, 255, 255);
2413  else if(rgbColor == "darkblue")
2414  return TQColor(0, 0, 139);
2415  else if(rgbColor == "darkcyan")
2416  return TQColor(0, 139, 139);
2417  else if(rgbColor == "darkgoldenrod")
2418  return TQColor(184, 134, 11);
2419  else if(rgbColor == "darkgray")
2420  return TQColor(169, 169, 169);
2421  else if(rgbColor == "darkgrey")
2422  return TQColor(169, 169, 169);
2423  else if(rgbColor == "darkgreen")
2424  return TQColor(0, 100, 0);
2425  else if(rgbColor == "darkkhaki")
2426  return TQColor(189, 183, 107);
2427  else if(rgbColor == "darkmagenta")
2428  return TQColor(139, 0, 139);
2429  else if(rgbColor == "darkolivegreen")
2430  return TQColor(85, 107, 47);
2431  else if(rgbColor == "darkorange")
2432  return TQColor(255, 140, 0);
2433  else if(rgbColor == "darkorchid")
2434  return TQColor(153, 50, 204);
2435  else if(rgbColor == "darkred")
2436  return TQColor(139, 0, 0);
2437  else if(rgbColor == "darksalmon")
2438  return TQColor(233, 150, 122);
2439  else if(rgbColor == "darkseagreen")
2440  return TQColor(143, 188, 143);
2441  else if(rgbColor == "darkslateblue")
2442  return TQColor(72, 61, 139);
2443  else if(rgbColor == "darkslategray")
2444  return TQColor(47, 79, 79);
2445  else if(rgbColor == "darkslategrey")
2446  return TQColor(47, 79, 79);
2447  else if(rgbColor == "darkturquoise")
2448  return TQColor(0, 206, 209);
2449  else if(rgbColor == "darkviolet")
2450  return TQColor(148, 0, 211);
2451  else if(rgbColor == "deeppink")
2452  return TQColor(255, 20, 147);
2453  else if(rgbColor == "deepskyblue")
2454  return TQColor(0, 191, 255);
2455  else if(rgbColor == "dimgray")
2456  return TQColor(105, 105, 105);
2457  else if(rgbColor == "dimgrey")
2458  return TQColor(105, 105, 105);
2459  else if(rgbColor == "dodgerblue")
2460  return TQColor(30, 144, 255);
2461  else if(rgbColor == "firebrick")
2462  return TQColor(178, 34, 34);
2463  else if(rgbColor == "floralwhite")
2464  return TQColor(255, 250, 240);
2465  else if(rgbColor == "forestgreen")
2466  return TQColor(34, 139, 34);
2467  else if(rgbColor == "fuchsia")
2468  return TQColor(255, 0, 255);
2469  else if(rgbColor == "gainsboro")
2470  return TQColor(220, 220, 220);
2471  else if(rgbColor == "ghostwhite")
2472  return TQColor(248, 248, 255);
2473  else if(rgbColor == "gold")
2474  return TQColor(255, 215, 0);
2475  else if(rgbColor == "goldenrod")
2476  return TQColor(218, 165, 32);
2477  else if(rgbColor == "gray")
2478  return TQColor(128, 128, 128);
2479  else if(rgbColor == "grey")
2480  return TQColor(128, 128, 128);
2481  else if(rgbColor == "green")
2482  return TQColor(0, 128, 0);
2483  else if(rgbColor == "greenyellow")
2484  return TQColor(173, 255, 47);
2485  else if(rgbColor == "honeydew")
2486  return TQColor(240, 255, 240);
2487  else if(rgbColor == "hotpink")
2488  return TQColor(255, 105, 180);
2489  else if(rgbColor == "indianred")
2490  return TQColor(205, 92, 92);
2491  else if(rgbColor == "indigo")
2492  return TQColor(75, 0, 130);
2493  else if(rgbColor == "ivory")
2494  return TQColor(255, 255, 240);
2495  else if(rgbColor == "khaki")
2496  return TQColor(240, 230, 140);
2497  else if(rgbColor == "lavender")
2498  return TQColor(230, 230, 250);
2499  else if(rgbColor == "lavenderblush")
2500  return TQColor(255, 240, 245);
2501  else if(rgbColor == "lawngreen")
2502  return TQColor(124, 252, 0);
2503  else if(rgbColor == "lemonchiffon")
2504  return TQColor(255, 250, 205);
2505  else if(rgbColor == "lightblue")
2506  return TQColor(173, 216, 230);
2507  else if(rgbColor == "lightcoral")
2508  return TQColor(240, 128, 128);
2509  else if(rgbColor == "lightcyan")
2510  return TQColor(224, 255, 255);
2511  else if(rgbColor == "lightgoldenrodyellow")
2512  return TQColor(250, 250, 210);
2513  else if(rgbColor == "lightgray")
2514  return TQColor(211, 211, 211);
2515  else if(rgbColor == "lightgrey")
2516  return TQColor(211, 211, 211);
2517  else if(rgbColor == "lightgreen")
2518  return TQColor(144, 238, 144);
2519  else if(rgbColor == "lightpink")
2520  return TQColor(255, 182, 193);
2521  else if(rgbColor == "lightsalmon")
2522  return TQColor(255, 160, 122);
2523  else if(rgbColor == "lightseagreen")
2524  return TQColor(32, 178, 170);
2525  else if(rgbColor == "lightskyblue")
2526  return TQColor(135, 206, 250);
2527  else if(rgbColor == "lightslategray")
2528  return TQColor(119, 136, 153);
2529  else if(rgbColor == "lightslategrey")
2530  return TQColor(119, 136, 153);
2531  else if(rgbColor == "lightsteelblue")
2532  return TQColor(176, 196, 222);
2533  else if(rgbColor == "lightyellow")
2534  return TQColor(255, 255, 224);
2535  else if(rgbColor == "lime")
2536  return TQColor(0, 255, 0);
2537  else if(rgbColor == "limegreen")
2538  return TQColor(50, 205, 50);
2539  else if(rgbColor == "linen")
2540  return TQColor(250, 240, 230);
2541  else if(rgbColor == "magenta")
2542  return TQColor(255, 0, 255);
2543  else if(rgbColor == "maroon")
2544  return TQColor(128, 0, 0);
2545  else if(rgbColor == "mediumaquamarine")
2546  return TQColor(102, 205, 170);
2547  else if(rgbColor == "mediumblue")
2548  return TQColor(0, 0, 205);
2549  else if(rgbColor == "mediumorchid")
2550  return TQColor(186, 85, 211);
2551  else if(rgbColor == "mediumpurple")
2552  return TQColor(147, 112, 219);
2553  else if(rgbColor == "mediumseagreen")
2554  return TQColor(60, 179, 113);
2555  else if(rgbColor == "mediumslateblue")
2556  return TQColor(123, 104, 238);
2557  else if(rgbColor == "mediumspringgreen")
2558  return TQColor(0, 250, 154);
2559  else if(rgbColor == "mediumturquoise")
2560  return TQColor(72, 209, 204);
2561  else if(rgbColor == "mediumvioletred")
2562  return TQColor(199, 21, 133);
2563  else if(rgbColor == "midnightblue")
2564  return TQColor(25, 25, 112);
2565  else if(rgbColor == "mintcream")
2566  return TQColor(245, 255, 250);
2567  else if(rgbColor == "mistyrose")
2568  return TQColor(255, 228, 225);
2569  else if(rgbColor == "moccasin")
2570  return TQColor(255, 228, 181);
2571  else if(rgbColor == "navajowhite")
2572  return TQColor(255, 222, 173);
2573  else if(rgbColor == "navy")
2574  return TQColor(0, 0, 128);
2575  else if(rgbColor == "oldlace")
2576  return TQColor(253, 245, 230);
2577  else if(rgbColor == "olive")
2578  return TQColor(128, 128, 0);
2579  else if(rgbColor == "olivedrab")
2580  return TQColor(107, 142, 35);
2581  else if(rgbColor == "orange")
2582  return TQColor(255, 165, 0);
2583  else if(rgbColor == "orangered")
2584  return TQColor(255, 69, 0);
2585  else if(rgbColor == "orchid")
2586  return TQColor(218, 112, 214);
2587  else if(rgbColor == "palegoldenrod")
2588  return TQColor(238, 232, 170);
2589  else if(rgbColor == "palegreen")
2590  return TQColor(152, 251, 152);
2591  else if(rgbColor == "paleturquoise")
2592  return TQColor(175, 238, 238);
2593  else if(rgbColor == "palevioletred")
2594  return TQColor(219, 112, 147);
2595  else if(rgbColor == "papayawhip")
2596  return TQColor(255, 239, 213);
2597  else if(rgbColor == "peachpuff")
2598  return TQColor(255, 218, 185);
2599  else if(rgbColor == "peru")
2600  return TQColor(205, 133, 63);
2601  else if(rgbColor == "pink")
2602  return TQColor(255, 192, 203);
2603  else if(rgbColor == "plum")
2604  return TQColor(221, 160, 221);
2605  else if(rgbColor == "powderblue")
2606  return TQColor(176, 224, 230);
2607  else if(rgbColor == "purple")
2608  return TQColor(128, 0, 128);
2609  else if(rgbColor == "red")
2610  return TQColor(255, 0, 0);
2611  else if(rgbColor == "rosybrown")
2612  return TQColor(188, 143, 143);
2613  else if(rgbColor == "royalblue")
2614  return TQColor(65, 105, 225);
2615  else if(rgbColor == "saddlebrown")
2616  return TQColor(139, 69, 19);
2617  else if(rgbColor == "salmon")
2618  return TQColor(250, 128, 114);
2619  else if(rgbColor == "sandybrown")
2620  return TQColor(244, 164, 96);
2621  else if(rgbColor == "seagreen")
2622  return TQColor(46, 139, 87);
2623  else if(rgbColor == "seashell")
2624  return TQColor(255, 245, 238);
2625  else if(rgbColor == "sienna")
2626  return TQColor(160, 82, 45);
2627  else if(rgbColor == "silver")
2628  return TQColor(192, 192, 192);
2629  else if(rgbColor == "skyblue")
2630  return TQColor(135, 206, 235);
2631  else if(rgbColor == "slateblue")
2632  return TQColor(106, 90, 205);
2633  else if(rgbColor == "slategray")
2634  return TQColor(112, 128, 144);
2635  else if(rgbColor == "slategrey")
2636  return TQColor(112, 128, 144);
2637  else if(rgbColor == "snow")
2638  return TQColor(255, 250, 250);
2639  else if(rgbColor == "springgreen")
2640  return TQColor(0, 255, 127);
2641  else if(rgbColor == "steelblue")
2642  return TQColor(70, 130, 180);
2643  else if(rgbColor == "tan")
2644  return TQColor(210, 180, 140);
2645  else if(rgbColor == "teal")
2646  return TQColor(0, 128, 128);
2647  else if(rgbColor == "thistle")
2648  return TQColor(216, 191, 216);
2649  else if(rgbColor == "tomato")
2650  return TQColor(255, 99, 71);
2651  else if(rgbColor == "turquoise")
2652  return TQColor(64, 224, 208);
2653  else if(rgbColor == "violet")
2654  return TQColor(238, 130, 238);
2655  else if(rgbColor == "wheat")
2656  return TQColor(245, 222, 179);
2657  else if(rgbColor == "white")
2658  return TQColor(255, 255, 255);
2659  else if(rgbColor == "whitesmoke")
2660  return TQColor(245, 245, 245);
2661  else if(rgbColor == "yellow")
2662  return TQColor(255, 255, 0);
2663  else if(rgbColor == "yellowgreen")
2664  return TQColor(154, 205, 50);
2665  }
2666 
2667  return TQColor();
2668 }
2669 
2670 double KSVGIconPainter::dpi()
2671 {
2672  return 90.0; // TODO: make modal?
2673 }
2674 
2675 double KSVGIconPainter::toPixel(const TQString &s, bool hmode)
2676 {
2677  if(s.isEmpty())
2678  return 0.0;
2679 
2680  TQString check = s;
2681 
2682  double ret = 0.0;
2683 
2684  double value = 0;
2685  const char *start = check.latin1();
2686  const char *end = getCoord(start, value);
2687 
2688  if(uint(end - start) < check.length())
2689  {
2690  if(check.endsWith("px"))
2691  ret = value;
2692  else if(check.endsWith("cm"))
2693  ret = (value / 2.54) * dpi();
2694  else if(check.endsWith("pc"))
2695  ret = (value / 6.0) * dpi();
2696  else if(check.endsWith("mm"))
2697  ret = (value / 25.4) * dpi();
2698  else if(check.endsWith("in"))
2699  ret = value * dpi();
2700  else if(check.endsWith("pt"))
2701  ret = (value / 72.0) * dpi();
2702  else if(check.endsWith("%"))
2703  {
2704  ret = value / 100.0;
2705 
2706  if(hmode)
2707  ret *= d->drawWidth;
2708  else
2709  ret *= d->drawHeight;
2710  }
2711  else if(check.endsWith("em"))
2712  {
2713  ret = value * 10.0; // TODO make this depend on actual font size
2714  }
2715  }
2716  else
2717  ret = value;
2718 
2719  return ret;
2720 }
2721 
2722 ArtGradientLinear *KSVGIconPainter::linearGradient(const TQString &id)
2723 {
2724  return d->helper->m_linearGradientMap[id];
2725 }
2726 
2727 void KSVGIconPainter::addLinearGradient(const TQString &id, ArtGradientLinear *gradient)
2728 {
2729  d->helper->m_linearGradientMap.insert(id, gradient);
2730 }
2731 
2732 TQDomElement KSVGIconPainter::linearGradientElement(ArtGradientLinear *linear)
2733 {
2734  return d->helper->m_linearGradientElementMap[linear];
2735 }
2736 
2737 void KSVGIconPainter::addLinearGradientElement(ArtGradientLinear *gradient, TQDomElement element)
2738 {
2739  d->helper->m_linearGradientElementMap.insert(gradient, element);
2740 }
2741 
2742 ArtGradientRadial *KSVGIconPainter::radialGradient(const TQString &id)
2743 {
2744  return d->helper->m_radialGradientMap[id];
2745 }
2746 
2747 void KSVGIconPainter::addRadialGradient(const TQString &id, ArtGradientRadial *gradient)
2748 {
2749  d->helper->m_radialGradientMap.insert(id, gradient);
2750 }
2751 
2752 TQDomElement KSVGIconPainter::radialGradientElement(ArtGradientRadial *radial)
2753 {
2754  return d->helper->m_radialGradientElementMap[radial];
2755 }
2756 
2757 void KSVGIconPainter::addRadialGradientElement(ArtGradientRadial *gradient, TQDomElement element)
2758 {
2759  d->helper->m_radialGradientElementMap.insert(gradient, element);
2760 }
2761 
2762 TQ_UINT32 KSVGIconPainter::toArtColor(const TQColor &color)
2763 {
2764  return d->helper->toArtColor(color);
2765 }
2766 
2767 TQWMatrix KSVGIconPainter::parseTransform(const TQString &transform)
2768 {
2769  TQWMatrix result;
2770 
2771  // Split string for handling 1 transform statement at a time
2772  TQStringList subtransforms = TQStringList::split(')', transform);
2773  TQStringList::ConstIterator it = subtransforms.begin();
2774  TQStringList::ConstIterator end = subtransforms.end();
2775  for(; it != end; ++it)
2776  {
2777  TQStringList subtransform = TQStringList::split('(', (*it));
2778 
2779  subtransform[0] = subtransform[0].stripWhiteSpace().lower();
2780  subtransform[1] = subtransform[1].simplifyWhiteSpace();
2781  TQRegExp reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)");
2782 
2783  int pos = 0;
2784  TQStringList params;
2785 
2786  while(pos >= 0)
2787  {
2788  pos = reg.search(subtransform[1], pos);
2789  if(pos != -1)
2790  {
2791  params += reg.cap(1);
2792  pos += reg.matchedLength();
2793  }
2794  }
2795 
2796  if(subtransform[0].startsWith(";") || subtransform[0].startsWith(","))
2797  subtransform[0] = subtransform[0].right(subtransform[0].length() - 1);
2798 
2799  if(subtransform[0] == "rotate")
2800  {
2801  if(params.count() == 3)
2802  {
2803  double x = params[1].toDouble();
2804  double y = params[2].toDouble();
2805 
2806  result.translate(x, y);
2807  result.rotate(params[0].toDouble());
2808  result.translate(-x, -y);
2809  }
2810  else
2811  result.rotate(params[0].toDouble());
2812  }
2813  else if(subtransform[0] == "translate")
2814  {
2815  if(params.count() == 2)
2816  result.translate(params[0].toDouble(), params[1].toDouble());
2817  else // Spec : if only one param given, assume 2nd param to be 0
2818  result.translate(params[0].toDouble() , 0);
2819  }
2820  else if(subtransform[0] == "scale")
2821  {
2822  if(params.count() == 2)
2823  result.scale(params[0].toDouble(), params[1].toDouble());
2824  else // Spec : if only one param given, assume uniform scaling
2825  result.scale(params[0].toDouble(), params[0].toDouble());
2826  }
2827  else if(subtransform[0] == "skewx")
2828  result.shear(tan(params[0].toDouble() * deg2rad), 0.0F);
2829  else if(subtransform[0] == "skewy")
2830  result.shear(tan(params[0].toDouble() * deg2rad), 0.0F);
2831  else if(subtransform[0] == "skewy")
2832  result.shear(0.0F, tan(params[0].toDouble() * deg2rad));
2833  else if(subtransform[0] == "matrix")
2834  {
2835  if(params.count() >= 6)
2836  {
2837  result.setMatrix(params[0].toDouble(), params[1].toDouble(), params[2].toDouble(), params[3].toDouble(), params[4].toDouble(), params[5].toDouble());
2838  }
2839  }
2840  }
2841 
2842  return result;
2843 }
TDEStdAccel::end
const TDEShortcut & end()
Goto end of the document.
Definition: tdestdaccel.cpp:289
KStdAction::name
const char * name(StdAction id)
KStdAction::find
TDEAction * find(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.11
This website is maintained by Timothy Pearson.