~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to Tools/SkinEditor/PropertyRegionTypeControl.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Albert Semenov
4
 
        @date           08/2010
5
 
*/
6
 
#include "Precompiled.h"
7
 
#include "PropertyRegionTypeControl.h"
8
 
 
9
 
namespace tools
10
 
{
11
 
 
12
 
        PropertyRegionTypeControl::PropertyRegionTypeControl(MyGUI::Widget* _parent) :
13
 
                wraps::BaseLayout("PropertyComboBoxControl.layout", _parent),
14
 
                mComboBox(nullptr)
15
 
        {
16
 
                assignWidget(mComboBox, "ComboBox");
17
 
 
18
 
                mComboBox->addItem("EditText");
19
 
                mComboBox->addItem("SimpleText");
20
 
 
21
 
                mComboBox->addItem("SubSkin");
22
 
 
23
 
                mComboBox->addItem("TileRect");
24
 
                mComboBox->addItem("TileRect Hor");
25
 
                mComboBox->addItem("TileRect Ver");
26
 
 
27
 
                mComboBox->beginToItemFirst();
28
 
 
29
 
                mComboBox->eventComboChangePosition += MyGUI::newDelegate(this, &PropertyRegionTypeControl::notifyComboChangePosition);
30
 
        }
31
 
 
32
 
        PropertyRegionTypeControl::~PropertyRegionTypeControl()
33
 
        {
34
 
                mComboBox->eventComboChangePosition -= MyGUI::newDelegate(this, &PropertyRegionTypeControl::notifyComboChangePosition);
35
 
        }
36
 
 
37
 
        void PropertyRegionTypeControl::updateProperty()
38
 
        {
39
 
                Property* proper = getProperty();
40
 
                if (proper != nullptr)
41
 
                {
42
 
                        mComboBox->setEnabled(!proper->getReadOnly());
43
 
                        size_t index = getComboIndex(proper->getValue());
44
 
                        mComboBox->setIndexSelected(index);
45
 
                }
46
 
                else
47
 
                {
48
 
                        mComboBox->setIndexSelected(MyGUI::ITEM_NONE);
49
 
                        mComboBox->setEnabled(false);
50
 
                }
51
 
        }
52
 
 
53
 
        void PropertyRegionTypeControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
54
 
        {
55
 
                Property* proper = getProperty();
56
 
                if (proper != nullptr)
57
 
                {
58
 
                        if (_index != MyGUI::ITEM_NONE)
59
 
                                proper->setValue(mComboBox->getItemNameAt(_index), getTypeName());
60
 
                        else
61
 
                                proper->setValue("", getTypeName());
62
 
                }
63
 
        }
64
 
 
65
 
        size_t PropertyRegionTypeControl::getComboIndex(const MyGUI::UString& _name)
66
 
        {
67
 
                size_t result = MyGUI::ITEM_NONE;
68
 
 
69
 
                size_t count = mComboBox->getItemCount();
70
 
                for (size_t index = 0; index < count; ++index)
71
 
                {
72
 
                        if (mComboBox->getItemNameAt(index) == _name)
73
 
                        {
74
 
                                result = index;
75
 
                                break;
76
 
                        }
77
 
                }
78
 
 
79
 
                return result;
80
 
        }
81
 
 
82
 
} // namespace tools
 
1
/*!
 
2
        @file
 
3
        @author         Albert Semenov
 
4
        @date           08/2010
 
5
*/
 
6
 
 
7
#include "Precompiled.h"
 
8
#include "PropertyRegionTypeControl.h"
 
9
#include "FactoryManager.h"
 
10
 
 
11
namespace tools
 
12
{
 
13
 
 
14
        FACTORY_ITEM_ATTRIBUTE(PropertyRegionTypeControl)
 
15
 
 
16
        PropertyRegionTypeControl::PropertyRegionTypeControl() :
 
17
                mName(nullptr),
 
18
                mComboBox(nullptr)
 
19
        {
 
20
        }
 
21
 
 
22
        PropertyRegionTypeControl::~PropertyRegionTypeControl()
 
23
        {
 
24
                mComboBox->eventComboChangePosition -= MyGUI::newDelegate(this, &PropertyRegionTypeControl::notifyComboChangePosition);
 
25
        }
 
26
 
 
27
        void PropertyRegionTypeControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
28
        {
 
29
                PropertyControl::OnInitialise(_parent, _place, "PropertyComboBoxControl.layout");
 
30
 
 
31
                assignWidget(mName, "Name", false);
 
32
                assignWidget(mComboBox, "ComboBox");
 
33
 
 
34
                mComboBox->addItem("SubSkin");
 
35
                mComboBox->addItem("TileRect");
 
36
                mComboBox->addItem("TileRect Horz");
 
37
                mComboBox->addItem("TileRect Vert");
 
38
 
 
39
                mComboBox->beginToItemFirst();
 
40
 
 
41
                mComboBox->eventComboChangePosition += MyGUI::newDelegate(this, &PropertyRegionTypeControl::notifyComboChangePosition);
 
42
        }
 
43
 
 
44
        void PropertyRegionTypeControl::updateCaption()
 
45
        {
 
46
                PropertyPtr proper = getProperty();
 
47
                if (proper != nullptr)
 
48
                        mName->setCaption(proper->getType()->getName());
 
49
        }
 
50
 
 
51
        void PropertyRegionTypeControl::updateProperty()
 
52
        {
 
53
                PropertyPtr proper = getProperty();
 
54
                if (proper != nullptr)
 
55
                {
 
56
                        mComboBox->setEnabled(!proper->getType()->getReadOnly());
 
57
                        size_t index = getComboIndex(proper->getValue());
 
58
                        mComboBox->setIndexSelected(index);
 
59
                }
 
60
                else
 
61
                {
 
62
                        mComboBox->setIndexSelected(MyGUI::ITEM_NONE);
 
63
                        mComboBox->setEnabled(false);
 
64
                }
 
65
        }
 
66
 
 
67
        void PropertyRegionTypeControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
 
68
        {
 
69
                PropertyPtr proper = getProperty();
 
70
                if (proper != nullptr)
 
71
                {
 
72
                        std::string value = _index != MyGUI::ITEM_NONE ? mComboBox->getItemNameAt(_index) : "";
 
73
                        executeAction(value);
 
74
                }
 
75
        }
 
76
 
 
77
        size_t PropertyRegionTypeControl::getComboIndex(const MyGUI::UString& _name)
 
78
        {
 
79
                size_t result = MyGUI::ITEM_NONE;
 
80
 
 
81
                size_t count = mComboBox->getItemCount();
 
82
                for (size_t index = 0; index < count; ++index)
 
83
                {
 
84
                        if (mComboBox->getItemNameAt(index) == _name)
 
85
                        {
 
86
                                result = index;
 
87
                                break;
 
88
                        }
 
89
                }
 
90
 
 
91
                return result;
 
92
        }
 
93
 
 
94
}