lib Library API Documentation

koPictureBase.cc

00001 /* This file is part of the KDE project
00002    Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
00003    Copyright (C) 2002, 2003 Nicolas GOUTTE <goutte@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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <qpainter.h>
00022 #include <qpicture.h>
00023 #include <qpixmap.h>
00024 #include <qdragobject.h>
00025 
00026 #include <kdebug.h>
00027 #include <kconfig.h>
00028 #include <kglobal.h>
00029 
00030 #include "koPictureKey.h"
00031 #include "koPictureBase.h"
00032 
00033 static int s_useSlowResizeMode = -1; // unset
00034 
00035 KoPictureBase::KoPictureBase(void)
00036 {
00037     // Slow mode can be very slow, especially at high zoom levels -> configurable
00038     if ( s_useSlowResizeMode == -1 )
00039     {
00040         KConfigGroup group( KGlobal::config(), "KOfficeImage" );
00041         s_useSlowResizeMode = group.readNumEntry( "HighResolution", 1 );
00042         kdDebug(30003) << "HighResolution = " << s_useSlowResizeMode << endl;
00043     }
00044 }
00045 
00046 KoPictureBase::~KoPictureBase(void)
00047 {
00048 }
00049 
00050 KoPictureBase* KoPictureBase::newCopy(void) const
00051 {
00052     return new KoPictureBase(*this);
00053 }
00054 
00055 KoPictureType::Type KoPictureBase::getType(void) const
00056 {
00057     return KoPictureType::TypeUnknown;
00058 }
00059 
00060 bool KoPictureBase::isNull(void) const
00061 {
00062     return true;    // A KoPictureBase is always null.
00063 }
00064 
00065 void KoPictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool /*fastMode*/)
00066 {
00067     // Draw a light red box (easier DEBUG)
00068     kdWarning(30003) << "Drawing light red rectangle! (KoPictureBase::draw)" << endl;
00069     painter.save();
00070     painter.setBrush(QColor(128,0,0));
00071     painter.drawRect(x,y,width,height);
00072     painter.restore();
00073 }
00074 
00075 bool KoPictureBase::load(QIODevice* io, const QString& extension)
00076 {
00077     return load(io->readAll(), extension);
00078 }
00079 
00080 bool KoPictureBase::load(const QByteArray&, const QString&)
00081 {
00082     // Nothing to load!
00083     return false;
00084 }
00085 
00086 bool KoPictureBase::save(QIODevice*)
00087 {
00088     // Nothing to save!
00089     return false;
00090 }
00091 
00092 bool KoPictureBase::saveAsKOffice1Dot1(QIODevice* io, const QString&)
00093 {
00094     // The default is the normla save
00095     return save(io);
00096 }
00097 
00098 QSize KoPictureBase::getOriginalSize(void) const
00099 {
00100     return QSize(0,0);
00101 }
00102 
00103 QPixmap KoPictureBase::generatePixmap(const QSize&, bool /*smoothScale*/)
00104 {
00105     return QPixmap();
00106 }
00107 
00108 bool KoPictureBase::isClipartAsKOffice1Dot1(void) const
00109 {
00110     return false;
00111 }
00112 
00113 QString KoPictureBase::getMimeType(const QString&) const
00114 {
00115     return QString(NULL_MIME_TYPE);
00116 }
00117 
00118 bool KoPictureBase::isSlowResizeModeAllowed(void) const
00119 {
00120     return s_useSlowResizeMode != 0;
00121 }
00122 
00123 QDragObject* KoPictureBase::dragObject( QWidget * dragSource, const char * name )
00124 {
00125     QImage image (generateImage(getOriginalSize()));
00126     if (image.isNull())
00127         return 0L;
00128     else
00129         return new QImageDrag( image, dragSource, name );
00130 }
00131 
00132 QImage KoPictureBase::generateImage(const QSize& size)
00133 {
00134     return generatePixmap(size,true).convertToImage();
00135 }
00136 
00137 void KoPictureBase::clearCache(void)
00138 {
00139     // Nothign to do!
00140 }
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 13:19:24 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003