F:/KPlato/koffice/libs/kotext/KoTextShape.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006 Boudewijn Rempt <boud@valdyas.org>
00003  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "KoTextShape.h"
00022 
00023 #include <QTextLayout>
00024 #include <QFont>
00025 #include <QAbstractTextDocumentLayout>
00026 #include <kdebug.h>
00027 #include <KoViewConverter.h>
00028 
00029 
00030 // ############ KoTextShape ################
00031 
00032 KoTextShape::KoTextShape()
00033 {
00034     m_textShapeData = new KoTextShapeData();
00035     setUserData(m_textShapeData);
00036     setShapeId(KoTextShape_SHAPEID);
00037 }
00038 
00039 KoTextShape::~KoTextShape() {
00040 }
00041 
00042 void KoTextShape::paint(QPainter &painter, const KoViewConverter &converter) {
00043     painter.fillRect(converter.documentToView(QRectF(QPointF(0.0,0.0), size())), background());
00044     applyConversion(painter, converter);
00045     QAbstractTextDocumentLayout::PaintContext pc;
00046     pc.cursorPosition = -1;
00047 
00048     QTextDocument *doc = m_textShapeData->document();
00049     painter.setClipRect(QRectF(QPointF(0, 0), size()), Qt::IntersectClip);
00050     painter.translate(0, -m_textShapeData->documentOffset());
00051     doc->documentLayout()->draw( &painter, pc);
00052 }
00053 
00054 QPointF KoTextShape::convertScreenPos(const QPointF &point) {
00055     QPointF p = m_invMatrix.map(point);
00056     return p + QPointF(0.0, m_textShapeData->documentOffset());
00057 }
00058 
00059 void KoTextShape::shapeChanged(ChangeType type) {
00060     if(type == PositionChanged || type == SizeChanged) {
00061         m_textShapeData->faul();
00062         m_textShapeData->fireResizeEvent();
00063     }
00064 }

Généré le Wed Nov 22 23:41:10 2006 pour KPlato par  doxygen 1.5.1-p1