summaryrefslogtreecommitdiff
path: root/src/gui/widgets/button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/button.cpp')
-rw-r--r--src/gui/widgets/button.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index f8ae3e65c..0c71bf8bd 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -147,7 +147,7 @@ Button::Button(const Widget2 *const widget,
mPressed(false)
{
init();
- loadImage(imageName);
+ loadImageSet(imageName);
adjustSize();
setActionEventId(actionEventId);
@@ -186,6 +186,46 @@ Button::Button(const Widget2 *const widget, const std::string &imageName,
mPressed(false)
{
init();
+ loadImageSet(imageName);
+ adjustSize();
+ setActionEventId(actionEventId);
+
+ if (listener)
+ addActionListener(listener);
+}
+
+Button::Button(const Widget2 *const widget,
+ const std::string &caption,
+ const std::string &imageName,
+ const std::string &actionEventId,
+ gcn::ActionListener *const listener) :
+ gcn::Button(caption),
+ Widget2(widget),
+ gcn::WidgetListener(),
+ mDescription(),
+ mVertexes2(new ImageCollection),
+ mEnabledColor(getThemeColor(Theme::BUTTON)),
+ mEnabledColor2(getThemeColor(Theme::BUTTON_OUTLINE)),
+ mDisabledColor(getThemeColor(Theme::BUTTON_DISABLED)),
+ mDisabledColor2(getThemeColor(Theme::BUTTON_DISABLED_OUTLINE)),
+ mHighlightedColor(getThemeColor(Theme::BUTTON_HIGHLIGHTED)),
+ mHighlightedColor2(getThemeColor(Theme::BUTTON_HIGHLIGHTED_OUTLINE)),
+ mPressedColor(getThemeColor(Theme::BUTTON_PRESSED)),
+ mPressedColor2(getThemeColor(Theme::BUTTON_PRESSED_OUTLINE)),
+ mImages(nullptr),
+ mImageSet(nullptr),
+ mClickCount(0),
+ mTag(0),
+ mMode(0),
+ mXOffset(0),
+ mYOffset(0),
+ mImageWidth(0),
+ mImageHeight(0),
+ mRedraw(true),
+ mStick(false),
+ mPressed(false)
+{
+ init();
loadImage(imageName);
adjustSize();
setActionEventId(actionEventId);
@@ -253,6 +293,19 @@ void Button::loadImage(const std::string &imageName)
mImageSet->decRef();
mImageSet = nullptr;
}
+ Image *const image = Theme::getImageFromThemeXml(imageName, "");
+ mImages = new Image*[BUTTON_COUNT];
+ for (int f = 0; f < BUTTON_COUNT; f ++)
+ mImages[f] = image;
+}
+
+void Button::loadImageSet(const std::string &imageName)
+{
+ if (mImageSet)
+ {
+ mImageSet->decRef();
+ mImageSet = nullptr;
+ }
mImageSet = Theme::getImageSetFromTheme(imageName,
mImageWidth, mImageHeight);
if (!mImageSet)