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.
106 lines
3.2 KiB
106 lines
3.2 KiB
15 years ago
|
/*
|
||
11 years ago
|
tdeiconedit - a small graphics drawing program for creating KDE icons
|
||
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.
|
||
|
*/
|
||
|
|
||
|
#ifndef __KCOLORGRID_H__
|
||
|
#define __KCOLORGRID_H__
|
||
|
|
||
15 years ago
|
#include <tqwidget.h>
|
||
|
#include <tqsize.h>
|
||
|
#include <tqrect.h>
|
||
15 years ago
|
|
||
|
#include "utils.h"
|
||
|
|
||
15 years ago
|
#define KArrayUint TQMemArray<uint>
|
||
15 years ago
|
|
||
|
class KColorArray : public KArrayUint
|
||
|
{
|
||
|
public:
|
||
|
void remove(int idx);
|
||
|
void append(uint);
|
||
|
uint closestMatch(uint);
|
||
|
};
|
||
|
|
||
14 years ago
|
class KColorGrid : public TQWidget
|
||
15 years ago
|
{
|
||
|
private:
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
13 years ago
|
KColorGrid( TQWidget * parent = 0, const char *name = 0, int spacing = 0);
|
||
15 years ago
|
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(); }
|
||
13 years ago
|
bool contains(uint c) { return numcolors.contains(c); }
|
||
15 years ago
|
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; }
|
||
13 years ago
|
virtual TQSize sizeHint() const;
|
||
15 years ago
|
|
||
15 years ago
|
void setSize(const TQSize s) { setNumRows(s.height()); setNumCols(s.width()); }
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
//virtual void show();
|
||
|
|
||
|
signals:
|
||
|
void addingcolor(uint);
|
||
|
void colorschanged(uint, uint*);
|
||
|
|
||
|
protected:
|
||
|
void updateCell(int row, int col, bool f);
|
||
15 years ago
|
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 *);
|
||
15 years ago
|
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);
|
||
15 years ago
|
const TQRect viewRect();
|
||
15 years ago
|
|
||
|
//private:
|
||
|
int s, cellsize, totalwidth, totalheight;
|
||
|
int rows, cols, ypos, xpos;
|
||
|
GridState gridstate;
|
||
|
bool hasgrid;
|
||
|
KColorArray gridcolors, numcolors;
|
||
|
};
|
||
|
|
||
|
#endif //__KCOLORGRID_H__
|