summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-23 22:33:26 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-23 22:33:26 +0300
commitc3755c31222a7cd4e90f772eb88a992dd64f6c06 (patch)
treeca0240e6b8597276a3e761d3ba18d838d8a94bc5 /src/gui/widgets
parent533e703a2c394b9c4a0c0e2d7367dd5cc48c1502 (diff)
downloadmanaplus-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.gz
manaplus-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.bz2
manaplus-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.xz
manaplus-c3755c31222a7cd4e90f772eb88a992dd64f6c06.zip
Use in different listbox derived classes different xml skin.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/extendedlistbox.cpp3
-rw-r--r--src/gui/widgets/extendedlistbox.h1
-rw-r--r--src/gui/widgets/listbox.cpp17
-rw-r--r--src/gui/widgets/listbox.h7
-rw-r--r--src/gui/widgets/popuplist.cpp5
-rw-r--r--src/gui/widgets/shoplistbox.cpp4
7 files changed, 19 insertions, 20 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c28b13753..92a6443be 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -45,7 +45,7 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(const Widget2 *const widget,
AvatarListModel *const model) :
- ListBox(widget, model),
+ ListBox(widget, model, "avatarlistbox.xml"),
mShowGender(config.getBoolValue("showgender")),
mShowLevel(config.getBoolValue("showlevel")),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT))
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 34f4f1a45..d83a2a1ba 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -38,8 +38,9 @@
ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
gcn::ListModel *const listModel,
+ const std::string &skin,
int rowHeight) :
- ListBox(widget, listModel),
+ ListBox(widget, listModel, skin),
mRowHeight(rowHeight),
mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
mSpacing(mSkin ? mSkin->getOption("spacing") : 0),
diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h
index 9da77abe7..c5fca2e4c 100644
--- a/src/gui/widgets/extendedlistbox.h
+++ b/src/gui/widgets/extendedlistbox.h
@@ -31,6 +31,7 @@ class ExtendedListBox final : public ListBox
*/
ExtendedListBox(const Widget2 *const widget,
gcn::ListModel *const listModel,
+ const std::string &skin,
int rowHeight = 13);
A_DELETE_COPY(ExtendedListBox)
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 9eb5f23a2..b89fc9688 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -38,11 +38,10 @@
#include "debug.h"
float ListBox::mAlpha = 1.0;
-Skin *ListBox::mSkin = nullptr;
-int ListBox::mInstances = 0;
ListBox::ListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel) :
+ gcn::ListModel *const listModel,
+ const std::string &skin) :
gcn::ListBox(listModel),
Widget2(widget),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
@@ -53,12 +52,9 @@ ListBox::ListBox(const Widget2 *const widget,
{
mForegroundColor = getThemeColor(Theme::LISTBOX);
- if (mInstances == 0)
- {
- if (Theme::instance())
- mSkin = Theme::instance()->load("listbox.xml", "");
- }
- mInstances ++;
+ Theme *const theme = Theme::instance();
+ if (theme)
+ mSkin = Theme::instance()->load(skin, "listbox.xml");
if (mSkin)
mPadding = mSkin->getPadding();
@@ -68,8 +64,7 @@ ListBox::ListBox(const Widget2 *const widget,
ListBox::~ListBox()
{
- mInstances --;
- if (mInstances == 0 && Theme::instance())
+ if (Theme::instance())
Theme::instance()->unload(mSkin);
}
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 21f6b00b0..8296d90e4 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -46,7 +46,9 @@ class ListBox : public gcn::ListBox,
/**
* Constructor.
*/
- ListBox(const Widget2 *const widget, gcn::ListModel *const listModel);
+ ListBox(const Widget2 *const widget,
+ gcn::ListModel *const listModel,
+ const std::string &skin);
A_DELETE_COPY(ListBox)
@@ -94,8 +96,7 @@ class ListBox : public gcn::ListBox,
int mOldSelected;
int mPadding;
static float mAlpha;
- static Skin *mSkin;
- static int mInstances;
+ Skin *mSkin;
};
#endif
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index ca9ef2c7d..ccd186197 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -36,8 +36,9 @@ PopupList::PopupList(DropDown *const widget,
Popup("PopupList", "popuplist.xml"),
gcn::FocusListener(),
mListModel(listModel),
- mListBox(extended ? new ExtendedListBox(widget, listModel, 0) :
- new ListBox(widget, listModel)),
+ mListBox(extended ? new ExtendedListBox(
+ widget, listModel, "extendedlistbox.xml", 0) :
+ new ListBox(widget, listModel, "popuplistbox.xml")),
mScrollArea(new ScrollArea(mListBox, false)),
mDropDown(widget),
mModal(modal)
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 4c0738374..5aa91a2c9 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -44,7 +44,7 @@ float ShopListBox::mAlpha = 1.0;
ShopListBox::ShopListBox(const Widget2 *const widget,
gcn::ListModel *const listModel) :
- ListBox(widget, listModel),
+ ListBox(widget, listModel, "shoplisbox.xml"),
mPlayerMoney(0),
mShopItems(nullptr),
mItemPopup(new ItemPopup),
@@ -60,7 +60,7 @@ ShopListBox::ShopListBox(const Widget2 *const widget,
ShopListBox::ShopListBox(const Widget2 *const widget,
gcn::ListModel *const listModel,
ShopItems *const shopListModel) :
- ListBox(widget, listModel),
+ ListBox(widget, listModel, "shoplisbox.xml"),
mPlayerMoney(0),
mShopItems(shopListModel),
mItemPopup(new ItemPopup),