KDChartTextArea.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2011 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #include "KDChartTextArea.h"
00024 #include "KDChartTextArea_p.h"
00025 
00026 #include <qglobal.h>
00027 
00028 #include <QPainter>
00029 #include <QRect>
00030 
00031 #include <KDABLibFakes>
00032 
00033 
00034 using namespace KDChart;
00035 
00036 TextArea::Private::Private() :
00037     AbstractAreaBase::Private()
00038 {
00039     // this bloc left empty intentionally
00040 }
00041 
00042 
00043 TextArea::Private::~Private()
00044 {
00045     // this bloc left empty intentionally
00046 }
00047 
00048 
00049 TextArea::TextArea()
00050     : QObject()
00051     , KDChart::AbstractAreaBase()
00052     , KDChart::TextLayoutItem()
00053 {
00054     // this bloc left empty intentionally
00055 }
00056 
00057 TextArea::~TextArea()
00058 {
00059     // this bloc left empty intentionally
00060 }
00061 
00062 
00063 void TextArea::init()
00064 {
00065     // this bloc left empty intentionally
00066 }
00067 
00068 void TextArea::paintIntoRect( QPainter& painter, const QRect& rect )
00069 {
00070     const QRect oldGeometry( geometry() );
00071     if( oldGeometry != rect )
00072         setGeometry( rect );
00073     painter.translate( rect.left(), rect.top() );
00074     paintAll( painter );
00075     painter.translate( -rect.left(), -rect.top() );
00076     if( oldGeometry != rect )
00077         setGeometry( oldGeometry );
00078 }
00079 
00080 void TextArea::paintAll( QPainter& painter )
00081 {
00082     // Paint the background and frame
00083     paintBackground( painter, geometry() );
00084     paintFrame(      painter, geometry() );
00085 
00086     // temporarily adjust the widget size, to be sure all content gets calculated
00087     // to fit into the inner rectangle
00088     const QRect oldGeometry( areaGeometry()  );
00089     QRect inner( innerRect() );
00090     inner.moveTo(
00091         oldGeometry.left() + inner.left(),
00092         oldGeometry.top()  + inner.top() );
00093     const bool needAdjustGeometry = oldGeometry != inner;
00094     if( needAdjustGeometry )
00095         setGeometry( inner );
00096     paint( &painter );
00097     if( needAdjustGeometry )
00098         setGeometry( oldGeometry );
00099     //qDebug() << "TextAreaWidget::paintAll() done.";
00100 }
00101 
00102 QRect TextArea::areaGeometry() const
00103 {
00104     return geometry();
00105 }
00106 
00107 void TextArea::positionHasChanged()
00108 {
00109     emit positionChanged( this );
00110 }
00111 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/