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

« back to all changes in this revision

Viewing changes to Tools/EditorFramework/PropertyBoolControl.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
 
 
7
#include "Precompiled.h"
 
8
#include "PropertyBoolControl.h"
 
9
 
 
10
namespace tools
 
11
{
 
12
 
 
13
        PropertyBoolControl::PropertyBoolControl() :
 
14
                mName(nullptr),
 
15
                mComboBox(nullptr)
 
16
        {
 
17
        }
 
18
 
 
19
        PropertyBoolControl::~PropertyBoolControl()
 
20
        {
 
21
                mComboBox->eventComboChangePosition -= MyGUI::newDelegate(this, &PropertyBoolControl::notifyComboChangePosition);
 
22
        }
 
23
 
 
24
        void PropertyBoolControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
25
        {
 
26
                PropertyControl::OnInitialise(_parent, _place, "PropertyComboBoxControl.layout");
 
27
 
 
28
                assignWidget(mName, "Name", false);
 
29
                assignWidget(mComboBox, "ComboBox");
 
30
 
 
31
                mComboBox->addItem("True");
 
32
                mComboBox->addItem("False");
 
33
 
 
34
                mComboBox->beginToItemFirst();
 
35
 
 
36
                mComboBox->eventComboChangePosition += MyGUI::newDelegate(this, &PropertyBoolControl::notifyComboChangePosition);
 
37
        }
 
38
 
 
39
        void PropertyBoolControl::updateCaption()
 
40
        {
 
41
                PropertyPtr proper = getProperty();
 
42
                if (proper != nullptr)
 
43
                        mName->setCaption(proper->getType()->getName());
 
44
        }
 
45
 
 
46
        void PropertyBoolControl::updateProperty()
 
47
        {
 
48
                PropertyPtr proper = getProperty();
 
49
                if (proper != nullptr)
 
50
                {
 
51
                        mComboBox->setEnabled(!proper->getType()->getReadOnly());
 
52
                        size_t index = getComboIndex(proper->getValue());
 
53
                        mComboBox->setIndexSelected(index);
 
54
                }
 
55
                else
 
56
                {
 
57
                        mComboBox->setIndexSelected(MyGUI::ITEM_NONE);
 
58
                        mComboBox->setEnabled(false);
 
59
                }
 
60
        }
 
61
 
 
62
        void PropertyBoolControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
 
63
        {
 
64
                PropertyPtr proper = getProperty();
 
65
                if (proper != nullptr)
 
66
                {
 
67
                        std::string value = _index != MyGUI::ITEM_NONE ? mComboBox->getItemNameAt(_index) : "";
 
68
                        executeAction(value);
 
69
                }
 
70
        }
 
71
 
 
72
        size_t PropertyBoolControl::getComboIndex(const MyGUI::UString& _name)
 
73
        {
 
74
                size_t result = MyGUI::ITEM_NONE;
 
75
 
 
76
                size_t count = mComboBox->getItemCount();
 
77
                for (size_t index = 0; index < count; ++index)
 
78
                {
 
79
                        if (mComboBox->getItemNameAt(index) == _name)
 
80
                        {
 
81
                                result = index;
 
82
                                break;
 
83
                        }
 
84
                }
 
85
 
 
86
                return result;
 
87
        }
 
88
 
 
89
}