00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef __ko_iconchooser_h__
00022
#define __ko_iconchooser_h__
00023
00024
#include <qgridview.h>
00025
#include <qptrlist.h>
00026
#include <qpixmap.h>
00027
00028
class KoIconItem
00029 {
00030
public:
00031 KoIconItem() {}
00032
virtual ~KoIconItem() {}
00033
00034
bool hasValidPixmap() {
return validPixmap; }
00035
bool validPixmap;
00036
bool hasValidThumb() {
return validThumb; }
00037
bool validThumb;
00038
00039
virtual int spacing()
const {
return 0; }
00040
virtual void setSpacing(
int) {}
00041
virtual QPixmap &pixmap() const = 0;
00042 virtual
QPixmap &thumbPixmap() const = 0;
00043 };
00044
00045 class KoPixmapWidget : public
QFrame
00046 {
00047
public:
00048 KoPixmapWidget(
const QPixmap &aPixmap,
QWidget *parent = 0L,
const char *name = 0L);
00049 ~KoPixmapWidget();
00050
00051
protected:
00052
void paintEvent(
QPaintEvent *e);
00053
00054
private:
00055
QPixmap mPixmap;
00056 };
00057
00058
class KoIconChooser:
public QGridView
00059 {
00060 Q_OBJECT
00061
public:
00062 KoIconChooser(
QSize iconSize,
QWidget *parent = 0L,
const char *name = 0L);
00063
virtual ~KoIconChooser();
00064
00065
bool autoDelete()
const {
return mIconList.autoDelete(); }
00066
void setAutoDelete(
bool b) {mIconList.setAutoDelete(b); }
00067
00068
void addItem(KoIconItem *item);
00069
bool removeItem(KoIconItem *item);
00070
void clear();
00071
00072 KoIconItem *currentItem();
00073
void setCurrentItem(KoIconItem *item);
00074
00075
void setDragEnabled(
bool allow) { mDragEnabled = allow; }
00076
bool dragEnabled()
const {
return mDragEnabled; }
00077
00078 signals:
00079
void selected(KoIconItem *item);
00080
00081
protected:
00082
void keyPressEvent(
QKeyEvent *e);
00083
void mousePressEvent(
QMouseEvent *e);
00084
void mouseReleaseEvent(
QMouseEvent *e);
00085
void mouseMoveEvent(
QMouseEvent *e);
00086
void resizeEvent(
QResizeEvent *e);
00087
void paintCell(
QPainter *p,
int row,
int col);
00088
virtual void startDrag();
00089
00090
private:
00091 KoIconItem *itemAt(
int row,
int col);
00092 KoIconItem *itemAt(
int index);
00093
int cellIndex(
int row,
int col);
00094
void calculateCells();
00095
void showFullPixmap(
const QPixmap &pix,
const QPoint &p);
00096
00097
private:
00098
QPtrList<KoIconItem> mIconList;
00099 KoPixmapWidget *mPixmapWidget;
00100
int mItemWidth;
00101
int mItemHeight;
00102
int mItemCount;
00103
int nCols;
00104
int mCurRow;
00105
int mCurCol;
00106
int mMargin;
00107
QPoint mDragStartPos;
00108
bool mMouseButtonDown;
00109
bool mDragEnabled;
00110 };
00111
00112
00113
00114
00115
class KoPatternChooser :
public QWidget
00116 {
00117 Q_OBJECT
00118
public:
00119 KoPatternChooser(
const QPtrList<KoIconItem> &list,
QWidget *parent,
const char *name = 0 );
00120 ~KoPatternChooser();
00121
00122 KoIconItem *currentPattern();
00123
void setCurrentPattern( KoIconItem * );
00124
void addPattern( KoIconItem * );
00125
00126
private:
00127 KoIconChooser *chooser;
00128
00129 signals:
00130
void selected( KoIconItem * );
00131 };
00132
00133
00134
#endif