MyGUI: MyGUI_ResourceImageSetPointer.cpp Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_ResourceImageSetPointer.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
8#include "MyGUI_ResourceImageSetPointer.h"
9#include "MyGUI_ImageBox.h"
10#include "MyGUI_ResourceManager.h"
11
12namespace MyGUI
13{
14
15 ResourceImageSetPointer::ResourceImageSetPointer() :
16 mImageSet(nullptr)
17 {
18 }
19
20 void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
21 {
22 Base::deserialization(_node, _version);
23
24 // берем детей и крутимся, основной цикл
25 xml::ElementEnumerator info = _node->getElementEnumerator();
26 while (info.next("Property"))
27 {
28 const std::string& key = info->findAttribute("key");
29 const std::string& value = info->findAttribute("value");
30
31 if (key == "Point")
32 mPoint = IntPoint::parse(value);
33 else if (key == "Size")
34 mSize = IntSize::parse(value);
35 else if (key == "Resource")
36 mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
37 }
38 }
39
40 void ResourceImageSetPointer::setImage(ImageBox* _image)
41 {
42 if (mImageSet != nullptr)
43 _image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
44 }
45
46 void ResourceImageSetPointer::setPosition(ImageBox* _image, const IntPoint& _point)
47 {
48 _image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height);
49 }
50
51} // namespace MyGUI
MyGUI_ImageBox.h
MyGUI_Precompiled.h
MyGUI_ResourceImageSetPointer.h
MyGUI_ResourceManager.h
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition MyGUI_IObject.h:18
MyGUI::ImageBox
widget description should be here.
Definition MyGUI_ImageBox.h:24
MyGUI::ImageBox::setItemResourceInfo
void setItemResourceInfo(const ImageIndexInfo &_info)
Definition MyGUI_ImageBox.cpp:320
MyGUI::ResourceImageSet
Definition MyGUI_ResourceImageSet.h:28
MyGUI::ResourceImageSet::getIndexInfo
ImageIndexInfo getIndexInfo(const std::string &_group, const std::string &_index) const
Definition MyGUI_ResourceImageSet.cpp:65
MyGUI::ResourceImageSetPointer::setPosition
void setPosition(ImageBox *_image, const IntPoint &_point) override
Definition MyGUI_ResourceImageSetPointer.cpp:46
MyGUI::ResourceImageSetPointer::ResourceImageSetPointer
ResourceImageSetPointer()
Definition MyGUI_ResourceImageSetPointer.cpp:15
MyGUI::ResourceImageSetPointer::deserialization
void deserialization(xml::ElementPtr _node, Version _version) override
Definition MyGUI_ResourceImageSetPointer.cpp:20
MyGUI::ResourceImageSetPointer::setImage
void setImage(ImageBox *_image) override
Definition MyGUI_ResourceImageSetPointer.cpp:40
MyGUI::ResourceManager::getByName
IResource * getByName(const std::string &_name, bool _throw=true) const
Definition MyGUI_ResourceManager.cpp:235
MyGUI::ResourceManager::getInstance
static ResourceManager & getInstance()
MyGUI::Version
Definition MyGUI_Version.h:18
MyGUI::Widget::setCoord
void setCoord(const IntCoord &_value) override
Definition MyGUI_Widget.cpp:686
MyGUI::xml::ElementEnumerator
Definition MyGUI_XmlDocument.h:115
MyGUI::xml::ElementEnumerator::next
bool next()
Definition MyGUI_XmlDocument.cpp:100
MyGUI::xml::Element
Definition MyGUI_XmlDocument.h:159
MyGUI::xml::Element::getElementEnumerator
ElementEnumerator getElementEnumerator()
Definition MyGUI_XmlDocument.cpp:352
MyGUI::xml::Element::findAttribute
bool findAttribute(const std::string &_name, std::string &_value)
Definition MyGUI_XmlDocument.cpp:246
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::types::TPoint< int >
MyGUI::types::TPoint::left
T left
Definition MyGUI_TPoint.h:20
MyGUI::types::TPoint< int >::parse
static TPoint< int > parse(const std::string &_value)
Definition MyGUI_TPoint.h:120
MyGUI::types::TPoint::top
T top
Definition MyGUI_TPoint.h:21
MyGUI::types::TSize::width
T width
Definition MyGUI_TSize.h:20
MyGUI::types::TSize< int >::parse
static TSize< int > parse(const std::string &_value)
Definition MyGUI_TSize.h:120
MyGUI::types::TSize::height
T height
Definition MyGUI_TSize.h:21