summaryrefslogtreecommitdiff
path: root/src/gui/widgets/radiobutton.cpp
diff options
context:
space:
mode:
authorMaximilian Philipps <Turmfalke2007@web.de>2009-08-02 20:15:38 +0200
committerChuck Miller <shadowmil@gmail.com>2009-08-05 15:19:32 -0400
commit1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8 (patch)
tree098001f83da97cc77cb234dc40bc23dae6d8fe95 /src/gui/widgets/radiobutton.cpp
parent5c578f9d64bfcc0dbd81d9c6bad549a65bd1ad32 (diff)
downloadmana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.gz
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.bz2
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.xz
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.zip
patch for #813, adds mouse over highlight for
radio buttons, tabs, checkboxes, slider and scrollbars
Diffstat (limited to 'src/gui/widgets/radiobutton.cpp')
-rw-r--r--src/gui/widgets/radiobutton.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 6f0ccdbd..9cf49672 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -33,10 +33,13 @@ Image *RadioButton::radioNormal;
Image *RadioButton::radioChecked;
Image *RadioButton::radioDisabled;
Image *RadioButton::radioDisabledChecked;
+Image *RadioButton::radioNormalHi;
+Image *RadioButton::radioCheckedHi;
RadioButton::RadioButton(const std::string &caption, const std::string &group,
bool marked):
- gcn::RadioButton(caption, group, marked)
+ gcn::RadioButton(caption, group, marked),
+ mHasMouse(false)
{
if (instances == 0)
{
@@ -45,10 +48,14 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group,
radioChecked = resman->getImage("graphics/gui/radioin.png");
radioDisabled = resman->getImage("graphics/gui/radioout.png");
radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
+ radioNormalHi = resman->getImage("graphics/gui/radioout_highlight.png");
+ radioCheckedHi = resman->getImage("graphics/gui/radioin_highlight.png");
radioNormal->setAlpha(mAlpha);
radioChecked->setAlpha(mAlpha);
radioDisabled->setAlpha(mAlpha);
radioDisabledChecked->setAlpha(mAlpha);
+ radioNormalHi->setAlpha(mAlpha);
+ radioCheckedHi->setAlpha(mAlpha);
}
instances++;
@@ -64,6 +71,8 @@ RadioButton::~RadioButton()
radioChecked->decRef();
radioDisabled->decRef();
radioDisabledChecked->decRef();
+ radioNormalHi->decRef();
+ radioCheckedHi->decRef();
}
}
@@ -76,21 +85,28 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
radioChecked->setAlpha(mAlpha);
radioDisabled->setAlpha(mAlpha);
radioDisabledChecked->setAlpha(mAlpha);
+ radioNormalHi->setAlpha(mAlpha);
+ radioCheckedHi->setAlpha(mAlpha);
}
Image *box = NULL;
- if (isSelected())
- {
- if (isEnabled())
- box = radioChecked;
+ if (isEnabled())
+ if (isSelected())
+ if (mHasMouse)
+ box = radioCheckedHi;
+ else
+ box = radioChecked;
else
- box = radioDisabledChecked;
- }
- else if (isEnabled())
- box = radioNormal;
+ if (mHasMouse)
+ box = radioNormalHi;
+ else
+ box = radioNormal;
else
- box = radioDisabled;
+ if (isSelected())
+ box = radioDisabledChecked;
+ else
+ box = radioDisabled;
if (box)
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
@@ -111,3 +127,14 @@ void RadioButton::draw(gcn::Graphics* graphics)
int h = getHeight() + getHeight() / 2;
graphics->drawText(getCaption(), h - 2, 0);
}
+
+void RadioButton::mouseEntered(gcn::MouseEvent& event)
+{
+ mHasMouse = true;
+}
+
+void RadioButton::mouseExited(gcn::MouseEvent& event)
+{
+ mHasMouse = false;
+}
+