diff options
| author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
|---|---|---|
| committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
| commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
| tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /krita/ui/kis_part_layer_handler.cc | |
| download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip | |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/ui/kis_part_layer_handler.cc')
| -rw-r--r-- | krita/ui/kis_part_layer_handler.cc | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/krita/ui/kis_part_layer_handler.cc b/krita/ui/kis_part_layer_handler.cc new file mode 100644 index 000000000..787de8727 --- /dev/null +++ b/krita/ui/kis_part_layer_handler.cc @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2006 Bart Coppens <kde@bartcoppens.be> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_canvas.h" +#include <fixx11h.h> // kis_canvas.h does X11 stuff + +#include <qpainter.h> +#include <qcursor.h> + +#include "kis_cursor.h" +#include "kis_canvas_painter.h" +#include "kis_move_event.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_group_layer.h" +#include "kis_part_layer_handler.h" + +KisPartLayerHandler::KisPartLayerHandler(KisView* view, const KoDocumentEntry& entry, + KisGroupLayerSP parent, KisLayerSP above) + : m_parent(parent), m_above(above), m_view(view), m_entry(entry) { + m_started = false; + view->getCanvasController()->setCanvasCursor( KisCursor::selectCursor() ); +} + +void KisPartLayerHandler::done() { + emit handlerDone(); // We will get deleted by the view +} + +void KisPartLayerHandler::gotMoveEvent(KisMoveEvent* event) { + if (!m_started) { + emit sigGotMoveEvent(event); + return; + } + + KisCanvasPainter painter(m_view->getCanvasController()->kiscanvas()); + painter.setRasterOp( NotROP ); + + // erase old lines + QRect r(m_start, m_end); + r = r.normalize(); + if (!r.isEmpty()) + painter.drawRect(r); + + m_end = event->pos().roundQPoint(); + r = QRect(m_start, m_end).normalize(); + + painter.drawRect(r); + painter.end(); +} + +void KisPartLayerHandler::gotButtonPressEvent(KisButtonPressEvent* event) { + m_start = event->pos().roundQPoint(); + m_end = m_start; + m_started = true; +} + +void KisPartLayerHandler::gotButtonReleaseEvent(KisButtonReleaseEvent* event) { + if (!m_started) { + done(); + return; + } + + m_end = event->pos().roundQPoint(); + + QRect r(m_start, m_end); + + m_view->insertPart(r.normalize(), m_entry, m_parent, m_above); + // We will get deleted by the view through the above +} + +void KisPartLayerHandler::gotKeyPressEvent(QKeyEvent* event) { + if (event->key() == Key_Escape) { + done(); + } else { + emit sigGotKeyPressEvent(event); + } +} + +#include "kis_part_layer_handler.moc" |
