summaryrefslogtreecommitdiffstats
path: root/kivio/plugins/kiviotexttool
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kivio/plugins/kiviotexttool
downloadkoffice-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 'kivio/plugins/kiviotexttool')
-rw-r--r--kivio/plugins/kiviotexttool/Makefile.am38
-rw-r--r--kivio/plugins/kiviotexttool/Text.sml16
-rw-r--r--kivio/plugins/kiviotexttool/Text.xpm70
-rw-r--r--kivio/plugins/kiviotexttool/kivio_stenciltexteditorui.ui256
-rw-r--r--kivio/plugins/kiviotexttool/kivio_text.xpm25
-rw-r--r--kivio/plugins/kiviotexttool/kivio_text_cursor.xpm25
-rw-r--r--kivio/plugins/kiviotexttool/kiviotexttool.desktop66
-rw-r--r--kivio/plugins/kiviotexttool/kiviotexttool.rc11
-rw-r--r--kivio/plugins/kiviotexttool/plugin.cpp58
-rw-r--r--kivio/plugins/kiviotexttool/plugin.h44
-rw-r--r--kivio/plugins/kiviotexttool/stenciltexteditor.cpp190
-rw-r--r--kivio/plugins/kiviotexttool/stenciltexteditor.h72
-rw-r--r--kivio/plugins/kiviotexttool/tool_text.cpp439
-rw-r--r--kivio/plugins/kiviotexttool/tool_text.h88
14 files changed, 1398 insertions, 0 deletions
diff --git a/kivio/plugins/kiviotexttool/Makefile.am b/kivio/plugins/kiviotexttool/Makefile.am
new file mode 100644
index 00000000..fa355929
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/Makefile.am
@@ -0,0 +1,38 @@
+kde_module_LTLIBRARIES =libkiviotexttool.la
+
+
+INCLUDES = -I$(top_srcdir)/kivio/kiviopart/config \
+ -I$(top_builddir)/kivio/kiviopart/config \
+ -I$(top_srcdir)/kivio/kiviopart\
+ -I$(top_srcdir)/kivio/kiviopart/kiviosdk\
+ -I$(top_srcdir)/kivio/kiviopart/tools\
+ $(KOFFICE_INCLUDES) $(KOTEXT_INCLUDES) $(all_includes)
+libkiviotexttool_la_METASOURCES = AUTO
+libkiviotexttool_la_SOURCES = \
+ plugin.cpp\
+ tool_text.cpp kivio_stenciltexteditorui.ui stenciltexteditor.cpp
+EXTRA_DIST = \
+ plugin.h\
+ plugin.cpp\
+ kiviotexttool.desktop\
+ kiviotexttool.rc\
+ tool_text.cpp\
+ tool_text.h\
+ kivio_text.xpm\
+ kivio_text_cursor.xpm\
+ Text.sml\
+ Text.xpm
+libkiviotexttool_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+libkiviotexttool_la_LIBADD =$(LIB_KOTEXT) $(LIB_KOPAINTER) $(top_builddir)/kivio/kiviopart/libkiviocommon.la
+
+rc_DATA = kiviotexttool.rc
+rcdir = $(kde_datadir)/kivio/kpartplugins
+
+desktop_DATA = kiviotexttool.desktop
+desktopdir = $(kde_servicesdir)
+
+kiviopics_DATA = kivio_text.xpm kivio_text_cursor.xpm
+kiviopicsdir = $(kde_datadir)/kivio/pics
+
+stencil_DATA = Text.sml Text.xpm
+stencildir = $(kde_datadir)/kivio/autoloadStencils
diff --git a/kivio/plugins/kiviotexttool/Text.sml b/kivio/plugins/kiviotexttool/Text.sml
new file mode 100644
index 00000000..2840bc81
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/Text.sml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<KivioShapeStencil creator="vi">
+ <KivioSMLStencilSpawnerInfo>
+ <Author data="Landshark"/>
+ <Title data="Text"/>
+ <Id data="Dave Marotti - Text"/>
+ <Description data="Text"/>
+ <Version data="0.1"/>
+ <Web data="www.thekompany.com"/>
+ <Email data="[email protected]"/>
+ <Copyright data="Copyright (C) 2000 theKompany.com &amp; Dave Marotti. All rights reserved."/>
+ <AutoUpdate data="off"/>
+ </KivioSMLStencilSpawnerInfo>
+ <Dimensions w="72.0" h="36.0"/>
+ <KivioShape type="TextBox" name="Text" x="0.0" y="0.0" w="72.0" h="36.0"/>
+</KivioShapeStencil>
diff --git a/kivio/plugins/kiviotexttool/Text.xpm b/kivio/plugins/kiviotexttool/Text.xpm
new file mode 100644
index 00000000..46f50d3c
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/Text.xpm
@@ -0,0 +1,70 @@
+/* XPM */
+static const char * Text_xpm[] = {
+"32 32 35 1",
+" c None",
+". c #F8FCF8",
+"+ c #808080",
+"@ c #C0C0C0",
+"# c #AAAAAA",
+"$ c #404040",
+"% c #6A6A6A",
+"& c #000000",
+"* c #151515",
+"= c #2A2A2A",
+"- c #555555",
+"; c #424242",
+"> c #959595",
+", c #212121",
+"' c #101010",
+") c #848484",
+"! c #A3A3A3",
+"~ c #4C4C4C",
+"{ c #878787",
+"] c #1C1C1C",
+"^ c #8E8E8E",
+"/ c #525252",
+"( c #9C9C9C",
+"_ c #2D2D2D",
+": c #B8B8B8",
+"< c #5A5A5A",
+"[ c #717171",
+"} c #B1B1B1",
+"| c #0E0E0E",
+"1 c #474747",
+"2 c #636363",
+"3 c #393939",
+"4 c #4B4B4B",
+"5 c #3B3B3B",
+"6 c #2F2F2F",
+"...............................+",
+".+++++++++++++++++++++++++++++.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@#$$$$$$$$$$$$$$$$$$%@@@@.+",
+".+@@@@+&&&*$$*&&&&=$$*&&&+@@@@.+",
+".+@@@@-&&;>>>,&&&&>>>>'&&)>!@@.+",
+".+@@@@=&~+++{&&&&]++^>/&&++#@@.+",
+".+@@@@&$(++(>&&&&=++@@@&_++:@@.+",
+".+@@@>*#^+(@%&&&&-+^@@@$<++@@@.+",
+".+@@@@@@+>@@$&&&&[+>@@@@@+>@@@.+",
+".+@@@@@}{:@@*&&&|++#@@@@@>!@@@.+",
+".+@@@@@@@@@#&&&&=++:@@@@@@@@@@.+",
+".+@@@@@@@@@+&&&&1+{@@@@@@@@@@@.+",
+".+@@@@@@@@@-&&&&2+>@@@@@@@@@@@.+",
+".+@@@@@@@@@=&&&&++!@@@@@@@@@@@.+",
+".+@@@@@@@@@&&&&]++}@@@@@@@@@@@.+",
+".+@@@@@@@@>&&&&3++@@@@@@@@@@@@.+",
+".+@@@@@@@@%&&&&-+^@@@@@@@@@@@@.+",
+".+@@@@@@@@$&&&&[+(@@@@@@@@@@@@.+",
+".+@@@@@@@@&&&&|++#@@@@@@@@@@@@.+",
+".+@@@@@@@>&&&&]++:@@@@@@@@@@@@.+",
+".+@@@@#+-*&&&&&]4#@@@@@@@@@@@@.+",
+".+@@@@+$$$$5====6>@@@@@@@@@@@@.+",
+".+@@@@@@:#({+++++^!:@@@@@@@@@@.+",
+".+@@@@@@#>>>>>>>>>>}@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+"...............................+",
+"++++++++++++++++++++++++++++++++"};
diff --git a/kivio/plugins/kiviotexttool/kivio_stenciltexteditorui.ui b/kivio/plugins/kiviotexttool/kivio_stenciltexteditorui.ui
new file mode 100644
index 00000000..8a6f9ce6
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/kivio_stenciltexteditorui.ui
@@ -0,0 +1,256 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>Kivio::StencilTextEditorUI</class>
+<comment>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.
+</comment>
+<author>Copyright (C) 2005 Peter Simonsson</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Kivio::StencilTextEditorUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>535</width>
+ <height>447</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Kivio::StencilTextEditor</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QToolButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_boldButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Bold</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>6</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>7</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>9</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>10</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>11</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>12</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>18</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>20</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>22</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>24</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>26</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>28</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>36</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>48</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>72</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_fontSizeCombo</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KFontCombo" row="0" column="0">
+ <property name="name">
+ <cstring>m_fontCombo</cstring>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="3">
+ <property name="name">
+ <cstring>m_italicsButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Italics</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="4">
+ <property name="name">
+ <cstring>m_underLineButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Underline</string>
+ </property>
+ </widget>
+ <spacer row="0" column="8">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>110</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KColorButton" row="0" column="7">
+ <property name="name">
+ <cstring>m_textColorButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="5">
+ <property name="name">
+ <cstring>m_hAlignButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="popupDelay">
+ <number>0</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Horizontal Alignment</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="6">
+ <property name="name">
+ <cstring>m_vAlignButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="popupDelay">
+ <number>0</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Vertical Alignment</string>
+ </property>
+ </widget>
+ <widget class="KTextEdit" row="1" column="0" rowspan="1" colspan="9">
+ <property name="name">
+ <cstring>m_textArea</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>m_textArea</tabstop>
+ <tabstop>m_fontCombo</tabstop>
+ <tabstop>m_fontSizeCombo</tabstop>
+ <tabstop>m_textColorButton</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kfontcombo.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>ktextedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kivio/plugins/kiviotexttool/kivio_text.xpm b/kivio/plugins/kiviotexttool/kivio_text.xpm
new file mode 100644
index 00000000..c359937e
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/kivio_text.xpm
@@ -0,0 +1,25 @@
+/* XPM */
+static const char *magick[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 3 1",
+" c Black",
+". c #808080",
+"X c None",
+/* pixels */
+"XXXXXXXXXXXXXXXX",
+"XXXXXXXXXXXXXXXX",
+"XXXXXXX XXXXXXXX",
+"XXXXXX. .XXXXXXX",
+"XXXXXX XXXXXXX",
+"XXXXX. .XXXXXX",
+"XXXXX X XXXXXX",
+"XXXX. XX .XXXXX",
+"XXXX XXXXX",
+"XXX. XXXX .XXXX",
+"XXX XXXX. XXXX",
+"XX. XXXXX. .XXX",
+"X XXX XX",
+"XXXXXXXXXXXXXXXX",
+"XXXXXXXXXXXXXXXX",
+"XXXXXXXXXXXXXXXX"
+};
diff --git a/kivio/plugins/kiviotexttool/kivio_text_cursor.xpm b/kivio/plugins/kiviotexttool/kivio_text_cursor.xpm
new file mode 100644
index 00000000..8c6e0eb5
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/kivio_text_cursor.xpm
@@ -0,0 +1,25 @@
+/* XPM */
+static const char *magick[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 3 1",
+" c Black",
+". c #808080",
+"X c None",
+/* pixels */
+"XX XXXXXXXXXXXXX",
+"XX XXXXXXXXXXXXX",
+" XX XXXXXXXX",
+"XX XXX. .XXXXXXX",
+"XX XXX XXXXXXX",
+"XXXXX. .XXXXXX",
+"XXXXX X XXXXXX",
+"XXXX. XX .XXXXX",
+"XXXX XXXXX",
+"XXX. XXXX .XXXX",
+"XXX XXXX. XXXX",
+"XX. XXXXX. .XXX",
+"X XXX XX",
+"XXXXXXXXXXXXXXXX",
+"XXXXXXXXXXXXXXXX",
+"XXXXXXXXXXXXXXXX"
+};
diff --git a/kivio/plugins/kiviotexttool/kiviotexttool.desktop b/kivio/plugins/kiviotexttool/kiviotexttool.desktop
new file mode 100644
index 00000000..85c8207f
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/kiviotexttool.desktop
@@ -0,0 +1,66 @@
+[Desktop Entry]
+X-KDE-Library=libkiviotexttool
+Name=TextTool for Kivio
+Name[af]=Teks gereedskap vir Kivio
+Name[ar]=أداة النّص لدى Kivio
+Name[az]=Kivio üçün mətn vasitəsi
+Name[bg]=Текстов инструмент за Kivio
+Name[br]=Ostilh skrid evit Kivio
+Name[bs]=Tekst alat za Kivio
+Name[ca]=Eina de text per a Kivio
+Name[cs]=Textový nástroj pro Kivio
+Name[cy]=ErfynTestun i Kivio
+Name[da]=Tekstværktøj for Kivio
+Name[de]=Text-Werkzeug für Kivio
+Name[el]=Εργαλείο κειμένου για το Kivio
+Name[eo]=Tekstilo por Kivio
+Name[es]=Herramienta de texto para Kivio
+Name[et]=Kivio teksti tööriist
+Name[eu]=Kivio-ren testu-tresna
+Name[fa]=ابزار متن برای Kivio
+Name[fi]=Tekstityökalu Kivioon
+Name[fr]=Outil texte pour Kivio
+Name[fy]=Tekstark foar Kivio
+Name[gl]=Ferramenta de Texto para Kivio
+Name[he]=כלי טקסט של Kivio
+Name[hr]=Alat teksta za Kivio
+Name[hu]=Szöveges eszköz a Kivióhoz
+Name[id]=Editor Teks buat Kivio
+Name[is]=Textatól fyrir Kivio
+Name[it]=Strumento di testo per Kivio
+Name[ja]=Kivio テキストツール
+Name[km]=ឧបករណ៍​អត្ថបទ​សម្រាប់ Kivio
+Name[lo]=ເຄື່ຶຶຶືຶອງມືຂໍ້ຄວາມສຳລັບແຜນຜັງໄດອະແກຣມ K
+Name[lt]=TextTool skirtas Kivio
+Name[lv]=Teksta rīks priekš Kivio
+Name[ms]=Alat Teks bagi Kivio
+Name[mt]=Għodda tat-Test għall-Kivio
+Name[nb]=Tekstverktøy for Kivio
+Name[nds]=Textwarktüüch för Kivio
+Name[ne]=किभियोका लागि पाठउपकरण
+Name[nl]=Tekstgereedschap voor Kivio
+Name[nn]=Tekstverktøy for Kivio
+Name[pl]=Narzędzie tekstowe dla Kivio
+Name[pt]=Ferramenta de Texto para o Kivio
+Name[pt_BR]=Ferramenta de texto para o Kivio
+Name[ro]=Unealtă text pentru Kivio
+Name[ru]=Текстовая врезка для Kivio
+Name[se]=Kivio-teakstareaidu
+Name[sk]=Textový nástroj pre Kivio
+Name[sl]=Besedilno orodje za Kivio
+Name[sr]=Текстуални алат за Kivio
+Name[sr@Latn]=Tekstualni alat za Kivio
+Name[sv]=Textverktyg för Kivio
+Name[ta]=Kivio உரைக்கருவி
+Name[tg]=Матни Асбоб барои Kivio
+Name[th]=เครื่องมือข้อความสำหรับแผนผังไดอะแกรม K
+Name[tr]=Kivio için Metin Aracı
+Name[uk]=Текстовий засіб для Kivio
+Name[uz]=Kivio uchun matn vositasi
+Name[uz@cyrillic]=Kivio учун матн воситаси
+Name[ven]=Tshishumiswa tsha manwalwa tsha Kivio
+Name[xh]=Isixhobo Sombhalo se Kivio
+Name[zh_CN]=Kivio 文字工具
+Name[zh_TW]=Kivio 文字工具
+Name[zu]=Ithuluzi lokubhaliweyo le Kivio
+Type=Service
diff --git a/kivio/plugins/kiviotexttool/kiviotexttool.rc b/kivio/plugins/kiviotexttool/kiviotexttool.rc
new file mode 100644
index 00000000..a9e6b9ab
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/kiviotexttool.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="KivioTextTool" library="libkiviotexttool" version="4">
+<MenuBar>
+ <Menu name="Tools">
+ <Action name="text"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="ToolsToolBar">
+ <Action name="text"/>
+</ToolBar>
+</kpartgui>
diff --git a/kivio/plugins/kiviotexttool/plugin.cpp b/kivio/plugins/kiviotexttool/plugin.cpp
new file mode 100644
index 00000000..456805a4
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/plugin.cpp
@@ -0,0 +1,58 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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 "plugin.h"
+#include "tool_text.h"
+
+#include "kivio_view.h"
+
+#include <kinstance.h>
+#include <kiconloader.h>
+
+/***************************************************
+ * Factory
+ ***************************************************/
+K_EXPORT_COMPONENT_FACTORY( libkiviotexttool, TextToolFactory )
+
+KInstance* TextToolFactory::s_global = 0;
+
+TextToolFactory::TextToolFactory( QObject* parent, const char* name )
+: KLibFactory( parent, name )
+{
+ s_global = new KInstance("kivio");
+}
+
+TextToolFactory::~TextToolFactory()
+{
+ delete s_global;
+}
+
+QObject* TextToolFactory::createObject( QObject* parent, const char*, const char*, const QStringList& )
+{
+ if ( !parent->inherits("KivioView") )
+ return 0;
+
+ QObject *obj = new TextTool( (KivioView*)parent );
+ return obj;
+}
+
+KInstance* TextToolFactory::global()
+{
+ return s_global;
+}
+#include "plugin.moc"
diff --git a/kivio/plugins/kiviotexttool/plugin.h b/kivio/plugins/kiviotexttool/plugin.h
new file mode 100644
index 00000000..18d4f41f
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/plugin.h
@@ -0,0 +1,44 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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.
+ */
+#ifndef TEXT_PLUGIN_H
+#define TEXT_PLUGIN_H
+
+#include <qstringlist.h>
+#include <qobject.h>
+
+#include <klibloader.h>
+
+class KInstance;
+
+class TextToolFactory : public KLibFactory
+{ Q_OBJECT
+public:
+ TextToolFactory( QObject* parent = 0, const char* name = 0 );
+ ~TextToolFactory();
+
+ virtual QObject* createObject( QObject* parent = 0, const char* name = 0,
+ const char* classname = "QObject", const QStringList &args = QStringList() );
+
+ static KInstance* global();
+
+private:
+ static KInstance* s_global;
+};
+
+#endif
diff --git a/kivio/plugins/kiviotexttool/stenciltexteditor.cpp b/kivio/plugins/kiviotexttool/stenciltexteditor.cpp
new file mode 100644
index 00000000..9cf3a7e5
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/stenciltexteditor.cpp
@@ -0,0 +1,190 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2005 Peter Simonsson <[email protected]>
+ *
+ * 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 "stenciltexteditor.h"
+
+#include <qtoolbutton.h>
+#include <qfont.h>
+#include <qcolor.h>
+#include <qpopupmenu.h>
+
+#include <kiconloader.h>
+#include <ktextedit.h>
+#include <kfontcombo.h>
+#include <kcolorbutton.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <karrowbutton.h>
+
+#include "kivio_stenciltexteditorui.h"
+
+namespace Kivio {
+
+StencilTextEditor::StencilTextEditor(const QString& caption, QWidget *parent, const char *name)
+ : KDialogBase(parent, name, true, caption, KDialogBase::Ok|KDialogBase::Cancel)
+{
+ m_hAlign = -1;
+ m_vAlign = -1;
+ m_mainWidget = new StencilTextEditorUI(this);
+ setMainWidget(m_mainWidget);
+
+ m_mainWidget->m_boldButton->setIconSet(SmallIconSet("text_bold", 16));
+ m_mainWidget->m_italicsButton->setIconSet(SmallIconSet("text_italic", 16));
+ m_mainWidget->m_underLineButton->setIconSet(SmallIconSet("text_under", 16));
+
+ QPopupMenu* menu = new QPopupMenu(m_mainWidget->m_hAlignButton, "hAlignMenu");
+ menu->setCheckable(true);
+ menu->insertItem(SmallIconSet("text_left", 16), i18n("Align Left"), Qt::AlignLeft);
+ menu->insertItem(SmallIconSet("text_center", 16), i18n("Align Center"), Qt::AlignHCenter);
+ menu->insertItem(SmallIconSet("text_right", 16), i18n("Align Right"), Qt::AlignRight);
+ m_mainWidget->m_hAlignButton->setPopup(menu);
+ connect(menu, SIGNAL(activated(int)), this, SLOT(setHorizontalAlign(int)));
+ connect(m_mainWidget->m_hAlignButton, SIGNAL(clicked()), this, SLOT(showHAlignPopup()));
+
+ menu = new QPopupMenu(m_mainWidget->m_vAlignButton, "hAlignMenu");
+ menu->setCheckable(true);
+ menu->insertItem(SmallIconSet("align_top", 16), i18n("Align Top"), Qt::AlignTop);
+ menu->insertItem(SmallIconSet("align_vcenter", 16), i18n("Align Vertical Center"), Qt::AlignVCenter);
+ menu->insertItem(SmallIconSet("align_bottom", 16), i18n("Align Bottom"), Qt::AlignBottom);
+ m_mainWidget->m_vAlignButton->setPopup(menu);
+ connect(menu, SIGNAL(activated(int)), this, SLOT(setVerticalAlign(int)));
+ connect(m_mainWidget->m_vAlignButton, SIGNAL(clicked()), this, SLOT(showVAlignPopup()));
+
+ connect(m_mainWidget->m_fontCombo, SIGNAL(activated(int)), this, SLOT(updateFormating()));
+ connect(m_mainWidget->m_fontSizeCombo, SIGNAL(activated(int)), this, SLOT(updateFormating()));
+ connect(m_mainWidget->m_boldButton, SIGNAL(clicked()), this, SLOT(updateFormating()));
+ connect(m_mainWidget->m_italicsButton, SIGNAL(clicked()), this, SLOT(updateFormating()));
+ connect(m_mainWidget->m_underLineButton, SIGNAL(clicked()), this, SLOT(updateFormating()));
+ connect(m_mainWidget->m_textColorButton, SIGNAL(clicked()), this, SLOT(updateFormating()));
+
+ m_mainWidget->m_textArea->setFocus();
+}
+
+StencilTextEditor::~StencilTextEditor()
+{
+}
+
+void StencilTextEditor::setFont(const QFont& font)
+{
+ m_mainWidget->m_textArea->setFont(font);
+ m_mainWidget->m_fontCombo->setCurrentFont(font.family());
+ m_mainWidget->m_fontSizeCombo->setCurrentText(QString::number(font.pointSize()));
+ m_mainWidget->m_boldButton->setOn(font.bold());
+ m_mainWidget->m_italicsButton->setOn(font.italic());
+ m_mainWidget->m_underLineButton->setOn(font.underline());
+}
+
+void StencilTextEditor::setFontColor(const QColor& color)
+{
+ m_mainWidget->m_textArea->setPaletteForegroundColor(color);
+ m_mainWidget->m_textColorButton->setColor(color);
+}
+
+void StencilTextEditor::setBackgroundColor(const QColor& color)
+{
+ m_mainWidget->m_textArea->setPaletteBackgroundColor(color);
+}
+
+void StencilTextEditor::setHorizontalAlign(int flag)
+{
+ if(m_hAlign >= 0) {
+ m_mainWidget->m_hAlignButton->popup()->setItemChecked(m_hAlign, false);
+ }
+
+ m_mainWidget->m_hAlignButton->popup()->setItemChecked(flag, true);
+ m_mainWidget->m_hAlignButton->setIconSet(*(m_mainWidget->m_hAlignButton->popup()->iconSet(flag)));
+ m_mainWidget->m_textArea->setAlignment(flag|verticalAlignment());
+ m_hAlign = flag;
+}
+
+void StencilTextEditor::setVerticalAlign(int flag)
+{
+ if(m_vAlign >= 0) {
+ m_mainWidget->m_vAlignButton->popup()->setItemChecked(m_vAlign, false);
+ }
+
+ m_mainWidget->m_vAlignButton->popup()->setItemChecked(flag, true);
+ m_mainWidget->m_vAlignButton->setIconSet(*(m_mainWidget->m_vAlignButton->popup()->iconSet(flag)));
+ m_mainWidget->m_textArea->setAlignment(flag|horizontalAlignment());
+ m_vAlign = flag;
+}
+
+QFont StencilTextEditor::font() const
+{
+ QFont font;
+ font.setFamily(m_mainWidget->m_fontCombo->currentFont());
+ font.setPointSize(m_mainWidget->m_fontSizeCombo->currentText().toInt());
+ font.setBold(m_mainWidget->m_boldButton->isOn());
+ font.setItalic(m_mainWidget->m_italicsButton->isOn());
+ font.setUnderline(m_mainWidget->m_underLineButton->isOn());
+
+ return font;
+}
+
+QColor StencilTextEditor::fontColor() const
+{
+ return m_mainWidget->m_textColorButton->color();
+}
+
+Qt::AlignmentFlags StencilTextEditor::horizontalAlignment() const
+{
+ return static_cast<Qt::AlignmentFlags>(m_hAlign);
+}
+
+Qt::AlignmentFlags StencilTextEditor::verticalAlignment() const
+{
+ return static_cast<Qt::AlignmentFlags>(m_vAlign);
+}
+
+void StencilTextEditor::setText(const QString& text)
+{
+ m_mainWidget->m_textArea->setText(text);
+}
+
+QString StencilTextEditor::text() const
+{
+ return m_mainWidget->m_textArea->text();
+}
+
+void StencilTextEditor::updateFormating()
+{
+ m_mainWidget->m_textArea->setFont(font());
+
+ m_mainWidget->m_textArea->setPaletteForegroundColor(fontColor());
+
+
+ m_mainWidget->m_textArea->selectAll(true);
+ m_mainWidget->m_textArea->setAlignment(horizontalAlignment()|verticalAlignment());
+ m_mainWidget->m_textArea->selectAll(false);
+
+ m_mainWidget->m_textArea->setFocus();
+}
+
+void StencilTextEditor::showHAlignPopup()
+{
+ m_mainWidget->m_hAlignButton->openPopup();
+}
+
+void StencilTextEditor::showVAlignPopup()
+{
+ m_mainWidget->m_vAlignButton->openPopup();
+}
+
+}
+
+#include "stenciltexteditor.moc"
diff --git a/kivio/plugins/kiviotexttool/stenciltexteditor.h b/kivio/plugins/kiviotexttool/stenciltexteditor.h
new file mode 100644
index 00000000..0c2a3b1a
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/stenciltexteditor.h
@@ -0,0 +1,72 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2005 Peter Simonsson <[email protected]>
+ *
+ * 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.
+ */
+#ifndef KIVIOSTENCILTEXTEDITOR_H
+#define KIVIOSTENCILTEXTEDITOR_H
+
+#include <kdialogbase.h>
+
+class QFont;
+class QColor;
+
+namespace Kivio {
+
+class StencilTextEditorUI;
+
+/**
+ * Dialog for editing stencil text
+ */
+class StencilTextEditor : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ StencilTextEditor(const QString& caption, QWidget *parent = 0, const char *name = 0);
+ ~StencilTextEditor();
+
+ void setFont(const QFont& font);
+ void setFontColor(const QColor& color);
+ void setBackgroundColor(const QColor& color);
+
+ QFont font() const;
+ QColor fontColor() const;
+ Qt::AlignmentFlags horizontalAlignment() const;
+ Qt::AlignmentFlags verticalAlignment() const;
+
+ void setText(const QString& text);
+ QString text() const;
+
+ public slots:
+ void setHorizontalAlign(int flag);
+ void setVerticalAlign(int flag);
+
+ protected slots:
+ void updateFormating();
+
+ void showHAlignPopup();
+ void showVAlignPopup();
+
+ private:
+ StencilTextEditorUI* m_mainWidget;
+
+ int m_hAlign;
+ int m_vAlign;
+};
+
+}
+
+#endif
diff --git a/kivio/plugins/kiviotexttool/tool_text.cpp b/kivio/plugins/kiviotexttool/tool_text.cpp
new file mode 100644
index 00000000..8b7e52e7
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/tool_text.cpp
@@ -0,0 +1,439 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2003 theKompany.com & Dave Marotti,
+ * Peter Simonsson
+ *
+ * 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 "tool_text.h"
+
+#include <qcursor.h>
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+#include <KoPoint.h>
+#include <klocale.h>
+#include <KoZoomHandler.h>
+#include <kinputdialog.h>
+
+#include "kivio_view.h"
+#include "kivio_canvas.h"
+#include "kivio_page.h"
+#include "kivio_doc.h"
+
+#include "kivio_stencil_spawner_set.h"
+#include "kivio_stencil_spawner.h"
+#include "kivio_custom_drag_data.h"
+#include "kivio_layer.h"
+#include "kivio_point.h"
+#include "kivio_stencil.h"
+#include "kivio_factory.h"
+#include "kivio_command.h"
+#include "kivio_pluginmanager.h"
+#include "mousetoolaction.h"
+#include "stenciltexteditor.h"
+
+
+TextTool::TextTool( KivioView* parent ) : Kivio::MouseTool(parent, "Text Mouse Tool")
+{
+ m_textAction = new Kivio::MouseToolAction( i18n("Text Tool"), "text", Key_F2, actionCollection(), "text" );
+ connect(m_textAction, SIGNAL(toggled(bool)), this, SLOT(setActivated(bool)));
+ connect(m_textAction, SIGNAL(doubleClicked()), this, SLOT(makePermanent()));
+
+ m_permanent = false;
+ m_mode = stmNone;
+
+ QPixmap pix = BarIcon("kivio_text_cursor",KivioFactory::global());
+ m_pTextCursor = new QCursor(pix,2,2);
+}
+
+TextTool::~TextTool()
+{
+ delete m_pTextCursor;
+}
+
+
+/**
+ * Event delegation
+ *
+ * @param e The event to be identified and processed
+ *
+ */
+bool TextTool::processEvent(QEvent* e)
+{
+ switch (e->type())
+ {
+ case QEvent::MouseButtonPress:
+ mousePress( (QMouseEvent*)e );
+ return true;
+ break;
+
+ case QEvent::MouseButtonRelease:
+ mouseRelease( (QMouseEvent*)e );
+ return true;
+ break;
+
+ case QEvent::MouseMove:
+ mouseMove( (QMouseEvent*)e );
+ return true;
+ break;
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+void TextTool::setActivated(bool a)
+{
+ if(a) {
+ emit activated(this);
+ m_textAction->setChecked(true);
+ view()->canvasWidget()->setCursor(*m_pTextCursor);
+ m_mode = stmNone;
+ } else {
+ m_textAction->setChecked(false);
+ m_permanent = false;
+ }
+}
+
+void TextTool::text(QRect r)
+{
+ // Calculate the start and end clicks in terms of page coordinates
+ KoPoint startPoint = view()->canvasWidget()->mapFromScreen( QPoint( r.x(), r.y() ) );
+ KoPoint releasePoint = view()->canvasWidget()->mapFromScreen( QPoint( r.x() + r.width(), r.y() + r.height() ) );
+
+ // Calculate the x,y position of the textion box
+ float x = startPoint.x() < releasePoint.x() ? startPoint.x() : releasePoint.x();
+ float y = startPoint.y() < releasePoint.y() ? startPoint.y() : releasePoint.y();
+
+ // Calculate the w/h of the textion box
+ float w = releasePoint.x() - startPoint.x();
+
+ if( w < 0.0 ) {
+ w *= -1.0;
+ }
+
+ float h = releasePoint.y() - startPoint.y();
+
+ if( h < 0.0 ) {
+ h *= -1.0;
+ }
+
+ KivioDoc* doc = view()->doc();
+ KivioPage* page = view()->activePage();
+
+ KivioStencilSpawner* ss = doc->findInternalStencilSpawner("Dave Marotti - Text");
+
+ if (!ss) {
+ return;
+ }
+
+ KivioStencil* stencil = ss->newStencil();
+ stencil->setType(kstText);
+ stencil->setPosition(x,y);
+ stencil->setDimensions(w,h);
+ stencil->setText("");
+ stencil->setTextFont(doc->defaultFont());
+ page->unselectAllStencils();
+ page->addStencil(stencil);
+ page->selectStencil(stencil);
+
+ doc->updateView(page);
+
+ applyToolAction(page->selectedStencils());
+
+ if (stencil->text().isEmpty()) {
+ page->deleteSelectedStencils();
+ doc->updateView(page);
+ }
+}
+
+void TextTool::mousePress( QMouseEvent *e )
+{
+ if(e->button() == LeftButton) {
+ KoPoint pagePoint = view()->canvasWidget()->mapFromScreen(e->pos());
+ int colType;
+ KivioPage *page = view()->activePage();
+ KivioStencil* stencil = page->checkForStencil( &pagePoint, &colType, 0.0, false);
+
+ if(stencil) {
+ applyToolAction(stencil, pagePoint);
+ } else if(startRubberBanding(e)) {
+ m_mode = stmDrawRubber;
+ }
+ }
+}
+
+
+/**
+ * Tests if we should start rubber banding (always returns true).
+ */
+bool TextTool::startRubberBanding( QMouseEvent *e )
+{
+ view()->canvasWidget()->startRectDraw( e->pos(), KivioCanvas::Rubber );
+ view()->canvasWidget()->repaint();
+ m_startPoint = e->pos();
+
+ return true;
+}
+
+void TextTool::mouseMove( QMouseEvent * e )
+{
+ switch( m_mode )
+ {
+ case stmDrawRubber:
+ continueRubberBanding(e);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void TextTool::continueRubberBanding( QMouseEvent *e )
+{
+ view()->canvasWidget()->continueRectDraw( e->pos(), KivioCanvas::Rubber );
+}
+
+void TextTool::mouseRelease( QMouseEvent *e )
+{
+ m_releasePoint = e->pos();
+
+ switch( m_mode )
+ {
+ case stmDrawRubber:
+ endRubberBanding(e);
+ break;
+ }
+
+ m_mode = stmNone;
+
+ view()->canvasWidget()->repaint();
+}
+
+void TextTool::endRubberBanding(QMouseEvent */*e*/)
+{
+ // End the rubber-band drawing
+ view()->canvasWidget()->endRectDraw();
+ QRect rect;
+
+ if( m_startPoint != m_releasePoint ) {
+ rect = view()->canvasWidget()->rect();
+ } else { // Behave a bit more sensible when clicking the canvas...
+ rect.setTopLeft(m_startPoint);
+ rect.setWidth(view()->zoomHandler()->zoomItX(100));
+ rect.setHeight(view()->zoomHandler()->zoomItY(20));
+ }
+
+ text(rect);
+
+ if(!m_permanent) {
+ view()->pluginManager()->activateDefaultTool();
+ }
+}
+
+void TextTool::applyToolAction(QPtrList<KivioStencil>* stencils)
+{
+ if(stencils->isEmpty()) {
+ return;
+ }
+
+ KivioStencil* stencil = stencils->first();
+ bool ok = false;
+
+ while(stencil) {
+ if(stencil->hasTextBox()) {
+ ok = true;
+ break;
+ }
+
+ stencil = stencils->next();
+ }
+
+ if(!ok) {
+ return;
+ }
+
+ Kivio::StencilTextEditor editor(i18n("Edit Text"), view(), "StencilTextEditor");
+ editor.setFont(stencil->textFont());
+ editor.setFontColor(stencil->textColor());
+ editor.setBackgroundColor(stencil->bgColor());
+ editor.setText(stencil->text());
+ editor.setHorizontalAlign(static_cast<Qt::AlignmentFlags>(stencil->hTextAlign()));
+ editor.setVerticalAlign(static_cast<Qt::AlignmentFlags>(stencil->vTextAlign()));
+
+ if(editor.exec() == QDialog::Accepted) {
+ KMacroCommand* macroCmd = new KMacroCommand(i18n("Change Stencil Text and Formatting"));
+ bool changed = false;
+ QString text = editor.text();
+ QFont font = editor.font();
+ QColor textColor = editor.fontColor();
+ int halignment = editor.horizontalAlignment();
+ int valignment = editor.verticalAlignment();
+ bool changeFont = (stencil->textFont() != font);
+ bool changeTextColor = (stencil->textColor() != textColor);
+ bool changeHAlignment = (stencil->hTextAlign() != halignment);
+ bool changeVAlignment = (stencil->vTextAlign() != valignment);
+
+
+ while( stencil )
+ {
+ if(stencil->text() != text)
+ {
+ KivioChangeStencilTextCommand *cmd = new KivioChangeStencilTextCommand(i18n("Change Stencil Text"),
+ stencil, stencil->text(), text, view()->activePage());
+ stencil->setText(text);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ if(changeFont && (stencil->textFont() != font)) {
+ KivioChangeStencilFontCommand* cmd = new KivioChangeStencilFontCommand(i18n("Change Stencil Font"),
+ view()->activePage(), stencil, stencil->textFont(), font);
+ stencil->setTextFont(font);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ if(changeTextColor && (stencil->textColor() != textColor)) {
+ KivioChangeStencilColorCommand* cmd = new KivioChangeStencilColorCommand(i18n("Change Stencil Text Color"),
+ view()->activePage(), stencil, stencil->textColor(), textColor, KivioChangeStencilColorCommand::CT_TEXTCOLOR);
+ stencil->setTextColor(textColor);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ if(changeHAlignment && (stencil->hTextAlign() != halignment)) {
+ KivioChangeStencilHAlignmentCommand* cmd = new KivioChangeStencilHAlignmentCommand(
+ i18n("Change Stencil Horizontal Alignment"), view()->activePage(), stencil, stencil->hTextAlign(), halignment);
+ stencil->setHTextAlign(halignment);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ if(changeVAlignment && (stencil->vTextAlign() != valignment)) {
+ KivioChangeStencilVAlignmentCommand* cmd = new KivioChangeStencilVAlignmentCommand(
+ i18n("Change Stencil Vertical Alignment"), view()->activePage(), stencil, stencil->vTextAlign(), valignment);
+ stencil->setVTextAlign(valignment);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ stencil = stencils->next();
+ }
+
+ if(changed) {
+ view()->doc()->addCommand(macroCmd);
+ view()->doc()->updateView(view()->activePage());
+ } else {
+ delete macroCmd;
+ }
+ }
+}
+
+void TextTool::applyToolAction(KivioStencil* stencil, const KoPoint& pos)
+{
+ if(!stencil) {
+ return;
+ }
+
+ QString name = stencil->getTextBoxName(pos);
+
+ if(name.isEmpty()) {
+ return;
+ }
+
+ Kivio::StencilTextEditor editor(i18n("Edit Text"), view(), "StencilTextEditor");
+ editor.setFont(stencil->textFont(name));
+ editor.setFontColor(stencil->textColor(name));
+ editor.setBackgroundColor(stencil->bgColor());
+ editor.setText(stencil->text(name));
+ editor.setHorizontalAlign(static_cast<Qt::AlignmentFlags>(stencil->hTextAlign(name)));
+ editor.setVerticalAlign(static_cast<Qt::AlignmentFlags>(stencil->vTextAlign(name)));
+
+ if(editor.exec() == QDialog::Accepted) {
+ KMacroCommand* macroCmd = new KMacroCommand(i18n("Change Stencil Text and Formatting"));
+ bool changed = false;
+ QString text = editor.text();
+
+ if(stencil->text(name) != text)
+ {
+ KivioChangeStencilTextCommand *cmd = new KivioChangeStencilTextCommand(i18n("Change Stencil Text"),
+ stencil, stencil->text(name), text, view()->activePage(), name);
+ stencil->setText(text, name);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ QFont font = editor.font();
+
+ if(stencil->textFont(name) != font) {
+ KivioChangeStencilFontCommand* cmd = new KivioChangeStencilFontCommand(i18n("Change Stencil Font"),
+ view()->activePage(), stencil, stencil->textFont(name), font, name);
+ stencil->setTextFont(name, font);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ QColor textColor = editor.fontColor();
+
+ if(stencil->textColor(name) != textColor) {
+ KivioChangeStencilColorCommand* cmd = new KivioChangeStencilColorCommand(i18n("Change Stencil Text Color"),
+ view()->activePage(), stencil, stencil->textColor(name), textColor,
+ KivioChangeStencilColorCommand::CT_TEXTCOLOR, name);
+ stencil->setTextColor(name, textColor);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ int halignment = editor.horizontalAlignment();
+
+ if(stencil->hTextAlign(name) != halignment) {
+ KivioChangeStencilHAlignmentCommand* cmd = new KivioChangeStencilHAlignmentCommand(
+ i18n("Change Stencil Horizontal Alignment"), view()->activePage(), stencil,
+ stencil->hTextAlign(name), halignment, name);
+ stencil->setHTextAlign(name, halignment);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ int valignment = editor.verticalAlignment();
+
+ if(stencil->vTextAlign(name) != valignment) {
+ KivioChangeStencilVAlignmentCommand* cmd = new KivioChangeStencilVAlignmentCommand(
+ i18n("Change Stencil Vertical Alignment"), view()->activePage(), stencil,
+ stencil->vTextAlign(name), valignment, name);
+ stencil->setVTextAlign(name, valignment);
+ macroCmd->addCommand(cmd);
+ changed = true;
+ }
+
+ if(changed) {
+ view()->doc()->addCommand(macroCmd);
+ view()->doc()->updateView(view()->activePage());
+ } else {
+ delete macroCmd;
+ }
+ }
+}
+
+void TextTool::makePermanent()
+{
+ m_permanent = true;
+}
+
+#include "tool_text.moc"
diff --git a/kivio/plugins/kiviotexttool/tool_text.h b/kivio/plugins/kiviotexttool/tool_text.h
new file mode 100644
index 00000000..f5b0bb7b
--- /dev/null
+++ b/kivio/plugins/kiviotexttool/tool_text.h
@@ -0,0 +1,88 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2003 theKompany.com & Dave Marotti,
+ * Peter Simonsson
+ *
+ * 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.
+ */
+#ifndef TOOL_TEXT_H
+#define TOOL_TEXT_H
+
+#include "kivio_mousetool.h"
+#include <koffice_export.h>
+class QMouseEvent;
+class QCursor;
+
+namespace Kivio {
+ class MouseToolAction;
+}
+
+class KivioView;
+class KivioPage;
+class KoPoint;
+
+class KIVIO_EXPORT TextTool : public Kivio::MouseTool
+{
+ Q_OBJECT
+ public:
+ TextTool( KivioView* parent );
+ ~TextTool();
+
+ virtual bool processEvent(QEvent* e);
+
+ void text(QRect);
+
+ public slots:
+ virtual void setActivated(bool a);
+ virtual void applyToolAction(QPtrList<KivioStencil>* stencils);
+ virtual void applyToolAction(KivioStencil* stencil, const KoPoint& pos);
+
+ protected slots:
+ void makePermanent();
+
+ signals:
+ void operationDone();
+
+ protected:
+ void mousePress(QMouseEvent *);
+ void mouseMove(QMouseEvent *);
+ void mouseRelease(QMouseEvent *);
+
+ bool startRubberBanding(QMouseEvent*);
+ void continueRubberBanding(QMouseEvent *);
+ void endRubberBanding(QMouseEvent *);
+
+
+
+ QPoint m_startPoint, m_releasePoint;
+
+ // Text Tool Mode
+ enum
+ {
+ stmNone,
+ stmDrawRubber
+ };
+
+ private:
+ // Flag to indicate that we are drawing a rubber band
+ int m_mode;
+ QCursor* m_pTextCursor;
+ Kivio::MouseToolAction* m_textAction;
+ bool m_permanent;
+};
+
+#endif
+
+