00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __KDCHARTCUSTOMBOX_H__
00030 #define __KDCHARTCUSTOMBOX_H__
00031
00032 #include <qobject.h>
00033 #include <qtextstream.h>
00034 #include <qfont.h>
00035 #include <qdom.h>
00036 #include "KDChartGlobal.h"
00037 #include "KDChartEnums.h"
00038 #include "KDChartTextPiece.h"
00039
00040
00041 class KDFrame;
00042
00043
00044 #define KDCHART_AlignAuto 0
00045
00046
00054 class KDCHART_EXPORT KDChartCustomBox :public QObject
00055 {
00056 Q_OBJECT
00057 friend class KDChartPainter;
00058 friend class KDChartParams;
00059
00060 public:
00061
00066 KDChartCustomBox() :
00067 _rotation( 0 ),
00068 _fontSize( -10 ),
00069 _fontScaleGlobal( true ),
00070 _deltaX( 0 ),
00071 _deltaY( 0 ),
00072 _width( 0 ),
00073 _height( 0 ),
00074 _color( Qt::black ),
00075 _paper( Qt::NoBrush ),
00076 _anchorArea( KDChartEnums::AreaInnermost ),
00077 _anchorPos( KDChartEnums::PosTopLeft ),
00078 _anchorAlign( Qt::AlignTop + Qt::AlignLeft ),
00079 _dataRow( 0 ),
00080 _dataCol( 0 ),
00081 _data3rd( 0 ),
00082 _deltaAlign( KDCHART_AlignAuto ),
00083 _deltaScaleGlobal( true ),
00084 _anchorBeingCalculated( false ),
00085 _parentAxisArea( -1 )
00086 {
00087 const KDChartTextPiece piece( 0, "", QFont( "helvetica", 8, QFont::Normal, false ) );
00088 _content.deepCopy( &piece );
00089 }
00090
00108 KDChartCustomBox( const KDChartTextPiece & content,
00109 int fontSize,
00110 bool fontScaleGlobal = true ) :
00111 _rotation( 0 ),
00112 _fontSize( fontSize ),
00113 _fontScaleGlobal( fontScaleGlobal ),
00114 _deltaX( 0 ),
00115 _deltaY( 0 ),
00116 _width( 0 ),
00117 _height( 0 ),
00118 _color( Qt::black ),
00119 _paper( Qt::NoBrush ),
00120 _anchorArea( KDChartEnums::AreaInnermost ),
00121 _anchorPos( KDChartEnums::PosTopLeft ),
00122 _anchorAlign( Qt::AlignTop + Qt::AlignLeft ),
00123 _dataRow( 0 ),
00124 _dataCol( 0 ),
00125 _data3rd( 0 ),
00126 _deltaAlign( KDCHART_AlignAuto ),
00127 _deltaScaleGlobal( true ),
00128 _anchorBeingCalculated( false ),
00129 _parentAxisArea( -1 )
00130 {
00131 _content.deepCopy( &content );
00132 }
00133
00134
00201 KDChartCustomBox( const KDChartTextPiece & content,
00202 int fontSize,
00203 bool fontScaleGlobal,
00204 int deltaX,
00205 int deltaY,
00206 int width,
00207 int height,
00208 const QColor & color = QColor( Qt::black ),
00209 const QBrush & paper = QBrush( Qt::NoBrush ),
00210 uint area = KDChartEnums::AreaInnermost,
00211 KDChartEnums::PositionFlag position = KDChartEnums::PosTopLeft,
00212 uint align = Qt::AlignTop + Qt::AlignLeft,
00213 uint dataRow = 0,
00214 uint dataCol = 0,
00215 uint data3rd = 0,
00216 uint deltaAlign = KDCHART_AlignAuto,
00217 bool deltaScaleGlobal = true,
00218 int parentAxis = -1 )
00219 : _rotation( 0 ),
00220 _fontSize( fontSize ),
00221 _fontScaleGlobal( fontScaleGlobal ),
00222 _deltaX( deltaX ),
00223 _deltaY( deltaY ),
00224 _width( width ),
00225 _height( height ),
00226 _color( color ),
00227 _paper( paper ),
00228 _anchorArea( area ),
00229 _anchorPos( position ),
00230 _anchorAlign( align ),
00231 _dataRow( dataRow ),
00232 _dataCol( dataCol ),
00233 _data3rd( data3rd ),
00234 _deltaAlign( deltaAlign ),
00235 _deltaScaleGlobal( deltaScaleGlobal ),
00236 _anchorBeingCalculated( false ),
00237 _parentAxisArea( parentAxis )
00238 {
00239 _content.deepCopy( &content );
00240 }
00241
00242
00322 KDChartCustomBox( int rotation,
00323 const KDChartTextPiece & content,
00324 int fontSize,
00325 bool fontScaleGlobal,
00326 int deltaX,
00327 int deltaY,
00328 int width,
00329 int height,
00330 const QColor & color = QColor( Qt::black ),
00331 const QBrush & paper = QBrush( Qt::NoBrush ),
00332 uint area = KDChartEnums::AreaInnermost,
00333 KDChartEnums::PositionFlag position = KDChartEnums::PosTopLeft,
00334 uint align = Qt::AlignTop + Qt::AlignLeft,
00335 uint dataRow = 0,
00336 uint dataCol = 0,
00337 uint data3rd = 0,
00338 uint deltaAlign = KDCHART_AlignAuto,
00339 bool deltaScaleGlobal = true,
00340 int parentAxis = -1 )
00341 : _rotation( rotation ),
00342 _fontSize( fontSize ),
00343 _fontScaleGlobal( fontScaleGlobal ),
00344 _deltaX( deltaX ),
00345 _deltaY( deltaY ),
00346 _width( width ),
00347 _height( height ),
00348 _color( color ),
00349 _paper( paper ),
00350 _anchorArea( area ),
00351 _anchorPos( position ),
00352 _anchorAlign( align ),
00353 _dataRow( dataRow ),
00354 _dataCol( dataCol ),
00355 _data3rd( data3rd ),
00356 _deltaAlign( deltaAlign ),
00357 _deltaScaleGlobal( deltaScaleGlobal ),
00358 _anchorBeingCalculated( false ),
00359 _parentAxisArea( parentAxis )
00360 {
00361 _content.deepCopy( &content );
00362 }
00363
00364
00374 static void createCustomBoxNode( QDomDocument& document,
00375 QDomNode& parent,
00376 const QString& elementName,
00377 const KDChartCustomBox* custombox );
00378
00386 static bool readCustomBoxNode( const QDomElement& element,
00387 KDChartCustomBox& custombox );
00388
00389 public slots:
00390
00391 float trueFontSize( double areaWidthP1000,
00392 double areaHeightP1000,
00393 int rectHeight ) const;
00394 int trueFontLineSpacing( double areaWidthP1000,
00395 double areaHeightP1000,
00396 int rectHeight ) const;
00397 int trueRectAlignX(const QRect& rect) const;
00398 int trueRectAlignY(const QRect& rect) const;
00399 void getTrueShift( double areaWidthP1000,
00400 double areaHeightP1000,
00401 int rectHeight,
00402 int& dX,
00403 int& dY )const;
00404
00405
00422 QRect trueRect( QPainter * painter,
00423 QPoint anchor, double areaWidthP1000, double areaHeightP1000 ) const ;
00424
00437 virtual QRect trueRect( QPoint anchor,
00438 double areaWidthP1000,
00439 double areaHeightP1000 ) const ;
00440
00458 virtual void paint( QPainter* painter,
00459 QPoint anchor,
00460 double areaWidthP1000,
00461 double areaHeightP1000,
00462 const KDFrame* frame = 0,
00463 const QRect& frameRect = QRect(),
00464 const QColor * color = 0,
00465 const QBrush * paper = 0 ) const ;
00466
00470 void setRotation( int rotation )
00471 {
00472 _rotation = rotation;
00473 }
00474
00478 void setContent( const KDChartTextPiece & content )
00479 {
00480 _content.deepCopy( &content );
00481 }
00482
00504 void setFontSize( int fontSize, bool fontScaleGlobal )
00505 {
00506 _fontSize = fontSize;
00507 _fontScaleGlobal = fontScaleGlobal;
00508 }
00509
00513 void setAnchorArea( uint area )
00514 {
00515 _anchorArea = area;
00516 }
00517
00523 void setAnchorPosition( KDChartEnums::PositionFlag position )
00524 {
00525
00526 _anchorPos = position;
00527 }
00528
00532 void setAnchorAlign( uint align )
00533 {
00534 _anchorAlign = align;
00535 }
00536
00541 void setDataRow( uint dataRow )
00542 {
00543 _dataRow = dataRow;
00544 }
00545
00550 void setDataCol( uint dataCol )
00551 {
00552 _dataCol = dataCol;
00553 }
00554
00560 void setData3rd( uint data3rd )
00561 {
00562 _data3rd = data3rd;
00563 }
00564
00587 void setDistanceAndSize( int deltaX,
00588 int deltaY,
00589 int width,
00590 int height,
00591 uint deltaAlign = KDCHART_AlignAuto,
00592 bool deltaScaleGlobal = true )
00593 {
00594 _deltaX = deltaX;
00595 _deltaY = deltaY;
00596 _width = width;
00597 _height = height;
00598 _deltaAlign = deltaAlign;
00599 _deltaScaleGlobal = deltaScaleGlobal;
00600 }
00601
00628 void setDistance( int deltaX,
00629 int deltaY,
00630 uint align = KDCHART_AlignAuto,
00631 bool deltaScaleGlobal = true )
00632 {
00633 _deltaX = deltaX;
00634 _deltaY = deltaY;
00635 _deltaAlign = align;
00636 _deltaScaleGlobal = deltaScaleGlobal;
00637 }
00638
00668 void setDeltaAlign( uint align,
00669 bool deltaScaleGlobal = true )
00670 {
00671 _deltaAlign = align;
00672 _deltaScaleGlobal = deltaScaleGlobal;
00673 }
00674
00686 void setDeltaScale( bool deltaScaleGlobal )
00687 {
00688 _deltaScaleGlobal = deltaScaleGlobal;
00689 }
00690
00710 void setSize( int width, int height )
00711 {
00712 _width = width;
00713 _height = height;
00714 }
00715
00721 void setColor( QColor color )
00722 {
00723 _color = color;
00724 }
00725
00731 void setPaper( const QBrush & paper )
00732 {
00733 _paper = paper;
00734 }
00735
00739 int rotation() const
00740 {
00741 return _rotation;
00742 }
00743
00747 const KDChartTextPiece & content() const
00748 {
00749 return _content;
00750 }
00751
00762 int fontSize() const
00763 {
00764 return _fontSize;
00765 }
00766
00773 bool fontScaleGlobal() const
00774 {
00775 return _fontScaleGlobal;
00776 }
00777
00781 uint anchorArea() const
00782 {
00783 return _anchorArea;
00784 }
00785
00791 KDChartEnums::PositionFlag anchorPosition() const
00792 {
00793 return _anchorPos;
00794 }
00795
00799 uint anchorAlign() const
00800 {
00801 return _anchorAlign;
00802 }
00803
00809 uint dataRow() const
00810 {
00811 return _dataRow;
00812 }
00813
00819 uint dataCol() const
00820 {
00821 return _dataCol;
00822 }
00823
00830 uint data3rd() const
00831 {
00832 return _data3rd;
00833 }
00834
00845 int deltaX() const
00846 {
00847 return _deltaX;
00848 }
00849
00860 int deltaY() const
00861 {
00862 return _deltaY;
00863 }
00864
00871 uint deltaAlign() const
00872 {
00873 return _deltaAlign;
00874 }
00875
00882 bool deltaScaleGlobal() const
00883 {
00884 return _deltaScaleGlobal;
00885 }
00886
00894 int width() const
00895 {
00896 return _width;
00897 }
00898
00906 int height() const
00907 {
00908 return _height;
00909 }
00910
00914 QColor color() const
00915 {
00916 return _color;
00917 }
00918
00922 const QBrush & paper() const
00923 {
00924 return _paper;
00925 }
00926
00927 public:
00931 virtual ~KDChartCustomBox();
00932
00940 void deepCopy( const KDChartCustomBox* source );
00941
00942
00952 const KDChartCustomBox* clone() const;
00953
00954 private:
00955 KDChartCustomBox( const KDChartCustomBox& ) : QObject(0) {}
00956
00957 protected:
00963 void setInternalFlagAnchorBeingCalculated( bool flag ) const
00964 {
00965 KDChartCustomBox* that = const_cast<KDChartCustomBox*>(this);
00966 that->_anchorBeingCalculated = flag;
00967 }
00971 bool anchorBeingCalculated() const
00972 {
00973 return _anchorBeingCalculated;
00974 }
00975
00976 void setParentAxisArea( int parentAxis ) const
00977 {
00978 KDChartCustomBox* that = const_cast<KDChartCustomBox*>(this);
00979 that->_parentAxisArea = parentAxis;
00980 }
00981
00982 int parentAxisArea() const
00983 {
00984 return _parentAxisArea;
00985 }
00986
00987 private:
00988 int _rotation;
00989 KDChartTextPiece _content;
00990 int _fontSize;
00991 bool _fontScaleGlobal;
00992
00993
00994
00995 int _deltaX;
00996 int _deltaY;
00997 int _width;
00998 int _height;
00999
01000 QColor _color;
01001 QBrush _paper;
01002
01003 uint _anchorArea;
01004 KDChartEnums::PositionFlag _anchorPos;
01005 uint _anchorAlign;
01006 uint _dataRow;
01007 uint _dataCol;
01008 uint _data3rd;
01009 uint _deltaAlign;
01010 bool _deltaScaleGlobal;
01011
01012
01013
01014
01015
01016
01017 bool _anchorBeingCalculated;
01018 int _parentAxisArea;
01019 };
01020
01021
01029
01030
01031
01040
01041
01042
01043 #endif