libs/flake

KoCanvasResourceProvider.h

Go to the documentation of this file.
00001 /*
00002    Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org)
00003    Copyright (C) 2007, 2009 Thomas Zander <zander@kde.org>
00004    Copyright (c) 2008 Carlos Licea <carlos.licea@kdemail.net>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020  */
00021 #ifndef KO_CANVAS_RESOURCE_PROVIDER_H
00022 #define KO_CANVAS_RESOURCE_PROVIDER_H
00023 
00024 #include <QObject>
00025 #include <QHash>
00026 #include <QVariant>
00027 #include <QSizeF>
00028 
00029 #include <KoID.h>
00030 #include "flake_export.h"
00031 
00032 #include "FlakeColor.h" // For KoColor
00033 
00034 class KoShape;
00035 class KoLineBorder;
00036 
00043 namespace KoCanvasResource
00044 {
00045 
00049 enum CanvasResource {
00050     ForegroundColor,    
00051     BackgroundColor,    
00052     ActiveBorder,       
00053     HandleRadius,       
00054     GrabSensitivity,    
00055     PageSize,           
00056     DocumentIsLoading,  
00057     Unit,               
00058     CurrentPage,        
00059     ActiveStyleType,    
00060     KarbonStart = 1000,      
00061     KexiStart = 2000,        
00062     KivioStart = 3000,       
00063     KPlatoStart = 4000,      
00064     KPresenterStart = 5000,  
00065     KritaStart = 6000,       
00066     KSpreadStart = 7000,     
00067     KWordStart = 8000,        
00068     KoPageAppStart = 9000    
00069 };
00070 
00071 }
00072 
00080 class FLAKE_EXPORT KoCanvasResourceProvider : public QObject
00081 {
00082     Q_OBJECT
00083 
00084 public:
00085 
00090     explicit KoCanvasResourceProvider(QObject * parent = 0);
00091     ~KoCanvasResourceProvider();
00092 
00098     void setResource(int key, const QVariant & value);
00099 
00105     void setResource(int key, const KoColor & color);
00106 
00112     void setResource(int key, const KoID & id);
00118     void setResource(int key, KoShape* shape);
00119 
00125     QVariant resource(int key);
00126 
00131     void setForegroundColor(const KoColor & color);
00132 
00136     KoColor foregroundColor();
00137 
00142     void setBackgroundColor(const KoColor & color);
00146     KoColor backgroundColor();
00147 
00153     void setHandleRadius(int handleSize);
00155     int handleRadius();
00156 
00162     void setGrabSensitivity(uint grabSensitivity);
00164     uint grabSensitivity();
00165 
00167     void setActiveBorder( const KoLineBorder &border );
00168 
00170     KoLineBorder activeBorder();
00171 
00176     void setUnitChanged();
00177 
00182     bool boolResource(int key) const;
00183 
00188     int intResource(int key) const;
00189 
00194     qreal doubleResource(int key) const;
00195 
00200     KoColor koColorResource(int key);
00201 
00206     KoID koIDResource(int key);
00207 
00212     KoShape * koShapeResource(int key);
00213 
00218     QString stringResource(int key);
00219 
00224     QSizeF sizeResource(int key);
00225 
00230     bool hasResource(int key);
00231 
00237     void clearResource(int key);
00238 
00239 signals:
00246     void resourceChanged(int key, const QVariant & value);
00247 
00248 private:
00249     KoCanvasResourceProvider(const KoCanvasResourceProvider&);
00250     KoCanvasResourceProvider& operator=(const KoCanvasResourceProvider&);
00251 
00252 private:
00253     class Private;
00254     Private *const d;
00255 };
00256 
00257 #endif // KO_CANVAS_RESOURCE_PROVIDER_H