summaryrefslogtreecommitdiffstats
path: root/karbon/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'karbon/plugins')
-rw-r--r--karbon/plugins/Makefile.am1
-rw-r--r--karbon/plugins/flattenpath/Makefile.am15
-rw-r--r--karbon/plugins/flattenpath/flattenpathplugin.cc85
-rw-r--r--karbon/plugins/flattenpath/flattenpathplugin.h60
-rw-r--r--karbon/plugins/flattenpath/flattenpathplugin.rc11
-rw-r--r--karbon/plugins/imagetool/Makefile.am14
-rw-r--r--karbon/plugins/imagetool/imagetoolplugin.cc56
-rw-r--r--karbon/plugins/imagetool/imagetoolplugin.h39
-rw-r--r--karbon/plugins/imagetool/imagetoolplugin.rc3
-rw-r--r--karbon/plugins/imagetool/karbonimagetool.desktop48
-rw-r--r--karbon/plugins/imagetool/vimagetool.cc132
-rw-r--r--karbon/plugins/imagetool/vimagetool.h70
-rw-r--r--karbon/plugins/insertknots/Makefile.am15
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.cc118
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.h75
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.rc11
-rw-r--r--karbon/plugins/roundcorners/Makefile.am15
-rw-r--r--karbon/plugins/roundcorners/roundcornersplugin.cc402
-rw-r--r--karbon/plugins/roundcorners/roundcornersplugin.h76
-rw-r--r--karbon/plugins/roundcorners/roundcornersplugin.rc11
-rw-r--r--karbon/plugins/shadoweffect/Makefile.am15
-rw-r--r--karbon/plugins/shadoweffect/shadoweffectplugin.cc237
-rw-r--r--karbon/plugins/shadoweffect/shadoweffectplugin.h86
-rw-r--r--karbon/plugins/shadoweffect/shadoweffectplugin.rc11
-rw-r--r--karbon/plugins/shadoweffect/vshadowdecorator.cc150
-rw-r--r--karbon/plugins/shadoweffect/vshadowdecorator.h64
-rw-r--r--karbon/plugins/whirlpinch/Makefile.am16
-rw-r--r--karbon/plugins/whirlpinch/whirlpinchplugin.cc199
-rw-r--r--karbon/plugins/whirlpinch/whirlpinchplugin.h90
-rw-r--r--karbon/plugins/whirlpinch/whirlpinchplugin.rc11
-rw-r--r--karbon/plugins/zoomtool/Makefile.am14
-rw-r--r--karbon/plugins/zoomtool/karbonzoomtool.desktop48
-rw-r--r--karbon/plugins/zoomtool/vzoomtool.cc170
-rw-r--r--karbon/plugins/zoomtool/vzoomtool.h69
-rw-r--r--karbon/plugins/zoomtool/zoomtoolplugin.cc56
-rw-r--r--karbon/plugins/zoomtool/zoomtoolplugin.h41
-rw-r--r--karbon/plugins/zoomtool/zoomtoolplugin.rc3
37 files changed, 2537 insertions, 0 deletions
diff --git a/karbon/plugins/Makefile.am b/karbon/plugins/Makefile.am
new file mode 100644
index 00000000..6f43cf6e
--- /dev/null
+++ b/karbon/plugins/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = flattenpath roundcorners insertknots whirlpinch shadoweffect zoomtool imagetool
diff --git a/karbon/plugins/flattenpath/Makefile.am b/karbon/plugins/flattenpath/Makefile.am
new file mode 100644
index 00000000..2356e933
--- /dev/null
+++ b/karbon/plugins/flattenpath/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_flattenpathplugin.la
+
+karbon_flattenpathplugin_la_SOURCES = flattenpathplugin.cc
+karbon_flattenpathplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOFFICEUI) \
+ ../../libkarboncommon.la
+
+karbon_flattenpathplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = flattenpathplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/flattenpath/flattenpathplugin.cc b/karbon/plugins/flattenpath/flattenpathplugin.cc
new file mode 100644
index 00000000..4532a12c
--- /dev/null
+++ b/karbon/plugins/flattenpath/flattenpathplugin.cc
@@ -0,0 +1,85 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 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 "flattenpathplugin.h"
+#include "klocale.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+#include <commands/vflattencmd.h>
+
+
+typedef KGenericFactory<FlattenPathPlugin, KarbonView> FlattenPathPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_flattenpathplugin, FlattenPathPluginFactory( "karbonflattenpathplugin" ) )
+
+FlattenPathPlugin::FlattenPathPlugin( KarbonView *parent, const char* name, const QStringList & )
+: Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Flatten Path..." ), "14_flatten", 0, this,
+ SLOT( slotFlattenPath() ), actionCollection(), "path_flatten" );
+
+ m_flattenPathDlg = new VFlattenDlg();
+ m_flattenPathDlg->setFlatness( 0.2 );
+}
+
+void
+FlattenPathPlugin::slotFlattenPath()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_flattenPathDlg->exec() )
+ part->addCommand( new VFlattenCmd( &part->document(), m_flattenPathDlg->flatness() ), true );
+}
+
+VFlattenDlg::VFlattenDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Flatten Path" ), Ok | Cancel )
+{
+ // add input fields on the left:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+ new QLabel( i18n( "Flatness:" ), group );
+ m_flatness = new KDoubleNumInput( group );
+ group->setMinimumWidth( 300 );
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+ setFixedSize( baseSize() );
+}
+
+double
+VFlattenDlg::flatness() const
+{
+ return m_flatness->value();
+}
+
+void
+VFlattenDlg::setFlatness( double value )
+{
+ m_flatness->setValue( value);
+}
+
+#include "flattenpathplugin.moc"
+
diff --git a/karbon/plugins/flattenpath/flattenpathplugin.h b/karbon/plugins/flattenpath/flattenpathplugin.h
new file mode 100644
index 00000000..0e92d8f3
--- /dev/null
+++ b/karbon/plugins/flattenpath/flattenpathplugin.h
@@ -0,0 +1,60 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 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 __FLATTENPATHPLUGIN_H__
+#define __FLATTENPATHPLUGIN_H__
+
+#include <kparts/plugin.h>
+#include <kdialogbase.h>
+
+class KarbonView;
+class VFlattenDlg;
+
+class FlattenPathPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ FlattenPathPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~FlattenPathPlugin() {}
+
+private slots:
+ void slotFlattenPath();
+
+private:
+ VFlattenDlg *m_flattenPathDlg;
+};
+
+class KDoubleNumInput;
+
+class VFlattenDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VFlattenDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ double flatness() const;
+ void setFlatness( double value );
+
+private:
+ KDoubleNumInput* m_flatness;
+};
+
+#endif
+
diff --git a/karbon/plugins/flattenpath/flattenpathplugin.rc b/karbon/plugins/flattenpath/flattenpathplugin.rc
new file mode 100644
index 00000000..4b5f76c2
--- /dev/null
+++ b/karbon/plugins/flattenpath/flattenpathplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="flattenpathplugin" library="karbon_flattenpathplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="path_flatten"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" hidden="true" fullWidth="false">
+ <Action name="path_flatten"/>
+</ToolBar>
+</kpartplugin>
diff --git a/karbon/plugins/imagetool/Makefile.am b/karbon/plugins/imagetool/Makefile.am
new file mode 100644
index 00000000..491c0f86
--- /dev/null
+++ b/karbon/plugins/imagetool/Makefile.am
@@ -0,0 +1,14 @@
+kde_services_DATA = karbonimagetool.desktop
+
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_imagetoolplugin.la
+
+karbon_imagetoolplugin_la_SOURCES = imagetoolplugin.cc vimagetool.cc
+karbon_imagetoolplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOFFICEUI) \
+ ../../libkarboncommon.la
+
+karbon_imagetoolplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/imagetool/imagetoolplugin.cc b/karbon/plugins/imagetool/imagetoolplugin.cc
new file mode 100644
index 00000000..cd9c7c2f
--- /dev/null
+++ b/karbon/plugins/imagetool/imagetoolplugin.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 "vimagetool.h"
+
+#include "imagetoolplugin.h"
+
+typedef KGenericFactory<ImageToolPlugin> ImageToolPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_imagetoolplugin, ImageToolPluginFactory( "karbonimagetoolplugin" ) )
+
+ImageToolPlugin::ImageToolPlugin(QObject *parent, const char *name, const QStringList &) : KParts::Plugin(parent, name)
+{
+ setInstance(ImageToolPluginFactory::instance());
+
+ kdDebug() << "VImageToolPlugin. Class: "
+ << className()
+ << ", Parent: "
+ << parent -> className()
+ << "\n";
+
+ if ( parent->inherits("KarbonFactory") )
+ {
+ KarbonToolRegistry* r = KarbonToolRegistry::instance();
+ r->add(new KarbonToolFactory<VImageTool>());
+ }
+}
+
+ImageToolPlugin::~ImageToolPlugin()
+{
+}
+
+#include "imagetoolplugin.moc"
+
diff --git a/karbon/plugins/imagetool/imagetoolplugin.h b/karbon/plugins/imagetool/imagetoolplugin.h
new file mode 100644
index 00000000..6f7e6547
--- /dev/null
+++ b/karbon/plugins/imagetool/imagetoolplugin.h
@@ -0,0 +1,39 @@
+/* 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 __IMAGETOOLPLUGIN_H__
+#define __IMAGETOOLPLUGIN_H__
+
+#include <qstring.h>
+
+#include <kparts/plugin.h>
+
+/**
+ */
+class ImageToolPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ ImageToolPlugin(QObject *parent, const char *name, const QStringList &);
+ virtual ~ImageToolPlugin();
+};
+
+#endif
+
diff --git a/karbon/plugins/imagetool/imagetoolplugin.rc b/karbon/plugins/imagetool/imagetoolplugin.rc
new file mode 100644
index 00000000..2defe12d
--- /dev/null
+++ b/karbon/plugins/imagetool/imagetoolplugin.rc
@@ -0,0 +1,3 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="imagetoolplugin" library="karbon_imagetoolplugin">
+</kpartplugin>
diff --git a/karbon/plugins/imagetool/karbonimagetool.desktop b/karbon/plugins/imagetool/karbonimagetool.desktop
new file mode 100644
index 00000000..1294482e
--- /dev/null
+++ b/karbon/plugins/imagetool/karbonimagetool.desktop
@@ -0,0 +1,48 @@
+[Desktop Entry]
+Name=Image Tool
+Name[bg]=Инструмент за изображения
+Name[br]=Ostilh skeudenn
+Name[ca]=Eina d'imatge
+Name[cy]=Erfyn Delwedd
+Name[da]=Billedværktøj
+Name[de]=Bild-Werkzeug
+Name[el]=Εργαλείο εικόνας
+Name[eo]=Bildprilaborilo
+Name[es]=Herramienta de imagen
+Name[et]=Pilditööriist
+Name[fa]=ابزار تصویر
+Name[fi]=Kuvatyökalu
+Name[fr]=Outil d'images
+Name[fy]=Ofbyldingsark
+Name[ga]=Uirlis Íomhá
+Name[gl]=Ferramenta de Imaxes
+Name[he]=כלי תמונהב
+Name[hr]=Alat za slike
+Name[hu]=Képkezelő
+Name[is]=Myndatól
+Name[it]=Strumento per immagini
+Name[ja]=画像ツール
+Name[km]=ឧបករណ៍​រូបភាព​
+Name[lv]=Attēlu rīks
+Name[nb]=Bildeverktøy
+Name[nds]=Bild-Warktüüch
+Name[ne]=छवि उपकरण
+Name[nl]=Afbeeldingsgereedschap
+Name[pl]=Narzędzie do obrazków
+Name[pt]=Ferramenta de Imagens
+Name[pt_BR]=Ferramenta de Imagens
+Name[ru]=Изображение
+Name[se]=Govvareaidu
+Name[sk]=Nástroj obrázok
+Name[sl]=Slikarsko orodje
+Name[sr]=Алат за слике
+Name[sr@Latn]=Alat za slike
+Name[sv]=Bildverktyg
+Name[uk]=Засіб для зображень
+Name[uz]=Rasm vositasi
+Name[uz@cyrillic]=Расм воситаси
+Name[zh_CN]=图像工具
+Name[zh_TW]=圖片工具
+ServiceTypes=Karbon/CoreModule
+Type=Service
+X-KDE-Library=karbon_imagetoolplugin
diff --git a/karbon/plugins/imagetool/vimagetool.cc b/karbon/plugins/imagetool/vimagetool.cc
new file mode 100644
index 00000000..6511fa4d
--- /dev/null
+++ b/karbon/plugins/imagetool/vimagetool.cc
@@ -0,0 +1,132 @@
+/* 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 <klocale.h>
+#include <kfiledialog.h>
+#include <kdebug.h>
+
+#include "vimagetool.h"
+#include <karbon_part.h>
+#include <karbon_view.h>
+#include <core/vimage.h>
+#include <core/vselection.h>
+#include <core/vcursor.h>
+
+VImageTool::VImageTool( KarbonView *view ) : VTool( view, "tool_image_plugin" )
+{
+ registerTool( this );
+ m_cursor = new QCursor( VCursor::createCursor( VCursor::CrossHair ) );
+}
+
+VImageTool::~VImageTool()
+{
+ delete m_cursor;
+}
+
+QString
+VImageTool::contextHelp()
+{
+ QString s = i18n( "<qt><b>Image tool:</b><br>" );
+ return s;
+}
+
+void
+VImageTool::activate()
+{
+ view()->setCursor( *m_cursor );
+ VTool::activate();
+}
+
+QString
+VImageTool::statusText()
+{
+ return i18n( "Image Tool" );
+}
+
+void
+VImageTool::deactivate()
+{
+}
+
+void
+VImageTool::mouseButtonRelease()
+{
+ QString fname = KFileDialog::getOpenFileName( QString::null, "*.jpg *.gif *.png", view(), i18n( "Choose Image to Add" ) );
+ if( !fname.isEmpty() )
+ {
+ VImage *image = new VImage( 0L, fname );
+ VInsertImageCmd *cmd = new VInsertImageCmd( &view()->part()->document(), i18n( "Insert Image" ), image, first() );
+
+ view()->part()->addCommand( cmd, true );
+ }
+}
+
+VImageTool::VInsertImageCmd::VInsertImageCmd( VDocument* doc, const QString& name, VImage *image, KoPoint pos )
+ : VCommand( doc, name, "frame_image" ), m_image( image ), m_pos( pos )
+{
+}
+
+void
+VImageTool::VInsertImageCmd::execute()
+{
+ if( !m_image )
+ return;
+
+ if( m_image->state() == VObject::deleted )
+ m_image->setState( VObject::normal );
+ else
+ {
+ m_image->setState( VObject::normal );
+ m_image->transform( QWMatrix().translate( m_pos.x(), m_pos.y() ) );
+ document()->append( m_image );
+ document()->selection()->clear();
+ document()->selection()->append( m_image );
+ }
+
+ setSuccess( true );
+}
+
+void
+VImageTool::VInsertImageCmd::unexecute()
+{
+ if( !m_image )
+ return;
+
+ document()->selection()->take( *m_image );
+ m_image->setState( VObject::deleted );
+
+ setSuccess( false );
+}
+
+void
+VImageTool::setup( KActionCollection *collection )
+{
+ m_action = static_cast<KRadioAction *>(collection -> action( name() ) );
+
+ if( m_action == 0 )
+ {
+ m_action = new KRadioAction( i18n( "Image Tool" ), "14_image", Qt::SHIFT+Qt::Key_H, this, SLOT( activate() ), collection, name() );
+ m_action->setToolTip( i18n( "Image" ) );
+ m_action->setExclusiveGroup( "misc" );
+ //m_ownAction = true;
+ }
+}
+
diff --git a/karbon/plugins/imagetool/vimagetool.h b/karbon/plugins/imagetool/vimagetool.h
new file mode 100644
index 00000000..c9ac7f44
--- /dev/null
+++ b/karbon/plugins/imagetool/vimagetool.h
@@ -0,0 +1,70 @@
+/* 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 __VIMAGETOOL_H__
+#define __VIMAGETOOL_H__
+
+#include <qstring.h>
+
+#include "vtool.h"
+#include <commands/vcommand.h>
+
+class KarbonView;
+class VImage;
+class QCursor;
+
+class VImageTool : public VTool
+{
+public:
+ VImageTool( KarbonView *view );
+ ~VImageTool();
+
+ virtual void activate();
+ virtual void deactivate();
+
+ virtual void setup( KActionCollection *collection );
+ virtual QString uiname() { return i18n( "Image Tool" ); }
+ virtual QString contextHelp();
+ virtual QString statusText();
+
+protected:
+ class VInsertImageCmd : public VCommand
+ {
+ public:
+ VInsertImageCmd( VDocument* doc, const QString& name, VImage *image, KoPoint pos );
+ virtual ~VInsertImageCmd() {}
+
+ virtual void execute();
+ virtual void unexecute();
+ virtual bool changesSelection() const { return true; }
+
+ protected:
+ VImage *m_image;
+ KoPoint m_pos;
+ };
+
+ virtual void mouseButtonRelease();
+
+private:
+ QCursor* m_cursor;
+};
+
+#endif
+
diff --git a/karbon/plugins/insertknots/Makefile.am b/karbon/plugins/insertknots/Makefile.am
new file mode 100644
index 00000000..9f76a527
--- /dev/null
+++ b/karbon/plugins/insertknots/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_insertknotsplugin.la
+
+karbon_insertknotsplugin_la_SOURCES = insertknotsplugin.cc
+karbon_insertknotsplugin_la_LIBADD = $(LIB_KPARTS) \
+ ../../libkarboncommon.la
+
+karbon_insertknotsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = insertknotsplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.cc b/karbon/plugins/insertknots/insertknotsplugin.cc
new file mode 100644
index 00000000..2d470b88
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.cc
@@ -0,0 +1,118 @@
+/* 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 "insertknotsplugin.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <core/vpath.h>
+#include <core/vsegment.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+
+typedef KGenericFactory<InsertKnotsPlugin, KarbonView> InsertKnotsPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_insertknotsplugin, InsertKnotsPluginFactory( "karboninsertknotsplugin" ) )
+
+InsertKnotsPlugin::InsertKnotsPlugin( KarbonView *parent, const char* name, const QStringList & ) : Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Insert Knots..." ), "14_insertknots", 0, this,
+ SLOT( slotInsertKnots() ), actionCollection(), "path_insert_knots" );
+
+ m_insertKnotsDlg = new VInsertKnotsDlg();
+}
+
+void
+InsertKnotsPlugin::slotInsertKnots()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_insertKnotsDlg->exec() )
+ part->addCommand( new VInsertKnotsCmd( &part->document(), m_insertKnotsDlg->knots() ), true );
+}
+
+VInsertKnotsDlg::VInsertKnotsDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Insert Knots" ), Ok | Cancel )
+{
+ // add input fields:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+
+ new QLabel( i18n( "Knots:" ), group );
+ m_knots = new KIntSpinBox( group );
+ m_knots->setMinValue( 1 );
+ group->setMinimumWidth( 300 );
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+ setFixedSize( baseSize() );
+}
+
+uint
+VInsertKnotsDlg::knots() const
+{
+ return m_knots->value();
+}
+
+void
+VInsertKnotsDlg::setKnots( uint value )
+{
+ m_knots->setValue( value );
+}
+
+
+VInsertKnotsCmd::VInsertKnotsCmd( VDocument* doc, uint knots )
+ : VReplacingCmd( doc, i18n( "Insert Knots" ) )
+{
+ m_knots = knots > 0 ? knots : 1;
+}
+
+void
+VInsertKnotsCmd::visitVSubpath( VSubpath& path )
+{
+ path.first();
+
+ double length;
+
+ // Ommit first segment.
+ while( path.next() )
+ {
+ length = path.current()->length();
+
+ for( uint i = m_knots; i > 0; --i )
+ {
+ path.insert(
+ path.current()->splitAt(
+ path.current()->lengthParam( length / ( m_knots + 1.0 ) ) ) );
+
+ path.next();
+ }
+
+ if( !success() )
+ setSuccess();
+ }
+}
+
+#include "insertknotsplugin.moc"
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.h b/karbon/plugins/insertknots/insertknotsplugin.h
new file mode 100644
index 00000000..89f0a4d0
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.h
@@ -0,0 +1,75 @@
+/* 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 __INSERTKNOTSPLUGIN_H__
+#define __INSERTKNOTSPLUGIN_H__
+
+#include <kparts/plugin.h>
+#include <kdialogbase.h>
+#include <commands/vreplacingcmd.h>
+
+class VInsertKnotsDlg;
+class KarbonView;
+
+class InsertKnotsPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ InsertKnotsPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~InsertKnotsPlugin() {}
+
+private slots:
+ void slotInsertKnots();
+
+private:
+ VInsertKnotsDlg *m_insertKnotsDlg;
+};
+
+class KIntSpinBox;
+
+class VInsertKnotsDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VInsertKnotsDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ uint knots() const;
+ void setKnots( uint value );
+
+private:
+ KIntSpinBox* m_knots;
+};
+
+class VSubpath;
+
+class VInsertKnotsCmd : public VReplacingCmd
+{
+public:
+ VInsertKnotsCmd( VDocument* doc, uint knots );
+ virtual ~VInsertKnotsCmd() {}
+
+ virtual void visitVSubpath( VSubpath& path );
+
+protected:
+ uint m_knots;
+};
+
+#endif
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.rc b/karbon/plugins/insertknots/insertknotsplugin.rc
new file mode 100644
index 00000000..6572440c
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="insertknotsplugin" library="karbon_insertknotsplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="path_insert_knots"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" fullWidth="false">
+ <Action name="path_insert_knots"/>
+</ToolBar>
+</kpartplugin>
diff --git a/karbon/plugins/roundcorners/Makefile.am b/karbon/plugins/roundcorners/Makefile.am
new file mode 100644
index 00000000..de2ff76c
--- /dev/null
+++ b/karbon/plugins/roundcorners/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_roundcornersplugin.la
+
+karbon_roundcornersplugin_la_SOURCES = roundcornersplugin.cc
+karbon_roundcornersplugin_la_LIBADD = $(LIB_KPARTS) \
+ ../../libkarboncommon.la
+
+karbon_roundcornersplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = roundcornersplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/roundcorners/roundcornersplugin.cc b/karbon/plugins/roundcorners/roundcornersplugin.cc
new file mode 100644
index 00000000..5a36fa51
--- /dev/null
+++ b/karbon/plugins/roundcorners/roundcornersplugin.cc
@@ -0,0 +1,402 @@
+/* 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 "roundcornersplugin.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <core/vpath.h>
+#include <core/vsegment.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+
+typedef KGenericFactory<VRoundCornersPlugin, KarbonView> VRoundCornersPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_roundcornersplugin, VRoundCornersPluginFactory( "karbonroundcornersplugin" ) )
+
+VRoundCornersPlugin::VRoundCornersPlugin( KarbonView *parent, const char* name, const QStringList & ) : Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Round Corners..." ), "14_roundcorners", 0, this,
+ SLOT( slotRoundCorners() ), actionCollection(), "path_round_corners" );
+
+ m_roundCornersDlg = new VRoundCornersDlg();
+ m_roundCornersDlg->setRadius( 10.0 );
+}
+
+VRoundCornersPlugin::~VRoundCornersPlugin()
+{
+}
+
+void
+VRoundCornersPlugin::slotRoundCorners()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_roundCornersDlg->exec() )
+ part->addCommand( new VRoundCornersCmd( &part->document(), m_roundCornersDlg->radius() ), true );
+}
+
+
+VRoundCornersDlg::VRoundCornersDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Polygonize" ), Ok | Cancel )
+{
+ // add input:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+
+ new QLabel( i18n( "Round corners:" ), group );
+ m_radius = new KDoubleNumInput( group );
+ group->setMinimumWidth( 300 );
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+ setFixedSize( baseSize() );
+}
+
+double
+VRoundCornersDlg::radius() const
+{
+ return m_radius->value();
+}
+
+void
+VRoundCornersDlg::setRadius( double value )
+{
+ m_radius->setValue(value);
+}
+
+
+
+VRoundCornersCmd::VRoundCornersCmd( VDocument* doc, double radius )
+ : VReplacingCmd( doc, i18n( "Round Corners" ) )
+{
+ // Set members.
+ m_radius = radius > 0.0 ? radius : 1.0;
+}
+
+void
+VRoundCornersCmd::visitVSubpath( VSubpath& path )
+{
+ // Optimize and avoid a crash.
+ if( path.isEmpty() )
+ return;
+
+ // Note: we modiy segments from path. that doesn't hurt, since we
+ // replace "path" with the temporary path "newPath" afterwards.
+
+ VSubpath newPath( 0L );
+
+ path.first();
+ // Skip "begin".
+ path.next();
+
+ /* This algorithm is worked out by <kudling AT kde DOT org> to produce similar results as
+ * the "round corners" algorithms found in other applications. Neither code nor
+ * algorithms from any 3rd party is used though.
+ *
+ * We want to replace all corners with round corners having "radius" m_radius.
+ * The algorithm doesn't really produce circular arcs, but that's ok since
+ * the algorithm achieves nice looking results and is generic enough to be applied
+ * to all kind of paths.
+ * Note also, that this algorithm doesn't touch smooth joins (in the sense of
+ * VSegment::isSmooth() ).
+ *
+ * We'll manipulate the input path for bookkeeping purposes and construct a new
+ * temporary path in parallel. We finally replace the input path with the new path.
+ *
+ *
+ * Without restricting generality, let's assume the input path is closed and
+ * contains segments which build a rectangle.
+ *
+ * 2
+ * O------------O
+ * | | Numbers reflect the segments' order
+ * 3| |1 in the path. We neglect the "begin"
+ * | | segment here.
+ * O------------O
+ * 0
+ *
+ * There are three unique steps to process. The second step is processed
+ * many times in a loop.
+ *
+ * 1) Begin
+ * -----
+ * Split the first segment of the input path (called "path[0]" here)
+ * at parameter t
+ *
+ * t = path[0]->param( m_radius )
+ *
+ * and move newPath to this new knot. If current segment is too small
+ * (smaller than 2 * m_radius), we always set t = 0.5 here and in the further
+ * steps as well.
+ *
+ * path: new path:
+ *
+ * 2
+ * O------------O
+ * | |
+ * 3 | | 1 The current segment is marked with "#"s.
+ * | |
+ * O##O#########O ...O
+ * 0 0
+ *
+ * 2) Loop
+ * ----
+ * The loop step is iterated over all segments. After each appliance the index n
+ * is incremented and the loop step is reapplied until no untouched segment is left.
+ *
+ * Split the current segment path[n] of the input path at parameter t
+ *
+ * t = path[n]->param( path[n]->length() - m_radius )
+ *
+ * and add the first subsegment of the curent segment to newPath.
+ *
+ * path: new path:
+ *
+ * 2
+ * O------------O
+ * | |
+ * 3 | | 1
+ * | |
+ * O--O######O##O O------O...
+ * 0 0
+ *
+ * Now make the second next segment (the original path[1] segment in our example)
+ * the current one. Split it at parameter t
+ *
+ * t = path[n]->param( m_radius )
+ *
+ * path: new path:
+ *
+ * 2
+ * O------------O
+ * | #
+ * 3 | O 1
+ * | #
+ * O--O------O--O O------O...
+ * 0 0
+ *
+ * Make the first subsegment of the current segment the current one.
+ *
+ * path: new path:
+ *
+ * 2
+ * O------------O
+ * | |
+ * 3 | O 1 O
+ * | # /.1
+ * O--O------O--O O------O...
+ * 0 0
+ *
+ * 3) End
+ * ---
+ *
+ * path: new path:
+ *
+ * 2 4
+ * O--O------O--O 5 .O------O. 3
+ * | | / \
+ * 3 O O 1 6 O O 2
+ * | | 7 .\ /
+ * O--O------O--O ...O------O. 1
+ * 0 0
+ */
+
+ double length;
+ double param;
+
+ // "Begin" step.
+ // =============
+
+ // Convert flat beziers to lines.
+ if( path.current()->isFlat() )
+ path.current()->setDegree( 1 );
+
+ if( path.getLast()->isFlat() )
+ path.getLast()->setDegree( 1 );
+
+ if(
+ path.isClosed() &&
+ // Don't touch smooth joins.
+ !path.getLast()->isSmooth( *path.current() ) )
+ {
+ length = path.current()->length();
+
+ param = length > 2 * m_radius
+ ? path.current()->lengthParam( m_radius )
+ : 0.5;
+
+
+ path.insert(
+ path.current()->splitAt( param ) );
+
+ newPath.moveTo(
+ path.current()->knot() );
+
+ path.next();
+
+
+ if( !success() )
+ setSuccess();
+ }
+ else
+ {
+ newPath.moveTo(
+ path.current()->prev()->knot() );
+ }
+
+
+ // "Loop" step.
+ // ============
+
+ while(
+ path.current() &&
+ path.current()->next() )
+ {
+ // Convert flat beziers to lines.
+ if( path.current()->isFlat() )
+ path.current()->setDegree( 1 );
+
+ if( path.current()->next()->isFlat() )
+ path.current()->next()->setDegree( 1 );
+
+
+ // Don't touch smooth joins.
+ if( path.current()->isSmooth() )
+ {
+ newPath.append( path.current()->clone() );
+ path.next();
+ continue;
+ }
+
+
+ // Split the current segment at param( m_radius ) counting
+ // from the end.
+ length = path.current()->length();
+
+ // If the current segment is too short to be split, just don't split it
+ // because it was split already a t=0.5 during the former step.
+ if( length > m_radius )
+ {
+ param = path.current()->lengthParam( length - m_radius );
+
+ path.insert(
+ path.current()->splitAt( param ) );
+ newPath.append(
+ path.current()->clone() );
+
+ path.next();
+ }
+
+
+ // Jump to the next untouched segment.
+ path.next();
+
+
+ // Split the current segment at param( m_radius ).
+ length = path.current()->length();
+
+ param = length > 2 * m_radius
+ ? path.current()->lengthParam( m_radius )
+ : 0.5;
+
+ path.insert(
+ path.current()->splitAt( param ) );
+
+
+ // Round corner.
+ newPath.curveTo(
+ path.current()->prev()->pointAt( 0.5 ),
+ path.current()->pointAt( 0.5 ),
+ path.current()->knot() );
+
+
+ if( !success() )
+ setSuccess();
+
+ path.next();
+ }
+
+
+ // "End" step.
+ // ===========
+
+ if( path.isClosed() )
+ {
+ // Convert flat beziers to lines.
+ if( path.current()->isFlat() )
+ path.current()->setDegree( 1 );
+
+ if( path.getFirst()->next()->isFlat() )
+ path.getFirst()->next()->setDegree( 1 );
+
+ // Don't touch smooth joins.
+ if( !path.current()->isSmooth( *path.getFirst()->next() ) )
+ {
+ length = path.current()->length();
+
+ // If the current segment is too short to be split, just don't split it
+ // because it was split already at t=0.5 during the former step.
+ if( length > m_radius )
+ {
+ param = path.current()->lengthParam( length - m_radius );
+
+ path.insert(
+ path.current()->splitAt( param ) );
+ newPath.append(
+ path.current()->clone() );
+
+ path.next();
+ }
+
+
+ path.first();
+ path.next();
+
+ // Round corner.
+ newPath.curveTo(
+ path.getLast()->pointAt( 0.5 ),
+ path.current()->pointAt( 0.5 ),
+ path.current()->knot() );
+
+
+ if( !success() )
+ setSuccess();
+ }
+ else
+ newPath.append( path.current()->clone() );
+
+ newPath.close();
+ }
+ else
+ newPath.append( path.current()->clone() );
+
+
+ path = newPath;
+
+ // Invalidate bounding box once.
+ path.invalidateBoundingBox();
+}
+
+#include "roundcornersplugin.moc"
+
diff --git a/karbon/plugins/roundcorners/roundcornersplugin.h b/karbon/plugins/roundcorners/roundcornersplugin.h
new file mode 100644
index 00000000..626d698c
--- /dev/null
+++ b/karbon/plugins/roundcorners/roundcornersplugin.h
@@ -0,0 +1,76 @@
+/* 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 __ROUNDCORNERSPLUGIN_H__
+#define __ROUNDCORNERSPLUGIN_H__
+
+#include <kparts/plugin.h>
+#include <kdialogbase.h>
+#include <commands/vreplacingcmd.h>
+#include <koffice_export.h>
+
+class KarbonView;
+class VRoundCornersDlg;
+
+class KARBONBASE_EXPORT VRoundCornersPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ VRoundCornersPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~VRoundCornersPlugin();
+
+private slots:
+ void slotRoundCorners();
+
+private:
+ VRoundCornersDlg *m_roundCornersDlg;
+};
+
+class KDoubleNumInput;
+
+class VRoundCornersDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VRoundCornersDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ double radius() const;
+ void setRadius( double value );
+
+private:
+ KDoubleNumInput* m_radius;
+};
+
+class VSubpath;
+
+class VRoundCornersCmd : public VReplacingCmd
+{
+public:
+ VRoundCornersCmd( VDocument* doc, double radius );
+ virtual ~VRoundCornersCmd() {}
+
+ virtual void visitVSubpath( VSubpath& path );
+
+protected:
+ double m_radius;
+};
+
+#endif
+
diff --git a/karbon/plugins/roundcorners/roundcornersplugin.rc b/karbon/plugins/roundcorners/roundcornersplugin.rc
new file mode 100644
index 00000000..febd47a4
--- /dev/null
+++ b/karbon/plugins/roundcorners/roundcornersplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="roundcornersplugin" library="karbon_roundcornersplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="path_round_corners"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" hidden="true" fullWidth="false">
+ <Action name="path_round_corners"/>
+</ToolBar>
+</kpartplugin>
diff --git a/karbon/plugins/shadoweffect/Makefile.am b/karbon/plugins/shadoweffect/Makefile.am
new file mode 100644
index 00000000..73d9144f
--- /dev/null
+++ b/karbon/plugins/shadoweffect/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_shadoweffectplugin.la
+
+karbon_shadoweffectplugin_la_SOURCES = shadoweffectplugin.cc vshadowdecorator.cc
+karbon_shadoweffectplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOFFICEUI) \
+ ../../libkarboncommon.la
+
+karbon_shadoweffectplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = shadoweffectplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/shadoweffect/shadoweffectplugin.cc b/karbon/plugins/shadoweffect/shadoweffectplugin.cc
new file mode 100644
index 00000000..c1a0aa33
--- /dev/null
+++ b/karbon/plugins/shadoweffect/shadoweffectplugin.cc
@@ -0,0 +1,237 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 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 "shadoweffectplugin.h"
+#include "klocale.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+#include <core/vgroup.h>
+#include <core/vpath.h>
+#include <core/vsegment.h>
+#include <core/vselection.h>
+#include <core/vdocument.h>
+#include "vshadowdecorator.h"
+
+typedef KGenericFactory<ShadowEffectPlugin, KarbonView> ShadowEffectPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_shadoweffectplugin, ShadowEffectPluginFactory( "karbonshadoweffectplugin" ) )
+
+ShadowEffectPlugin::ShadowEffectPlugin( KarbonView *parent, const char* name, const QStringList & )
+: Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Shadow Effect..." ), "shadowRB", 0, this,
+ SLOT( slotShadowEffect() ), actionCollection(), "object_shadow" );
+
+ m_shadowEffectDlg = new VShadowEffectDlg();
+ m_shadowEffectDlg->setDistance( 2 );
+ m_shadowEffectDlg->setAngle( 0 );
+}
+
+void
+ShadowEffectPlugin::slotShadowEffect()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_shadowEffectDlg->exec() )
+ part->addCommand( new VCreateShadowCmd( &part->document(), m_shadowEffectDlg->distance(), m_shadowEffectDlg->angle(), double( m_shadowEffectDlg->opacity() ) / 255.0 ), true );
+}
+
+VShadowEffectDlg::VShadowEffectDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Create Shadow Effect" ), Ok | Cancel )
+{
+ // add input fields on the left:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+ new QLabel( i18n( "Distance:" ), group );
+ m_distance = new KIntNumInput( group );
+ m_distance->setRange( -1000, 1000, 1, true );
+ m_distance->setValue( 2 );
+ new QLabel( i18n( "Angle:" ), group );
+ m_angle = new KIntNumInput( group );
+ m_angle->setRange( 0, 360, 10, true );
+ m_angle->setValue( 0 );
+ new QLabel( i18n( "Opacity:" ), group );
+ m_opacity = new KIntNumInput( group );
+ m_opacity->setRange( 0, 100, 1, true );
+ m_opacity->setValue( 100 );
+ group->setMinimumWidth( 300 );
+ m_opacity->setSuffix(i18n("%"));
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+}
+
+void
+VShadowEffectDlg::setDistance( int d )
+{
+ m_distance->setValue( d );
+}
+
+void
+VShadowEffectDlg::setAngle( int a )
+{
+ m_angle->setValue( a );
+}
+
+void
+VShadowEffectDlg::setOpacity( int o )
+{
+ m_angle->setValue( o );
+}
+
+int
+VShadowEffectDlg::distance() const
+{
+ return m_distance->value();
+}
+
+int
+VShadowEffectDlg::angle() const
+{
+ return m_angle->value();
+}
+
+int
+VShadowEffectDlg::opacity() const
+{
+ return m_opacity->value();
+}
+
+VCreateShadowCmd::VCreateShadowCmd( VDocument* doc, int distance, int angle, float opacity )
+ : VCommand( doc, i18n( "Create Shadow" ) ), m_distance( distance ), m_angle( angle ), m_opacity( opacity )
+{
+ // Set members.
+ m_oldObjects = document()->selection()->clone();
+ m_newObjects = 0L;
+}
+
+VCreateShadowCmd::~VCreateShadowCmd()
+{
+ delete( m_oldObjects );
+ delete( m_newObjects );
+}
+
+void
+VCreateShadowCmd::execute()
+{
+ // Did we have at least once a success? Otherwise we don't get inserted
+ // into the command history.
+ bool successful = false;
+
+
+ // Create new shapes if they don't exist yet.
+ if( !m_newObjects )
+ {
+ m_newObjects = new VSelection();
+
+ // Pointer to temporary object.
+ VObject* newObject;
+
+ VObjectListIterator itr( m_oldObjects->objects() );
+
+ for( ; itr.current(); ++itr )
+ {
+ // Clone object and visit the clone.
+ VShadowDecorator *shadow = dynamic_cast<VShadowDecorator *>( itr.current() );
+ if( shadow )
+ {
+ //kdDebug() << "Its a decorator!!!" << endl;
+ shadow->setShadow( m_distance, m_angle, m_opacity );
+ newObject = 0L;
+ }
+ else
+ newObject = new VShadowDecorator( itr.current()->clone(), 0L, m_distance, m_angle, m_opacity );
+
+ successful = true;
+
+ if(newObject)
+ {
+ // Insert new shape right before old shape.
+ itr.current()->parent()->insertInfrontOf(
+ newObject, itr.current() );
+
+ // Add new shape to list of new objects.
+ m_newObjects->append( newObject );
+ }
+ }
+ }
+
+ // Nothing to do.
+ if( m_newObjects->objects().count() == 0 )
+ return;
+
+ VObjectListIterator itr( m_oldObjects->objects() );
+
+ // Hide old objects.
+ for( ; itr.current(); ++itr )
+ {
+ document()->selection()->take( *itr.current() );
+ itr.current()->setState( VObject::deleted );
+ }
+
+ // Show new objects.
+ for( itr = m_newObjects->objects(); itr.current(); ++itr )
+ {
+ itr.current()->setState( VObject::normal );
+ document()->selection()->append( itr.current() );
+ }
+
+ successful = true;
+
+ // Tell command history wether we had success at least once.
+ setSuccess( successful );
+}
+
+void
+VCreateShadowCmd::unexecute()
+{
+ // Nothing to do.
+ if( m_newObjects->objects().count() == 0 )
+ return;
+
+
+ VObjectListIterator itr( m_oldObjects->objects() );
+
+ // Show old objects.
+ for( ; itr.current(); ++itr )
+ {
+ itr.current()->setState( VObject::normal );
+ document()->selection()->append( itr.current() );
+ }
+
+ // Hide new objects.
+ for( itr = m_newObjects->objects(); itr.current(); ++itr )
+ {
+ document()->selection()->take( *itr.current() );
+ itr.current()->setState( VObject::deleted );
+ }
+
+ // Reset success for command history.
+ setSuccess( false );
+}
+
+#include "shadoweffectplugin.moc"
+
diff --git a/karbon/plugins/shadoweffect/shadoweffectplugin.h b/karbon/plugins/shadoweffect/shadoweffectplugin.h
new file mode 100644
index 00000000..9a97da98
--- /dev/null
+++ b/karbon/plugins/shadoweffect/shadoweffectplugin.h
@@ -0,0 +1,86 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003, 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 __SHADOWEFFECTPLUGIN_H__
+#define __SHADOWEFFECTPLUGIN_H__
+
+#include <kparts/plugin.h>
+#include <kdialogbase.h>
+#include <commands/vcommand.h>
+
+class KarbonView;
+class VSelection;
+class VShadowEffectDlg;
+
+class ShadowEffectPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ ShadowEffectPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~ShadowEffectPlugin() {}
+
+private slots:
+ void slotShadowEffect();
+
+private:
+ VShadowEffectDlg *m_shadowEffectDlg;
+};
+
+class KIntNumInput;
+
+class VShadowEffectDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VShadowEffectDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ void setAngle( int );
+ void setDistance( int );
+ void setOpacity( int );
+
+ int angle() const;
+ int distance() const;
+ int opacity() const;
+
+private:
+ KIntNumInput *m_angle;
+ KIntNumInput *m_distance;
+ KIntNumInput *m_opacity;
+};
+
+class VCreateShadowCmd : public VCommand
+{
+public:
+ VCreateShadowCmd( VDocument* doc, int distance, int angle, float opacity );
+ virtual ~VCreateShadowCmd();
+
+ virtual void execute();
+ virtual void unexecute();
+ virtual bool changesSelection() const { return true; }
+private:
+ VSelection *m_oldObjects;
+ VSelection *m_newObjects;
+ int m_distance;
+ int m_angle;
+ float m_opacity;
+};
+
+#endif
+
diff --git a/karbon/plugins/shadoweffect/shadoweffectplugin.rc b/karbon/plugins/shadoweffect/shadoweffectplugin.rc
new file mode 100644
index 00000000..2cfe75af
--- /dev/null
+++ b/karbon/plugins/shadoweffect/shadoweffectplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="shadoweffectplugin" library="karbon_shadoweffectplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="object_shadow"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" hidden="true" fullWidth="false">
+ <Action name="object_shadow"/>
+</ToolBar>
+</kpartplugin>
diff --git a/karbon/plugins/shadoweffect/vshadowdecorator.cc b/karbon/plugins/shadoweffect/vshadowdecorator.cc
new file mode 100644
index 00000000..238673ba
--- /dev/null
+++ b/karbon/plugins/shadoweffect/vshadowdecorator.cc
@@ -0,0 +1,150 @@
+/* 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 "vshadowdecorator.h"
+#include <core/vfill.h>
+#include <core/vstroke.h>
+#include <render/vpainter.h>
+#include <core/vvisitor.h>
+#include <core/vdocument.h>
+#include <core/vselection.h>
+#include <commands/vtransformcmd.h>
+
+VShadowDecorator::VShadowDecorator( VObject *object, VObject* parent, int distance, int angle, float opacity )
+ : VObject( parent ), m_object( object ), m_distance( distance ), m_angle( angle ), m_opacity( opacity )
+{
+}
+
+VShadowDecorator::VShadowDecorator( const VShadowDecorator& other ) : VObject( other )
+{
+ m_object = other.m_object->clone();
+ m_opacity = other.m_opacity;
+ m_distance = other.m_distance;
+ m_angle = other.m_angle;
+}
+
+VShadowDecorator::~VShadowDecorator()
+{
+ delete m_object;
+}
+
+void
+VShadowDecorator::draw( VPainter* painter, const KoRect* rect ) const
+{
+ if( state() == deleted ||
+ state() == hidden ||
+ state() == hidden_locked )
+ {
+ return;
+ }
+
+ // make sure swallowed object has the same state
+ m_object->setState( state() );
+
+ if( state() != VObject::edit )
+ {
+ int shadowDx = int( m_distance * cos( m_angle / 360. * 6.2832 ) );
+ int shadowDy = int( m_distance * sin( m_angle / 360. * 6.2832 ) );
+
+ VFill *fill = new VFill( *m_object->fill() );
+ VStroke *stroke = new VStroke( *m_object->stroke() );
+ VColor black( Qt::black );
+ black.setOpacity( m_opacity );
+ if( m_object->fill()->type() != VFill::none )
+ m_object->fill()->setColor( black );
+ m_object->stroke()->setColor( black );
+ QWMatrix mat = painter->worldMatrix();
+ painter->setWorldMatrix( mat.translate( shadowDx * painter->zoomFactor(), -shadowDy * painter->zoomFactor()) );
+ m_object->draw( painter, rect );
+ m_object->setFill( *fill );
+ m_object->setStroke( *stroke );
+ painter->setWorldMatrix( mat.translate( -shadowDx* painter->zoomFactor() , shadowDy * painter->zoomFactor() ) );
+ }
+ m_object->draw( painter, rect );
+}
+
+VObject *
+VShadowDecorator::clone() const
+{
+ return new VShadowDecorator( *this );
+}
+
+void
+VShadowDecorator::accept( VVisitor& visitor )
+{
+ m_object->accept( visitor );
+ visitor.visitVObject( *this );
+ // do not allow swallowed object to be part of the selection
+ document()->selection()->take( *m_object );
+}
+
+void
+VShadowDecorator::setShadow( int distance, int angle, float opacity )
+{
+ m_distance = distance;
+ m_angle = angle;
+ m_opacity = opacity;
+}
+
+void
+VShadowDecorator::setStroke( const VStroke& stroke )
+{
+ m_object->setStroke( stroke );
+}
+
+void
+VShadowDecorator::setFill( const VFill& fill )
+{
+ m_object->setFill( fill );
+}
+
+void
+VShadowDecorator::setState( const VState state )
+{
+ m_state = state;
+ m_object->setState( state );
+}
+
+void
+VShadowDecorator::save( QDomElement& element ) const
+{
+ if( m_state != VObject::deleted )
+ {
+ // save shadow as new object
+ int shadowDx = int( m_distance * cos( m_angle / 360. * 6.2832 ) );
+ int shadowDy = int( m_distance * sin( m_angle / 360. * 6.2832 ) );
+
+ VObject *shadow = m_object->clone();
+
+ VColor black( Qt::black );
+ black.setOpacity( m_opacity );
+ if( shadow->fill()->type() != VFill::none )
+ shadow->fill()->setColor( black );
+ shadow->stroke()->setColor( black );
+ QWMatrix mat;
+ mat.translate( shadowDx, -shadowDy );
+ VTransformCmd trafo( 0L, mat );
+ trafo.visit( *shadow );
+ shadow->save( element );
+ delete shadow;
+
+ // save swallowed object
+ m_object->save( element );
+ }
+}
diff --git a/karbon/plugins/shadoweffect/vshadowdecorator.h b/karbon/plugins/shadoweffect/vshadowdecorator.h
new file mode 100644
index 00000000..3ec57e88
--- /dev/null
+++ b/karbon/plugins/shadoweffect/vshadowdecorator.h
@@ -0,0 +1,64 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001, 2002, 2003 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 __VSHADOWDECORATOR_H__
+#define __VSHADOWDECORATOR_H__
+
+
+#include "vobject.h"
+#include <koffice_export.h>
+
+/**
+ */
+class KARBONBASE_EXPORT VShadowDecorator : public VObject
+{
+public:
+ VShadowDecorator( VObject* object, VObject* parent, int distance = 2, int angle = 0, float opacity = 1.0 );
+ VShadowDecorator( const VShadowDecorator& obj );
+
+ virtual ~VShadowDecorator();
+
+ virtual void draw( VPainter* /*painter*/, const KoRect* /*rect*/ = 0L ) const;
+
+ virtual const KoRect& boundingBox() const { return m_object->boundingBox(); }
+ VStroke* stroke() const { return m_object->stroke(); }
+ virtual void setStroke( const VStroke& stroke );
+ VFill* fill() const { return m_object->fill(); }
+ virtual void setFill( const VFill& fill );
+
+ virtual void accept( VVisitor& /*visitor*/ );
+
+ virtual void save( QDomElement& ) const;
+ virtual void load( const QDomElement& ) {}
+
+ virtual VObject* clone() const;
+
+ VState state() const { return m_state; }
+ virtual void setState( const VState state );
+
+ void setShadow( int distance = 2, int angle = 0, float opacity = 1.0 );
+protected:
+ VObject *m_object;
+ int m_distance;
+ int m_angle;
+ float m_opacity;
+};
+
+#endif
+
diff --git a/karbon/plugins/whirlpinch/Makefile.am b/karbon/plugins/whirlpinch/Makefile.am
new file mode 100644
index 00000000..a0d53a7c
--- /dev/null
+++ b/karbon/plugins/whirlpinch/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(KOPAINTER_INCLUDES) $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_whirlpinchplugin.la
+
+karbon_whirlpinchplugin_la_SOURCES = whirlpinchplugin.cc
+karbon_whirlpinchplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOPAINTER) \
+ ../../libkarboncommon.la
+
+
+karbon_whirlpinchplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = whirlpinchplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/whirlpinch/whirlpinchplugin.cc b/karbon/plugins/whirlpinch/whirlpinchplugin.cc
new file mode 100644
index 00000000..5c6c716a
--- /dev/null
+++ b/karbon/plugins/whirlpinch/whirlpinchplugin.cc
@@ -0,0 +1,199 @@
+/* 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 <core/vselection.h>
+#include "whirlpinchplugin.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <kgenericfactory.h>
+#include <core/vdocument.h>
+#include <core/vcomposite.h>
+#include <core/vpath.h>
+#include <core/vsegment.h>
+#include <core/vglobal.h>
+
+#include <kdebug.h>
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+
+typedef KGenericFactory<WhirlPinchPlugin, KarbonView> WhirlPinchPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_whirlpinchplugin, WhirlPinchPluginFactory( "karbonwhirlpinchplugin" ) )
+
+WhirlPinchPlugin::WhirlPinchPlugin( KarbonView *parent, const char* name, const QStringList & ) : Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Whirl/Pinch..." ), "14_whirl", 0, this,
+ SLOT( slotWhirlPinch() ), actionCollection(), "path_whirlpinch" );
+
+ m_whirlPinchDlg = new VWhirlPinchDlg();
+ m_whirlPinchDlg->setAngle( 20.0 );
+ m_whirlPinchDlg->setPinch( 0.0 );
+ m_whirlPinchDlg->setRadius( 100.0 );
+}
+
+void
+WhirlPinchPlugin::slotWhirlPinch()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_whirlPinchDlg->exec() )
+ part->addCommand( new VWhirlPinchCmd( &part->document(), m_whirlPinchDlg->angle(), m_whirlPinchDlg->pinch(), m_whirlPinchDlg->radius() ), true );
+}
+
+VWhirlPinchDlg::VWhirlPinchDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Whirl Pinch" ), Ok | Cancel )
+{
+ // add input fields:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+
+ new QLabel( i18n( "Angle:" ), group );
+ m_angle = new KDoubleNumInput( group );
+ new QLabel( i18n( "Pinch:" ), group );
+ m_pinch = new KDoubleNumInput( group );
+ new QLabel( i18n( "Radius:" ), group );
+ m_radius = new KDoubleNumInput( group );
+ group->setMinimumWidth( 300 );
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+ setFixedSize( baseSize() );
+}
+
+double
+VWhirlPinchDlg::angle() const
+{
+ return m_angle->value();
+}
+
+double
+VWhirlPinchDlg::pinch() const
+{
+ return m_pinch->value();
+}
+
+double
+VWhirlPinchDlg::radius() const
+{
+ return m_radius->value();
+}
+
+void
+VWhirlPinchDlg::setAngle( double value )
+{
+ m_angle->setValue( value);
+}
+
+void
+VWhirlPinchDlg::setPinch( double value )
+{
+ m_pinch->setValue(value);
+}
+
+void
+VWhirlPinchDlg::setRadius( double value )
+{
+ m_radius->setValue( value);
+}
+
+VWhirlPinchCmd::VWhirlPinchCmd( VDocument* doc,
+ double angle, double pinch, double radius )
+ : VReplacingCmd( doc, i18n( "Whirl Pinch" ) )
+{
+ m_angle = angle;
+ m_pinch = pinch;
+ m_radius = radius;
+ m_center = document()->selection()->boundingBox().center();
+}
+
+VWhirlPinchCmd::~VWhirlPinchCmd()
+{
+}
+
+void
+VWhirlPinchCmd::visitVPath( VPath& composite )
+{
+ // first subdivide:
+// VInsertKnots insertKnots( 2 );
+// insertKnots.visit( composite );
+
+ VVisitor::visitVPath( composite );
+}
+
+void
+VWhirlPinchCmd::visitVSubpath( VSubpath& path )
+{
+ QWMatrix m;
+ KoPoint delta;
+ double dist;
+
+ path.first();
+
+ VSegment *curr = path.current();
+
+ while( curr )
+ {
+// TODO: selfmade this function since it's gone:
+// path.current()->convertToCurve();
+
+ // Apply effect to each segment node.
+ for( int i = 0; i < curr->degree(); ++i )
+ {
+ // calculate distance from whirl center to actual point
+ delta = curr->point( i ) - m_center;
+ dist = sqrt( delta.x() * delta.x() + delta.y() * delta.y() );
+
+ // check if point is inside the whirl radius
+ if( dist < m_radius )
+ {
+ m.reset();
+
+ // normalize distance to whirl radius
+ dist /= m_radius;
+
+ double scale = pow( sin( VGlobal::pi_2 * dist ), -m_pinch );
+ // pinch:
+ m.translate( m_center.x(), m_center.y() );
+ m.scale( scale, scale );
+
+ // whirl:
+ m.rotate( m_angle * ( 1.0 - dist ) * ( 1.0 - dist ) );
+ m.translate( -m_center.x(), -m_center.y() );
+
+ path.current()->setPoint( i, curr->point( i ).transform( m ) );
+ }
+
+ }
+
+ if( !success() )
+ setSuccess();
+
+ curr = path.next();
+ }
+
+ // Invalidate bounding box once.
+ path.invalidateBoundingBox();
+}
+
+#include "whirlpinchplugin.moc"
+
diff --git a/karbon/plugins/whirlpinch/whirlpinchplugin.h b/karbon/plugins/whirlpinch/whirlpinchplugin.h
new file mode 100644
index 00000000..ffbff5b2
--- /dev/null
+++ b/karbon/plugins/whirlpinch/whirlpinchplugin.h
@@ -0,0 +1,90 @@
+/* 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 __WHIRLPINCHPLUGIN_H__
+#define __WHIRLPINCHPLUGIN_H__
+
+#include <kdialogbase.h>
+#include <kparts/plugin.h>
+#include <commands/vreplacingcmd.h>
+
+class KarbonView;
+class VWhirlPinchDlg;
+
+class WhirlPinchPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ WhirlPinchPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~WhirlPinchPlugin() {}
+
+private slots:
+ void slotWhirlPinch();
+
+private:
+ VWhirlPinchDlg *m_whirlPinchDlg;
+};
+
+class KDoubleNumInput;
+
+class VWhirlPinchDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VWhirlPinchDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ double angle() const;
+ double pinch() const;
+ double radius() const;
+ void setAngle( double value );
+ void setPinch( double value );
+ void setRadius( double value );
+
+private:
+ KDoubleNumInput* m_angle;
+ KDoubleNumInput* m_pinch;
+ KDoubleNumInput* m_radius;
+};
+
+class VPath;
+class VSubpath;
+class VSelection;
+
+class VWhirlPinchCmd : public VReplacingCmd
+{
+public:
+ VWhirlPinchCmd( VDocument* doc,
+ double angle, double pinch, double radius );
+ virtual ~VWhirlPinchCmd();
+
+ virtual void visitVPath( VPath& composite );
+ virtual void visitVSubpath( VSubpath& path );
+
+ virtual bool changesSelection() const { return true; }
+
+protected:
+ KoPoint m_center;
+ double m_angle;
+ double m_pinch;
+ double m_radius;
+};
+
+#endif
+
diff --git a/karbon/plugins/whirlpinch/whirlpinchplugin.rc b/karbon/plugins/whirlpinch/whirlpinchplugin.rc
new file mode 100644
index 00000000..797707f7
--- /dev/null
+++ b/karbon/plugins/whirlpinch/whirlpinchplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="whirlpinchplugin" library="karbon_whirlpinchplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="path_whirlpinch"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" hidden="true" fullWidth="false">
+ <Action name="path_whirlpinch"/>
+</ToolBar>
+</kpartplugin>
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>