summaryrefslogtreecommitdiff
path: root/libqtaux/qcolordialog.h
Unidiff
Diffstat (limited to 'libqtaux/qcolordialog.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qcolordialog.h315
1 files changed, 313 insertions, 2 deletions
diff --git a/libqtaux/qcolordialog.h b/libqtaux/qcolordialog.h
index 89c6283..50c6482 100644
--- a/libqtaux/qcolordialog.h
+++ b/libqtaux/qcolordialog.h
@@ -42,6 +42,288 @@
42#include <qdialog.h> 42#include <qdialog.h>
43#endif // QT_H 43#endif // QT_H
44 44
45#include <qlabel.h>
46#include <qlineedit.h>
47#include <qtableview.h>
48#include <qvalidator.h>
49
50struct QWellArrayData;
51
52class QWellArray : public QTableView
53{
54 Q_OBJECT
55// Q_PROPERTY( int numCols READ numCols )
56// Q_PROPERTY( int numRows READ numRows )
57// Q_PROPERTY( int selectedColumn READ selectedColumn )
58// Q_PROPERTY( int selectedRow READ selectedRow )
59
60public:
61 QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
62
63 ~QWellArray() {}
64 QString cellContent( int row, int col ) const;
65 // ### Paul !!! virtual void setCellContent( int row, int col, const QString &);
66
67 // ##### Obsolete since not const
68 int numCols() { return nCols; }
69 int numRows() { return nRows; }
70
71 int numCols() const { return nCols; }
72 int numRows() const { return nRows; }
73
74 // ##### Obsolete since not const
75 int selectedColumn() { return selCol; }
76 int selectedRow() { return selRow; }
77
78 int selectedColumn() const { return selCol; }
79 int selectedRow() const { return selRow; }
80
81 virtual void setSelected( int row, int col );
82
83 void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
84
85 QSize sizeHint() const;
86
87 virtual void setDimension( int rows, int cols );
88 virtual void setCellBrush( int row, int col, const QBrush & );
89 QBrush cellBrush( int row, int col );
90
91signals:
92 void selected( int row, int col );
93
94protected:
95 virtual void setCurrent( int row, int col );
96
97 virtual void drawContents( QPainter *, int row, int col, const QRect& );
98 void drawContents( QPainter * );
99
100 void paintCell( QPainter*, int row, int col );
101 void mousePressEvent( QMouseEvent* );
102 void mouseReleaseEvent( QMouseEvent* );
103 void mouseMoveEvent( QMouseEvent* );
104 void keyPressEvent( QKeyEvent* );
105 void focusInEvent( QFocusEvent* );
106 void focusOutEvent( QFocusEvent* );
107
108private:
109 int curRow;
110 int curCol;
111 int selRow;
112 int selCol;
113 int nCols;
114 int nRows;
115 bool smallStyle;
116 QWellArrayData *d;
117
118private: // Disabled copy constructor and operator=
119#if defined(Q_DISABLE_COPY)
120 QWellArray( const QWellArray & );
121 QWellArray& operator=( const QWellArray & );
122#endif
123};
124
125struct QWellArrayData {
126 QBrush *brush;
127};
128
129class QColNumLineEdit : public QLineEdit
130{
131public:
132 QColNumLineEdit( QWidget *parent, const char* name = 0 )
133 : QLineEdit( parent, name ) { setMaxLength( 3 );}
134 QSize sizeHint() const {
135 return QSize( 30, //#####
136 QLineEdit::sizeHint().height() ); }
137 void setNum( int i ) {
138 QString s;
139 s.setNum(i);
140 bool block = signalsBlocked();
141 blockSignals(TRUE);
142 setText( s );
143 blockSignals(block);
144 }
145 int val() const { return text().toInt(); }
146};
147
148class QColorShowLabel : public QFrame
149{
150 Q_OBJECT
151
152public:
153 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
154 setFrameStyle( QFrame::Panel|QFrame::Sunken );
155 setBackgroundMode( PaletteBackground );
156 setAcceptDrops( TRUE );
157 mousePressed = FALSE;
158 }
159 void setColor( QColor c ) { col = c; }
160
161signals:
162 void colorDropped( QRgb );
163
164protected:
165 void drawContents( QPainter *p );
166 void mousePressEvent( QMouseEvent *e );
167 void mouseMoveEvent( QMouseEvent *e );
168 void mouseReleaseEvent( QMouseEvent *e );
169#ifndef QT_NO_DRAGANDDROP
170 void dragEnterEvent( QDragEnterEvent *e );
171 void dragLeaveEvent( QDragLeaveEvent *e );
172 void dropEvent( QDropEvent *e );
173#endif
174
175private:
176 QColor col;
177 bool mousePressed;
178 QPoint pressPos;
179
180};
181
182class QColorShower : public QWidget
183{
184 Q_OBJECT
185public:
186 QColorShower( QWidget *parent, const char *name = 0 );
187
188 //things that don't emit signals
189 void setHsv( int h, int s, int v );
190
191 int currentAlpha() const { return alphaEd->val(); }
192 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
193 void showAlpha( bool b );
194
195
196 QRgb currentColor() const { return curCol; }
197
198public slots:
199 void setRgb( QRgb rgb );
200
201signals:
202 void newCol( QRgb rgb );
203private slots:
204 void rgbEd();
205 void hsvEd();
206private:
207 void showCurrentColor();
208 int hue, sat, val;
209 QRgb curCol;
210 QColNumLineEdit *hEd;
211 QColNumLineEdit *sEd;
212 QColNumLineEdit *vEd;
213 QColNumLineEdit *rEd;
214 QColNumLineEdit *gEd;
215 QColNumLineEdit *bEd;
216 QColNumLineEdit *alphaEd;
217 QLabel *alphaLab;
218 QColorShowLabel *lab;
219 bool rgbOriginal;
220};
221
222class QColorPicker : public QFrame
223{
224 Q_OBJECT
225public:
226 QColorPicker(QWidget* parent=0, const char* name=0);
227 ~QColorPicker();
228
229public slots:
230 void setCol( int h, int s );
231
232signals:
233 void newCol( int h, int s );
234
235protected:
236 QSize sizeHint() const;
237 QSizePolicy sizePolicy() const;
238 void drawContents(QPainter* p);
239 void mouseMoveEvent( QMouseEvent * );
240 void mousePressEvent( QMouseEvent * );
241
242private:
243 int hue;
244 int sat;
245
246 QPoint colPt();
247 int huePt( const QPoint &pt );
248 int satPt( const QPoint &pt );
249 void setCol( const QPoint &pt );
250
251 QPixmap *pix;
252};
253
254class QColorLuminancePicker : public QWidget
255{
256 Q_OBJECT
257public:
258 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
259 ~QColorLuminancePicker();
260
261public slots:
262 void setCol( int h, int s, int v );
263 void setCol( int h, int s );
264
265signals:
266 void newHsv( int h, int s, int v );
267
268protected:
269// QSize sizeHint() const;
270// QSizePolicy sizePolicy() const;
271 void paintEvent( QPaintEvent*);
272 void mouseMoveEvent( QMouseEvent * );
273 void mousePressEvent( QMouseEvent * );
274
275private:
276 enum { foff = 3, coff = 4 }; //frame and contents offset
277 int val;
278 int hue;
279 int sat;
280
281 int y2val( int y );
282 int val2y( int val );
283 void setVal( int v );
284
285 QPixmap *pix;
286};
287
288class QColorWell : public QWellArray
289{
290public:
291 QColorWell( QWidget *parent, int r, int c, QRgb *vals )
292 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
293 { setDimension(r,c); setWFlags( WResizeNoErase ); }
294 QSizePolicy sizePolicy() const;
295
296protected:
297 void drawContents( QPainter *, int row, int col, const QRect& );
298 void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
299 void mousePressEvent( QMouseEvent *e );
300 void mouseMoveEvent( QMouseEvent *e );
301 void mouseReleaseEvent( QMouseEvent *e );
302#ifndef QT_NO_DRAGANDDROP
303 void dragEnterEvent( QDragEnterEvent *e );
304 void dragLeaveEvent( QDragLeaveEvent *e );
305 void dragMoveEvent( QDragMoveEvent *e );
306 void dropEvent( QDropEvent *e );
307#endif
308
309private:
310 QRgb *values;
311 bool mousePressed;
312 QPoint pressPos;
313 QPoint oldCurrent;
314
315};
316
317class QColIntValidator: public QIntValidator
318{
319public:
320 QColIntValidator( int bottom, int top,
321 QWidget * parent, const char *name = 0 )
322 :QIntValidator( bottom, top, parent, name ) {}
323
324 QValidator::State validate( QString &, int & ) const;
325};
326
45class QColorDialogPrivate; 327class QColorDialogPrivate;
46 328
47class Q_EXPORT QColorDialog : public QDialog 329class Q_EXPORT QColorDialog : public QDialog
@@ -51,7 +333,7 @@ class Q_EXPORT QColorDialog : public QDialog
51public: 333public:
52 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor& 334 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor&
53 static QRgb getRgba( QRgb, bool* ok = 0, 335 static QRgb getRgba( QRgb, bool* ok = 0,
54 QWidget *parent=0, const char* name=0 ); 336 QWidget *parent=0, const char* name=0 );
55 337
56 338
57 static int customCount(); 339 static int customCount();
@@ -74,11 +356,40 @@ private:
74 QColorDialogPrivate *d; 356 QColorDialogPrivate *d;
75 friend class QColorDialogPrivate; 357 friend class QColorDialogPrivate;
76 358
77 private:// Disabled copy constructor and operator= 359private: // Disabled copy constructor and operator=
78#if defined(Q_DISABLE_COPY) 360#if defined(Q_DISABLE_COPY)
79 QColorDialog( const QColorDialog & ); 361 QColorDialog( const QColorDialog & );
80 QColorDialog& operator=( const QColorDialog & ); 362 QColorDialog& operator=( const QColorDialog & );
81#endif 363#endif
82}; 364};
83 365
366class QColorDialogPrivate : public QObject
367{
368Q_OBJECT
369public:
370 QColorDialogPrivate( QColorDialog *p );
371 QRgb currentColor() const { return cs->currentColor(); }
372 void setCurrentColor( QRgb rgb );
373
374 int currentAlpha() const { return cs->currentAlpha(); }
375 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
376 void showAlpha( bool b ) { cs->showAlpha( b ); }
377
378private slots:
379 void addCustom();
380
381 void newHsv( int h, int s, int v );
382 void newColorTypedIn( QRgb rgb );
383 void newCustom( int, int );
384 void newStandard( int, int );
385private:
386 QColorPicker *cp;
387 QColorLuminancePicker *lp;
388 QWellArray *custom;
389 QWellArray *standard;
390 QColorShower *cs;
391 int nextCust;
392 bool compact;
393};
394
84#endif 395#endif