summaryrefslogtreecommitdiff
path: root/src/gui/widgets/checkbox.cpp
diff options
context:
space:
mode:
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;
+}