#include <pathstroke.h>
Inheritance diagram for PathStrokeWidget:


Definition at line 98 of file pathstroke.h.
Public Member Functions | |
| PathStrokeWidget () | |
Private Attributes | |
| PathStrokeRenderer * | m_renderer |
| PathStrokeWidget::PathStrokeWidget | ( | ) |
Definition at line 30 of file pathstroke.cpp.
References QBoxLayout::addStretch(), QBoxLayout::addWidget(), QObject::connect(), QSizePolicy::Fixed, QGLFormat::hasOpenGL(), QSize::height(), QWidget::hide(), Qt::Horizontal, ArthurFrame::loadDescription(), ArthurFrame::loadSourceFile(), m_renderer, QWidget::palette(), QSizePolicy::Preferred, QWidget::setAttribute(), QAbstractButton::setCheckable(), QAbstractButton::setChecked(), QWidget::setFixedHeight(), QWidget::setFixedWidth(), QAbstractButton::setIcon(), QAbstractButton::setIconSize(), QLayout::setMargin(), QWidget::setPalette(), QAbstractSlider::setRange(), QWidget::setSizePolicy(), QAbstractButton::setText(), QGroupBox::setTitle(), QAbstractSlider::setValue(), QWidget::setWindowTitle(), SIGNAL, QPixmap::size(), QRadioButton::sizeHint(), SLOT, and Qt::WA_ContentsPropagated.
00031 { 00032 setWindowTitle(tr("Path Stroking")); 00033 00034 // Setting up palette. 00035 QPalette pal = palette(); 00036 // pal.setBrush(QPalette::Background, Qt::white); 00037 // pal.setBrush(QPalette::Foreground, QColor("aquamarine")); 00038 // pal.setBrush(QPalette::Background, QPixmap("background.png")); 00039 setPalette(pal); 00040 00041 // Widget construction and property setting 00042 m_renderer = new PathStrokeRenderer(this); 00043 00044 QGroupBox *mainGroup = new QGroupBox(this); 00045 // QWidget *mainGroup = new QWidget(this); 00046 mainGroup->setFixedWidth(180); 00047 mainGroup->setTitle("Path Stroking"); 00048 00049 QGroupBox *capGroup = new QGroupBox(mainGroup); 00050 capGroup->setAttribute(Qt::WA_ContentsPropagated); 00051 QRadioButton *flatCap = new QRadioButton(capGroup); 00052 QRadioButton *squareCap = new QRadioButton(capGroup); 00053 QRadioButton *roundCap = new QRadioButton(capGroup); 00054 capGroup->setTitle("Cap Style"); 00055 flatCap->setText("Flat Cap"); 00056 squareCap->setText("Square Cap"); 00057 roundCap->setText("Round Cap"); 00058 00059 QGroupBox *joinGroup = new QGroupBox(mainGroup); 00060 joinGroup->setAttribute(Qt::WA_ContentsPropagated); 00061 QRadioButton *bevelJoin = new QRadioButton(joinGroup); 00062 QRadioButton *miterJoin = new QRadioButton(joinGroup); 00063 QRadioButton *roundJoin = new QRadioButton(joinGroup); 00064 joinGroup->setTitle("Join Style"); 00065 bevelJoin->setText("Bevel Join"); 00066 miterJoin->setText("Miter Join"); 00067 roundJoin->setText("Round Join"); 00068 00069 QGroupBox *styleGroup = new QGroupBox(mainGroup); 00070 styleGroup->setAttribute(Qt::WA_ContentsPropagated); 00071 QRadioButton *solidLine = new QRadioButton(styleGroup); 00072 QRadioButton *dashLine = new QRadioButton(styleGroup); 00073 QRadioButton *dotLine = new QRadioButton(styleGroup); 00074 QRadioButton *dashDotLine = new QRadioButton(styleGroup); 00075 QRadioButton *dashDotDotLine = new QRadioButton(styleGroup); 00076 QRadioButton *customDashLine = new QRadioButton(styleGroup); 00077 styleGroup->setTitle("Pen Style"); 00078 #if 0 00079 solidLine->setText("Solid Line"); 00080 dashLine->setText("Dash Line"); 00081 dotLine->setText("Dot Line"); 00082 dashDotLine->setText("Dash Dot Line"); 00083 dashDotDotLine->setText("Dash Dot Dot Line"); 00084 #else 00085 QPixmap line_solid(":res/images/line_solid.png"); 00086 solidLine->setIcon(line_solid); 00087 solidLine->setIconSize(line_solid.size()); 00088 QPixmap line_dashed(":res/images/line_dashed.png"); 00089 dashLine->setIcon(line_dashed); 00090 dashLine->setIconSize(line_dashed.size()); 00091 QPixmap line_dotted(":res/images/line_dotted.png"); 00092 dotLine->setIcon(line_dotted); 00093 dotLine->setIconSize(line_dotted.size()); 00094 QPixmap line_dash_dot(":res/images/line_dash_dot.png"); 00095 dashDotLine->setIcon(line_dash_dot); 00096 dashDotLine->setIconSize(line_dash_dot.size()); 00097 QPixmap line_dash_dot_dot(":res/images/line_dash_dot_dot.png"); 00098 dashDotDotLine->setIcon(line_dash_dot_dot); 00099 dashDotDotLine->setIconSize(line_dash_dot_dot.size()); 00100 customDashLine->setText("Custom Style"); 00101 00102 int fixedHeight = bevelJoin->sizeHint().height(); 00103 solidLine->setFixedHeight(fixedHeight); 00104 dashLine->setFixedHeight(fixedHeight); 00105 dotLine->setFixedHeight(fixedHeight); 00106 dashDotLine->setFixedHeight(fixedHeight); 00107 dashDotDotLine->setFixedHeight(fixedHeight); 00108 #endif 00109 00110 QGroupBox *pathModeGroup = new QGroupBox(mainGroup); 00111 pathModeGroup->setAttribute(Qt::WA_ContentsPropagated); 00112 QRadioButton *curveMode = new QRadioButton(pathModeGroup); 00113 QRadioButton *lineMode = new QRadioButton(pathModeGroup); 00114 pathModeGroup->setTitle("Path composed of"); 00115 curveMode->setText("Curves"); 00116 lineMode->setText("Lines"); 00117 00118 QGroupBox *penWidthGroup = new QGroupBox(mainGroup); 00119 penWidthGroup->setAttribute(Qt::WA_ContentsPropagated); 00120 QSlider *penWidth = new QSlider(Qt::Horizontal, penWidthGroup); 00121 penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 00122 penWidthGroup->setTitle("Pen Width"); 00123 penWidth->setRange(0, 500); 00124 00125 #if 0 00126 QCheckBox *animated = new QCheckBox(mainGroup); 00127 animated->setText("Animated"); 00128 #else 00129 QPushButton *animated = new QPushButton(mainGroup); 00130 animated->setText("Animate"); 00131 animated->setCheckable(true); 00132 #endif 00133 00134 QPushButton *showSourceButton = new QPushButton(mainGroup); 00135 showSourceButton->setText("Show Source"); 00136 #ifdef QT_OPENGL_SUPPORT 00137 QPushButton *enableOpenGLButton = new QPushButton(mainGroup); 00138 enableOpenGLButton->setText("Use OpenGL"); 00139 enableOpenGLButton->setCheckable(true); 00140 enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); 00141 if (!QGLFormat::hasOpenGL()) 00142 enableOpenGLButton->hide(); 00143 #endif 00144 QPushButton *whatsThisButton = new QPushButton(mainGroup); 00145 whatsThisButton->setText("What's This?"); 00146 whatsThisButton->setCheckable(true); 00147 00148 // Layouting 00149 QHBoxLayout *viewLayout = new QHBoxLayout(this); 00150 viewLayout->addWidget(m_renderer); 00151 viewLayout->addWidget(mainGroup); 00152 00153 QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); 00154 mainGroupLayout->setMargin(3); 00155 mainGroupLayout->addWidget(capGroup); 00156 mainGroupLayout->addWidget(joinGroup); 00157 mainGroupLayout->addWidget(styleGroup); 00158 mainGroupLayout->addWidget(penWidthGroup); 00159 mainGroupLayout->addWidget(pathModeGroup); 00160 mainGroupLayout->addWidget(animated); 00161 mainGroupLayout->addStretch(1); 00162 mainGroupLayout->addWidget(showSourceButton); 00163 #ifdef QT_OPENGL_SUPPORT 00164 mainGroupLayout->addWidget(enableOpenGLButton); 00165 #endif 00166 mainGroupLayout->addWidget(whatsThisButton); 00167 00168 QVBoxLayout *capGroupLayout = new QVBoxLayout(capGroup); 00169 capGroupLayout->addWidget(flatCap); 00170 capGroupLayout->addWidget(squareCap); 00171 capGroupLayout->addWidget(roundCap); 00172 00173 QVBoxLayout *joinGroupLayout = new QVBoxLayout(joinGroup); 00174 joinGroupLayout->addWidget(bevelJoin); 00175 joinGroupLayout->addWidget(miterJoin); 00176 joinGroupLayout->addWidget(roundJoin); 00177 00178 QVBoxLayout *styleGroupLayout = new QVBoxLayout(styleGroup); 00179 styleGroupLayout->addWidget(solidLine); 00180 styleGroupLayout->addWidget(dashLine); 00181 styleGroupLayout->addWidget(dotLine); 00182 styleGroupLayout->addWidget(dashDotLine); 00183 styleGroupLayout->addWidget(dashDotDotLine); 00184 styleGroupLayout->addWidget(customDashLine); 00185 00186 QVBoxLayout *pathModeGroupLayout = new QVBoxLayout(pathModeGroup); 00187 pathModeGroupLayout->addWidget(curveMode); 00188 pathModeGroupLayout->addWidget(lineMode); 00189 00190 QVBoxLayout *penWidthLayout = new QVBoxLayout(penWidthGroup); 00191 penWidthLayout->addWidget(penWidth); 00192 00193 // Set up connections 00194 connect(penWidth, SIGNAL(valueChanged(int)), 00195 m_renderer, SLOT(setPenWidth(int))); 00196 connect(animated, SIGNAL(toggled(bool)), 00197 m_renderer, SLOT(setAnimation(bool))); 00198 00199 connect(flatCap, SIGNAL(clicked()), m_renderer, SLOT(setFlatCap())); 00200 connect(squareCap, SIGNAL(clicked()), m_renderer, SLOT(setSquareCap())); 00201 connect(roundCap, SIGNAL(clicked()), m_renderer, SLOT(setRoundCap())); 00202 00203 connect(bevelJoin, SIGNAL(clicked()), m_renderer, SLOT(setBevelJoin())); 00204 connect(miterJoin, SIGNAL(clicked()), m_renderer, SLOT(setMiterJoin())); 00205 connect(roundJoin, SIGNAL(clicked()), m_renderer, SLOT(setRoundJoin())); 00206 00207 connect(curveMode, SIGNAL(clicked()), m_renderer, SLOT(setCurveMode())); 00208 connect(lineMode, SIGNAL(clicked()), m_renderer, SLOT(setLineMode())); 00209 00210 connect(solidLine, SIGNAL(clicked()), m_renderer, SLOT(setSolidLine())); 00211 connect(dashLine, SIGNAL(clicked()), m_renderer, SLOT(setDashLine())); 00212 connect(dotLine, SIGNAL(clicked()), m_renderer, SLOT(setDotLine())); 00213 connect(dashDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotLine())); 00214 connect(dashDotDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotDotLine())); 00215 connect(customDashLine, SIGNAL(clicked()), m_renderer, SLOT(setCustomDashLine())); 00216 00217 connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); 00218 #ifdef QT_OPENGL_SUPPORT 00219 connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); 00220 #endif 00221 connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool))); 00222 connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), 00223 whatsThisButton, SLOT(setChecked(bool))); 00224 00225 // Set the defaults 00226 animated->setChecked(true); 00227 flatCap->setChecked(true); 00228 bevelJoin->setChecked(true); 00229 penWidth->setValue(50); 00230 curveMode->setChecked(true); 00231 solidLine->setChecked(true); 00232 00233 m_renderer->loadSourceFile(":res/pathstroke.cpp"); 00234 m_renderer->loadDescription(":res/pathstroke.html"); 00235 }
Here is the call graph for this function:

PathStrokeRenderer* PathStrokeWidget::m_renderer [private] |
1.5.1