KD Chart 2: KDChartTextArea.cpp Source File

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# KDChartTextArea.cpp

Go to the documentation of this file.

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