diff options
author | Norwegian Rock Cat <qt-info@nokia.com> | 2009-05-15 14:47:05 +0200 |
---|---|---|
committer | Norwegian Rock Cat <qt-info@nokia.com> | 2009-05-15 14:47:05 +0200 |
commit | 2b966fcc5b6f4ab5417cfdd938619dea6d94d6ac (patch) | |
tree | 2922dfe3241cd08441d18ed51654922453ad0077 /src | |
parent | 0fa61c04061a963cbab47f319542d9e26c06594f (diff) |
more "style-like" drawing
Diffstat (limited to 'src')
-rw-r--r-- | src/qtsegmentcontrol.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/qtsegmentcontrol.cpp b/src/qtsegmentcontrol.cpp index dc73a60..f4839b9 100644 --- a/src/qtsegmentcontrol.cpp +++ b/src/qtsegmentcontrol.cpp @@ -77,13 +77,9 @@ protected: QtStyleOptionSegmentControlSegment(int version); }; -static void drawSegmentControlSegment(const QStyleOption *option, - QPainter *painter, QWidget * = 0) +static void drawSegmentControlSegmentSegment(const QStyleOption *option, QPainter *painter, QWidget *) { -#ifndef Q_WS_MAC - painter->fillRect(option->rect, Qt::blue); -#else - // ### Change to qstyleoption_cast! + // ### Change to qstyleoption_cast! if (const QtStyleOptionSegmentControlSegment *segment = static_cast<const QtStyleOptionSegmentControlSegment *>(option)) { CGContextRef cg = qt_mac_cg_context(painter->device()); @@ -100,6 +96,25 @@ static void drawSegmentControlSegment(const QStyleOption *option, HIThemeDrawSegment(&hirect, &sgi, cg, kHIThemeOrientationNormal); CFRelease(cg); } +} + +static void drawSegmentControlSegmentLabel(const QStyleOption *option, QPainter *painter, QWidget *) +{ + if (const QtStyleOptionSegmentControlSegment *segment + = static_cast<const QtStyleOptionSegmentControlSegment *>(option)) { + painter->drawText(segment->rect, Qt::AlignCenter, segment->text); + } + +} + +static void drawSegmentControlSegment(const QStyleOption *option, + QPainter *painter, QWidget *widget) +{ +#ifndef Q_WS_MAC + painter->fillRect(option->rect, QColor(255, 0, 0, 135)); +#else + drawSegmentControlSegmentSegment(segment, painter, widget); + drawSegmentControlSegmentLabel(segment, painter, widget); #endif } |