libs/flake

KoCanvasBase.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002 
00003    Copyright (C) 2006 Thorsten Zachmann <zachmann@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 "KoCanvasBase.h"
00022 #include "KoCanvasResourceProvider.h"
00023 #include "KoShapeController.h"
00024 #include "KoCanvasController.h"
00025 #include "KoSnapGuide.h"
00026 
00027 #include <KGlobal>
00028 #include <KConfigGroup>
00029 #include <KSharedPtr>
00030 #include <KSharedConfig>
00031 
00032 class KoCanvasBase::Private
00033 {
00034 public:
00035     Private() : shapeController(0), resourceProvider(0), controller(0) {}
00036     ~Private() {
00037         delete shapeController;
00038         delete resourceProvider;
00039         delete snapGuide;
00040     }
00041     KoShapeController *shapeController;
00042     KoCanvasResourceProvider * resourceProvider;
00043     KoCanvasController *controller;
00044     KoSnapGuide * snapGuide;
00045 };
00046 
00047 KoCanvasBase::KoCanvasBase(KoShapeControllerBase *shapeControllerBase)
00048         : d(new Private())
00049 {
00050     d->resourceProvider = new KoCanvasResourceProvider();
00051     d->shapeController = new KoShapeController(this, shapeControllerBase);
00052     d->snapGuide = new KoSnapGuide(this);
00053 }
00054 
00055 KoCanvasBase::~KoCanvasBase()
00056 {
00057     delete d;
00058 }
00059 
00060 
00061 KoShapeController *KoCanvasBase::shapeController() const
00062 {
00063     return d->shapeController;
00064 }
00065 
00066 KoCanvasResourceProvider *KoCanvasBase::resourceProvider() const
00067 {
00068     return d->resourceProvider;
00069 }
00070 
00071 void KoCanvasBase::ensureVisible(const QRectF &rect)
00072 {
00073     if (d->controller)
00074         d->controller->ensureVisible(rect);
00075 }
00076 
00077 void KoCanvasBase::setCanvasController(KoCanvasController *controller)
00078 {
00079     d->controller = controller;
00080 }
00081 
00082 KoCanvasController *KoCanvasBase::canvasController() const
00083 {
00084     return d->controller;
00085 }
00086 
00087 void KoCanvasBase::clipToDocument(const KoShape *, QPointF &) const
00088 {
00089 }
00090 
00091 KoSnapGuide * KoCanvasBase::snapGuide() const
00092 {
00093     return d->snapGuide;
00094 }
00095 
00096 KoGuidesData * KoCanvasBase::guidesData()
00097 {
00098     return 0;
00099 }