Created
June 20, 2009 18:35
-
-
Save neel/133232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ArthurStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const{ | |
Q_ASSERT(option); | |
switch (element) { | |
case PE_FrameFocusRect: | |
break; | |
case PE_IndicatorRadioButton: | |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { | |
bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); | |
painter->save(); | |
QPixmap radio; | |
if(hover){ | |
qDebug() << "Hover on Radio"; | |
drawHoverRect(painter, widget->rect()); | |
} | |
if (button->state & State_Sunken) | |
radio = cached(":res/images/radiobutton-on.png"); | |
else if (button->state & State_On) | |
radio = cached(":res/images/radiobutton_on.png"); | |
else | |
radio = cached(":res/images/radiobutton_off.png"); | |
painter->drawPixmap(button->rect.topLeft(), radio); | |
painter->restore(); | |
} | |
break; | |
case PE_IndicatorCheckBox: | |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { | |
bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); | |
painter->save(); | |
QPixmap radio; | |
if (hover){ | |
qDebug() << "Hover on CheckBox"; | |
drawHoverRect(painter, widget->rect()); | |
} | |
if (button->state & State_Sunken) | |
radio = cached(":res/images/radiobutton-on.png"); | |
else if (button->state & State_On) | |
radio = cached(":res/images/radiobutton_on.png"); | |
else | |
radio = cached(":res/images/radiobutton_off.png"); | |
painter->drawPixmap(button->rect.topLeft(), radio); | |
painter->restore(); | |
} | |
break; | |
........ | |
........ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment