summaryrefslogtreecommitdiff
authordrw <drw>2004-02-21 22:54:19 (UTC)
committer drw <drw>2004-02-21 22:54:19 (UTC)
commitf36efd3490299fb9402a2dc2a6bd2a029fcd93cb (patch) (side-by-side diff)
tree701f649c97a730794a45f47a94e09b9d2ce670d0
parent1a89ecd8e2d11d48a8e80b2fd8b1e95b738a286c (diff)
downloadopie-f36efd3490299fb9402a2dc2a6bd2a029fcd93cb.zip
opie-f36efd3490299fb9402a2dc2a6bd2a029fcd93cb.tar.gz
opie-f36efd3490299fb9402a2dc2a6bd2a029fcd93cb.tar.bz2
Moved class defines in qcolordialog.cpp to header so that apps can properly link to libqtaux
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libqtaux/qcolordialog.cpp357
-rw-r--r--libqtaux/qcolordialog.h311
2 files changed, 321 insertions, 347 deletions
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp
index 5881a89..1574841 100644
--- a/libqtaux/qcolordialog.cpp
+++ b/libqtaux/qcolordialog.cpp
@@ -37,22 +37,19 @@
#include "qcolordialog.h"
-#include "qpainter.h"
-#include "qlayout.h"
-#include "qlabel.h"
-#include "qpushbutton.h"
-#include "qlineedit.h"
-#include "qimage.h"
-#include "qpixmap.h"
-#include "qdrawutil.h"
-#include "qvalidator.h"
-#include "qdragobject.h"
-#include "qapplication.h"
-#include "qdragobject.h"
+#include <qpainter.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qdrawutil.h>
+#include <qdragobject.h>
+#include <qapplication.h>
+#include <qdragobject.h>
//////////// QWellArray BEGIN
-#include "qobjectdict.h"
+#include <qobjectdict.h>
//
// W A R N I N G
@@ -65,105 +62,6 @@
//
//
-
-#include "qtableview.h"
-
-
-struct QWellArrayData;
-
-class QWellArray : public QTableView
-{
- Q_OBJECT
- Q_PROPERTY( int numCols READ numCols )
- Q_PROPERTY( int numRows READ numRows )
- Q_PROPERTY( int selectedColumn READ selectedColumn )
- Q_PROPERTY( int selectedRow READ selectedRow )
-
-public:
- QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
-
- ~QWellArray() {}
- QString cellContent( int row, int col ) const;
- // ### Paul !!! virtual void setCellContent( int row, int col, const QString &);
-
- // ##### Obsolete since not const
- int numCols() { return nCols; }
- int numRows() { return nRows; }
-
- int numCols() const { return nCols; }
- int numRows() const { return nRows; }
-
- // ##### Obsolete since not const
- int selectedColumn() { return selCol; }
- int selectedRow() { return selRow; }
-
- int selectedColumn() const { return selCol; }
- int selectedRow() const { return selRow; }
-
- virtual void setSelected( int row, int col );
-
- void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
-
- QSize sizeHint() const;
-
- virtual void setDimension( int rows, int cols );
- virtual void setCellBrush( int row, int col, const QBrush & );
- QBrush cellBrush( int row, int col );
-
-signals:
- void selected( int row, int col );
-
-protected:
- virtual void setCurrent( int row, int col );
-
- virtual void drawContents( QPainter *, int row, int col, const QRect& );
- void drawContents( QPainter * );
-
- void paintCell( QPainter*, int row, int col );
- void mousePressEvent( QMouseEvent* );
- void mouseReleaseEvent( QMouseEvent* );
- void mouseMoveEvent( QMouseEvent* );
- void keyPressEvent( QKeyEvent* );
- void focusInEvent( QFocusEvent* );
- void focusOutEvent( QFocusEvent* );
-
-private:
- int curRow;
- int curCol;
- int selRow;
- int selCol;
- int nCols;
- int nRows;
- bool smallStyle;
- QWellArrayData *d;
-
-private: // Disabled copy constructor and operator=
-#if defined(Q_DISABLE_COPY)
- QWellArray( const QWellArray & );
- QWellArray& operator=( const QWellArray & );
-#endif
-};
-
-
-
-// non-interface ...
-
-
-
-struct QWellArrayData {
- QBrush *brush;
-};
-
-// NOT REVISED
-/* WARNING, NOT
- \class QWellArray qwellarray_p.h
- \brief ....
-
- ....
-
- \ingroup advanced
-*/
-
QWellArray::QWellArray( QWidget *parent, const char * name, bool popup )
: QTableView( parent, name,
popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 )
@@ -566,35 +464,6 @@ static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
c.getHsv(h,s,v);
}
-class QColorWell : public QWellArray
-{
-public:
- QColorWell( QWidget *parent, int r, int c, QRgb *vals )
- :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
- { setDimension(r,c); setWFlags( WResizeNoErase ); }
- QSizePolicy sizePolicy() const;
-
-protected:
- void drawContents( QPainter *, int row, int col, const QRect& );
- void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
- void mousePressEvent( QMouseEvent *e );
- void mouseMoveEvent( QMouseEvent *e );
- void mouseReleaseEvent( QMouseEvent *e );
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent( QDragEnterEvent *e );
- void dragLeaveEvent( QDragLeaveEvent *e );
- void dragMoveEvent( QDragMoveEvent *e );
- void dropEvent( QDropEvent *e );
-#endif
-
-private:
- QRgb *values;
- bool mousePressed;
- QPoint pressPos;
- QPoint oldCurrent;
-
-};
-
QSizePolicy QColorWell::sizePolicy() const
{
return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
@@ -686,76 +555,9 @@ void QColorWell::mouseReleaseEvent( QMouseEvent *e )
mousePressed = FALSE;
}
-class QColorPicker : public QFrame
-{
- Q_OBJECT
-public:
- QColorPicker(QWidget* parent=0, const char* name=0);
- ~QColorPicker();
-
-public slots:
- void setCol( int h, int s );
-
-signals:
- void newCol( int h, int s );
-
-protected:
- QSize sizeHint() const;
- QSizePolicy sizePolicy() const;
- void drawContents(QPainter* p);
- void mouseMoveEvent( QMouseEvent * );
- void mousePressEvent( QMouseEvent * );
-
-private:
- int hue;
- int sat;
-
- QPoint colPt();
- int huePt( const QPoint &pt );
- int satPt( const QPoint &pt );
- void setCol( const QPoint &pt );
-
- QPixmap *pix;
-};
-
static int pWidth = 200;
static int pHeight = 200;
-class QColorLuminancePicker : public QWidget
-{
- Q_OBJECT
-public:
- QColorLuminancePicker(QWidget* parent=0, const char* name=0);
- ~QColorLuminancePicker();
-
-public slots:
- void setCol( int h, int s, int v );
- void setCol( int h, int s );
-
-signals:
- void newHsv( int h, int s, int v );
-
-protected:
-// QSize sizeHint() const;
-// QSizePolicy sizePolicy() const;
- void paintEvent( QPaintEvent*);
- void mouseMoveEvent( QMouseEvent * );
- void mousePressEvent( QMouseEvent * );
-
-private:
- enum { foff = 3, coff = 4 }; //frame and contents offset
- int val;
- int hue;
- int sat;
-
- int y2val( int y );
- int val2y( int val );
- void setVal( int v );
-
- QPixmap *pix;
-};
-
-
int QColorLuminancePicker::y2val( int y )
{
int d = height() - 2*coff - 1;
@@ -935,20 +737,6 @@ void QColorPicker::drawContents(QPainter* p)
}
-class QColorShowLabel;
-
-
-
-class QColIntValidator: public QIntValidator
-{
-public:
- QColIntValidator( int bottom, int top,
- QWidget * parent, const char *name = 0 )
- :QIntValidator( bottom, top, parent, name ) {}
-
- QValidator::State validate( QString &, int & ) const;
-};
-
QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
{
State state = QIntValidator::validate(s,pos);
@@ -967,102 +755,6 @@ QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
return state;
}
-
-
-class QColNumLineEdit : public QLineEdit
-{
-public:
- QColNumLineEdit( QWidget *parent, const char* name = 0 )
- : QLineEdit( parent, name ) { setMaxLength( 3 );}
- QSize sizeHint() const {
- return QSize( 30, //#####
- QLineEdit::sizeHint().height() ); }
- void setNum( int i ) {
- QString s;
- s.setNum(i);
- bool block = signalsBlocked();
- blockSignals(TRUE);
- setText( s );
- blockSignals(block);
- }
- int val() const { return text().toInt(); }
-};
-
-
-class QColorShower : public QWidget
-{
- Q_OBJECT
-public:
- QColorShower( QWidget *parent, const char *name = 0 );
-
- //things that don't emit signals
- void setHsv( int h, int s, int v );
-
- int currentAlpha() const { return alphaEd->val(); }
- void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
- void showAlpha( bool b );
-
-
- QRgb currentColor() const { return curCol; }
-
-public slots:
- void setRgb( QRgb rgb );
-
-signals:
- void newCol( QRgb rgb );
-private slots:
- void rgbEd();
- void hsvEd();
-private:
- void showCurrentColor();
- int hue, sat, val;
- QRgb curCol;
- QColNumLineEdit *hEd;
- QColNumLineEdit *sEd;
- QColNumLineEdit *vEd;
- QColNumLineEdit *rEd;
- QColNumLineEdit *gEd;
- QColNumLineEdit *bEd;
- QColNumLineEdit *alphaEd;
- QLabel *alphaLab;
- QColorShowLabel *lab;
- bool rgbOriginal;
-};
-
-class QColorShowLabel : public QFrame
-{
- Q_OBJECT
-
-public:
- QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
- setFrameStyle( QFrame::Panel|QFrame::Sunken );
- setBackgroundMode( PaletteBackground );
- setAcceptDrops( TRUE );
- mousePressed = FALSE;
- }
- void setColor( QColor c ) { col = c; }
-
-signals:
- void colorDropped( QRgb );
-
-protected:
- void drawContents( QPainter *p );
- void mousePressEvent( QMouseEvent *e );
- void mouseMoveEvent( QMouseEvent *e );
- void mouseReleaseEvent( QMouseEvent *e );
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent( QDragEnterEvent *e );
- void dragLeaveEvent( QDragLeaveEvent *e );
- void dropEvent( QDropEvent *e );
-#endif
-
-private:
- QColor col;
- bool mousePressed;
- QPoint pressPos;
-
-};
-
void QColorShowLabel::drawContents( QPainter *p )
{
p->fillRect( contentsRect(), col );
@@ -1286,35 +978,6 @@ void QColorShower::setHsv( int h, int s, int v )
showCurrentColor();
}
-class QColorDialogPrivate : public QObject
-{
-Q_OBJECT
-public:
- QColorDialogPrivate( QColorDialog *p );
- QRgb currentColor() const { return cs->currentColor(); }
- void setCurrentColor( QRgb rgb );
-
- int currentAlpha() const { return cs->currentAlpha(); }
- void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
- void showAlpha( bool b ) { cs->showAlpha( b ); }
-
-private slots:
- void addCustom();
-
- void newHsv( int h, int s, int v );
- void newColorTypedIn( QRgb rgb );
- void newCustom( int, int );
- void newStandard( int, int );
-private:
- QColorPicker *cp;
- QColorLuminancePicker *lp;
- QWellArray *custom;
- QWellArray *standard;
- QColorShower *cs;
- int nextCust;
- bool compact;
-};
-
//sets all widgets to display h,s,v
void QColorDialogPrivate::newHsv( int h, int s, int v )
{
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 @@
#include <qdialog.h>
#endif // QT_H
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qtableview.h>
+#include <qvalidator.h>
+
+struct QWellArrayData;
+
+class QWellArray : public QTableView
+{
+ Q_OBJECT
+// Q_PROPERTY( int numCols READ numCols )
+// Q_PROPERTY( int numRows READ numRows )
+// Q_PROPERTY( int selectedColumn READ selectedColumn )
+// Q_PROPERTY( int selectedRow READ selectedRow )
+
+public:
+ QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
+
+ ~QWellArray() {}
+ QString cellContent( int row, int col ) const;
+ // ### Paul !!! virtual void setCellContent( int row, int col, const QString &);
+
+ // ##### Obsolete since not const
+ int numCols() { return nCols; }
+ int numRows() { return nRows; }
+
+ int numCols() const { return nCols; }
+ int numRows() const { return nRows; }
+
+ // ##### Obsolete since not const
+ int selectedColumn() { return selCol; }
+ int selectedRow() { return selRow; }
+
+ int selectedColumn() const { return selCol; }
+ int selectedRow() const { return selRow; }
+
+ virtual void setSelected( int row, int col );
+
+ void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
+
+ QSize sizeHint() const;
+
+ virtual void setDimension( int rows, int cols );
+ virtual void setCellBrush( int row, int col, const QBrush & );
+ QBrush cellBrush( int row, int col );
+
+signals:
+ void selected( int row, int col );
+
+protected:
+ virtual void setCurrent( int row, int col );
+
+ virtual void drawContents( QPainter *, int row, int col, const QRect& );
+ void drawContents( QPainter * );
+
+ void paintCell( QPainter*, int row, int col );
+ void mousePressEvent( QMouseEvent* );
+ void mouseReleaseEvent( QMouseEvent* );
+ void mouseMoveEvent( QMouseEvent* );
+ void keyPressEvent( QKeyEvent* );
+ void focusInEvent( QFocusEvent* );
+ void focusOutEvent( QFocusEvent* );
+
+private:
+ int curRow;
+ int curCol;
+ int selRow;
+ int selCol;
+ int nCols;
+ int nRows;
+ bool smallStyle;
+ QWellArrayData *d;
+
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ QWellArray( const QWellArray & );
+ QWellArray& operator=( const QWellArray & );
+#endif
+};
+
+struct QWellArrayData {
+ QBrush *brush;
+};
+
+class QColNumLineEdit : public QLineEdit
+{
+public:
+ QColNumLineEdit( QWidget *parent, const char* name = 0 )
+ : QLineEdit( parent, name ) { setMaxLength( 3 );}
+ QSize sizeHint() const {
+ return QSize( 30, //#####
+ QLineEdit::sizeHint().height() ); }
+ void setNum( int i ) {
+ QString s;
+ s.setNum(i);
+ bool block = signalsBlocked();
+ blockSignals(TRUE);
+ setText( s );
+ blockSignals(block);
+ }
+ int val() const { return text().toInt(); }
+};
+
+class QColorShowLabel : public QFrame
+{
+ Q_OBJECT
+
+public:
+ QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
+ setFrameStyle( QFrame::Panel|QFrame::Sunken );
+ setBackgroundMode( PaletteBackground );
+ setAcceptDrops( TRUE );
+ mousePressed = FALSE;
+ }
+ void setColor( QColor c ) { col = c; }
+
+signals:
+ void colorDropped( QRgb );
+
+protected:
+ void drawContents( QPainter *p );
+ void mousePressEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent( QDragEnterEvent *e );
+ void dragLeaveEvent( QDragLeaveEvent *e );
+ void dropEvent( QDropEvent *e );
+#endif
+
+private:
+ QColor col;
+ bool mousePressed;
+ QPoint pressPos;
+
+};
+
+class QColorShower : public QWidget
+{
+ Q_OBJECT
+public:
+ QColorShower( QWidget *parent, const char *name = 0 );
+
+ //things that don't emit signals
+ void setHsv( int h, int s, int v );
+
+ int currentAlpha() const { return alphaEd->val(); }
+ void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
+ void showAlpha( bool b );
+
+
+ QRgb currentColor() const { return curCol; }
+
+public slots:
+ void setRgb( QRgb rgb );
+
+signals:
+ void newCol( QRgb rgb );
+private slots:
+ void rgbEd();
+ void hsvEd();
+private:
+ void showCurrentColor();
+ int hue, sat, val;
+ QRgb curCol;
+ QColNumLineEdit *hEd;
+ QColNumLineEdit *sEd;
+ QColNumLineEdit *vEd;
+ QColNumLineEdit *rEd;
+ QColNumLineEdit *gEd;
+ QColNumLineEdit *bEd;
+ QColNumLineEdit *alphaEd;
+ QLabel *alphaLab;
+ QColorShowLabel *lab;
+ bool rgbOriginal;
+};
+
+class QColorPicker : public QFrame
+{
+ Q_OBJECT
+public:
+ QColorPicker(QWidget* parent=0, const char* name=0);
+ ~QColorPicker();
+
+public slots:
+ void setCol( int h, int s );
+
+signals:
+ void newCol( int h, int s );
+
+protected:
+ QSize sizeHint() const;
+ QSizePolicy sizePolicy() const;
+ void drawContents(QPainter* p);
+ void mouseMoveEvent( QMouseEvent * );
+ void mousePressEvent( QMouseEvent * );
+
+private:
+ int hue;
+ int sat;
+
+ QPoint colPt();
+ int huePt( const QPoint &pt );
+ int satPt( const QPoint &pt );
+ void setCol( const QPoint &pt );
+
+ QPixmap *pix;
+};
+
+class QColorLuminancePicker : public QWidget
+{
+ Q_OBJECT
+public:
+ QColorLuminancePicker(QWidget* parent=0, const char* name=0);
+ ~QColorLuminancePicker();
+
+public slots:
+ void setCol( int h, int s, int v );
+ void setCol( int h, int s );
+
+signals:
+ void newHsv( int h, int s, int v );
+
+protected:
+// QSize sizeHint() const;
+// QSizePolicy sizePolicy() const;
+ void paintEvent( QPaintEvent*);
+ void mouseMoveEvent( QMouseEvent * );
+ void mousePressEvent( QMouseEvent * );
+
+private:
+ enum { foff = 3, coff = 4 }; //frame and contents offset
+ int val;
+ int hue;
+ int sat;
+
+ int y2val( int y );
+ int val2y( int val );
+ void setVal( int v );
+
+ QPixmap *pix;
+};
+
+class QColorWell : public QWellArray
+{
+public:
+ QColorWell( QWidget *parent, int r, int c, QRgb *vals )
+ :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
+ { setDimension(r,c); setWFlags( WResizeNoErase ); }
+ QSizePolicy sizePolicy() const;
+
+protected:
+ void drawContents( QPainter *, int row, int col, const QRect& );
+ void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
+ void mousePressEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent( QDragEnterEvent *e );
+ void dragLeaveEvent( QDragLeaveEvent *e );
+ void dragMoveEvent( QDragMoveEvent *e );
+ void dropEvent( QDropEvent *e );
+#endif
+
+private:
+ QRgb *values;
+ bool mousePressed;
+ QPoint pressPos;
+ QPoint oldCurrent;
+
+};
+
+class QColIntValidator: public QIntValidator
+{
+public:
+ QColIntValidator( int bottom, int top,
+ QWidget * parent, const char *name = 0 )
+ :QIntValidator( bottom, top, parent, name ) {}
+
+ QValidator::State validate( QString &, int & ) const;
+};
+
class QColorDialogPrivate;
class Q_EXPORT QColorDialog : public QDialog
@@ -81,4 +363,33 @@ private: // Disabled copy constructor and operator=
#endif
};
+class QColorDialogPrivate : public QObject
+{
+Q_OBJECT
+public:
+ QColorDialogPrivate( QColorDialog *p );
+ QRgb currentColor() const { return cs->currentColor(); }
+ void setCurrentColor( QRgb rgb );
+
+ int currentAlpha() const { return cs->currentAlpha(); }
+ void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
+ void showAlpha( bool b ) { cs->showAlpha( b ); }
+
+private slots:
+ void addCustom();
+
+ void newHsv( int h, int s, int v );
+ void newColorTypedIn( QRgb rgb );
+ void newCustom( int, int );
+ void newStandard( int, int );
+private:
+ QColorPicker *cp;
+ QColorLuminancePicker *lp;
+ QWellArray *custom;
+ QWellArray *standard;
+ QColorShower *cs;
+ int nextCust;
+ bool compact;
+};
+
#endif