GradientWidget Class Reference

#include <gradients.h>

Inheritance diagram for GradientWidget:

Inheritance graph
[legend]
Collaboration diagram for GradientWidget:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 125 of file gradients.h.

Public Slots

void setDefault1 ()
void setDefault2 ()
void setDefault3 ()
void setDefault4 ()

Public Member Functions

 GradientWidget (QWidget *parent)

Private Member Functions

void setDefault (int i)

Private Attributes

GradientRendererm_renderer
GradientEditorm_editor
QRadioButtonm_linearButton
QRadioButtonm_radialButton
QRadioButtonm_conicalButton
QRadioButtonm_padSpreadButton
QRadioButtonm_reflectSpreadButton
QRadioButtonm_repeatSpreadButton


Constructor & Destructor Documentation

GradientWidget::GradientWidget ( QWidget parent  ) 

Definition at line 256 of file gradients.cpp.

References QBoxLayout::addStretch(), QBoxLayout::addWidget(), QObject::connect(), QGLFormat::hasOpenGL(), QWidget::hide(), GradientRenderer::hoverPoints(), ArthurFrame::loadDescription(), ArthurFrame::loadSourceFile(), m_conicalButton, m_editor, m_linearButton, m_padSpreadButton, m_radialButton, m_reflectSpreadButton, m_renderer, m_repeatSpreadButton, QWidget::setAttribute(), QAbstractButton::setCheckable(), QAbstractButton::setChecked(), setDefault1(), setDefault2(), setDefault3(), setDefault4(), QWidget::setDisabled(), QWidget::setFixedWidth(), QAbstractButton::setText(), QGroupBox::setTitle(), QWidget::setWindowTitle(), SIGNAL, QTimer::singleShot(), SLOT, and Qt::WA_ContentsPropagated.

00257     : QWidget(parent)
00258 {
00259     setWindowTitle("Gradients");
00260 
00261     m_renderer = new GradientRenderer(this);
00262 
00263     QGroupBox *mainGroup = new QGroupBox(this);
00264     mainGroup->setTitle("Gradients");
00265 
00266     QGroupBox *editorGroup = new QGroupBox(mainGroup);
00267     editorGroup->setAttribute(Qt::WA_ContentsPropagated);
00268     editorGroup->setTitle("Color Editor");
00269     m_editor = new GradientEditor(editorGroup);
00270 
00271     QGroupBox *typeGroup = new QGroupBox(mainGroup);
00272     typeGroup->setAttribute(Qt::WA_ContentsPropagated);
00273     typeGroup->setTitle("Gradient Type");
00274     m_linearButton = new QRadioButton("Linear Gradient", typeGroup);
00275     m_radialButton = new QRadioButton("Radial Gradient", typeGroup);
00276     m_conicalButton = new QRadioButton("Conical Gradient", typeGroup);
00277 
00278     QGroupBox *spreadGroup = new QGroupBox(mainGroup);
00279     spreadGroup->setAttribute(Qt::WA_ContentsPropagated);
00280     spreadGroup->setTitle("Spread Method");
00281     m_padSpreadButton = new QRadioButton("Pad Spread", spreadGroup);
00282     m_reflectSpreadButton = new QRadioButton("Reflect Spread", spreadGroup);
00283     m_repeatSpreadButton = new QRadioButton("Repeat Spread", spreadGroup);
00284 
00285     QGroupBox *defaultsGroup = new QGroupBox(mainGroup);
00286     defaultsGroup->setAttribute(Qt::WA_ContentsPropagated);
00287     defaultsGroup->setTitle("Defaults");
00288     QPushButton *default1Button = new QPushButton("1", defaultsGroup);
00289     QPushButton *default2Button = new QPushButton("2", defaultsGroup);
00290     QPushButton *default3Button = new QPushButton("3", defaultsGroup);
00291     QPushButton *default4Button = new QPushButton("Reset", editorGroup);
00292 
00293     QPushButton *showSourceButton = new QPushButton(mainGroup);
00294     showSourceButton->setText("Show Source");
00295 #ifdef QT_OPENGL_SUPPORT
00296     QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
00297     enableOpenGLButton->setText("Use OpenGL");
00298     enableOpenGLButton->setCheckable(true);
00299     enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
00300     if (!QGLFormat::hasOpenGL())
00301         enableOpenGLButton->hide();
00302 #endif
00303     QPushButton *whatsThisButton = new QPushButton(mainGroup);
00304     whatsThisButton->setText("What's This?");
00305     whatsThisButton->setCheckable(true);
00306 
00307     // Layouts
00308     QHBoxLayout *mainLayout = new QHBoxLayout(this);
00309     mainLayout->addWidget(m_renderer);
00310     mainLayout->addWidget(mainGroup);
00311 
00312     mainGroup->setFixedWidth(180);
00313     QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup);
00314     mainGroupLayout->addWidget(editorGroup);
00315     mainGroupLayout->addWidget(typeGroup);
00316     mainGroupLayout->addWidget(spreadGroup);
00317     mainGroupLayout->addWidget(defaultsGroup);
00318     mainGroupLayout->addStretch(1);
00319     mainGroupLayout->addWidget(showSourceButton);
00320 #ifdef QT_OPENGL_SUPPORT
00321     mainGroupLayout->addWidget(enableOpenGLButton);
00322 #endif
00323     mainGroupLayout->addWidget(whatsThisButton);
00324 
00325     QVBoxLayout *editorGroupLayout = new QVBoxLayout(editorGroup);
00326     editorGroupLayout->addWidget(m_editor);
00327 
00328     QVBoxLayout *typeGroupLayout = new QVBoxLayout(typeGroup);
00329     typeGroupLayout->addWidget(m_linearButton);
00330     typeGroupLayout->addWidget(m_radialButton);
00331     typeGroupLayout->addWidget(m_conicalButton);
00332 
00333     QVBoxLayout *spreadGroupLayout = new QVBoxLayout(spreadGroup);
00334     spreadGroupLayout->addWidget(m_padSpreadButton);
00335     spreadGroupLayout->addWidget(m_repeatSpreadButton);
00336     spreadGroupLayout->addWidget(m_reflectSpreadButton);
00337 
00338     QHBoxLayout *defaultsGroupLayout = new QHBoxLayout(defaultsGroup);
00339     defaultsGroupLayout->addWidget(default1Button);
00340     defaultsGroupLayout->addWidget(default2Button);
00341     defaultsGroupLayout->addWidget(default3Button);
00342     editorGroupLayout->addWidget(default4Button);
00343 
00344     connect(m_editor, SIGNAL(gradientStopsChanged(const QGradientStops &)),
00345             m_renderer, SLOT(setGradientStops(const QGradientStops &)));
00346 
00347     connect(m_linearButton, SIGNAL(clicked()), m_renderer, SLOT(setLinearGradient()));
00348     connect(m_radialButton, SIGNAL(clicked()), m_renderer, SLOT(setRadialGradient()));
00349     connect(m_conicalButton, SIGNAL(clicked()), m_renderer, SLOT(setConicalGradient()));
00350 
00351     connect(m_padSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setPadSpread()));
00352     connect(m_reflectSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setReflectSpread()));
00353     connect(m_repeatSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setRepeatSpread()));
00354 
00355     connect(default1Button, SIGNAL(clicked()), this, SLOT(setDefault1()));
00356     connect(default2Button, SIGNAL(clicked()), this, SLOT(setDefault2()));
00357     connect(default3Button, SIGNAL(clicked()), this, SLOT(setDefault3()));
00358     connect(default4Button, SIGNAL(clicked()), this, SLOT(setDefault4()));
00359 
00360     connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource()));
00361 #ifdef QT_OPENGL_SUPPORT
00362     connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
00363 #endif
00364     connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool)));
00365     connect(whatsThisButton, SIGNAL(clicked(bool)),
00366             m_renderer->hoverPoints(), SLOT(setDisabled(bool)));
00367     connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
00368             whatsThisButton, SLOT(setChecked(bool)));
00369     connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
00370             m_renderer->hoverPoints(), SLOT(setDisabled(bool)));
00371 
00372     m_renderer->loadSourceFile(":res/gradients.cpp");
00373     m_renderer->loadDescription(":res/gradients.html");
00374 
00375     QTimer::singleShot(50, this, SLOT(setDefault1()));
00376 }

Here is the call graph for this function:


Member Function Documentation

void GradientWidget::setDefault1 (  )  [inline, slot]

Definition at line 132 of file gradients.h.

References setDefault().

Referenced by GradientWidget().

00132 { setDefault(1); }

void GradientWidget::setDefault2 (  )  [inline, slot]

Definition at line 133 of file gradients.h.

References setDefault().

Referenced by GradientWidget().

00133 { setDefault(2); }

void GradientWidget::setDefault3 (  )  [inline, slot]

Definition at line 134 of file gradients.h.

References setDefault().

Referenced by GradientWidget().

00134 { setDefault(3); }

void GradientWidget::setDefault4 (  )  [inline, slot]

Definition at line 135 of file gradients.h.

References setDefault().

Referenced by GradientWidget().

00135 { setDefault(4); }

void GradientWidget::setDefault ( int  i  )  [private]

Definition at line 378 of file gradients.cpp.

References QAbstractButton::animateClick(), QColor::fromRgba(), QWidget::height(), GradientRenderer::hoverPoints(), m_conicalButton, m_editor, m_linearButton, m_padSpreadButton, m_radialButton, m_renderer, m_repeatSpreadButton, qWarning(), GradientEditor::setGradientStops(), GradientRenderer::setGradientStops(), HoverPoints::setPoints(), and QWidget::width().

Referenced by setDefault1(), setDefault2(), setDefault3(), and setDefault4().

00379 {
00380     QGradientStops stops;
00381     QPolygonF points;
00382     switch (config) {
00383     case 1:
00384         stops << QGradientStop(0.00, QColor::fromRgba(0));
00385         stops << QGradientStop(0.04, QColor::fromRgba(0xff131360));
00386         stops << QGradientStop(0.08, QColor::fromRgba(0xff202ccc));
00387         stops << QGradientStop(0.42, QColor::fromRgba(0xff93d3f9));
00388         stops << QGradientStop(0.51, QColor::fromRgba(0xffb3e6ff));
00389         stops << QGradientStop(0.73, QColor::fromRgba(0xffffffec));
00390         stops << QGradientStop(0.92, QColor::fromRgba(0xff5353d9));
00391         stops << QGradientStop(0.96, QColor::fromRgba(0xff262666));
00392         stops << QGradientStop(1.00, QColor::fromRgba(0));
00393         m_linearButton->animateClick();
00394         m_repeatSpreadButton->animateClick();
00395         break;
00396 
00397     case 2:
00398         stops << QGradientStop(0.00, QColor::fromRgba(0xffffffff));
00399         stops << QGradientStop(0.11, QColor::fromRgba(0xfff9ffa0));
00400         stops << QGradientStop(0.13, QColor::fromRgba(0xfff9ff99));
00401         stops << QGradientStop(0.14, QColor::fromRgba(0xfff3ff86));
00402         stops << QGradientStop(0.49, QColor::fromRgba(0xff93b353));
00403         stops << QGradientStop(0.87, QColor::fromRgba(0xff264619));
00404         stops << QGradientStop(0.96, QColor::fromRgba(0xff0c1306));
00405         stops << QGradientStop(1.00, QColor::fromRgba(0));
00406         m_radialButton->animateClick();
00407         m_padSpreadButton->animateClick();
00408         break;
00409 
00410     case 3:
00411         stops << QGradientStop(0.00, QColor::fromRgba(0));
00412         stops << QGradientStop(0.10, QColor::fromRgba(0xffe0cc73));
00413         stops << QGradientStop(0.17, QColor::fromRgba(0xffc6a006));
00414         stops << QGradientStop(0.46, QColor::fromRgba(0xff600659));
00415         stops << QGradientStop(0.72, QColor::fromRgba(0xff0680ac));
00416         stops << QGradientStop(0.92, QColor::fromRgba(0xffb9d9e6));
00417         stops << QGradientStop(1.00, QColor::fromRgba(0));
00418         m_conicalButton->animateClick();
00419         m_padSpreadButton->animateClick();
00420         break;
00421 
00422     case 4:
00423         stops << QGradientStop(0.00, QColor::fromRgba(0xff000000));
00424         stops << QGradientStop(1.00, QColor::fromRgba(0xffffffff));
00425         break;
00426 
00427     default:
00428         qWarning("bad default: %d\n", config);
00429         break;
00430     }
00431 
00432     QPolygonF pts;
00433     int h_off = m_renderer->width() / 10;
00434     int v_off = m_renderer->height() / 8;
00435     pts << QPointF(m_renderer->width() / 2, m_renderer->height() / 2)
00436         << QPointF(m_renderer->width() / 2 - h_off, m_renderer->height() / 2 - v_off);
00437 
00438     m_editor->setGradientStops(stops);
00439     m_renderer->hoverPoints()->setPoints(pts);
00440     m_renderer->setGradientStops(stops);
00441 }

Here is the call graph for this function:


Member Data Documentation

GradientRenderer* GradientWidget::m_renderer [private]

Definition at line 140 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

GradientEditor* GradientWidget::m_editor [private]

Definition at line 141 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

QRadioButton* GradientWidget::m_linearButton [private]

Definition at line 143 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

QRadioButton* GradientWidget::m_radialButton [private]

Definition at line 144 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

QRadioButton* GradientWidget::m_conicalButton [private]

Definition at line 145 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

QRadioButton* GradientWidget::m_padSpreadButton [private]

Definition at line 146 of file gradients.h.

Referenced by GradientWidget(), and setDefault().

QRadioButton* GradientWidget::m_reflectSpreadButton [private]

Definition at line 147 of file gradients.h.

Referenced by GradientWidget().

QRadioButton* GradientWidget::m_repeatSpreadButton [private]

Definition at line 148 of file gradients.h.

Referenced by GradientWidget(), and setDefault().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:02:05 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1