Otclient  14/8/2020
uiitem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 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 
30 class UIItem : public UIWidget
31 {
32 public:
33  UIItem();
34  void drawSelf(Fw::DrawPane drawPane);
35 
36  void setItemId(int id);
37  void setItemCount(int count) { if(m_item) m_item->setCount(count); }
38  void setItemSubType(int subType) { if(m_item) m_item->setSubType(subType); }
39  void setItemVisible(bool visible) { m_itemVisible = visible; }
40  void setItem(const ItemPtr& item) { m_item = item; }
41  void setVirtual(bool virt) { m_virtual = virt; }
42  void clearItem() { setItemId(0); }
43 
44  int getItemId() { return m_item ? m_item->getId() : 0; }
45  int getItemCount() { return m_item ? m_item->getCount() : 0; }
46  int getItemSubType() { return m_item ? m_item->getSubType() : 0; }
47  ItemPtr getItem() { return m_item; }
48  bool isVirtual() { return m_virtual; }
49  bool isItemVisible() { return m_itemVisible; }
50 
51 protected:
52  void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
53 
58 };
59 
60 #endif
UIWidget
Definition: uiwidget.h:47
UIItem::m_itemVisible
stdext::boolean< true > m_itemVisible
Definition: uiitem.h:56
Item::getId
uint32 getId()
Definition: item.h:97
UIItem::getItemId
int getItemId()
Definition: uiitem.h:44
UIItem::UIItem
UIItem()
Definition: uiitem.cpp:28
UIItem
Definition: uiitem.h:30
Item::setSubType
void setSubType(int subType)
Definition: item.h:91
UIItem::getItem
ItemPtr getItem()
Definition: uiitem.h:47
UIItem::setItem
void setItem(const ItemPtr &item)
Definition: uiitem.h:40
uiwidget.h
stdext::boolean< false >
UIItem::clearItem
void clearItem()
Definition: uiitem.h:42
UIItem::isItemVisible
bool isItemVisible()
Definition: uiitem.h:49
declarations.h
UIItem::setItemVisible
void setItemVisible(bool visible)
Definition: uiitem.h:39
Item::setCount
void setCount(int count)
Definition: item.h:90
UIItem::setVirtual
void setVirtual(bool virt)
Definition: uiitem.h:41
Item::getSubType
int getSubType()
Definition: item.cpp:240
UIItem::setItemSubType
void setItemSubType(int subType)
Definition: uiitem.h:38
UIItem::getItemSubType
int getItemSubType()
Definition: uiitem.h:46
UIItem::m_virtual
stdext::boolean< false > m_virtual
Definition: uiitem.h:55
Fw::DrawPane
DrawPane
Definition: const.h:285
UIItem::drawSelf
void drawSelf(Fw::DrawPane drawPane)
Definition: uiitem.cpp:33
stdext::shared_object_ptr< Item >
UIItem::m_item
ItemPtr m_item
Definition: uiitem.h:54
UIItem::setItemCount
void setItemCount(int count)
Definition: uiitem.h:37
UIItem::m_showId
stdext::boolean< false > m_showId
Definition: uiitem.h:57
UIItem::getItemCount
int getItemCount()
Definition: uiitem.h:45
Item::getCount
int getCount()
Definition: item.cpp:249
UIItem::setItemId
void setItemId(int id)
Definition: uiitem.cpp:76
UIItem::onStyleApply
void onStyleApply(const std::string &styleName, const OTMLNodePtr &styleNode)
Definition: uiitem.cpp:89
UIItem::isVirtual
bool isVirtual()
Definition: uiitem.h:48
item.h