summaryrefslogtreecommitdiff
path: root/src/gui/widgets/checkbox.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/checkbox.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/checkbox.cpp')
-rw-r--r--src/gui/widgets/checkbox.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 2e9a234b..dd57f674 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -35,9 +35,12 @@ Image *CheckBox::checkBoxNormal;
Image *CheckBox::checkBoxChecked;
Image *CheckBox::checkBoxDisabled;
Image *CheckBox::checkBoxDisabledChecked;
+Image *CheckBox::checkBoxNormalHi;
+Image *CheckBox::checkBoxCheckedHi;
CheckBox::CheckBox(const std::string &caption, bool selected):
- gcn::CheckBox(caption, selected)
+ gcn::CheckBox(caption, selected),
+ mHasMouse(false)
{
if (instances == 0)
{
@@ -47,10 +50,14 @@ CheckBox::CheckBox(const std::string &caption, bool selected):
checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10);
checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10);
+ checkBoxNormalHi = checkBox->getSubImage(36, 0, 9, 10);
+ checkBoxCheckedHi = checkBox->getSubImage(45, 0, 9, 10);
checkBoxNormal->setAlpha(mAlpha);
checkBoxChecked->setAlpha(mAlpha);
checkBoxDisabled->setAlpha(mAlpha);
checkBoxDisabledChecked->setAlpha(mAlpha);
+ checkBoxNormalHi->setAlpha(mAlpha);
+ checkBoxCheckedHi->setAlpha(mAlpha);
checkBox->decRef();
}
@@ -67,6 +74,8 @@ CheckBox::~CheckBox()
delete checkBoxChecked;
delete checkBoxDisabled;
delete checkBoxDisabledChecked;
+ delete checkBoxNormalHi;
+ delete checkBoxCheckedHi;
}
}
@@ -86,17 +95,22 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
{
Image *box;
- if (isSelected())
- {
- if (isEnabled())
- box = checkBoxChecked;
+ if (isEnabled())
+ if (isSelected())
+ if (mHasMouse)
+ box = checkBoxCheckedHi;
+ else
+ box = checkBoxChecked;
else
- box = checkBoxDisabledChecked;
- }
- else if (isEnabled())
- box = checkBoxNormal;
+ if (mHasMouse)
+ box = checkBoxNormalHi;
+ else
+ box = checkBoxNormal;
else
- box = checkBoxDisabled;
+ if (isSelected())
+ box = checkBoxDisabledChecked;
+ else
+ box = checkBoxDisabled;
if (config.getValue("guialpha", 0.8) != mAlpha)
{
@@ -105,7 +119,19 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
checkBoxChecked->setAlpha(mAlpha);
checkBoxDisabled->setAlpha(mAlpha);
checkBoxDisabledChecked->setAlpha(mAlpha);
+ checkBoxNormal->setAlpha(mAlpha);
+ checkBoxCheckedHi->setAlpha(mAlpha);
}
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
}
+
+void CheckBox::mouseEntered(gcn::MouseEvent& event)
+{
+ mHasMouse = true;
+}
+
+void CheckBox::mouseExited(gcn::MouseEvent& event)
+{
+ mHasMouse = false;
+}