summaryrefslogtreecommitdiff
path: root/src/gui/radiobutton.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 21:53:10 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 21:53:10 +0000
commitf80bf2dfb4de682a56abe79b7b0e5e0459804b30 (patch)
treecc45a8a6dfa7abe41b9f13fabffbb6287513cf46 /src/gui/radiobutton.cpp
parent6a25f872d6102058c8186398627abc5d84f2363a (diff)
downloadmana-f80bf2dfb4de682a56abe79b7b0e5e0459804b30.tar.gz
mana-f80bf2dfb4de682a56abe79b7b0e5e0459804b30.tar.bz2
mana-f80bf2dfb4de682a56abe79b7b0e5e0459804b30.tar.xz
mana-f80bf2dfb4de682a56abe79b7b0e5e0459804b30.zip
Made button, checkbox and radiobutton count their instances and only load their
resources once. Other widgets will follow later.
Diffstat (limited to 'src/gui/radiobutton.cpp')
-rw-r--r--src/gui/radiobutton.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index d04d8586..f03c333f 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -24,15 +24,39 @@
#include "radiobutton.h"
#include "../resources/resourcemanager.h"
+int RadioButton::instances = 0;
+Image *RadioButton::radioNormal;
+Image *RadioButton::radioChecked;
+Image *RadioButton::radioDisabled;
+Image *RadioButton::radioDisabledChecked;
+
RadioButton::RadioButton(const std::string& caption, const std::string& group,
bool marked):
gcn::RadioButton(caption, group, marked)
{
- ResourceManager *resman = ResourceManager::getInstance();
- radioNormal = resman->getImage("graphics/gui/radioout.png");
- radioChecked = resman->getImage("graphics/gui/radioin.png");
- radioDisabled = resman->getImage("graphics/gui/radioout.png");
- radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
+ if (instances == 0)
+ {
+ ResourceManager *resman = ResourceManager::getInstance();
+ radioNormal = resman->getImage("graphics/gui/radioout.png");
+ radioChecked = resman->getImage("graphics/gui/radioin.png");
+ radioDisabled = resman->getImage("graphics/gui/radioout.png");
+ radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
+ }
+
+ instances++;
+}
+
+RadioButton::~RadioButton()
+{
+ instances--;
+
+ if (instances == 0)
+ {
+ radioNormal->decRef();
+ radioChecked->decRef();
+ radioDisabled->decRef();
+ radioDisabledChecked->decRef();
+ }
}
void RadioButton::drawBox(gcn::Graphics* graphics)