summaryrefslogtreecommitdiffstats
path: root/kiconedit
diff options
context:
space:
mode:
Diffstat (limited to 'kiconedit')
-rw-r--r--kiconedit/AUTHORS10
-rw-r--r--kiconedit/Makefile.am26
-rw-r--r--kiconedit/NEWS68
-rw-r--r--kiconedit/kcolorgrid.cpp335
-rw-r--r--kiconedit/kcolorgrid.h104
-rw-r--r--kiconedit/kicon.cpp279
-rw-r--r--kiconedit/kicon.h78
-rw-r--r--kiconedit/kiconcolors.cpp170
-rw-r--r--kiconedit/kiconcolors.h83
-rw-r--r--kiconedit/kiconconfig.cpp589
-rw-r--r--kiconedit/kiconconfig.h153
-rw-r--r--kiconedit/kiconedit.cpp497
-rw-r--r--kiconedit/kiconedit.desktop95
-rw-r--r--kiconedit/kiconedit.h157
-rw-r--r--kiconedit/kiconeditslots.cpp543
-rw-r--r--kiconedit/kiconeditui.rc66
-rw-r--r--kiconedit/kicongrid.cpp2263
-rw-r--r--kiconedit/kicongrid.h263
-rw-r--r--kiconedit/knew.cpp326
-rw-r--r--kiconedit/knew.h164
-rw-r--r--kiconedit/kresize.cpp83
-rw-r--r--kiconedit/kresize.h62
-rw-r--r--kiconedit/main.cpp89
-rw-r--r--kiconedit/palettetoolbar.cpp178
-rw-r--r--kiconedit/palettetoolbar.h63
-rw-r--r--kiconedit/pics/Makefile.am5
-rw-r--r--kiconedit/pics/hi16-app-kiconedit.pngbin0 -> 406 bytes
-rw-r--r--kiconedit/pics/hi22-app-kiconedit.pngbin0 -> 1101 bytes
-rw-r--r--kiconedit/pics/hi32-app-kiconedit.pngbin0 -> 853 bytes
-rw-r--r--kiconedit/pics/hi48-app-kiconedit.pngbin0 -> 1187 bytes
-rw-r--r--kiconedit/pics/icons/Makefile.am5
-rw-r--r--kiconedit/pics/icons/compressed.pngbin0 -> 530 bytes
-rw-r--r--kiconedit/pics/icons/source.pngbin0 -> 473 bytes
-rw-r--r--kiconedit/pics/icons/standard.pngbin0 -> 611 bytes
-rw-r--r--kiconedit/pics/logo.xpm137
-rw-r--r--kiconedit/pics/toolbar/Makefile.am28
-rw-r--r--kiconedit/pics/toolbar/aim-cursor.xpm28
-rw-r--r--kiconedit/pics/toolbar/aim.pngbin0 -> 303 bytes
-rw-r--r--kiconedit/pics/toolbar/airbrush-cursor.xpm35
-rw-r--r--kiconedit/pics/toolbar/areaselect.pngbin0 -> 290 bytes
-rw-r--r--kiconedit/pics/toolbar/circle.pngbin0 -> 274 bytes
-rw-r--r--kiconedit/pics/toolbar/colorpicker-cursor.xpm36
-rw-r--r--kiconedit/pics/toolbar/ellipse.pngbin0 -> 257 bytes
-rw-r--r--kiconedit/pics/toolbar/eraser-cursor.xpm32
-rw-r--r--kiconedit/pics/toolbar/fileclose.pngbin0 -> 317 bytes
-rw-r--r--kiconedit/pics/toolbar/fill-cursor.xpm36
-rw-r--r--kiconedit/pics/toolbar/filledcircle.pngbin0 -> 279 bytes
-rw-r--r--kiconedit/pics/toolbar/filledellipse.pngbin0 -> 262 bytes
-rw-r--r--kiconedit/pics/toolbar/filledrectangle.pngbin0 -> 238 bytes
-rw-r--r--kiconedit/pics/toolbar/flood-cursor.xpm32
-rw-r--r--kiconedit/pics/toolbar/flood.pngbin0 -> 440 bytes
-rw-r--r--kiconedit/pics/toolbar/grayscale.pngbin0 -> 449 bytes
-rw-r--r--kiconedit/pics/toolbar/grid.pngbin0 -> 236 bytes
-rw-r--r--kiconedit/pics/toolbar/kdepalette.pngbin0 -> 416 bytes
-rw-r--r--kiconedit/pics/toolbar/line.pngbin0 -> 222 bytes
-rw-r--r--kiconedit/pics/toolbar/paintbrush-cursor.xpm36
-rw-r--r--kiconedit/pics/toolbar/paintbrush.pngbin0 -> 374 bytes
-rw-r--r--kiconedit/pics/toolbar/pointer.pngbin0 -> 298 bytes
-rw-r--r--kiconedit/pics/toolbar/rectangle.pngbin0 -> 246 bytes
-rw-r--r--kiconedit/pics/toolbar/selectcircle.pngbin0 -> 274 bytes
-rw-r--r--kiconedit/pics/toolbar/selectrect.pngbin0 -> 243 bytes
-rw-r--r--kiconedit/pics/toolbar/spraycan-cursor.xpm30
-rw-r--r--kiconedit/pics/toolbar/spraycan.pngbin0 -> 407 bytes
-rw-r--r--kiconedit/pics/toolbar/transform.pngbin0 -> 409 bytes
-rw-r--r--kiconedit/pics/toolbar/window_new.pngbin0 -> 799 bytes
-rw-r--r--kiconedit/properties.cpp147
-rw-r--r--kiconedit/properties.h82
-rw-r--r--kiconedit/utils.cpp134
-rw-r--r--kiconedit/utils.h73
-rw-r--r--kiconedit/version.h36
70 files changed, 7656 insertions, 0 deletions
diff --git a/kiconedit/AUTHORS b/kiconedit/AUTHORS
new file mode 100644
index 00000000..dd2047ae
--- /dev/null
+++ b/kiconedit/AUTHORS
@@ -0,0 +1,10 @@
+Copyright 1998 by Thomas Tanghus <tanghus@kde.org>
+Copyright 2000 by John Califf <jcaliff@compuzone.net>
+
+Original Author:
+ Thomas Tanghus
+
+Current Maintainers:
+ John Califf <jcaliff@compuzone.net>
+ Laurent Montel <lmontel@mandrakesoft.com>
+
diff --git a/kiconedit/Makefile.am b/kiconedit/Makefile.am
new file mode 100644
index 00000000..c2536935
--- /dev/null
+++ b/kiconedit/Makefile.am
@@ -0,0 +1,26 @@
+INCLUDES = $(all_includes)
+SUBDIRS = pics
+
+bin_PROGRAMS = kiconedit
+
+kiconedit_SOURCES = utils.cpp main.cpp kiconedit.cpp kicongrid.cpp \
+ kiconcolors.cpp kcolorgrid.cpp palettetoolbar.cpp\
+ kicon.cpp kresize.cpp knew.cpp properties.cpp \
+ kiconeditslots.cpp kiconconfig.cpp
+
+kiconedit_METASOURCES = AUTO
+
+# the library search path.
+kiconedit_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kiconedit_LDADD = $(LIB_KFILE) -lkdeprint
+
+DISTCLEANFILES = *~ .deps/* .libs/*
+
+rcdir = $(kde_datadir)/kiconedit
+rc_DATA = kiconeditui.rc
+
+xdg_apps_DATA = kiconedit.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) rc.cpp $(kiconedit_SOURCES) -o $(podir)/kiconedit.pot
+
diff --git a/kiconedit/NEWS b/kiconedit/NEWS
new file mode 100644
index 00000000..ba7ef218
--- /dev/null
+++ b/kiconedit/NEWS
@@ -0,0 +1,68 @@
+KDE Icon Editor
+_______________
+
+------------------------------------------------------------------------------
+ News and fixes in version 0.4.0:
+------------------------------------------------------------------------------
+ - Enabled loading other image types than XPM.
+ - Repainting large pictures is very much faster now.
+ - Added drop site indication when using XDND.
+ - Added QWhatsThis help (this is great!).
+ - Started playing with XDND. The toolbar now has a drag source and the grid
+ supports both XDND and KDND.
+ - Added rulers (can be toggled from the configuration dialog).
+ - Circular selection.
+ - Configuration dialog:
+ - Shortcut keys.
+ - Appearance.
+ - Templates.
+ - Miscellaneous (paste mode, show rulers etc.).
+
+------------------------------------------------------------------------------
+ News and fixes in version 0.3.2:
+------------------------------------------------------------------------------
+ - German translations. (thanks to Gregor Zumstein <zumste98@cui.unige.ch>)
+ - Solaris didn't like TRANSPARENT definition. (thanks to Alastair Burt <burt@dfki.de>)
+ - Crashed on empty string in strlen. (thanks to Alastair Burt <burt@dfki.de>)
+ - Russian translations (thanks to Andy Pershin <apa@penza.com.ru>)
+
+------------------------------------------------------------------------------
+ News and fixes in version 0.3.1:
+------------------------------------------------------------------------------
+ - Icon templates installed in the wrong directory.
+ - Templates didn't load.
+
+------------------------------------------------------------------------------
+ News and fixes in version 0.3:
+------------------------------------------------------------------------------
+ - Complete rewrite of the drawing grid. Should now be faster and more flexible.
+ - New class KIcon for file manipulation.
+ - The "Line" tool can now draw 45 dgr. angles.
+ - Smooth resizing of icons if linked with QT >= 1.40.
+ - Improved loading/saving images with transparent pixels.
+ - Loading and saving should now work on non-local files.
+
+------------------------------------------------------------------------------
+ News and fixes in version 0.2:
+------------------------------------------------------------------------------
+ - Saves restore file when closed by session management or by crash.
+ - Fixed multi instance handling.
+ - Added toolbar button for creating new instances.
+ - Added danish translation.
+ - Added statusbar field for messages.
+ - Saves window size.
+ - Couldn't toggle grid from the menu.
+ - Added "Toggle toolbar", "Toggle drawing tools" and "Toggle statusbar" to the
+ "View" menu. This as well as the *Bar positions is saved between sessions.
+ - Grid state and zoom factor saved between sessions.
+ - The clipboard is checked with short intervals to check if there's a pixmap.
+ - The cursor hotspots are now correct.
+ - Cursor position is shown in the statusbar.
+ - Removed a lot of memory leaks and made the general memory footprint some smaller.
+ - New tools: "Find pixel", "Flood Fill", "Filled Circle" and "Filled Ellipse".
+ - Clipboard now supports selection of regions and inserting into existing image.
+ - Speeded up loading of pixmaps by some thousand percents ;-)
+ - Preview has scrollbars if it doesn't fit.
+
+
+
diff --git a/kiconedit/kcolorgrid.cpp b/kiconedit/kcolorgrid.cpp
new file mode 100644
index 00000000..a3793cb2
--- /dev/null
+++ b/kiconedit/kcolorgrid.cpp
@@ -0,0 +1,335 @@
+/*
+ kiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <qpainter.h>
+
+#include <kdebug.h>
+
+#include "kcolorgrid.h"
+
+void KColorArray::remove(int idx)
+{
+ int oldsize = size();
+ if(idx >= (int)size())
+ {
+ kdWarning() << "KColorArray::remove: Index " << idx << " out of range" << endl;
+ return;
+ }
+ KColorArray tmp(*this);
+ tmp.detach();
+ resize(size()-1);
+ for(int i = idx; i < oldsize-1; i++)
+ at(i) = tmp[i+1];
+ //kdDebug(4640) << "KColorArray::remove() " << at(idx) << "\t-\tsize: " << size() << endl;
+}
+
+void KColorArray::append(uint c)
+{
+ resize(size()+1);
+ at(size()-1) = c;
+ //kdDebug(4640) << "KColorArray::append() " << c << "\t-\tsize: " << size() << endl;
+}
+
+uint KColorArray::closestMatch(uint color)
+{
+ //kdDebug(4640) << "KColorArray: " << c << endl;
+ uint c = color & ~OPAQUE_MASK, d = 0xffffff, t;
+ //kdDebug(4640) << "KColorArray: " << c << endl;
+ //kdDebug(4640) << "KColorArray: " << c|OPAQUE_MASK << endl;
+ uint cb = c;
+ for(uint i = 0; i < size(); i++)
+ {
+ if (at(i) > cb)
+ t = at(i) - cb;
+ else
+ t = cb - at(i);
+ if( t < d )
+ {
+ d = t;
+ c = at(i);
+ }
+ }
+ return c|OPAQUE_MASK;
+}
+
+KColorGrid::KColorGrid(QWidget *parent, const char *name, int space)
+ : QWidget(parent, name, Qt::WResizeNoErase|Qt::WRepaintNoErase)
+{
+ //kdDebug(4640) << "KColorGrid - constructor" << endl;
+ s = space;
+ rows = cols = totalwidth = totalheight = 0;
+ setCellSize(10);
+ setGridState(Plain);
+ setGrid(true);
+ numcolors.resize(0);
+ gridcolors.resize(0);
+
+ //kdDebug(4640) << "KColorGrid - constructor - done" << endl;
+}
+/*
+void KColorGrid::show()
+{
+ //updateScrollBars();
+ QWidget::show();
+}
+*/
+void KColorGrid::paintEvent(QPaintEvent *e)
+{
+ //kdDebug(4640) << "KColorGrid::paintEvent" << endl;
+
+ //updateScrollBars();
+ //QWidget::paintEvent(e);
+
+ const QRect urect = e->rect();
+
+ //kdDebug(4640) << "Update rect = ( " << //urect.left() << ", " << urect.top() << ", " << urect.width() << ", " << urect.height() << " )" << endl;
+
+
+ int firstcol = getX(urect.x())-1;
+ int firstrow = getY(urect.y())-1;
+ int lastcol = getX(urect.right())+1;
+ int lastrow = getY(urect.bottom())+1;
+
+ QWMatrix matrix;
+ QPixmap pm(urect.width(),urect.height());
+ pm.fill(paletteBackgroundColor());
+ QPainter p;
+ p.begin( &pm );
+
+ firstrow = (firstrow < 0) ? 0 : firstrow;
+ firstcol = (firstcol < 0) ? 0 : firstcol;
+ lastrow = (lastrow >= rows) ? rows : lastrow;
+ lastcol = (lastcol >= cols) ? cols : lastcol;
+ //kdDebug(4640) << urect.x() << " x " << urect.y() << " - row: " << urect.width() << " x " << urect.height() << endl;
+ //kdDebug(4640) << "col: " << firstcol << " -> " << lastcol << " - row: " << firstrow << " -> " << lastrow << endl;
+
+/*
+ if(this->isA("KDrawGrid"))
+ kdDebug(4640) << "KDrawGrid\n firstcol: " << firstcol << "\n lastcol: " << lastcol << "\n firstrow: " << firstrow << "\n lastrow: " << lastrow << endl;
+*/
+ for(int i = firstrow; i < lastrow; i++)
+ {
+ //if(this->isA("KDrawGrid"))
+ // kdDebug(4640) << "Updating row " << i << endl;
+ for(int j = firstcol; j < lastcol; j++)
+ {
+ matrix.translate( (j*cellsize)-urect.x(), (i*cellsize)-urect.y() );
+ p.setWorldMatrix( matrix );
+ //p.setClipRect(j*cellsize, i*cellsize, cellsize, cellsize);
+ paintCell(&p, i, j);
+ //p.setClipping(FALSE);
+ matrix.reset();
+ p.setWorldMatrix( matrix );
+ }
+ //kapp->processEvents();
+ }
+
+ matrix.translate(-urect.x(),-urect.y());
+ p.setWorldMatrix( matrix );
+ paintForeground(&p,e);
+
+ p.end();
+
+ bitBlt(this,urect.topLeft(),&pm,QRect(0,0,pm.width(),pm.height()));
+
+}
+
+void KColorGrid::paintForeground(QPainter* , QPaintEvent* )
+{
+}
+
+/*
+void KColorGrid::resizeEvent(QResizeEvent *)
+{
+ //kdDebug(4640) << "resize: width: " << width() << " - total: " << totalwidth << endl;
+ //kdDebug(4640) << "resize: height: " << height() << " - total: " << totalheight << endl;
+}
+*/
+
+QSize KColorGrid::sizeHint() const
+{
+ return QSize(totalwidth, totalheight);
+}
+
+int KColorGrid::getY( int y )
+{
+ if(y > (totalheight-1))
+ y = totalheight;
+ if(cellsize == 1)
+ return y;
+ return (y/cellsize);
+}
+
+int KColorGrid::getX( int x )
+{
+ if( x > totalwidth-1)
+ x = totalwidth;
+ if(cellsize == 1)
+ return x;
+ return (x/cellsize);
+}
+
+const QRect KColorGrid::viewRect()
+{
+ //kdDebug(4640) << "viewRect" << endl;
+ const QRect r(0, 0, width(), height());
+ //kdDebug(4640) << "viewRect - " << x << " x " << y << " - " << w << " x " << h << endl;
+ return r;
+}
+
+void KColorGrid::setNumRows(int n)
+{
+ //kdDebug(4640) << "setNumRows" << endl;
+ if(n < 0 || n == rows)
+ return;
+
+ rows = n;
+
+ gridcolors.resize(n*numCols());
+ //QTableView::setNumRows(n);
+ totalheight = (n * cellsize) + 1;
+ resize(totalwidth, totalheight);
+ //kdDebug(4640) << "setNumRows() - gridcolors: " << gridcolors.size() << " size: " << numCols()*numRows() << endl;
+}
+
+void KColorGrid::setNumCols(int n)
+{
+ //kdDebug(4640) << "setNumCols" << endl;
+ if(n < 0)
+ return;
+ int on = numCols();
+ KColorArray gc(gridcolors);
+ gc.detach();
+ //kdDebug(4640) << "gc size: " << gc.size() << " numrows: " << numRows() << endl;
+ gridcolors.resize(n*numRows());
+ cols = n;
+
+ totalwidth = (n * cellsize) + 1;
+ resize(totalwidth, totalheight);
+ //kdDebug(4640) << "numRows: " << numRows() << endl;
+ //kdDebug(4640) << "gridcolor: " << gridcolors.size() << " grid: " << numRows()*numCols() << endl;
+ if(numRows() == 0)
+ return;
+
+ for(int i = 0; i < numRows(); i++)
+ {
+ for(int j = 0; j < n; j++)
+ {
+ //kdDebug(4640) << "row " << i << " , col " << j << endl;
+ if(j < on ) //If there's something to read here -- i.e. we're within the original grid
+ {
+ //kdDebug(4640) << (i*numCols())+j << " " << (i*on)+j << endl;
+ gridcolors.at((i*numCols())+j) = gc.at((i*on)+j);
+ }
+ else //Initialize to something..
+ {
+ if (gc.size()) //Have some pixels originally..
+ gridcolors.at((i*numCols())+j) = gc.at(0);
+ else
+ gridcolors.at((i*numCols())+j) = 0; //Picks something #### Update numcolors?
+ }
+ }
+ }
+
+ //kdDebug(4640) << "setNumCols() - gridcolors: " << gridcolors.size() << " size: " << numCols()*numRows() << endl;
+}
+
+void KColorGrid::fill( uint color)
+{
+ gridcolors.fill(color);
+ numcolors.resize(1);
+ numcolors.at(0) = color;
+ emit colorschanged(numcolors.size(), numcolors.data());
+}
+
+void KColorGrid::setColor( int colNum, uint col, bool update )
+{
+ //kdDebug(4640) << "KColorGrid::setColor" << endl;
+ uint oldcolor = gridcolors[colNum];
+ gridcolors[colNum] = col;
+
+ if(!update)
+ return;
+
+ //kdDebug(4640) << "KColorGrid::setColor - before adding" << endl;
+ if(!numcolors.contains(col))
+ {
+ //kdDebug(4640) << "KColorGrid::setColor() - adding " << // col << " - " << qRed(col) << " " << qGreen(col) << " " << qBlue(col) << endl;
+ numcolors.append(col);
+ //kdDebug(4640) << "KColorGrid::setColor() - adding done " << numcolors.size()-1 << endl;
+ //numcolors++;
+ emit addingcolor(col);
+ }
+
+ //kdDebug(4640) << "KColorGrid::setColor - before removing" << endl;
+ if(!gridcolors.contains(oldcolor))
+ {
+ int idx = numcolors.find(oldcolor);
+ if(idx != -1)
+ {
+ //kdDebug(4640) << "KColorGrid::setColor() - removing " << // oldcolor << " - " << qRed(oldcolor) << " " << qGreen(oldcolor) << " " << qBlue(oldcolor) << endl;
+ numcolors.remove(idx);
+ //kdDebug(4640) << "KColorGrid::setColor() - removing done" << endl;
+ emit colorschanged(numcolors.size(), numcolors.data());
+ }
+ //numcolors--;
+ }
+
+ //kdDebug(4640) << "KColorGrid::setColor - before updateCell" << endl;
+ repaint((colNum%numCols())*cellsize,(colNum/numCols())*cellsize, cellsize, cellsize);
+ //updateCell( colNum/numCols(), colNum%numCols(), false );
+ //kdDebug(4640) << "KColorGrid::setColor - after updateCell" << endl;
+}
+
+void KColorGrid::updateCell( int row, int col, bool )
+{
+ //kdDebug(4640) << "updateCell - before repaint" << endl;
+ QWMatrix matrix;
+ QPainter p;
+ p.begin( this );
+ matrix.translate( (col*cellsize), (row*cellsize) );
+ p.setWorldMatrix( matrix );
+ paintCell(&p, row, col);
+ p.end();
+
+}
+
+void KColorGrid::updateColors()
+{
+ numcolors.resize(0);
+ for(int i = 0; i < (int)gridcolors.size(); i++)
+ {
+ uint col = gridcolors.at(i);
+ if(!numcolors.contains(col))
+ numcolors.append(col);
+ }
+ emit colorschanged(numcolors.size(), numcolors.data());
+}
+
+void KColorGrid::setCellSize( int s )
+{
+ cellsize = s;
+ totalwidth = (numCols() * s) + 1;
+ totalheight = (numRows() * s) + 1;
+ resize(totalwidth, totalheight);
+ if ( isVisible() )
+ repaint(viewRect(), false);
+}
+#include "kcolorgrid.moc"
diff --git a/kiconedit/kcolorgrid.h b/kiconedit/kcolorgrid.h
new file mode 100644
index 00000000..2bb7c856
--- /dev/null
+++ b/kiconedit/kcolorgrid.h
@@ -0,0 +1,104 @@
+/*
+ kiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KCOLORGRID_H__
+#define __KCOLORGRID_H__
+
+#include <qwidget.h>
+#include <qsize.h>
+#include <qrect.h>
+
+#include "utils.h"
+
+#define KArrayUint QMemArray<uint>
+
+class KColorArray : public KArrayUint
+{
+public:
+ void remove(int idx);
+ void append(uint);
+ uint closestMatch(uint);
+};
+
+class KColorGrid : public QWidget
+{
+private:
+ Q_OBJECT
+public:
+ KColorGrid( QWidget * parent = 0, const char *name = 0, int spacing = 0);
+ virtual ~KColorGrid() {};
+
+ enum GridState { Plain, Shaded };
+
+ void setSpacing(int space) { s = space; update(); }
+ void setGridState(GridState state) { gridstate = state;}
+ GridState gridState() { return gridstate; }
+ void setGrid(bool state) { hasgrid = state; }
+ int spacing() { return s; }
+ bool hasGrid() { return hasgrid; }
+ uint numColors() { return numcolors.size(); }
+ uint colors( uint *c ) { c = numcolors.data(); return numcolors.size(); }
+ bool contains(uint c) { return numcolors.contains(c); }
+ uint colorAt(int idx) { return gridcolors.at(idx); }
+ uint *data() {return numcolors.data(); }
+ void fill(uint color);
+ int numCols() { return cols; }
+ int numRows() { return rows; }
+
+ virtual void setCellSize( int s );
+ virtual int cellSize() { return cellsize; }
+ virtual QSize sizeHint() const;
+
+ void setSize(const QSize s) { setNumRows(s.height()); setNumCols(s.width()); }
+
+public slots:
+ //virtual void show();
+
+signals:
+ void addingcolor(uint);
+ void colorschanged(uint, uint*);
+
+protected:
+ void updateCell(int row, int col, bool f);
+ virtual void paintForeground( QPainter* p, QPaintEvent* e);
+ virtual void paintCell( QPainter *p, int row, int col) = 0;
+ virtual void paintEvent(QPaintEvent *);
+ //virtual void resizeEvent(QResizeEvent *);
+ void setColor(int colNum, uint, bool update = true );
+ void updateColors();
+ virtual void setNumRows(int);
+ virtual void setNumCols(int);
+ virtual int totalWidth() { return totalwidth; }
+ virtual int totalHeight() { return totalheight; }
+ int findRow(int y) { return getY(y); }
+ int getY(int y);
+ int findCol(int x) { return getX(x); }
+ int getX(int x);
+ const QRect viewRect();
+
+//private:
+ int s, cellsize, totalwidth, totalheight;
+ int rows, cols, ypos, xpos;
+ GridState gridstate;
+ bool hasgrid;
+ KColorArray gridcolors, numcolors;
+};
+
+#endif //__KCOLORGRID_H__
diff --git a/kiconedit/kicon.cpp b/kiconedit/kicon.cpp
new file mode 100644
index 00000000..92f1bc0b
--- /dev/null
+++ b/kiconedit/kicon.cpp
@@ -0,0 +1,279 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <stdlib.h>
+
+#include <qimage.h>
+
+#include <kmessagebox.h>
+#include <kfiledialog.h>
+#include <kio/netaccess.h>
+#include <kimageio.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "kicon.h"
+#include "utils.h"
+
+KIconEditIcon::KIconEditIcon(QObject *parent, const QImage *img, KURL url)
+ : QObject(parent)
+{
+ f = 0;
+ _lastdir = "/";
+ //checkUnNamedBackup(img);
+
+ if(!url.isEmpty())
+ {
+ open(img, url);
+ }
+}
+
+
+KIconEditIcon::~KIconEditIcon()
+{
+}
+
+
+bool KIconEditIcon::open(const QImage *image, KURL url)
+{
+ QImage *img = (QImage*)image;
+
+ if(url.isEmpty())
+ return false;
+
+ kdDebug(4640) << "KIconEditIcon::open " << url.prettyURL() << endl;
+
+ if(!url.isValid()) // try to see if it is a relative filename
+ {
+ kdDebug(4640) << "KIconEditIcon::open (malformed) " << url.prettyURL() << endl;
+
+ QFileInfo fi(url.url());
+ if(fi.isRelative())
+ url = "file:" + fi.absFilePath();
+
+ if(!url.isValid()) // Giving up
+ {
+ QString msg = i18n("The URL: %1 \nseems to be malformed.\n").arg(url.url());
+ KMessageBox::sorry((QWidget*)parent(), msg);
+ return false;
+ }
+ }
+
+ QString filename;
+
+ if(url.isLocalFile())
+ {
+ filename = url.path();
+ }
+ else
+ {
+ if(!KIO::NetAccess::download( url, filename, (QWidget*)parent() ))
+ {
+ QString msg = i18n("There was an error loading:\n%1\n").arg(url.prettyURL());
+ KMessageBox::error((QWidget*)parent(), msg);
+ return false;
+ }
+ }
+
+ bool loadedOk = img->load(filename);
+
+ if(!url.isLocalFile())
+ {
+ KIO::NetAccess::removeTempFile( filename );
+ }
+
+ if(!loadedOk)
+ {
+ QString msg = i18n("There was an error loading:\n%1\n").arg(url.prettyURL());
+ KMessageBox::error((QWidget*)parent(), msg);
+ }
+ else
+ {
+ kdDebug(4640) << "KIconEditIcon::open - Image loaded" << endl;
+
+ // _url is saved off for use in saving the image to the same
+ // file later - should include full path
+ if(url.isLocalFile())
+ {
+ _url = url.path();
+ }
+ else
+ {
+ _url = "";
+ }
+
+ kdDebug(4640) << "KIcon: _url: " << _url << endl;
+
+ // this causes updates of preview, color palettes, etc.
+ emit loaded(img);
+ kdDebug(4640) << "loaded(img)" << endl;
+
+ // this is the name that shows up in status bar -
+ // should be filename with path
+ emit newname(url.prettyURL());
+ kdDebug(4640) << "newname(_url) : " << url.prettyURL() << endl;
+
+ emit addrecent(url.prettyURL());
+
+ kdDebug(4640) << "KIconEditIcon::open - done" << endl;
+ }
+
+ return loadedOk;
+}
+
+
+
+bool KIconEditIcon::promptForFile(const QImage *img)
+{
+ kdDebug(4640) << "KIconEditIcon::promptForFile(const QImage *img)" << endl;
+ /*
+ QString filter = i18n("*|All Files (*)\n"
+ "*.xpm|XPM (*.xpm)\n"
+ "*.png|PNG (*.png)\n"
+ "*.gif|GIF files (*.gif)\n"
+ "*.jpg|JPEG files (*.jpg)\n"
+ "*.ico|Icon files (*.ico)\n");
+
+
+ KURL url = KFileDialog::getOpenURL( QString::null, filter );
+ */
+ bool loaded = false;
+ KURL url = KFileDialog::getImageOpenURL( QString::null, static_cast<QWidget *>(parent()) );
+
+ if( !url.isEmpty() )
+ {
+ loaded = open( img, url );
+ }
+
+ return loaded;
+}
+
+
+
+bool KIconEditIcon::saveAs(const QImage *image)
+{
+ kdDebug(4640) << "KIconEditIcon::saveAs" << endl;
+
+ QString file;
+
+ //Get list of file types..
+ KFileDialog *dialog=new KFileDialog(QString::null, QString::null, static_cast<QWidget *>(parent()), "file dialog", true);
+ dialog->setCaption( i18n("Save Icon As") );
+ dialog->setKeepLocation( true );
+ dialog->setMimeFilter( KImageIO::mimeTypes(KImageIO::Writing), "image/png" );
+ dialog->setOperationMode( KFileDialog::Saving );
+
+ if(dialog->exec()==QDialog::Accepted)
+ {
+ file = dialog->selectedFile();
+ if( file.isNull() )
+ {
+ delete dialog;
+ return false;
+ }
+ if ( !KImageIO::canWrite(KImageIO::type(file)) )
+ {
+ if ( KImageIO::canWrite(KImageIO::typeForMime(dialog->currentFilter())) )
+ file += "."+KImageIO::suffix(KImageIO::typeForMime(dialog->currentFilter()));
+ else
+ file += ".png";
+ }
+ }
+ else
+ {
+ delete dialog;
+ return false;
+ }
+
+ delete dialog;
+
+ if(QFile::exists(file))
+ {
+ int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
+ i18n( "A file named \"%1\" already exists. "
+ "Overwrite it?" ).arg(file),
+ i18n( "Overwrite File?" ),
+ i18n( "&Overwrite" ) );
+
+ if(r==KMessageBox::Cancel)
+ {
+ return false;
+ }
+ }
+
+ return save( image, file );
+}
+
+
+
+bool KIconEditIcon::save(const QImage *image, const QString &_filename)
+{
+ kdDebug(4640) << "KIconEditIcon::save" << endl;
+ QString filename = _filename;
+
+ if(filename.isEmpty())
+ {
+ if(_url.isEmpty())
+ {
+ return saveAs(image);
+ }
+ else
+ {
+ KURL turl(_url);
+ filename = turl.path();
+ }
+ }
+
+ QImage *img = (QImage*)image;
+ img->setAlphaBuffer(true);
+
+ KURL turl(filename);
+ QString str = turl.path();
+ bool savedOk = false;
+
+ /* base image type on file extension - let kimageio
+ take care of this determination */
+
+ if(img->save(str, KImageIO::type(str).ascii()))
+ {
+ kdDebug(4640) << "img->save()) successful" << endl;
+ emit saved();
+ _url = filename;
+
+ // emit signal to change title bar to reflect new name
+ emit newname(filename);
+ kdDebug(4640) << "newname(filenamme) : " << _url << endl;
+ savedOk = true;
+ emit addrecent(filename);
+ }
+ else
+ {
+ QString msg = i18n("There was an error saving:\n%1\n").arg(str);
+ KMessageBox::error((QWidget*)parent(), msg);
+ kdDebug(4640) << "KIconEditIcon::save - " << msg << endl;
+ }
+
+ kdDebug(4640) << "KIconEditIcon::save - done" << endl;
+
+ return savedOk;
+}
+
+
+#include "kicon.moc"
diff --git a/kiconedit/kicon.h b/kiconedit/kicon.h
new file mode 100644
index 00000000..3af48c14
--- /dev/null
+++ b/kiconedit/kicon.h
@@ -0,0 +1,78 @@
+/*
+ KDE Icon Editor - a small icon drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KICON_H__
+#define __KICON_H__
+
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+#include <unistd.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(HAVE_FCNTL_H) && !defined(HAVE_FLOCK)
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_STDC_HEADERS
+#include <stdlib.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+
+class QImage;
+
+class KIconEditIcon : public QObject
+{
+ Q_OBJECT
+public:
+ KIconEditIcon(QObject*, const QImage*, KURL url = KURL() );
+ ~KIconEditIcon();
+
+ bool isLocal() { return local; }
+ QString url() { return _url; }
+ void setUrl( const QString & u ) { _url = u; };
+
+public slots:
+ bool open(const QImage*, KURL url = KURL());
+ bool promptForFile(const QImage*);
+ bool save(const QImage*, const QString &filename=QString::null);
+ bool saveAs(const QImage*);
+
+signals:
+ void newmessage( const QString &);
+ void newname(const QString &);
+ void addrecent(const QString &);
+ void opennewwin(const QString &);
+ void loaded(QImage *);
+ void saved();
+
+protected:
+ bool local;
+ QString _url;
+ QString _lastdir;
+ FILE *f;
+};
+
+#endif //__KICON_H__
diff --git a/kiconedit/kiconcolors.cpp b/kiconedit/kiconcolors.cpp
new file mode 100644
index 00000000..549f74d2
--- /dev/null
+++ b/kiconedit/kiconcolors.cpp
@@ -0,0 +1,170 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <qpainter.h>
+#include <qdrawutil.h>
+
+#include <kdebug.h>
+
+#include "kiconcolors.h"
+
+KDrawColors::KDrawColors(QWidget *parent) : KColorGrid(parent, 0, 3)
+{
+ kdDebug(4640) << "KDrawColors - constructor" << endl;
+ setCellSize(17);
+ setGrid(true);
+ setGridState(KColorGrid::Shaded);
+ selected = 0;
+ kdDebug(4640) << "KDrawColors - constructor - done" << endl;
+}
+
+void KDrawColors::paintCell( QPainter *painter, int row, int col )
+{
+ //KColorGrid::paintCell(painter, row, col);
+ uint c = colorAt( row * numCols() + col );
+ QBrush brush(c);
+ int d = spacing();
+
+ qDrawShadePanel( painter, d, d, cellSize()-d, cellSize()-d,
+ colorGroup(), true, 1, &brush);
+ if ( row * numCols() + col == selected)
+ painter->drawWinFocusRect( d+1, d+1, cellSize()-(2*d)+1, cellSize()-(2*d)+1 );
+}
+
+void KDrawColors::mouseReleaseEvent( QMouseEvent *e )
+{
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ int cell = row * numCols() + col;
+
+ if ( selected != cell )
+ {
+ int prevSel = selected;
+ selected = cell;
+ updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
+ updateCell( row, col, FALSE );
+ }
+
+ emit newColor(colorAt(cell)|OPAQUE_MASK);
+}
+
+KSysColors::KSysColors(QWidget *parent) : KDrawColors(parent)
+{
+ kdDebug(4640) << "KSysColors - constructor" << endl;
+
+ setNumRows(7);
+ setNumCols(6);
+ //fill(backgroundColor().rgb()|OPAQUE_MASK);
+ setFixedSize(numCols()*cellSize(), numRows()*cellSize());
+ fill(TRANSPARENT|OPAQUE_MASK);
+
+ int numcells = 42;
+
+ kdDebug(4640) << "KSysColors - constructor - before setColor" << endl;
+ for(int i = 0; i < numcells; i++)
+ {
+ setColor(i, iconpalette[i]|OPAQUE_MASK);
+ }
+ kdDebug(4640) << "KSysColors - constructor - done" << endl;
+}
+
+KCustomColors::KCustomColors(QWidget *parent) : KDrawColors(parent)
+{
+ kdDebug(4640) << "KCustomColors - constructor" << endl;
+ setNumRows(3);
+ setNumCols(6);
+ fill(TRANSPARENT|OPAQUE_MASK);
+ setFixedSize(numCols()*cellSize(), numRows()*cellSize());
+ freecells = new bool[numRows()*numCols()];
+ for(int i = 0; i < numRows()*numCols(); i++)
+ freecells[i] = true;
+ kdDebug(4640) << "KCustomColors - constructor - done" << endl;
+}
+
+KCustomColors::~KCustomColors()
+{
+ delete [] freecells;
+}
+
+void KCustomColors::mouseDoubleClickEvent(QMouseEvent *e)
+{
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ int cell = row * numCols() + col;
+ QColor color=colorAt(cell);
+ if(KColorDialog::getColor(color))
+ {
+ setColor(cell, color.rgb());
+ emit newColor(color.rgb()|OPAQUE_MASK);
+ freecells[cell] = false;
+ }
+}
+
+void KCustomColors::addColor(uint c)
+{
+ if(!contains(c))
+ {
+ int f = getFreeCell();
+ if(f != -1)
+ {
+ QColor color(c);
+ if(!color.isValid())
+ {
+ kdDebug(4640) << "KCustomColors::addColor: Not a valid color: " << c << endl;
+ return;
+ }
+ //kdDebug(4640) << "KCustomColors::addColor: Adding color: " << c << " - " << qRed(c) << " " << qGreen(c) << " " << qBlue(c) << endl;
+ setColor(f, c);
+ freecells[f] = false;
+ }
+ }
+}
+
+int KCustomColors::getFreeCell()
+{
+ for (int i = 0; i < numRows()*numCols(); i++)
+ {
+ if(freecells[i])
+ {
+ if(i+1 < numRows()*numCols())
+ freecells[i+1] = true;
+ else
+ freecells[0] = true;
+ return i;
+ break;
+ }
+ }
+ freeAllCells(); // start over again - not very elegant
+ return 0;
+}
+
+void KCustomColors::freeAllCells()
+{
+ for (int i = 0; i < numRows()*numCols(); i++)
+ freecells[i] = true;
+}
+
+void KCustomColors::clear()
+{
+ fill(TRANSPARENT);
+ freeAllCells();
+ update();
+}
+#include "kiconcolors.moc"
diff --git a/kiconedit/kiconcolors.h b/kiconedit/kiconcolors.h
new file mode 100644
index 00000000..a4293ff3
--- /dev/null
+++ b/kiconedit/kiconcolors.h
@@ -0,0 +1,83 @@
+/*
+ kiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KDRAWCOLORS_H__
+#define __KDRAWCOLORS_H__
+
+#include <qpopupmenu.h>
+
+#include <kcolordialog.h>
+
+#include "kcolorgrid.h"
+#include "utils.h"
+
+class KDrawColors : public KColorGrid
+{
+ Q_OBJECT
+public:
+ KDrawColors(QWidget *parent);
+
+ //bool hasColor(uint);
+
+signals:
+ void newColor(uint);
+
+protected:
+ virtual void paintCell( QPainter*, int, int );
+ virtual void mouseReleaseEvent(QMouseEvent*);
+
+ int selected;
+};
+
+class KCustomColors : public KDrawColors
+{
+ Q_OBJECT
+public:
+ KCustomColors(QWidget *parent);
+ ~KCustomColors();
+
+ void addColor(uint);
+ void clear();
+
+protected:
+ virtual void mouseDoubleClickEvent(QMouseEvent*);
+ int getFreeCell();
+ void freeAllCells();
+
+protected:
+ bool *freecells;
+ QPopupMenu *popup;
+};
+
+class KSysColors : public KDrawColors
+{
+ Q_OBJECT
+public:
+
+ KSysColors(QWidget *parent);
+
+};
+
+
+
+#endif //__KDRAWCOLORS_H__
+
+
+
diff --git a/kiconedit/kiconconfig.cpp b/kiconedit/kiconconfig.cpp
new file mode 100644
index 00000000..e7677e30
--- /dev/null
+++ b/kiconedit/kiconconfig.cpp
@@ -0,0 +1,589 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <stdlib.h>
+
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qvbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+#include <kaccel.h>
+#include <kbuttonbox.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kcolorbutton.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <kurlrequester.h>
+
+#include "kiconconfig.h"
+#include "kiconedit.h"
+
+#ifndef PICS_INCLUDED
+#define PICS_INCLUDED
+#include "pics/logo.xpm"
+#endif
+
+// little helper:
+static inline QPixmap loadIcon( const char * name )
+{
+ return KGlobal::instance()->iconLoader()
+ ->loadIcon( QString::fromLatin1(name), KIcon::NoGroup, KIcon::SizeMedium );
+}
+
+KTemplateEditDlg::KTemplateEditDlg(QWidget *parent)
+ : KDialogBase(parent, "KTemplateEditDlg", true, i18n( "Icon Template" ),
+ Ok|Cancel )
+{
+ QFrame *frame = makeMainWidget();
+ QVBoxLayout *ml = new QVBoxLayout(frame);
+ QGroupBox *grp = new QGroupBox(i18n("Template"), frame);
+ grp->setColumnLayout(0, Qt::Vertical);
+ grp->layout()->setSpacing(spacingHint());
+ grp->layout()->setMargin(marginHint());
+ QGridLayout *l = new QGridLayout(grp->layout());
+
+ ln_name = new QLineEdit( grp );
+ connect( ln_name, SIGNAL( textChanged( const QString & ) ),
+ SLOT( slotTextChanged() ) );
+ QLabel* lb_name = new QLabel( ln_name, i18n( "Description:" ), grp );
+
+ ln_path = new KURLRequester(grp);
+ connect( ln_path, SIGNAL( textChanged( const QString & ) ),
+ SLOT( slotTextChanged() ) );
+ QLabel* lb_path = new QLabel( ln_path, i18n( "Path:" ), grp );
+
+ l->addWidget(lb_name, 0, 0);
+ l->addWidget(ln_name, 0, 1);
+ l->addWidget(lb_path, 1, 0);
+ l->addWidget(ln_path, 1, 1);
+
+ ml->addWidget( grp, 1);
+
+ slotTextChanged();
+
+ setMinimumSize( 400, 150 );
+}
+
+void KTemplateEditDlg::slotTextChanged()
+{
+ QString name = ln_name->text(), path = ln_path->url();
+ enableButtonOK(name.length() && path.length());
+}
+
+void KTemplateEditDlg::setName(const QString & name)
+{
+ ln_name->setText(name);
+}
+
+QString KTemplateEditDlg::name()
+{
+ return ln_name->text();
+}
+
+void KTemplateEditDlg::setPath(const QString & path)
+{
+ ln_path->setURL(path);
+}
+
+QString KTemplateEditDlg::path()
+{
+ return ln_path->url();
+}
+
+KTemplateConfig::KTemplateConfig(QWidget *parent) : QWidget(parent)
+{
+ kdDebug(4640) << "KTemplateConfig constructor" << endl;
+
+ btadd = btremove = btedit = 0L;
+
+ QGroupBox* grp = new QGroupBox( i18n( "Templates" ), this );
+ grp->setColumnLayout( 0, Qt::Horizontal );
+
+ templates = new KIconListBox( grp );
+ connect( templates, SIGNAL( highlighted( int ) ),
+ SLOT( checkSelection( int ) ) );
+ connect( templates, SIGNAL(doubleClicked( QListBoxItem * ) ),
+ SLOT( edit() ) );
+
+ QVBoxLayout* ml = new QVBoxLayout( this );
+ ml->addWidget( grp );
+
+ QVBoxLayout* l = new QVBoxLayout( grp->layout(), KDialog::spacingHint() );
+ l->addWidget( templates );
+
+ for( unsigned int i = 0; i < KIconTemplateContainer::self()->count(); i++ )
+ templates->insertItem( new KIconListBoxItem( *KIconTemplateContainer::self()->at( i ) ) ) ;
+
+ KButtonBox *bbox = new KButtonBox( grp );
+
+ btadd = bbox->addButton( i18n( "&Add..." ) );
+ connect( btadd, SIGNAL( clicked() ), SLOT( add() ) );
+
+ btedit = bbox->addButton( i18n( "&Edit..." ) );
+ connect( btedit, SIGNAL( clicked() ), SLOT( edit() ) );
+ btedit->setEnabled( false );
+
+ btremove = bbox->addButton( i18n( "&Remove" ) );
+ connect( btremove, SIGNAL( clicked() ), SLOT( remove() ) );
+ btremove->setEnabled( false );
+
+ bbox->addStretch( 1 );
+
+ bbox->layout();
+ l->addWidget( bbox );
+}
+
+KTemplateConfig::~KTemplateConfig()
+{
+}
+
+void KTemplateConfig::saveSettings()
+{
+ kdDebug(4640) << "KTemplateConfig::saveSettings" << endl;
+
+ KIconTemplateContainer::self()->clear();
+
+ for(int i = 0; i < (int)templates->count(); i++)
+ {
+ KIconTemplateContainer::self()->append(templates->iconTemplate(i));
+ }
+ KIconTemplateContainer::self()->save();
+ kdDebug(4640) << "KTemplateConfig::saveSettings - done" << endl;
+
+}
+
+void KTemplateConfig::checkSelection(int)
+{
+ kdDebug(4640) << "KTemplateConfig::checkSelection" << endl;
+ if(templates->currentItem() != -1)
+ {
+ if(btremove) btremove->setEnabled(true);
+ if(btedit) btedit->setEnabled(true);
+ }
+ else
+ {
+ if(btremove) btremove->setEnabled(false);
+ if(btedit) btedit->setEnabled(false);
+ }
+ kdDebug(4640) << "KTemplateConfig::checkSelection - done" << endl;
+}
+
+void KTemplateConfig::remove()
+{
+ templates->removeItem(templates->currentItem());
+}
+
+void KTemplateConfig::add()
+{
+ KTemplateEditDlg dlg(this);
+ if(dlg.exec())
+ {
+ KIconTemplate it;
+ it.path = dlg.path();
+ it.title = dlg.name();
+ templates->insertItem(new KIconListBoxItem(it));
+ }
+}
+
+void KTemplateConfig::edit()
+{
+ KTemplateEditDlg dlg(this);
+ dlg.setPath(templates->path(templates->currentItem()));
+ dlg.setName(templates->text(templates->currentItem()));
+ templates->item(templates->currentItem());
+ if(dlg.exec())
+ {
+ //Edit the entry
+ KIconTemplate &it=templates->iconTemplate(templates->currentItem());
+ it.path = dlg.path();
+ it.title = dlg.name();
+ static_cast<KIconListBoxItem*>(templates->item(templates->currentItem()))->reloadIcon();
+ templates->update();
+ }
+}
+
+KBackgroundConfig::KBackgroundConfig( QWidget* parent )
+ : QWidget( parent )
+{
+ kdDebug(4640) << "KBackgroundConfig - constructor" << endl;
+
+ lb_ex = 0L;
+
+ KIconEditProperties *props = KIconEditProperties::self();
+
+ pixpath = props->bgPixmap();
+ pix.load(pixpath);
+ if(pix.isNull())
+ {
+ kdDebug(4640) << "BGPIX: " << pixpath << " not valid!" << endl;
+ QPixmap pmlogo((const char**)logo);
+ pix = pmlogo;
+ }
+
+ QVBoxLayout *mainLayout = new QVBoxLayout( this );
+
+ QGroupBox *grp1 = new QGroupBox( i18n( "Select Background" ), this );
+ grp1->setColumnLayout(0, Qt::Vertical );
+ grp1->layout()->setSpacing( KDialog::spacingHint() );
+ grp1->layout()->setMargin( KDialog::marginHint() );
+ mainLayout->addWidget( grp1 );
+
+ QGridLayout *grp1Layout = new QGridLayout( grp1->layout(), 3, 2 );
+
+ QButtonGroup* btngrp = new QButtonGroup( grp1 );
+ btngrp->setExclusive( true );
+ btngrp->setFrameStyle( QFrame::NoFrame );
+ connect( btngrp, SIGNAL( clicked( int ) ), SLOT( slotBackgroundMode( int ) ) );
+ grp1Layout->addWidget( btngrp, 0, 0 );
+
+ QVBoxLayout *bgl = new QVBoxLayout( btngrp, 5 );
+
+ QRadioButton *rbc = new QRadioButton( i18n( "Use co&lor" ), btngrp );
+ btngrp->insert( rbc, 0 );
+ bgl->addWidget( rbc );
+
+ QRadioButton *rbp = new QRadioButton( i18n( "Use pix&map" ), btngrp );
+ btngrp->insert( rbp, 1 );
+ bgl->addWidget( rbp );
+
+ bgl->addStretch( 1 );
+
+ QVBox *bbox = new QVBox( grp1 );
+ grp1Layout->addWidget( bbox, 0, 1 );
+
+ btcolor = new KColorButton(props->bgColor(), bbox) ;
+ connect(btcolor, SIGNAL(changed(const QColor &)),
+ SLOT( selectColor(const QColor &)));
+
+ btpix = new QPushButton(i18n( "Choose..." ), bbox);
+ connect( btpix, SIGNAL( clicked() ), SLOT( selectPixmap() ) );
+
+ QGroupBox *grp2 = new QGroupBox( i18n( "Preview" ), this );
+ mainLayout->addWidget( grp2, 1 );
+
+ QBoxLayout *l2 = new QVBoxLayout( grp2, 15 );
+
+ l2->addSpacing( 10 );
+
+ lb_ex = new QLabel( grp2 );
+ lb_ex->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ l2->addWidget( lb_ex );
+
+/*
+ l1->addWidget( btngrp, 0, AlignLeft );
+ l1->addLayout( l1r );
+*/
+ bgmode = props->bgMode();
+
+ if( bgmode == QWidget::FixedPixmap )
+ {
+ btngrp->setButton( 1 );
+ btcolor->setEnabled( false );
+ lb_ex->setBackgroundPixmap( pix );
+ }
+ else
+ {
+ btngrp->setButton( 0 );
+ btpix->setEnabled( false );
+ lb_ex->setBackgroundColor(btcolor->color());
+ }
+}
+
+KBackgroundConfig::~KBackgroundConfig()
+{
+}
+
+void KBackgroundConfig::slotBackgroundMode(int id)
+{
+ if(id == 0)
+ {
+ bgmode = QWidget::FixedColor;
+ btpix->setEnabled(false);
+ btcolor->setEnabled(true);
+ if(lb_ex)
+ lb_ex->setBackgroundColor(btcolor->color());
+ }
+ else
+ {
+ bgmode = QWidget::FixedPixmap;
+ btpix->setEnabled(true);
+ btcolor->setEnabled(false);
+ if(lb_ex)
+ lb_ex->setBackgroundPixmap(pix);
+ }
+}
+
+void KBackgroundConfig::saveSettings()
+{
+ kdDebug(4640) << "KBackgroundConfig::saveSettings" << endl;
+ KIconEditProperties *props = KIconEditProperties::self();
+ props->setBgMode( bgmode );
+ props->setBgPixmap( pixpath );
+ props->setBgColor( btcolor->color() );
+ kdDebug(4640) << "KBackgroundConfig::saveSettings - done" << endl;
+}
+
+void KBackgroundConfig::selectColor(const QColor & newColor)
+{
+ lb_ex->setBackgroundColor(newColor);
+}
+
+void KBackgroundConfig::selectPixmap()
+{
+ // KURL url = KFileDialog::getOpenURL("/", "*.xpm");
+ KURL url = KFileDialog::getImageOpenURL("/");
+
+ if( url.isEmpty() )
+ return;
+
+ if( !url.isLocalFile() )
+ {
+ KMessageBox::sorry( 0L, i18n( "Only local files are supported yet." ) );
+ return;
+ }
+
+ QPixmap p(url.path());
+
+ if( !p.isNull() )
+ {
+ lb_ex->setBackgroundPixmap( p );
+ pixpath = url.path();
+ }
+}
+
+KMiscConfig::KMiscConfig(QWidget *parent) : QWidget(parent)
+{
+ kdDebug(4640) << "KMiscConfig - constructor" << endl;
+
+ KIconEditProperties* props = KIconEditProperties::self();
+
+ QBoxLayout *ml = new QVBoxLayout( this, 0, 5 );
+
+ QCheckBox *cbp = new QCheckBox( i18n( "Paste &transparent pixels" ), this );
+ connect( cbp, SIGNAL( toggled( bool ) ), SLOT( pasteMode( bool ) ) );
+ ml->addWidget(cbp);
+
+ QCheckBox *cbr = new QCheckBox( i18n( "Show &rulers" ), this );
+ connect( cbr, SIGNAL( toggled( bool ) ), SLOT( showRulers( bool ) ) );
+ ml->addWidget(cbr);
+
+ QButtonGroup* btngrp = new QButtonGroup( i18n( "Transparency Display" ), this);
+ btngrp->setExclusive( true );
+ connect( btngrp, SIGNAL( clicked( int ) ), SLOT( slotTransparencyDisplayType( int ) ) );
+ ml->addWidget( btngrp );
+
+ QVBoxLayout *tgl = new QVBoxLayout( btngrp, KDialog::marginHint(), KDialog::spacingHint() );
+ tgl->insertSpacing(0, 10);
+
+ QHBoxLayout *hl = new QHBoxLayout(tgl);
+
+ QRadioButton *solidColorRButton = new QRadioButton( i18n( "&Solid color:" ), btngrp );
+ btngrp->insert( solidColorRButton, 0 );
+ hl->addWidget( solidColorRButton );
+
+ m_solidColorButton = new KColorButton(props->transparencySolidColor(), btngrp);
+ btngrp->insert( m_solidColorButton, 2 );
+ hl->addWidget(m_solidColorButton);
+ //connect(btcolor, SIGNAL(changed(const QColor &)),
+ // SLOT( selectColor(const QColor &)));
+
+ QRadioButton *checkerboardRButton = new QRadioButton( i18n( "Checker&board" ), btngrp );
+ btngrp->insert( checkerboardRButton, 1 );
+ tgl->addWidget( checkerboardRButton );
+
+ QGridLayout *grid = new QGridLayout(tgl, 3, 3);
+ grid->addColSpacing(0, 40);
+ grid->setColStretch(1, 1);
+ grid->setColStretch(2, 1);
+
+ m_checkerboardSizeCombo = new QComboBox(btngrp);
+ m_checkerboardSizeCombo->insertItem( i18n( "Small" ) );
+ m_checkerboardSizeCombo->insertItem( i18n( "Medium" ) );
+ m_checkerboardSizeCombo->insertItem( i18n( "Large" ) );
+ m_checkerboardSizeCombo->setCurrentItem(props->checkerboardSize());
+
+ QLabel *label = new QLabel(m_checkerboardSizeCombo, i18n("Si&ze:"), btngrp);
+
+ grid->addWidget(label, 0, 1);
+ grid->addWidget(m_checkerboardSizeCombo, 0, 2);
+
+ m_checkerboardColor1Button = new KColorButton(props->checkerboardColor1(), btngrp);
+ label = new QLabel(m_checkerboardColor1Button, i18n("Color &1:"), btngrp);
+
+ grid->addWidget(label, 1, 1);
+ grid->addWidget(m_checkerboardColor1Button, 1, 2);
+
+ m_checkerboardColor2Button = new KColorButton(props->checkerboardColor2(), btngrp);
+ label = new QLabel(m_checkerboardColor2Button, i18n("Color &2:"), btngrp);
+
+ grid->addWidget(label, 2, 1);
+ grid->addWidget(m_checkerboardColor2Button, 2, 2);
+
+ if(props->transparencyDisplayType() == KIconEditGrid::TRD_CHECKERBOARD)
+ {
+ checkerboardRButton->setChecked(true);
+ m_checkerboardColor1Button->setEnabled(true);
+ m_checkerboardColor2Button->setEnabled(true);
+ m_checkerboardSizeCombo->setEnabled(true);
+
+ solidColorRButton->setChecked(false);
+ m_solidColorButton->setEnabled(false);
+ }
+ else
+ {
+ checkerboardRButton->setChecked(false);
+ m_checkerboardColor1Button->setEnabled(false);
+ m_checkerboardColor2Button->setEnabled(false);
+ m_checkerboardSizeCombo->setEnabled(false);
+
+ solidColorRButton->setChecked(true);
+ m_solidColorButton->setEnabled(true);
+ }
+
+ ml->addStretch(1);
+
+ cbp->setChecked( props->pasteTransparent() );
+ cbr->setChecked( props->showRulers() );
+}
+
+KMiscConfig::~KMiscConfig()
+{
+
+}
+
+void KMiscConfig::saveSettings()
+{
+ kdDebug(4640) << "KMiscConfig::saveSettings" << endl;
+ KIconEditProperties* props = KIconEditProperties::self();
+ props->setPasteTransparent( pastemode );
+ props->setShowRulers( showrulers );
+ if(m_solidColorButton->isEnabled())
+ {
+ props->setTransparencyDisplayType(KIconEditGrid::TRD_SOLIDCOLOR);
+ props->setTransparencySolidColor(m_solidColorButton->color());
+ }
+ else
+ {
+ props->setTransparencyDisplayType(KIconEditGrid::TRD_CHECKERBOARD);
+ props->setCheckerboardColor1(m_checkerboardColor1Button->color());
+ props->setCheckerboardColor2(m_checkerboardColor2Button->color());
+ props->setCheckerboardSize((KIconEditGrid::CheckerboardSize)m_checkerboardSizeCombo->currentItem());
+ }
+}
+
+void KMiscConfig::pasteMode(bool mode)
+{
+ pastemode = mode;
+}
+
+void KMiscConfig::showRulers(bool mode)
+{
+ showrulers = mode;
+}
+
+void KMiscConfig::slotTransparencyDisplayType(int id)
+{
+ if(id == 0)
+ {
+ m_checkerboardColor1Button->setEnabled(false);
+ m_checkerboardColor2Button->setEnabled(false);
+ m_checkerboardSizeCombo->setEnabled(false);
+
+ m_solidColorButton->setEnabled(true);
+ }
+ else
+ if(id == 1)
+ {
+ m_checkerboardColor1Button->setEnabled(true);
+ m_checkerboardColor2Button->setEnabled(true);
+ m_checkerboardSizeCombo->setEnabled(true);
+
+ m_solidColorButton->setEnabled(false);
+ }
+}
+
+KIconConfig::KIconConfig(QWidget *parent)
+ : KDialogBase(KDialogBase::IconList, i18n("Configure"),
+ KDialogBase::Help |
+ KDialogBase::Ok |
+ KDialogBase::Apply |
+ KDialogBase::Cancel,
+ KDialogBase::Ok,
+ parent, "configDialog", true, true)
+{
+ setHelp(QString::null);
+ //KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+ connect(this, SIGNAL(finished()), this, SLOT(finis()));
+
+ QVBox* page = addVBoxPage(i18n("Icon Templates"), QString::null, loadIcon("icons"));
+ temps = new KTemplateConfig(page);
+
+ page = addVBoxPage(i18n("Background"), QString::null, loadIcon("background"));
+ backs = new KBackgroundConfig(page);
+
+ page = addVBoxPage(i18n("Icon Grid"), QString::null, loadIcon("kiconedit"));
+ misc = new KMiscConfig(page);
+
+ QSize min(300, 400);
+
+ if (300 < sizeHint().width()) { min.setWidth(sizeHint().width()); }
+ if (400 < sizeHint().height()) { min.setHeight(sizeHint().height()); }
+
+ resize(min);
+}
+
+KIconConfig::~KIconConfig()
+{
+ //delete dict;
+}
+
+void KIconConfig::slotApply()
+{
+ kdDebug(4640) << "KIconEditConfig::saveSettings" << endl;
+
+ temps->saveSettings();
+ backs->saveSettings();
+ misc->saveSettings();
+
+ for (KIconEdit* window = KIconEdit::windowList.first();
+ window;
+ window = KIconEdit::windowList.next())
+ {
+ window->updateProperties();
+ }
+}
+
+void KIconConfig::slotOk()
+{
+ slotApply();
+ KDialogBase::slotOk();
+}
+
+void KIconConfig::finis()
+{
+ delayedDestruct();
+}
+
+#include "kiconconfig.moc"
diff --git a/kiconedit/kiconconfig.h b/kiconedit/kiconconfig.h
new file mode 100644
index 00000000..04483732
--- /dev/null
+++ b/kiconedit/kiconconfig.h
@@ -0,0 +1,153 @@
+/*
+ KDE Icon Editor - a small icon drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KICONCONFIG_H__
+#define __KICONCONFIG_H__
+
+#include <qpixmap.h>
+#include <kdialogbase.h>
+
+#include "knew.h"
+#include "utils.h"
+#include "properties.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+class KAccel;
+class KKeyChooser;
+class KColorButton;
+class KURLRequester;
+class QComboBox;
+
+class KTemplateEditDlg : public KDialogBase
+{
+ Q_OBJECT
+public:
+ KTemplateEditDlg(QWidget *);
+ ~KTemplateEditDlg() {};
+
+ QString name();
+ QString path();
+ void setName(const QString &);
+ void setPath(const QString &);
+
+public slots:
+ void slotTextChanged();
+
+protected:
+ QLineEdit *ln_name;
+ KURLRequester *ln_path;
+};
+
+class KTemplateConfig : public QWidget
+{
+ Q_OBJECT
+public:
+ KTemplateConfig(QWidget*);
+ ~KTemplateConfig();
+
+ void saveSettings();
+
+protected slots:
+ void add();
+ void edit();
+ void remove();
+ void checkSelection(int);
+
+protected:
+ KIconListBox *templates;
+ QPushButton *btadd, *btedit, *btremove;
+};
+
+class KBackgroundConfig : public QWidget
+{
+ Q_OBJECT
+public:
+ KBackgroundConfig(QWidget *parent);
+ ~KBackgroundConfig();
+
+public slots:
+ void saveSettings();
+ void selectColor(const QColor & newColor);
+ void selectPixmap();
+
+signals:
+
+protected slots:
+ void slotBackgroundMode(int);
+
+protected:
+ KColorButton *btcolor;
+ QPushButton *btpix;
+ QPixmap pix;
+ QString pixpath;
+ QWidget::BackgroundMode bgmode;
+ QLabel *lb_ex;
+};
+
+class KMiscConfig : public QWidget
+{
+ Q_OBJECT
+public:
+ KMiscConfig(QWidget *parent);
+ ~KMiscConfig();
+
+public slots:
+ void saveSettings();
+ void pasteMode(bool);
+ void showRulers(bool);
+
+protected slots:
+ void slotTransparencyDisplayType(int);
+
+signals:
+
+protected:
+ bool pastemode, showrulers;
+ QRadioButton *rbp;
+ KColorButton *m_solidColorButton;
+ KColorButton *m_checkerboardColor1Button;
+ KColorButton *m_checkerboardColor2Button;
+ QComboBox *m_checkerboardSizeCombo;
+};
+
+class KIconConfig : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+
+ KIconConfig(QWidget *parent);
+ ~KIconConfig();
+
+protected slots:
+ void slotApply();
+ void slotOk();
+ void finis();
+
+protected:
+ KTemplateConfig *temps;
+ KBackgroundConfig *backs;
+ KMiscConfig *misc;
+};
+
+#endif //__KICONCONFIG_H__
diff --git a/kiconedit/kiconedit.cpp b/kiconedit/kiconedit.cpp
new file mode 100644
index 00000000..13cd4b89
--- /dev/null
+++ b/kiconedit/kiconedit.cpp
@@ -0,0 +1,497 @@
+/*
+ kiconedit - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <qwhatsthis.h>
+#include <qtooltip.h>
+
+#include <kpopupmenu.h>
+#include <kstdaction.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+#include "kiconedit.h"
+#include "palettetoolbar.h"
+
+WindowList KIconEdit::windowList;
+
+KIconEdit::KIconEdit(const QImage image, const char *name)
+ : KMainWindow(0, name)
+{
+ init();
+ img = image;
+ img.detach();
+ grid->load(&img);
+ grid->setModified(true);
+}
+
+KIconEdit::KIconEdit(KURL url, const char *name)
+ : KMainWindow(0, name)
+{
+ init();
+ icon->open(&img, url);
+}
+
+void KIconEdit::init()
+{
+ setMinimumSize( 600, 540 );
+
+ windowList.append(this);
+ setCaption(kapp->caption());
+
+ m_paletteToolBar = 0L;
+ statusbar = 0L;
+
+ history = new KCommandHistory( actionCollection(), true );
+
+ gridview = new KGridView(&img, history, this);
+ grid = gridview->grid();
+ icon = new KIconEditIcon(this, &grid->image());
+
+ setAcceptDrops(true);
+
+ setupActions();
+ setupStatusBar();
+ setStandardToolBarMenuEnabled( true );
+
+ createGUI();
+
+ connect(this, SIGNAL(newname(const QString &)),
+ SLOT( slotUpdateStatusName(const QString &)));
+
+ connect( icon, SIGNAL( saved()), SLOT(slotSaved()));
+ connect( icon, SIGNAL( loaded(QImage *)), grid, SLOT(load(QImage *)));
+ connect( icon, SIGNAL(opennewwin(const QString &)),
+ SLOT(slotNewWin(const QString &)));
+ connect(icon, SIGNAL(newname(const QString &)),
+ SLOT( slotUpdateStatusName(const QString &)));
+ connect(icon, SIGNAL(newmessage(const QString &)),
+ SLOT( slotUpdateStatusMessage(const QString &)));
+ connect(icon, SIGNAL(addrecent(const QString &)),
+ SLOT( addRecent(const QString &)));
+
+ connect( m_paletteToolBar, SIGNAL( newColor(uint)),
+ grid, SLOT(setColorSelection(uint)));
+
+ connect( grid, SIGNAL( changed(const QPixmap &) ),
+ m_paletteToolBar, SLOT( previewChanged(const QPixmap &) ) );
+ connect( grid, SIGNAL( addingcolor(uint) ),
+ m_paletteToolBar, SLOT(addColor(uint)));
+ connect( grid, SIGNAL( colorschanged(uint, uint*) ),
+ m_paletteToolBar, SLOT(addColors(uint, uint*)));
+
+ connect(grid, SIGNAL(sizechanged(int, int)),
+ SLOT( slotUpdateStatusSize(int, int)));
+ connect(grid, SIGNAL(poschanged(int, int)),
+ SLOT( slotUpdateStatusPos(int, int)));
+ connect(grid, SIGNAL(scalingchanged(int)),
+ SLOT( slotUpdateStatusScaling(int)));
+ connect(grid, SIGNAL(scalingchanged(int)),
+ SLOT( slotUpdateZoom(int)));
+ connect( grid, SIGNAL( addingcolor(uint) ),
+ SLOT(slotUpdateStatusColors(uint)));
+ connect(grid, SIGNAL(colorschanged(uint, uint*)),
+ SLOT( slotUpdateStatusColors(uint, uint*)));
+ connect(grid, SIGNAL(newmessage(const QString &)),
+ SLOT( slotUpdateStatusMessage(const QString &)));
+ connect(grid, SIGNAL(clipboarddata(bool)),
+ SLOT( slotUpdatePaste(bool)));
+ connect(grid, SIGNAL(colorSelected(uint)),
+ m_paletteToolBar, SLOT(currentColorChanged(uint)));
+ connect(grid, SIGNAL(modifiedchanged(bool)),
+ SLOT( slotUpdateStatusModified(bool)));
+ gridview->checkClipboard(); //Not very elegant, but fixes a buglet
+
+ connect(grid, SIGNAL(selecteddata(bool)), SLOT( slotUpdateCopy(bool)));
+
+ kdDebug(4640) << "Updating statusbar" << endl;
+ slotUpdateStatusSize(grid->cols(), grid->rows());
+ slotUpdateStatusScaling(grid->scaling());
+
+ slotUpdateZoom( grid->scaling() );
+
+ if(icon->url().length())
+ slotUpdateStatusName(icon->url());
+ else
+ slotUpdateStatusName(i18n("Untitled"));
+
+ slotUpdateCopy(false);
+
+ uint *c = 0, n = 0;
+ n = grid->getColors(c);
+ slotUpdateStatusColors(n, c);
+
+ setCentralWidget(gridview);
+
+ applyMainWindowSettings( kapp->config(), "MainWindowSettings" );
+ updateProperties();
+
+ updateAccels();
+ show();
+ moveDockWindow( m_paletteToolBar, Qt::DockRight, true, 0 );
+}
+
+KIconEdit::~KIconEdit()
+{
+ windowList.remove(this);
+
+ if (windowList.count() < 1)
+ {
+ kapp->quit();
+ }
+}
+
+bool KIconEdit::queryClose()
+{
+ bool cancel = false;
+ if (grid->isModified())
+ {
+ int r = KMessageBox::warningYesNoCancel(this,
+ i18n("The current file has been modified.\nDo you want to save it?"), QString::null, KStdGuiItem::save(), KStdGuiItem::discard());
+
+ switch(r)
+ {
+ case KMessageBox::Yes:
+ if (!icon->save(&grid->image()))
+ {
+ cancel = true;
+ }
+ break;
+ case KMessageBox::Cancel:
+ cancel = true;
+ break;
+ case KMessageBox::No:
+ default:
+ break;
+ }
+ }
+
+ if(!cancel)
+ {
+ writeConfig();
+ }
+ return (!cancel);
+}
+
+// this is for exit by request of the session manager
+void KIconEdit::saveProperties(KConfig *config )
+{
+ kdDebug(4640) << "KIconEdit::saveProperties" << endl;
+
+ config->writePathEntry("Name", icon->url());
+}
+
+// this is for instances opened by the session manager
+void KIconEdit::readProperties(KConfig *config)
+{
+ kdDebug(4640) << "KIconEdit::readProperties" << endl;
+
+ QString entry = config->readPathEntry("Name"); // no default
+ if (entry.isEmpty()) return;
+ icon->open(&grid->image(), KURL::fromPathOrURL( entry ));
+}
+
+/*
+ this is for normal exits or request from "Options->Save options".
+*/
+void KIconEdit::writeConfig()
+{
+ KConfig *config = kapp->config();
+ m_actRecent->saveEntries( kapp->config() );
+
+ KIconEditProperties::self()->save();
+
+ saveMainWindowSettings( config, "MainWindowSettings" );
+}
+
+QSize KIconEdit::sizeHint() const
+{
+ if(gridview)
+ return gridview->sizeHint();
+ else
+ return QSize(-1, -1);
+}
+
+void KIconEdit::setupActions()
+{
+ kdDebug(4640) << "setupActions" << endl;
+
+ KAction *action;
+ KRadioAction *toolAction;
+ KShortcut cut;
+
+ // File Menu
+ action = new KAction(i18n("New &Window"), "window_new", cut,
+ this, SLOT(slotNewWin()), actionCollection(), "file_new_window");
+ action->setWhatsThis(i18n("New window\n\nOpens a new icon editor window."));
+
+ action = KStdAction::openNew(this, SLOT(slotNew()), actionCollection());
+ action->setWhatsThis(i18n("New\n\nCreate a new icon, either from a"
+ " template or by specifying the size"));
+
+ action = KStdAction::open(this, SLOT(slotOpen()), actionCollection());
+ action->setWhatsThis(i18n("Open\n\nOpen an existing icon"));
+
+ m_actRecent = KStdAction::openRecent(this,
+ SLOT(slotOpenRecent(const KURL&)), actionCollection());
+ m_actRecent->setMaxItems(15); // FIXME should be configurable!
+ m_actRecent->loadEntries(kapp->config());
+
+ action = KStdAction::save(this, SLOT(slotSave()), actionCollection());
+ action->setWhatsThis(i18n("Save\n\nSave the current icon"));
+
+ KStdAction::saveAs(this, SLOT(slotSaveAs()), actionCollection());
+
+ action = KStdAction::print(this, SLOT(slotPrint()), actionCollection());
+ action->setWhatsThis(i18n("Print\n\nOpens a print dialog to let you print"
+ " the current icon."));
+
+ KStdAction::close(this, SLOT(slotClose()), actionCollection());
+
+ // Edit Menu
+
+ m_actCut = KStdAction::cut(this, SLOT(slotCut()), actionCollection());
+ m_actCut->setWhatsThis(i18n("Cut\n\nCut the current selection out of the"
+ " icon.\n\n(Tip: You can make both rectangular and circular selections)"));
+
+ m_actCopy = KStdAction::copy(this, SLOT(slotCopy()), actionCollection());
+ m_actCopy->setWhatsThis(i18n("Copy\n\nCopy the current selection out of the"
+ " icon.\n\n(Tip: You can make both rectangular and circular selections)"));
+
+ m_actPaste = KStdAction::paste(this, SLOT(slotPaste()), actionCollection());
+ m_actPaste->setWhatsThis(i18n("Paste\n\n"
+ "Paste the contents of the clipboard into the current icon.\n\n"
+ "If the contents are larger than the current icon you can paste them"
+ " in a new window.\n\n"
+ "(Tip: Select \"Paste transparent pixels\" in the configuration dialog"
+ " if you also want to paste transparency.)"));
+
+ m_actPasteNew = new KAction( i18n( "Paste as &New" ), cut, grid,
+ SLOT( editPasteAsNew() ), actionCollection(), "edit_paste_as_new" );
+
+ KStdAction::clear(this, SLOT(slotClear()), actionCollection());
+ KStdAction::selectAll(this, SLOT(slotSelectAll()), actionCollection());
+
+ action = new KAction(i18n("Resi&ze..."), "transform", cut,
+ grid, SLOT(editResize()), actionCollection(), "edit_resize");
+ action->setWhatsThis(i18n("Resize\n\nSmoothly resizes the icon while"
+ " trying to preserve the contents"));
+
+ action = new KAction(i18n("&GrayScale"), "grayscale", cut,
+ grid, SLOT(grayScale()), actionCollection(), "edit_grayscale");
+ action->setWhatsThis(i18n("Gray scale\n\nGray scale the current icon.\n"
+ "(Warning: The result is likely to contain colors not in the icon"
+ " palette"));
+
+ // View Menu
+ m_actZoomIn = KStdAction::zoomIn(this, SLOT(slotZoomIn()),
+ actionCollection());
+ m_actZoomIn->setWhatsThis(i18n("Zoom in\n\nZoom in by one."));
+
+ m_actZoomOut = KStdAction::zoomOut(this, SLOT(slotZoomOut()),
+ actionCollection());
+ m_actZoomOut->setWhatsThis(i18n("Zoom out\n\nZoom out by one."));
+
+ KActionMenu *actMenu = new KActionMenu( i18n( "&Zoom" ), "viewmag",
+ actionCollection(), "view_zoom" );
+
+ // xgettext:no-c-format
+ action = new KAction( i18n( "100%" ), cut, this, SLOT( slotZoom1() ),
+ actionCollection(), "view_zoom_1" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new KAction( i18n( "200%" ), cut, this, SLOT( slotZoom2() ),
+ actionCollection(), "view_zoom_2" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new KAction( i18n( "500%" ), cut, this, SLOT( slotZoom5() ),
+ actionCollection(), "view_zoom_5" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new KAction( i18n( "1000%" ), cut, this, SLOT( slotZoom10() ),
+ actionCollection(), "view_zoom_10" );
+ actMenu->insert( action );
+
+ // Settings Menu
+ KStdAction::keyBindings(this, SLOT(slotConfigureKeys()),
+ actionCollection());
+ KStdAction::preferences(this, SLOT(slotConfigureSettings()),
+ actionCollection());
+
+ createStandardStatusBarAction();
+
+ KToggleAction *toggle;
+
+ toggle = new KToggleAction( i18n( "Show &Grid" ), "grid",
+ cut, this, SLOT( slotShowGrid() ), actionCollection(),
+ "options_show_grid" );
+ toggle->setCheckedState(i18n("Hide &Grid"));
+ toggle->setWhatsThis( i18n( "Show grid\n\nToggles the grid in the icon"
+ " edit grid on/off" ) );
+ toggle->setChecked( KIconEditProperties::self()->showGrid() );
+
+ // Tools Menu
+ toolAction = new KRadioAction(i18n("Color Picker"), "colorpicker",
+ cut, this, SLOT(slotToolPointer()), actionCollection(),
+ "tool_find_pixel");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Color Picker\n\nThe color of the pixel clicked"
+ " on will be the current draw color"));
+
+ toolAction = new KRadioAction(i18n("Freehand"), "paintbrush",
+ cut, this, SLOT(slotToolFreehand()), actionCollection(),
+ "tool_freehand");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Free hand\n\nDraw non-linear lines"));
+
+ toolAction->setChecked( true );
+ grid->setTool(KIconEditGrid::Freehand);
+
+ toolAction = new KRadioAction(i18n("Rectangle"), "rectangle",
+ cut, this, SLOT(slotToolRectangle()), actionCollection(),
+ "tool_rectangle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Rectangle\n\nDraw a rectangle"));
+
+ toolAction = new KRadioAction(i18n("Filled Rectangle"), "filledrectangle",
+ cut, this, SLOT(slotToolFilledRectangle()), actionCollection(),
+ "tool_filled_rectangle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled rectangle\n\nDraw a filled rectangle"));
+
+ toolAction = new KRadioAction(i18n("Circle"), "circle",
+ cut, this, SLOT(slotToolCircle()), actionCollection(),
+ "tool_circle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Circle\n\nDraw a circle"));
+
+ toolAction = new KRadioAction(i18n("Filled Circle"), "filledcircle",
+ cut, this, SLOT(slotToolFilledCircle()), actionCollection(),
+ "tool_filled_circle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled circle\n\nDraw a filled circle"));
+
+ toolAction = new KRadioAction(i18n("Ellipse"), "ellipse",
+ cut, this, SLOT(slotToolEllipse()), actionCollection(),
+ "tool_ellipse");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Ellipse\n\nDraw an ellipse"));
+
+ toolAction = new KRadioAction(i18n("Filled Ellipse"), "filledellipse",
+ cut, this, SLOT(slotToolFilledEllipse()), actionCollection(),
+ "tool_filled_ellipse");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled ellipse\n\nDraw a filled ellipse"));
+
+ toolAction = new KRadioAction(i18n("Spray"), "airbrush",
+ cut, this, SLOT(slotToolSpray()), actionCollection(),
+ "tool_spray");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Spray\n\nDraw scattered pixels in the"
+ " current color"));
+
+ toolAction = new KRadioAction(i18n("Flood Fill"), "fill",
+ cut, this, SLOT(slotToolFlood()), actionCollection(),
+ "tool_flood_fill");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Flood fill\n\nFill adjoining pixels with"
+ " the same color with the current color"));
+
+ toolAction = new KRadioAction(i18n("Line"), "line",
+ cut, this, SLOT(slotToolLine()), actionCollection(),
+ "tool_line");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Line\n\nDraw a straight line vertically,"
+ " horizontally or at 45 deg. angles"));
+
+ toolAction = new KRadioAction(i18n("Eraser (Transparent)"), "eraser",
+ cut, this, SLOT(slotToolEraser()), actionCollection(),
+ "tool_eraser");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Erase\n\nErase pixels. Set the pixels to"
+ " be transparent\n\n(Tip: If you want to draw transparency with a"
+ " different tool, first click on \"Erase\" then on the tool you want"
+ " to use)"));
+
+ toolAction = new KRadioAction(i18n("Rectangular Selection"),
+ "selectrect", cut, this, SLOT(slotToolSelectRect()),
+ actionCollection(), "edit_select_rectangle");
+ toolAction->setExclusiveGroup( "toolActions" );
+ toolAction->setWhatsThis(i18n("Select\n\nSelect a rectangular section"
+ " of the icon using the mouse."));
+
+ toolAction = new KRadioAction(i18n("Circular Selection"),
+ "selectcircle", cut, this, SLOT(slotToolSelectCircle()),
+ actionCollection(), "edit_select_circle");
+ toolAction->setExclusiveGroup( "toolActions" );
+ toolAction->setWhatsThis(i18n("Select\n\nSelect a circular section of the"
+ " icon using the mouse."));
+}
+
+void KIconEdit::updateAccels()
+{
+ actionCollection()->readShortcutSettings();
+}
+
+QWidget *KIconEdit::createContainer( QWidget *parent, int index,
+ const QDomElement &element, int &id )
+{
+ if ( element.attribute( "name" ) == "paletteToolBar" )
+ {
+ m_paletteToolBar = new PaletteToolBar( this, "paletteToolBar" );
+ m_paletteToolBar->setText( i18n( "Palette Toolbar" ) );
+ return m_paletteToolBar;
+ }
+
+ return KXMLGUIBuilder::createContainer( parent, index, element, id );
+}
+
+bool KIconEdit::setupStatusBar()
+{
+ statusbar = statusBar();
+
+ QString str = i18n("Statusbar\n\nThe statusbar gives information on"
+ " the status of the current icon. The fields are:\n\n"
+ "\t- Application messages\n\t- Cursor position\n\t- Size\n\t- Zoom factor\n"
+ "\t- Number of colors");
+ QWhatsThis::add(statusBar(), str);
+
+ statusbar->insertFixedItem("99999,99999", 0, true);
+ statusbar->insertFixedItem("99999 x 99999", 1, true);
+ statusbar->insertFixedItem(" 1:999", 2, true);
+ str = i18n("Colors: %1").arg(9999999);
+ statusbar->insertFixedItem(str, 3, true);
+ statusbar->insertItem("", 4);
+
+ statusbar->changeItem( "", 0);
+ statusbar->changeItem( "", 1);
+ statusbar->changeItem( "", 2);
+ statusbar->changeItem( "", 3);
+
+ return true;
+}
+
+void KIconEdit::addRecent(const QString & path)
+{
+ m_actRecent->addURL(KURL( path ));
+}
+
+#include "kiconedit.moc"
diff --git a/kiconedit/kiconedit.desktop b/kiconedit/kiconedit.desktop
new file mode 100644
index 00000000..be70ac9f
--- /dev/null
+++ b/kiconedit/kiconedit.desktop
@@ -0,0 +1,95 @@
+[Desktop Entry]
+GenericName=Icon Editor
+GenericName[af]=Ikoon Redigeerder
+GenericName[ar]=محرر الإيقونات
+GenericName[bg]=Редактор на икони
+GenericName[br]=Aozer arlunioù
+GenericName[bs]=Editor ikona
+GenericName[ca]=Editor d'icones
+GenericName[cs]=Editor ikon
+GenericName[cy]=Golygydd Eiconau
+GenericName[da]=Ikoneditor
+GenericName[de]=Editor für Arbeitsflächensymbole
+GenericName[el]=Επεξεργαστής εικονιδίων
+GenericName[eo]=Ilo por pentri kaj redakti piktogramojn
+GenericName[es]=Editor de iconos
+GenericName[et]=Ikoonide redaktor
+GenericName[eu]=Ikono editorea
+GenericName[fa]=ویرایشگر شمایل
+GenericName[fi]=Kuvakemuokkain
+GenericName[fr]=Éditeur d'icônes
+GenericName[ga]=Eagarthóir Deilbhíní
+GenericName[gl]=Editor de iconas
+GenericName[he]=עורך סמלים
+GenericName[hi]=प्रतीक (आइकॉन) संपादक
+GenericName[hr]=Uređivač ikona
+GenericName[hu]=Ikonszerkesztő
+GenericName[is]=Táknmyndaritill
+GenericName[it]=Editor di icone
+GenericName[ja]=アイコンエディタ
+GenericName[kk]=Таңбаша өңдегіші
+GenericName[km]=កម្មវិធី​និពន្ធ​រូបតំណាង
+GenericName[lt]=Ženkliukų redaktorius
+GenericName[lv]=Ikonu Redaktors
+GenericName[ms]=Editor Ikon
+GenericName[nb]=Ikonredigerer
+GenericName[nds]=Lüttbildeditor
+GenericName[ne]=प्रतिमा सम्पादक
+GenericName[nl]=Pictogrambewerker
+GenericName[nn]=Ikonredigering
+GenericName[nso]=Mofetosi wa Seemedi
+GenericName[pa]=ਆਈਕਾਨ ਸੰਪਾਦਕ
+GenericName[pl]=Edytor ikon
+GenericName[pt]=Editor de Ícones
+GenericName[pt_BR]=Editor de Ícones
+GenericName[ro]=Editor de iconiţe
+GenericName[ru]=Редактор пиктограмм
+GenericName[se]=Govašdoaimmaheaddji
+GenericName[sk]=Editor ikon
+GenericName[sl]=Urejevalnik ikon
+GenericName[sr]=Уређивач икона
+GenericName[sr@Latn]=Uređivač ikona
+GenericName[sv]=Ikoneditor
+GenericName[ta]= கேசின்னம் திருத்தி
+GenericName[tg]=Муҳаррири ишорот
+GenericName[th]=เครื่องมือแก้ไขไอคอน
+GenericName[tr]=Simge Düzenleyici
+GenericName[uk]=Редактор піктограм
+GenericName[uz]=Nishoncha tahrirchi
+GenericName[uz@cyrillic]=Нишонча таҳрирчи
+GenericName[ven]=Musengulusi wa Aikhono
+GenericName[wa]=Aspougneu d' imådjetes
+GenericName[xh]=Umhleli we Icon
+GenericName[zh_CN]=图标编辑器
+GenericName[zh_HK]=圖示編輯器
+GenericName[zh_TW]=圖示編輯器
+GenericName[zu]=Umhleli we Icon
+Name=KIconEdit
+Name[af]=K-ikoon-redigeer
+Name[ar]=برنامج KIconEdit
+Name[cy]=KGolyguEicon
+Name[eo]=Piktogramredaktilo
+Name[hi]=के-आइकॉन-एडिट
+Name[hr]=Uređivač ikona
+Name[is]=Táknmyndaritill
+Name[lv]=KIkonuRedaktors
+Name[ms]=KIkonEdit
+Name[ne]=केडीई प्रतिमा सम्पादन
+Name[pl]=Edytor ikon
+Name[pt_BR]=KEditor de Ícones
+Name[ro]=Editor iconiţe
+Name[sv]=Kiconedit
+Name[ta]=கேசின்னம் திருத்து
+Name[tr]=K Icon Düzenleyici
+Name[ven]=U sengulusa ha aikhono ya K
+Name[zh_TW]=KIconEdit 圖示編輯器
+MimeType=image/x-xpm;image/x-ico;image/png;image/jpeg;
+Exec=kiconedit -caption "%c" %i %m %u
+Icon=kiconedit
+Path=
+DocPath=kiconedit/index.html
+Type=Application
+Terminal=false
+
+X-DCOP-ServiceType=Multi
+Categories=Qt;KDE;Graphics;X-KDE-More;
diff --git a/kiconedit/kiconedit.h b/kiconedit/kiconedit.h
new file mode 100644
index 00000000..54227206
--- /dev/null
+++ b/kiconedit/kiconedit.h
@@ -0,0 +1,157 @@
+/*
+ kiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KICONEDIT_H__
+#define __KICONEDIT_H__
+
+#include <qwidget.h>
+#include <qpixmap.h>
+#include <qptrlist.h>
+
+#include <kmainwindow.h>
+#include <kiconloader.h>
+#include <kmenubar.h>
+#include <kstatusbar.h>
+#include <ktoolbar.h>
+#include <kaccel.h>
+#include <kurl.h>
+#include <kaction.h>
+
+#include "knew.h"
+#include "kicon.h"
+#include "kiconconfig.h"
+#include "kicongrid.h"
+#include "kresize.h"
+#include "properties.h"
+
+class KIconEdit;
+class KCommandHistory;
+typedef QPtrList<KIconEdit> WindowList;
+
+class QWhatsThis;
+class QToolButton;
+class QLabel;
+class PaletteToolBar;
+
+/**
+* KIconEdit
+* @short KIconEdit
+* @author Thomas Tanghus <tanghus@kde.org>
+* @version 0.4
+*/
+class KIconEdit : public KMainWindow
+{
+ Q_OBJECT
+public:
+ KIconEdit( KURL url = KURL(), const char *name = "kiconedit");
+ KIconEdit( const QImage image, const char *name = "kiconedit");
+ ~KIconEdit();
+
+ virtual QSize sizeHint() const;
+ static WindowList windowList;
+
+signals:
+ void newname(const QString &);
+
+public slots:
+ virtual void saveProperties(KConfig*);
+ virtual void readProperties(KConfig*);
+ void updateProperties();
+
+protected slots:
+ void slotNewWin(const QString & url = 0);
+ void slotNew();
+ void slotOpen();
+ void slotClose();
+ void slotSave();
+ void slotSaveAs();
+ void slotPrint();
+ void slotZoomIn();
+ void slotZoomOut();
+ void slotZoom1();
+ void slotZoom2();
+ void slotZoom5();
+ void slotZoom10();
+ void slotCopy();
+ void slotCut();
+ void slotPaste();
+ void slotClear();
+ void slotSaved();
+ void slotSelectAll();
+ void slotOpenRecent(const KURL&);
+ void slotToolPointer();
+ void slotToolFreehand();
+ void slotToolRectangle();
+ void slotToolFilledRectangle();
+ void slotToolCircle();
+ void slotToolFilledCircle();
+ void slotToolEllipse();
+ void slotToolFilledEllipse();
+ void slotToolSpray();
+ void slotToolFlood();
+ void slotToolLine();
+ void slotToolEraser();
+ void slotToolSelectRect();
+ void slotToolSelectCircle();
+ void slotConfigureSettings();
+ void slotConfigureKeys();
+ void slotShowGrid();
+ void slotUpdateZoom( int );
+ void slotUpdateStatusColors(uint);
+ void slotUpdateStatusColors(uint, uint*);
+ void slotUpdateStatusPos(int, int);
+ void slotUpdateStatusSize(int, int);
+ void slotUpdateStatusMessage(const QString &);
+ void slotUpdateStatusName(const QString &);
+ void slotUpdateStatusModified(bool);
+ void slotUpdateStatusScaling(int);
+ void slotUpdatePaste(bool);
+ void slotUpdateCopy(bool);
+ void slotOpenBlank(const QSize);
+ void addRecent(const QString &);
+
+ virtual void dragEnterEvent(QDragEnterEvent* event);
+ virtual void dropEvent(QDropEvent *e);
+
+protected:
+ void init();
+ void setupActions();
+ bool setupStatusBar();
+ void writeConfig();
+ void updateAccels();
+
+ virtual bool queryClose();
+ virtual QWidget *createContainer( QWidget*, int, const QDomElement&, int& );
+
+ KCommandHistory* history;
+ PaletteToolBar *m_paletteToolBar;
+ KStatusBar *statusbar;
+ KIconEditGrid *grid;
+ KGridView *gridview;
+ KIconEditIcon *icon;
+ QImage img;
+ QString m_name;
+
+ KAction *m_actCopy, *m_actPaste, *m_actCut, *m_actPasteNew;
+ KAction *m_actZoomIn, *m_actZoomOut;
+ KRecentFilesAction *m_actRecent;
+};
+
+#endif //__KICONEDIT_H__
diff --git a/kiconedit/kiconeditslots.cpp b/kiconedit/kiconeditslots.cpp
new file mode 100644
index 00000000..0d57d28e
--- /dev/null
+++ b/kiconedit/kiconeditslots.cpp
@@ -0,0 +1,543 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <qpaintdevicemetrics.h>
+#include <qpainter.h>
+
+#include <kkeydialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <kprinter.h>
+#include <kurldrag.h>
+
+#include "kiconedit.h"
+#include "kiconcolors.h"
+#include "palettetoolbar.h"
+
+#ifndef PICS_INCLUDED
+#define PICS_INCLUDED
+#include "pics/logo.xpm"
+#endif
+
+void KIconEdit::updateProperties()
+{
+ KIconEditProperties *props = KIconEditProperties::self();
+ gridview->setShowRulers(props->showRulers());
+ if(props->bgMode() == QWidget::FixedPixmap)
+ {
+ QPixmap pix(props->bgPixmap());
+ if(pix.isNull())
+ {
+ QPixmap pmlogo((const char**)logo);
+ pix = pmlogo;
+ }
+ gridview->viewPortWidget()->viewport()->setBackgroundPixmap(pix);
+ m_paletteToolBar->setPreviewBackground(pix);
+ }
+ else
+ {
+ gridview->viewPortWidget()->viewport()
+ ->setBackgroundColor(props->bgColor());
+ m_paletteToolBar->setPreviewBackground(props->bgColor());
+ }
+ grid->setTransparencyDisplayType(props->transparencyDisplayType());
+ grid->setTransparencySolidColor(props->transparencySolidColor());
+ grid->setCheckerboardColor1(props->checkerboardColor1());
+ grid->setCheckerboardColor2(props->checkerboardColor2());
+ grid->setCheckerboardSize(props->checkerboardSize());
+ grid->update();
+}
+
+void KIconEdit::slotNewWin(const QString & url)
+{
+ //kdDebug(4640) << "KIconEdit::openNewWin() - " << url << endl;
+
+ KIconEdit *w = new KIconEdit(KURL(url), "kiconedit");
+ Q_CHECK_PTR(w);
+}
+
+
+void KIconEdit::slotNew()
+{
+ bool cancel = false;
+ if (grid->isModified())
+ {
+ int r = KMessageBox::warningYesNoCancel(this,
+ i18n("The current file has been modified.\nDo you want to save it?"), QString::null, KStdGuiItem::save(), KStdGuiItem::discard());
+
+ switch(r)
+ {
+ case KMessageBox::Yes:
+ if(!icon->save(&grid->image()))
+ {
+ cancel = true;
+ }
+ break;
+
+ case KMessageBox::No:
+ break;
+
+ case KMessageBox::Cancel:
+ cancel = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ if(!cancel)
+ {
+ KNewIcon newicon(this);
+ if(newicon.exec())
+ {
+ int r = newicon.openStyle();
+ if(r == KNewIcon::Blank)
+ {
+ grid->editClear();
+ const QSize s = newicon.templateSize();
+ //kdDebug(4640) << "Size: " << s.width() << " x " << s.height() << endl;
+ grid->setSize(s);
+ grid->setModified(false);
+ }
+ else if(r == KNewIcon::Template)
+ {
+ QString str = newicon.templatePath();
+ icon->open(&grid->image(), KURL( str ));
+ }
+ icon->setUrl("");
+ emit newname(i18n("Untitled"));
+ }
+ }
+}
+
+
+void KIconEdit::slotOpen()
+{
+ bool cancel = false;
+
+ if( grid->isModified() )
+ {
+ int r = KMessageBox::warningYesNoCancel(this,
+ i18n("The current file has been modified.\nDo you want to save it?"),QString::null, KStdGuiItem::save(), KStdGuiItem::discard());
+
+ switch( r )
+ {
+ case KMessageBox::Yes:
+ if(!icon->save( &grid->image() ))
+ {
+ cancel = true;
+ }
+ break;
+
+ case KMessageBox::No:
+ break;
+
+ case KMessageBox::Cancel:
+ cancel = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( !cancel )
+ {
+ if (icon->promptForFile( &grid->image() ))
+ {
+ grid->setModified(false);
+ }
+ }
+}
+
+/*
+ close only the current window
+*/
+void KIconEdit::slotClose()
+{
+ //kdDebug(4640) << "KIconEdit: Closing " << endl;
+ close();
+}
+
+void KIconEdit::slotSave()
+{
+ //kdDebug(4640) << "KIconEdit: slotSave() " << endl;
+ icon->save(&grid->image());
+}
+
+
+void KIconEdit::slotSaveAs()
+{
+ //kdDebug(4640) << "KIconEdit: slotSaveAs() " << endl;
+ icon->saveAs(&grid->image());
+}
+
+
+void KIconEdit::slotPrint()
+{
+ KPrinter printer;
+
+ if ( printer.setup(this, i18n("Print %1").arg(icon->url().section('/', -1))) )
+ {
+ int margin = 10, yPos = 0;
+ printer.setCreator("KDE Icon Editor");
+
+ QPainter p;
+ p.begin( &printer );
+ QFontMetrics fm = p.fontMetrics();
+ // need width/height
+ QPaintDeviceMetrics metrics( &printer );
+
+ p.drawText( margin, margin + yPos, metrics.width(), fm.lineSpacing(),
+ ExpandTabs | DontClip, icon->url() );
+ yPos = yPos + fm.lineSpacing();
+ p.drawPixmap( margin, margin + yPos, grid->pixmap() );
+ p.end();
+ }
+}
+
+void KIconEdit::slotZoomIn()
+{
+ grid->zoom(DirIn);
+}
+
+void KIconEdit::slotZoomOut()
+{
+ grid->zoom(DirOut);
+}
+
+void KIconEdit::slotZoom1()
+{
+ grid->zoomTo(1);
+}
+
+void KIconEdit::slotZoom2()
+{
+ grid->zoomTo(2);
+}
+
+void KIconEdit::slotZoom5()
+{
+ grid->zoomTo(5);
+}
+
+void KIconEdit::slotZoom10()
+{
+ grid->zoomTo(10);
+}
+
+void KIconEdit::slotCopy()
+{
+ grid->editCopy();
+}
+
+void KIconEdit::slotCut()
+{
+ grid->editCopy(true);
+}
+
+void KIconEdit::slotPaste()
+{
+ static_cast<KRadioAction*>(actionCollection()
+ ->action("tool_find_pixel"))->setChecked(true);
+ grid->setTool(KIconEditGrid::Find);
+ grid->editPaste();
+}
+
+void KIconEdit::slotClear()
+{
+ grid->editClear();
+}
+
+void KIconEdit::slotSelectAll()
+{
+ grid->setTool(KIconEditGrid::SelectRect);
+ grid->editSelectAll();
+}
+
+void KIconEdit::slotOpenRecent(const KURL& iconFile)
+{
+ bool cancel = false;
+
+ if( grid->isModified() )
+ {
+ int r = KMessageBox::warningYesNoCancel(this,
+ i18n("The current file has been modified.\nDo you want to save it?"),QString::null, KStdGuiItem::save(), KStdGuiItem::discard());
+
+ switch( r )
+ {
+ case KMessageBox::Yes:
+ if (!icon->save( &grid->image() ))
+ {
+ cancel = true;
+ }
+ break;
+
+ case KMessageBox::No:
+ break;
+
+ case KMessageBox::Cancel:
+ cancel = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( !cancel )
+ {
+ if(icon->open(&grid->image(), iconFile))
+ {
+ grid->setModified(false);
+ }
+ }
+}
+
+void KIconEdit::slotConfigureSettings()
+{
+ KIconConfig* c = new KIconConfig(this);
+ c->exec();
+ delete c;
+}
+
+void KIconEdit::slotConfigureKeys()
+{
+ KKeyDialog::configure(actionCollection());
+
+ KIconEdit *ki = 0L;
+ for (ki = windowList.first(); ki; ki = windowList.next())
+ {
+ if (ki != this)
+ {
+ ki->updateAccels();
+ }
+ }
+}
+
+void KIconEdit::slotShowGrid()
+{
+ bool b = KIconEditProperties::self()->showGrid();
+ grid->setGrid( !b );
+ KIconEditProperties::self()->setShowGrid( !b );
+}
+
+void KIconEdit::slotToolPointer()
+{
+ grid->setTool(KIconEditGrid::Find);
+}
+
+void KIconEdit::slotToolFreehand()
+{
+ grid->setTool(KIconEditGrid::Freehand);
+}
+
+void KIconEdit::slotToolRectangle()
+{
+ grid->setTool(KIconEditGrid::Rect);
+}
+
+void KIconEdit::slotToolFilledRectangle()
+{
+ grid->setTool(KIconEditGrid::FilledRect);
+}
+
+void KIconEdit::slotToolCircle()
+{
+ grid->setTool(KIconEditGrid::Circle);
+}
+
+void KIconEdit::slotToolFilledCircle()
+{
+ grid->setTool(KIconEditGrid::FilledCircle);
+}
+
+void KIconEdit::slotToolEllipse()
+{
+ grid->setTool(KIconEditGrid::Ellipse);
+}
+
+void KIconEdit::slotToolFilledEllipse()
+{
+ grid->setTool(KIconEditGrid::FilledEllipse);
+}
+
+void KIconEdit::slotToolSpray()
+{
+ grid->setTool(KIconEditGrid::Spray);
+}
+
+void KIconEdit::slotToolFlood()
+{
+ grid->setTool(KIconEditGrid::FloodFill);
+}
+
+void KIconEdit::slotToolLine()
+{
+ grid->setTool(KIconEditGrid::Line);
+}
+
+void KIconEdit::slotToolEraser()
+{
+ grid->setTool(KIconEditGrid::Eraser);
+}
+
+void KIconEdit::slotToolSelectRect()
+{
+ grid->setTool(KIconEditGrid::SelectRect);
+}
+
+void KIconEdit::slotToolSelectCircle()
+{
+ grid->setTool(KIconEditGrid::SelectCircle);
+}
+
+void KIconEdit::slotSaved()
+{
+ grid->setModified(false);
+}
+
+void KIconEdit::slotUpdateZoom( int s )
+{
+ m_actZoomOut->setEnabled( s>1 );
+}
+
+void KIconEdit::slotUpdateStatusPos(int x, int y)
+{
+ QString str = i18n("Status Position", "%1, %2").arg(x).arg(y);
+ statusbar->changeItem( str, 0);
+}
+
+void KIconEdit::slotUpdateStatusSize(int x, int y)
+{
+ QString str = i18n("Status Size", "%1 x %2").arg(x).arg(y);
+ statusbar->changeItem( str, 1);
+}
+
+void KIconEdit::slotUpdateStatusScaling(int s)
+{
+ KIconEditProperties::self()->setGridScale( s );
+ QString str;
+
+ str.sprintf("1:%d", s);
+ statusbar->changeItem( str, 2);
+}
+
+void KIconEdit::slotUpdateStatusColors(uint)
+{
+ QString str = i18n("Colors: %1").arg(grid->numColors());
+ statusbar->changeItem( str, 3);
+}
+
+void KIconEdit::slotUpdateStatusColors(uint n, uint *)
+{
+ QString str = i18n("Colors: %1").arg(n);
+ statusbar->changeItem( str, 3);
+}
+
+
+void KIconEdit::slotUpdateStatusMessage(const QString & msg)
+{
+ statusbar->changeItem( msg, 4);
+}
+
+
+void KIconEdit::slotUpdateStatusName(const QString & name)
+{
+ m_name = name;
+
+ QString text = m_name;
+
+ if(grid->isModified())
+ {
+ text += " ["+i18n("modified")+"]";
+ }
+
+ setCaption(text);
+}
+
+
+void KIconEdit::slotUpdateStatusModified(bool)
+{
+ slotUpdateStatusName(m_name);
+}
+
+void KIconEdit::slotUpdatePaste(bool state)
+{
+ m_actPaste->setEnabled(state);
+ m_actPasteNew->setEnabled(state);
+}
+
+
+void KIconEdit::slotUpdateCopy(bool state)
+{
+ m_actCopy->setEnabled(state);
+ m_actCut->setEnabled(state);
+}
+
+
+void KIconEdit::slotOpenBlank(const QSize s)
+{
+ grid->loadBlank( s.width(), s.height());
+}
+
+
+void KIconEdit::dragEnterEvent(QDragEnterEvent* e)
+{
+ e->accept(KURLDrag::canDecode(e));
+}
+
+
+/*
+ accept drop of a file - opens file in current window
+ old code to drop image, as image, should be removed
+*/
+void KIconEdit::dropEvent( QDropEvent *e )
+{
+ //kdDebug(4640) << "Got QDropEvent!" << endl;
+
+ KURL::List fileList;
+ bool loadedinthis = false;
+
+ if(KURLDrag::decode(e, fileList))
+ {
+ for(KURL::List::ConstIterator it = fileList.begin();
+ it != fileList.end(); ++it)
+ {
+ //kdDebug(4640) << "In dropEvent for " << (*it).prettyURL() << endl;
+ const KURL &url = *it;
+ if(url.isValid())
+ {
+ if (!grid->isModified() && !loadedinthis)
+ {
+ icon->open(&grid->image(), url);
+ loadedinthis = true;
+ }
+ else
+ {
+ slotNewWin(url.url());
+ }
+ }
+ }
+ }
+}
+
+
diff --git a/kiconedit/kiconeditui.rc b/kiconedit/kiconeditui.rc
new file mode 100644
index 00000000..cdef162c
--- /dev/null
+++ b/kiconedit/kiconeditui.rc
@@ -0,0 +1,66 @@
+<!DOCTYPE kpartgui>
+<kpartgui version="2" name="kiconedit">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_new_window" append="new_merge"/>
+ </Menu>
+ <Menu name="edit"><text>&amp;Edit</text>
+ <Action name="edit_paste_as_new" append="edit_paste_merge"/>
+ <Separator/>
+ <Action name="edit_resize"/>
+ <Action name="edit_grayscale"/>
+ </Menu>
+ <Menu name="tools"><text>&amp;Tools</text>
+ <Action name="tool_freehand"/>
+ <Action name="tool_find_pixel"/>
+ <Action name="tool_rectangle"/>
+ <Action name="tool_filled_rectangle"/>
+ <Action name="tool_circle"/>
+ <Action name="tool_filled_circle"/>
+ <Action name="tool_ellipse"/>
+ <Action name="tool_filled_ellipse"/>
+ <Action name="tool_spray"/>
+ <Action name="tool_flood_fill"/>
+ <Action name="tool_line"/>
+ <Action name="tool_eraser"/>
+ <Separator/>
+ <Action name="edit_select_rectangle"/>
+ <Action name="edit_select_circle"/>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="options_show_grid" append="show_merge"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar" newline="true" fullwidth="true">
+ <text>Main Toolbar</text>
+ <Action name="view_zoom_in"/>
+ <Action name="view_zoom_out"/>
+ <Separator/>
+ <Action name="edit_resize"/>
+ <Action name="edit_grayscale"/>
+ <Separator/>
+ <Action name="options_show_grid"/>
+</ToolBar>
+<ToolBar name="toolsToolBar" position="left" noEdit="true">
+ <text>Tools Toolbar</text>
+ <Action name="tool_freehand"/>
+ <Action name="tool_find_pixel"/>
+ <Action name="tool_rectangle"/>
+ <Action name="tool_filled_rectangle"/>
+ <Action name="tool_circle"/>
+ <Action name="tool_filled_circle"/>
+ <Action name="tool_ellipse"/>
+ <Action name="tool_filled_ellipse"/>
+ <Action name="tool_spray"/>
+ <Action name="tool_flood_fill"/>
+ <Action name="tool_line"/>
+ <Action name="tool_eraser"/>
+ <Separator/>
+ <Action name="edit_select_rectangle"/>
+ <Action name="edit_select_circle"/>
+</ToolBar>
+<ToolBar name="paletteToolBar" position="right" noEdit="true">
+ <text>Pallette Toolbar</text>
+</ToolBar>
+</kpartgui>
+
diff --git a/kiconedit/kicongrid.cpp b/kiconedit/kicongrid.cpp
new file mode 100644
index 00000000..abfb848e
--- /dev/null
+++ b/kiconedit/kicongrid.cpp
@@ -0,0 +1,2263 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ Includes portions of code from Qt,
+ Copyright (C) 1992-2000 Trolltech AS.
+
+ 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 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 <stdlib.h>
+
+#include <qpainter.h>
+#include <qwhatsthis.h>
+#include <qscrollview.h>
+#include <qbitmap.h>
+#include <qclipboard.h>
+#include <qdatetime.h>
+
+#include <kiconloader.h>
+#include <kruler.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+#include "kresize.h"
+#include "properties.h"
+#include "kicongrid.h"
+#include "kiconedit.h"
+#ifndef PICS_INCLUDED
+#include "pics/logo.xpm"
+#define PICS_INCLUDED
+#endif
+
+#include <X11/Xos.h>
+
+void DrawCommand::execute()
+{
+ oldcolor = *((uint*)image->scanLine(y) + x);
+ *((uint*)image->scanLine(y) + x) = newcolor;
+ int cell = y * grid->numCols() + x;
+ grid->setUndoColor( cell, newcolor, false );
+}
+
+void DrawCommand::unexecute()
+{
+ *((uint*)image->scanLine(y) + x) = oldcolor;
+ int cell = y * grid->numCols() + x;
+ grid->setUndoColor( cell, oldcolor, false );
+}
+
+void RepaintCommand::execute()
+{
+ grid->update( area);
+}
+
+KGridView::KGridView(QImage *image, KCommandHistory* history, QWidget *parent, const char *name)
+: QFrame(parent, name)
+{
+ _corner = 0L;
+ _hruler = _vruler = 0L;
+ _grid = 0L;
+
+ acceptdrop = false;
+
+ KIconEditProperties *props = KIconEditProperties::self();
+
+ viewport = new QScrollView(this);
+ Q_CHECK_PTR(viewport);
+
+ _grid = new KIconEditGrid(image, history, viewport->viewport());
+ Q_CHECK_PTR(_grid);
+ viewport->addChild(_grid);
+ _grid->setGrid(props->showGrid());
+ _grid->setCellSize(props->gridScale());
+
+ QString str = i18n( "Icon draw grid\n\nThe icon grid is the area where"
+ " you draw the icons.\nYou can zoom in and out using the magnifying"
+ " glasses on the toolbar.\n(Tip: Hold the magnify button down for a"
+ " few seconds to zoom to a predefined scale)" );
+ QWhatsThis::add( _grid, str );
+
+ if(props->bgMode() == FixedPixmap)
+ {
+ QPixmap pix(props->bgPixmap());
+ if(pix.isNull())
+ {
+ QPixmap pmlogo((const char **)logo);
+ pix = pmlogo;
+ }
+ viewport->viewport()->setBackgroundPixmap(pix);
+ _grid->setBackgroundPixmap(pix);
+ }
+ else
+ {
+ viewport->viewport()->setBackgroundColor(props->bgColor());
+ }
+
+ _corner = new QFrame(this);
+ _corner->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+
+ _hruler = new KRuler(Qt::Horizontal, this);
+ _hruler->setEndLabel(i18n("width"));
+ _hruler->setOffset( -2 );
+ _hruler->setRange(0, 1000);
+
+ _vruler = new KRuler(Qt::Vertical, this);
+ _vruler->setEndLabel(i18n("height"));
+ _vruler->setOffset( -2 );
+ _vruler->setRange(0, 1000);
+
+ str = i18n( "Rulers\n\nThis is a visual representation of the current"
+ " cursor position" );
+ QWhatsThis::add( _hruler, str );
+ QWhatsThis::add( _vruler, str );
+
+ connect(_grid, SIGNAL(scalingchanged(int)), SLOT(scalingChange(int)));
+ connect(_grid, SIGNAL(sizechanged(int, int)), SLOT(sizeChange(int, int)));
+ connect(_grid, SIGNAL(needPainting()), SLOT(paintGrid()));
+ connect( _grid, SIGNAL(xposchanged(int)), _hruler, SLOT(slotNewValue(int)) );
+ connect( _grid, SIGNAL(yposchanged(int)), _vruler, SLOT(slotNewValue(int)) );
+ connect(viewport, SIGNAL(contentsMoving(int, int)), SLOT(moving(int, int)));
+
+ setSizes();
+ QResizeEvent e(size(), size());
+ resizeEvent(&e);
+}
+
+void KGridView::paintGrid()
+{
+ _grid->update(viewRect());
+}
+
+void KGridView::setSizes()
+{
+ if(KIconEditProperties::self()->showRulers())
+ {
+ _hruler->setLittleMarkDistance(_grid->scaling());
+ _vruler->setLittleMarkDistance(_grid->scaling());
+
+ _hruler->setMediumMarkDistance(5);
+ _vruler->setMediumMarkDistance(5);
+
+ _hruler->setBigMarkDistance(10);
+ _vruler->setBigMarkDistance(10);
+
+ _hruler->setShowTinyMarks(true);
+ _hruler->setShowLittleMarks(false);
+ _hruler->setShowMediumMarks(true);
+ _hruler->setShowBigMarks(true);
+ _hruler->setShowEndMarks(true);
+
+ _vruler->setShowTinyMarks(true);
+ _vruler->setShowLittleMarks(false);
+ _vruler->setShowMediumMarks(true);
+ _vruler->setShowBigMarks(true);
+ _vruler->setShowEndMarks(true);
+
+ _hruler->setPixelPerMark(_grid->scaling());
+ _vruler->setPixelPerMark(_grid->scaling());
+
+ _hruler->setMaxValue(_grid->width()+20);
+ _vruler->setMaxValue(_grid->height()+20);
+
+ _hruler->show();
+ _vruler->show();
+
+ _corner->show();
+ //resize(_grid->width()+_vruler->width(), _grid->height()+_hruler->height());
+ }
+ else
+ {
+ _hruler->hide();
+ _vruler->hide();
+ _corner->hide();
+ //resize(_grid->size());
+ }
+}
+
+void KGridView::sizeChange(int, int)
+{
+ setSizes();
+}
+
+void KGridView::moving(int x, int y)
+{
+ _hruler->setOffset(abs(x));
+ _vruler->setOffset(abs(y));
+}
+
+void KGridView::scalingChange(int)
+{
+ setSizes();
+}
+
+void KGridView::setShowRulers(bool mode)
+{
+ KIconEditProperties::self()->setShowRulers( mode );
+ setSizes();
+ QResizeEvent e(size(), size());
+ resizeEvent(&e);
+}
+
+void KGridView::setAcceptDrop(bool a)
+{
+ if(a == acceptdrop) return;
+ acceptdrop = a;
+ paintDropSite();
+}
+
+void KGridView::checkClipboard()
+{
+ _grid->checkClipboard();
+}
+
+const QRect KGridView::viewRect()
+{
+ int x, y, cx, cy;
+ if(viewport->horizontalScrollBar()->isVisible())
+ {
+ x = viewport->contentsX();
+ cx = viewport->viewport()->width();
+ }
+ else
+ {
+ x = 0;
+ cx = viewport->contentsWidth();
+ }
+
+ if(viewport->verticalScrollBar()->isVisible())
+ {
+ y = viewport->contentsY();
+ cy = viewport->viewport()->height();
+ }
+ else
+ {
+ y = 0;
+ cy = viewport->contentsHeight();
+ }
+
+ return QRect(x, y, cx, cy);
+}
+
+void KGridView::paintDropSite()
+{
+ QPainter p;
+ p.begin( _grid );
+ p.setRasterOp (NotROP);
+ p.drawRect(viewRect());
+ p.end();
+}
+
+void KGridView::paintEvent(QPaintEvent *)
+{
+ if(acceptdrop)
+ paintDropSite();
+}
+
+
+void KGridView::resizeEvent(QResizeEvent*)
+{
+ kdDebug(4640) << "KGridView::resizeEvent" << endl;
+
+ setSizes();
+
+ if(KIconEditProperties::self()->showRulers())
+ {
+ _hruler->setGeometry(_vruler->width(), 0, width(), _hruler->height());
+ _vruler->setGeometry(0, _hruler->height(), _vruler->width(), height());
+
+ _corner->setGeometry(0, 0, _vruler->width(), _hruler->height());
+ viewport->setGeometry(_corner->width(), _corner->height(),
+ width()-_corner->width(), height()-_corner->height());
+ }
+ else
+ viewport->setGeometry(0, 0, width(), height());
+}
+
+
+KIconEditGrid::KIconEditGrid(QImage *image, KCommandHistory* h, QWidget *parent, const char *name)
+ : KColorGrid(parent, name, 1)
+{
+ img = image;
+ history = h;
+ selected = 0;
+ m_command = 0;
+
+ // the 42 normal kde colors - there can be an additional
+ // 18 custom colors in the custom colors palette
+ for(uint i = 0; i < 42; i++)
+ iconcolors.append(iconpalette[i]);
+
+ setupImageHandlers();
+ btndown = isselecting = ispasting = modified = false;
+
+ img->create(32, 32, 32);
+ img->setAlphaBuffer(true);
+ clearImage(img);
+
+ currentcolor = qRgb(0,0,0)|OPAQUE_MASK;
+ emit colorSelected(currentcolor);
+
+ setMouseTracking(true);
+
+ setNumRows(32);
+ setNumCols(32);
+ fill(TRANSPARENT);
+
+ connect( kapp->clipboard(), SIGNAL(dataChanged()), SLOT(checkClipboard()));
+ connect( h, SIGNAL(commandExecuted()), this, SLOT(updatePreviewPixmap() ));
+ createCursors();
+
+ KIconEditProperties *props = KIconEditProperties::self();
+
+ setTransparencyDisplayType(props->transparencyDisplayType());
+ setTransparencySolidColor(props->transparencySolidColor());
+ setCheckerboardColor1(props->checkerboardColor1());
+ setCheckerboardColor2(props->checkerboardColor2());
+ setCheckerboardSize(props->checkerboardSize());
+}
+
+KIconEditGrid::~KIconEditGrid()
+{
+ kdDebug(4640) << "KIconEditGrid - destructor: done" << endl;
+}
+
+void KIconEditGrid::paintEvent(QPaintEvent *e)
+{
+ const QRect cellsRect(0, 0, numCols() * cellSize(), numRows() * cellSize());
+ const QRect paintCellsRect = cellsRect.intersect(e->rect());
+
+ if(!paintCellsRect.isEmpty())
+ {
+ //QTime time;
+
+ //time.start();
+
+ QRgb *imageBuffer = new QRgb[paintCellsRect.width() * paintCellsRect.height()];
+ const int cellsize = cellSize();
+ const int firstCellPixelsRemaining = cellsize - paintCellsRect.left() % cellsize;
+
+ if(transparencyDisplayType() == TRD_SOLIDCOLOR)
+ {
+ const QRgb backgroundColor = transparencySolidColor().rgb();
+ const int backgroundRed = transparencySolidColor().red();
+ const int backgroundGreen = transparencySolidColor().green();
+ const int backgroundBlue = transparencySolidColor().blue();
+ const int firstCellX = paintCellsRect.left() / cellsize;
+
+ for(int y = paintCellsRect.top(); y <= paintCellsRect.bottom(); y++)
+ {
+ QRgb *dest = imageBuffer + (y - paintCellsRect.top()) * paintCellsRect.width();
+
+ if(y % cellsize == 0 || dest == imageBuffer)
+ {
+ // Paint the first scanline in each block of cellSize() identical lines.
+ // The remaineder can just be copied from this one.
+ const int cellY = y / cellsize;
+ QRgb *src = gridcolors.data() + cellY * numCols() + firstCellX;
+
+ QRgb sourcePixel = *src++;
+ int sourceAlpha = qAlpha(sourcePixel);
+
+ QRgb c;
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = backgroundColor;
+ }
+ else
+ {
+ const int sourceRed = qRed(sourcePixel);
+ const int sourceGreen = qGreen(sourcePixel);
+ const int sourceBlue = qBlue(sourcePixel);
+
+ int r = (sourceAlpha * (sourceRed - backgroundRed)) + 0x80;
+ r = backgroundRed + ((r + (r >> 8)) >> 8);
+
+ int g = (sourceAlpha * (sourceGreen - backgroundGreen)) + 0x80;
+ g = backgroundGreen + ((g + (g >> 8)) >> 8);
+
+ int b = (sourceAlpha * (sourceBlue - backgroundBlue)) + 0x80;
+ b = backgroundBlue + ((b + (b >> 8)) >> 8);
+
+ c = qRgb(r, g, b);
+ }
+
+ int cellPixelsRemaining = firstCellPixelsRemaining;
+
+ for(int x = paintCellsRect.left(); x <= paintCellsRect.right(); x++)
+ {
+ if(cellPixelsRemaining == 0)
+ {
+ cellPixelsRemaining = cellsize;
+
+ // Fetch the next source pixel
+ sourcePixel = *src++;
+ sourceAlpha = qAlpha(sourcePixel);
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = backgroundColor;
+ }
+ else
+ {
+ const int sourceRed = qRed(sourcePixel);
+ const int sourceGreen = qGreen(sourcePixel);
+ const int sourceBlue = qBlue(sourcePixel);
+
+ //int r = backgroundRed + (sourceAlpha * (sourceRed - backgroundRed)) / 255;
+ //int g = backgroundGreen + (sourceAlpha * (sourceGreen - backgroundGreen)) / 255;
+ //int b = backgroundBlue + (sourceAlpha * (sourceBlue - backgroundBlue)) / 255;
+
+ int r = (sourceAlpha * (sourceRed - backgroundRed)) + 0x80;
+ r = backgroundRed + ((r + (r >> 8)) >> 8);
+
+ int g = (sourceAlpha * (sourceGreen - backgroundGreen)) + 0x80;
+ g = backgroundGreen + ((g + (g >> 8)) >> 8);
+
+ int b = (sourceAlpha * (sourceBlue - backgroundBlue)) + 0x80;
+ b = backgroundBlue + ((b + (b >> 8)) >> 8);
+
+ c = qRgb(r, g, b);
+ }
+ }
+
+ cellPixelsRemaining--;
+
+ *dest++ = c;
+ }
+ }
+ else
+ {
+ // Copy the scanline above.
+ memcpy(dest, dest - paintCellsRect.width(), paintCellsRect.width() * sizeof(QRgb));
+ }
+ }
+ }
+ else
+ {
+ int squareSize;
+ const int fixedPointMultiplier = 4;
+
+ if(checkerboardSize() == CHK_SMALL)
+ {
+ squareSize = (cellSize() * fixedPointMultiplier) / 4;
+ }
+ else
+ if(checkerboardSize() == CHK_MEDIUM)
+ {
+ squareSize = (cellSize() * fixedPointMultiplier) / 2;
+ }
+ else
+ {
+ squareSize = (2 * cellSize() * fixedPointMultiplier) / 2;
+ }
+
+ QRgb *color1ScanLine = new QRgb[paintCellsRect.width()];
+ QRgb *color2ScanLine = new QRgb[paintCellsRect.width()];
+ QRgb *color1Buffer = color1ScanLine;
+ QRgb *color2Buffer = color2ScanLine;
+
+ for(int x = paintCellsRect.left(); x <= paintCellsRect.right(); x++)
+ {
+ if((((x * fixedPointMultiplier) / squareSize) & 1) == 0)
+ {
+ *color1Buffer++ = checkerboardColor1().rgb();
+ *color2Buffer++ = checkerboardColor2().rgb();
+ }
+ else
+ {
+ *color1Buffer++ = checkerboardColor2().rgb();
+ *color2Buffer++ = checkerboardColor1().rgb();
+ }
+ }
+
+ const int firstCellX = paintCellsRect.left() / cellsize;
+ const int firstCellPixelsRemaining = cellsize - paintCellsRect.left() % cellsize;
+ int lastCellY = -1;
+ int lastLineFirstSquareColour = 0;
+
+ for(int y = paintCellsRect.top(); y <= paintCellsRect.bottom(); y++)
+ {
+ QRgb *dest = imageBuffer + (y - paintCellsRect.top()) * paintCellsRect.width();
+ const int cellY = y / cellsize;
+
+ int firstSquareColour;
+ const QRgb *checkerboardSrc;
+
+ if((((y * fixedPointMultiplier) / squareSize) & 1) == 0)
+ {
+ firstSquareColour = 1;
+ checkerboardSrc = color1ScanLine;
+ }
+ else
+ {
+ firstSquareColour = 2;
+ checkerboardSrc = color2ScanLine;
+ }
+
+ if(cellY == lastCellY && firstSquareColour == lastLineFirstSquareColour)
+ {
+ // Copy the scanline above.
+ memcpy(dest, dest - paintCellsRect.width(), paintCellsRect.width() * sizeof(QRgb));
+ }
+ else
+ {
+ QRgb *src = gridcolors.data() + cellY * numCols() + firstCellX;
+
+ QRgb sourcePixel = *src++;
+ int sourceRed = qRed(sourcePixel);
+ int sourceGreen = qGreen(sourcePixel);
+ int sourceBlue = qBlue(sourcePixel);
+ int sourceAlpha = qAlpha(sourcePixel);
+
+ int cellPixelsRemaining = firstCellPixelsRemaining;
+
+ for(int x = paintCellsRect.left(); x <= paintCellsRect.right(); x++)
+ {
+ if(cellPixelsRemaining == 0)
+ {
+ cellPixelsRemaining = cellsize;
+
+ // Fetch the next source pixel
+ sourcePixel = *src++;
+ sourceRed = qRed(sourcePixel);
+ sourceGreen = qGreen(sourcePixel);
+ sourceBlue = qBlue(sourcePixel);
+ sourceAlpha = qAlpha(sourcePixel);
+ }
+
+ cellPixelsRemaining--;
+
+ QRgb c;
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = *checkerboardSrc;
+ }
+ else
+ {
+ const int backgroundColor = *checkerboardSrc;
+ const int backgroundRed = qRed(backgroundColor);
+ const int backgroundGreen = qGreen(backgroundColor);
+ const int backgroundBlue = qBlue(backgroundColor);
+
+ //int r = backgroundRed + (sourceAlpha * (sourceRed - backgroundRed)) / 255;
+ //int g = backgroundGreen + (sourceAlpha * (sourceGreen - backgroundGreen)) / 255;
+ //int b = backgroundBlue + (sourceAlpha * (sourceBlue - backgroundBlue)) / 255;
+
+ int r = (sourceAlpha * (sourceRed - backgroundRed)) + 0x80;
+ r = backgroundRed + ((r + (r >> 8)) >> 8);
+
+ int g = (sourceAlpha * (sourceGreen - backgroundGreen)) + 0x80;
+ g = backgroundGreen + ((g + (g >> 8)) >> 8);
+
+ int b = (sourceAlpha * (sourceBlue - backgroundBlue)) + 0x80;
+ b = backgroundBlue + ((b + (b >> 8)) >> 8);
+
+ c = qRgb(r, g, b);
+ }
+
+ *dest++ = c;
+ checkerboardSrc++;
+ }
+ }
+
+ lastCellY = cellY;
+ lastLineFirstSquareColour = firstSquareColour;
+ }
+
+ delete [] color1ScanLine;
+ delete [] color2ScanLine;
+ }
+
+ QImage image((uchar *)(imageBuffer), paintCellsRect.width(), paintCellsRect.height(), 32, 0, 0,
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ QImage::LittleEndian);
+#else
+ QImage::BigEndian);
+#endif
+ Q_ASSERT(!image.isNull());
+
+ QPixmap _pixmap;
+ _pixmap.convertFromImage(image);
+
+ QPainter p;
+ p.begin(&_pixmap);
+ paintForeground(&p, e);
+ p.end();
+
+ bitBlt(this, paintCellsRect.left(), paintCellsRect.top(), &_pixmap);
+
+ //kdDebug(4640) << "Image render elapsed: " << time.elapsed() << endl;
+
+ delete [] imageBuffer;
+ }
+}
+
+void KIconEditGrid::paintForeground(QPainter* p, QPaintEvent* e)
+{
+ QWMatrix matrix;
+
+ matrix.translate(-e->rect().x(), -e->rect().y());
+ p->setWorldMatrix( matrix );
+
+ QRect cellsRect(0, 0, numCols() * cellSize(), numRows() * cellSize());
+ QRect paintCellsRect = cellsRect.intersect(e->rect());
+
+ if(!paintCellsRect.isEmpty())
+ {
+ int firstColumn = paintCellsRect.left() / cellSize();
+ int lastColumn = paintCellsRect.right() / cellSize();
+
+ int firstRow = paintCellsRect.top() / cellSize();
+ int lastRow = paintCellsRect.bottom() / cellSize();
+
+ p->setPen(QColor(0, 0, 0));
+ p->setBrush(QColor(0, 0, 0));
+
+ for(int column = firstColumn; column <= lastColumn; column++)
+ {
+ for(int row = firstRow; row <= lastRow; row++)
+ {
+ int x = column * cellSize();
+ int y = row * cellSize();
+
+ if((ispasting || isselecting) && isMarked(column, row))
+ {
+ p->drawWinFocusRect(x + 1, y + 1, cellSize() - 2, cellSize() - 2);
+ }
+ else
+ {
+ switch( tool )
+ {
+ case FilledRect:
+ case Rect:
+ case Ellipse:
+ case Circle:
+ case FilledEllipse:
+ case FilledCircle:
+ case Line:
+ if(btndown && isMarked(column, row))
+ {
+ if(cellSize() > 1)
+ {
+ p->drawWinFocusRect( x + 1, y + 1, cellSize() - 2, cellSize() - 2);
+ }
+ else
+ {
+ p->drawPoint(x, y);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if(hasGrid()&& !(cellSize()==1))
+ {
+ p->setPen(QColor(0, 0, 0));
+ int x = e->rect().x() - ((e->rect().x() % cellSize()) + cellSize());
+ if(x < 0) x = 0;
+ int y = e->rect().y() - ((e->rect().y() % cellSize()) + cellSize());
+ if(y < 0) y = 0;
+ int cx = e->rect().right() + cellSize();
+ int cy = e->rect().bottom() + cellSize();
+
+ // draw grid lines
+ for(int i = x; i < cx; i += cellSize())
+ p->drawLine(i, y, i, cy);
+
+ for(int i = y; i < cy; i += cellSize())
+ p->drawLine(x, i, cx, i);
+ }
+}
+
+void KIconEditGrid::mousePressEvent( QMouseEvent *e )
+{
+ if(!e || (e->button() != LeftButton))
+ return;
+
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ //int cell = row * numCols() + col;
+
+ if(!img->valid(col, row))
+ return;
+
+ btndown = true;
+ start.setX(col);
+ start.setY(row);
+
+ if(ispasting)
+ {
+ ispasting = false;
+ editPaste(true);
+ }
+
+ if(isselecting)
+ {
+ QPointArray a(pntarray.copy());
+ pntarray.resize(0);
+ drawPointArray(a, Mark);
+ emit selecteddata(false);
+ }
+
+ switch( tool )
+ {
+ case SelectRect:
+ case SelectCircle:
+ isselecting = true;
+ break;
+ default:
+ break;
+ }
+}
+
+void KIconEditGrid::mouseMoveEvent( QMouseEvent *e )
+{
+ if(!e) return;
+
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ int cell = row * numCols() + col;
+
+ if(img->valid(col, row))
+ {
+ //kdDebug(4640) << col << " X " << row << endl;
+ emit poschanged(col, row);
+ // for the rulers
+ emit xposchanged((col*scaling())+scaling()/2);
+ emit yposchanged((row*scaling())+scaling()/2);
+ }
+
+ QPoint tmpp(col, row);
+ if(tmpp == end) return;
+
+ // need to use intersection of rectangles to allow pasting
+ // only that part of clip image which intersects -jwc-
+ if(ispasting && !btndown && img->valid(col, row))
+ {
+ if( (col + cbsize.width()) > (numCols()-1) )
+ insrect.setX(numCols()-insrect.width());
+ else
+ insrect.setX(col);
+ if( (row + cbsize.height()) > (numRows()-1) )
+ insrect.setY(numRows()-insrect.height());
+ else
+ insrect.setY(row);
+
+ insrect.setSize(cbsize);
+ start = insrect.topLeft();
+ end = insrect.bottomRight();
+ drawRect(false);
+ return;
+ }
+
+ if(!img->valid(col, row) || !btndown)
+ return;
+
+ end.setX(col);
+ end.setY(row);
+
+ if(isselecting)
+ {
+ if(tool == SelectRect)
+ drawRect(false);
+ else
+ drawEllipse(false);
+ return;
+ }
+
+ bool erase=false;
+ switch( tool )
+ {
+ case Eraser:
+ erase=true;
+
+ case Freehand:
+ {
+ if( !m_command )
+ m_command = new KMacroCommand( i18n("Free Hand") );
+
+ if(erase)
+ setColor( cell, TRANSPARENT );
+ else
+ setColor( cell, currentcolor );
+
+ if ( selected != cell )
+ {
+ setModified( true );
+ int prevSel = selected;
+ selected = cell;
+ QRect area = QRect( col*cellsize,row*cellsize, cellsize, cellsize ).unite(
+ QRect ( (prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize ) );
+
+ m_command->addCommand( new RepaintCommand( area, this ) );
+ DrawCommand* dc = new DrawCommand( col, row, colorAt(cell), img, this );
+ RepaintCommand* rp = new RepaintCommand( area, this );
+ dc->execute();
+ rp->execute();
+ m_command->addCommand( dc );
+ m_command->addCommand( rp );
+ }
+ break;
+ }
+ case Find:
+ {
+ iconcolors.closestMatch(colorAt(cell));
+ if ( selected != cell )
+ {
+ int prevSel = selected;
+ selected = cell;
+ update((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize);
+ update(col*cellsize,row*cellsize, cellsize, cellsize);
+ emit colorSelected(colorAt(selected));
+ }
+ break;
+ }
+ case Ellipse:
+ case Circle:
+ case FilledEllipse:
+ case FilledCircle:
+ {
+ drawEllipse(false);
+ break;
+ }
+ case FilledRect:
+ case Rect:
+ {
+ drawRect(false);
+ break;
+ }
+ case Line:
+ {
+ drawLine(false, false);
+ break;
+ }
+ case Spray:
+ {
+ drawSpray(QPoint(col, row));
+ setModified(true);
+ break;
+ }
+ default:
+ break;
+ }
+
+ p = *img;
+ emit changed(QPixmap(p));
+}
+
+void KIconEditGrid::mouseReleaseEvent( QMouseEvent *e )
+{
+ if(!e || (e->button() != LeftButton))
+ return;
+
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ btndown = false;
+ end.setX(col);
+ end.setY(row);
+ int cell = row * numCols() + col;
+ bool erase=false;
+ switch( tool )
+ {
+ case Eraser:
+ erase=true;
+ //currentcolor = TRANSPARENT;
+ case Freehand:
+ {
+ if(!img->valid(col, row))
+ return;
+ if(erase)
+ setColor( cell, TRANSPARENT );
+ else
+ setColor( cell, currentcolor );
+ //if ( selected != cell )
+ //{
+ setModified( true );
+ int prevSel = selected;
+ selected = cell;
+ update((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize);
+ update(col*cellsize,row*cellsize, cellsize, cellsize);
+ //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
+ //updateCell( row, col, FALSE );
+ *((uint*)img->scanLine(row) + col) = colorAt(cell);
+ p = *img;
+ //}
+
+ if( m_command ) {
+ history->addCommand( m_command, false );
+ m_command = 0;
+ }
+
+ break;
+ }
+ case Ellipse:
+ case Circle:
+ case FilledEllipse:
+ case FilledCircle:
+ {
+ drawEllipse(true);
+ break;
+ }
+ case FilledRect:
+ case Rect:
+ {
+ drawRect(true);
+ break;
+ }
+ case Line:
+ {
+ drawLine(true, false);
+ break;
+ }
+ case Spray:
+ {
+ drawSpray(QPoint(col, row));
+ break;
+ }
+ case FloodFill:
+ {
+ QApplication::setOverrideCursor(waitCursor);
+ drawFlood(col, row, colorAt(cell));
+ QApplication::restoreOverrideCursor();
+ updateColors();
+ emit needPainting();
+ p = *img;
+ break;
+ }
+ case Find:
+ {
+ currentcolor = colorAt(cell);
+ if ( selected != cell )
+ {
+ int prevSel = selected;
+ selected = cell;
+ update((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize);
+ update(col*cellsize,row*cellsize, cellsize, cellsize);
+ emit colorSelected(currentcolor);
+ //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
+ //updateCell( row, col, FALSE );
+ }
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ emit changed(QPixmap(p));
+ //emit colorschanged(numColors(), data());
+}
+
+//void KIconEditGrid::setColorSelection( const QColor &color )
+void KIconEditGrid::setColorSelection( uint c )
+{
+ currentcolor = c;
+ emit colorSelected(currentcolor);
+}
+
+void KIconEditGrid::loadBlank( int w, int h )
+{
+ img->create(w, h, 32);
+ img->setAlphaBuffer(true);
+ clearImage(img);
+ setNumRows(h);
+ setNumCols(w);
+ fill(TRANSPARENT);
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ history->clear();
+}
+
+
+
+void KIconEditGrid::load( QImage *image)
+{
+ kdDebug(4640) << "KIconEditGrid::load" << endl;
+
+ setUpdatesEnabled(false);
+
+ if(image == 0L)
+ {
+ QString msg = i18n("There was an error loading a blank image.\n");
+ KMessageBox::error(this, msg);
+ return;
+ }
+
+ *img = image->convertDepth(32);
+ img->setAlphaBuffer(true);
+ setNumRows(img->height());
+ setNumCols(img->width());
+
+ for(int y = 0; y < numRows(); y++)
+ {
+ uint *l = (uint*)img->scanLine(y);
+ for(int x = 0; x < numCols(); x++, l++)
+ {
+ setColor((y*numCols())+x, *l, false);
+ }
+ //kdDebug(4640) << "Row: " << y << endl;
+ kapp->processEvents(200);
+ }
+
+ updateColors();
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ emit changed(pixmap());
+ setUpdatesEnabled(true);
+ emit needPainting();
+ //repaint(viewRect(), false);
+ history->clear();
+}
+
+const QPixmap &KIconEditGrid::pixmap()
+{
+ if(!img->isNull())
+ p = *img;
+ //p.convertFromImage(*img, 0);
+ return(p);
+}
+
+void KIconEditGrid::getImage(QImage *image)
+{
+ kdDebug(4640) << "KIconEditGrid::getImage" << endl;
+ *image = *img;
+}
+
+bool KIconEditGrid::zoomTo(int scale)
+{
+ QApplication::setOverrideCursor(waitCursor);
+ setUpdatesEnabled(false);
+ setCellSize( scale );
+ setUpdatesEnabled(true);
+ emit needPainting();
+ QApplication::restoreOverrideCursor();
+ emit scalingchanged(cellSize());
+
+ if(scale == 1)
+ return false;
+ return true;
+}
+
+bool KIconEditGrid::zoom(Direction d)
+{
+ int f = (d == DirIn) ? (cellSize()+1) : (cellSize()-1);
+ QApplication::setOverrideCursor(waitCursor);
+ setUpdatesEnabled(false);
+ setCellSize( f );
+ setUpdatesEnabled(true);
+ //emit needPainting();
+ QApplication::restoreOverrideCursor();
+
+ emit scalingchanged(cellSize());
+ if(d == DirOut && cellSize() <= 1)
+ return false;
+ return true;
+}
+
+void KIconEditGrid::checkClipboard()
+{
+ bool ok = false;
+ QImage tmp = clipboardImage(ok);
+ if(ok)
+ emit clipboarddata(true);
+ else
+ {
+ emit clipboarddata(false);
+ }
+}
+
+QImage KIconEditGrid::clipboardImage(bool &ok)
+{
+ //###### Remove me later.
+ //Workaround Qt bug -- check whether format provided first.
+ //Code below is from QDragObject, to match the mimetype list....
+
+ QStrList fileFormats = QImageIO::inputFormats();
+ fileFormats.first();
+ bool oneIsSupported = false;
+ while ( fileFormats.current() )
+ {
+ QCString format = fileFormats.current();
+ QCString type = "image/" + format.lower();
+ if (kapp->clipboard()->data()->provides(type ) )
+ {
+ oneIsSupported = true;
+ }
+ fileFormats.next();
+ }
+ if (!oneIsSupported)
+ {
+ ok = false;
+ return QImage();
+ }
+
+ QImage image = kapp->clipboard()->image();
+ ok = !image.isNull();
+ if ( ok )
+ {
+ image = image.convertDepth(32);
+ image.setAlphaBuffer(true);
+ }
+ return image;
+}
+
+
+void KIconEditGrid::editSelectAll()
+{
+ start.setX(0);
+ start.setY(0);
+ end.setX(numCols()-1);
+ end.setY(numRows()-1);
+ isselecting = true;
+ drawRect(false);
+ emit newmessage(i18n("All selected"));
+}
+
+void KIconEditGrid::editClear()
+{
+ clearImage(img);
+ fill(TRANSPARENT);
+ update();
+ setModified(true);
+ p = *img;
+ emit changed(p);
+ emit newmessage(i18n("Cleared"));
+}
+
+QImage KIconEditGrid::getSelection(bool cut)
+{
+ const QRect rect = pntarray.boundingRect();
+ int nx = 0, ny = 0, nw = 0, nh = 0;
+ rect.rect(&nx, &ny, &nw, &nh);
+
+ QImage tmp(nw, nh, 32);
+ tmp.setAlphaBuffer(true);
+ clearImage(&tmp);
+
+ int s = pntarray.size();
+
+ for(int i = 0; i < s; i++)
+ {
+ int x = pntarray[i].x();
+ int y = pntarray[i].y();
+ if(img->valid(x, y) && rect.contains(QPoint(x, y)))
+ {
+ *((uint*)tmp.scanLine(y-ny) + (x-nx)) = *((uint*)img->scanLine(y) + x);
+ if(cut)
+ {
+ *((uint*)img->scanLine(y) + x) = TRANSPARENT;
+ setColor( (y*numCols()) + x, TRANSPARENT, false );
+ }
+ }
+ }
+
+ QPointArray a(pntarray.copy());
+ pntarray.resize(0);
+ drawPointArray(a, Mark);
+ emit selecteddata(false);
+ if(cut)
+ {
+ updateColors();
+ update(rect.x()*cellSize(), rect.y()*cellSize(),
+ rect.width()*cellSize(), rect.height()*cellSize());
+ p = *img;
+ emit changed(p);
+ emit colorschanged(numColors(), data());
+ emit newmessage(i18n("Selected area cut"));
+ setModified(true);
+ }
+ else
+ emit newmessage(i18n("Selected area copied"));
+
+ return tmp;
+}
+
+void KIconEditGrid::editCopy(bool cut)
+{
+ kapp->clipboard()->setImage(getSelection(cut));
+ isselecting = false;
+}
+
+
+void KIconEditGrid::editPaste(bool paste)
+{
+ bool ok = false;
+ QImage tmp = clipboardImage(ok);
+
+ KIconEditProperties *props = KIconEditProperties::self();
+
+ if(ok)
+ {
+ if( (tmp.size().width() > img->size().width())
+ || (tmp.size().height() > img->size().height()) )
+ {
+ if(KMessageBox::warningYesNo(this,
+ i18n("The clipboard image is larger than the current"
+ " image!\nPaste as new image?"),QString::null,i18n("Paste"), i18n("Do Not Paste")) == 0)
+ {
+ editPasteAsNew();
+ }
+ return;
+ }
+ else if(!paste)
+ {
+ ispasting = true;
+ cbsize = tmp.size();
+ return;
+ // emit newmessage(i18n("Pasting"));
+ }
+ else
+ {
+ //kdDebug(4640) << "KIconEditGrid: Pasting at: " << insrect.x() << " x " << insrect.y() << endl;
+ QApplication::setOverrideCursor(waitCursor);
+
+ for(int y = insrect.y(), ny = 0; y < numRows() && ny < insrect.height(); y++, ny++)
+ {
+ uint *l = ((uint*)img->scanLine(y)+insrect.x());
+ uint *cl = (uint*)tmp.scanLine(ny);
+ for(int x = insrect.x(), nx = 0; x < numCols() && nx < insrect.width(); x++, nx++, l++, cl++)
+ {
+ if(props->pasteTransparent())
+ {
+ *l = *cl;
+ }
+ else
+ {
+ // Porter-Duff Over composition
+ double alphaS = qAlpha(*cl) / 255.0;
+ double alphaD = qAlpha(*l) / 255.0;
+
+ double r = qRed(*cl) * alphaS + (1 - alphaS) * qRed(*l) * alphaD;
+ double g = qGreen(*cl) * alphaS + (1 - alphaS) * qGreen(*l) * alphaD;
+ double b = qBlue(*cl) * alphaS + (1 - alphaS) * qBlue(*l) * alphaD;
+ double a = alphaS + (1 - alphaS) * alphaD;
+
+ // Remove multiplication by alpha
+
+ if(a > 0)
+ {
+ r /= a;
+ g /= a;
+ b /= a;
+ }
+ else
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+
+ int ir = (int)(r + 0.5);
+
+ if(ir < 0)
+ {
+ ir = 0;
+ }
+ else
+ if(ir > 255)
+ {
+ ir = 255;
+ }
+
+ int ig = (int)(g + 0.5);
+
+ if(ig < 0)
+ {
+ ig = 0;
+ }
+ else
+ if(ig > 255)
+ {
+ ig = 255;
+ }
+
+ int ib = (int)(b + 0.5);
+
+ if(ib < 0)
+ {
+ ib = 0;
+ }
+ else
+ if(ib > 255)
+ {
+ ib = 255;
+ }
+
+ int ia = (int)((a * 255) + 0.5);
+
+ if(ia < 0)
+ {
+ ia = 0;
+ }
+ else
+ if(ia > 255)
+ {
+ ia = 255;
+ }
+
+ *l = qRgba(ir, ig, ib, ia);
+ }
+
+ setColor((y*numCols())+x, (uint)*l, false);
+ }
+ }
+ updateColors();
+ update(insrect.x()*cellSize(), insrect.y()*cellSize(),
+ insrect.width()*cellSize(), insrect.height()*cellSize());
+
+ QApplication::restoreOverrideCursor();
+
+ setModified(true);
+ p = *img;
+ emit changed(QPixmap(p));
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ emit newmessage(i18n("Done pasting"));
+ }
+ }
+ else
+ {
+ QString msg = i18n("Invalid pixmap data in clipboard!\n");
+ KMessageBox::sorry(this, msg);
+ }
+}
+
+
+void KIconEditGrid::editPasteAsNew()
+{
+ bool ok = false;
+ QImage tmp = clipboardImage(ok);
+
+ if(ok)
+ {
+ if(isModified())
+ {
+ KIconEdit *w = new KIconEdit(tmp);
+ Q_CHECK_PTR(w);
+ }
+ else
+ {
+ *img = tmp;
+ load(img);
+ setModified(true);
+ //repaint(viewRect(), false);
+
+ p = *img;
+ emit changed(QPixmap(p));
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ emit newmessage(i18n("Done pasting"));
+ history->clear();
+ }
+ }
+ else
+ {
+ QString msg = i18n("Invalid pixmap data in clipboard!\n");
+ KMessageBox::error(this, msg);
+ }
+}
+
+
+void KIconEditGrid::editResize()
+{
+ kdDebug(4640) << "KIconGrid::editResize" << endl;
+ KResizeDialog *rs = new KResizeDialog(this, 0, QSize(numCols(), numRows()));
+ if(rs->exec())
+ {
+ const QSize s = rs->getSize();
+ *img = img->smoothScale(s.width(), s.height());
+ load(img);
+
+ setModified(true);
+ }
+ delete rs;
+}
+
+
+void KIconEditGrid::setSize(const QSize s)
+{
+ kdDebug(4640) << "::setSize: " << s.width() << " x " << s.height() << endl;
+
+ img->create(s.width(), s.height(), 32);
+ img->setAlphaBuffer(true);
+ clearImage(img);
+ load(img);
+}
+
+
+void KIconEditGrid::createCursors()
+{
+ QBitmap mask(22, 22);
+ QPixmap pix;
+
+ cursor_normal = QCursor(arrowCursor);
+
+ pix = BarIcon("colorpicker-cursor");
+ if(pix.isNull())
+ {
+ cursor_colorpicker = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading colorpicker-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask();
+ pix.setMask(mask);
+ cursor_colorpicker = QCursor(pix, 1, 21);
+ }
+
+ pix = BarIcon("paintbrush-cursor");
+ if(pix.isNull())
+ {
+ cursor_paint = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading paintbrush.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask();
+ pix.setMask(mask);
+ cursor_paint = QCursor(pix, 0, 19);
+ }
+
+ pix = BarIcon("fill-cursor");
+ if(pix.isNull())
+ {
+ cursor_flood = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading fill-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask();
+ pix.setMask(mask);
+ cursor_flood = QCursor(pix, 3, 20);
+ }
+
+ pix = BarIcon("aim-cursor");
+ if(pix.isNull())
+ {
+ cursor_aim = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading aim-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask();
+ pix.setMask(mask);
+ cursor_aim = QCursor(pix, 10, 10);
+ }
+
+ pix = BarIcon("airbrush-cursor");
+ if(pix.isNull())
+ {
+ cursor_spray = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading airbrush-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask(true);
+ pix.setMask(mask);
+ cursor_spray = QCursor(pix, 0, 20);
+ }
+
+ pix = BarIcon("eraser-cursor");
+ if(pix.isNull())
+ {
+ cursor_erase = cursor_normal;
+ kdDebug(4640) << "KIconEditGrid: Error loading eraser-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = pix.createHeuristicMask(true);
+ pix.setMask(mask);
+ cursor_erase = QCursor(pix, 1, 16);
+ }
+}
+
+
+
+void KIconEditGrid::setTool(DrawTool t)
+{
+ btndown = false;
+ tool = t;
+
+ if(tool != SelectRect && tool != SelectCircle)
+ isselecting = false;
+
+ switch( tool )
+ {
+ case SelectRect:
+ isselecting = true;
+ setCursor(cursor_aim);
+ break;
+ case SelectCircle:
+ isselecting = true;
+ setCursor(cursor_aim);
+ break;
+ case Line:
+ case Ellipse:
+ case Circle:
+ case FilledEllipse:
+ case FilledCircle:
+ case FilledRect:
+ case Rect:
+ setCursor(cursor_aim);
+ break;
+ case Freehand:
+ setCursor(cursor_paint);
+ break;
+ case Spray:
+ setCursor(cursor_spray);
+ break;
+ case Eraser:
+ setCursor(cursor_erase);
+ break;
+ case FloodFill:
+ setCursor(cursor_flood);
+ break;
+ case Find:
+ setCursor(cursor_colorpicker);
+ break;
+ default:
+ break;
+ }
+}
+
+
+void KIconEditGrid::drawFlood(int x, int y, uint oldcolor)
+{
+ if((!img->valid(x, y))
+ || (colorAt((y * numCols())+x) != oldcolor)
+ || (colorAt((y * numCols())+x) == currentcolor))
+ return;
+
+ *((uint*)img->scanLine(y) + x) = currentcolor;
+ setColor((y*numCols())+x, currentcolor, false);
+
+ setModified(true);
+
+ drawFlood(x, y-1, oldcolor);
+ drawFlood(x, y+1, oldcolor);
+ drawFlood(x-1, y, oldcolor);
+ drawFlood(x+1, y, oldcolor);
+ //TODO: add undo
+}
+
+
+void KIconEditGrid::drawSpray(QPoint point)
+{
+ int x = (point.x()-5);
+ int y = (point.y()-5);
+
+ //kdDebug(4640) << "drawSpray() - " << x << " X " << y << endl;
+
+ pntarray.resize(0);
+ int points = 0;
+ for(int i = 1; i < 4; i++, points++)
+ {
+ int dx = (rand() % 10);
+ int dy = (rand() % 10);
+ pntarray.putPoints(points, 1, x+dx, y+dy);
+ }
+
+ drawPointArray(pntarray, Draw);
+}
+
+
+//This routine is from Qt sources -- it's the branch of QPointArray::makeEllipse( int x, int y, int w, int h ) that's not normally compiled
+//It seems like KIconEdit relied on the Qt1 semantics for makeEllipse, which broke
+//the tool with reasonably recent Qt versions.
+//Thankfully, Qt includes the old code #ifdef'd, which is hence included here
+static void QPA_makeEllipse(QPointArray& ar, int x, int y, int w, int h )
+{ // midpoint, 1/4 ellipse
+ if ( w <= 0 || h <= 0 ) {
+ if ( w == 0 || h == 0 ) {
+ ar.resize( 0 );
+ return;
+ }
+ if ( w < 0 ) { // negative width
+ w = -w;
+ x -= w;
+ }
+ if ( h < 0 ) { // negative height
+ h = -h;
+ y -= h;
+ }
+ }
+ int s = (w+h+2)/2; // max size of xx,yy array
+ int *px = new int[s]; // 1/4th of ellipse
+ int *py = new int[s];
+ int xx, yy, i=0;
+ double d1, d2;
+ double a2=(w/2)*(w/2), b2=(h/2)*(h/2);
+ xx = 0;
+ yy = int(h/2);
+ d1 = b2 - a2*(h/2) + 0.25*a2;
+ px[i] = xx;
+ py[i] = yy;
+ i++;
+ while ( a2*(yy-0.5) > b2*(xx+0.5) ) { // region 1
+ if ( d1 < 0 ) {
+ d1 = d1 + b2*(3.0+2*xx);
+ xx++;
+ } else {
+ d1 = d1 + b2*(3.0+2*xx) + 2.0*a2*(1-yy);
+ xx++;
+ yy--;
+ }
+ px[i] = xx;
+ py[i] = yy;
+ i++;
+ }
+ d2 = b2*(xx+0.5)*(xx+0.5) + a2*(yy-1)*(yy-1) - a2*b2;
+ while ( yy > 0 ) { // region 2
+ if ( d2 < 0 ) {
+ d2 = d2 + 2.0*b2*(xx+1) + a2*(3-2*yy);
+ xx++;
+ yy--;
+ } else {
+ d2 = d2 + a2*(3-2*yy);
+ yy--;
+ }
+ px[i] = xx;
+ py[i] = yy;
+ i++;
+ }
+ s = i;
+ ar.resize( 4*s ); // make full point array
+ x += w/2;
+ y += h/2;
+ for ( i=0; i<s; i++ ) { // mirror
+ xx = px[i];
+ yy = py[i];
+ ar.setPoint( s-i-1, x+xx, y-yy );
+ ar.setPoint( s+i, x-xx, y-yy );
+ ar.setPoint( 3*s-i-1, x-xx, y+yy );
+ ar.setPoint( 3*s+i, x+xx, y+yy );
+ }
+ delete[] px;
+ delete[] py;
+}
+
+
+
+void KIconEditGrid::drawEllipse(bool drawit)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ QPointArray a(pntarray.copy());
+ int x = start.x(), y = start.y(), cx, cy;
+
+ if(x > end.x())
+ {
+ cx = x - end.x();
+ x = x - cx;
+ }
+ else
+ cx = end.x() - x;
+ if(y > end.y())
+ {
+ cy = y - end.y();
+ y = y - cy;
+ }
+ else
+ cy = end.y() - y;
+
+ int d = (cx > cy) ? cx : cy;
+
+ //kdDebug(4640) << x << ", " << y << " - " << d << " " << d << endl;
+ pntarray.resize(0);
+ drawPointArray(a, Mark);
+
+ if(tool == Circle || tool == FilledCircle || tool == SelectCircle)
+ QPA_makeEllipse(pntarray, x, y, d, d);
+ else if(tool == Ellipse || tool == FilledEllipse)
+ QPA_makeEllipse(pntarray, x, y, cx, cy);
+
+ if((tool == FilledEllipse) || (tool == FilledCircle)
+ || (tool == SelectCircle))
+ {
+ int s = pntarray.size();
+ int points = s;
+ for(int i = 0; i < s; i++)
+ {
+ int x = pntarray[i].x();
+ int y = pntarray[i].y();
+ for(int j = 0; j < s; j++)
+ {
+ if((pntarray[j].y() == y) && (pntarray[j].x() > x))
+ {
+ for(int k = x; k < pntarray[j].x(); k++, points++)
+ pntarray.putPoints(points, 1, k, y);
+ break;
+ }
+ }
+ }
+ }
+
+ drawPointArray(pntarray, Mark);
+
+ if(tool == SelectCircle && pntarray.size() > 0 && !ispasting)
+ emit selecteddata(true);
+}
+
+
+void KIconEditGrid::drawRect(bool drawit)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ QPointArray a(pntarray.copy());
+ int x = start.x(), y = start.y(), cx, cy;
+
+ if(x > end.x())
+ {
+ cx = x - end.x();
+ x = x - cx;
+ }
+ else
+ cx = end.x() - x;
+ if(y > end.y())
+ {
+ cy = y - end.y();
+ y = y - cy;
+ }
+ else
+ cy = end.y() - y;
+
+ //kdDebug(4640) << x << ", " << y << " - " << cx << " " << cy << endl;
+ pntarray.resize(0);
+ drawPointArray(a, Mark); // remove previous marking
+
+ int points = 0;
+ bool pasting = ispasting;
+
+ if(tool == FilledRect || (tool == SelectRect))
+ {
+ for(int i = x; i <= x + (pasting ? cx + 1 : cx); i++)
+ {
+ for(int j = y; j <= y+cy; j++, points++)
+ pntarray.putPoints(points, 1, i, j);
+ }
+ }
+ else
+ {
+ for(int i = x; i <= x+cx; i++, points++)
+ pntarray.putPoints(points, 1, i, y);
+ for(int i = y; i <= y+cy; i++, points++)
+ pntarray.putPoints(points, 1, x, i);
+ for(int i = x; i <= x+cx; i++, points++)
+ pntarray.putPoints(points, 1, i, y+cy);
+ for(int i = y; i <= y+cy; i++, points++)
+ pntarray.putPoints(points, 1, x+cx, i);
+ }
+
+ drawPointArray(pntarray, Mark);
+
+ if(tool == SelectRect && pntarray.size() > 0 && !ispasting)
+ emit selecteddata(true);
+}
+
+
+void KIconEditGrid::drawLine(bool drawit, bool drawStraight)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ QPointArray a(pntarray.copy());
+ pntarray.resize(0);
+
+ // remove previous marking
+ drawPointArray(a, Mark);
+
+ int x, y, dx, dy, delta;
+
+ dx = end.x() - start.x();
+ dy = end.y() - start.y();
+ x = start.x();
+ y = start.y();
+
+ delta = QMAX(abs(dx), abs(dy));
+ int deltaX = abs(dx);
+ int deltaY = abs(dy);
+
+ if ((drawStraight) && (delta > 0))
+ {
+ dx /= delta;
+ dy /= delta;
+
+ for(int i = 0; i <= delta; i++)
+ {
+ pntarray.putPoints(i, 1, x, y);
+ x += dx;
+ y += dy;
+ }
+ }
+
+ else if ((delta > 0) && (deltaX >= deltaY))
+ {
+ for(int i = 0; i <= deltaX; i++)
+ {
+ pntarray.putPoints(i, 1, x, y);
+
+ if(dx > 0)
+ x++;
+ else
+ x--;
+
+ if(dy >= 0)
+ y = start.y() + (abs(start.x() - x) * deltaY) / deltaX;
+ else
+ y = start.y() - (abs(start.x() - x) * deltaY) / deltaX;
+ }
+ }
+
+ else if ((delta > 0) && (deltaY > deltaX))
+ {
+ for(int i = 0; i <= deltaY; i++)
+ {
+ pntarray.putPoints(i, 1, x, y);
+
+ if(dy > 0)
+ y++;
+ else
+ y--;
+
+ if(dx >= 0)
+ x = start.x() + (abs(start.y() - y) * deltaX) / deltaY;
+ else
+ x = start.x() - (abs(start.y() - y) * deltaX) / deltaY;
+ }
+ }
+
+ drawPointArray(pntarray, Mark);
+}
+
+
+void KIconEditGrid::drawPointArray(QPointArray a, DrawAction action)
+{
+ QRect area( a.boundingRect().x()*cellSize()-1, a.boundingRect().y()*cellSize()-1,
+ a.boundingRect().width()*cellSize()+1, a.boundingRect().height()*cellSize()+1 );
+
+ KMacroCommand* macro = 0;
+ bool doupdate = false;
+
+ if( a.size() > 0 && action == Draw ) {
+ // might cause a memmory leak, if
+ // macro is never used and never
+ // added to the history! TODO: Fix this
+ macro = new KMacroCommand( i18n("Drawn Array") );
+ RepaintCommand* rc = new RepaintCommand( area, this );
+ macro->addCommand( rc );
+ }
+
+ int s = a.size(); //((rect.size().width()) * (rect.size().height()));
+ for(int i = 0; i < s; i++)
+ {
+ int x = a[i].x();
+ int y = a[i].y();
+
+ if(img->valid(x, y) && a.boundingRect().contains(a[ i ]))
+ {
+ //kdDebug(4640) << "x: " << x << " - y: " << y << endl;
+ switch( action )
+ {
+ case Draw:
+ {
+ DrawCommand* dc = new DrawCommand( x, y, currentcolor, img, this );
+ dc->execute();
+ //*((uint*)img->scanLine(y) + x) = currentcolor; //colors[cell]|OPAQUE;
+ //int cell = y * numCols() + x;
+ //setColor( cell, currentcolor, false );
+ doupdate = true;
+ //updateCell( y, x, FALSE );
+ macro->addCommand( dc );
+ break;
+ }
+
+ case Mark:
+ case UnMark:
+ update(x*cellsize,y*cellsize, cellsize, cellsize);
+ //updateCell( y, x, true );
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+
+ if(doupdate)
+ {
+ setModified( true );
+ updateColors();
+ RepaintCommand* rc = new RepaintCommand( area, this );
+ rc->execute();
+ macro->addCommand( rc );
+ pntarray.resize(0);
+ // add to undo/redo history
+ history->addCommand( macro, false ); }
+}
+
+void KIconEditGrid::updatePreviewPixmap()
+{
+ p = *img;
+ emit changed(QPixmap(p));
+}
+
+
+bool KIconEditGrid::isMarked(QPoint point)
+{
+ return isMarked(point.x(), point.y());
+}
+
+
+bool KIconEditGrid::isMarked(int x, int y)
+{
+ if(((y * numCols()) + x) == selected)
+ return true;
+
+ int s = pntarray.size();
+ for(int i = 0; i < s; i++)
+ {
+ if(y == pntarray[i].y() && x == pntarray[i].x())
+ return true;
+ }
+
+ return false;
+}
+
+
+// Fast diffuse dither to 3x3x3 color cube
+// Based on Qt's image conversion functions
+static bool kdither_32_to_8( const QImage *src, QImage *dst )
+{
+ register QRgb *p;
+ uchar *b;
+ int y;
+
+ //printf("kconvert_32_to_8\n");
+
+ if ( !dst->create(src->width(), src->height(), 8, 256) ) {
+ kdWarning() << "OImage: destination image not valid" << endl;
+ return FALSE;
+ }
+
+ int ncols = 256;
+
+ static uint bm[16][16];
+ static int init=0;
+ if (!init)
+ {
+ // Build a Bayer Matrix for dithering
+ init = 1;
+ int n, i, j;
+
+ bm[0][0]=0;
+
+ for (n=1; n<16; n*=2)
+ {
+ for (i=0; i<n; i++)
+ {
+ for (j=0; j<n; j++)
+ {
+ bm[i][j]*=4;
+ bm[i+n][j]=bm[i][j]+2;
+ bm[i][j+n]=bm[i][j]+3;
+ bm[i+n][j+n]=bm[i][j]+1;
+ }
+ }
+ }
+
+ for (i=0; i<16; i++)
+ for (j=0; j<16; j++)
+ bm[i][j]<<=8;
+ }
+
+ dst->setNumColors( ncols );
+
+#define MAX_R 2
+#define MAX_G 2
+#define MAX_B 2
+#define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b))
+
+ int rc, gc, bc;
+
+ for ( rc=0; rc<=MAX_R; rc++ ) // build 2x2x2 color cube
+ for ( gc=0; gc<=MAX_G; gc++ )
+ for ( bc=0; bc<=MAX_B; bc++ )
+ {
+ dst->setColor( INDEXOF(rc,gc,bc),
+ qRgb( rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B ) );
+ }
+
+ int sw = src->width();
+ int* line1[3];
+ int* line2[3];
+ int* pv[3];
+
+ line1[0] = new int[src->width()];
+ line2[0] = new int[src->width()];
+ line1[1] = new int[src->width()];
+ line2[1] = new int[src->width()];
+ line1[2] = new int[src->width()];
+ line2[2] = new int[src->width()];
+ pv[0] = new int[sw];
+ pv[1] = new int[sw];
+ pv[2] = new int[sw];
+
+ for ( y=0; y < src->height(); y++ )
+ {
+ p = (QRgb *)src->scanLine(y);
+ b = dst->scanLine(y);
+ int endian = (QImage::systemByteOrder() == QImage::BigEndian);
+ int x;
+ uchar* q = src->scanLine(y);
+ uchar* q2 = src->scanLine(y+1 < src->height() ? y + 1 : 0);
+ for (int chan = 0; chan < 3; chan++)
+ {
+ b = dst->scanLine(y);
+ int *l1 = (y&1) ? line2[chan] : line1[chan];
+ int *l2 = (y&1) ? line1[chan] : line2[chan];
+ if ( y == 0 )
+ {
+ for (int i=0; i<sw; i++)
+ l1[i] = q[i*4+chan+endian];
+ }
+ if ( y+1 < src->height() )
+ {
+ for (int i=0; i<sw; i++)
+ l2[i] = q2[i*4+chan+endian];
+ }
+ // Bi-directional error diffusion
+ if ( y&1 )
+ {
+ for (x=0; x<sw; x++)
+ {
+ int pix = QMAX(QMIN(2, (l1[x] * 2 + 128)/ 255), 0);
+ int err = l1[x] - pix * 255 / 2;
+ pv[chan][x] = pix;
+
+ // Spread the error around...
+ if ( x+1<sw )
+ {
+ l1[x+1] += (err*7)>>4;
+ l2[x+1] += err>>4;
+ }
+ l2[x]+=(err*5)>>4;
+ if (x>1)
+ l2[x-1]+=(err*3)>>4;
+ }
+ }
+ else
+ {
+ for (x=sw; x-->0; )
+ {
+ int pix = QMAX(QMIN(2, (l1[x] * 2 + 128)/ 255), 0);
+ int err = l1[x] - pix * 255 / 2;
+ pv[chan][x] = pix;
+
+ // Spread the error around...
+ if ( x > 0 )
+ {
+ l1[x-1] += (err*7)>>4;
+ l2[x-1] += err>>4;
+ }
+ l2[x]+=(err*5)>>4;
+ if (x+1 < sw)
+ l2[x+1]+=(err*3)>>4;
+ }
+ }
+ }
+ if (endian)
+ {
+ for (x=0; x<sw; x++)
+ {
+ *b++ = INDEXOF(pv[2][x],pv[1][x],pv[0][x]);
+ }
+ }
+ else
+ {
+ for (x=0; x<sw; x++)
+ {
+ *b++ = INDEXOF(pv[0][x],pv[1][x],pv[2][x]);
+ }
+ }
+ }
+
+ delete [] line1[0];
+ delete [] line2[0];
+ delete [] line1[1];
+ delete [] line2[1];
+ delete [] line1[2];
+ delete [] line2[2];
+ delete [] pv[0];
+ delete [] pv[1];
+ delete [] pv[2];
+
+#undef MAX_R
+#undef MAX_G
+#undef MAX_B
+#undef INDEXOF
+
+ return TRUE;
+}
+
+// this doesn't work the way it should but the way KPixmap does.
+void KIconEditGrid::mapToKDEPalette()
+{
+ QImage dest;
+
+ kdither_32_to_8(img, &dest);
+ *img = dest.convertDepth(32);
+
+ for(int y = 0; y < img->height(); y++)
+ {
+ uint *l = (uint*)img->scanLine(y);
+ for(int x = 0; x < img->width(); x++, l++)
+ {
+ if(*l < 0xff000000)
+ {
+ *l = *l | 0xff000000;
+ }
+ }
+ }
+
+ load(img);
+ return;
+
+/*
+#if QT_VERSION > 140
+ *img = img->convertDepthWithPalette(32, iconpalette, 42);
+ load(img);
+ return;
+#endif
+*/
+
+ QApplication::setOverrideCursor(waitCursor);
+ for(int y = 0; y < numRows(); y++)
+ {
+ uint *l = (uint*)img->scanLine(y);
+ for(int x = 0; x < numCols(); x++, l++)
+ {
+ if(*l != TRANSPARENT)
+ {
+ if(!iconcolors.contains(*l))
+ *l = iconcolors.closestMatch(*l);
+ }
+ }
+ }
+
+ load(img);
+ setModified(true);
+ QApplication::restoreOverrideCursor();
+}
+
+
+void KIconEditGrid::grayScale()
+{
+ for(int y = 0; y < numRows(); y++)
+ {
+ uint *l = (uint*)img->scanLine(y);
+ for(int x = 0; x < numCols(); x++, l++)
+ {
+ if(*l != TRANSPARENT)
+ {
+ uint c = qGray(*l);
+ *l = qRgba(c, c, c, qAlpha(*l));
+ }
+ }
+ }
+
+ load(img);
+ setModified(true);
+}
+
+
+void KIconEditGrid::clearImage(QImage *image)
+{
+ if(image->depth() != 32)
+ {
+ image->fill(TRANSPARENT);
+ }
+ else
+ {
+ // QImage::fill() does not set the alpha channel so do it
+ // manually.
+ for(int y = 0; y < image->height(); y++)
+ {
+ uint *l = (uint*)image->scanLine(y);
+ for(int x = 0; x < image->width(); x++, l++)
+ {
+ *l = TRANSPARENT;
+ }
+ }
+ }
+}
+
+
+void KIconEditGrid::setModified(bool m)
+{
+ if(m != modified)
+ {
+ modified = m;
+ emit modifiedchanged(m);
+ }
+}
+
+
+#include "kicongrid.moc"
+// vim: set ts=4:
diff --git a/kiconedit/kicongrid.h b/kiconedit/kicongrid.h
new file mode 100644
index 00000000..24730735
--- /dev/null
+++ b/kiconedit/kicongrid.h
@@ -0,0 +1,263 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KICONEDITGRID_H__
+#define __KICONEDITGRID_H__
+
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qcursor.h>
+#include <qpointarray.h>
+#include <qframe.h>
+#include <kcommand.h>
+#include <klocale.h>
+
+#include "kcolorgrid.h"
+
+class KCommandHistory;
+class KRuler;
+class KIconEditGrid;
+class QScrollView;
+
+enum Direction {
+ DirIn = 0, DirOut = 1,
+ DirUp = DirIn, DirDown = DirOut,
+ DirLeft, DirRight
+};
+
+class DrawCommand : public KCommand {
+ public:
+ DrawCommand( int xx, int yy, uint newcol, QImage* img, KIconEditGrid* g ) {
+ x = xx;
+ y = yy;
+ newcolor = newcol;
+ image = img;
+ grid = g;
+ }
+
+ void execute();
+ void unexecute();
+ QString name() const {
+ return i18n("Drawed Something");
+ }
+
+ protected:
+ int x;
+ int y;
+ uint newcolor;
+ uint oldcolor;
+ QImage* image;
+ KIconEditGrid* grid;
+};
+
+class RepaintCommand : public KCommand {
+ public:
+ RepaintCommand( QRect a, KIconEditGrid* g ) {
+ area = a;
+ grid = g;
+ }
+
+ void execute();
+ void unexecute() {
+ execute();
+ }
+
+ QString name() const {
+ return "repainted";
+ }
+ protected:
+ KIconEditGrid* grid;
+ QRect area;
+};
+
+class KGridView : public QFrame
+{
+ Q_OBJECT
+public:
+ KGridView( QImage *image, KCommandHistory* history, QWidget * parent = 0, const char *name = 0);
+
+ KRuler *hruler() { return _hruler;}
+ KRuler *vruler() { return _vruler;}
+ QFrame *corner() { return _corner;}
+ KIconEditGrid *grid() { return _grid; }
+ void setShowRulers(bool mode);
+ void setAcceptDrop(bool a);
+ const QRect viewRect();
+ QScrollView *viewPortWidget() { return viewport;}
+
+public slots:
+ void sizeChange(int, int);
+ void moving(int, int);
+ void scalingChange(int);
+ void paintGrid();
+ void checkClipboard();
+
+protected:
+ virtual void paintEvent(QPaintEvent*);
+ virtual void resizeEvent(QResizeEvent*);
+ void paintDropSite();
+ void setSizes();
+
+ QFrame *_corner;
+ KIconEditGrid *_grid;
+ KRuler *_hruler, *_vruler;
+ QScrollView *viewport;
+ bool acceptdrop;
+};
+
+/**
+* KIconEditGrid
+* @short KIconEditGrid
+* @author Thomas Tanghus <tanghus@kde.org>
+* @version 0.3
+*/
+class KIconEditGrid : public KColorGrid
+{
+ Q_OBJECT
+public:
+ KIconEditGrid( QImage *image, KCommandHistory* h, QWidget * parent = 0, const char *name = 0);
+ virtual ~KIconEditGrid();
+
+ enum DrawTool { Line, Freehand, FloodFill, Spray, Rect, FilledRect, Circle,
+ FilledCircle, Ellipse, FilledEllipse, Eraser, SelectRect, SelectCircle, Find };
+ enum DrawAction { Mark, UnMark, Draw };
+
+ void setGrid(bool g) { KColorGrid::setGrid(g); emit needPainting(); }
+ bool isModified() { return modified; };
+ void setModified(bool m);
+ const QPixmap &pixmap();
+ const QImage &image() { return *img; }
+ QImage clipboardImage(bool &ok);
+ QImage getSelection(bool);
+ int rows() { return numRows(); };
+ int cols() { return numCols(); };
+ uint getColors( uint *_colors) { return colors(_colors); }
+ bool isMarked(QPoint p);
+ bool isMarked(int x, int y);
+ int scaling() { return cellSize(); }
+ void loadBlank( int w = 0, int h = 0);
+ void setUndoColor( int colNum, uint v, bool update = true ) {
+ setColor( colNum, v, update );
+ };
+
+ enum TransparencyDisplayType
+ {
+ TRD_SOLIDCOLOR,
+ TRD_CHECKERBOARD
+ };
+ enum CheckerboardSize
+ {
+ CHK_SMALL = 0,
+ CHK_MEDIUM = 1,
+ CHK_LARGE = 2
+ };
+
+ TransparencyDisplayType transparencyDisplayType() const { return m_transparencyDisplayType; }
+ QColor checkerboardColor1() const { return m_checkerboardColor1; }
+ QColor checkerboardColor2() const { return m_checkerboardColor2; }
+ CheckerboardSize checkerboardSize() const { return m_checkerboardSize; }
+ QColor transparencySolidColor() const { return m_transparencySolidColor; }
+
+ void setTransparencyDisplayType(TransparencyDisplayType t) { m_transparencyDisplayType = t; }
+ void setCheckerboardColor1(const QColor& c) { m_checkerboardColor1 = c; }
+ void setCheckerboardColor2(const QColor& c) { m_checkerboardColor2 = c; }
+ void setCheckerboardSize(CheckerboardSize size) { m_checkerboardSize = size; }
+ void setTransparencySolidColor(const QColor& c) { m_transparencySolidColor = c; }
+
+public slots:
+ void load( QImage *);
+ void editCopy(bool cut = false);
+ void editPaste(bool paste = false);
+ void editPasteAsNew();
+ void editSelectAll();
+ void editClear();
+ void getImage(QImage *image);
+//#if QT_VERSION <= 140
+ void editResize();
+//#endif
+ void setSize(const QSize s);
+ void grayScale();
+ void mapToKDEPalette();
+ void setTool(DrawTool tool);
+ bool zoom(Direction direct);
+ bool zoomTo(int);
+
+ void checkClipboard();
+
+signals:
+ void scalingchanged(int);
+ void changed( const QPixmap & );
+ void sizechanged( int, int );
+ void poschanged( int, int );
+ void xposchanged( int );
+ void yposchanged( int );
+ void newmessage(const QString &);
+ void clipboarddata(bool);
+ void selecteddata(bool);
+ void needPainting();
+ void modifiedchanged(bool);
+ void colorSelected(uint);
+
+protected slots:
+ void setColorSelection( uint );
+ void updatePreviewPixmap();
+
+protected:
+ virtual void paintEvent(QPaintEvent*);
+ virtual void paintCell( QPainter*, int, int ) {}
+ virtual void paintForeground(QPainter* p, QPaintEvent* e);
+ virtual void mousePressEvent(QMouseEvent*);
+ virtual void mouseReleaseEvent(QMouseEvent*);
+ virtual void mouseMoveEvent(QMouseEvent*);
+ void createCursors();
+ void drawPointArray(QPointArray, DrawAction);
+ void drawEllipse(bool);
+ void drawLine(bool drawIt, bool drawStraight);
+ void drawRect(bool);
+ void drawSpray(QPoint);
+ void drawFlood(int x, int y, uint oldcolor);
+ static void clearImage(QImage *image);
+
+ uint currentcolor;
+ QPoint start, end;
+ QRect insrect;
+ QSize cbsize;
+ QImage *img;
+ QPixmap p;
+ int selected, tool; //, numrows, numcols;
+ bool modified, btndown, ispasting, isselecting;
+ QPointArray pntarray;
+ KColorArray iconcolors;
+ KCommandHistory* history;
+ KMacroCommand* m_command;
+ QCursor cursor_normal, cursor_aim, cursor_flood, cursor_spray, cursor_erase, cursor_paint, cursor_colorpicker;
+ TransparencyDisplayType m_transparencyDisplayType;
+ QColor m_checkerboardColor1;
+ QColor m_checkerboardColor2;
+ CheckerboardSize m_checkerboardSize;
+ QColor m_transparencySolidColor;
+};
+
+
+
+#endif //__KICONEDITGRID_H__
+
+
+
diff --git a/kiconedit/knew.cpp b/kiconedit/knew.cpp
new file mode 100644
index 00000000..214952b0
--- /dev/null
+++ b/kiconedit/knew.cpp
@@ -0,0 +1,326 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <qlayout.h>
+#include <qpainter.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qpushbutton.h>
+
+#include <kconfig.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <kapplication.h>
+
+#include "knew.h"
+
+KIconTemplateContainer* KIconTemplateContainer::instance = 0;
+
+void createStandardTemplates(KIconTemplateContainer *list)
+{
+ KIconLoader *kil = KGlobal::iconLoader();
+
+ KIconTemplate it;
+ it.path = kil->iconPath("standard", KIcon::User);
+ it.title = i18n("Standard File");
+ list->append(it);
+
+ it.path = kil->iconPath("source", KIcon::User);
+ it.title = i18n("Source File");
+ list->append(it);
+
+ it.path = kil->iconPath("compressed", KIcon::User);
+ it.title = i18n("Compressed File");
+ list->append(it);
+
+ it.path = kil->iconPath("folder", KIcon::User);
+ it.title = i18n("Standard Folder");
+ list->append(it);
+
+ it.path = kil->iconPath("package", KIcon::User);
+ it.title = i18n("Standard Package");
+ list->append(it);
+
+ it.path = kil->iconPath("mini-folder", KIcon::User);
+ it.title = i18n("Mini Folder");
+ list->append(it);
+
+ it.path = kil->iconPath("mini-package", KIcon::User);
+ it.title = i18n("Mini Package");
+ list->append(it);
+}
+
+void KIconTemplateContainer::save()
+{
+ KConfig *k = kapp->config();
+ k->setGroup("Templates");
+
+ QStringList names;
+ for (QValueListIterator<KIconTemplate> iter = begin(); iter != end(); iter++)
+ {
+ names.append((*iter).title);
+ }
+
+ k->writeEntry("Names", names);
+
+ for(unsigned int i = 0; i < names.count(); i++)
+ {
+ k->writePathEntry(names[i], (*this)[i].path);
+ }
+}
+
+KIconTemplateContainer::KIconTemplateContainer() : QValueList<KIconTemplate>()
+{
+ QStrList names;
+ KConfig *k = kapp->config();
+ k->setGroup("Templates");
+ k->readListEntry("Names", names);
+ for(int i = 0; i < (int)names.count(); i++)
+ {
+ KIconTemplate it;
+ it.path = k->readPathEntry(names.at(i));
+ it.title = names.at(i);
+ //kdDebug(4640) << "Template: " << names.at(i) << "\n" << path.data() << endl;
+ append(it);
+ }
+
+ if(count() == 0)
+ {
+ createStandardTemplates(this);
+ }
+}
+
+KIconTemplateContainer::~KIconTemplateContainer()
+{
+ clear();
+}
+
+KIconListBoxItem::KIconListBoxItem( KIconTemplate t )
+ : QListBoxItem(), icontemplate(t)
+{
+ //kdDebug(4640) << "KIconListBoxItem - " << t->path.data() << ", " << t->title.data() << endl;
+
+ pm.load(t.path);
+ setText( t.title );
+}
+
+void KIconListBoxItem::reloadIcon()
+{
+ pm.load(icontemplate.path);
+ setText( icontemplate.title );
+}
+
+
+
+void KIconListBoxItem::paint( QPainter *p )
+{
+ p->drawPixmap( 3, 0, pm );
+ QFontMetrics fm = p->fontMetrics();
+ int yPos; // vertical text position
+ if ( pm.height() < fm.height() )
+ yPos = fm.ascent() + fm.leading()/2;
+ else
+ yPos = pm.height()/2 - fm.height()/2 + fm.ascent();
+ p->drawText( pm.width() + 5, yPos, text() );
+}
+
+int KIconListBoxItem::height(const QListBox *lb ) const
+{
+ return QMAX( pm.height(), lb->fontMetrics().lineSpacing() + 1 );
+}
+
+int KIconListBoxItem::width(const QListBox *lb ) const
+{
+ return pm.width() + lb->fontMetrics().width( text() ) + 6;
+}
+
+NewSelect::NewSelect(QWidget *parent) : QWidget( parent )
+{
+ wiz = (KWizard*) parent;
+ grp = new QButtonGroup( this );
+ connect( grp, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) );
+ grp->setExclusive( true );
+
+ QVBoxLayout* ml = new QVBoxLayout( this );
+ ml->addWidget( grp, 1 );
+ //ml->addWidget(grp, 10, AlignLeft);
+ QVBoxLayout* l = new QVBoxLayout( grp, 10 );
+
+ rbscratch = new QRadioButton( i18n( "Create from scratch" ), grp );
+ l->addWidget( rbscratch, 1 );
+ //l->addWidget(rbscratch, 5, AlignLeft);
+
+ rbtempl = new QRadioButton( i18n( "Create from template" ), grp );
+ l->addWidget( rbtempl, 1 );
+ //l->addWidget(rbtempl, 5, AlignLeft);
+
+ //grp->setMinimumSize(grp->childrenRect().size());
+
+ grp->setButton( 0 );
+}
+
+NewSelect::~NewSelect()
+{
+}
+
+void NewSelect::buttonClicked(int id)
+{
+ //kdDebug(4640) << "Button: " << id << endl;
+
+ emit iconopenstyle(id);
+}
+
+NewFromTemplate::NewFromTemplate( QWidget* parent )
+ : QWidget( parent )
+{
+ wiz = (KWizard*) parent;
+
+ QVBoxLayout* ml = new QVBoxLayout(this);
+
+ grp = new QGroupBox( i18n( "Templates" ), this );
+ ml->addWidget( grp, 1 );
+ //ml->addWidget(grp, 10, AlignLeft);
+
+ QHBoxLayout* l = new QHBoxLayout( grp, 15 );
+
+ templates = new KIconListBox( grp );
+ connect( templates, SIGNAL( highlighted( int ) ), SLOT( checkSelection( int ) ) );
+ l->addWidget( templates );
+
+ for( int i = 0; i < (int) KIconTemplateContainer::self()->count(); i++ )
+ templates->insertItem( new KIconListBoxItem( *KIconTemplateContainer::self()->at( i ) ) );
+}
+
+NewFromTemplate::~NewFromTemplate()
+{
+}
+
+void NewFromTemplate::checkSelection( int )
+{
+ //kdDebug(4640) << "checkSelection(int) " << templates->currentItem() << endl;
+ if( templates->currentItem() != -1 )
+ wiz->finishButton()->setEnabled( true );
+ else
+ wiz->finishButton()->setEnabled( false );
+}
+
+KNewIcon::KNewIcon( QWidget* parent )
+ : KWizard( parent, 0, true )
+{
+ //kdDebug(4640) << "KNewIcon" << endl;
+ setCaption( i18n( "Create New Icon" ) );
+ resize( 400, 250 );
+
+ openstyle = 0;
+
+ finishButton()->setEnabled( true );
+ cancelButton()->setEnabled( true );
+ nextButton()->setEnabled( false );
+
+ select = new NewSelect( this );
+ connect( select, SIGNAL( iconopenstyle( int ) ), SLOT( iconOpenStyle( int ) ) );
+
+ scratch = new KResizeWidget( this, 0, QSize( 32, 32 ) );
+ // this doesn't accept default valid size, besides spin buttons won't allow
+ // an invalid size to be set by the user - forces user to change valid default
+ // size to create the new icon object -
+ connect( scratch, SIGNAL( validSize( bool ) ), SLOT( checkPage( bool ) ) );
+ connect(this, SIGNAL(selected(const QString &)), this, SLOT(checkPage(const QString &)));
+ templ = new NewFromTemplate(this);
+ templ->hide();
+
+ addPage(select, i18n("Select Icon Type"));
+ addPage(scratch, i18n("Create From Scratch"));
+ act = scratch;
+ //addPage(templ, i18n("Create From Template"));
+}
+
+KNewIcon::~KNewIcon()
+{
+ delete select;
+ delete scratch;
+ delete templ;
+}
+
+void KNewIcon::okClicked()
+{
+ if(openstyle == Blank)
+ emit newicon(scratch->getSize());
+ else
+ emit newicon(templ->path());
+ hide();
+ setResult(1);
+ accept();
+}
+
+void KNewIcon::cancelClicked()
+{
+ hide();
+ setResult(0);
+ reject();
+}
+
+void KNewIcon::iconOpenStyle(int style)
+{
+ openstyle = style;
+
+ if( act )
+ removePage( act );
+
+ if(openstyle == Blank)
+ {
+ act = scratch;
+ setNextEnabled( act, true );
+ addPage( scratch, i18n( "Create From Scratch" ) );
+ }
+ else if( openstyle == Template )
+ {
+ act = templ;
+ setNextEnabled( act, true );
+ addPage( templ, i18n( "Create From Template" ) );
+ }
+}
+
+void KNewIcon::checkPage( bool b)
+{
+ //kdDebug(4640) << "checkPage(int) " << openstyle << " " << p << endl;
+ if(openstyle == Blank)
+ finishButton()->setEnabled(true);
+ else if( !b )
+ finishButton()->setEnabled(false);
+ else
+ templ->checkSelection(0);
+}
+
+void KNewIcon::checkPage(const QString &)
+{
+ if(currentPage() == select || openstyle == Blank)
+ finishButton()->setEnabled(true);
+ else
+ finishButton()->setEnabled(false);
+}
+#include "knew.moc"
+
+
+
+
+
diff --git a/kiconedit/knew.h b/kiconedit/knew.h
new file mode 100644
index 00000000..8801faf7
--- /dev/null
+++ b/kiconedit/knew.h
@@ -0,0 +1,164 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KNEWICON_H__
+#define __KNEWICON_H__
+
+#include <qwidget.h>
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qlistbox.h>
+
+#include <kwizard.h>
+
+#include "kresize.h"
+
+class KIconListBox;
+class KIconTemplateContainer;
+class QButtonGroup;
+class QRadioButton;
+class QGroupBox;
+
+struct KIconTemplate
+{
+ QString path;
+ QString title;
+};
+
+class KIconListBoxItem : public QListBoxItem
+{
+public:
+ KIconListBoxItem( KIconTemplate );
+
+
+ const QString path() { return icontemplate.path; }
+ KIconTemplate& iconTemplate() { return icontemplate; }
+ void reloadIcon();
+
+protected:
+ virtual void paint( QPainter * );
+ virtual int height( const QListBox * ) const;
+ virtual int width( const QListBox * ) const;
+private:
+ QPixmap pm;
+ KIconTemplate icontemplate;
+};
+
+class KIconListBox : public QListBox
+{
+ Q_OBJECT
+public:
+ KIconListBox( QWidget *parent ) : QListBox(parent) {} ;
+ const QString path(int idx) { return ((KIconListBoxItem*)item(idx))->path(); }
+ KIconTemplate& iconTemplate(int idx) { return ((KIconListBoxItem*)item(idx))->iconTemplate(); }
+
+};
+
+class KIconTemplateContainer : public QValueList<KIconTemplate>
+{
+public:
+ static KIconTemplateContainer* self()
+ {
+ if (!instance)
+ instance = new KIconTemplateContainer;
+ return instance;
+ }
+
+ void save();
+
+private:
+ static KIconTemplateContainer* instance;
+
+ const KIconTemplateContainer operator = (const KIconTemplateContainer&);
+ KIconTemplateContainer(const KIconTemplateContainer&);
+
+ KIconTemplateContainer();
+ ~KIconTemplateContainer();
+};
+
+class NewSelect : public QWidget
+{
+ Q_OBJECT
+public:
+ NewSelect(QWidget *parent);
+ ~NewSelect();
+
+signals:
+ void iconopenstyle(int);
+
+protected slots:
+ void buttonClicked(int);
+
+protected:
+ KWizard *wiz;
+ QButtonGroup *grp;
+ QRadioButton *rbscratch, *rbtempl;
+};
+
+class NewFromTemplate : public QWidget
+{
+ Q_OBJECT
+public:
+ NewFromTemplate(QWidget *parent);
+ ~NewFromTemplate();
+
+ const QString path() { return QString(templates->path(templates->currentItem())); }
+
+public slots:
+ void checkSelection(int);
+
+protected:
+ KIconListBox *templates;
+ KWizard *wiz;
+ QGroupBox *grp;
+};
+
+class KNewIcon : public KWizard
+{
+ Q_OBJECT
+public:
+ KNewIcon(QWidget *parent);
+ ~KNewIcon();
+
+ enum { Blank = 0, Template = 1};
+ int openStyle() { return openstyle; }
+ const QString templatePath() { return QString(templ->path()); }
+ const QSize templateSize() { return scratch->getSize(); }
+
+protected slots:
+ void okClicked();
+ void cancelClicked();
+ void iconOpenStyle(int);
+ void checkPage(bool);
+ void checkPage(const QString &);
+
+signals:
+ void newicon(const QSize);
+ void newicon(const QString);
+
+protected:
+ NewSelect *select;
+ KResizeWidget *scratch;
+ NewFromTemplate *templ;
+ QWidget *act;
+ int openstyle;
+};
+
+#endif // __KNEWICON_H__
diff --git a/kiconedit/kresize.cpp b/kiconedit/kresize.cpp
new file mode 100644
index 00000000..82a86ee3
--- /dev/null
+++ b/kiconedit/kresize.cpp
@@ -0,0 +1,83 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+ Copyright (C) 2002 Nadeem Hasan ( nhasan@kde.org )
+
+ 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 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 <qlabel.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+
+#include <klocale.h>
+#include <knuminput.h>
+
+#include "kresize.h"
+
+KResizeWidget::KResizeWidget( QWidget* parent, const char* name,
+ const QSize& size ) : QWidget( parent, name )
+{
+ QHBoxLayout* genLayout = new QHBoxLayout( this );
+
+ QGroupBox* group = new QGroupBox( i18n( "Size" ), this );
+ group->setColumnLayout( 0, Qt::Horizontal );
+ genLayout->addWidget( group );
+
+ QHBoxLayout* layout = new QHBoxLayout( group->layout(), 6 );
+
+ m_width = new KIntSpinBox( 1, 200, 1, 1, 10, group );
+ m_width->setValue( size.width() );
+ layout->addWidget( m_width, 1 );
+
+ QLabel* label = new QLabel( "X", group );
+ layout->addWidget( label );
+
+ m_height = new KIntSpinBox( 1, 200, 1, 1, 10, group);
+ m_height->setValue( size.height() );
+ layout->addWidget( m_height, 1 );
+
+ setMinimumSize( 200, 100 );
+}
+
+KResizeWidget::~KResizeWidget()
+{
+}
+
+const QSize KResizeWidget::getSize()
+{
+ return QSize( m_width->value(), m_height->value() );
+}
+
+KResizeDialog::KResizeDialog( QWidget* parent, const char* name,
+ const QSize size )
+ : KDialogBase( parent, name, true, i18n( "Select Size" ), Ok|Cancel )
+{
+ m_resize = new KResizeWidget( this, "resize widget", size );
+
+ setMainWidget( m_resize );
+}
+
+KResizeDialog::~KResizeDialog()
+{
+}
+
+const QSize KResizeDialog::getSize()
+{
+ return m_resize->getSize();
+}
+
+#include "kresize.moc"
diff --git a/kiconedit/kresize.h b/kiconedit/kresize.h
new file mode 100644
index 00000000..691a4bd9
--- /dev/null
+++ b/kiconedit/kresize.h
@@ -0,0 +1,62 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+ Copyright ( C ) 2002 Nadeem Hasan ( nhasan@kde.org )
+
+ 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 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 __KRESIZE_H__
+#define __KRESIZE_H__
+
+#include <kdialogbase.h>
+
+class KIntSpinBox;
+
+class KResizeWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ KResizeWidget( QWidget* parent, const char* name, const QSize& );
+ ~KResizeWidget();
+
+ const QSize getSize();
+
+private:
+
+ KIntSpinBox *m_width;
+ KIntSpinBox *m_height;
+};
+
+class KResizeDialog : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+
+ KResizeDialog( QWidget* parent, const char* name, const QSize s );
+ ~KResizeDialog();
+
+ const QSize getSize();
+
+private:
+
+ KResizeWidget* m_resize;
+};
+
+#endif //__KRESIZE_H__
diff --git a/kiconedit/main.cpp b/kiconedit/main.cpp
new file mode 100644
index 00000000..52abdd09
--- /dev/null
+++ b/kiconedit/main.cpp
@@ -0,0 +1,89 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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.
+*/
+
+// A lot of this code is lifted from KMail. Thanks, guys!
+
+#include <stdlib.h>
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+
+#include "kiconedit.h"
+#include "config.h"
+#include "properties.h"
+
+static const char description[] =
+ I18N_NOOP("KDE Icon Editor");
+
+static KCmdLineOptions options[] =
+{
+ { "+[file(s)]" , I18N_NOOP("Icon file(s) to open"), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KAboutData aboutData( "kiconedit", I18N_NOOP("KIconEdit"),
+ VERSION, description, KAboutData::License_GPL,
+ "(c) 1998, Thomas Tanghus");
+
+ aboutData.addAuthor("Thomas Tanghus",0, "tanghus@kde.org");
+ aboutData.addAuthor("John Califf",0, "jcaliff@compuzone.net");
+ aboutData.addAuthor("Laurent Montel",0, "lmontel@mandrakesoft.com");
+ aboutData.addAuthor("Aaron J. Seigo",0, "aseigo@olympusproject.org");
+ aboutData.addCredit( "Nadeem Hasan", "Rewrote UI to use XMLGUI\n"
+ "Lots of fixes and cleanup", "nhasan@nadmm.com" );
+ aboutData.addCredit( "Adrian Page", I18N_NOOP("Bug fixes and GUI tidy up"),
+ "Adrian.Page@tesco.net" );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ KApplication a;
+
+// setSignalHandler(signalHandler);
+
+ if (a.isRestored())
+ {
+ RESTORE(KIconEdit);
+ }
+ else
+ {
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ for(int i = 0; i < args->count(); i++)
+ {
+ KIconEdit *ki = new KIconEdit(args->url(i), "kiconedit");
+ Q_CHECK_PTR(ki);
+ }
+
+ if (args->count() == 0)
+ {
+ KIconEdit *ki = new KIconEdit;
+ Q_CHECK_PTR(ki);
+ }
+ args->clear();
+ }
+
+ int rc = a.exec();
+ delete KIconEditProperties::self();
+ return rc;
+}
+
diff --git a/kiconedit/palettetoolbar.cpp b/kiconedit/palettetoolbar.cpp
new file mode 100644
index 00000000..207442e1
--- /dev/null
+++ b/kiconedit/palettetoolbar.cpp
@@ -0,0 +1,178 @@
+/*
+ kiconedit - a small graphics drawing program for the KDE
+ Copyright ( C ) 1998 Thomas Tanghus ( tanghus@kde.org )
+ Copyright ( C ) 2002 Nadeem Hasan ( nhasan@kde.org )
+
+ 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 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 <qlabel.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include <qpainter.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "kiconcolors.h"
+#include "palettetoolbar.h"
+
+PaletteToolBar::PaletteToolBar( QWidget *parent, const char *name )
+ : KToolBar( parent, name )
+{
+ QWidget *base = new QWidget( this );
+
+ QBoxLayout::Direction d = orientation() == Qt::Horizontal?
+ QBoxLayout::LeftToRight : QBoxLayout::TopToBottom;
+ m_layout = new QBoxLayout( base, d, 2, 6 );
+
+ m_lblPreview = new QLabel( base );
+ m_lblPreview->setFrameStyle( QFrame::Panel|QFrame::Sunken );
+ m_lblPreview->setFixedHeight( 64 );
+ m_lblPreview->setAlignment( Qt::AlignHCenter|Qt::AlignVCenter );
+ QWhatsThis::add(m_lblPreview, i18n( "Preview\n\nThis is a 1:1 preview"
+ " of the current icon" ) );
+ m_layout->addWidget( m_lblPreview );
+
+ m_currentColorView = new QLabel( base );
+ m_currentColorView->setFrameStyle( QFrame::Panel|QFrame::Sunken );
+ m_currentColorView->setFixedHeight( 24 );
+ m_currentColorView->setAlignment( Qt::AlignHCenter|Qt::AlignVCenter );
+ QWhatsThis::add(m_currentColorView, i18n( "Current color\n\nThis is the currently selected color" ) );
+ m_layout->addWidget( m_currentColorView );
+
+ QVBoxLayout *vlayout = new QVBoxLayout( m_layout, 0 );
+ QLabel *l = new QLabel( i18n( "System colors:" ), base );
+ vlayout->addWidget( l );
+ m_sysColors = new KSysColors( base );
+ QWhatsThis::add(m_sysColors, i18n( "System colors\n\nHere you can select"
+ " colors from the KDE icon palette" ) );
+
+ vlayout->addWidget( m_sysColors );
+
+ connect( m_sysColors, SIGNAL( newColor(uint) ),
+ SIGNAL( newColor(uint) ) );
+
+ vlayout = new QVBoxLayout( m_layout, 0 );
+ l = new QLabel( i18n( "Custom colors:" ), base );
+ vlayout->addWidget( l );
+ m_customColors = new KCustomColors( base );
+ QWhatsThis::add(m_customColors, i18n( "Custom colors\n\nHere you can"
+ " build a palette of custom colors.\nDouble-click on a box to edit"
+ " the color" ) );
+
+ vlayout->addWidget( m_customColors );
+
+ connect( m_customColors, SIGNAL( newColor(uint) ),
+ SIGNAL( newColor(uint) ) );
+ connect( this, SIGNAL( newColor(uint)),
+ this, SLOT(currentColorChanged(uint)));
+ currentColorChanged(OPAQUE_MASK|0);
+
+ setEnableContextMenu( false );
+ setMovingEnabled( false );
+}
+
+void PaletteToolBar::setOrientation( Orientation o )
+{
+ if( barPos() == Floating )
+ o = o == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
+
+ QBoxLayout::Direction d = o == Qt::Horizontal? QBoxLayout::LeftToRight
+ : QBoxLayout::TopToBottom;
+ m_layout->setDirection( d );
+
+ QDockWindow::setOrientation( o );
+}
+
+void PaletteToolBar::previewChanged( const QPixmap &p )
+{
+ m_lblPreview->setPixmap( p );
+}
+
+void PaletteToolBar::addColors( uint n, uint *c )
+{
+ m_customColors->clear();
+ for( uint i = 0; i < n; i++ )
+ addColor( c[ i ] );
+}
+
+void PaletteToolBar::addColor( uint color )
+{
+ if( !m_sysColors->contains( color ) )
+ m_customColors->addColor( color );
+}
+
+void PaletteToolBar::setPreviewBackground( QPixmap pixmap )
+{
+ m_lblPreview->setBackgroundPixmap(pixmap);
+}
+
+void PaletteToolBar::setPreviewBackground( const QColor& colour )
+{
+ m_lblPreview->setBackgroundColor(colour);
+}
+
+void PaletteToolBar::currentColorChanged(uint color)
+{
+ if(qAlpha(color) == 255)
+ {
+ m_currentColorView->setBackgroundColor(color);
+ }
+ else
+ {
+ // Show the colour as if drawn over a checkerboard pattern
+ const int squareWidth = 8;
+ const uint lightColour = qRgb(255, 255, 255);
+ const uint darkColour = qRgb(127, 127, 127);
+
+ QPixmap pm(2 * squareWidth, 2 * squareWidth);
+ QPainter p(&pm);
+
+ double alpha = qAlpha(color) / 255.0;
+
+ int r = int(qRed(color) * alpha + (1 - alpha) * qRed(lightColour) + 0.5);
+ int g = int(qGreen(color) * alpha + (1 - alpha) * qGreen(lightColour) + 0.5);
+ int b = int(qBlue(color) * alpha + (1 - alpha) * qBlue(lightColour) + 0.5);
+
+ uint squareColour = qRgb(r, g, b);
+
+ p.setPen(Qt::NoPen);
+ p.setBrush(squareColour);
+ p.drawRect(0, 0, squareWidth, squareWidth);
+ p.drawRect(squareWidth, squareWidth, squareWidth, squareWidth);
+
+ r = int(qRed(color) * alpha + (1 - alpha) * qRed(darkColour) + 0.5);
+ g = int(qGreen(color) * alpha + (1 - alpha) * qGreen(darkColour) + 0.5);
+ b = int(qBlue(color) * alpha + (1 - alpha) * qBlue(darkColour) + 0.5);
+
+ squareColour = qRgb(r, g, b);
+
+ p.setBrush(squareColour);
+ p.drawRect(squareWidth, 0, squareWidth, squareWidth);
+ p.drawRect(0, squareWidth, squareWidth, squareWidth);
+
+ p.end();
+
+ m_currentColorView->setBackgroundPixmap(pm);
+ }
+}
+
+#include "palettetoolbar.moc"
+
+/* vim: et sw=2 ts=2
+*/
+
diff --git a/kiconedit/palettetoolbar.h b/kiconedit/palettetoolbar.h
new file mode 100644
index 00000000..83cb3960
--- /dev/null
+++ b/kiconedit/palettetoolbar.h
@@ -0,0 +1,63 @@
+/*
+ kiconedit - a small graphics drawing program for the KDE
+ Copyright ( C ) 1998 Thomas Tanghus ( tanghus@kde.org )
+ Copyright ( C ) 2002 Nadeem Hasan ( nhasan@kde.org )
+
+ 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 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 PALLETTETOOLBAR_H
+#define PALLETTETOOLBAR_H
+
+#include <ktoolbar.h>
+
+class QBoxLayout;
+class QLabel;
+class KSysColors;
+class KCustomColors;
+
+class PaletteToolBar : public KToolBar
+{
+ Q_OBJECT
+
+ public:
+ PaletteToolBar( QWidget *parent, const char *name = 0L );
+
+ signals:
+ void newColor( uint c );
+
+ public slots:
+ virtual void setOrientation( Orientation o );
+ void previewChanged( const QPixmap &p );
+ void addColors( uint n, uint *c );
+ void addColor( uint color );
+ void setPreviewBackground( QPixmap pixmap );
+ void setPreviewBackground( const QColor& colour );
+ void currentColorChanged(uint color);
+
+ private:
+ QBoxLayout *m_layout;
+ QLabel *m_lblPreview;
+ QLabel *m_currentColorView;
+ KSysColors *m_sysColors;
+ KCustomColors *m_customColors;
+};
+
+#endif // PALLETTETOOLBAR_H
+
+/* vim: et sw=2 ts=2
+*/
+
diff --git a/kiconedit/pics/Makefile.am b/kiconedit/pics/Makefile.am
new file mode 100644
index 00000000..1a0b167e
--- /dev/null
+++ b/kiconedit/pics/Makefile.am
@@ -0,0 +1,5 @@
+
+SUBDIRS = icons toolbar
+
+KDE_ICON = kiconedit
+
diff --git a/kiconedit/pics/hi16-app-kiconedit.png b/kiconedit/pics/hi16-app-kiconedit.png
new file mode 100644
index 00000000..ff16bcae
--- /dev/null
+++ b/kiconedit/pics/hi16-app-kiconedit.png
Binary files differ
diff --git a/kiconedit/pics/hi22-app-kiconedit.png b/kiconedit/pics/hi22-app-kiconedit.png
new file mode 100644
index 00000000..8bb080c7
--- /dev/null
+++ b/kiconedit/pics/hi22-app-kiconedit.png
Binary files differ
diff --git a/kiconedit/pics/hi32-app-kiconedit.png b/kiconedit/pics/hi32-app-kiconedit.png
new file mode 100644
index 00000000..604b17dd
--- /dev/null
+++ b/kiconedit/pics/hi32-app-kiconedit.png
Binary files differ
diff --git a/kiconedit/pics/hi48-app-kiconedit.png b/kiconedit/pics/hi48-app-kiconedit.png
new file mode 100644
index 00000000..b95bffae
--- /dev/null
+++ b/kiconedit/pics/hi48-app-kiconedit.png
Binary files differ
diff --git a/kiconedit/pics/icons/Makefile.am b/kiconedit/pics/icons/Makefile.am
new file mode 100644
index 00000000..4acb372f
--- /dev/null
+++ b/kiconedit/pics/icons/Makefile.am
@@ -0,0 +1,5 @@
+pics_DATA = source.png \
+ standard.png \
+ compressed.png
+
+picsdir = $(kde_datadir)/kiconedit/pics
diff --git a/kiconedit/pics/icons/compressed.png b/kiconedit/pics/icons/compressed.png
new file mode 100644
index 00000000..c919f3bf
--- /dev/null
+++ b/kiconedit/pics/icons/compressed.png
Binary files differ
diff --git a/kiconedit/pics/icons/source.png b/kiconedit/pics/icons/source.png
new file mode 100644
index 00000000..8351e380
--- /dev/null
+++ b/kiconedit/pics/icons/source.png
Binary files differ
diff --git a/kiconedit/pics/icons/standard.png b/kiconedit/pics/icons/standard.png
new file mode 100644
index 00000000..df1e8318
--- /dev/null
+++ b/kiconedit/pics/icons/standard.png
Binary files differ
diff --git a/kiconedit/pics/logo.xpm b/kiconedit/pics/logo.xpm
new file mode 100644
index 00000000..97dab29d
--- /dev/null
+++ b/kiconedit/pics/logo.xpm
@@ -0,0 +1,137 @@
+/* XPM */
+static const char *logo[]={
+"260 87 47 1",
+"J c #9e9e9e",
+"b c #9f9f9f",
+"f c #a0a0a0",
+"I c #a1a1a1",
+"c c #a2a2a2",
+"B c #a3a3a3",
+"G c #a4a4a4",
+"O c #a5a5a5",
+"a c #a6a6a6",
+"v c #a7a7a7",
+"N c #a8a8a8",
+"R c #a9a9a9",
+"z c #aaaaaa",
+"p c #ababab",
+"w c #acacac",
+"t c #adadad",
+"Q c #aeaeae",
+"P c #afafaf",
+"o c #b0b0b0",
+"S c #b1b1b1",
+"K c #b2b2b2",
+"C c #b3b3b3",
+"M c #b4b4b4",
+"s c #b5b5b5",
+"k c #b6b6b6",
+"n c #b7b7b7",
+"H c #b8b8b8",
+"A c #b9b9b9",
+"d c #bababa",
+"u c #bbbbbb",
+"x c #bcbcbc",
+"l c #bdbdbd",
+"q c #bebebe",
+"r c #bfbfbf",
+"e c #c0c0c0",
+"D c #c1c1c1",
+"E c #c2c2c2",
+"L c #c3c3c3",
+"F c #c4c4c4",
+"i c #c5c5c5",
+"h c #c6c6c6",
+"# c #c7c7c7",
+"j c #c8c8c8",
+"y c #c9c9c9",
+"g c #cacaca",
+"m c #cbcbcb",
+". c #cccccc",
+"....................#abcdebfg.hbijklm...................................#abcdebfg.hbijklm...................................#abcdebfg.hbijklm...................................#abcdebfg.hbijklm...................................#abcdebfg.hbijklm...............",
+"................gni.opqrcstbu..vd...................................gni.opqrcstbu..vd...................................gni.opqrcstbu..vd...................................gni.opqrcstbu..vd...................................gni.opqrcstbu..vd...................",
+"................qbu.wk..qbxbv..y....................................qbu.wk..qbxbv..y....................................qbu.wk..qbxbv..y....................................qbu.wk..qbxbv..y....................................qbu.wk..qbxbv..y....................",
+"........iszA....qB..svm..vsCbr.........Dd.sE................iszA....qB..svm..vsCbr.........Dd.sE................iszA....qB..svm..vsCbr.........Dd.sE................iszA....qB..svm..vsCbr.........Dd.sE................iszA....qB..svm..vsCbr.........Dd.sE........",
+"........sbbl.#..Ffg.jGog.zp.l#.........jh.Hp................sbbl.#..Ffg.jGog.zp.l#.........jh.Hp................sbbl.#..Ffg.jGog.zp.l#.........jh.Hp................sbbl.#..Ffg.jGog.zp.l#.........jh.Hp................sbbl.#..Ffg.jGog.zp.l#.........jh.Hp........",
+".....dm.obbFmfH.mBu..iaIvbq...............yIE............dm.obbFmfH.mBu..iaIvbq...............yIE............dm.obbFmfH.mBu..iaIvbq...............yIE............dm.obbFmfH.mBu..iaIvbq...............yIE............dm.obbFmfH.mBu..iaIvbq...............yIE.......",
+"...#pbu.pbJg.CbE.sGg.AKunL.................MNrKj.......#pbu.pbJg.CbE.sGg.AKunL.................MNrKj.......#pbu.pbJg.CbE.sGg.AKunL.................MNrKj.......#pbu.pbJg.CbE.sGg.AKunL.................MNrKj.......#pbu.pbJg.CbE.sGg.AKunL.................MNrKj....",
+"...EJbGmabB..ycp.#ONHBE....................#ffHg.......EJbGmabB..ycp.#ONHBE....................#ffHg.......EJbGmabB..ycp.#ONHBE....................#ffHg.......EJbGmabB..ycp.#ONHBE....................#ffHg.......EJbGmabB..ycp.#ONHBE....................#ffHg....",
+"....PbbHfbGh..xbHDOswq..............NF......acg.........PbbHfbGh..xbHDOswq..............NF......acg.........PbbHfbGh..xbHDOswq..............NF......acg.........PbbHfbGh..xbHDOswq..............NF......acg.........PbbHfbGh..xbHDOswq..............NF......acg.....",
+".hDixfbcbbbbwD.nbbz.................pp......jGC......hDixfbcbbbbwD.nbbz.................pp......jGC......hDixfbcbbbbwD.nbbz.................pp......jGC......hDixfbcbbbbwD.nbbz.................pp......jGC......hDixfbcbbbbwD.nbbz.................pp......jGC.....",
+".KbbpsbbfBbbbbNuLqg.................lbr..CF..rfE.....KbbpsbbfBbbbbNuLqg.................lbr..CF..rfE.....KbbpsbbfBbbbbNuLqg.................lbr..CF..rfE.....KbbpsbbfBbbbbNuLqg.................lbr..CF..rfE.....KbbpsbbfBbbbbNuLqg.................lbr..CF..rfE....",
+".QbbAgGbbuAObbbQm...................gBOm.PB#..KOg....QbbAgGbbuAObbbQm...................gBOm.PB#..KOg....QbbAgGbbuAObbbQm...................gBOm.PB#..KOg....QbbAgGbbuAObbbQm...................gBOm.PB#..KOg....QbbAgGbbuAObbbQm...................gBOm.PB#..KOg...",
+"..qIF.lbbOgmlNzg....................yvbn.hfP..#ONg....qIF.lbbOgmlNzg....................yvbn.hfP..#ONg....qIF.lbbOgmlNzg....................yvbn.hfP..#ONg....qIF.lbbOgmlNzg....................yvbn.hfP..#ONg....qIF.lbbOgmlNzg....................yvbn.hfP..#ONg..",
+"...vx..Rbbn.npwA....................MGGIj.MfFmvqbL.....vx..Rbbn.npwA....................MGGIj.MfFmvqbL.....vx..Rbbn.npwA....................MGGIj.MfFmvqbL.....vx..Rbbn.npwA....................MGGIj.MfFmvqbL.....vx..Rbbn.npwA....................MGGIj.MfFmvqbL..",
+"..HJo..LbbNmObbr................#y..anebS.gRcSbyrm....HJo..LbbNmObbr................#y..anebS.gRcSbyrm....HJo..LbbNmObbr................#y..anebS.gRcSbyrm....HJo..LbbNmObbr................#y..anebS.gRcSbyrm....HJo..LbbNmObbr................#y..anebS.gRcSbyrm..",
+".Lbbbl..SMyQQEqy...............sbBj.Od.nJA.gKvn......Lbbbl..SMyQQEqy...............sbBj.Od.nJA.gKvn......Lbbbl..SMyQQEqy...............sbBj.Od.nJA.gKvn......Lbbbl..SMyQQEqy...............sbBj.Od.nJA.gKvn......Lbbbl..SMyQQEqy...............sbBj.Od.nJA.gKvn.....",
+"..wpMGPrLdNbL.................yflad.to.ibbvRq.........wpMGPrLdNbL.................yflad.to.ibbvRq.........wpMGPrLdNbL.................yflad.to.ibbvRq.........wpMGPrLdNbL.................yflad.to.ibbvRq.........wpMGPrLdNbL.................yflad.to.ibbvRq.......",
+".....ubbNpbbM..............Dnhibmwn.lfEhbsul.............ubbNpbbM..............Dnhibmwn.lfEhbsul.............ubbNpbbM..............Dnhibmwn.lfEhbsul.............ubbNpbbM..............Dnhibmwn.lfEhbsul.............ubbNpbbM..............Dnhibmwn.lfEhbsul........",
+".....sbBg.KJC...........DFiIQBEbjOq..PINOm...............sbBg.KJC...........DFiIQBEbjOq..PINOm...............sbBg.KJC...........DFiIQBEbjOq..PINOm...............sbBg.KJC...........DFiIQBEbjOq..PINOm...............sbBg.KJC...........DFiIQBEbjOq..PINOm..........",
+".....Fkd..mxF...........qzAz.Cazvcg..QtKh................Fkd..mxF...........qzAz.Cazvcg..QtKh................Fkd..mxF...........qzAz.Cazvcg..QtKh................Fkd..mxF...........qzAz.Cazvcg..QtKh................Fkd..mxF...........qzAz.Cazvcg..QtKh...........",
+"...........rL...........gbvQ.gGHBOiiwOy........................rL...........gbvQ.gGHBOiiwOy........................rL...........gbvQ.gGHBOiiwOy........................rL...........gbvQ.gGHBOiiwOy........................rL...........gbvQ.gGHBOiiwOy.............",
+".....................LHL.wbO..dOiNbfoj...................................LHL.wbO..dOiNbfoj...................................LHL.wbO..dOiNbfoj...................................LHL.wbO..dOiNbfoj...................................LHL.wbO..dOiNbfoj..............",
+"....................EIbcPFfJ#.yfD.E#....................................EIbcPFfJ#.yfD.E#....................................EIbcPFfJ#.yfD.E#....................................EIbcPFfJ#.yfD.E#....................................EIbcPFfJ#.yfD.E#................",
+"................jwe.QKyjvwKbk..Pr...................................jwe.QKyjvwKbk..Pr...................................jwe.QKyjvwKbk..Pr...................................jwe.QKyjvwKbk..Pr...................................jwe.QKyjvwKbk..Pr...................",
+"..........mj....lbD.tM..FbxbBm................................mj....lbD.tM..FbxbBm................................mj....lbD.tM..FbxbBm................................mj....lbD.tM..FbxbBm................................mj....lbD.tM..FbxbBm......................",
+"........ezfH....rB..ABy..RKlfl.........qs.Pl................ezfH....rB..ABy..RKlfl.........qs.Pl................ezfH....rB..ABy..RKlfl.........qs.Pl................ezfH....rB..ABy..RKlfl.........qs.Pl................ezfH....rB..ABy..RKlfl.........qs.Pl........",
+"........Mbbrmxm.#bj.mpvEyvw.#m..........m.la................Mbbrmxm.#bj.mpvEyvw.#m..........m.la................Mbbrmxm.#bj.mpvEyvw.#m..........m.la................Mbbrmxm.#bj.mpvEyvw.#m..........m.la................Mbbrmxm.#bj.mpvEyvw.#m..........m.la........",
+"....jQy.Qbbi.BQ..as..htfbci...............mOx...........jQy.Qbbi.BQ..as..htfbci...............mOx...........jQy.Qbbi.BQ..as..htfbci...............mOx...........jQy.Qbbi.BQ..as..htfbci...............mOx...........jQy.Qbbi.BQ..as..htfbci...............mOx.......",
+"...LBbs.Rbfg.dbx.xfF.ssiEm.................AGMa#.......LBbs.Rbfg.dbx.xfF.ssiEm.................AGMa#.......LBbs.Rbfg.dbx.xfF.ssiEm.................AGMa#.......LBbs.Rbfg.dbx.xfF.ssiEm.................AGMa#.......LBbs.Rbfg.dbx.xfF.ssiEm.................AGMa#....",
+"...hIbIjGbO..mvOmhNIwBh.............#......gfIE........hIbIjGbO..mvOmhNIwBh.............#......gfIE........hIbIjGbO..mvOmhNIwBh.............#......gfIE........hIbIjGbO..mvOmhNIwBh.............#......gfIE........hIbIjGbO..mvOmhNIwBh.............#......gfIE.....",
+"....kbbKfbcum.LftABDnh..............Bq......wIh.........kbbKfbcum.LftABDnh..............Bq......wIh.........kbbKfbcum.LftABDnh..............Bq......wIh.........kbbKfbcum.LftABDnh..............Bq......wIh.........kbbKfbcum.LftABDnh..............Bq......wIh.....",
+".DkAkGbbbbbbBkjeGbC.................Qam.....gRw......DkAkGbbbbbbBkjeGbC.................Qam.....gRw......DkAkGbbbbbbBkjeGbC.................Qam.....gRw......DkAkGbbbbbbBkjeGbC.................Qam.....gRw......DkAkGbbbbbbBkjeGbC.................Qam.....gRw.....",
+".PbbQxbbfzJbbbfomy..................DbH..zx..iIu.....PbbQxbbfzJbbbfomy..................DbH..zx..iIu.....PbbQxbbfzJbbbfomy..................DbH..zx..iIu.....PbbQxbbfzJbbbfomy..................DbH..zx..iIu.....PbbQxbbfzJbbbfomy..................DbH..zx..iIu....",
+".kIbl.zbbkFofbbn.....................vIj.MbE..AIi....kIbl.zbbkFofbbn.....................vIj.MbE..AIi....kIbl.zbbkFofbbn.....................vIj.MbE..AIi....kIbl.zbbkFofbbn.....................vIj.MbE..AIi....kIbl.zbbkFofbbn.....................vIj.MbE..AIi...",
+"..#BF.LbbI#.FCCy....................hBbK.yBz..Epcy....#BF.LbbI#.FCCy....................hBbK.yBz..Epcy....#BF.LbbI#.FCCy....................hBbK.yBz..Epcy....#BF.LbbI#.FCCy....................hBbK.yBz..Epcy....#BF.LbbI#.FCCy....................hBbK.yBz..Epcy..",
+"..mOA..obbo.KIOH....................QRRbL.ubxgBLfF....mOA..obbo.KIOH....................QRRbL.ubxgBLfF....mOA..obbo.KIOH....................QRRbL.ubxgBLfF....mOA..obbo.KIOH....................QRRbL.ubxgBLfF....mOA..obbo.KIOH....................QRRbL.ubxgBLfF..",
+".gQbp..#IbojcfbD...............mlD..OAiBz..Kbvfyy....gQbp..#IbojcfbD...............mlD..OAiBz..Kbvfyy....gQbp..#IbojcfbD...............mlD..OAiBz..Kbvfyy....gQbp..#IbojcfbD...............mlD..OAiBz..Kbvfyy....gQbp..#IbojcfbD...............mlD..OAiBz..Kbvfyy...",
+".LbbbKm.dr#ak.ym...............pcbF.OA.ubQygxKD......LbbbKm.dr#ak.ym...............pcbF.OA.ubQygxKD......LbbbKm.dr#ak.ym...............pcbF.OA.ubQygxKD......LbbbKm.dr#ak.ym...............pcbF.OA.ubQygxKD......LbbbKm.dr#ak.ym...............pcbF.OA.ubQygxKD.....",
+"..nkrpGMnPIbD.................#bFRA.Sw.#bfbIe.........nkrpGMnPIbD.................#bFRA.Sw.#bfbIe.........nkrpGMnPIbD.................#bFRA.Sw.#bfbIe.........nkrpGMnPIbD.................#bFRA.Sw.#bfbIe.........nkrpGMnPIbD.................#bFRA.Sw.#bfbIe.......",
+".....dbbCkfbS..............kpqib.wH.EfdLbeh#.............dbbCkfbS..............kpqib.wH.EfdLbeh#.............dbbCkfbS..............kpqib.wH.EfdLbeh#.............dbbCkfbS..............kpqib.wH.EfdLbeh#.............dbbCkfbS..............kpqib.wH.EfdLbeh#........",
+".....Mbv..xBx...........xqEIdIlfLBD..kJfp................Mbv..xBx...........xqEIdIlfLBD..kJfp................Mbv..xBx...........xqEIdIlfLBD..kJfp................Mbv..xBx...........xqEIdIlfLBD..kJfp................Mbv..xBx...........xqEIdIlfLBD..kJfp...........",
+".....gDE...ur...........EOnw.uBofGm.yakqm................gDE...ur...........EOnw.uBofGm.yakqm................gDE...ur...........EOnw.uBofGm.yakqm................gDE...ur...........EOnw.uBofGm.yakqm................gDE...ur...........EOnw.uBofGm.yakqm...........",
+"...........hj...........mIcw..NsRcAABtm........................hj...........mIcw..NsRcAABtm........................hj...........mIcw..NsRcAABtm........................hj...........mIcw..NsRcAABtm........................hj...........mIcw..NsRcAABtm.............",
+".....................dtngCbB..rByMfvx....................................dtngCbB..rByMfvx....................................dtngCbB..rByMfvx....................................dtngCbB..rByMfvx....................................dtngCbB..rByMfvx...............",
+".................m..uINROFBbL.gIl....................................m..uINROFBbL.gIl....................................m..uINROFBbL.gIl....................................m..uINROFBbL.gIl....................................m..uINROFBbL.gIl...................",
+"................FId.ws.mPOkbK..AL...................................FId.ws.mPOkbK..AL...................................FId.ws.mPOkbK..AL...................................FId.ws.mPOkbK..AL...................................FId.ws.mPOkbK..AL...................",
+".........gDL....lI#.oS..jIdcIj.........gj.Fg.................gDL....lI#.oS..jIdcIj.........gj.Fg.................gDL....lI#.oS..jIdcIj.........gj.Fg.................gDL....lI#.oS..jIdcIj.........gj.Fg.................gDL....lI#.oS..jIdcIj.........gj.Fg........",
+"........dfbd....Dc..qfL..pPivr.........rH.ok................dfbd....Dc..qfL..pPivr.........rH.ok................dfbd....Dc..qfL..pPivr.........rH.ok................dfbd....Dc..qfL..pPivr.........rH.ok................dfbd....Dc..qfL..pPivr.........rH.ok........",
+".....m..Cbbemoj.ybi..sInlGP...............Dcg............m..Cbbemoj.ybi..sInlGP...............Dcg............m..Cbbemoj.ybi..sInlGP...............Dcg............m..Cbbemoj.ybi..sInlGP...............Dcg............m..Cbbemoj.ybi..sInlGP...............Dcg.......",
+"....eGh.Qbb#.vvg.zP..LoOfwy................Rs.j.........eGh.Qbb#.vvg.zP..LoOfwy................Rs.j.........eGh.Qbb#.vvg.zP..LoOfwy................Rs.j.........eGh.Qbb#.vvg.zP..LoOfwy................Rs.j.........eGh.Qbb#.vvg.zP..LoOfwy................Rs.j.....",
+"...rbbP.RbI..ebk.Ebx.QH....................qfNB#.......rbbP.RbI..ebk.Ebx.QH....................qfNB#.......rbbP.RbI..ebk.Ebx.QH....................qfNB#.......rbbP.RbI..ebk.Ebx.QH....................qfNB#.......rbbP.RbI..ebk.Ebx.QH....................qfNB#....",
+"...gGbbFBbv...tcjiRIcRg.............lm.....mIBy........gGbbFBbv...tcjiRIcRg.............lm.....mIBy........gGbbFBbv...tcjiRIcRg.............lm.....mIBy........gGbbFBbv...tcjiRIcRg.............lm.....mIBy........gGbbFBbv...tcjiRIcRg.............lm.....mIBy.....",
+"....ubbpbbbPL.jGGPByLm..............GH......kbD.........ubbpbbbPL.jGGPByLm..............GH......kbD.........ubbpbbbPL.jGGPByLm..............GH......kbD.........ubbpbbbPL.jGGPByLm..............GH......kbD.........ubbpbbbPL.jGGPByLm..............GH......kbD.....",
+".uzQQRbbbbbbbzq#PNx.................Ccj..#...oag.....uzQQRbbbbbbbzq#PNx.................Ccj..#...oag.....uzQQRbbbbbbbzq#PNx.................Ccj..#...oag.....uzQQRbbbbbbbzq#PNx.................Ccj..#...oag.....uzQQRbbbbbbbzq#PNx.................Ccj..#...oag....",
+".wbbSEJbfCBbbbbvm...................ibS..vK..yGC.....wbbSEJbfCBbbbbvm...................ibS..vK..yGC.....wbbSEJbfCBbbbbvm...................ibS..vK..yGC.....wbbSEJbfCBbbbbvm...................ibS..vK..yGC.....wbbSEJbfCBbbbbvm...................ibS..vK..yGC....",
+".rNbD.obbSmuabbe.....................pbF.dbx..ebl....rNbD.obbSmuabbe.....................pbF.dbx..ebl....rNbD.obbSmuabbe.....................pbF.dbx..ebl....rNbD.obbSmuabbe.....................pbF.dbx..ebl....rNbD.obbSmuabbe.....................pbF.dbx..ebl...",
+"...OD.#IbbL.LnnL....................ebbp.mvOmmdKb#.....OD.#IbbL.LnnL....................ebbp.mvOmmdKb#.....OD.#IbbL.LnnL....................ebbp.mvOmmdKb#.....OD.#IbbL.LnnL....................ebbp.mvOmmdKb#.....OD.#IbbL.LnnL....................ebbp.mvOmmdKb#..",
+"..jBk..nbbz.Qbbd....................pPobq.EbK#fhRh....jBk..nbbz.Qbbd....................pPobq.EbK#fhRh....jBk..nbbz.Qbbd....................pPobq.EbK#fhRh....jBk..nbbz.Qbbd....................pPobq.EbK#fhRh....jBk..nbbz.Qbbd....................pPobq.EbK#fhRh..",
+".#abay.gOIxEBpvF...............hSn..GdyROy.xIbGg.....#abay.gOIxEBpvF...............hSn..GdyROy.xIbGg.....#abay.gOIxEBpvF...............hSn..GdyROy.xIbGg.....#abay.gOIxEBpvF...............hSn..GdyROy.xIbGg.....#abay.gOIxEBpvF...............hSn..GdyROy.xIbGg....",
+".#IbbRF.EhqIq.................mOzfe.Nk.rbOqeDqy......#IbbRF.EhqIq.................mOzfe.Nk.rbOqeDqy......#IbbRF.EhqIq.................mOzfe.Nk.rbOqeDqy......#IbbRF.EhqIq.................mOzfe.Nk.rbOqeDqy......#IbbRF.EhqIq.................mOzfe.Nk.rbOqeDqy.....",
+"..eEgKbNpGbbl...............m.hbjpH.MvmjbOOaF.........eEgKbNpGbbl...............m.hbjpH.MvmjbOOaF.........eEgKbNpGbbl...............m.hbjpH.MvmjbOOaF.........eEgKbNpGbbl...............m.hbjpH.MvmjbOOaF.........eEgKbNpGbbl...............m.hbjpH.MvmjbOOaF.......",
+".....HbbqDBbt...........m.mpfMhbmpA.#cPdbi...............HbbqDBbt...........m.mpfMhbmpA.#cPdbi...............HbbqDBbt...........m.mpfMhbmpA.#cPdbi...............HbbqDBbt...........m.mpfMhbmpA.#cPdbi...............HbbqDBbt...........m.mpfMhbmpA.#cPdbi..........",
+".....Hfw..Lti...........dkqGiOsIAfF..AfbM................Hfw..Lti...........dkqGiOsIAfF..AfbM................Hfw..Lti...........dkqGiOsIAfF..AfbM................Hfw..Lti...........dkqGiOsIAfF..AfbM................Hfw..Lti...........dkqGiOsIAfF..AfbM...........",
+"......gj...nx...........hIKQ.Efkbv..Ecey..................gj...nx...........hIKQ.Efkbv..Ecey..................gj...nx...........hIKQ.Efkbv..Ecey..................gj...nx...........hIKQ.Efkbv..Ecey..................gj...nx...........hIKQ.Efkbv..Ecey............",
+"...........m............mBbz..QoCbQQfH.........................m............mBbz..QoCbQQfH.........................m............mBbz..QoCbQQfH.........................m............mBbz..QoCbQQfH.........................m............mBbz..QoCbQQfH..............",
+"....................mPIwFdbIm.EfjrpKh...................................mPIwFdbIm.EfjrpKh...................................mPIwFdbIm.EfjrpKh...................................mPIwFdbIm.EfjrpKh...................................mPIwFdbIm.EfjrpKh...............",
+".................Eg.saCMfqvbr.mBd....................................Eg.saCMfqvbr.mBd....................................Eg.saCMfqvbr.mBd....................................Eg.saCMfqvbr.mBd....................................Eg.saCMfqvbr.mBd...................",
+"................ebH.pn..ncdbw..Dy...................................ebH.pn..ncdbw..Dy...................................ebH.pn..ncdbw..Dy...................................ebH.pn..ncdbw..Dy...................................ebH.pn..ncdbw..Dy...................",
+"........gekq....lcm.Kw..mGHNbL.........hD.l#................gekq....lcm.Kw..mGHNbL.........hD.l#................gekq....lcm.Kw..mGHNbL.........hD.l#................gekq....lcm.Kw..mGHNbL.........hD.l#................gekq....lcm.Kw..mGHNbL.........hD.l#........",
+"........nbbx....Lfm.Ffd..ptmKL.........Lr.Co................nbbx....Lfm.Ffd..ptmKL.........Lr.Co................nbbx....Lfm.Ffd..ptmKL.........Lr.Co................nbbx....Lfm.Ffd..ptmKL.........Lr.Co................nbbx....Lfm.Ffd..ptmKL.........Lr.Co........",
+".....F..SbbEmOD.gfe..rIpKfk...............hf#............F..SbbEmOD.gfe..rIpKfk...............hf#............F..SbbEmOD.gfe..rIpKfk...............hf#............F..SbbEmOD.gfe..rIpKfk...............hf#............F..SbbEmOD.gfe..rIpKfk...............hf#.......",
+"...msbD.wbbj.tc#.PR..qoowHm................PPylg.......msbD.wbbj.tc#.PR..qoowHm................PPylg.......msbD.wbbj.tc#.PR..qoowHm................PPylg.......msbD.wbbj.tc#.PR..qoowHm................PPylg.......msbD.wbbj.tc#.PR..qoowHm................PPylg....",
+"...rbbR.vbc..hfo.hcSLNl....................Lbfwj.......rbbR.vbc..hfo.hcSLNl....................Lbfwj.......rbbR.vbc..hfo.hcSLNl....................Lbfwj.......rbbR.vbc..hfo.hcSLNl....................Lbfwj.......rbbR.vbc..hfo.hcSLNl....................Lbfwj....",
+"....Nbbqcbvm..MbELNzIM..............Kj......BBm.........Nbbqcbvm..MbELNzIM..............Kj......BBm.........Nbbqcbvm..MbELNzIM..............Kj......BBm.........Nbbqcbvm..MbELNzIM..............Kj......BBm.........Nbbqcbvm..MbELNzIM..............Kj......BBm.....",
+".g..qJbObbbOAymwbaO.................vS......rfd......g..qJbObbbOAymwbaO.................vS......rfd......g..qJbObbbOAymwbaO.................vS......rfd......g..qJbObbbOAymwbaO.................vS......rfd......g..qJbObbbOAymwbaO.................vS......rfd.....",
+".sbcpobbJbbbbICidCi.................HbF..ly..nI#.....sbcpobbJbbbbICidCi.................HbF..ly..nI#.....sbcpobbJbbbbICidCi.................HbF..ly..nI#.....sbcpobbJbbbbICidCi.................HbF..ly..nI#.....sbcpobbJbbbbICidCi.................HbF..ly..nI#....",
+".zbbkjIbbdQbbbbvm...................jfp..zRg.mzp.....zbbkjIbbdQbbbbvm...................jfp..zRg.mzp.....zbbkjIbbdQbbbbvm...................jfp..zRg.mzp.....zbbkjIbbdQbbbbvm...................jfp..zRg.mzp.....zbbkjIbbdQbbbbvm...................jfp..zRg.mzp....",
+".jCfL.kbbz.hSfGh....................mzbq.Dbs..hIK....jCfL.kbbz.hSfGh....................mzbq.Dbs..hIK....jCfL.kbbz.hSfGh....................mzbq.Dbs..hIK....jCfL.kbbz.hSfGh....................mzbq.Dbs..hIK....jCfL.kbbz.hSfGh....................mzbq.Dbs..hIK...",
+"...vq.gGbbq.qMCl....................dffOm.tIjmoAbi.....vq.gGbbq.qMCl....................dffOm.tIjmoAbi.....vq.gGbbq.qMCl....................dffOm.tIjmoAbi.....vq.gGbbq.qMCl....................dffOm.tIjmoAbi.....vq.gGbbq.qMCl....................dffOm.tIjmoAbi..",
+"..EIM..lbbv.Rbbl....................NMHbn.#cRxb#Mj....EIM..lbbv.Rbbl....................NMHbn.#cRxb#Mj....EIM..lbbv.Rbbl....................NMHbn.#cRxb#Mj....EIM..lbbv.Rbbl....................NMHbn.#cRxb#Mj....EIM..lbbv.Rbbl....................NMHbn.#cRxb#Mj..",
+".iIbIL..zNiAvnKj...............qapm.GumoIL.Fvbwm.....iIbIL..zNiAvnKj...............qapm.GumoIL.Fvbwm.....iIbIL..zNiAvnKj...............qapm.GumoIL.Fvbwm.....iIbIL..zNiAvnKj...............qapm.GumoIL.Fvbwm.....iIbIL..zNiAvnKj...............qapm.GumoIL.Fvbwm....",
+".gGIRBdgjiCbE.................gICBx.zM.EbfKsDy.......gGIRBdgjiCbE.................gICBx.zM.EbfKsDy.......gGIRBdgjiCbE.................gICBx.zM.EbfKsDy.......gGIRBdgjiCbE.................gICBx.zM.EbfKsDy.......gGIRBdgjiCbE.................gICBx.zM.EbfKsDy......",
+"..jm.HbbIIbbA..............jEmibgwn.HBjjbwoKy.........jm.HbbIIbbA..............jEmibgwn.HBjjbwoKy.........jm.HbbIIbbA..............jEmibgwn.HBjjbwoKy.........jm.HbbIIbbA..............jEmibgwn.HBjjbwoKy.........jm.HbbIIbbA..............jEmibgwn.HBjjbwoKy.......",
+".....kbIygRbt...........hyyBGRFbgRu.gvvoIy...............kbIygRbt...........hyyBGRFbgRu.gvvoIy...............kbIygRbt...........hyyBGRFbgRu.gvvoIy...............kbIygRbt...........hyyBGRFbgRu.gvvoIy...............kbIygRbt...........hyyBGRFbgRu.gvvoIy..........",
+".....qzK..ykj...........uouvmptOPf#..kvvl................qzK..ykj...........uouvmptOPf#..kvvl................qzK..ykj...........uouvmptOPf#..kvvl................qzK..ykj...........uouvmptOPf#..kvvl................qzK..ykj...........uouvmptOPf#..kvvl...........",
+"...........Aq...........ybtQ.#fHfvmmnIi........................Aq...........ybtQ.#fHfvmmnIi........................Aq...........ybtQ.#fHfvmmnIi........................Aq...........ybtQ.#fHfvmmnIi........................Aq...........ybtQ.#fHfvmmnIi.............",
+".....................yLmmvbN..MplIBBaE...................................yLmmvbN..MplIBBaE...................................yLmmvbN..MplIBBaE...................................yLmmvbN..MplIBBaE...................................yLmmvbN..MplIBBaE.............."};
diff --git a/kiconedit/pics/toolbar/Makefile.am b/kiconedit/pics/toolbar/Makefile.am
new file mode 100644
index 00000000..8e3cb6e2
--- /dev/null
+++ b/kiconedit/pics/toolbar/Makefile.am
@@ -0,0 +1,28 @@
+toolbar_DATA = fileclose.png \
+ circle.png \
+ filledcircle.png \
+ line.png \
+ paintbrush-cursor.xpm \
+ airbrush-cursor.xpm \
+ ellipse.png \
+ filledellipse.png \
+ rectangle.png \
+ filledrectangle.png \
+ areaselect.png \
+ selectrect.png \
+ selectcircle.png \
+ fill-cursor.xpm \
+ grid.png \
+ pointer.png \
+ aim.png \
+ aim-cursor.xpm \
+ window_new.png \
+ grayscale.png \
+ kdepalette.png \
+ transform.png \
+ eraser-cursor.xpm \
+ colorpicker-cursor.xpm
+
+
+
+toolbardir = $(kde_datadir)/kiconedit/pics
diff --git a/kiconedit/pics/toolbar/aim-cursor.xpm b/kiconedit/pics/toolbar/aim-cursor.xpm
new file mode 100644
index 00000000..ecef295f
--- /dev/null
+++ b/kiconedit/pics/toolbar/aim-cursor.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static char *aim[]={
+"22 22 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"......................",
+"..........#...........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+"..#######...#######...",
+".#aaaaaaa...aaaaaaa#..",
+"..#######...#######...",
+"..........a...........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+".........#a#..........",
+"..........#...........",
+"......................",
+"......................"};
diff --git a/kiconedit/pics/toolbar/aim.png b/kiconedit/pics/toolbar/aim.png
new file mode 100644
index 00000000..ed0088a7
--- /dev/null
+++ b/kiconedit/pics/toolbar/aim.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/airbrush-cursor.xpm b/kiconedit/pics/toolbar/airbrush-cursor.xpm
new file mode 100644
index 00000000..2fd8314d
--- /dev/null
+++ b/kiconedit/pics/toolbar/airbrush-cursor.xpm
@@ -0,0 +1,35 @@
+/* XPM */
+static char *airbrush[]={
+"22 22 10 1",
+". c None",
+"a c #000000",
+"d c #2a2a2a",
+"g c #303030",
+"c c #444444",
+"h c #555555",
+"f c #808080",
+"b c #aaaaaa",
+"e c #c8c8c8",
+"# c #ffffff",
+"..................#aa#",
+".................#abca",
+"................#abcca",
+"...####........#abccda",
+"..#aaaa#......#abccda#",
+".#a####a#....#abccda#.",
+".#a#eeba#...#abccda#..",
+".#a#eeba#..#abccda#...",
+".#a#eeba#.#abccda#....",
+".#a#eeba##abccda#.....",
+".#a#ebba#abccda#......",
+".#a#bbbfaeccda#.......",
+"..#a#bfgaebda#.#####..",
+"..#a#bfaebffa##ddddd#.",
+"...#afaebbfa##ddaaada#",
+"..#a#eebbfadddda###da#",
+".#a#eebbfa#aaaa#..#da#",
+"#a#eebbfa#.####..#da#.",
+"#aeebbfa#.......#da#..",
+".#ebbfa#.......#da#...",
+"dhfffa#.......#da#....",
+"hd.aa#........#da#...."};
diff --git a/kiconedit/pics/toolbar/areaselect.png b/kiconedit/pics/toolbar/areaselect.png
new file mode 100644
index 00000000..de3fe8fb
--- /dev/null
+++ b/kiconedit/pics/toolbar/areaselect.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/circle.png b/kiconedit/pics/toolbar/circle.png
new file mode 100644
index 00000000..ccb5c9db
--- /dev/null
+++ b/kiconedit/pics/toolbar/circle.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/colorpicker-cursor.xpm b/kiconedit/pics/toolbar/colorpicker-cursor.xpm
new file mode 100644
index 00000000..8edc155e
--- /dev/null
+++ b/kiconedit/pics/toolbar/colorpicker-cursor.xpm
@@ -0,0 +1,36 @@
+/* XPM */
+static char *colorpicker[]={
+"22 22 11 1",
+". c None",
+"# c #000000",
+"f c #151515",
+"e c #2a2a2a",
+"c c #333333",
+"d c #3a3a3a",
+"i c #808080",
+"g c #aaaaaa",
+"b c #d5d5d5",
+"h c #dcdcdc",
+"a c #ffffff",
+"..................##a.",
+".................#bc#a",
+"................#bdcc#",
+"...............#bddce#",
+"..............#bddcef#",
+"............##bddcef#a",
+"...........#bdddcef#a.",
+"............#becef#a..",
+"...........#agbee#a...",
+"..........#ahgibf#a...",
+".........#ahgi#.#a....",
+"........#ahgi#........",
+".......#ahgi#.........",
+"......#ahgi#..........",
+".....#ahgi#...........",
+"....#ahgi#............",
+"...#ahgi#.............",
+"..#ahgi#..............",
+".#ahgi#...............",
+".#hgi#................",
+"#ig##.................",
+"#i#..................."};
diff --git a/kiconedit/pics/toolbar/ellipse.png b/kiconedit/pics/toolbar/ellipse.png
new file mode 100644
index 00000000..658b944d
--- /dev/null
+++ b/kiconedit/pics/toolbar/ellipse.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/eraser-cursor.xpm b/kiconedit/pics/toolbar/eraser-cursor.xpm
new file mode 100644
index 00000000..12c07f11
--- /dev/null
+++ b/kiconedit/pics/toolbar/eraser-cursor.xpm
@@ -0,0 +1,32 @@
+/* XPM */
+static char *eraser[]={
+"22 22 7 1",
+"b c #000080",
+"e c #800000",
+"a c #8080ff",
+"d c #c00000",
+"# c #c0c0ff",
+"c c #ffc0c0",
+". c #ffffff",
+"......................",
+"...............#aa....",
+"..............#aaaa...",
+".............#aaaaaa..",
+"............#aaaaaaaa.",
+"...........#aaaaaaaaa.",
+"..........#aaaaaaaaab.",
+".........#aaaaaaaaab..",
+"........#aaaaaaaaab...",
+".......c##aaaaaaab....",
+"......cdd##aaaaab.....",
+".....cdddd##aaab......",
+"....cdddddd##ab.......",
+"...cdddddddd#b........",
+"..cddddddddde.........",
+".cddddddddde..........",
+".ccddddddde...........",
+".cccddddde............",
+"..cccddde.............",
+"...cccde..............",
+"....cce...............",
+"......................"};
diff --git a/kiconedit/pics/toolbar/fileclose.png b/kiconedit/pics/toolbar/fileclose.png
new file mode 100644
index 00000000..906b2ec5
--- /dev/null
+++ b/kiconedit/pics/toolbar/fileclose.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/fill-cursor.xpm b/kiconedit/pics/toolbar/fill-cursor.xpm
new file mode 100644
index 00000000..d5ca3034
--- /dev/null
+++ b/kiconedit/pics/toolbar/fill-cursor.xpm
@@ -0,0 +1,36 @@
+/* XPM */
+static char *fill[]={
+"22 22 11 1",
+". c None",
+"a c #000000",
+"i c #222222",
+"c c #2a2a2a",
+"e c #333333",
+"g c #3a3a3a",
+"d c #404040",
+"h c #555555",
+"f c #aaaaaa",
+"b c #d5d5d5",
+"# c #ffffff",
+"......................",
+"............#.........",
+"...........#a#........",
+"..........#aba#.......",
+".........#abcca#......",
+"........#adceca#......",
+".......#afdcecca#.....",
+"......#abcedcecca#....",
+".....#afcgeedeeca#....",
+"...##fddcggeeeecca#...",
+"..#fdccddcggeeeecca#..",
+".#ddcdcdddcggeeeeca#..",
+".#dccbdddddcggeeecca#.",
+".#ddcddbbdddgggeeccba#",
+".#ddhadddbddggggeebia#",
+".#fda#adddbdddggebca#.",
+".#fda##aaddbbddgbca#..",
+".#fda#.##adddbdbca#...",
+"..#da#...#aaddbca#....",
+"..#fa#....##abca#.....",
+"..#f#.......#aa#......",
+"...#.........##......."};
diff --git a/kiconedit/pics/toolbar/filledcircle.png b/kiconedit/pics/toolbar/filledcircle.png
new file mode 100644
index 00000000..1431fbe2
--- /dev/null
+++ b/kiconedit/pics/toolbar/filledcircle.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/filledellipse.png b/kiconedit/pics/toolbar/filledellipse.png
new file mode 100644
index 00000000..3f1d6220
--- /dev/null
+++ b/kiconedit/pics/toolbar/filledellipse.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/filledrectangle.png b/kiconedit/pics/toolbar/filledrectangle.png
new file mode 100644
index 00000000..1a011a63
--- /dev/null
+++ b/kiconedit/pics/toolbar/filledrectangle.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/flood-cursor.xpm b/kiconedit/pics/toolbar/flood-cursor.xpm
new file mode 100644
index 00000000..8707443d
--- /dev/null
+++ b/kiconedit/pics/toolbar/flood-cursor.xpm
@@ -0,0 +1,32 @@
+/* XPM */
+static char *flood[]={
+"22 22 7 1",
+"b c #000000",
+"c c #303030",
+"# c #808080",
+"e c #a0a0a4",
+"a c #c0c0c0",
+"d c #dcdcdc",
+". c #ffffff",
+"......................",
+"......................",
+"...........##.........",
+"..........####........",
+".........##aa##.......",
+".........##ba##.......",
+".........##.b##.......",
+".......cc##..b#.......",
+".....cccd##d..b.......",
+"....cccdd#b.d..b......",
+"...ccceddbdb.d..b.....",
+"..eccceeddbdd.d..b....",
+"..ecccceeddddd.d..b...",
+"..ecccebeeddddd.d.b...",
+"..eccceebeeddddd.b....",
+"..eccc.eebeeddd.b.....",
+"..eecc..eebeeddb......",
+"...eec...eebeeb.......",
+"....e.....eebb........",
+"...........ee.........",
+"......................",
+"......................"};
diff --git a/kiconedit/pics/toolbar/flood.png b/kiconedit/pics/toolbar/flood.png
new file mode 100644
index 00000000..45e1130b
--- /dev/null
+++ b/kiconedit/pics/toolbar/flood.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/grayscale.png b/kiconedit/pics/toolbar/grayscale.png
new file mode 100644
index 00000000..3b475550
--- /dev/null
+++ b/kiconedit/pics/toolbar/grayscale.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/grid.png b/kiconedit/pics/toolbar/grid.png
new file mode 100644
index 00000000..acf1b687
--- /dev/null
+++ b/kiconedit/pics/toolbar/grid.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/kdepalette.png b/kiconedit/pics/toolbar/kdepalette.png
new file mode 100644
index 00000000..705865a2
--- /dev/null
+++ b/kiconedit/pics/toolbar/kdepalette.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/line.png b/kiconedit/pics/toolbar/line.png
new file mode 100644
index 00000000..25964286
--- /dev/null
+++ b/kiconedit/pics/toolbar/line.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/paintbrush-cursor.xpm b/kiconedit/pics/toolbar/paintbrush-cursor.xpm
new file mode 100644
index 00000000..fa4a1e32
--- /dev/null
+++ b/kiconedit/pics/toolbar/paintbrush-cursor.xpm
@@ -0,0 +1,36 @@
+/* XPM */
+static char *paintbrush[]={
+"22 22 11 1",
+". c None",
+"a c #000000",
+"d c #272727",
+"i c #2c2c2c",
+"h c #303030",
+"c c #3b3b3b",
+"g c #aaaaaa",
+"e c #c8c8c8",
+"b c #d5d5d5",
+"f c #ececec",
+"# c #ffffff",
+".................#abcc",
+"................#abccc",
+"...............#abcccd",
+"..............#abcccdd",
+".............#abcccdda",
+"............#abcccdda#",
+"...........#abcccdda#.",
+"..........#abcccdda#..",
+"..........abcccdda#...",
+".........##cccdda#....",
+".........#eecdda#.....",
+"......##f#eegda#......",
+".....#aabeggga#.......",
+"....#abbchgaa#........",
+"...#abcccda##.........",
+"...abcccdda#..........",
+"..#abccddia#..........",
+".#abccdiaa#...........",
+"#abdddaa##............",
+"aaaaaa##..............",
+"######................",
+"......................"};
diff --git a/kiconedit/pics/toolbar/paintbrush.png b/kiconedit/pics/toolbar/paintbrush.png
new file mode 100644
index 00000000..53774e19
--- /dev/null
+++ b/kiconedit/pics/toolbar/paintbrush.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/pointer.png b/kiconedit/pics/toolbar/pointer.png
new file mode 100644
index 00000000..62229be5
--- /dev/null
+++ b/kiconedit/pics/toolbar/pointer.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/rectangle.png b/kiconedit/pics/toolbar/rectangle.png
new file mode 100644
index 00000000..7075cf10
--- /dev/null
+++ b/kiconedit/pics/toolbar/rectangle.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/selectcircle.png b/kiconedit/pics/toolbar/selectcircle.png
new file mode 100644
index 00000000..91f528ec
--- /dev/null
+++ b/kiconedit/pics/toolbar/selectcircle.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/selectrect.png b/kiconedit/pics/toolbar/selectrect.png
new file mode 100644
index 00000000..0ce3aa21
--- /dev/null
+++ b/kiconedit/pics/toolbar/selectrect.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/spraycan-cursor.xpm b/kiconedit/pics/toolbar/spraycan-cursor.xpm
new file mode 100644
index 00000000..13d84b80
--- /dev/null
+++ b/kiconedit/pics/toolbar/spraycan-cursor.xpm
@@ -0,0 +1,30 @@
+/* XPM */
+static char *spraycan[]={
+"22 22 5 1",
+"# c #000000",
+"c c #808080",
+"b c #a0a0a4",
+"a c #c0c0c0",
+". c #ffffff",
+"......................",
+"......................",
+"......................",
+"......................",
+"........##............",
+"#.#..#..#a####........",
+".........#a.#.#.......",
+"......#..#b#a..#......",
+".#.......##aaa..#.....",
+"....#....#cbaaa..#....",
+".........b#cbaaa..#...",
+"..#...#..bc#cbaaa..#..",
+"..........bc#cbaaa..#.",
+".....#.....bc#cbaaa..#",
+"............bc#cbaaa#.",
+".............bc#cba#..",
+"..............bc#c#...",
+"...............bc#....",
+"................b.....",
+"......................",
+"......................",
+"......................"};
diff --git a/kiconedit/pics/toolbar/spraycan.png b/kiconedit/pics/toolbar/spraycan.png
new file mode 100644
index 00000000..c2ce7e8d
--- /dev/null
+++ b/kiconedit/pics/toolbar/spraycan.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/transform.png b/kiconedit/pics/toolbar/transform.png
new file mode 100644
index 00000000..3a5ca2b3
--- /dev/null
+++ b/kiconedit/pics/toolbar/transform.png
Binary files differ
diff --git a/kiconedit/pics/toolbar/window_new.png b/kiconedit/pics/toolbar/window_new.png
new file mode 100644
index 00000000..4d0a40a0
--- /dev/null
+++ b/kiconedit/pics/toolbar/window_new.png
Binary files differ
diff --git a/kiconedit/properties.cpp b/kiconedit/properties.cpp
new file mode 100644
index 00000000..0f2c1f44
--- /dev/null
+++ b/kiconedit/properties.cpp
@@ -0,0 +1,147 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <kconfig.h>
+#include <kdebug.h>
+#include <kapplication.h>
+
+#include "properties.h"
+
+KIconEditProperties* KIconEditProperties::m_self = 0;
+
+KIconEditProperties* KIconEditProperties::self()
+{
+ if (!m_self)
+ m_self = new KIconEditProperties();
+ return m_self;
+}
+
+KIconEditProperties::KIconEditProperties() : QObject()
+{
+ KConfig *config = kapp->config();
+
+ config->setGroup( "Appearance" );
+
+ m_bgMode = (QWidget::BackgroundMode)config->readNumEntry( "BackgroundMode", QWidget::FixedPixmap);
+ m_bgColor = config->readColorEntry( "BackgroundColor", &gray);
+ m_bgPixmap = config->readPathEntry("BackgroundPixmap");
+
+ config->setGroup( "Grid" );
+ m_pasteTransparent = config->readBoolEntry( "PasteTransparent", false );
+ m_showGrid = config->readBoolEntry( "ShowGrid", true );
+ m_gridScale = config->readNumEntry( "GridScaling", 10 );
+ m_showRulers = config->readBoolEntry( "ShowRulers", true );
+
+ if(config->readEntry( "TransparencyDisplayType", "Checkerboard" ) == "Checkerboard")
+ {
+ m_transparencyDisplayType = KIconEditGrid::TRD_CHECKERBOARD;
+ }
+ else
+ {
+ m_transparencyDisplayType = KIconEditGrid::TRD_SOLIDCOLOR;
+ }
+
+ QColor checkColor1(255, 255, 255);
+ QColor checkColor2(127, 127, 127);
+
+ m_checkerboardColor1 = config->readColorEntry( "CheckerboardColor1", &checkColor1);
+ m_checkerboardColor2 = config->readColorEntry( "CheckerboardColor2", &checkColor2);
+
+ QString checkerboardSize = config->readEntry( "CheckerboardSize", "Medium" );
+
+ if(checkerboardSize == "Small")
+ {
+ m_checkerboardSize = KIconEditGrid::CHK_SMALL;
+ }
+ else
+ if(checkerboardSize == "Medium")
+ {
+ m_checkerboardSize = KIconEditGrid::CHK_MEDIUM;
+ }
+ else
+ {
+ m_checkerboardSize = KIconEditGrid::CHK_LARGE;
+ }
+
+ QColor solidColor(255, 255, 255);
+ m_transparencySolidColor = config->readColorEntry( "TransparencySolidColor", &solidColor);
+}
+
+KIconEditProperties::~KIconEditProperties()
+{
+ kdDebug(4640) << "KIconEditProperties: Deleting properties" << endl;
+ m_self = 0;
+}
+
+void KIconEditProperties::save()
+{
+ KConfig *config = kapp->config();
+
+ config->setGroup( "Appearance" );
+
+ config->writeEntry("BackgroundMode", m_bgMode );
+ config->writeEntry("BackgroundColor", m_bgColor );
+ config->writePathEntry("BackgroundPixmap", m_bgPixmap );
+
+ config->setGroup( "Grid" );
+ config->writeEntry("PasteTransparent", m_pasteTransparent );
+ config->writeEntry("ShowGrid", m_showGrid );
+ config->writeEntry("GridScaling", m_gridScale );
+ config->writeEntry("ShowRulers", m_showRulers );
+
+ QString transparencyDisplayType;
+
+ switch(m_transparencyDisplayType)
+ {
+ case KIconEditGrid::TRD_SOLIDCOLOR:
+ transparencyDisplayType = "SolidColor";
+ break;
+ case KIconEditGrid::TRD_CHECKERBOARD:
+ default:
+ transparencyDisplayType = "Checkerboard";
+ break;
+ }
+
+ config->writeEntry( "TransparencyDisplayType", transparencyDisplayType );
+ config->writeEntry( "CheckerboardColor1", m_checkerboardColor1 );
+ config->writeEntry( "CheckerboardColor2", m_checkerboardColor2 );
+
+ QString checkerboardSize;
+
+ switch(m_checkerboardSize)
+ {
+ case KIconEditGrid::CHK_SMALL:
+ checkerboardSize = "Small";
+ break;
+ case KIconEditGrid::CHK_MEDIUM:
+ checkerboardSize = "Medium";
+ break;
+ case KIconEditGrid::CHK_LARGE:
+ default:
+ checkerboardSize = "Large";
+ break;
+ }
+
+ config->writeEntry( "CheckerboardSize", checkerboardSize );
+ config->writeEntry( "TransparencySolidColor", m_transparencySolidColor );
+
+ config->sync();
+}
+
diff --git a/kiconedit/properties.h b/kiconedit/properties.h
new file mode 100644
index 00000000..e94f6d2c
--- /dev/null
+++ b/kiconedit/properties.h
@@ -0,0 +1,82 @@
+/*
+ kiconedit - a small graphics drawing program the KDE.
+
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __PROPS_H__
+#define __PROPS_H__
+
+#include <qwidget.h>
+
+#include "kicongrid.h"
+
+class KIconEditProperties : public QObject
+{
+public:
+ static KIconEditProperties* self();
+ ~KIconEditProperties();
+
+ QString bgPixmap() { return m_bgPixmap; }
+ QColor bgColor() { return m_bgColor; }
+ QWidget::BackgroundMode bgMode() { return m_bgMode; }
+ bool showGrid() { return m_showGrid; }
+ bool pasteTransparent() { return m_pasteTransparent; }
+ bool showRulers() { return m_showRulers; }
+ int gridScale() { return m_gridScale; }
+
+ KIconEditGrid::TransparencyDisplayType transparencyDisplayType() const { return m_transparencyDisplayType; }
+ QColor checkerboardColor1() const { return m_checkerboardColor1; }
+ QColor checkerboardColor2() const { return m_checkerboardColor2; }
+ KIconEditGrid::CheckerboardSize checkerboardSize() const { return m_checkerboardSize; }
+ QColor transparencySolidColor() const { return m_transparencySolidColor; }
+
+ void setBgPixmap( const QString &p ) { m_bgPixmap = p; }
+ void setBgColor( const QColor &c ) { m_bgColor = c; }
+ void setBgMode( QWidget::BackgroundMode m ) { m_bgMode = m; }
+ void setShowGrid( bool b ) { m_showGrid = b; }
+ void setPasteTransparent( bool b ) { m_pasteTransparent = b; }
+ void setShowRulers( bool b ) { m_showRulers = b; }
+ void setGridScale( int s ) { m_gridScale = s; }
+ void setTransparencyDisplayType(KIconEditGrid::TransparencyDisplayType t) { m_transparencyDisplayType = t; }
+ void setCheckerboardColor1(const QColor& c) { m_checkerboardColor1 = c; }
+ void setCheckerboardColor2(const QColor& c) { m_checkerboardColor2 = c; }
+ void setCheckerboardSize(KIconEditGrid::CheckerboardSize size) { m_checkerboardSize = size; }
+ void setTransparencySolidColor(const QColor& c) { m_transparencySolidColor = c; }
+
+ void save();
+
+protected:
+ KIconEditProperties();
+ QString m_bgPixmap;
+ QColor m_bgColor;
+ QWidget::BackgroundMode m_bgMode;
+ bool m_showGrid;
+ bool m_pasteTransparent;
+ bool m_showRulers;
+ int m_gridScale;
+ KIconEditGrid::TransparencyDisplayType m_transparencyDisplayType;
+ QColor m_checkerboardColor1;
+ QColor m_checkerboardColor2;
+ KIconEditGrid::CheckerboardSize m_checkerboardSize;
+ QColor m_transparencySolidColor;
+
+ static KIconEditProperties* m_self;
+};
+
+#endif //__PROPS_H__
diff --git a/kiconedit/utils.cpp b/kiconedit/utils.cpp
new file mode 100644
index 00000000..1af52803
--- /dev/null
+++ b/kiconedit/utils.cpp
@@ -0,0 +1,134 @@
+/*
+ KDE Icon Editor - a small graphics drawing program for the KDE
+
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 <kimageio.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "utils.h"
+#include "config.h"
+
+imageFormats *formats = 0L;
+
+void setupImageHandlers()
+{
+ if(formats != 0L)
+ return;
+
+ KImageIO::registerFormats();
+
+ kdDebug(4640) << "Initializing formats" << endl;
+ formats = new imageFormats;
+ Q_CHECK_PTR(formats);
+ formats->setAutoDelete(true);
+ formats->append(new imageFormat("GIF", "GIF", "gif"));
+#ifdef HAVE_LIBJPEG
+ formats->append(new imageFormat("JFIF", "JPEG", "jpg"));
+#endif
+ formats->append(new imageFormat("XPM", "XPM", "xpm"));
+ formats->append(new imageFormat("ICO", "Windows Icon File", "ico"));
+/*
+#ifdef HAVE_LIBJPEG
+ QImageIO::defineIOHandler("JFIF","^\377\330\377\340", 0, read_jpeg_jfif, NULL);
+#endif
+*/
+}
+
+// Simple copy operation on local files (isn't there something like this in the libs?)
+bool copyFile(const QString &src, const QString &dest)
+{
+ QFile f_src(src);
+ QFile f_dest(dest);
+ QFileInfo fi(f_src);
+ uint src_size = fi.size();
+ kdDebug(4640) << "Size: " << src_size << endl;
+
+ if ( f_src.open(IO_ReadOnly) )
+ { // file opened successfully
+ if ( !f_dest.open(IO_WriteOnly) )
+ {
+ kdDebug(4640) << "copyFile - There was an error opening destination file: " << dest << endl;
+ f_src.close();
+ return false;
+ }
+ char *data = new char[src_size];
+ if(f_src.readBlock(data, src_size) == -1)
+ {
+ kdDebug(4640) << "copyFile - There was an error reading source file: " << src << endl;
+ f_src.close();
+ f_dest.close();
+ delete [] data;
+ return false;
+ }
+ if(f_dest.writeBlock(data, src_size) == -1)
+ {
+ kdDebug(4640) << "copyFile - There was an error writing to destination file: " << dest << endl;
+ f_src.close();
+ f_dest.close();
+ delete [] data;
+ return false;
+ }
+
+ f_src.close();
+ f_dest.close();
+ delete [] data;
+ return true;
+ }
+ kdDebug(4640) << "copyFile - There was an error opening source file: " << src << endl;
+ return false;
+}
+
+bool removeFile(const QString &file)
+{
+ if(file.length() > 0 && QFile::exists(file))
+ {
+ QDir d;
+ kdDebug(4640) << "Removing " << file << endl;
+ if(!d.remove(file))
+ {
+ kdDebug(4640) << "removeFile - There was an error removing the file: " << file << endl;
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+bool moveFile(const QString &src, const QString &dest)
+{
+ if(copyFile(src, dest))
+ return removeFile(src);
+ return false;
+}
+
+uint kdeColor(uint color)
+{
+ uint c = iconpalette[0]|OPAQUE_MASK;
+
+ for(uint i = 0; i < 42; i++)
+ {
+ //kdDebug(4640) << "Color #" << i << " " << iconpalette[i] << endl;
+ if( (iconpalette[i]|OPAQUE_MASK) - c < (iconpalette[i]|OPAQUE_MASK) - color)
+ c = iconpalette[i]|OPAQUE_MASK;
+ }
+ //kdDebug(4640) << color << " -> " << c << endl;
+ return c;
+}
diff --git a/kiconedit/utils.h b/kiconedit/utils.h
new file mode 100644
index 00000000..c1e1a4c0
--- /dev/null
+++ b/kiconedit/utils.h
@@ -0,0 +1,73 @@
+/*
+ kiconedit - a small graphics drawing program for the KDE
+
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __UTILS_H__
+#define __UTILS_H__
+
+#include <qimage.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <kapplication.h>
+
+#define OPAQUE_MASK 0xff000000
+
+#ifdef TRANSPARENT
+#undef TRANSPARENT
+#endif
+#define TRANSPARENT 0x00000000
+
+const uint iconpalette[42] = { // kde palette
+ 0x303030,0x585858,0x808080,0xa0a0a0,0xc3c3c3,0xdcdcdc,
+ 0x000040,0x004000,0x000000,0x004040,0x404000,0x000000,
+ 0x000080,0x008000,0x800000,0x008080,0x808000,0x800080,
+ 0x0000c0,0x00c000,0xc00000,0x00c0c0,0xc0c000,0xc000c0,
+ 0x0000ff,0x00ff00,0xff0000,0x00ffff,0xffff00,0xff00ff,
+ 0xc0c0ff,0xc0ffc0,0xffc0c0,0xc0ffff,0xffffc0,0xffc0ff,
+ 0x0080ff,0x0058c0,0x58a8ff,0xa8dcff,0xffffff,0x000000};
+
+struct imageFormat
+{
+ imageFormat(const char *f, const char *t, const char *e) { format = f; title = t, extension = e;}
+ const char *format;
+ const char *title;
+ const char *extension;
+};
+
+typedef QPtrList<struct imageFormat> imageFormats;
+extern imageFormats *formats;
+
+void setupImageHandlers();
+
+bool copyFile(const QString &src, const QString &dest);
+bool removeFile(const QString &file);
+bool moveFile(const QString &src, const QString &dest);
+uint kdeColor(uint c);
+
+#endif //__UTILS_H__
+
+
+
diff --git a/kiconedit/version.h b/kiconedit/version.h
new file mode 100644
index 00000000..8f04bb6e
--- /dev/null
+++ b/kiconedit/version.h
@@ -0,0 +1,36 @@
+/*
+ kiconedit - a small graphics drawing program for the KDE
+
+ Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
+
+ 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 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 __KIE_VERSION_H__
+#define __KIE_VERSION_H__
+
+#define KIE_VERSION_MAJOR 0
+#define KIE_VERSION_MINOR 4
+#define KIE_VERSION_RELEASE 0
+#define KIE_VERSION ((KIE_VERSION_MAJOR * 100) + (KIE_VERSION_MINOR *10) + KIE_VERSION_RELEASE)
+#define KIE_VERSION_STRING "0.4.0"
+
+
+
+#endif // __KIE_VERSION_H__
+
+
+