1/*
2 * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#ifndef UIITEM_H
24#define UIITEM_H
25
26#include "declarations.h"
27#include <framework/ui/uiwidget.h>
28#include "item.h"
29
30class UIItem : public UIWidget
31{
32public:
33 UIItem();
34 void drawSelf(Fw::DrawPane drawPane);
35
36 void setItemId(int id);
37 void setItemCount(int count);
38 void setItemSubType(int subType);
39 void setItemVisible(bool visible) { m_itemVisible = visible; }
40 void setItem(const ItemPtr& item);
41 void setVirtual(bool virt) { m_virtual = virt; }
42 void clearItem() { setItemId(0); }
43 void setShowCount(bool value) { m_showCount = value; }
44 void setItemShader(const std::string& str);
45
46 int getItemId() { return m_item ? m_item->getId() : 0; }
47 int getItemCount() { return m_item ? m_item->getCount() : 0; }
48 int getItemSubType() { return m_item ? m_item->getSubType() : 0; }
49 int getItemCountOrSubType() { return m_item ? m_item->getCountOrSubType() : 0; }
50 ItemPtr getItem() { return m_item; }
51 bool isVirtual() { return m_virtual; }
52 bool isItemVisible() { return m_itemVisible; }
53
54protected:
55 void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
56 void cacheCountText();
57
58 ItemPtr m_item;
59 stdext::boolean<false> m_virtual;
60 stdext::boolean<true> m_itemVisible;
61 stdext::boolean<false> m_showId;
62 stdext::boolean<true> m_showCount;
63 std::string m_shader;
64 std::string m_countText;
65};
66
67#endif
68