diff options
Diffstat (limited to 'karbon/plugins/zoomtool')
-rw-r--r-- | karbon/plugins/zoomtool/Makefile.am | 14 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/karbonzoomtool.desktop | 48 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/vzoomtool.cc | 170 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/vzoomtool.h | 69 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/zoomtoolplugin.cc | 56 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/zoomtoolplugin.h | 41 | ||||
-rw-r--r-- | karbon/plugins/zoomtool/zoomtoolplugin.rc | 3 |
7 files changed, 401 insertions, 0 deletions
diff --git a/karbon/plugins/zoomtool/Makefile.am b/karbon/plugins/zoomtool/Makefile.am new file mode 100644 index 00000000..a0883c96 --- /dev/null +++ b/karbon/plugins/zoomtool/Makefile.am @@ -0,0 +1,14 @@ +kde_services_DATA = karbonzoomtool.desktop + +INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes) + +kde_module_LTLIBRARIES = karbon_zoomtoolplugin.la + +karbon_zoomtoolplugin_la_SOURCES = vzoomtool.cc zoomtoolplugin.cc +karbon_zoomtoolplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOFFICEUI) \ + ../../libkarboncommon.la + +karbon_zoomtoolplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +METASOURCES = AUTO + diff --git a/karbon/plugins/zoomtool/karbonzoomtool.desktop b/karbon/plugins/zoomtool/karbonzoomtool.desktop new file mode 100644 index 00000000..3692ac54 --- /dev/null +++ b/karbon/plugins/zoomtool/karbonzoomtool.desktop @@ -0,0 +1,48 @@ +[Desktop Entry] +Name=Zoom Tool +Name[bg]=Инструмент за мащаб +Name[br]=Ostilh Zoom +Name[ca]=Eina per a apropar/allunyar +Name[cy]=Erfyn Chwyddo +Name[da]=Forstørrelsesværktøj +Name[de]=Zoom-Werkzeug +Name[el]=Εργαλείο εστίασης +Name[eo]=Zomilo +Name[es]=Herramienta para zoom +Name[et]=Suurendustööriist +Name[fa]=ابزار بزرگنمایی +Name[fi]=Zoomaustyökalu +Name[fr]=Outil de zoom +Name[fy]=Zoomark +Name[ga]=Uirlis Súmála +Name[gl]=Ferramenta de Ampliación +Name[hr]=Alat za uvećavanje +Name[hu]=Nagyító +Name[is]=Stækkunartól +Name[it]=Strumento di ingrandimento +Name[ja]=ズームツール +Name[km]=ឧបករណ៍ពង្រីក +Name[lt]=Didinimo įrankis +Name[lv]=Tālummaiņas rīks +Name[nb]=Verktøy som forstørrer/forminsker +Name[nds]=Vergröttern-Warktüüch +Name[ne]=जूम उपकरण +Name[nl]=Zoomgereedschap +Name[pl]=Narzędzie powiększenia +Name[pt]=Ferramenta de Ampliação +Name[pt_BR]=Ferramenta de Ampliação +Name[ru]=Масштабирование +Name[se]=Stuoridan-/unnidanreaidu +Name[sk]=Nástroj lupa +Name[sl]=Orodje za povečavo +Name[sr]=Алат за увећање +Name[sr@Latn]=Alat za uvećanje +Name[sv]=Zoomverktyg +Name[uk]=Засіб масштабування +Name[uz]=Kattalashtirish vositasi +Name[uz@cyrillic]=Катталаштириш воситаси +Name[zh_CN]=缩放工具 +Name[zh_TW]=縮放工具 +ServiceTypes=Karbon/CoreModule +Type=Service +X-KDE-Library=karbon_zoomtoolplugin diff --git a/karbon/plugins/zoomtool/vzoomtool.cc b/karbon/plugins/zoomtool/vzoomtool.cc new file mode 100644 index 00000000..60142481 --- /dev/null +++ b/karbon/plugins/zoomtool/vzoomtool.cc @@ -0,0 +1,170 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#include <qcursor.h> +#include <qevent.h> + +#include <klocale.h> + +#include "vzoomtool.h" +#include <karbon_part.h> +#include <karbon_part.h> +#include <karbon_view.h> +#include <karbon_view.h> +#include <render/vpainter.h> +#include <render/vpainterfactory.h> +#include <core/vcursor.h> + +VZoomTool::VZoomTool(KarbonView *view ): VTool( view, "tool_zoom_plugin" ) +{ + m_plusCursor = new QCursor( VCursor::createCursor( VCursor::ZoomPlus ) ); + + registerTool( this ); +} + +VZoomTool::~VZoomTool() +{ + delete m_plusCursor; +} + +QString +VZoomTool::contextHelp() +{ + QString s = i18n( "<qt><b>Zoom tool:</b><br>" ); + s += i18n( "<i>Click and drag</i> to zoom into a rectangular area.<br>" ); + s += i18n( "<i>Right click</i> to zoom out of canvas.<br>" ); + s += i18n( "<i>Pressing +/- keys</i><br>to zoom into/out of canvas." ); + return s; +} + +void +VZoomTool::activate() +{ + VTool::activate(); + view()->setCursor( *m_plusCursor ); +} + +QString +VZoomTool::statusText() +{ + return i18n( "Zoom Tool" ); +} + +void +VZoomTool::deactivate() +{ +} + +void +VZoomTool::draw() +{ + VPainter *painter = view()->painterFactory()->editpainter(); + painter->setRasterOp( Qt::NotROP ); + + if( isDragging() ) + { + painter->setPen( Qt::DotLine ); + painter->newPath(); + painter->moveTo( KoPoint( first().x(), first().y() ) ); + painter->lineTo( KoPoint( m_current.x(), first().y() ) ); + painter->lineTo( KoPoint( m_current.x(), m_current.y() ) ); + painter->lineTo( KoPoint( first().x(), m_current.y() ) ); + painter->lineTo( KoPoint( first().x(), first().y() ) ); + painter->strokePath(); + } +} + +void +VZoomTool::mouseButtonPress() +{ + m_current = first(); + + recalc(); + + draw(); +} + +void +VZoomTool::rightMouseButtonRelease() +{ + view()->setZoomAt( view()->zoom() * 0.75, last() ); +} + +void +VZoomTool::mouseButtonRelease() +{ + view()->setZoomAt( view()->zoom() * 1.5, last() ); +} + +void +VZoomTool::mouseDrag() +{ + draw(); + + recalc(); + + draw(); +} + +void +VZoomTool::mouseDragRelease() +{ + KoRect rect( first().x(), first().y(), last().x() - first().x(), last().y() - first().y() ); + rect = rect.normalize(); + view()->setViewportRect( rect ); +} + +bool +VZoomTool::keyReleased( Qt::Key key ) +{ + double zoomChange = 0; + if( key == Qt::Key_Minus ) + zoomChange = 0.75; + else if( key == Qt::Key_Plus ) + zoomChange = 1.50; + + if( zoomChange != 0 ) + { + view()->setZoomAt( view()->zoom() * zoomChange ); + return true; + } + return false; +} + +void +VZoomTool::recalc() +{ + m_current = last(); +} + +void +VZoomTool::setup( KActionCollection *collection ) +{ + m_action = static_cast<KRadioAction *>(collection -> action( name() ) ); + + if( m_action == 0 ) + { + m_action = new KRadioAction( i18n( "Zoom Tool" ), "14_zoom", Qt::SHIFT+Qt::Key_H, this, SLOT( activate() ), collection, name() ); + m_action->setToolTip( i18n( "Zoom" ) ); + m_action->setExclusiveGroup( "misc" ); + //m_ownAction = true; + } +} + diff --git a/karbon/plugins/zoomtool/vzoomtool.h b/karbon/plugins/zoomtool/vzoomtool.h new file mode 100644 index 00000000..2616c03f --- /dev/null +++ b/karbon/plugins/zoomtool/vzoomtool.h @@ -0,0 +1,69 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#ifndef __VZOOMTOOL_H__ +#define __VZOOMTOOL_H__ + +#include "KoPoint.h" +#include <qstring.h> + +#include "vtool.h" + +class QCursor; + +class KarbonView; + +class VZoomTool : public VTool +{ +public: + VZoomTool( KarbonView *view ); + ~VZoomTool(); + + virtual void activate(); + virtual void deactivate(); + + virtual void setup( KActionCollection *collection ); + virtual QString uiname() { return i18n( "Zoom Tool" ); } + virtual QString contextHelp(); + virtual QString statusText(); + +protected: + void draw(); + + virtual void mouseButtonPress(); + virtual void mouseButtonRelease(); + virtual void mouseDrag(); + virtual void mouseDragRelease(); + + virtual bool keyReleased( Qt::Key key ); + + virtual void rightMouseButtonRelease(); + + void recalc(); + + KoPoint m_current; + +private: + QCursor* m_plusCursor; + +}; + +#endif + diff --git a/karbon/plugins/zoomtool/zoomtoolplugin.cc b/karbon/plugins/zoomtool/zoomtoolplugin.cc new file mode 100644 index 00000000..fefec1d9 --- /dev/null +++ b/karbon/plugins/zoomtool/zoomtoolplugin.cc @@ -0,0 +1,56 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#include <kgenericfactory.h> + +#include "karbon_factory.h" +#include "karbon_tool_factory.h" +#include "karbon_tool_registry.h" + +#include "zoomtoolplugin.h" +#include "vzoomtool.h" + +typedef KGenericFactory<ZoomToolPlugin> ZoomToolPluginFactory; +K_EXPORT_COMPONENT_FACTORY( karbon_zoomtoolplugin, ZoomToolPluginFactory( "karbonzoomtoolplugin" ) ) + +ZoomToolPlugin::ZoomToolPlugin(QObject *parent, const char *name, const QStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ZoomToolPluginFactory::instance()); + + kdDebug() << "Zoom tool plugin. Class: " + << className() + << ", Parent: " + << parent -> className() + << "\n"; + + if ( parent->inherits("KarbonFactory") ) + { + KarbonToolRegistry* r = KarbonToolRegistry::instance(); + r -> add(new KarbonToolFactory<VZoomTool>()); + } + +} + +ZoomToolPlugin::~ZoomToolPlugin() +{ +} + +#include "zoomtoolplugin.moc" diff --git a/karbon/plugins/zoomtool/zoomtoolplugin.h b/karbon/plugins/zoomtool/zoomtoolplugin.h new file mode 100644 index 00000000..488526c7 --- /dev/null +++ b/karbon/plugins/zoomtool/zoomtoolplugin.h @@ -0,0 +1,41 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#ifndef __ZOOMTOOLPLUGIN_H__ +#define __ZOOMTOOLPLUGIN_H__ + +#include <qstring.h> + +#include <kparts/plugin.h> + +/** + * A module that provides a zoom tool. + */ +class ZoomToolPlugin : public KParts::Plugin +{ + Q_OBJECT +public: + ZoomToolPlugin(QObject *parent, const char *name, const QStringList &); + virtual ~ZoomToolPlugin(); +}; + +#endif // __ZOOMTOOLPLUGIN_H__ + + diff --git a/karbon/plugins/zoomtool/zoomtoolplugin.rc b/karbon/plugins/zoomtool/zoomtoolplugin.rc new file mode 100644 index 00000000..14a6399c --- /dev/null +++ b/karbon/plugins/zoomtool/zoomtoolplugin.rc @@ -0,0 +1,3 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="zoomtoolplugin" library="karbon_zoomtoolplugin"> +</kpartplugin> |