kdgantt

KDGanttXMLTools.cpp
1 /*
2  $Id$
3  KDGantt - a multi-platform charting engine
4 */
5 
6 /****************************************************************************
7  ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
8  **
9  ** This file is part of the KDGantt library.
10  **
11  ** This file may be distributed and/or modified under the terms of the
12  ** GNU General Public License version 2 as published by the Free Software
13  ** Foundation and appearing in the file LICENSE.GPL included in the
14  ** packaging of this file.
15  **
16  ** Licensees holding valid commercial KDGantt licenses may use this file in
17  ** accordance with the KDGantt Commercial License Agreement provided with
18  ** the Software.
19  **
20  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  **
23  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
24  ** information about KDGantt Commercial License Agreements.
25  **
26  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
27  ** licensing are not clear to you.
28  **
29  ** As a special exception, permission is given to link this program
30  ** with any edition of TQt, and distribute the resulting executable,
31  ** without including the source code for TQt in the source distribution.
32  **
33  **********************************************************************/
34 
35 #include "KDGanttXMLTools.h"
36 #include <tqbrush.h>
37 #include <tqbuffer.h>
38 #include <tqimage.h>
39 #include <zlib.h>
40 
41 namespace KDGanttXML {
42 
43 void createBoolNode( TQDomDocument& doc, TQDomNode& parent,
44  const TQString& elementName, bool value )
45 {
46  TQDomElement newElement =
47  doc.createElement( elementName );
48  parent.appendChild( newElement );
49  TQDomText elementContent =
50  doc.createTextNode( value ? "true" : "false" );
51  newElement.appendChild( elementContent );
52 }
53 
54 
55 
56 void createSizeNode( TQDomDocument& doc, TQDomNode& parent,
57  const TQString& elementName, const TQSize& value )
58 {
59  TQDomElement newElement =
60  doc.createElement( elementName );
61  parent.appendChild( newElement );
62  newElement.setAttribute( "Width", value.width() );
63  newElement.setAttribute( "Height", value.height() );
64 }
65 
66 
67 void createIntNode( TQDomDocument& doc, TQDomNode& parent,
68  const TQString& elementName, int value )
69 {
70  TQDomElement newElement =
71  doc.createElement( elementName );
72  parent.appendChild( newElement );
73  TQDomText elementContent =
74  doc.createTextNode( TQString::number( value ) );
75  newElement.appendChild( elementContent );
76 }
77 
78 
79 void createDoubleNode( TQDomDocument& doc, TQDomNode& parent,
80  const TQString& elementName, double value )
81 {
82  TQDomElement newElement =
83  doc.createElement( elementName );
84  parent.appendChild( newElement );
85  TQDomText elementContent =
86  doc.createTextNode( TQString::number( value ) );
87  newElement.appendChild( elementContent );
88 }
89 
90 
91 void createStringNode( TQDomDocument& doc, TQDomNode& parent,
92  const TQString& elementName,
93  const TQString& text )
94 {
95  TQDomElement newElement =
96  doc.createElement( elementName );
97  parent.appendChild( newElement );
98  TQDomText elementContent =
99  doc.createTextNode( text );
100  newElement.appendChild( elementContent );
101 }
102 
103 
104 void createColorNode( TQDomDocument& doc, TQDomNode& parent,
105  const TQString& elementName, const TQColor& color )
106 {
107  TQDomElement colorElement = doc.createElement( elementName );
108  parent.appendChild( colorElement );
109  colorElement.setAttribute( "Red",
110  TQString::number( color.red() ) );
111  colorElement.setAttribute( "Green",
112  TQString::number( color.green() ) );
113  colorElement.setAttribute( "Blue",
114  TQString::number( color.blue() ) );
115 }
116 
117 
118 void createBrushNode( TQDomDocument& doc, TQDomNode& parent,
119  const TQString& elementName, const TQBrush& brush )
120 
121 {
122  TQDomElement brushElement = doc.createElement( elementName );
123  parent.appendChild( brushElement );
124  createColorNode( doc, brushElement, "Color", brush.color() );
125  createStringNode( doc, brushElement, "Style",
126  KDGanttXML::brushStyleToString( brush.style() ) );
127  if( brush.style() == TQt::CustomPattern && brush.pixmap() )
128  createPixmapNode( doc, brushElement, "Pixmap", *brush.pixmap() );
129 }
130 
131 
132 void createPixmapNode( TQDomDocument& doc, TQDomNode& parent,
133  const TQString& elementName, const TQPixmap& pixmap )
134 {
135  TQDomElement pixmapElement = doc.createElement( elementName );
136  parent.appendChild( pixmapElement );
137 
138  // Convert the pixmap to an image, save that image to an in-memory
139  // XPM representation and compress this representation. This
140  // conforms to the file format TQt Designer uses.
141  TQByteArray ba;
142  TQBuffer buffer( ba );
143  buffer.open( IO_WriteOnly );
144  TQImageIO imgio( &buffer, "XPM" );
145  TQImage image = pixmap.convertToImage();
146  imgio.setImage( image );
147  imgio.write();
148  buffer.close();
149  ulong len = ba.size() * 2;
150  TQByteArray bazip( len );
151  ::compress( (uchar*) bazip.data(), &len, (uchar*) ba.data(), ba.size() );
152  TQString dataString;
153  static const char hexchars[] = "0123456789abcdef";
154  for ( int i = 0; i < (int)len; ++i ) {
155  uchar c = (uchar) bazip[i];
156  dataString += hexchars[c >> 4];
157  dataString += hexchars[c & 0x0f];
158  }
159 
160  createStringNode( doc, pixmapElement, "Format", "XPM.GZ" );
161  createIntNode( doc, pixmapElement, "Length", ba.size() );
162  createStringNode( doc, pixmapElement, "Data", dataString );
163 }
164 
165 
166 void createRectNode( TQDomDocument& doc, TQDomNode& parent,
167  const TQString& elementName, const TQRect& rect )
168 {
169  TQDomElement rectElement = doc.createElement( elementName );
170  parent.appendChild( rectElement );
171  TQDomElement xElement = doc.createElement( "X" );
172  rectElement.appendChild( xElement );
173  TQDomText xContent = doc.createTextNode( TQString::number( rect.x() ) );
174  xElement.appendChild( xContent );
175  TQDomElement yElement = doc.createElement( "Y" );
176  rectElement.appendChild( yElement );
177  TQDomText yContent = doc.createTextNode( TQString::number( rect.y() ) );
178  yElement.appendChild( yContent );
179  TQDomElement widthElement = doc.createElement( "Width" );
180  rectElement.appendChild( widthElement );
181  TQDomText widthContent = doc.createTextNode( TQString::number( rect.width() ) );
182  widthElement.appendChild( widthContent );
183  TQDomElement heightElement = doc.createElement( "Height" );
184  rectElement.appendChild( heightElement );
185  TQDomText heightContent = doc.createTextNode( TQString::number( rect.height() ) );
186  heightElement.appendChild( heightContent );
187 }
188 
189 
190 void createStringListNodes( TQDomDocument& doc, TQDomNode& parent,
191  const TQString& elementName,
192  const TQStringList* list )
193 {
194  if( !list )
195  return;
196 
197  for( TQStringList::ConstIterator it = list->begin();
198  it != list->end(); ++it ) {
199  TQDomElement element = doc.createElement( elementName );
200  parent.appendChild( element );
201  TQDomText elementContent = doc.createTextNode( *it );
202  element.appendChild( elementContent );
203  }
204 }
205 
206 
207 void createFontNode( TQDomDocument& doc, TQDomNode& parent,
208  const TQString& elementName, const TQFont& font )
209 {
210  TQDomElement fontElement = doc.createElement( elementName );
211  parent.appendChild( fontElement );
212  createStringNode( doc, fontElement, "Family", font.family() );
213  createIntNode( doc, fontElement, "PointSize", font.pointSize() );
214  createIntNode( doc, fontElement, "PixelSize", font.pixelSize() );
215  createIntNode( doc, fontElement, "Weight", font.weight() );
216  createBoolNode( doc, fontElement, "Italic", font.italic() );
217 }
218 
219 
220 void createPenNode( TQDomDocument& doc, TQDomNode& parent,
221  const TQString& elementName, const TQPen& pen )
222 {
223  TQDomElement penElement = doc.createElement( elementName );
224  parent.appendChild( penElement );
225  createIntNode( doc, penElement, "Width", pen.width() );
226  createColorNode( doc, penElement, "Color", pen.color() );
227  createStringNode( doc, penElement, "Style", penStyleToString( pen.style() ) );
228 }
229 
230 
231 void createDateTimeNode( TQDomDocument& doc, TQDomNode& parent,
232  const TQString& elementName,
233  const TQDateTime& datetime )
234 {
235  TQDomElement dateTimeElement = doc.createElement( elementName );
236  parent.appendChild( dateTimeElement );
237  createDateNode( doc, dateTimeElement, "Date", datetime.date() );
238  createTimeNode( doc, dateTimeElement, "Time", datetime.time() );
239 }
240 
241 
242 void createDateNode( TQDomDocument& doc, TQDomNode& parent,
243  const TQString& elementName, const TQDate& date )
244 {
245  TQDomElement dateElement = doc.createElement( elementName );
246  parent.appendChild( dateElement );
247  dateElement.setAttribute( "Year", TQString::number( date.year() ) );
248  dateElement.setAttribute( "Month", TQString::number( date.month() ) );
249  dateElement.setAttribute( "Day", TQString::number( date.day() ) );
250 }
251 
252 
253 void createTimeNode( TQDomDocument& doc, TQDomNode& parent,
254  const TQString& elementName, const TQTime& time )
255 {
256  TQDomElement timeElement = doc.createElement( elementName );
257  parent.appendChild( timeElement );
258  timeElement.setAttribute( "Hour",
259  TQString::number( time.hour() ) );
260  timeElement.setAttribute( "Minute",
261  TQString::number( time.minute() ) );
262  timeElement.setAttribute( "Second",
263  TQString::number( time.second() ) );
264  timeElement.setAttribute( "Millisecond",
265  TQString::number( time.msec() ) );
266 }
267 
268 
269 TQString penStyleToString( TQt::PenStyle style )
270 {
271  switch( style ) {
272  case TQt::NoPen:
273  return "NoPen";
274  case TQt::SolidLine:
275  return "SolidLine";
276  case TQt::DashLine:
277  return "DashLine";
278  case TQt::DotLine:
279  return "DotLine";
280  case TQt::DashDotLine:
281  return "DashDotLine";
282  case TQt::DashDotDotLine:
283  return "DashDotDotLine";
284  default: // should not happen
285  return "SolidLine";
286  }
287 }
288 
289 
290 
291 TQString brushStyleToString( TQt::BrushStyle style )
292 {
293  // PENDING(kalle) Support custom patterns
294  switch( style ) {
295  case TQt::NoBrush:
296  return "NoBrush";
297  case TQt::SolidPattern:
298  return "SolidPattern";
299  case TQt::Dense1Pattern:
300  return "Dense1Pattern";
301  case TQt::Dense2Pattern:
302  return "Dense2Pattern";
303  case TQt::Dense3Pattern:
304  return "Dense3Pattern";
305  case TQt::Dense4Pattern:
306  return "Dense4Pattern";
307  case TQt::Dense5Pattern:
308  return "Dense5Pattern";
309  case TQt::Dense6Pattern:
310  return "Dense6Pattern";
311  case TQt::Dense7Pattern:
312  return "Dense7Pattern";
313  case TQt::HorPattern:
314  return "HorPattern";
315  case TQt::VerPattern:
316  return "VerPattern";
317  case TQt::CrossPattern:
318  return "CrossPattern";
319  case TQt::BDiagPattern:
320  return "BDiagPattern";
321  case TQt::FDiagPattern:
322  return "FDiagPattern";
323  case TQt::DiagCrossPattern:
324  return "DiagCrossPattern";
325  default: // should not happen (but can for a custom pattern)
326  return "SolidPattern";
327  }
328 }
329 
330 
331 bool readStringNode( const TQDomElement& element, TQString& value )
332 {
333  value = element.text();
334  return true;
335 }
336 
337 
338 bool readIntNode( const TQDomElement& element, int& value )
339 {
340  bool ok = false;
341  int temp = element.text().toInt( &ok );
342  if( ok )
343  value = temp;
344  return ok;
345 }
346 
347 
348 bool readDoubleNode( const TQDomElement& element, double& value )
349 {
350  bool ok = false;
351  double temp = element.text().toDouble( &ok );
352  if( ok )
353  value = temp;
354  return ok;
355 }
356 
357 
358 bool readBoolNode( const TQDomElement& element, bool& value )
359 {
360  if( element.text() == "true" ) {
361  value = true;
362  return true;
363  } else if( element.text() == "false" ) {
364  value = false;
365  return true;
366  } else
367  return false;
368 }
369 
370 
371 bool readColorNode( const TQDomElement& element, TQColor& value )
372 {
373  bool ok = true;
374  int red, green, blue;
375  if( element.hasAttribute( "Red" ) ) {
376  bool redOk = false;
377  red = element.attribute( "Red" ).toInt( &redOk );
378  ok = ok & redOk;
379  }
380  if( element.hasAttribute( "Green" ) ) {
381  bool greenOk = false;
382  green = element.attribute( "Green" ).toInt( &greenOk );
383  ok = ok & greenOk;
384  }
385  if( element.hasAttribute( "Blue" ) ) {
386  bool blueOk = false;
387  blue = element.attribute( "Blue" ).toInt( &blueOk );
388  ok = ok & blueOk;
389  }
390 
391  if( ok )
392  value.setRgb( red, green, blue );
393 
394  return ok;
395 }
396 
397 
398 bool readBrushNode( const TQDomElement& element, TQBrush& brush )
399 {
400  bool ok = true;
401  TQColor tempColor;
402  TQt::BrushStyle tempStyle;
403  TQPixmap tempPixmap;
404  TQDomNode node = element.firstChild();
405  while( !node.isNull() ) {
406  TQDomElement element = node.toElement();
407  if( !element.isNull() ) { // was really an element
408  TQString tagName = element.tagName();
409  if( tagName == "Color" ) {
410  ok = ok & readColorNode( element, tempColor );
411  } else if( tagName == "Style" ) {
412  TQString value;
413  ok = ok & readStringNode( element, value );
414  tempStyle = stringToBrushStyle( value );
415  } else if( tagName == "Pixmap" ) {
416  ok = ok & readPixmapNode( element, tempPixmap );
417  } else {
418  tqDebug( "Unknown tag in brush" );
419  }
420  }
421  node = node.nextSibling();
422  }
423 
424  if( ok ) {
425  brush.setColor( tempColor );
426  brush.setStyle( tempStyle );
427  if( !tempPixmap.isNull() )
428  brush.setPixmap( tempPixmap );
429  }
430 
431  return ok;
432 }
433 
434 
435 bool readPixmapNode( const TQDomElement& element, TQPixmap& pixmap )
436 {
437  bool ok = true;
438  int tempLengthi;
439  TQString tempData;
440  TQDomNode node = element.firstChild();
441  while( !node.isNull() ) {
442  TQDomElement element = node.toElement();
443  if( !element.isNull() ) { // was really an element
444  TQString tagName = element.tagName();
445  if( tagName == "Format" ) {
446  TQString formatName;
447  ok = ok & readStringNode( element, formatName );
448 #ifndef NDEBUG
449  if( formatName != "XPM.GZ" )
450  tqDebug( "Unsupported pixmap format in XML file" );
451 #endif
452  } else if( tagName == "Length" ) {
453  ok = ok & readIntNode( element, tempLengthi );
454  } else if( tagName == "Data" ) {
455  ok = ok & readStringNode( element, tempData );
456  } else {
457  tqDebug( "Unknown tag in Pixmap" );
458  }
459  }
460  node = node.nextSibling();
461  }
462 
463  if( ok ) {
464  if( 0 < tempLengthi ) {
465  // Decode the image file format in the same way TQt Designer does.
466  char *ba = new char[ tempData.length() / 2 ];
467  for ( int i = 0; i < (int)tempData.length() / 2; ++i ) {
468  char h = tempData[ 2 * i ].latin1();
469  char l = tempData[ 2 * i + 1 ].latin1();
470  uchar r = 0;
471  if ( h <= '9' )
472  r += h - '0';
473  else
474  r += h - 'a' + 10;
475  r = r << 4;
476  if ( l <= '9' )
477  r += l - '0';
478  else
479  r += l - 'a' + 10;
480  ba[ i ] = r;
481  }
482 
483  if( tempLengthi < (int)tempData.length() * 5 )
484  tempLengthi = tempData.length() * 5;
485  unsigned long tempLength = tempLengthi;
486  TQByteArray baunzip( tempLength );
487  ::uncompress( (uchar*) baunzip.data(), &tempLength,
488  (uchar*) ba, tempData.length()/2 );
489  TQImage image;
490  image.loadFromData( (const uchar*)baunzip.data(), tempLength, "XPM" );
491 
492  if( image.isNull() )
493  pixmap.resize( 0, 0 ); // This is _not_ an error, we just read a NULL pixmap!
494  else
495  ok = ok & pixmap.convertFromImage( image, 0 );
496  } else
497  pixmap.resize( 0, 0 ); // This is _not_ an error, we just read a empty pixmap!
498  }
499 
500  return ok;
501 }
502 
503 
504 bool readPenNode( const TQDomElement& element, TQPen& pen )
505 {
506  bool ok = true;
507  int tempWidth;
508  TQColor tempColor;
509  TQt::PenStyle tempStyle;
510  TQDomNode node = element.firstChild();
511  while( !node.isNull() ) {
512  TQDomElement element = node.toElement();
513  if( !element.isNull() ) { // was really an element
514  TQString tagName = element.tagName();
515  if( tagName == "Width" ) {
516  ok = ok & readIntNode( element, tempWidth );
517  } else if( tagName == "Color" ) {
518  ok = ok & readColorNode( element, tempColor );
519  } else if( tagName == "Style" ) {
520  TQString value;
521  ok = ok & readStringNode( element, value );
522  tempStyle = stringToPenStyle( value );
523  } else {
524  tqDebug( "Unknown tag in brush" );
525  }
526  }
527  node = node.nextSibling();
528  }
529 
530  if( ok ) {
531  pen.setWidth( tempWidth );
532  pen.setColor( tempColor );
533  pen.setStyle( tempStyle );
534  }
535 
536  return ok;
537 }
538 
539 bool readFontNode( const TQDomElement& element, TQFont& font )
540 {
541  bool ok = true;
542  TQString family;
543  int pointSize, pixelSize, weight;
544  bool italic;
545  int charSet;
546  TQDomNode node = element.firstChild();
547  while( !node.isNull() ) {
548  TQDomElement element = node.toElement();
549  if( !element.isNull() ) { // was really an element
550  TQString tagName = element.tagName();
551  if( tagName == "Family" ) {
552  ok = ok & readStringNode( element, family );
553  } else if( tagName == "PointSize" ) {
554  ok = ok & readIntNode( element, pointSize );
555  } else if( tagName == "PixelSize" ) {
556  ok = ok & readIntNode( element, pixelSize );
557  } else if( tagName == "Weight" ) {
558  ok = ok & readIntNode( element, weight );
559  } else if( tagName == "Italic" ) {
560  ok = ok & readBoolNode( element, italic );
561  } else if( tagName == "CharSet" ) {
562  ok = ok & readIntNode( element, charSet );
563  } else {
564  tqDebug( "Unknown tag in color map" );
565  }
566  }
567  node = node.nextSibling();
568  }
569 
570  if( ok ) {
571  font.setFamily( family );
572  if ( pointSize > 0 ) font.setPointSize( pointSize );
573  if ( pixelSize > 0 ) font.setPixelSize( pixelSize );
574  font.setWeight( weight );
575  font.setItalic( italic );
576  }
577 
578  return ok;
579 }
580 
581 bool readRectNode( const TQDomElement& element, TQRect& value )
582 {
583  bool ok = true;
584  int width, height, x, y;
585  TQDomNode node = element.firstChild();
586  while( !node.isNull() ) {
587  TQDomElement element = node.toElement();
588  if( !element.isNull() ) { // was really an element
589  TQString tagName = element.tagName();
590  if( tagName == "Width" ) {
591  ok = ok & readIntNode( element, width );
592  } else if( tagName == "Height" ) {
593  ok = ok & readIntNode( element, height );
594  } else if( tagName == "X" ) {
595  ok = ok & readIntNode( element, x );
596  } else if( tagName == "Y" ) {
597  ok = ok & readIntNode( element, y );
598  } else {
599  tqDebug( "Unknown tag in rect" );
600  }
601  }
602  node = node.nextSibling();
603  }
604 
605  if( ok ) {
606  value.setX( x );
607  value.setY( y );
608  value.setWidth( width );
609  value.setHeight( height );
610  }
611 
612  return ok;
613 }
614 
615 
616 
617 bool readDateTimeNode( const TQDomElement& element, TQDateTime& datetime )
618 {
619  bool ok = true;
620  TQDate tempDate;
621  TQTime tempTime;
622  TQDomNode node = element.firstChild();
623  while( !node.isNull() ) {
624  TQDomElement element = node.toElement();
625  if( !element.isNull() ) { // was really an element
626  TQString tagName = element.tagName();
627  if( tagName == "Date" ) {
628  ok = ok & readDateNode( element, tempDate );
629  } else if( tagName == "Time" ) {
630  ok = ok & readTimeNode( element, tempTime );
631  } else {
632  tqDebug( "Unknown tag in datetime" );
633  }
634  }
635  node = node.nextSibling();
636  }
637 
638  if( ok ) {
639  datetime.setDate( tempDate );
640  datetime.setTime( tempTime );
641  }
642 
643  return ok;
644 }
645 
646 
647 bool readDateNode( const TQDomElement& element, TQDate& value )
648 {
649  bool ok = true;
650  int year, month, day;
651  if( element.hasAttribute( "Year" ) ) {
652  bool yearOk = false;
653  year = element.attribute( "Year" ).toInt( &yearOk );
654  ok = ok & yearOk;
655  }
656  if( element.hasAttribute( "Month" ) ) {
657  bool monthOk = false;
658  month = element.attribute( "Month" ).toInt( &monthOk );
659  ok = ok & monthOk;
660  }
661  if( element.hasAttribute( "Day" ) ) {
662  bool dayOk = false;
663  day = element.attribute( "Day" ).toInt( &dayOk );
664  ok = ok & dayOk;
665  }
666 
667  if( ok )
668  value.setYMD( year, month, day );
669 
670  return ok;
671 }
672 
673 
674 
675 bool readTimeNode( const TQDomElement& element, TQTime& value )
676 {
677  bool ok = true;
678  int hour, minute, second, msec;
679  if( element.hasAttribute( "Hour" ) ) {
680  bool hourOk = false;
681  hour = element.attribute( "Hour" ).toInt( &hourOk );
682  ok = ok & hourOk;
683  }
684  if( element.hasAttribute( "Minute" ) ) {
685  bool minuteOk = false;
686  minute = element.attribute( "Minute" ).toInt( &minuteOk );
687  ok = ok & minuteOk;
688  }
689  if( element.hasAttribute( "Second" ) ) {
690  bool secondOk = false;
691  second = element.attribute( "Second" ).toInt( &secondOk );
692  ok = ok & secondOk;
693  }
694  if( element.hasAttribute( "Millisecond" ) ) {
695  bool msecOk = false;
696  msec = element.attribute( "Millisecond" ).toInt( &msecOk );
697  ok = ok & msecOk;
698  }
699 
700  if( ok )
701  value.setHMS( hour, minute, second, msec );
702 
703  return ok;
704 }
705 
706 
707 
708 TQt::PenStyle stringToPenStyle( const TQString& style )
709 {
710  if( style == "NoPen" )
711  return TQt::NoPen;
712  else if( style == "SolidLine" )
713  return TQt::SolidLine;
714  else if( style == "DashLine" )
715  return TQt::DashLine;
716  else if( style == "DotLine" )
717  return TQt::DotLine;
718  else if( style == "DashDotLine" )
719  return TQt::DashDotLine;
720  else if( style == "DashDotDotLine" )
721  return TQt::DashDotDotLine;
722  else // should not happen
723  return TQt::SolidLine;
724 }
725 
726 
727 TQt::BrushStyle stringToBrushStyle( const TQString& style )
728 {
729  // PENDING(kalle) Support custom patterns
730  if( style == "NoBrush" )
731  return TQt::NoBrush;
732  else if( style == "SolidPattern" )
733  return TQt::SolidPattern;
734  else if( style == "Dense1Pattern" )
735  return TQt::Dense1Pattern;
736  else if( style == "Dense2Pattern" )
737  return TQt::Dense2Pattern;
738  else if( style == "Dense3Pattern" )
739  return TQt::Dense3Pattern;
740  else if( style == "Dense4Pattern" )
741  return TQt::Dense4Pattern;
742  else if( style == "Dense5Pattern" )
743  return TQt::Dense5Pattern;
744  else if( style == "Dense6Pattern" )
745  return TQt::Dense6Pattern;
746  else if( style == "Dense7Pattern" )
747  return TQt::Dense7Pattern;
748  else if( style == "HorPattern" )
749  return TQt::HorPattern;
750  else if( style == "VerPattern" )
751  return TQt::VerPattern;
752  else if( style == "CrossPattern" )
753  return TQt::CrossPattern;
754  else if( style == "BDiagPattern" )
755  return TQt::BDiagPattern;
756  else if( style == "FDiagPattern" )
757  return TQt::FDiagPattern;
758  else if( style == "DiagCrossPattern" )
759  return TQt::DiagCrossPattern;
760  else // should not happen (but can with custom patterns)
761  return TQt::SolidPattern;
762 }
763 
764 }