-void SegmentedControl::drawButton (QPainter *painter,
- const QRect& rect,
- const QAction *action) {
- if (action == d->checkedAction)
- drawSelectedButton(painter, rect, action);
- else
- drawUnselectedButton(painter, rect, action);
-}
-
-void SegmentedControl::drawUnselectedButton (QPainter *painter,
- const QRect& rect,
- const QAction *action) {
- painter->setPen(QColor(0, 0, 0, 128));
- paintButton(painter, rect, action);
-}
-
-void SegmentedControl::drawSelectedButton (QPainter *painter,
- const QRect& rect,
- const QAction *action) {
- painter->save();
- painter->translate(rect.topLeft());
-
- const int width = rect.width();
- const int height = rect.height();
- const int hCenter = width * .5;
- QRadialGradient gradient(hCenter, 0,
- width,
- hCenter, 0);
- gradient.setColorAt(1, QColor(212, 210, 212));
- gradient.setColorAt(0, QColor(203, 203, 205));
- painter->fillRect(0, 0, width, height, QBrush(gradient));
-
- painter->restore();
- painter->setPen(palette().windowText().color());
- paintButton(painter, rect, action);
-}
-
-void SegmentedControl::paintButton(QPainter *painter, const QRect& rect, const QAction *action) {