krita/ui

kis_canvas_decoration.cc

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008 Cyrille Berger <cberger@cberger.net>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "kis_canvas_decoration.h"
00020 
00021 #include "kis_view2.h"
00022 
00023 struct KisCanvasDecoration::Private {
00024     bool visible;
00025     KisView2* view;
00026     QString id;
00027     QString name;
00028 };
00029 
00030 KisCanvasDecoration::KisCanvasDecoration(const QString& id, const QString& name, KisView2 * parent) : QObject(parent), d(new Private)
00031 {
00032     d->visible = false;
00033     d->view = parent;
00034     d->id = id;
00035     d->name = name;
00036 }
00037 
00038 KisCanvasDecoration::~KisCanvasDecoration()
00039 {
00040     delete d;
00041 }
00042 
00043 const QString& KisCanvasDecoration::id() const
00044 {
00045     return d->id;
00046 }
00047 
00048 const QString& KisCanvasDecoration::name() const
00049 {
00050     return d->name;
00051 }
00052 
00053 void KisCanvasDecoration::setVisible(bool v)
00054 {
00055     d->visible = v;
00056     d->view->canvas()->update();
00057 }
00058 
00059 bool KisCanvasDecoration::visible() const
00060 {
00061     return d->visible;
00062 }
00063 
00064 void KisCanvasDecoration::toggleVisibility()
00065 {
00066     d->visible = !d->visible;
00067 }
00068 
00069 void KisCanvasDecoration::paint(QPainter& gc, const QPoint & documentOffset, const QRect& area, const KoViewConverter &converter)
00070 {
00071     if (visible()) {
00072         //dbgKrita << "Decoration " << name() << " is visible";
00073         drawDecoration(gc, documentOffset, area, converter);
00074     }
00075 }
00076 
00077 KisView2* KisCanvasDecoration::view() const
00078 {
00079     return d->view;
00080 }
00081 #include "kis_canvas_decoration.moc"