Source Code (Use browser search to find items of interest.)
Class Index
qt'QColorDialog (./qt-2.1.0/src/dialogs/qcolordialog.h:35)
class Q_EXPORT QColorDialog : public QDialog
{
Q_OBJECT
public:
static QColor getColor( QColor, QWidget *parent=0, const char* name=0 );
static QRgb getRgba( QRgb, bool* ok = 0,
QWidget *parent=0, const char* name=0 );
static int customCount();
static QRgb customColor( int );
static void setCustomColor( int, QRgb );
private:
~QColorDialog();
QColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE );
void setColor( QColor );
QColor color() const;
private:
void setSelectedAlpha( int );
int selectedAlpha() const;
void showCustom( bool=TRUE );
private:
QColorDialogPrivate *d;
friend class QColorDialogPrivate;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QColorDialog( const QColorDialog & );
QColorDialog& operator=( const QColorDialog & );
#endif
};
qt'QColorDialog::customCount() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:66)
int QColorDialog::customCount()
{
return 2*8;
}
/*!
Returns custom color number \a i as a QRgb.
*/
qt'QColorDialog::customColor() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:74)
QRgb QColorDialog::customColor( int i )
{
initRGB();
if ( i < 0 || i >= customCount() ) {
#ifdef CHECK_RANGE
qWarning( "QColorDialog::customColor() index %d out of range", i );
#endif
i = 0;
}
return cusrgb[i];
}
/*!
Sets custom color number \a i to the QRgb value \a c.
*/
qt'QColorDialog::setCustomColor() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:89)
void QColorDialog::setCustomColor( int i, QRgb c )
{
initRGB();
if ( i < 0 || i >= customCount() ) {
#ifdef CHECK_RANGE
qWarning( "QColorDialog::customColor() index %d out of range", i );
#endif
return;
}
cusrgb[i] = c;
}
qt'QColorDialog::QColorDialog() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1003)
QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) :
QDialog(parent, name, modal )
{
d = new QColorDialogPrivate( this );
}
/*!
Pops up a modal color dialog letting the user choose a color and returns
that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels
the dialog. All colors allocated by the dialog will be deallocated
before this function returns.
*/
qt'QColorDialog::getColor() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1018)
QColor QColorDialog::getColor( QColor initial, QWidget *parent,
const char *name )
{
int allocContext = QColor::enterAllocContext();
QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
dlg->setCaption( QColorDialog::tr( "Select color" ) );
dlg->setColor( initial );
int resultCode = dlg->exec();
QColor::leaveAllocContext();
QColor result;
if ( resultCode == QDialog::Accepted )
result = dlg->color();
QColor::destroyAllocContext(allocContext);
delete dlg;
return result;
}
/*!
Pops up a modal color dialog, letting the user choose a color and an
alpha channel value. The color+alpha is initially set to \a initial.
If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
and FALSE if the user clicked Cancel.
If the user clicks Cancel the \a initial value is returned.
*/
qt'QColorDialog::getRgba() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1048)
QRgb QColorDialog::getRgba( QRgb initial, bool *ok,
QWidget *parent, const char* name )
{
int allocContext = QColor::enterAllocContext();
QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
dlg->setColor( initial );
dlg->setSelectedAlpha( qAlpha(initial) );
int resultCode = dlg->exec();
QColor::leaveAllocContext();
QRgb result = initial;
if ( resultCode == QDialog::Accepted ) {
QRgb c = dlg->color().rgb();
int alpha = dlg->selectedAlpha();
result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
}
if ( ok )
*ok = resultCode == QDialog::Accepted;
QColor::destroyAllocContext(allocContext);
delete dlg;
return result;
}
/*!
Returns the color currently selected in the dialog.
\sa setColor()
*/
qt'QColorDialog::color() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1081)
QColor QColorDialog::color() const
{
return QColor(d->currentColor());
}
/*! Destructs the dialog and frees any memory it allocated.
*/
qt'QColorDialog::~QColorDialog() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1091)
QColorDialog::~QColorDialog()
{
//d inherits QObject, so it is deleted by Qt.
}
/*!
Sets the color shown in the dialog to \a c.
\sa color()
*/
qt'QColorDialog::setColor() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1103)
void QColorDialog::setColor( QColor c )
{
d->setCurrentColor( c.rgb() );
}
/*!
Sets the initial alpha channel value to \a a, and show the alpha channel
entry box.
*/
qt'QColorDialog::setSelectedAlpha() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1116)
void QColorDialog::setSelectedAlpha( int a )
{
d->showAlpha( TRUE );
d->setCurrentAlpha( a );
}
/*!
Returns the value selected for the alpha channel.
*/
qt'QColorDialog::selectedAlpha() (./qt-2.1.0/src/dialogs/qcolordialog.cpp:1127)
int QColorDialog::selectedAlpha() const
{
return d->currentAlpha();
}