summaryrefslogtreecommitdiffstats
path: root/tdeiconedit
diff options
context:
space:
mode:
authorDarrell Anderson <[email protected]>2014-02-06 17:28:41 -0600
committerDarrell Anderson <[email protected]>2014-02-06 17:28:41 -0600
commit7ad9c00daa716f90e6b71af463c50eebc93f4250 (patch)
treef472270f99cab538f9db00a80e09d35f4d351d6b /tdeiconedit
parent00af0dfbf87c62e25b5050102b7bd8df2ddcc1d0 (diff)
downloadtdegraphics-7ad9c00daa716f90e6b71af463c50eebc93f4250.tar.gz
tdegraphics-7ad9c00daa716f90e6b71af463c50eebc93f4250.zip
Finish renaming kiconedit->tdeiconedit.
Diffstat (limited to 'tdeiconedit')
-rw-r--r--tdeiconedit/AUTHORS10
-rw-r--r--tdeiconedit/CMakeLists.txt42
-rw-r--r--tdeiconedit/Makefile.am26
-rw-r--r--tdeiconedit/NEWS68
-rw-r--r--tdeiconedit/kcolorgrid.cpp335
-rw-r--r--tdeiconedit/kcolorgrid.h105
-rw-r--r--tdeiconedit/knew.cpp326
-rw-r--r--tdeiconedit/knew.h168
-rw-r--r--tdeiconedit/kresize.cpp83
-rw-r--r--tdeiconedit/kresize.h64
-rw-r--r--tdeiconedit/main.cpp89
-rw-r--r--tdeiconedit/palettetoolbar.cpp178
-rw-r--r--tdeiconedit/palettetoolbar.h64
-rw-r--r--tdeiconedit/pics/CMakeLists.txt15
-rw-r--r--tdeiconedit/pics/Makefile.am5
-rw-r--r--tdeiconedit/pics/hi16-app-tdeiconedit.pngbin0 -> 406 bytes
-rw-r--r--tdeiconedit/pics/hi22-app-tdeiconedit.pngbin0 -> 1101 bytes
-rw-r--r--tdeiconedit/pics/hi32-app-tdeiconedit.pngbin0 -> 853 bytes
-rw-r--r--tdeiconedit/pics/hi48-app-tdeiconedit.pngbin0 -> 1187 bytes
-rw-r--r--tdeiconedit/pics/icons/CMakeLists.txt12
-rw-r--r--tdeiconedit/pics/icons/Makefile.am5
-rw-r--r--tdeiconedit/pics/icons/compressed.pngbin0 -> 530 bytes
-rw-r--r--tdeiconedit/pics/icons/source.pngbin0 -> 473 bytes
-rw-r--r--tdeiconedit/pics/icons/standard.pngbin0 -> 611 bytes
-rw-r--r--tdeiconedit/pics/logo.xpm137
-rw-r--r--tdeiconedit/pics/toolbar/CMakeLists.txt20
-rw-r--r--tdeiconedit/pics/toolbar/Makefile.am28
-rw-r--r--tdeiconedit/pics/toolbar/aim-cursor.xpm28
-rw-r--r--tdeiconedit/pics/toolbar/aim.pngbin0 -> 303 bytes
-rw-r--r--tdeiconedit/pics/toolbar/airbrush-cursor.xpm35
-rw-r--r--tdeiconedit/pics/toolbar/areaselect.pngbin0 -> 290 bytes
-rw-r--r--tdeiconedit/pics/toolbar/circle.pngbin0 -> 274 bytes
-rw-r--r--tdeiconedit/pics/toolbar/colorpicker-cursor.xpm36
-rw-r--r--tdeiconedit/pics/toolbar/ellipse.pngbin0 -> 257 bytes
-rw-r--r--tdeiconedit/pics/toolbar/eraser-cursor.xpm32
-rw-r--r--tdeiconedit/pics/toolbar/fileclose.pngbin0 -> 317 bytes
-rw-r--r--tdeiconedit/pics/toolbar/fill-cursor.xpm36
-rw-r--r--tdeiconedit/pics/toolbar/filledcircle.pngbin0 -> 279 bytes
-rw-r--r--tdeiconedit/pics/toolbar/filledellipse.pngbin0 -> 262 bytes
-rw-r--r--tdeiconedit/pics/toolbar/filledrectangle.pngbin0 -> 238 bytes
-rw-r--r--tdeiconedit/pics/toolbar/flood-cursor.xpm32
-rw-r--r--tdeiconedit/pics/toolbar/flood.pngbin0 -> 440 bytes
-rw-r--r--tdeiconedit/pics/toolbar/grayscale.pngbin0 -> 449 bytes
-rw-r--r--tdeiconedit/pics/toolbar/grid.pngbin0 -> 236 bytes
-rw-r--r--tdeiconedit/pics/toolbar/kdepalette.pngbin0 -> 416 bytes
-rw-r--r--tdeiconedit/pics/toolbar/line.pngbin0 -> 222 bytes
-rw-r--r--tdeiconedit/pics/toolbar/paintbrush-cursor.xpm36
-rw-r--r--tdeiconedit/pics/toolbar/paintbrush.pngbin0 -> 374 bytes
-rw-r--r--tdeiconedit/pics/toolbar/pointer.pngbin0 -> 298 bytes
-rw-r--r--tdeiconedit/pics/toolbar/rectangle.pngbin0 -> 246 bytes
-rw-r--r--tdeiconedit/pics/toolbar/selectcircle.pngbin0 -> 274 bytes
-rw-r--r--tdeiconedit/pics/toolbar/selectrect.pngbin0 -> 243 bytes
-rw-r--r--tdeiconedit/pics/toolbar/spraycan-cursor.xpm30
-rw-r--r--tdeiconedit/pics/toolbar/spraycan.pngbin0 -> 407 bytes
-rw-r--r--tdeiconedit/pics/toolbar/transform.pngbin0 -> 409 bytes
-rw-r--r--tdeiconedit/pics/toolbar/window_new.pngbin0 -> 799 bytes
-rw-r--r--tdeiconedit/properties.cpp147
-rw-r--r--tdeiconedit/properties.h82
-rw-r--r--tdeiconedit/tdeicon.cpp279
-rw-r--r--tdeiconedit/tdeicon.h79
-rw-r--r--tdeiconedit/tdeiconcolors.cpp170
-rw-r--r--tdeiconedit/tdeiconcolors.h86
-rw-r--r--tdeiconedit/tdeiconconfig.cpp589
-rw-r--r--tdeiconedit/tdeiconconfig.h158
-rw-r--r--tdeiconedit/tdeiconedit.cpp497
-rw-r--r--tdeiconedit/tdeiconedit.desktop94
-rw-r--r--tdeiconedit/tdeiconedit.h158
-rw-r--r--tdeiconedit/tdeiconeditslots.cpp543
-rw-r--r--tdeiconedit/tdeiconeditui.rc66
-rw-r--r--tdeiconedit/tdeicongrid.cpp2263
-rw-r--r--tdeiconedit/tdeicongrid.h265
-rw-r--r--tdeiconedit/utils.cpp134
-rw-r--r--tdeiconedit/utils.h73
-rw-r--r--tdeiconedit/version.h36
74 files changed, 7764 insertions, 0 deletions
diff --git a/tdeiconedit/AUTHORS b/tdeiconedit/AUTHORS
new file mode 100644
index 00000000..dd2047ae
--- /dev/null
+++ b/tdeiconedit/AUTHORS
@@ -0,0 +1,10 @@
+Copyright 1998 by Thomas Tanghus <[email protected]>
+Copyright 2000 by John Califf <[email protected]>
+
+Original Author:
+ Thomas Tanghus
+
+Current Maintainers:
+ John Califf <[email protected]>
+ Laurent Montel <[email protected]>
+
diff --git a/tdeiconedit/CMakeLists.txt b/tdeiconedit/CMakeLists.txt
new file mode 100644
index 00000000..4faa13c5
--- /dev/null
+++ b/tdeiconedit/CMakeLists.txt
@@ -0,0 +1,42 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory ( pics )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+#### other data #################################
+
+install( FILES tdeiconedit.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install( FILES tdeiconeditui.rc DESTINATION ${DATA_INSTALL_DIR}/tdeiconedit )
+
+
+#### tdeiconedit (executable) #####################
+
+tde_add_executable( tdeiconedit AUTOMOC
+ SOURCES
+ utils.cpp main.cpp tdeiconedit.cpp tdeicongrid.cpp
+ tdeiconcolors.cpp kcolorgrid.cpp palettetoolbar.cpp
+ tdeicon.cpp kresize.cpp knew.cpp properties.cpp
+ tdeiconeditslots.cpp tdeiconconfig.cpp
+ LINK tdeio-shared tdeprint-shared
+ DESTINATION ${BIN_INSTALL_DIR}
+)
diff --git a/tdeiconedit/Makefile.am b/tdeiconedit/Makefile.am
new file mode 100644
index 00000000..2fd37a01
--- /dev/null
+++ b/tdeiconedit/Makefile.am
@@ -0,0 +1,26 @@
+INCLUDES = $(all_includes)
+SUBDIRS = pics
+
+bin_PROGRAMS = tdeiconedit
+
+tdeiconedit_SOURCES = utils.cpp main.cpp tdeiconedit.cpp tdeicongrid.cpp \
+ tdeiconcolors.cpp kcolorgrid.cpp palettetoolbar.cpp\
+ tdeicon.cpp kresize.cpp knew.cpp properties.cpp \
+ tdeiconeditslots.cpp tdeiconconfig.cpp
+
+tdeiconedit_METASOURCES = AUTO
+
+# the library search path.
+tdeiconedit_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
+tdeiconedit_LDADD = $(LIB_TDEFILE) -ltdeprint
+
+DISTCLEANFILES = *~ .deps/* .libs/*
+
+rcdir = $(kde_datadir)/tdeiconedit
+rc_DATA = tdeiconeditui.rc
+
+xdg_apps_DATA = tdeiconedit.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) rc.cpp $(tdeiconedit_SOURCES) -o $(podir)/tdeiconedit.pot
+
diff --git a/tdeiconedit/NEWS b/tdeiconedit/NEWS
new file mode 100644
index 00000000..5f5b23fe
--- /dev/null
+++ b/tdeiconedit/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 <[email protected]>)
+ - Solaris didn't like TRANSPARENT definition. (thanks to Alastair Burt <[email protected]>)
+ - Crashed on empty string in strlen. (thanks to Alastair Burt <[email protected]>)
+ - Russian translations (thanks to Andy Pershin <[email protected]>)
+
+------------------------------------------------------------------------------
+ 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 TDEIcon 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/tdeiconedit/kcolorgrid.cpp b/tdeiconedit/kcolorgrid.cpp
new file mode 100644
index 00000000..131d5a9f
--- /dev/null
+++ b/tdeiconedit/kcolorgrid.cpp
@@ -0,0 +1,335 @@
+/*
+ tdeiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqpainter.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(TQWidget *parent, const char *name, int space)
+ : TQWidget(parent, name, TQt::WResizeNoErase|TQt::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();
+ TQWidget::show();
+}
+*/
+void KColorGrid::paintEvent(TQPaintEvent *e)
+{
+ //kdDebug(4640) << "KColorGrid::paintEvent" << endl;
+
+ //updateScrollBars();
+ //TQWidget::paintEvent(e);
+
+ const TQRect 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;
+
+ TQWMatrix matrix;
+ TQPixmap pm(urect.width(),urect.height());
+ pm.fill(paletteBackgroundColor());
+ TQPainter 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,TQRect(0,0,pm.width(),pm.height()));
+
+}
+
+void KColorGrid::paintForeground(TQPainter* , TQPaintEvent* )
+{
+}
+
+/*
+void KColorGrid::resizeEvent(TQResizeEvent *)
+{
+ //kdDebug(4640) << "resize: width: " << width() << " - total: " << totalwidth << endl;
+ //kdDebug(4640) << "resize: height: " << height() << " - total: " << totalheight << endl;
+}
+*/
+
+TQSize KColorGrid::sizeHint() const
+{
+ return TQSize(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 TQRect KColorGrid::viewRect()
+{
+ //kdDebug(4640) << "viewRect" << endl;
+ const TQRect 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());
+ //TQTableView::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 << " - " << tqRed(col) << " " << tqGreen(col) << " " << tqBlue(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 << " - " << tqRed(oldcolor) << " " << tqGreen(oldcolor) << " " << tqBlue(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;
+ TQWMatrix matrix;
+ TQPainter 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/tdeiconedit/kcolorgrid.h b/tdeiconedit/kcolorgrid.h
new file mode 100644
index 00000000..a116f74b
--- /dev/null
+++ b/tdeiconedit/kcolorgrid.h
@@ -0,0 +1,105 @@
+/*
+ tdeiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqwidget.h>
+#include <tqsize.h>
+#include <tqrect.h>
+
+#include "utils.h"
+
+#define KArrayUint TQMemArray<uint>
+
+class KColorArray : public KArrayUint
+{
+public:
+ void remove(int idx);
+ void append(uint);
+ uint closestMatch(uint);
+};
+
+class KColorGrid : public TQWidget
+{
+private:
+ Q_OBJECT
+
+public:
+ KColorGrid( TQWidget * 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 TQSize sizeHint() const;
+
+ void setSize(const TQSize 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( TQPainter* p, TQPaintEvent* e);
+ virtual void paintCell( TQPainter *p, int row, int col) = 0;
+ virtual void paintEvent(TQPaintEvent *);
+ //virtual void resizeEvent(TQResizeEvent *);
+ 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 TQRect 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/tdeiconedit/knew.cpp b/tdeiconedit/knew.cpp
new file mode 100644
index 00000000..2536816f
--- /dev/null
+++ b/tdeiconedit/knew.cpp
@@ -0,0 +1,326 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqlayout.h>
+#include <tqpainter.h>
+#include <tqbuttongroup.h>
+#include <tqradiobutton.h>
+#include <tqpushbutton.h>
+
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdeglobal.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <tdeapplication.h>
+
+#include "knew.h"
+
+TDEIconTemplateContainer* TDEIconTemplateContainer::instance = 0;
+
+void createStandardTemplates(TDEIconTemplateContainer *list)
+{
+ TDEIconLoader *kil = TDEGlobal::iconLoader();
+
+ TDEIconTemplate it;
+ it.path = kil->iconPath("standard", TDEIcon::User);
+ it.title = i18n("Standard File");
+ list->append(it);
+
+ it.path = kil->iconPath("source", TDEIcon::User);
+ it.title = i18n("Source File");
+ list->append(it);
+
+ it.path = kil->iconPath("compressed", TDEIcon::User);
+ it.title = i18n("Compressed File");
+ list->append(it);
+
+ it.path = kil->iconPath("folder", TDEIcon::User);
+ it.title = i18n("Standard Folder");
+ list->append(it);
+
+ it.path = kil->iconPath("package", TDEIcon::User);
+ it.title = i18n("Standard Package");
+ list->append(it);
+
+ it.path = kil->iconPath("mini-folder", TDEIcon::User);
+ it.title = i18n("Mini Folder");
+ list->append(it);
+
+ it.path = kil->iconPath("mini-package", TDEIcon::User);
+ it.title = i18n("Mini Package");
+ list->append(it);
+}
+
+void TDEIconTemplateContainer::save()
+{
+ TDEConfig *k = kapp->config();
+ k->setGroup("Templates");
+
+ TQStringList names;
+ for (TQValueListIterator<TDEIconTemplate> 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);
+ }
+}
+
+TDEIconTemplateContainer::TDEIconTemplateContainer() : TQValueList<TDEIconTemplate>()
+{
+ TQStrList names;
+ TDEConfig *k = kapp->config();
+ k->setGroup("Templates");
+ k->readListEntry("Names", names);
+ for(int i = 0; i < (int)names.count(); i++)
+ {
+ TDEIconTemplate 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);
+ }
+}
+
+TDEIconTemplateContainer::~TDEIconTemplateContainer()
+{
+ clear();
+}
+
+TDEIconListBoxItem::TDEIconListBoxItem( TDEIconTemplate t )
+ : TQListBoxItem(), icontemplate(t)
+{
+ //kdDebug(4640) << "TDEIconListBoxItem - " << t->path.data() << ", " << t->title.data() << endl;
+
+ pm.load(t.path);
+ setText( t.title );
+}
+
+void TDEIconListBoxItem::reloadIcon()
+{
+ pm.load(icontemplate.path);
+ setText( icontemplate.title );
+}
+
+
+
+void TDEIconListBoxItem::paint( TQPainter *p )
+{
+ p->drawPixmap( 3, 0, pm );
+ TQFontMetrics 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 TDEIconListBoxItem::height(const TQListBox *lb ) const
+{
+ return TQMAX( pm.height(), lb->fontMetrics().lineSpacing() + 1 );
+}
+
+int TDEIconListBoxItem::width(const TQListBox *lb ) const
+{
+ return pm.width() + lb->fontMetrics().width( text() ) + 6;
+}
+
+NewSelect::NewSelect(TQWidget *parent) : TQWidget( parent )
+{
+ wiz = (KWizard*) parent;
+ grp = new TQButtonGroup( this );
+ connect( grp, TQT_SIGNAL( clicked( int ) ), TQT_SLOT( buttonClicked( int ) ) );
+ grp->setExclusive( true );
+
+ TQVBoxLayout* ml = new TQVBoxLayout( this );
+ ml->addWidget( grp, 1 );
+ //ml->addWidget(grp, 10, AlignLeft);
+ TQVBoxLayout* l = new TQVBoxLayout( grp, 10 );
+
+ rbscratch = new TQRadioButton( i18n( "Create from scratch" ), grp );
+ l->addWidget( rbscratch, 1 );
+ //l->addWidget(rbscratch, 5, AlignLeft);
+
+ rbtempl = new TQRadioButton( 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( TQWidget* parent )
+ : TQWidget( parent )
+{
+ wiz = (KWizard*) parent;
+
+ TQVBoxLayout* ml = new TQVBoxLayout(this);
+
+ grp = new TQGroupBox( i18n( "Templates" ), this );
+ ml->addWidget( grp, 1 );
+ //ml->addWidget(grp, 10, AlignLeft);
+
+ TQHBoxLayout* l = new TQHBoxLayout( grp, 15 );
+
+ templates = new TDEIconListBox( grp );
+ connect( templates, TQT_SIGNAL( highlighted( int ) ), TQT_SLOT( checkSelection( int ) ) );
+ l->addWidget( templates );
+
+ for( int i = 0; i < (int) TDEIconTemplateContainer::self()->count(); i++ )
+ templates->insertItem( new TDEIconListBoxItem( *TDEIconTemplateContainer::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( TQWidget* 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, TQT_SIGNAL( iconopenstyle( int ) ), TQT_SLOT( iconOpenStyle( int ) ) );
+
+ scratch = new KResizeWidget( this, 0, TQSize( 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, TQT_SIGNAL( validSize( bool ) ), TQT_SLOT( checkPage( bool ) ) );
+ connect(this, TQT_SIGNAL(selected(const TQString &)), this, TQT_SLOT(checkPage(const TQString &)));
+ 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 TQString &)
+{
+ if(currentPage() == select || openstyle == Blank)
+ finishButton()->setEnabled(true);
+ else
+ finishButton()->setEnabled(false);
+}
+#include "knew.moc"
+
+
+
+
+
diff --git a/tdeiconedit/knew.h b/tdeiconedit/knew.h
new file mode 100644
index 00000000..faae9684
--- /dev/null
+++ b/tdeiconedit/knew.h
@@ -0,0 +1,168 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqwidget.h>
+#include <tqpixmap.h>
+#include <tqimage.h>
+#include <tqlistbox.h>
+
+#include <kwizard.h>
+
+#include "kresize.h"
+
+class TDEIconListBox;
+class TDEIconTemplateContainer;
+class TQButtonGroup;
+class TQRadioButton;
+class TQGroupBox;
+
+struct TDEIconTemplate
+{
+ TQString path;
+ TQString title;
+};
+
+class TDEIconListBoxItem : public TQListBoxItem
+{
+public:
+ TDEIconListBoxItem( TDEIconTemplate );
+
+
+ const TQString path() { return icontemplate.path; }
+ TDEIconTemplate& iconTemplate() { return icontemplate; }
+ void reloadIcon();
+
+protected:
+ virtual void paint( TQPainter * );
+ virtual int height( const TQListBox * ) const;
+ virtual int width( const TQListBox * ) const;
+private:
+ TQPixmap pm;
+ TDEIconTemplate icontemplate;
+};
+
+class TDEIconListBox : public TQListBox
+{
+ Q_OBJECT
+
+public:
+ TDEIconListBox( TQWidget *parent ) : TQListBox(parent) {} ;
+ const TQString path(int idx) { return ((TDEIconListBoxItem*)item(idx))->path(); }
+ TDEIconTemplate& iconTemplate(int idx) { return ((TDEIconListBoxItem*)item(idx))->iconTemplate(); }
+
+};
+
+class TDEIconTemplateContainer : public TQValueList<TDEIconTemplate>
+{
+public:
+ static TDEIconTemplateContainer* self()
+ {
+ if (!instance)
+ instance = new TDEIconTemplateContainer;
+ return instance;
+ }
+
+ void save();
+
+private:
+ static TDEIconTemplateContainer* instance;
+
+ const TDEIconTemplateContainer operator = (const TDEIconTemplateContainer&);
+ TDEIconTemplateContainer(const TDEIconTemplateContainer&);
+
+ TDEIconTemplateContainer();
+ ~TDEIconTemplateContainer();
+};
+
+class NewSelect : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ NewSelect(TQWidget *parent);
+ ~NewSelect();
+
+signals:
+ void iconopenstyle(int);
+
+protected slots:
+ void buttonClicked(int);
+
+protected:
+ KWizard *wiz;
+ TQButtonGroup *grp;
+ TQRadioButton *rbscratch, *rbtempl;
+};
+
+class NewFromTemplate : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ NewFromTemplate(TQWidget *parent);
+ ~NewFromTemplate();
+
+ const TQString path() { return TQString(templates->path(templates->currentItem())); }
+
+public slots:
+ void checkSelection(int);
+
+protected:
+ TDEIconListBox *templates;
+ KWizard *wiz;
+ TQGroupBox *grp;
+};
+
+class KNewIcon : public KWizard
+{
+ Q_OBJECT
+
+public:
+ KNewIcon(TQWidget *parent);
+ ~KNewIcon();
+
+ enum { Blank = 0, Template = 1};
+ int openStyle() { return openstyle; }
+ const TQString templatePath() { return TQString(templ->path()); }
+ const TQSize templateSize() { return scratch->getSize(); }
+
+protected slots:
+ void okClicked();
+ void cancelClicked();
+ void iconOpenStyle(int);
+ void checkPage(bool);
+ void checkPage(const TQString &);
+
+signals:
+ void newicon(const TQSize);
+ void newicon(const TQString);
+
+protected:
+ NewSelect *select;
+ KResizeWidget *scratch;
+ NewFromTemplate *templ;
+ TQWidget *act;
+ int openstyle;
+};
+
+#endif // __KNEWICON_H__
diff --git a/tdeiconedit/kresize.cpp b/tdeiconedit/kresize.cpp
new file mode 100644
index 00000000..b7007238
--- /dev/null
+++ b/tdeiconedit/kresize.cpp
@@ -0,0 +1,83 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+ Copyright (C) 2002 Nadeem Hasan ( [email protected] )
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqlabel.h>
+#include <tqlayout.h>
+#include <tqgroupbox.h>
+
+#include <tdelocale.h>
+#include <knuminput.h>
+
+#include "kresize.h"
+
+KResizeWidget::KResizeWidget( TQWidget* parent, const char* name,
+ const TQSize& size ) : TQWidget( parent, name )
+{
+ TQHBoxLayout* genLayout = new TQHBoxLayout( this );
+
+ TQGroupBox* group = new TQGroupBox( i18n( "Size" ), this );
+ group->setColumnLayout( 0, Qt::Horizontal );
+ genLayout->addWidget( group );
+
+ TQHBoxLayout* layout = new TQHBoxLayout( group->layout(), 6 );
+
+ m_width = new KIntSpinBox( 1, 200, 1, 1, 10, group );
+ m_width->setValue( size.width() );
+ layout->addWidget( m_width, 1 );
+
+ TQLabel* label = new TQLabel( "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 TQSize KResizeWidget::getSize()
+{
+ return TQSize( m_width->value(), m_height->value() );
+}
+
+KResizeDialog::KResizeDialog( TQWidget* parent, const char* name,
+ const TQSize size )
+ : KDialogBase( parent, name, true, i18n( "Select Size" ), Ok|Cancel )
+{
+ m_resize = new KResizeWidget( this, "resize widget", size );
+
+ setMainWidget( m_resize );
+}
+
+KResizeDialog::~KResizeDialog()
+{
+}
+
+const TQSize KResizeDialog::getSize()
+{
+ return m_resize->getSize();
+}
+
+#include "kresize.moc"
diff --git a/tdeiconedit/kresize.h b/tdeiconedit/kresize.h
new file mode 100644
index 00000000..fcfb18c3
--- /dev/null
+++ b/tdeiconedit/kresize.h
@@ -0,0 +1,64 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+ Copyright ( C ) 2002 Nadeem Hasan ( [email protected] )
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 TQWidget
+{
+ Q_OBJECT
+
+
+public:
+
+ KResizeWidget( TQWidget* parent, const char* name, const TQSize& );
+ ~KResizeWidget();
+
+ const TQSize getSize();
+
+private:
+
+ KIntSpinBox *m_width;
+ KIntSpinBox *m_height;
+};
+
+class KResizeDialog : public KDialogBase
+{
+ Q_OBJECT
+
+
+public:
+
+ KResizeDialog( TQWidget* parent, const char* name, const TQSize s );
+ ~KResizeDialog();
+
+ const TQSize getSize();
+
+private:
+
+ KResizeWidget* m_resize;
+};
+
+#endif //__KRESIZE_H__
diff --git a/tdeiconedit/main.cpp b/tdeiconedit/main.cpp
new file mode 100644
index 00000000..5b28bcd8
--- /dev/null
+++ b/tdeiconedit/main.cpp
@@ -0,0 +1,89 @@
+/*
+ KDE Draw - a small graphics drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+// A lot of this code is lifted from KMail. Thanks, guys!
+
+#include <stdlib.h>
+
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <tdeaboutdata.h>
+#include <tdecmdlineargs.h>
+#include <kdebug.h>
+
+#include "tdeiconedit.h"
+#include "config.h"
+#include "properties.h"
+
+static const char description[] =
+ I18N_NOOP("TDE Icon Editor");
+
+static TDECmdLineOptions options[] =
+{
+ { "+[file(s)]" , I18N_NOOP("Icon file(s) to open"), 0 },
+ TDECmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ TDEAboutData aboutData( "tdeiconedit", I18N_NOOP("TDEIconEdit"),
+ VERSION, description, TDEAboutData::License_GPL,
+ "(c) 1998, Thomas Tanghus");
+
+ aboutData.addAuthor("Thomas Tanghus",0, "[email protected]");
+ aboutData.addAuthor("John Califf",0, "[email protected]");
+ aboutData.addAuthor("Laurent Montel",0, "[email protected]");
+ aboutData.addAuthor("Aaron J. Seigo",0, "[email protected]");
+ aboutData.addCredit( "Nadeem Hasan", "Rewrote UI to use XMLGUI\n"
+ "Lots of fixes and cleanup", "[email protected]" );
+ aboutData.addCredit( "Adrian Page", I18N_NOOP("Bug fixes and GUI tidy up"),
+ TDECmdLineArgs::init( argc, argv, &aboutData );
+ TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ TDEApplication a;
+
+// setSignalHandler(signalHandler);
+
+ if (a.isRestored())
+ {
+ RESTORE(TDEIconEdit);
+ }
+ else
+ {
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ for(int i = 0; i < args->count(); i++)
+ {
+ TDEIconEdit *ki = new TDEIconEdit(args->url(i), "tdeiconedit");
+ TQ_CHECK_PTR(ki);
+ }
+
+ if (args->count() == 0)
+ {
+ TDEIconEdit *ki = new TDEIconEdit;
+ TQ_CHECK_PTR(ki);
+ }
+ args->clear();
+ }
+
+ int rc = a.exec();
+ delete TDEIconEditProperties::self();
+ return rc;
+}
+
diff --git a/tdeiconedit/palettetoolbar.cpp b/tdeiconedit/palettetoolbar.cpp
new file mode 100644
index 00000000..5e61cb48
--- /dev/null
+++ b/tdeiconedit/palettetoolbar.cpp
@@ -0,0 +1,178 @@
+/*
+ tdeiconedit - a small graphics drawing program for the KDE
+ Copyright ( C ) 1998 Thomas Tanghus ( [email protected] )
+ Copyright ( C ) 2002 Nadeem Hasan ( [email protected] )
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or ( at your option ) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqlabel.h>
+#include <tqlayout.h>
+#include <tqwhatsthis.h>
+#include <tqpainter.h>
+
+#include <tdelocale.h>
+#include <kdebug.h>
+
+#include "tdeiconcolors.h"
+#include "palettetoolbar.h"
+
+PaletteToolBar::PaletteToolBar( TQWidget *parent, const char *name )
+ : TDEToolBar( parent, name )
+{
+ TQWidget *base = new TQWidget( this );
+
+ TQBoxLayout::Direction d = orientation() == Qt::Horizontal?
+ TQBoxLayout::LeftToRight : TQBoxLayout::TopToBottom;
+ m_layout = new TQBoxLayout( base, d, 2, 6 );
+
+ m_lblPreview = new TQLabel( base );
+ m_lblPreview->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
+ m_lblPreview->setFixedHeight( 64 );
+ m_lblPreview->setAlignment( TQt::AlignHCenter|TQt::AlignVCenter );
+ TQWhatsThis::add(m_lblPreview, i18n( "Preview\n\nThis is a 1:1 preview"
+ " of the current icon" ) );
+ m_layout->addWidget( m_lblPreview );
+
+ m_currentColorView = new TQLabel( base );
+ m_currentColorView->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
+ m_currentColorView->setFixedHeight( 24 );
+ m_currentColorView->setAlignment( TQt::AlignHCenter|TQt::AlignVCenter );
+ TQWhatsThis::add(m_currentColorView, i18n( "Current color\n\nThis is the currently selected color" ) );
+ m_layout->addWidget( m_currentColorView );
+
+ TQVBoxLayout *vlayout = new TQVBoxLayout( m_layout, 0 );
+ TQLabel *l = new TQLabel( i18n( "System colors:" ), base );
+ vlayout->addWidget( l );
+ m_sysColors = new KSysColors( base );
+ TQWhatsThis::add(m_sysColors, i18n( "System colors\n\nHere you can select"
+ " colors from the TDE icon palette" ) );
+
+ vlayout->addWidget( m_sysColors );
+
+ connect( m_sysColors, TQT_SIGNAL( newColor(uint) ),
+ TQT_SIGNAL( newColor(uint) ) );
+
+ vlayout = new TQVBoxLayout( m_layout, 0 );
+ l = new TQLabel( i18n( "Custom colors:" ), base );
+ vlayout->addWidget( l );
+ m_customColors = new KCustomColors( base );
+ TQWhatsThis::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, TQT_SIGNAL( newColor(uint) ),
+ TQT_SIGNAL( newColor(uint) ) );
+ connect( this, TQT_SIGNAL( newColor(uint)),
+ this, TQT_SLOT(currentColorChanged(uint)));
+ currentColorChanged(OPAQUE_MASK|0);
+
+ setEnableContextMenu( false );
+ setMovingEnabled( false );
+}
+
+void PaletteToolBar::setOrientation( Qt::Orientation o )
+{
+ if( barPos() == Floating )
+ o = o == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
+
+ TQBoxLayout::Direction d = o == Qt::Horizontal? TQBoxLayout::LeftToRight
+ : TQBoxLayout::TopToBottom;
+ m_layout->setDirection( d );
+
+ TQDockWindow::setOrientation( o );
+}
+
+void PaletteToolBar::previewChanged( const TQPixmap &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( TQPixmap pixmap )
+{
+ m_lblPreview->setBackgroundPixmap(pixmap);
+}
+
+void PaletteToolBar::setPreviewBackground( const TQColor& colour )
+{
+ m_lblPreview->setBackgroundColor(colour);
+}
+
+void PaletteToolBar::currentColorChanged(uint color)
+{
+ if(tqAlpha(color) == 255)
+ {
+ m_currentColorView->setBackgroundColor(color);
+ }
+ else
+ {
+ // Show the colour as if drawn over a checkerboard pattern
+ const int squareWidth = 8;
+ const uint lightColour = tqRgb(255, 255, 255);
+ const uint darkColour = tqRgb(127, 127, 127);
+
+ TQPixmap pm(2 * squareWidth, 2 * squareWidth);
+ TQPainter p(&pm);
+
+ double alpha = tqAlpha(color) / 255.0;
+
+ int r = int(tqRed(color) * alpha + (1 - alpha) * tqRed(lightColour) + 0.5);
+ int g = int(tqGreen(color) * alpha + (1 - alpha) * tqGreen(lightColour) + 0.5);
+ int b = int(tqBlue(color) * alpha + (1 - alpha) * tqBlue(lightColour) + 0.5);
+
+ uint squareColour = tqRgb(r, g, b);
+
+ p.setPen(TQt::NoPen);
+ p.setBrush(TQColor(squareColour));
+ p.drawRect(0, 0, squareWidth, squareWidth);
+ p.drawRect(squareWidth, squareWidth, squareWidth, squareWidth);
+
+ r = int(tqRed(color) * alpha + (1 - alpha) * tqRed(darkColour) + 0.5);
+ g = int(tqGreen(color) * alpha + (1 - alpha) * tqGreen(darkColour) + 0.5);
+ b = int(tqBlue(color) * alpha + (1 - alpha) * tqBlue(darkColour) + 0.5);
+
+ squareColour = tqRgb(r, g, b);
+
+ p.setBrush(TQColor(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/tdeiconedit/palettetoolbar.h b/tdeiconedit/palettetoolbar.h
new file mode 100644
index 00000000..3945331a
--- /dev/null
+++ b/tdeiconedit/palettetoolbar.h
@@ -0,0 +1,64 @@
+/*
+ tdeiconedit - a small graphics drawing program for the KDE
+ Copyright ( C ) 1998 Thomas Tanghus ( [email protected] )
+ Copyright ( C ) 2002 Nadeem Hasan ( [email protected] )
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or ( at your option ) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tdetoolbar.h>
+
+class TQBoxLayout;
+class TQLabel;
+class KSysColors;
+class KCustomColors;
+
+class PaletteToolBar : public TDEToolBar
+{
+ Q_OBJECT
+
+
+ public:
+ PaletteToolBar( TQWidget *parent, const char *name = 0L );
+
+ signals:
+ void newColor( uint c );
+
+ public slots:
+ virtual void setOrientation( Qt::Orientation o );
+ void previewChanged( const TQPixmap &p );
+ void addColors( uint n, uint *c );
+ void addColor( uint color );
+ void setPreviewBackground( TQPixmap pixmap );
+ void setPreviewBackground( const TQColor& colour );
+ void currentColorChanged(uint color);
+
+ private:
+ TQBoxLayout *m_layout;
+ TQLabel *m_lblPreview;
+ TQLabel *m_currentColorView;
+ KSysColors *m_sysColors;
+ KCustomColors *m_customColors;
+};
+
+#endif // PALLETTETOOLBAR_H
+
+/* vim: et sw=2 ts=2
+*/
+
diff --git a/tdeiconedit/pics/CMakeLists.txt b/tdeiconedit/pics/CMakeLists.txt
new file mode 100644
index 00000000..e4d1a99a
--- /dev/null
+++ b/tdeiconedit/pics/CMakeLists.txt
@@ -0,0 +1,15 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( icons )
+add_subdirectory( toolbar )
+
+tde_install_icons( tdeiconedit )
diff --git a/tdeiconedit/pics/Makefile.am b/tdeiconedit/pics/Makefile.am
new file mode 100644
index 00000000..d1b91e7d
--- /dev/null
+++ b/tdeiconedit/pics/Makefile.am
@@ -0,0 +1,5 @@
+
+SUBDIRS = icons toolbar
+
+KDE_ICON = tdeiconedit
+
diff --git a/tdeiconedit/pics/hi16-app-tdeiconedit.png b/tdeiconedit/pics/hi16-app-tdeiconedit.png
new file mode 100644
index 00000000..ff16bcae
--- /dev/null
+++ b/tdeiconedit/pics/hi16-app-tdeiconedit.png
Binary files differ
diff --git a/tdeiconedit/pics/hi22-app-tdeiconedit.png b/tdeiconedit/pics/hi22-app-tdeiconedit.png
new file mode 100644
index 00000000..8bb080c7
--- /dev/null
+++ b/tdeiconedit/pics/hi22-app-tdeiconedit.png
Binary files differ
diff --git a/tdeiconedit/pics/hi32-app-tdeiconedit.png b/tdeiconedit/pics/hi32-app-tdeiconedit.png
new file mode 100644
index 00000000..604b17dd
--- /dev/null
+++ b/tdeiconedit/pics/hi32-app-tdeiconedit.png
Binary files differ
diff --git a/tdeiconedit/pics/hi48-app-tdeiconedit.png b/tdeiconedit/pics/hi48-app-tdeiconedit.png
new file mode 100644
index 00000000..b95bffae
--- /dev/null
+++ b/tdeiconedit/pics/hi48-app-tdeiconedit.png
Binary files differ
diff --git a/tdeiconedit/pics/icons/CMakeLists.txt b/tdeiconedit/pics/icons/CMakeLists.txt
new file mode 100644
index 00000000..31ee65bf
--- /dev/null
+++ b/tdeiconedit/pics/icons/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+install( FILES source.png standard.png compressed.png DESTINATION ${DATA_INSTALL_DIR}/tdeiconedit/pics )
diff --git a/tdeiconedit/pics/icons/Makefile.am b/tdeiconedit/pics/icons/Makefile.am
new file mode 100644
index 00000000..ee985d89
--- /dev/null
+++ b/tdeiconedit/pics/icons/Makefile.am
@@ -0,0 +1,5 @@
+pics_DATA = source.png \
+ standard.png \
+ compressed.png
+
+picsdir = $(kde_datadir)/tdeiconedit/pics
diff --git a/tdeiconedit/pics/icons/compressed.png b/tdeiconedit/pics/icons/compressed.png
new file mode 100644
index 00000000..c919f3bf
--- /dev/null
+++ b/tdeiconedit/pics/icons/compressed.png
Binary files differ
diff --git a/tdeiconedit/pics/icons/source.png b/tdeiconedit/pics/icons/source.png
new file mode 100644
index 00000000..8351e380
--- /dev/null
+++ b/tdeiconedit/pics/icons/source.png
Binary files differ
diff --git a/tdeiconedit/pics/icons/standard.png b/tdeiconedit/pics/icons/standard.png
new file mode 100644
index 00000000..df1e8318
--- /dev/null
+++ b/tdeiconedit/pics/icons/standard.png
Binary files differ
diff --git a/tdeiconedit/pics/logo.xpm b/tdeiconedit/pics/logo.xpm
new file mode 100644
index 00000000..97dab29d
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/CMakeLists.txt b/tdeiconedit/pics/toolbar/CMakeLists.txt
new file mode 100644
index 00000000..d73cdf45
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/CMakeLists.txt
@@ -0,0 +1,20 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+install( FILES
+ 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
+ DESTINATION ${DATA_INSTALL_DIR}/tdeiconedit/pics
+)
diff --git a/tdeiconedit/pics/toolbar/Makefile.am b/tdeiconedit/pics/toolbar/Makefile.am
new file mode 100644
index 00000000..362dd41a
--- /dev/null
+++ b/tdeiconedit/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)/tdeiconedit/pics
diff --git a/tdeiconedit/pics/toolbar/aim-cursor.xpm b/tdeiconedit/pics/toolbar/aim-cursor.xpm
new file mode 100644
index 00000000..ecef295f
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/aim.png b/tdeiconedit/pics/toolbar/aim.png
new file mode 100644
index 00000000..ed0088a7
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/aim.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/airbrush-cursor.xpm b/tdeiconedit/pics/toolbar/airbrush-cursor.xpm
new file mode 100644
index 00000000..2fd8314d
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/areaselect.png b/tdeiconedit/pics/toolbar/areaselect.png
new file mode 100644
index 00000000..de3fe8fb
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/areaselect.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/circle.png b/tdeiconedit/pics/toolbar/circle.png
new file mode 100644
index 00000000..ccb5c9db
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/circle.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/colorpicker-cursor.xpm b/tdeiconedit/pics/toolbar/colorpicker-cursor.xpm
new file mode 100644
index 00000000..8edc155e
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/ellipse.png b/tdeiconedit/pics/toolbar/ellipse.png
new file mode 100644
index 00000000..658b944d
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/ellipse.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/eraser-cursor.xpm b/tdeiconedit/pics/toolbar/eraser-cursor.xpm
new file mode 100644
index 00000000..12c07f11
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/fileclose.png b/tdeiconedit/pics/toolbar/fileclose.png
new file mode 100644
index 00000000..906b2ec5
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/fileclose.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/fill-cursor.xpm b/tdeiconedit/pics/toolbar/fill-cursor.xpm
new file mode 100644
index 00000000..d5ca3034
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/filledcircle.png b/tdeiconedit/pics/toolbar/filledcircle.png
new file mode 100644
index 00000000..1431fbe2
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/filledcircle.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/filledellipse.png b/tdeiconedit/pics/toolbar/filledellipse.png
new file mode 100644
index 00000000..3f1d6220
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/filledellipse.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/filledrectangle.png b/tdeiconedit/pics/toolbar/filledrectangle.png
new file mode 100644
index 00000000..1a011a63
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/filledrectangle.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/flood-cursor.xpm b/tdeiconedit/pics/toolbar/flood-cursor.xpm
new file mode 100644
index 00000000..8707443d
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/flood.png b/tdeiconedit/pics/toolbar/flood.png
new file mode 100644
index 00000000..45e1130b
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/flood.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/grayscale.png b/tdeiconedit/pics/toolbar/grayscale.png
new file mode 100644
index 00000000..3b475550
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/grayscale.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/grid.png b/tdeiconedit/pics/toolbar/grid.png
new file mode 100644
index 00000000..acf1b687
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/grid.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/kdepalette.png b/tdeiconedit/pics/toolbar/kdepalette.png
new file mode 100644
index 00000000..705865a2
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/kdepalette.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/line.png b/tdeiconedit/pics/toolbar/line.png
new file mode 100644
index 00000000..25964286
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/line.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/paintbrush-cursor.xpm b/tdeiconedit/pics/toolbar/paintbrush-cursor.xpm
new file mode 100644
index 00000000..fa4a1e32
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/paintbrush.png b/tdeiconedit/pics/toolbar/paintbrush.png
new file mode 100644
index 00000000..53774e19
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/paintbrush.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/pointer.png b/tdeiconedit/pics/toolbar/pointer.png
new file mode 100644
index 00000000..62229be5
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/pointer.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/rectangle.png b/tdeiconedit/pics/toolbar/rectangle.png
new file mode 100644
index 00000000..7075cf10
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/rectangle.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/selectcircle.png b/tdeiconedit/pics/toolbar/selectcircle.png
new file mode 100644
index 00000000..91f528ec
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/selectcircle.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/selectrect.png b/tdeiconedit/pics/toolbar/selectrect.png
new file mode 100644
index 00000000..0ce3aa21
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/selectrect.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/spraycan-cursor.xpm b/tdeiconedit/pics/toolbar/spraycan-cursor.xpm
new file mode 100644
index 00000000..13d84b80
--- /dev/null
+++ b/tdeiconedit/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/tdeiconedit/pics/toolbar/spraycan.png b/tdeiconedit/pics/toolbar/spraycan.png
new file mode 100644
index 00000000..c2ce7e8d
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/spraycan.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/transform.png b/tdeiconedit/pics/toolbar/transform.png
new file mode 100644
index 00000000..3a5ca2b3
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/transform.png
Binary files differ
diff --git a/tdeiconedit/pics/toolbar/window_new.png b/tdeiconedit/pics/toolbar/window_new.png
new file mode 100644
index 00000000..4d0a40a0
--- /dev/null
+++ b/tdeiconedit/pics/toolbar/window_new.png
Binary files differ
diff --git a/tdeiconedit/properties.cpp b/tdeiconedit/properties.cpp
new file mode 100644
index 00000000..4a90d7fe
--- /dev/null
+++ b/tdeiconedit/properties.cpp
@@ -0,0 +1,147 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tdeconfig.h>
+#include <kdebug.h>
+#include <tdeapplication.h>
+
+#include "properties.h"
+
+TDEIconEditProperties* TDEIconEditProperties::m_self = 0;
+
+TDEIconEditProperties* TDEIconEditProperties::self()
+{
+ if (!m_self)
+ m_self = new TDEIconEditProperties();
+ return m_self;
+}
+
+TDEIconEditProperties::TDEIconEditProperties() : TQObject()
+{
+ TDEConfig *config = kapp->config();
+
+ config->setGroup( "Appearance" );
+
+ m_bgMode = (TQWidget::BackgroundMode)config->readNumEntry( "BackgroundMode", TQWidget::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 = TDEIconEditGrid::TRD_CHECKERBOARD;
+ }
+ else
+ {
+ m_transparencyDisplayType = TDEIconEditGrid::TRD_SOLIDCOLOR;
+ }
+
+ TQColor checkColor1(255, 255, 255);
+ TQColor checkColor2(127, 127, 127);
+
+ m_checkerboardColor1 = config->readColorEntry( "CheckerboardColor1", &checkColor1);
+ m_checkerboardColor2 = config->readColorEntry( "CheckerboardColor2", &checkColor2);
+
+ TQString checkerboardSize = config->readEntry( "CheckerboardSize", "Medium" );
+
+ if(checkerboardSize == "Small")
+ {
+ m_checkerboardSize = TDEIconEditGrid::CHK_SMALL;
+ }
+ else
+ if(checkerboardSize == "Medium")
+ {
+ m_checkerboardSize = TDEIconEditGrid::CHK_MEDIUM;
+ }
+ else
+ {
+ m_checkerboardSize = TDEIconEditGrid::CHK_LARGE;
+ }
+
+ TQColor solidColor(255, 255, 255);
+ m_transparencySolidColor = config->readColorEntry( "TransparencySolidColor", &solidColor);
+}
+
+TDEIconEditProperties::~TDEIconEditProperties()
+{
+ kdDebug(4640) << "TDEIconEditProperties: Deleting properties" << endl;
+ m_self = 0;
+}
+
+void TDEIconEditProperties::save()
+{
+ TDEConfig *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 );
+
+ TQString transparencyDisplayType;
+
+ switch(m_transparencyDisplayType)
+ {
+ case TDEIconEditGrid::TRD_SOLIDCOLOR:
+ transparencyDisplayType = "SolidColor";
+ break;
+ case TDEIconEditGrid::TRD_CHECKERBOARD:
+ default:
+ transparencyDisplayType = "Checkerboard";
+ break;
+ }
+
+ config->writeEntry( "TransparencyDisplayType", transparencyDisplayType );
+ config->writeEntry( "CheckerboardColor1", m_checkerboardColor1 );
+ config->writeEntry( "CheckerboardColor2", m_checkerboardColor2 );
+
+ TQString checkerboardSize;
+
+ switch(m_checkerboardSize)
+ {
+ case TDEIconEditGrid::CHK_SMALL:
+ checkerboardSize = "Small";
+ break;
+ case TDEIconEditGrid::CHK_MEDIUM:
+ checkerboardSize = "Medium";
+ break;
+ case TDEIconEditGrid::CHK_LARGE:
+ default:
+ checkerboardSize = "Large";
+ break;
+ }
+
+ config->writeEntry( "CheckerboardSize", checkerboardSize );
+ config->writeEntry( "TransparencySolidColor", m_transparencySolidColor );
+
+ config->sync();
+}
+
diff --git a/tdeiconedit/properties.h b/tdeiconedit/properties.h
new file mode 100644
index 00000000..e9ac5a88
--- /dev/null
+++ b/tdeiconedit/properties.h
@@ -0,0 +1,82 @@
+/*
+ tdeiconedit - a small graphics drawing program the KDE.
+
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqwidget.h>
+
+#include "tdeicongrid.h"
+
+class TDEIconEditProperties : public TQObject
+{
+public:
+ static TDEIconEditProperties* self();
+ ~TDEIconEditProperties();
+
+ TQString bgPixmap() { return m_bgPixmap; }
+ TQColor bgColor() { return m_bgColor; }
+ TQWidget::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; }
+
+ TDEIconEditGrid::TransparencyDisplayType transparencyDisplayType() const { return m_transparencyDisplayType; }
+ TQColor checkerboardColor1() const { return m_checkerboardColor1; }
+ TQColor checkerboardColor2() const { return m_checkerboardColor2; }
+ TDEIconEditGrid::CheckerboardSize checkerboardSize() const { return m_checkerboardSize; }
+ TQColor transparencySolidColor() const { return m_transparencySolidColor; }
+
+ void setBgPixmap( const TQString &p ) { m_bgPixmap = p; }
+ void setBgColor( const TQColor &c ) { m_bgColor = c; }
+ void setBgMode( TQWidget::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(TDEIconEditGrid::TransparencyDisplayType t) { m_transparencyDisplayType = t; }
+ void setCheckerboardColor1(const TQColor& c) { m_checkerboardColor1 = c; }
+ void setCheckerboardColor2(const TQColor& c) { m_checkerboardColor2 = c; }
+ void setCheckerboardSize(TDEIconEditGrid::CheckerboardSize size) { m_checkerboardSize = size; }
+ void setTransparencySolidColor(const TQColor& c) { m_transparencySolidColor = c; }
+
+ void save();
+
+protected:
+ TDEIconEditProperties();
+ TQString m_bgPixmap;
+ TQColor m_bgColor;
+ TQWidget::BackgroundMode m_bgMode;
+ bool m_showGrid;
+ bool m_pasteTransparent;
+ bool m_showRulers;
+ int m_gridScale;
+ TDEIconEditGrid::TransparencyDisplayType m_transparencyDisplayType;
+ TQColor m_checkerboardColor1;
+ TQColor m_checkerboardColor2;
+ TDEIconEditGrid::CheckerboardSize m_checkerboardSize;
+ TQColor m_transparencySolidColor;
+
+ static TDEIconEditProperties* m_self;
+};
+
+#endif //__PROPS_H__
diff --git a/tdeiconedit/tdeicon.cpp b/tdeiconedit/tdeicon.cpp
new file mode 100644
index 00000000..cd3ab63a
--- /dev/null
+++ b/tdeiconedit/tdeicon.cpp
@@ -0,0 +1,279 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqimage.h>
+
+#include <tdemessagebox.h>
+#include <tdefiledialog.h>
+#include <tdeio/netaccess.h>
+#include <kimageio.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+
+#include "tdeicon.h"
+#include "utils.h"
+
+TDEIconEditIcon::TDEIconEditIcon(TQObject *parent, const TQImage *img, KURL url)
+ : TQObject(parent)
+{
+ f = 0;
+ _lastdir = "/";
+ //checkUnNamedBackup(img);
+
+ if(!url.isEmpty())
+ {
+ open(img, url);
+ }
+}
+
+
+TDEIconEditIcon::~TDEIconEditIcon()
+{
+}
+
+
+bool TDEIconEditIcon::open(const TQImage *image, KURL url)
+{
+ TQImage *img = (TQImage*)image;
+
+ if(url.isEmpty())
+ return false;
+
+ kdDebug(4640) << "TDEIconEditIcon::open " << url.prettyURL() << endl;
+
+ if(!url.isValid()) // try to see if it is a relative filename
+ {
+ kdDebug(4640) << "TDEIconEditIcon::open (malformed) " << url.prettyURL() << endl;
+
+ TQFileInfo fi(url.url());
+ if(fi.isRelative())
+ url = "file:" + fi.absFilePath();
+
+ if(!url.isValid()) // Giving up
+ {
+ TQString msg = i18n("The URL: %1 \nseems to be malformed.\n").arg(url.url());
+ KMessageBox::sorry((TQWidget*)parent(), msg);
+ return false;
+ }
+ }
+
+ TQString filename;
+
+ if(url.isLocalFile())
+ {
+ filename = url.path();
+ }
+ else
+ {
+ if(!TDEIO::NetAccess::download( url, filename, (TQWidget*)parent() ))
+ {
+ TQString msg = i18n("There was an error loading:\n%1\n").arg(url.prettyURL());
+ KMessageBox::error((TQWidget*)parent(), msg);
+ return false;
+ }
+ }
+
+ bool loadedOk = img->load(filename);
+
+ if(!url.isLocalFile())
+ {
+ TDEIO::NetAccess::removeTempFile( filename );
+ }
+
+ if(!loadedOk)
+ {
+ TQString msg = i18n("There was an error loading:\n%1\n").arg(url.prettyURL());
+ KMessageBox::error((TQWidget*)parent(), msg);
+ }
+ else
+ {
+ kdDebug(4640) << "TDEIconEditIcon::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) << "TDEIcon: _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) << "TDEIconEditIcon::open - done" << endl;
+ }
+
+ return loadedOk;
+}
+
+
+
+bool TDEIconEditIcon::promptForFile(const TQImage *img)
+{
+ kdDebug(4640) << "TDEIconEditIcon::promptForFile(const TQImage *img)" << endl;
+ /*
+ TQString 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( TQString(), filter );
+ */
+ bool loaded = false;
+ KURL url = KFileDialog::getImageOpenURL( TQString(), TQT_TQWIDGET(parent()) );
+
+ if( !url.isEmpty() )
+ {
+ loaded = open( img, url );
+ }
+
+ return loaded;
+}
+
+
+
+bool TDEIconEditIcon::saveAs(const TQImage *image)
+{
+ kdDebug(4640) << "TDEIconEditIcon::saveAs" << endl;
+
+ TQString file;
+
+ //Get list of file types..
+ KFileDialog *dialog=new KFileDialog(TQString(), TQString(), TQT_TQWIDGET(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()==TQDialog::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(TQFile::exists(file))
+ {
+ int r=KMessageBox::warningContinueCancel(TQT_TQWIDGET(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 TDEIconEditIcon::save(const TQImage *image, const TQString &_filename)
+{
+ kdDebug(4640) << "TDEIconEditIcon::save" << endl;
+ TQString filename = _filename;
+
+ if(filename.isEmpty())
+ {
+ if(_url.isEmpty())
+ {
+ return saveAs(image);
+ }
+ else
+ {
+ KURL turl(_url);
+ filename = turl.path();
+ }
+ }
+
+ TQImage *img = (TQImage*)image;
+ img->setAlphaBuffer(true);
+
+ KURL turl(filename);
+ TQString 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
+ {
+ TQString msg = i18n("There was an error saving:\n%1\n").arg(str);
+ KMessageBox::error((TQWidget*)parent(), msg);
+ kdDebug(4640) << "TDEIconEditIcon::save - " << msg << endl;
+ }
+
+ kdDebug(4640) << "TDEIconEditIcon::save - done" << endl;
+
+ return savedOk;
+}
+
+
+#include "tdeicon.moc"
diff --git a/tdeiconedit/tdeicon.h b/tdeiconedit/tdeicon.h
new file mode 100644
index 00000000..ede75f71
--- /dev/null
+++ b/tdeiconedit/tdeicon.h
@@ -0,0 +1,79 @@
+/*
+ KDE Icon Editor - a small icon drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 TQImage;
+
+class TDEIconEditIcon : public TQObject
+{
+ Q_OBJECT
+
+public:
+ TDEIconEditIcon(TQObject*, const TQImage*, KURL url = KURL() );
+ ~TDEIconEditIcon();
+
+ bool isLocal() { return local; }
+ TQString url() { return _url; }
+ void setUrl( const TQString & u ) { _url = u; };
+
+public slots:
+ bool open(const TQImage*, KURL url = KURL());
+ bool promptForFile(const TQImage*);
+ bool save(const TQImage*, const TQString &filename=TQString());
+ bool saveAs(const TQImage*);
+
+signals:
+ void newmessage( const TQString &);
+ void newname(const TQString &);
+ void addrecent(const TQString &);
+ void opennewwin(const TQString &);
+ void loaded(TQImage *);
+ void saved();
+
+protected:
+ bool local;
+ TQString _url;
+ TQString _lastdir;
+ FILE *f;
+};
+
+#endif //__KICON_H__
diff --git a/tdeiconedit/tdeiconcolors.cpp b/tdeiconedit/tdeiconcolors.cpp
new file mode 100644
index 00000000..6b695fc5
--- /dev/null
+++ b/tdeiconedit/tdeiconcolors.cpp
@@ -0,0 +1,170 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqpainter.h>
+#include <tqdrawutil.h>
+
+#include <kdebug.h>
+
+#include "tdeiconcolors.h"
+
+KDrawColors::KDrawColors(TQWidget *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( TQPainter *painter, int row, int col )
+{
+ //KColorGrid::paintCell(painter, row, col);
+ uint c = colorAt( row * numCols() + col );
+ TQBrush 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( TQMouseEvent *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(TQWidget *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(TQWidget *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(TQMouseEvent *e)
+{
+ int row = findRow( e->pos().y() );
+ int col = findCol( e->pos().x() );
+ int cell = row * numCols() + col;
+ TQColor 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)
+ {
+ TQColor color(c);
+ if(!color.isValid())
+ {
+ kdDebug(4640) << "KCustomColors::addColor: Not a valid color: " << c << endl;
+ return;
+ }
+ //kdDebug(4640) << "KCustomColors::addColor: Adding color: " << c << " - " << tqRed(c) << " " << tqGreen(c) << " " << tqBlue(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 "tdeiconcolors.moc"
diff --git a/tdeiconedit/tdeiconcolors.h b/tdeiconedit/tdeiconcolors.h
new file mode 100644
index 00000000..6e12d810
--- /dev/null
+++ b/tdeiconedit/tdeiconcolors.h
@@ -0,0 +1,86 @@
+/*
+ tdeiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqpopupmenu.h>
+
+#include <kcolordialog.h>
+
+#include "kcolorgrid.h"
+#include "utils.h"
+
+class KDrawColors : public KColorGrid
+{
+ Q_OBJECT
+
+public:
+ KDrawColors(TQWidget *parent);
+
+ //bool hasColor(uint);
+
+signals:
+ void newColor(uint);
+
+protected:
+ virtual void paintCell( TQPainter*, int, int );
+ virtual void mouseReleaseEvent(TQMouseEvent*);
+
+ int selected;
+};
+
+class KCustomColors : public KDrawColors
+{
+ Q_OBJECT
+
+public:
+ KCustomColors(TQWidget *parent);
+ ~KCustomColors();
+
+ void addColor(uint);
+ void clear();
+
+protected:
+ virtual void mouseDoubleClickEvent(TQMouseEvent*);
+ int getFreeCell();
+ void freeAllCells();
+
+protected:
+ bool *freecells;
+ TQPopupMenu *popup;
+};
+
+class KSysColors : public KDrawColors
+{
+ Q_OBJECT
+
+public:
+
+ KSysColors(TQWidget *parent);
+
+};
+
+
+
+#endif //__KDRAWCOLORS_H__
+
+
+
diff --git a/tdeiconedit/tdeiconconfig.cpp b/tdeiconedit/tdeiconconfig.cpp
new file mode 100644
index 00000000..0fb4639a
--- /dev/null
+++ b/tdeiconedit/tdeiconconfig.cpp
@@ -0,0 +1,589 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqcheckbox.h>
+#include <tqlayout.h>
+#include <tqlineedit.h>
+#include <tqvbox.h>
+#include <tqbuttongroup.h>
+#include <tqradiobutton.h>
+
+#include <tdeaccel.h>
+#include <kbuttonbox.h>
+#include <tdeapplication.h>
+#include <tdelocale.h>
+#include <kcolorbutton.h>
+#include <tdefiledialog.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <kurlrequester.h>
+
+#include "tdeiconconfig.h"
+#include "tdeiconedit.h"
+
+#ifndef PICS_INCLUDED
+#define PICS_INCLUDED
+#include "pics/logo.xpm"
+#endif
+
+// little helper:
+static inline TQPixmap loadIcon( const char * name )
+{
+ return TDEGlobal::instance()->iconLoader()
+ ->loadIcon( TQString::fromLatin1(name), TDEIcon::NoGroup, TDEIcon::SizeMedium );
+}
+
+KTemplateEditDlg::KTemplateEditDlg(TQWidget *parent)
+ : KDialogBase(parent, "KTemplateEditDlg", true, i18n( "Icon Template" ),
+ Ok|Cancel )
+{
+ TQFrame *frame = makeMainWidget();
+ TQVBoxLayout *ml = new TQVBoxLayout(frame);
+ TQGroupBox *grp = new TQGroupBox(i18n("Template"), frame);
+ grp->setColumnLayout(0, Qt::Vertical);
+ grp->layout()->setSpacing(spacingHint());
+ grp->layout()->setMargin(marginHint());
+ TQGridLayout *l = new TQGridLayout(grp->layout());
+
+ ln_name = new TQLineEdit( grp );
+ connect( ln_name, TQT_SIGNAL( textChanged( const TQString & ) ),
+ TQT_SLOT( slotTextChanged() ) );
+ TQLabel* lb_name = new TQLabel( ln_name, i18n( "Description:" ), grp );
+
+ ln_path = new KURLRequester(grp);
+ connect( ln_path, TQT_SIGNAL( textChanged( const TQString & ) ),
+ TQT_SLOT( slotTextChanged() ) );
+ TQLabel* lb_path = new TQLabel( 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()
+{
+ TQString name = ln_name->text(), path = ln_path->url();
+ enableButtonOK(name.length() && path.length());
+}
+
+void KTemplateEditDlg::setName(const TQString & name)
+{
+ ln_name->setText(name);
+}
+
+TQString KTemplateEditDlg::name()
+{
+ return ln_name->text();
+}
+
+void KTemplateEditDlg::setPath(const TQString & path)
+{
+ ln_path->setURL(path);
+}
+
+TQString KTemplateEditDlg::path()
+{
+ return ln_path->url();
+}
+
+KTemplateConfig::KTemplateConfig(TQWidget *parent) : TQWidget(parent)
+{
+ kdDebug(4640) << "KTemplateConfig constructor" << endl;
+
+ btadd = btremove = btedit = 0L;
+
+ TQGroupBox* grp = new TQGroupBox( i18n( "Templates" ), this );
+ grp->setColumnLayout( 0, Qt::Horizontal );
+
+ templates = new TDEIconListBox( grp );
+ connect( templates, TQT_SIGNAL( highlighted( int ) ),
+ TQT_SLOT( checkSelection( int ) ) );
+ connect( templates, TQT_SIGNAL(doubleClicked( TQListBoxItem * ) ),
+ TQT_SLOT( edit() ) );
+
+ TQVBoxLayout* ml = new TQVBoxLayout( this );
+ ml->addWidget( grp );
+
+ TQVBoxLayout* l = new TQVBoxLayout( grp->layout(), KDialog::spacingHint() );
+ l->addWidget( templates );
+
+ for( unsigned int i = 0; i < TDEIconTemplateContainer::self()->count(); i++ )
+ templates->insertItem( new TDEIconListBoxItem( *TDEIconTemplateContainer::self()->at( i ) ) ) ;
+
+ KButtonBox *bbox = new KButtonBox( grp );
+
+ btadd = bbox->addButton( i18n( "&Add..." ) );
+ connect( btadd, TQT_SIGNAL( clicked() ), TQT_SLOT( add() ) );
+
+ btedit = bbox->addButton( i18n( "&Edit..." ) );
+ connect( btedit, TQT_SIGNAL( clicked() ), TQT_SLOT( edit() ) );
+ btedit->setEnabled( false );
+
+ btremove = bbox->addButton( i18n( "&Remove" ) );
+ connect( btremove, TQT_SIGNAL( clicked() ), TQT_SLOT( remove() ) );
+ btremove->setEnabled( false );
+
+ bbox->addStretch( 1 );
+
+ bbox->layout();
+ l->addWidget( bbox );
+}
+
+KTemplateConfig::~KTemplateConfig()
+{
+}
+
+void KTemplateConfig::saveSettings()
+{
+ kdDebug(4640) << "KTemplateConfig::saveSettings" << endl;
+
+ TDEIconTemplateContainer::self()->clear();
+
+ for(int i = 0; i < (int)templates->count(); i++)
+ {
+ TDEIconTemplateContainer::self()->append(templates->iconTemplate(i));
+ }
+ TDEIconTemplateContainer::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())
+ {
+ TDEIconTemplate it;
+ it.path = dlg.path();
+ it.title = dlg.name();
+ templates->insertItem(new TDEIconListBoxItem(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
+ TDEIconTemplate &it=templates->iconTemplate(templates->currentItem());
+ it.path = dlg.path();
+ it.title = dlg.name();
+ static_cast<TDEIconListBoxItem*>(templates->item(templates->currentItem()))->reloadIcon();
+ templates->update();
+ }
+}
+
+KBackgroundConfig::KBackgroundConfig( TQWidget* parent )
+ : TQWidget( parent )
+{
+ kdDebug(4640) << "KBackgroundConfig - constructor" << endl;
+
+ lb_ex = 0L;
+
+ TDEIconEditProperties *props = TDEIconEditProperties::self();
+
+ pixpath = props->bgPixmap();
+ pix.load(pixpath);
+ if(pix.isNull())
+ {
+ kdDebug(4640) << "BGPIX: " << pixpath << " not valid!" << endl;
+ TQPixmap pmlogo((const char**)logo);
+ pix = pmlogo;
+ }
+
+ TQVBoxLayout *mainLayout = new TQVBoxLayout( this );
+
+ TQGroupBox *grp1 = new TQGroupBox( i18n( "Select Background" ), this );
+ grp1->setColumnLayout(0, Qt::Vertical );
+ grp1->layout()->setSpacing( KDialog::spacingHint() );
+ grp1->layout()->setMargin( KDialog::marginHint() );
+ mainLayout->addWidget( grp1 );
+
+ TQGridLayout *grp1Layout = new TQGridLayout( grp1->layout(), 3, 2 );
+
+ TQButtonGroup* btngrp = new TQButtonGroup( grp1 );
+ btngrp->setExclusive( true );
+ btngrp->setFrameStyle( TQFrame::NoFrame );
+ connect( btngrp, TQT_SIGNAL( clicked( int ) ), TQT_SLOT( slotBackgroundMode( int ) ) );
+ grp1Layout->addWidget( btngrp, 0, 0 );
+
+ TQVBoxLayout *bgl = new TQVBoxLayout( btngrp, 5 );
+
+ TQRadioButton *rbc = new TQRadioButton( i18n( "Use co&lor" ), btngrp );
+ btngrp->insert( rbc, 0 );
+ bgl->addWidget( rbc );
+
+ TQRadioButton *rbp = new TQRadioButton( i18n( "Use pix&map" ), btngrp );
+ btngrp->insert( rbp, 1 );
+ bgl->addWidget( rbp );
+
+ bgl->addStretch( 1 );
+
+ TQVBox *bbox = new TQVBox( grp1 );
+ grp1Layout->addWidget( bbox, 0, 1 );
+
+ btcolor = new KColorButton(props->bgColor(), bbox) ;
+ connect(btcolor, TQT_SIGNAL(changed(const TQColor &)),
+ TQT_SLOT( selectColor(const TQColor &)));
+
+ btpix = new TQPushButton(i18n( "Choose..." ), bbox);
+ connect( btpix, TQT_SIGNAL( clicked() ), TQT_SLOT( selectPixmap() ) );
+
+ TQGroupBox *grp2 = new TQGroupBox( i18n( "Preview" ), this );
+ mainLayout->addWidget( grp2, 1 );
+
+ TQBoxLayout *l2 = new TQVBoxLayout( grp2, 15 );
+
+ l2->addSpacing( 10 );
+
+ lb_ex = new TQLabel( grp2 );
+ lb_ex->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
+ l2->addWidget( lb_ex );
+
+/*
+ l1->addWidget( btngrp, 0, AlignLeft );
+ l1->addLayout( l1r );
+*/
+ bgmode = props->bgMode();
+
+ if( bgmode == TQWidget::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 = TQWidget::FixedColor;
+ btpix->setEnabled(false);
+ btcolor->setEnabled(true);
+ if(lb_ex)
+ lb_ex->setBackgroundColor(btcolor->color());
+ }
+ else
+ {
+ bgmode = TQWidget::FixedPixmap;
+ btpix->setEnabled(true);
+ btcolor->setEnabled(false);
+ if(lb_ex)
+ lb_ex->setBackgroundPixmap(pix);
+ }
+}
+
+void KBackgroundConfig::saveSettings()
+{
+ kdDebug(4640) << "KBackgroundConfig::saveSettings" << endl;
+ TDEIconEditProperties *props = TDEIconEditProperties::self();
+ props->setBgMode( bgmode );
+ props->setBgPixmap( pixpath );
+ props->setBgColor( btcolor->color() );
+ kdDebug(4640) << "KBackgroundConfig::saveSettings - done" << endl;
+}
+
+void KBackgroundConfig::selectColor(const TQColor & 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;
+ }
+
+ TQPixmap p(url.path());
+
+ if( !p.isNull() )
+ {
+ lb_ex->setBackgroundPixmap( p );
+ pixpath = url.path();
+ }
+}
+
+KMiscConfig::KMiscConfig(TQWidget *parent) : TQWidget(parent)
+{
+ kdDebug(4640) << "KMiscConfig - constructor" << endl;
+
+ TDEIconEditProperties* props = TDEIconEditProperties::self();
+
+ TQBoxLayout *ml = new TQVBoxLayout( this, 0, 5 );
+
+ TQCheckBox *cbp = new TQCheckBox( i18n( "Paste &transparent pixels" ), this );
+ connect( cbp, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( pasteMode( bool ) ) );
+ ml->addWidget(cbp);
+
+ TQCheckBox *cbr = new TQCheckBox( i18n( "Show &rulers" ), this );
+ connect( cbr, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( showRulers( bool ) ) );
+ ml->addWidget(cbr);
+
+ TQButtonGroup* btngrp = new TQButtonGroup( i18n( "Transparency Display" ), this);
+ btngrp->setExclusive( true );
+ connect( btngrp, TQT_SIGNAL( clicked( int ) ), TQT_SLOT( slotTransparencyDisplayType( int ) ) );
+ ml->addWidget( btngrp );
+
+ TQVBoxLayout *tgl = new TQVBoxLayout( btngrp, KDialog::marginHint(), KDialog::spacingHint() );
+ tgl->insertSpacing(0, 10);
+
+ TQHBoxLayout *hl = new TQHBoxLayout(tgl);
+
+ TQRadioButton *solidColorRButton = new TQRadioButton( 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, TQT_SIGNAL(changed(const TQColor &)),
+ // TQT_SLOT( selectColor(const TQColor &)));
+
+ TQRadioButton *checkerboardRButton = new TQRadioButton( i18n( "Checker&board" ), btngrp );
+ btngrp->insert( checkerboardRButton, 1 );
+ tgl->addWidget( checkerboardRButton );
+
+ TQGridLayout *grid = new TQGridLayout(tgl, 3, 3);
+ grid->addColSpacing(0, 40);
+ grid->setColStretch(1, 1);
+ grid->setColStretch(2, 1);
+
+ m_checkerboardSizeCombo = new TQComboBox(btngrp);
+ m_checkerboardSizeCombo->insertItem( i18n( "Small" ) );
+ m_checkerboardSizeCombo->insertItem( i18n( "Medium" ) );
+ m_checkerboardSizeCombo->insertItem( i18n( "Large" ) );
+ m_checkerboardSizeCombo->setCurrentItem(props->checkerboardSize());
+
+ TQLabel *label = new TQLabel(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 TQLabel(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 TQLabel(m_checkerboardColor2Button, i18n("Color &2:"), btngrp);
+
+ grid->addWidget(label, 2, 1);
+ grid->addWidget(m_checkerboardColor2Button, 2, 2);
+
+ if(props->transparencyDisplayType() == TDEIconEditGrid::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;
+ TDEIconEditProperties* props = TDEIconEditProperties::self();
+ props->setPasteTransparent( pastemode );
+ props->setShowRulers( showrulers );
+ if(m_solidColorButton->isEnabled())
+ {
+ props->setTransparencyDisplayType(TDEIconEditGrid::TRD_SOLIDCOLOR);
+ props->setTransparencySolidColor(m_solidColorButton->color());
+ }
+ else
+ {
+ props->setTransparencyDisplayType(TDEIconEditGrid::TRD_CHECKERBOARD);
+ props->setCheckerboardColor1(m_checkerboardColor1Button->color());
+ props->setCheckerboardColor2(m_checkerboardColor2Button->color());
+ props->setCheckerboardSize((TDEIconEditGrid::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);
+ }
+}
+
+TDEIconConfig::TDEIconConfig(TQWidget *parent)
+ : KDialogBase(KDialogBase::IconList, i18n("Configure"),
+ KDialogBase::Help |
+ KDialogBase::Ok |
+ KDialogBase::Apply |
+ KDialogBase::Cancel,
+ KDialogBase::Ok,
+ parent, "configDialog", true, true)
+{
+ setHelp(TQString());
+ //KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+ connect(this, TQT_SIGNAL(finished()), this, TQT_SLOT(finis()));
+
+ TQVBox* page = addVBoxPage(i18n("Icon Templates"), TQString(), loadIcon("icons"));
+ temps = new KTemplateConfig(page);
+
+ page = addVBoxPage(i18n("Background"), TQString(), loadIcon("background"));
+ backs = new KBackgroundConfig(page);
+
+ page = addVBoxPage(i18n("Icon Grid"), TQString(), loadIcon("tdeiconedit"));
+ misc = new KMiscConfig(page);
+
+ TQSize min(300, 400);
+
+ if (300 < sizeHint().width()) { min.setWidth(sizeHint().width()); }
+ if (400 < sizeHint().height()) { min.setHeight(sizeHint().height()); }
+
+ resize(min);
+}
+
+TDEIconConfig::~TDEIconConfig()
+{
+ //delete dict;
+}
+
+void TDEIconConfig::slotApply()
+{
+ kdDebug(4640) << "TDEIconEditConfig::saveSettings" << endl;
+
+ temps->saveSettings();
+ backs->saveSettings();
+ misc->saveSettings();
+
+ for (TDEIconEdit* window = TDEIconEdit::windowList.first();
+ window;
+ window = TDEIconEdit::windowList.next())
+ {
+ window->updateProperties();
+ }
+}
+
+void TDEIconConfig::slotOk()
+{
+ slotApply();
+ KDialogBase::slotOk();
+}
+
+void TDEIconConfig::finis()
+{
+ delayedDestruct();
+}
+
+#include "tdeiconconfig.moc"
diff --git a/tdeiconedit/tdeiconconfig.h b/tdeiconedit/tdeiconconfig.h
new file mode 100644
index 00000000..62f7938c
--- /dev/null
+++ b/tdeiconedit/tdeiconconfig.h
@@ -0,0 +1,158 @@
+/*
+ KDE Icon Editor - a small icon drawing program for the KDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqpixmap.h>
+#include <kdialogbase.h>
+
+#include "knew.h"
+#include "utils.h"
+#include "properties.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+class TDEAccel;
+class KKeyChooser;
+class KColorButton;
+class KURLRequester;
+class TQComboBox;
+
+class KTemplateEditDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ KTemplateEditDlg(TQWidget *);
+ ~KTemplateEditDlg() {};
+
+ TQString name();
+ TQString path();
+ void setName(const TQString &);
+ void setPath(const TQString &);
+
+public slots:
+ void slotTextChanged();
+
+protected:
+ TQLineEdit *ln_name;
+ KURLRequester *ln_path;
+};
+
+class KTemplateConfig : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ KTemplateConfig(TQWidget*);
+ ~KTemplateConfig();
+
+ void saveSettings();
+
+protected slots:
+ void add();
+ void edit();
+ void remove();
+ void checkSelection(int);
+
+protected:
+ TDEIconListBox *templates;
+ TQPushButton *btadd, *btedit, *btremove;
+};
+
+class KBackgroundConfig : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ KBackgroundConfig(TQWidget *parent);
+ ~KBackgroundConfig();
+
+public slots:
+ void saveSettings();
+ void selectColor(const TQColor & newColor);
+ void selectPixmap();
+
+signals:
+
+protected slots:
+ void slotBackgroundMode(int);
+
+protected:
+ KColorButton *btcolor;
+ TQPushButton *btpix;
+ TQPixmap pix;
+ TQString pixpath;
+ TQWidget::BackgroundMode bgmode;
+ TQLabel *lb_ex;
+};
+
+class KMiscConfig : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ KMiscConfig(TQWidget *parent);
+ ~KMiscConfig();
+
+public slots:
+ void saveSettings();
+ void pasteMode(bool);
+ void showRulers(bool);
+
+protected slots:
+ void slotTransparencyDisplayType(int);
+
+signals:
+
+protected:
+ bool pastemode, showrulers;
+ TQRadioButton *rbp;
+ KColorButton *m_solidColorButton;
+ KColorButton *m_checkerboardColor1Button;
+ KColorButton *m_checkerboardColor2Button;
+ TQComboBox *m_checkerboardSizeCombo;
+};
+
+class TDEIconConfig : public KDialogBase
+{
+ Q_OBJECT
+
+
+public:
+
+ TDEIconConfig(TQWidget *parent);
+ ~TDEIconConfig();
+
+protected slots:
+ void slotApply();
+ void slotOk();
+ void finis();
+
+protected:
+ KTemplateConfig *temps;
+ KBackgroundConfig *backs;
+ KMiscConfig *misc;
+};
+
+#endif //__KICONCONFIG_H__
diff --git a/tdeiconedit/tdeiconedit.cpp b/tdeiconedit/tdeiconedit.cpp
new file mode 100644
index 00000000..4705d102
--- /dev/null
+++ b/tdeiconedit/tdeiconedit.cpp
@@ -0,0 +1,497 @@
+/*
+ tdeiconedit - a small graphics drawing program for the KDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqwhatsthis.h>
+#include <tqtooltip.h>
+
+#include <tdepopupmenu.h>
+#include <kstdaction.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+
+#include "tdeiconedit.h"
+#include "palettetoolbar.h"
+
+WindowList TDEIconEdit::windowList;
+
+TDEIconEdit::TDEIconEdit(const TQImage image, const char *name)
+ : TDEMainWindow(0, name)
+{
+ init();
+ img = image;
+ img.detach();
+ grid->load(&img);
+ grid->setModified(true);
+}
+
+TDEIconEdit::TDEIconEdit(KURL url, const char *name)
+ : TDEMainWindow(0, name)
+{
+ init();
+ icon->open(&img, url);
+}
+
+void TDEIconEdit::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 TDEIconEditIcon(TQT_TQOBJECT(this), &grid->image());
+
+ setAcceptDrops(true);
+
+ setupActions();
+ setupStatusBar();
+ setStandardToolBarMenuEnabled( true );
+
+ createGUI();
+
+ connect(this, TQT_SIGNAL(newname(const TQString &)),
+ TQT_SLOT( slotUpdateStatusName(const TQString &)));
+
+ connect( icon, TQT_SIGNAL( saved()), TQT_SLOT(slotSaved()));
+ connect( icon, TQT_SIGNAL( loaded(TQImage *)), grid, TQT_SLOT(load(TQImage *)));
+ connect( icon, TQT_SIGNAL(opennewwin(const TQString &)),
+ TQT_SLOT(slotNewWin(const TQString &)));
+ connect(icon, TQT_SIGNAL(newname(const TQString &)),
+ TQT_SLOT( slotUpdateStatusName(const TQString &)));
+ connect(icon, TQT_SIGNAL(newmessage(const TQString &)),
+ TQT_SLOT( slotUpdateStatusMessage(const TQString &)));
+ connect(icon, TQT_SIGNAL(addrecent(const TQString &)),
+ TQT_SLOT( addRecent(const TQString &)));
+
+ connect( m_paletteToolBar, TQT_SIGNAL( newColor(uint)),
+ grid, TQT_SLOT(setColorSelection(uint)));
+
+ connect( grid, TQT_SIGNAL( changed(const TQPixmap &) ),
+ m_paletteToolBar, TQT_SLOT( previewChanged(const TQPixmap &) ) );
+ connect( grid, TQT_SIGNAL( addingcolor(uint) ),
+ m_paletteToolBar, TQT_SLOT(addColor(uint)));
+ connect( grid, TQT_SIGNAL( colorschanged(uint, uint*) ),
+ m_paletteToolBar, TQT_SLOT(addColors(uint, uint*)));
+
+ connect(grid, TQT_SIGNAL(sizechanged(int, int)),
+ TQT_SLOT( slotUpdateStatusSize(int, int)));
+ connect(grid, TQT_SIGNAL(poschanged(int, int)),
+ TQT_SLOT( slotUpdateStatusPos(int, int)));
+ connect(grid, TQT_SIGNAL(scalingchanged(int)),
+ TQT_SLOT( slotUpdateStatusScaling(int)));
+ connect(grid, TQT_SIGNAL(scalingchanged(int)),
+ TQT_SLOT( slotUpdateZoom(int)));
+ connect( grid, TQT_SIGNAL( addingcolor(uint) ),
+ TQT_SLOT(slotUpdateStatusColors(uint)));
+ connect(grid, TQT_SIGNAL(colorschanged(uint, uint*)),
+ TQT_SLOT( slotUpdateStatusColors(uint, uint*)));
+ connect(grid, TQT_SIGNAL(newmessage(const TQString &)),
+ TQT_SLOT( slotUpdateStatusMessage(const TQString &)));
+ connect(grid, TQT_SIGNAL(clipboarddata(bool)),
+ TQT_SLOT( slotUpdatePaste(bool)));
+ connect(grid, TQT_SIGNAL(colorSelected(uint)),
+ m_paletteToolBar, TQT_SLOT(currentColorChanged(uint)));
+ connect(grid, TQT_SIGNAL(modifiedchanged(bool)),
+ TQT_SLOT( slotUpdateStatusModified(bool)));
+ gridview->checkClipboard(); //Not very elegant, but fixes a buglet
+
+ connect(grid, TQT_SIGNAL(selecteddata(bool)), TQT_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, TQt::DockRight, true, 0 );
+}
+
+TDEIconEdit::~TDEIconEdit()
+{
+ windowList.remove(this);
+
+ if (windowList.count() < 1)
+ {
+ kapp->quit();
+ }
+}
+
+bool TDEIconEdit::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?"), TQString(), 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 TDEIconEdit::saveProperties(TDEConfig *config )
+{
+ kdDebug(4640) << "TDEIconEdit::saveProperties" << endl;
+
+ config->writePathEntry("Name", icon->url());
+}
+
+// this is for instances opened by the session manager
+void TDEIconEdit::readProperties(TDEConfig *config)
+{
+ kdDebug(4640) << "TDEIconEdit::readProperties" << endl;
+
+ TQString 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 TDEIconEdit::writeConfig()
+{
+ TDEConfig *config = kapp->config();
+ m_actRecent->saveEntries( kapp->config() );
+
+ TDEIconEditProperties::self()->save();
+
+ saveMainWindowSettings( config, "MainWindowSettings" );
+}
+
+TQSize TDEIconEdit::sizeHint() const
+{
+ if(gridview)
+ return gridview->sizeHint();
+ else
+ return TQSize(-1, -1);
+}
+
+void TDEIconEdit::setupActions()
+{
+ kdDebug(4640) << "setupActions" << endl;
+
+ TDEAction *action;
+ TDERadioAction *toolAction;
+ TDEShortcut cut;
+
+ // File Menu
+ action = new TDEAction(i18n("New &Window"), "window_new", cut,
+ TQT_TQOBJECT(this), TQT_SLOT(slotNewWin()), actionCollection(), "file_new_window");
+ action->setWhatsThis(i18n("New window\n\nOpens a new icon editor window."));
+
+ action = KStdAction::openNew(TQT_TQOBJECT(this), TQT_SLOT(slotNew()), actionCollection());
+ action->setWhatsThis(i18n("New\n\nCreate a new icon, either from a"
+ " template or by specifying the size"));
+
+ action = KStdAction::open(TQT_TQOBJECT(this), TQT_SLOT(slotOpen()), actionCollection());
+ action->setWhatsThis(i18n("Open\n\nOpen an existing icon"));
+
+ m_actRecent = KStdAction::openRecent(TQT_TQOBJECT(this),
+ TQT_SLOT(slotOpenRecent(const KURL&)), actionCollection());
+ m_actRecent->setMaxItems(15); // FIXME should be configurable!
+ m_actRecent->loadEntries(kapp->config());
+
+ action = KStdAction::save(TQT_TQOBJECT(this), TQT_SLOT(slotSave()), actionCollection());
+ action->setWhatsThis(i18n("Save\n\nSave the current icon"));
+
+ KStdAction::saveAs(TQT_TQOBJECT(this), TQT_SLOT(slotSaveAs()), actionCollection());
+
+ action = KStdAction::print(TQT_TQOBJECT(this), TQT_SLOT(slotPrint()), actionCollection());
+ action->setWhatsThis(i18n("Print\n\nOpens a print dialog to let you print"
+ " the current icon."));
+
+ KStdAction::close(TQT_TQOBJECT(this), TQT_SLOT(slotClose()), actionCollection());
+
+ // Edit Menu
+
+ m_actCut = KStdAction::cut(TQT_TQOBJECT(this), TQT_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(TQT_TQOBJECT(this), TQT_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(TQT_TQOBJECT(this), TQT_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 TDEAction( i18n( "Paste as &New" ), cut, TQT_TQOBJECT(grid),
+ TQT_SLOT( editPasteAsNew() ), actionCollection(), "edit_paste_as_new" );
+
+ KStdAction::clear(TQT_TQOBJECT(this), TQT_SLOT(slotClear()), actionCollection());
+ KStdAction::selectAll(TQT_TQOBJECT(this), TQT_SLOT(slotSelectAll()), actionCollection());
+
+ action = new TDEAction(i18n("Resi&ze..."), "transform", cut,
+ TQT_TQOBJECT(grid), TQT_SLOT(editResize()), actionCollection(), "edit_resize");
+ action->setWhatsThis(i18n("Resize\n\nSmoothly resizes the icon while"
+ " trying to preserve the contents"));
+
+ action = new TDEAction(i18n("&GrayScale"), "grayscale", cut,
+ TQT_TQOBJECT(grid), TQT_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(TQT_TQOBJECT(this), TQT_SLOT(slotZoomIn()),
+ actionCollection());
+ m_actZoomIn->setWhatsThis(i18n("Zoom in\n\nZoom in by one."));
+
+ m_actZoomOut = KStdAction::zoomOut(TQT_TQOBJECT(this), TQT_SLOT(slotZoomOut()),
+ actionCollection());
+ m_actZoomOut->setWhatsThis(i18n("Zoom out\n\nZoom out by one."));
+
+ TDEActionMenu *actMenu = new TDEActionMenu( i18n( "&Zoom" ), "viewmag",
+ actionCollection(), "view_zoom" );
+
+ // xgettext:no-c-format
+ action = new TDEAction( i18n( "100%" ), cut, TQT_TQOBJECT(this), TQT_SLOT( slotZoom1() ),
+ actionCollection(), "view_zoom_1" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new TDEAction( i18n( "200%" ), cut, TQT_TQOBJECT(this), TQT_SLOT( slotZoom2() ),
+ actionCollection(), "view_zoom_2" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new TDEAction( i18n( "500%" ), cut, TQT_TQOBJECT(this), TQT_SLOT( slotZoom5() ),
+ actionCollection(), "view_zoom_5" );
+ actMenu->insert( action );
+ // xgettext:no-c-format
+ action = new TDEAction( i18n( "1000%" ), cut, TQT_TQOBJECT(this), TQT_SLOT( slotZoom10() ),
+ actionCollection(), "view_zoom_10" );
+ actMenu->insert( action );
+
+ // Settings Menu
+ KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(slotConfigureKeys()),
+ actionCollection());
+ KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(slotConfigureSettings()),
+ actionCollection());
+
+ createStandardStatusBarAction();
+
+ TDEToggleAction *toggle;
+
+ toggle = new TDEToggleAction( i18n( "Show &Grid" ), "grid",
+ cut, TQT_TQOBJECT(this), TQT_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( TDEIconEditProperties::self()->showGrid() );
+
+ // Tools Menu
+ toolAction = new TDERadioAction(i18n("Color Picker"), "colorpicker",
+ cut, TQT_TQOBJECT(this), TQT_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 TDERadioAction(i18n("Freehand"), "paintbrush",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolFreehand()), actionCollection(),
+ "tool_freehand");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Free hand\n\nDraw non-linear lines"));
+
+ toolAction->setChecked( true );
+ grid->setTool(TDEIconEditGrid::Freehand);
+
+ toolAction = new TDERadioAction(i18n("Rectangle"), "rectangle",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolRectangle()), actionCollection(),
+ "tool_rectangle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Rectangle\n\nDraw a rectangle"));
+
+ toolAction = new TDERadioAction(i18n("Filled Rectangle"), "filledrectangle",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolFilledRectangle()), actionCollection(),
+ "tool_filled_rectangle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled rectangle\n\nDraw a filled rectangle"));
+
+ toolAction = new TDERadioAction(i18n("Circle"), "circle",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolCircle()), actionCollection(),
+ "tool_circle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Circle\n\nDraw a circle"));
+
+ toolAction = new TDERadioAction(i18n("Filled Circle"), "filledcircle",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolFilledCircle()), actionCollection(),
+ "tool_filled_circle");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled circle\n\nDraw a filled circle"));
+
+ toolAction = new TDERadioAction(i18n("Ellipse"), "ellipse",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolEllipse()), actionCollection(),
+ "tool_ellipse");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Ellipse\n\nDraw an ellipse"));
+
+ toolAction = new TDERadioAction(i18n("Filled Ellipse"), "filledellipse",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolFilledEllipse()), actionCollection(),
+ "tool_filled_ellipse");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Filled ellipse\n\nDraw a filled ellipse"));
+
+ toolAction = new TDERadioAction(i18n("Spray"), "airbrush",
+ cut, TQT_TQOBJECT(this), TQT_SLOT(slotToolSpray()), actionCollection(),
+ "tool_spray");
+ toolAction->setExclusiveGroup("toolActions");
+ toolAction->setWhatsThis(i18n("Spray\n\nDraw scattered pixels in the"
+ " current color"));
+
+ toolAction = new TDERadioAction(i18n("Flood Fill"), "fill",
+ cut, TQT_TQOBJECT(this), TQT_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 TDERadioAction(i18n("Line"), "line",
+ cut, TQT_TQOBJECT(this), TQT_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 TDERadioAction(i18n("Eraser (Transparent)"), "eraser",
+ cut, TQT_TQOBJECT(this), TQT_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 TDERadioAction(i18n("Rectangular Selection"),
+ "selectrect", cut, TQT_TQOBJECT(this), TQT_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 TDERadioAction(i18n("Circular Selection"),
+ "selectcircle", cut, TQT_TQOBJECT(this), TQT_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 TDEIconEdit::updateAccels()
+{
+ actionCollection()->readShortcutSettings();
+}
+
+TQWidget *TDEIconEdit::createContainer( TQWidget *parent, int index,
+ const TQDomElement &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 TDEIconEdit::setupStatusBar()
+{
+ statusbar = statusBar();
+
+ TQString 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");
+ TQWhatsThis::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 TDEIconEdit::addRecent(const TQString & path)
+{
+ m_actRecent->addURL(KURL( path ));
+}
+
+#include "tdeiconedit.moc"
diff --git a/tdeiconedit/tdeiconedit.desktop b/tdeiconedit/tdeiconedit.desktop
new file mode 100644
index 00000000..44e23ba2
--- /dev/null
+++ b/tdeiconedit/tdeiconedit.desktop
@@ -0,0 +1,94 @@
+[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=TDEIconEdit
+Name[af]=TDE-ikoon-redigeer
+Name[ar]=برنامج TDEIconEdit
+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]=TDEiconedit
+Name[ta]=கேசின்னம் திருத்து
+Name[tr]=K Icon Düzenleyici
+Name[ven]=U sengulusa ha aikhono ya K
+Name[zh_TW]=TDEIconEdit 圖示編輯器
+MimeType=image/x-xpm;image/x-ico;image/png;image/jpeg;
+Exec=tdeiconedit -caption "%c" %i %m %u
+Icon=tdeiconedit
+Path=
+DocPath=tdeiconedit/index.html
+Type=Application
+Terminal=false
+X-DCOP-ServiceType=Multi
+Categories=Qt;TDE;Graphics;
diff --git a/tdeiconedit/tdeiconedit.h b/tdeiconedit/tdeiconedit.h
new file mode 100644
index 00000000..90a21d9f
--- /dev/null
+++ b/tdeiconedit/tdeiconedit.h
@@ -0,0 +1,158 @@
+/*
+ tdeiconedit - a small graphics drawing program for creating KDE icons
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 __TDEICONEDIT_H__
+#define __TDEICONEDIT_H__
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <tqptrlist.h>
+
+#include <tdemainwindow.h>
+#include <kiconloader.h>
+#include <tdemenubar.h>
+#include <kstatusbar.h>
+#include <tdetoolbar.h>
+#include <tdeaccel.h>
+#include <kurl.h>
+#include <tdeaction.h>
+
+#include "knew.h"
+#include "tdeicon.h"
+#include "tdeiconconfig.h"
+#include "tdeicongrid.h"
+#include "kresize.h"
+#include "properties.h"
+
+class TDEIconEdit;
+class KCommandHistory;
+typedef TQPtrList<TDEIconEdit> WindowList;
+
+class TQWhatsThis;
+class TQToolButton;
+class TQLabel;
+class PaletteToolBar;
+
+/**
+* TDEIconEdit
+* @short TDEIconEdit
+* @author Thomas Tanghus <[email protected]>
+* @version 0.4
+*/
+class TDEIconEdit : public TDEMainWindow
+{
+ Q_OBJECT
+
+public:
+ TDEIconEdit( KURL url = KURL(), const char *name = "tdeiconedit");
+ TDEIconEdit( const TQImage image, const char *name = "tdeiconedit");
+ ~TDEIconEdit();
+
+ virtual TQSize sizeHint() const;
+ static WindowList windowList;
+
+signals:
+ void newname(const TQString &);
+
+public slots:
+ virtual void saveProperties(TDEConfig*);
+ virtual void readProperties(TDEConfig*);
+ void updateProperties();
+
+protected slots:
+ void slotNewWin(const TQString & 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 TQString &);
+ void slotUpdateStatusName(const TQString &);
+ void slotUpdateStatusModified(bool);
+ void slotUpdateStatusScaling(int);
+ void slotUpdatePaste(bool);
+ void slotUpdateCopy(bool);
+ void slotOpenBlank(const TQSize);
+ void addRecent(const TQString &);
+
+ virtual void dragEnterEvent(TQDragEnterEvent* event);
+ virtual void dropEvent(TQDropEvent *e);
+
+protected:
+ void init();
+ void setupActions();
+ bool setupStatusBar();
+ void writeConfig();
+ void updateAccels();
+
+ virtual bool queryClose();
+ virtual TQWidget *createContainer( TQWidget*, int, const TQDomElement&, int& );
+
+ KCommandHistory* history;
+ PaletteToolBar *m_paletteToolBar;
+ KStatusBar *statusbar;
+ TDEIconEditGrid *grid;
+ KGridView *gridview;
+ TDEIconEditIcon *icon;
+ TQImage img;
+ TQString m_name;
+
+ TDEAction *m_actCopy, *m_actPaste, *m_actCut, *m_actPasteNew;
+ TDEAction *m_actZoomIn, *m_actZoomOut;
+ TDERecentFilesAction *m_actRecent;
+};
+
+#endif //__TDEICONEDIT_H__
diff --git a/tdeiconedit/tdeiconeditslots.cpp b/tdeiconedit/tdeiconeditslots.cpp
new file mode 100644
index 00000000..913c4037
--- /dev/null
+++ b/tdeiconedit/tdeiconeditslots.cpp
@@ -0,0 +1,543 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqpaintdevicemetrics.h>
+#include <tqpainter.h>
+
+#include <kkeydialog.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <kprinter.h>
+#include <kurldrag.h>
+
+#include "tdeiconedit.h"
+#include "tdeiconcolors.h"
+#include "palettetoolbar.h"
+
+#ifndef PICS_INCLUDED
+#define PICS_INCLUDED
+#include "pics/logo.xpm"
+#endif
+
+void TDEIconEdit::updateProperties()
+{
+ TDEIconEditProperties *props = TDEIconEditProperties::self();
+ gridview->setShowRulers(props->showRulers());
+ if(props->bgMode() == TQWidget::FixedPixmap)
+ {
+ TQPixmap pix(props->bgPixmap());
+ if(pix.isNull())
+ {
+ TQPixmap 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 TDEIconEdit::slotNewWin(const TQString & url)
+{
+ //kdDebug(4640) << "TDEIconEdit::openNewWin() - " << url << endl;
+
+ TDEIconEdit *w = new TDEIconEdit(KURL(url), "tdeiconedit");
+ TQ_CHECK_PTR(w);
+}
+
+
+void TDEIconEdit::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?"), TQString(), 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 TQSize s = newicon.templateSize();
+ //kdDebug(4640) << "Size: " << s.width() << " x " << s.height() << endl;
+ grid->setSize(s);
+ grid->setModified(false);
+ }
+ else if(r == KNewIcon::Template)
+ {
+ TQString str = newicon.templatePath();
+ icon->open(&grid->image(), KURL( str ));
+ }
+ icon->setUrl("");
+ emit newname(i18n("Untitled"));
+ }
+ }
+}
+
+
+void TDEIconEdit::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?"),TQString(), 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 TDEIconEdit::slotClose()
+{
+ //kdDebug(4640) << "TDEIconEdit: Closing " << endl;
+ close();
+}
+
+void TDEIconEdit::slotSave()
+{
+ //kdDebug(4640) << "TDEIconEdit: slotSave() " << endl;
+ icon->save(&grid->image());
+}
+
+
+void TDEIconEdit::slotSaveAs()
+{
+ //kdDebug(4640) << "TDEIconEdit: slotSaveAs() " << endl;
+ icon->saveAs(&grid->image());
+}
+
+
+void TDEIconEdit::slotPrint()
+{
+ KPrinter printer;
+
+ if ( printer.setup(this, i18n("Print %1").arg(icon->url().section('/', -1))) )
+ {
+ int margin = 10, yPos = 0;
+ printer.setCreator("TDE Icon Editor");
+
+ TQPainter p;
+ p.begin( &printer );
+ TQFontMetrics fm = p.fontMetrics();
+ // need width/height
+ TQPaintDeviceMetrics 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 TDEIconEdit::slotZoomIn()
+{
+ grid->zoom(DirIn);
+}
+
+void TDEIconEdit::slotZoomOut()
+{
+ grid->zoom(DirOut);
+}
+
+void TDEIconEdit::slotZoom1()
+{
+ grid->zoomTo(1);
+}
+
+void TDEIconEdit::slotZoom2()
+{
+ grid->zoomTo(2);
+}
+
+void TDEIconEdit::slotZoom5()
+{
+ grid->zoomTo(5);
+}
+
+void TDEIconEdit::slotZoom10()
+{
+ grid->zoomTo(10);
+}
+
+void TDEIconEdit::slotCopy()
+{
+ grid->editCopy();
+}
+
+void TDEIconEdit::slotCut()
+{
+ grid->editCopy(true);
+}
+
+void TDEIconEdit::slotPaste()
+{
+ static_cast<TDERadioAction*>(actionCollection()
+ ->action("tool_find_pixel"))->setChecked(true);
+ grid->setTool(TDEIconEditGrid::Find);
+ grid->editPaste();
+}
+
+void TDEIconEdit::slotClear()
+{
+ grid->editClear();
+}
+
+void TDEIconEdit::slotSelectAll()
+{
+ grid->setTool(TDEIconEditGrid::SelectRect);
+ grid->editSelectAll();
+}
+
+void TDEIconEdit::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?"),TQString(), 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 TDEIconEdit::slotConfigureSettings()
+{
+ TDEIconConfig* c = new TDEIconConfig(this);
+ c->exec();
+ delete c;
+}
+
+void TDEIconEdit::slotConfigureKeys()
+{
+ KKeyDialog::configure(actionCollection());
+
+ TDEIconEdit *ki = 0L;
+ for (ki = windowList.first(); ki; ki = windowList.next())
+ {
+ if (ki != this)
+ {
+ ki->updateAccels();
+ }
+ }
+}
+
+void TDEIconEdit::slotShowGrid()
+{
+ bool b = TDEIconEditProperties::self()->showGrid();
+ grid->setGrid( !b );
+ TDEIconEditProperties::self()->setShowGrid( !b );
+}
+
+void TDEIconEdit::slotToolPointer()
+{
+ grid->setTool(TDEIconEditGrid::Find);
+}
+
+void TDEIconEdit::slotToolFreehand()
+{
+ grid->setTool(TDEIconEditGrid::Freehand);
+}
+
+void TDEIconEdit::slotToolRectangle()
+{
+ grid->setTool(TDEIconEditGrid::Rect);
+}
+
+void TDEIconEdit::slotToolFilledRectangle()
+{
+ grid->setTool(TDEIconEditGrid::FilledRect);
+}
+
+void TDEIconEdit::slotToolCircle()
+{
+ grid->setTool(TDEIconEditGrid::Circle);
+}
+
+void TDEIconEdit::slotToolFilledCircle()
+{
+ grid->setTool(TDEIconEditGrid::FilledCircle);
+}
+
+void TDEIconEdit::slotToolEllipse()
+{
+ grid->setTool(TDEIconEditGrid::Ellipse);
+}
+
+void TDEIconEdit::slotToolFilledEllipse()
+{
+ grid->setTool(TDEIconEditGrid::FilledEllipse);
+}
+
+void TDEIconEdit::slotToolSpray()
+{
+ grid->setTool(TDEIconEditGrid::Spray);
+}
+
+void TDEIconEdit::slotToolFlood()
+{
+ grid->setTool(TDEIconEditGrid::FloodFill);
+}
+
+void TDEIconEdit::slotToolLine()
+{
+ grid->setTool(TDEIconEditGrid::Line);
+}
+
+void TDEIconEdit::slotToolEraser()
+{
+ grid->setTool(TDEIconEditGrid::Eraser);
+}
+
+void TDEIconEdit::slotToolSelectRect()
+{
+ grid->setTool(TDEIconEditGrid::SelectRect);
+}
+
+void TDEIconEdit::slotToolSelectCircle()
+{
+ grid->setTool(TDEIconEditGrid::SelectCircle);
+}
+
+void TDEIconEdit::slotSaved()
+{
+ grid->setModified(false);
+}
+
+void TDEIconEdit::slotUpdateZoom( int s )
+{
+ m_actZoomOut->setEnabled( s>1 );
+}
+
+void TDEIconEdit::slotUpdateStatusPos(int x, int y)
+{
+ TQString str = i18n("Status Position", "%1, %2").arg(x).arg(y);
+ statusbar->changeItem( str, 0);
+}
+
+void TDEIconEdit::slotUpdateStatusSize(int x, int y)
+{
+ TQString str = i18n("Status Size", "%1 x %2").arg(x).arg(y);
+ statusbar->changeItem( str, 1);
+}
+
+void TDEIconEdit::slotUpdateStatusScaling(int s)
+{
+ TDEIconEditProperties::self()->setGridScale( s );
+ TQString str;
+
+ str.sprintf("1:%d", s);
+ statusbar->changeItem( str, 2);
+}
+
+void TDEIconEdit::slotUpdateStatusColors(uint)
+{
+ TQString str = i18n("Colors: %1").arg(grid->numColors());
+ statusbar->changeItem( str, 3);
+}
+
+void TDEIconEdit::slotUpdateStatusColors(uint n, uint *)
+{
+ TQString str = i18n("Colors: %1").arg(n);
+ statusbar->changeItem( str, 3);
+}
+
+
+void TDEIconEdit::slotUpdateStatusMessage(const TQString & msg)
+{
+ statusbar->changeItem( msg, 4);
+}
+
+
+void TDEIconEdit::slotUpdateStatusName(const TQString & name)
+{
+ m_name = name;
+
+ TQString text = m_name;
+
+ if(grid->isModified())
+ {
+ text += " ["+i18n("modified")+"]";
+ }
+
+ setCaption(text);
+}
+
+
+void TDEIconEdit::slotUpdateStatusModified(bool)
+{
+ slotUpdateStatusName(m_name);
+}
+
+void TDEIconEdit::slotUpdatePaste(bool state)
+{
+ m_actPaste->setEnabled(state);
+ m_actPasteNew->setEnabled(state);
+}
+
+
+void TDEIconEdit::slotUpdateCopy(bool state)
+{
+ m_actCopy->setEnabled(state);
+ m_actCut->setEnabled(state);
+}
+
+
+void TDEIconEdit::slotOpenBlank(const TQSize s)
+{
+ grid->loadBlank( s.width(), s.height());
+}
+
+
+void TDEIconEdit::dragEnterEvent(TQDragEnterEvent* 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 TDEIconEdit::dropEvent( TQDropEvent *e )
+{
+ //kdDebug(4640) << "Got TQDropEvent!" << 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/tdeiconedit/tdeiconeditui.rc b/tdeiconedit/tdeiconeditui.rc
new file mode 100644
index 00000000..1b1eff81
--- /dev/null
+++ b/tdeiconedit/tdeiconeditui.rc
@@ -0,0 +1,66 @@
+<!DOCTYPE kpartgui>
+<kpartgui version="2" name="tdeiconedit">
+<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/tdeiconedit/tdeicongrid.cpp b/tdeiconedit/tdeicongrid.cpp
new file mode 100644
index 00000000..8c336428
--- /dev/null
+++ b/tdeiconedit/tdeicongrid.cpp
@@ -0,0 +1,2263 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ Includes portions of code from TQt,
+ 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 <tqpainter.h>
+#include <tqwhatsthis.h>
+#include <tqscrollview.h>
+#include <tqbitmap.h>
+#include <tqclipboard.h>
+#include <tqdatetime.h>
+
+#include <kiconloader.h>
+#include <kruler.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+
+#include "kresize.h"
+#include "properties.h"
+#include "tdeicongrid.h"
+#include "tdeiconedit.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(TQImage *image, KCommandHistory* history, TQWidget *parent, const char *name)
+: TQFrame(parent, name)
+{
+ _corner = 0L;
+ _hruler = _vruler = 0L;
+ _grid = 0L;
+
+ acceptdrop = false;
+
+ TDEIconEditProperties *props = TDEIconEditProperties::self();
+
+ viewport = new TQScrollView(this);
+ TQ_CHECK_PTR(viewport);
+
+ _grid = new TDEIconEditGrid(image, history, viewport->viewport());
+ TQ_CHECK_PTR(_grid);
+ viewport->addChild(_grid);
+ _grid->setGrid(props->showGrid());
+ _grid->setCellSize(props->gridScale());
+
+ TQString 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)" );
+ TQWhatsThis::add( _grid, str );
+
+ if(props->bgMode() == FixedPixmap)
+ {
+ TQPixmap pix(props->bgPixmap());
+ if(pix.isNull())
+ {
+ TQPixmap pmlogo((const char **)logo);
+ pix = pmlogo;
+ }
+ viewport->viewport()->setBackgroundPixmap(pix);
+ _grid->setBackgroundPixmap(pix);
+ }
+ else
+ {
+ viewport->viewport()->setBackgroundColor(props->bgColor());
+ }
+
+ _corner = new TQFrame(this);
+ _corner->setFrameStyle(TQFrame::WinPanel | TQFrame::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" );
+ TQWhatsThis::add( _hruler, str );
+ TQWhatsThis::add( _vruler, str );
+
+ connect(_grid, TQT_SIGNAL(scalingchanged(int)), TQT_SLOT(scalingChange(int)));
+ connect(_grid, TQT_SIGNAL(sizechanged(int, int)), TQT_SLOT(sizeChange(int, int)));
+ connect(_grid, TQT_SIGNAL(needPainting()), TQT_SLOT(paintGrid()));
+ connect( _grid, TQT_SIGNAL(xposchanged(int)), _hruler, TQT_SLOT(slotNewValue(int)) );
+ connect( _grid, TQT_SIGNAL(yposchanged(int)), _vruler, TQT_SLOT(slotNewValue(int)) );
+ connect(viewport, TQT_SIGNAL(contentsMoving(int, int)), TQT_SLOT(moving(int, int)));
+
+ setSizes();
+ TQResizeEvent e(size(), size());
+ resizeEvent(&e);
+}
+
+void KGridView::paintGrid()
+{
+ _grid->update(viewRect());
+}
+
+void KGridView::setSizes()
+{
+ if(TDEIconEditProperties::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)
+{
+ TDEIconEditProperties::self()->setShowRulers( mode );
+ setSizes();
+ TQResizeEvent e(size(), size());
+ resizeEvent(&e);
+}
+
+void KGridView::setAcceptDrop(bool a)
+{
+ if(a == acceptdrop) return;
+ acceptdrop = a;
+ paintDropSite();
+}
+
+void KGridView::checkClipboard()
+{
+ _grid->checkClipboard();
+}
+
+const TQRect 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 TQRect(x, y, cx, cy);
+}
+
+void KGridView::paintDropSite()
+{
+ TQPainter p;
+ p.begin( _grid );
+ p.setRasterOp (NotROP);
+ p.drawRect(viewRect());
+ p.end();
+}
+
+void KGridView::paintEvent(TQPaintEvent *)
+{
+ if(acceptdrop)
+ paintDropSite();
+}
+
+
+void KGridView::resizeEvent(TQResizeEvent*)
+{
+ kdDebug(4640) << "KGridView::resizeEvent" << endl;
+
+ setSizes();
+
+ if(TDEIconEditProperties::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());
+}
+
+
+TDEIconEditGrid::TDEIconEditGrid(TQImage *image, KCommandHistory* h, TQWidget *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 = tqRgb(0,0,0)|OPAQUE_MASK;
+ emit colorSelected(currentcolor);
+
+ setMouseTracking(true);
+
+ setNumRows(32);
+ setNumCols(32);
+ fill(TRANSPARENT);
+
+ connect( kapp->clipboard(), TQT_SIGNAL(dataChanged()), TQT_SLOT(checkClipboard()));
+ connect( h, TQT_SIGNAL(commandExecuted()), this, TQT_SLOT(updatePreviewPixmap() ));
+ createCursors();
+
+ TDEIconEditProperties *props = TDEIconEditProperties::self();
+
+ setTransparencyDisplayType(props->transparencyDisplayType());
+ setTransparencySolidColor(props->transparencySolidColor());
+ setCheckerboardColor1(props->checkerboardColor1());
+ setCheckerboardColor2(props->checkerboardColor2());
+ setCheckerboardSize(props->checkerboardSize());
+}
+
+TDEIconEditGrid::~TDEIconEditGrid()
+{
+ kdDebug(4640) << "TDEIconEditGrid - destructor: done" << endl;
+}
+
+void TDEIconEditGrid::paintEvent(TQPaintEvent *e)
+{
+ const TQRect cellsRect(0, 0, numCols() * cellSize(), numRows() * cellSize());
+ const TQRect paintCellsRect = cellsRect.intersect(e->rect());
+
+ if(!paintCellsRect.isEmpty())
+ {
+ //TQTime time;
+
+ //time.start();
+
+ TQRgb *imageBuffer = new TQRgb[paintCellsRect.width() * paintCellsRect.height()];
+ const int cellsize = cellSize();
+ const int firstCellPixelsRemaining = cellsize - paintCellsRect.left() % cellsize;
+
+ if(transparencyDisplayType() == TRD_SOLIDCOLOR)
+ {
+ const TQRgb 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++)
+ {
+ TQRgb *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;
+ TQRgb *src = gridcolors.data() + cellY * numCols() + firstCellX;
+
+ TQRgb sourcePixel = *src++;
+ int sourceAlpha = tqAlpha(sourcePixel);
+
+ TQRgb c;
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = backgroundColor;
+ }
+ else
+ {
+ const int sourceRed = tqRed(sourcePixel);
+ const int sourceGreen = tqGreen(sourcePixel);
+ const int sourceBlue = tqBlue(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 = tqRgb(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 = tqAlpha(sourcePixel);
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = backgroundColor;
+ }
+ else
+ {
+ const int sourceRed = tqRed(sourcePixel);
+ const int sourceGreen = tqGreen(sourcePixel);
+ const int sourceBlue = tqBlue(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 = tqRgb(r, g, b);
+ }
+ }
+
+ cellPixelsRemaining--;
+
+ *dest++ = c;
+ }
+ }
+ else
+ {
+ // Copy the scanline above.
+ memcpy(dest, dest - paintCellsRect.width(), paintCellsRect.width() * sizeof(TQRgb));
+ }
+ }
+ }
+ 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;
+ }
+
+ TQRgb *color1ScanLine = new TQRgb[paintCellsRect.width()];
+ TQRgb *color2ScanLine = new TQRgb[paintCellsRect.width()];
+ TQRgb *color1Buffer = color1ScanLine;
+ TQRgb *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++)
+ {
+ TQRgb *dest = imageBuffer + (y - paintCellsRect.top()) * paintCellsRect.width();
+ const int cellY = y / cellsize;
+
+ int firstSquareColour;
+ const TQRgb *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(TQRgb));
+ }
+ else
+ {
+ TQRgb *src = gridcolors.data() + cellY * numCols() + firstCellX;
+
+ TQRgb sourcePixel = *src++;
+ int sourceRed = tqRed(sourcePixel);
+ int sourceGreen = tqGreen(sourcePixel);
+ int sourceBlue = tqBlue(sourcePixel);
+ int sourceAlpha = tqAlpha(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 = tqRed(sourcePixel);
+ sourceGreen = tqGreen(sourcePixel);
+ sourceBlue = tqBlue(sourcePixel);
+ sourceAlpha = tqAlpha(sourcePixel);
+ }
+
+ cellPixelsRemaining--;
+
+ TQRgb c;
+
+ if(sourceAlpha == 255)
+ {
+ c = sourcePixel;
+ }
+ else
+ if(sourceAlpha == 0)
+ {
+ c = *checkerboardSrc;
+ }
+ else
+ {
+ const int backgroundColor = *checkerboardSrc;
+ const int backgroundRed = tqRed(backgroundColor);
+ const int backgroundGreen = tqGreen(backgroundColor);
+ const int backgroundBlue = tqBlue(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 = tqRgb(r, g, b);
+ }
+
+ *dest++ = c;
+ checkerboardSrc++;
+ }
+ }
+
+ lastCellY = cellY;
+ lastLineFirstSquareColour = firstSquareColour;
+ }
+
+ delete [] color1ScanLine;
+ delete [] color2ScanLine;
+ }
+
+ TQImage image((uchar *)(imageBuffer), paintCellsRect.width(), paintCellsRect.height(), 32, 0, 0,
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ TQImage::LittleEndian);
+#else
+ TQImage::BigEndian);
+#endif
+ Q_ASSERT(!image.isNull());
+
+ TQPixmap _pixmap;
+ _pixmap.convertFromImage(image);
+
+ TQPainter 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 TDEIconEditGrid::paintForeground(TQPainter* p, TQPaintEvent* e)
+{
+ TQWMatrix matrix;
+
+ matrix.translate(-e->rect().x(), -e->rect().y());
+ p->setWorldMatrix( matrix );
+
+ TQRect cellsRect(0, 0, numCols() * cellSize(), numRows() * cellSize());
+ TQRect 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(TQColor(0, 0, 0));
+ p->setBrush(TQColor(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(TQColor(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 TDEIconEditGrid::mousePressEvent( TQMouseEvent *e )
+{
+ if(!e || (e->button() != Qt::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)
+ {
+ TQPointArray a(pntarray.copy());
+ pntarray.resize(0);
+ drawPointArray(a, Mark);
+ emit selecteddata(false);
+ }
+
+ switch( tool )
+ {
+ case SelectRect:
+ case SelectCircle:
+ isselecting = true;
+ break;
+ default:
+ break;
+ }
+}
+
+void TDEIconEditGrid::mouseMoveEvent( TQMouseEvent *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);
+ }
+
+ TQPoint 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;
+ TQRect area = TQRect( col*cellsize,row*cellsize, cellsize, cellsize ).unite(
+ TQRect ( (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(TQPoint(col, row));
+ setModified(true);
+ break;
+ }
+ default:
+ break;
+ }
+
+ p = *img;
+ emit changed(TQPixmap(p));
+}
+
+void TDEIconEditGrid::mouseReleaseEvent( TQMouseEvent *e )
+{
+ if(!e || (e->button() != Qt::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(TQPoint(col, row));
+ break;
+ }
+ case FloodFill:
+ {
+ TQApplication::setOverrideCursor(waitCursor);
+ drawFlood(col, row, colorAt(cell));
+ TQApplication::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(TQPixmap(p));
+ //emit colorschanged(numColors(), data());
+}
+
+//void TDEIconEditGrid::setColorSelection( const TQColor &color )
+void TDEIconEditGrid::setColorSelection( uint c )
+{
+ currentcolor = c;
+ emit colorSelected(currentcolor);
+}
+
+void TDEIconEditGrid::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 TDEIconEditGrid::load( TQImage *image)
+{
+ kdDebug(4640) << "TDEIconEditGrid::load" << endl;
+
+ setUpdatesEnabled(false);
+
+ if(image == 0L)
+ {
+ TQString 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 TQPixmap &TDEIconEditGrid::pixmap()
+{
+ if(!img->isNull())
+ p = *img;
+ //p.convertFromImage(*img, 0);
+ return(p);
+}
+
+void TDEIconEditGrid::getImage(TQImage *image)
+{
+ kdDebug(4640) << "TDEIconEditGrid::getImage" << endl;
+ *image = *img;
+}
+
+bool TDEIconEditGrid::zoomTo(int scale)
+{
+ TQApplication::setOverrideCursor(waitCursor);
+ setUpdatesEnabled(false);
+ setCellSize( scale );
+ setUpdatesEnabled(true);
+ emit needPainting();
+ TQApplication::restoreOverrideCursor();
+ emit scalingchanged(cellSize());
+
+ if(scale == 1)
+ return false;
+ return true;
+}
+
+bool TDEIconEditGrid::zoom(Direction d)
+{
+ int f = (d == DirIn) ? (cellSize()+1) : (cellSize()-1);
+ TQApplication::setOverrideCursor(waitCursor);
+ setUpdatesEnabled(false);
+ setCellSize( f );
+ setUpdatesEnabled(true);
+ //emit needPainting();
+ TQApplication::restoreOverrideCursor();
+
+ emit scalingchanged(cellSize());
+ if(d == DirOut && cellSize() <= 1)
+ return false;
+ return true;
+}
+
+void TDEIconEditGrid::checkClipboard()
+{
+ bool ok = false;
+ TQImage tmp = clipboardImage(ok);
+ if(ok)
+ emit clipboarddata(true);
+ else
+ {
+ emit clipboarddata(false);
+ }
+}
+
+TQImage TDEIconEditGrid::clipboardImage(bool &ok)
+{
+ //###### Remove me later.
+ //Workaround TQt bug -- check whether format provided first.
+ //Code below is from TQDragObject, to match the mimetype list....
+
+ TQStrList fileFormats = TQImageIO::inputFormats();
+ fileFormats.first();
+ bool oneIsSupported = false;
+ while ( fileFormats.current() )
+ {
+ TQCString format = fileFormats.current();
+ TQCString type = "image/" + format.lower();
+ if (kapp->clipboard()->data()->provides(type ) )
+ {
+ oneIsSupported = true;
+ }
+ fileFormats.next();
+ }
+ if (!oneIsSupported)
+ {
+ ok = false;
+ return TQImage();
+ }
+
+ TQImage image = kapp->clipboard()->image();
+ ok = !image.isNull();
+ if ( ok )
+ {
+ image = image.convertDepth(32);
+ image.setAlphaBuffer(true);
+ }
+ return image;
+}
+
+
+void TDEIconEditGrid::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 TDEIconEditGrid::editClear()
+{
+ clearImage(img);
+ fill(TRANSPARENT);
+ update();
+ setModified(true);
+ p = *img;
+ emit changed(p);
+ emit newmessage(i18n("Cleared"));
+}
+
+TQImage TDEIconEditGrid::getSelection(bool cut)
+{
+ const TQRect rect = pntarray.boundingRect();
+ int nx = 0, ny = 0, nw = 0, nh = 0;
+ rect.rect(&nx, &ny, &nw, &nh);
+
+ TQImage 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(TQPoint(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 );
+ }
+ }
+ }
+
+ TQPointArray 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 TDEIconEditGrid::editCopy(bool cut)
+{
+ kapp->clipboard()->setImage(getSelection(cut));
+ isselecting = false;
+}
+
+
+void TDEIconEditGrid::editPaste(bool paste)
+{
+ bool ok = false;
+ TQImage tmp = clipboardImage(ok);
+
+ TDEIconEditProperties *props = TDEIconEditProperties::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?"),TQString(),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) << "TDEIconEditGrid: Pasting at: " << insrect.x() << " x " << insrect.y() << endl;
+ TQApplication::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 = tqAlpha(*cl) / 255.0;
+ double alphaD = tqAlpha(*l) / 255.0;
+
+ double r = tqRed(*cl) * alphaS + (1 - alphaS) * tqRed(*l) * alphaD;
+ double g = tqGreen(*cl) * alphaS + (1 - alphaS) * tqGreen(*l) * alphaD;
+ double b = tqBlue(*cl) * alphaS + (1 - alphaS) * tqBlue(*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 = tqRgba(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());
+
+ TQApplication::restoreOverrideCursor();
+
+ setModified(true);
+ p = *img;
+ emit changed(TQPixmap(p));
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ emit newmessage(i18n("Done pasting"));
+ }
+ }
+ else
+ {
+ TQString msg = i18n("Invalid pixmap data in clipboard!\n");
+ KMessageBox::sorry(this, msg);
+ }
+}
+
+
+void TDEIconEditGrid::editPasteAsNew()
+{
+ bool ok = false;
+ TQImage tmp = clipboardImage(ok);
+
+ if(ok)
+ {
+ if(isModified())
+ {
+ TDEIconEdit *w = new TDEIconEdit(tmp);
+ TQ_CHECK_PTR(w);
+ }
+ else
+ {
+ *img = tmp;
+ load(img);
+ setModified(true);
+ //repaint(viewRect(), false);
+
+ p = *img;
+ emit changed(TQPixmap(p));
+ emit sizechanged(numCols(), numRows());
+ emit colorschanged(numColors(), data());
+ emit newmessage(i18n("Done pasting"));
+ history->clear();
+ }
+ }
+ else
+ {
+ TQString msg = i18n("Invalid pixmap data in clipboard!\n");
+ KMessageBox::error(this, msg);
+ }
+}
+
+
+void TDEIconEditGrid::editResize()
+{
+ kdDebug(4640) << "TDEIconGrid::editResize" << endl;
+ KResizeDialog *rs = new KResizeDialog(this, 0, TQSize(numCols(), numRows()));
+ if(rs->exec())
+ {
+ const TQSize s = rs->getSize();
+ *img = img->smoothScale(s.width(), s.height());
+ load(img);
+
+ setModified(true);
+ }
+ delete rs;
+}
+
+
+void TDEIconEditGrid::setSize(const TQSize 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 TDEIconEditGrid::createCursors()
+{
+ TQBitmap mask(22, 22);
+ TQPixmap pix;
+
+ cursor_normal = TQCursor(arrowCursor);
+
+ pix = BarIcon("colorpicker-cursor");
+ if(pix.isNull())
+ {
+ cursor_colorpicker = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading colorpicker-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask());
+ pix.setMask(mask);
+ cursor_colorpicker = TQCursor(pix, 1, 21);
+ }
+
+ pix = BarIcon("paintbrush-cursor");
+ if(pix.isNull())
+ {
+ cursor_paint = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading paintbrush.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask());
+ pix.setMask(mask);
+ cursor_paint = TQCursor(pix, 0, 19);
+ }
+
+ pix = BarIcon("fill-cursor");
+ if(pix.isNull())
+ {
+ cursor_flood = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading fill-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask());
+ pix.setMask(mask);
+ cursor_flood = TQCursor(pix, 3, 20);
+ }
+
+ pix = BarIcon("aim-cursor");
+ if(pix.isNull())
+ {
+ cursor_aim = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading aim-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask());
+ pix.setMask(mask);
+ cursor_aim = TQCursor(pix, 10, 10);
+ }
+
+ pix = BarIcon("airbrush-cursor");
+ if(pix.isNull())
+ {
+ cursor_spray = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading airbrush-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask(true));
+ pix.setMask(mask);
+ cursor_spray = TQCursor(pix, 0, 20);
+ }
+
+ pix = BarIcon("eraser-cursor");
+ if(pix.isNull())
+ {
+ cursor_erase = cursor_normal;
+ kdDebug(4640) << "TDEIconEditGrid: Error loading eraser-cursor.xpm" << endl;
+ }
+ else
+ {
+ mask = TQPixmap(pix.createHeuristicMask(true));
+ pix.setMask(mask);
+ cursor_erase = TQCursor(pix, 1, 16);
+ }
+}
+
+
+
+void TDEIconEditGrid::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 TDEIconEditGrid::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 TDEIconEditGrid::drawSpray(TQPoint 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 TQt sources -- it's the branch of TQPointArray::makeEllipse( int x, int y, int w, int h ) that's not normally compiled
+//It seems like TDEIconEdit relied on the TQt1 semantics for makeEllipse, which broke
+//the tool with reasonably recent TQt versions.
+//Thankfully, TQt includes the old code #ifdef'd, which is hence included here
+static void TQPA_makeEllipse(TQPointArray& 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 TDEIconEditGrid::drawEllipse(bool drawit)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ TQPointArray 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)
+ TQPA_makeEllipse(pntarray, x, y, d, d);
+ else if(tool == Ellipse || tool == FilledEllipse)
+ TQPA_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 TDEIconEditGrid::drawRect(bool drawit)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ TQPointArray 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 TDEIconEditGrid::drawLine(bool drawit, bool drawStraight)
+{
+ if(drawit)
+ {
+ drawPointArray(pntarray, Draw);
+ p = *img;
+ emit changed(p);
+ return;
+ }
+
+ TQPointArray 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 = TQMAX(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 TDEIconEditGrid::drawPointArray(TQPointArray a, DrawAction action)
+{
+ TQRect 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) && TQT_TQRECT_OBJECT(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 TDEIconEditGrid::updatePreviewPixmap()
+{
+ p = *img;
+ emit changed(TQPixmap(p));
+}
+
+
+bool TDEIconEditGrid::isMarked(TQPoint point)
+{
+ return isMarked(point.x(), point.y());
+}
+
+
+bool TDEIconEditGrid::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 TQt's image conversion functions
+static bool kdither_32_to_8( const TQImage *src, TQImage *dst )
+{
+ register TQRgb *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),
+ tqRgb( 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 = (TQRgb *)src->scanLine(y);
+ b = dst->scanLine(y);
+ int endian = (TQImage::systemByteOrder() == TQImage::BigEndian);
+ int x;
+ uchar* q = const_cast<TQImage*>(src)->scanLine(y);
+ uchar* q2 = const_cast<TQImage*>(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 = TQMAX(TQMIN(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 = TQMAX(TQMIN(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 TDEIconEditGrid::mapToKDEPalette()
+{
+ TQImage 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 [[[TQT_VERSION IS DEPRECATED]]] > 140
+ *img = img->convertDepthWithPalette(32, iconpalette, 42);
+ load(img);
+ return;
+#endif
+*/
+
+ TQApplication::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);
+ TQApplication::restoreOverrideCursor();
+}
+
+
+void TDEIconEditGrid::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 = tqGray(*l);
+ *l = tqRgba(c, c, c, tqAlpha(*l));
+ }
+ }
+ }
+
+ load(img);
+ setModified(true);
+}
+
+
+void TDEIconEditGrid::clearImage(TQImage *image)
+{
+ if(image->depth() != 32)
+ {
+ image->fill(TRANSPARENT);
+ }
+ else
+ {
+ // TQImage::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 TDEIconEditGrid::setModified(bool m)
+{
+ if(m != modified)
+ {
+ modified = m;
+ emit modifiedchanged(m);
+ }
+}
+
+
+#include "tdeicongrid.moc"
+// vim: set ts=4:
diff --git a/tdeiconedit/tdeicongrid.h b/tdeiconedit/tdeicongrid.h
new file mode 100644
index 00000000..9f41084f
--- /dev/null
+++ b/tdeiconedit/tdeicongrid.h
@@ -0,0 +1,265 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE.
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 __TDEICONEDITGRID_H__
+#define __TDEICONEDITGRID_H__
+
+#include <tqpixmap.h>
+#include <tqimage.h>
+#include <tqcursor.h>
+#include <tqpointarray.h>
+#include <tqframe.h>
+#include <kcommand.h>
+#include <tdelocale.h>
+
+#include "kcolorgrid.h"
+
+class KCommandHistory;
+class KRuler;
+class TDEIconEditGrid;
+class TQScrollView;
+
+enum Direction {
+ DirIn = 0, DirOut = 1,
+ DirUp = DirIn, DirDown = DirOut,
+ DirLeft, DirRight
+};
+
+class DrawCommand : public KCommand {
+ public:
+ DrawCommand( int xx, int yy, uint newcol, TQImage* img, TDEIconEditGrid* g ) {
+ x = xx;
+ y = yy;
+ newcolor = newcol;
+ image = img;
+ grid = g;
+ }
+
+ void execute();
+ void unexecute();
+ TQString name() const {
+ return i18n("Drawed Something");
+ }
+
+ protected:
+ int x;
+ int y;
+ uint newcolor;
+ uint oldcolor;
+ TQImage* image;
+ TDEIconEditGrid* grid;
+};
+
+class RepaintCommand : public KCommand {
+ public:
+ RepaintCommand( TQRect a, TDEIconEditGrid* g ) {
+ area = a;
+ grid = g;
+ }
+
+ void execute();
+ void unexecute() {
+ execute();
+ }
+
+ TQString name() const {
+ return "repainted";
+ }
+ protected:
+ TDEIconEditGrid* grid;
+ TQRect area;
+};
+
+class KGridView : public TQFrame
+{
+ Q_OBJECT
+
+public:
+ KGridView( TQImage *image, KCommandHistory* history, TQWidget * parent = 0, const char *name = 0);
+
+ KRuler *hruler() { return _hruler;}
+ KRuler *vruler() { return _vruler;}
+ TQFrame *corner() { return _corner;}
+ TDEIconEditGrid *grid() { return _grid; }
+ void setShowRulers(bool mode);
+ void setAcceptDrop(bool a);
+ const TQRect viewRect();
+ TQScrollView *viewPortWidget() { return viewport;}
+
+public slots:
+ void sizeChange(int, int);
+ void moving(int, int);
+ void scalingChange(int);
+ void paintGrid();
+ void checkClipboard();
+
+protected:
+ virtual void paintEvent(TQPaintEvent*);
+ virtual void resizeEvent(TQResizeEvent*);
+ void paintDropSite();
+ void setSizes();
+
+ TQFrame *_corner;
+ TDEIconEditGrid *_grid;
+ KRuler *_hruler, *_vruler;
+ TQScrollView *viewport;
+ bool acceptdrop;
+};
+
+/**
+* TDEIconEditGrid
+* @short TDEIconEditGrid
+* @author Thomas Tanghus <[email protected]>
+* @version 0.3
+*/
+class TDEIconEditGrid : public KColorGrid
+{
+ Q_OBJECT
+
+public:
+ TDEIconEditGrid( TQImage *image, KCommandHistory* h, TQWidget * parent = 0, const char *name = 0);
+ virtual ~TDEIconEditGrid();
+
+ 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 TQPixmap &pixmap();
+ const TQImage &image() { return *img; }
+ TQImage clipboardImage(bool &ok);
+ TQImage getSelection(bool);
+ int rows() { return numRows(); };
+ int cols() { return numCols(); };
+ uint getColors( uint *_colors) { return colors(_colors); }
+ bool isMarked(TQPoint 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; }
+ TQColor checkerboardColor1() const { return m_checkerboardColor1; }
+ TQColor checkerboardColor2() const { return m_checkerboardColor2; }
+ CheckerboardSize checkerboardSize() const { return m_checkerboardSize; }
+ TQColor transparencySolidColor() const { return m_transparencySolidColor; }
+
+ void setTransparencyDisplayType(TransparencyDisplayType t) { m_transparencyDisplayType = t; }
+ void setCheckerboardColor1(const TQColor& c) { m_checkerboardColor1 = c; }
+ void setCheckerboardColor2(const TQColor& c) { m_checkerboardColor2 = c; }
+ void setCheckerboardSize(CheckerboardSize size) { m_checkerboardSize = size; }
+ void setTransparencySolidColor(const TQColor& c) { m_transparencySolidColor = c; }
+
+public slots:
+ void load( TQImage *);
+ void editCopy(bool cut = false);
+ void editPaste(bool paste = false);
+ void editPasteAsNew();
+ void editSelectAll();
+ void editClear();
+ void getImage(TQImage *image);
+//#if [[[TQT_VERSION IS DEPRECATED]]] <= 140
+ void editResize();
+//#endif
+ void setSize(const TQSize 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 TQPixmap & );
+ void sizechanged( int, int );
+ void poschanged( int, int );
+ void xposchanged( int );
+ void yposchanged( int );
+ void newmessage(const TQString &);
+ 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(TQPaintEvent*);
+ virtual void paintCell( TQPainter*, int, int ) {}
+ virtual void paintForeground(TQPainter* p, TQPaintEvent* e);
+ virtual void mousePressEvent(TQMouseEvent*);
+ virtual void mouseReleaseEvent(TQMouseEvent*);
+ virtual void mouseMoveEvent(TQMouseEvent*);
+ void createCursors();
+ void drawPointArray(TQPointArray, DrawAction);
+ void drawEllipse(bool);
+ void drawLine(bool drawIt, bool drawStraight);
+ void drawRect(bool);
+ void drawSpray(TQPoint);
+ void drawFlood(int x, int y, uint oldcolor);
+ static void clearImage(TQImage *image);
+
+ uint currentcolor;
+ TQPoint start, end;
+ TQRect insrect;
+ TQSize cbsize;
+ TQImage *img;
+ TQPixmap p;
+ int selected, tool; //, numrows, numcols;
+ bool modified, btndown, ispasting, isselecting;
+ TQPointArray pntarray;
+ KColorArray iconcolors;
+ KCommandHistory* history;
+ KMacroCommand* m_command;
+ TQCursor cursor_normal, cursor_aim, cursor_flood, cursor_spray, cursor_erase, cursor_paint, cursor_colorpicker;
+ TransparencyDisplayType m_transparencyDisplayType;
+ TQColor m_checkerboardColor1;
+ TQColor m_checkerboardColor2;
+ CheckerboardSize m_checkerboardSize;
+ TQColor m_transparencySolidColor;
+};
+
+
+
+#endif //__TDEICONEDITGRID_H__
+
+
+
diff --git a/tdeiconedit/utils.cpp b/tdeiconedit/utils.cpp
new file mode 100644
index 00000000..efd50d88
--- /dev/null
+++ b/tdeiconedit/utils.cpp
@@ -0,0 +1,134 @@
+/*
+ TDE Icon Editor - a small graphics drawing program for the TDE
+
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tdelocale.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;
+ TQ_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
+ TQImageIO::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 TQString &src, const TQString &dest)
+{
+ TQFile f_src(src);
+ TQFile f_dest(dest);
+ TQFileInfo 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 TQString &file)
+{
+ if(file.length() > 0 && TQFile::exists(file))
+ {
+ TQDir 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 TQString &src, const TQString &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/tdeiconedit/utils.h b/tdeiconedit/utils.h
new file mode 100644
index 00000000..197d67b6
--- /dev/null
+++ b/tdeiconedit/utils.h
@@ -0,0 +1,73 @@
+/*
+ tdeiconedit - a small graphics drawing program for the KDE
+
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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 <tqimage.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include <tqdir.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tdeapplication.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 TQPtrList<struct imageFormat> imageFormats;
+extern imageFormats *formats;
+
+void setupImageHandlers();
+
+bool copyFile(const TQString &src, const TQString &dest);
+bool removeFile(const TQString &file);
+bool moveFile(const TQString &src, const TQString &dest);
+uint kdeColor(uint c);
+
+#endif //__UTILS_H__
+
+
+
diff --git a/tdeiconedit/version.h b/tdeiconedit/version.h
new file mode 100644
index 00000000..3c7400a6
--- /dev/null
+++ b/tdeiconedit/version.h
@@ -0,0 +1,36 @@
+/*
+ tdeiconedit - a small graphics drawing program for the KDE
+
+ Copyright (C) 1998 Thomas Tanghus ([email protected])
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU 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__
+
+
+