You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
266 lines
7.2 KiB
266 lines
7.2 KiB
15 years ago
|
/*
|
||
13 years ago
|
TDE Icon Editor - a small graphics drawing program for the TDE.
|
||
15 years ago
|
Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
|
||
|
|
||
|
This program is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
11 years ago
|
#ifndef __TDEICONEDITGRID_H__
|
||
|
#define __TDEICONEDITGRID_H__
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqpixmap.h>
|
||
|
#include <tqimage.h>
|
||
|
#include <tqcursor.h>
|
||
|
#include <tqpointarray.h>
|
||
|
#include <tqframe.h>
|
||
15 years ago
|
#include <kcommand.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include "kcolorgrid.h"
|
||
|
|
||
|
class KCommandHistory;
|
||
|
class KRuler;
|
||
12 years ago
|
class TDEIconEditGrid;
|
||
15 years ago
|
class TQScrollView;
|
||
15 years ago
|
|
||
|
enum Direction {
|
||
|
DirIn = 0, DirOut = 1,
|
||
|
DirUp = DirIn, DirDown = DirOut,
|
||
|
DirLeft, DirRight
|
||
|
};
|
||
|
|
||
|
class DrawCommand : public KCommand {
|
||
|
public:
|
||
12 years ago
|
DrawCommand( int xx, int yy, uint newcol, TQImage* img, TDEIconEditGrid* g ) {
|
||
15 years ago
|
x = xx;
|
||
|
y = yy;
|
||
|
newcolor = newcol;
|
||
|
image = img;
|
||
|
grid = g;
|
||
|
}
|
||
|
|
||
|
void execute();
|
||
|
void unexecute();
|
||
15 years ago
|
TQString name() const {
|
||
15 years ago
|
return i18n("Drawed Something");
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
int x;
|
||
|
int y;
|
||
|
uint newcolor;
|
||
|
uint oldcolor;
|
||
15 years ago
|
TQImage* image;
|
||
12 years ago
|
TDEIconEditGrid* grid;
|
||
15 years ago
|
};
|
||
|
|
||
|
class RepaintCommand : public KCommand {
|
||
|
public:
|
||
12 years ago
|
RepaintCommand( TQRect a, TDEIconEditGrid* g ) {
|
||
15 years ago
|
area = a;
|
||
|
grid = g;
|
||
|
}
|
||
|
|
||
|
void execute();
|
||
|
void unexecute() {
|
||
|
execute();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString name() const {
|
||
14 years ago
|
return "repainted";
|
||
15 years ago
|
}
|
||
|
protected:
|
||
12 years ago
|
TDEIconEditGrid* grid;
|
||
15 years ago
|
TQRect area;
|
||
15 years ago
|
};
|
||
|
|
||
14 years ago
|
class KGridView : public TQFrame
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
13 years ago
|
KGridView( TQImage *image, KCommandHistory* history, TQWidget * parent = 0, const char *name = 0);
|
||
15 years ago
|
|
||
|
KRuler *hruler() { return _hruler;}
|
||
|
KRuler *vruler() { return _vruler;}
|
||
15 years ago
|
TQFrame *corner() { return _corner;}
|
||
12 years ago
|
TDEIconEditGrid *grid() { return _grid; }
|
||
15 years ago
|
void setShowRulers(bool mode);
|
||
|
void setAcceptDrop(bool a);
|
||
15 years ago
|
const TQRect viewRect();
|
||
|
TQScrollView *viewPortWidget() { return viewport;}
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
void sizeChange(int, int);
|
||
|
void moving(int, int);
|
||
|
void scalingChange(int);
|
||
|
void paintGrid();
|
||
|
void checkClipboard();
|
||
|
|
||
|
protected:
|
||
15 years ago
|
virtual void paintEvent(TQPaintEvent*);
|
||
|
virtual void resizeEvent(TQResizeEvent*);
|
||
15 years ago
|
void paintDropSite();
|
||
|
void setSizes();
|
||
|
|
||
15 years ago
|
TQFrame *_corner;
|
||
12 years ago
|
TDEIconEditGrid *_grid;
|
||
15 years ago
|
KRuler *_hruler, *_vruler;
|
||
15 years ago
|
TQScrollView *viewport;
|
||
15 years ago
|
bool acceptdrop;
|
||
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* TDEIconEditGrid
|
||
|
* @short TDEIconEditGrid
|
||
15 years ago
|
* @author Thomas Tanghus <tanghus@kde.org>
|
||
|
* @version 0.3
|
||
|
*/
|
||
12 years ago
|
class TDEIconEditGrid : public KColorGrid
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
12 years ago
|
TDEIconEditGrid( TQImage *image, KCommandHistory* h, TQWidget * parent = 0, const char *name = 0);
|
||
|
virtual ~TDEIconEditGrid();
|
||
15 years ago
|
|
||
|
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);
|
||
15 years ago
|
const TQPixmap &pixmap();
|
||
|
const TQImage &image() { return *img; }
|
||
|
TQImage clipboardImage(bool &ok);
|
||
|
TQImage getSelection(bool);
|
||
15 years ago
|
int rows() { return numRows(); };
|
||
|
int cols() { return numCols(); };
|
||
|
uint getColors( uint *_colors) { return colors(_colors); }
|
||
15 years ago
|
bool isMarked(TQPoint p);
|
||
15 years ago
|
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; }
|
||
15 years ago
|
TQColor checkerboardColor1() const { return m_checkerboardColor1; }
|
||
|
TQColor checkerboardColor2() const { return m_checkerboardColor2; }
|
||
15 years ago
|
CheckerboardSize checkerboardSize() const { return m_checkerboardSize; }
|
||
15 years ago
|
TQColor transparencySolidColor() const { return m_transparencySolidColor; }
|
||
15 years ago
|
|
||
|
void setTransparencyDisplayType(TransparencyDisplayType t) { m_transparencyDisplayType = t; }
|
||
15 years ago
|
void setCheckerboardColor1(const TQColor& c) { m_checkerboardColor1 = c; }
|
||
|
void setCheckerboardColor2(const TQColor& c) { m_checkerboardColor2 = c; }
|
||
15 years ago
|
void setCheckerboardSize(CheckerboardSize size) { m_checkerboardSize = size; }
|
||
15 years ago
|
void setTransparencySolidColor(const TQColor& c) { m_transparencySolidColor = c; }
|
||
15 years ago
|
|
||
|
public slots:
|
||
15 years ago
|
void load( TQImage *);
|
||
15 years ago
|
void editCopy(bool cut = false);
|
||
|
void editPaste(bool paste = false);
|
||
|
void editPasteAsNew();
|
||
|
void editSelectAll();
|
||
|
void editClear();
|
||
15 years ago
|
void getImage(TQImage *image);
|
||
14 years ago
|
//#if [[[TQT_VERSION IS DEPRECATED]]] <= 140
|
||
15 years ago
|
void editResize();
|
||
|
//#endif
|
||
15 years ago
|
void setSize(const TQSize s);
|
||
15 years ago
|
void grayScale();
|
||
|
void mapToKDEPalette();
|
||
|
void setTool(DrawTool tool);
|
||
|
bool zoom(Direction direct);
|
||
|
bool zoomTo(int);
|
||
|
|
||
|
void checkClipboard();
|
||
|
|
||
|
signals:
|
||
|
void scalingchanged(int);
|
||
15 years ago
|
void changed( const TQPixmap & );
|
||
15 years ago
|
void sizechanged( int, int );
|
||
|
void poschanged( int, int );
|
||
|
void xposchanged( int );
|
||
|
void yposchanged( int );
|
||
15 years ago
|
void newmessage(const TQString &);
|
||
15 years ago
|
void clipboarddata(bool);
|
||
|
void selecteddata(bool);
|
||
|
void needPainting();
|
||
|
void modifiedchanged(bool);
|
||
|
void colorSelected(uint);
|
||
|
|
||
|
protected slots:
|
||
|
void setColorSelection( uint );
|
||
|
void updatePreviewPixmap();
|
||
|
|
||
|
protected:
|
||
15 years ago
|
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*);
|
||
15 years ago
|
void createCursors();
|
||
15 years ago
|
void drawPointArray(TQPointArray, DrawAction);
|
||
15 years ago
|
void drawEllipse(bool);
|
||
|
void drawLine(bool drawIt, bool drawStraight);
|
||
|
void drawRect(bool);
|
||
15 years ago
|
void drawSpray(TQPoint);
|
||
15 years ago
|
void drawFlood(int x, int y, uint oldcolor);
|
||
15 years ago
|
static void clearImage(TQImage *image);
|
||
15 years ago
|
|
||
|
uint currentcolor;
|
||
15 years ago
|
TQPoint start, end;
|
||
|
TQRect insrect;
|
||
|
TQSize cbsize;
|
||
|
TQImage *img;
|
||
|
TQPixmap p;
|
||
15 years ago
|
int selected, tool; //, numrows, numcols;
|
||
|
bool modified, btndown, ispasting, isselecting;
|
||
15 years ago
|
TQPointArray pntarray;
|
||
15 years ago
|
KColorArray iconcolors;
|
||
|
KCommandHistory* history;
|
||
|
KMacroCommand* m_command;
|
||
15 years ago
|
TQCursor cursor_normal, cursor_aim, cursor_flood, cursor_spray, cursor_erase, cursor_paint, cursor_colorpicker;
|
||
15 years ago
|
TransparencyDisplayType m_transparencyDisplayType;
|
||
15 years ago
|
TQColor m_checkerboardColor1;
|
||
|
TQColor m_checkerboardColor2;
|
||
15 years ago
|
CheckerboardSize m_checkerboardSize;
|
||
15 years ago
|
TQColor m_transparencySolidColor;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
|
||
11 years ago
|
#endif //__TDEICONEDITGRID_H__
|
||
15 years ago
|
|
||
|
|
||
|
|