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

« back to all changes in this revision

Viewing changes to Tools/SkinEditor/PropertyInt4Control.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 "PropertyInt4Control.h"
8
 
#include "Localise.h"
9
 
 
10
 
namespace tools
11
 
{
12
 
 
13
 
        PropertyInt4Control::PropertyInt4Control(MyGUI::Widget* _parent) :
14
 
                wraps::BaseLayout("PropertyEditControl.layout", _parent),
15
 
                mEdit(nullptr)
16
 
        {
17
 
                assignWidget(mEdit, "Edit");
18
 
 
19
 
                mEdit->eventEditTextChange += MyGUI::newDelegate(this, &PropertyInt4Control::notifyEditTextChange);
20
 
        }
21
 
 
22
 
        PropertyInt4Control::~PropertyInt4Control()
23
 
        {
24
 
                mEdit->eventEditTextChange -= MyGUI::newDelegate(this, &PropertyInt4Control::notifyEditTextChange);
25
 
        }
26
 
 
27
 
        void PropertyInt4Control::updateProperty()
28
 
        {
29
 
                Property* proper = getProperty();
30
 
                if (proper != nullptr)
31
 
                {
32
 
                        mEdit->setEnabled(!proper->getReadOnly());
33
 
                        mEdit->setCaption(proper->getValue());
34
 
 
35
 
                        bool validate = isValidate();
36
 
                        setColour(validate);
37
 
                }
38
 
                else
39
 
                {
40
 
                        mEdit->setCaption("");
41
 
                        mEdit->setEnabled(false);
42
 
                }
43
 
        }
44
 
 
45
 
        void PropertyInt4Control::notifyEditTextChange(MyGUI::EditBox* _sender)
46
 
        {
47
 
                Property* proper = getProperty();
48
 
                if (proper != nullptr)
49
 
                {
50
 
                        bool validate = isValidate();
51
 
                        if (validate)
52
 
                                proper->setValue(getClearValue(), getTypeName());
53
 
 
54
 
                        setColour(validate);
55
 
                }
56
 
        }
57
 
 
58
 
        bool PropertyInt4Control::isValidate()
59
 
        {
60
 
                MyGUI::UString value = mEdit->getOnlyText();
61
 
 
62
 
                int value1 = 0;
63
 
                int value2 = 0;
64
 
                int value3 = 0;
65
 
                int value4 = 0;
66
 
                if (!MyGUI::utility::parseComplex(value, value1, value2, value3, value4))
67
 
                        return false;
68
 
 
69
 
                return true;
70
 
        }
71
 
 
72
 
        MyGUI::UString PropertyInt4Control::getClearValue()
73
 
        {
74
 
                MyGUI::UString value = mEdit->getOnlyText();
75
 
 
76
 
                int value1 = 0;
77
 
                int value2 = 0;
78
 
                int value3 = 0;
79
 
                int value4 = 0;
80
 
                if (MyGUI::utility::parseComplex(value, value1, value2, value3, value4))
81
 
                        return MyGUI::utility::toString(value1, " ", value2, " ", value3, " ", value4);
82
 
 
83
 
                return "";
84
 
        }
85
 
 
86
 
        void PropertyInt4Control::setColour(bool _validate)
87
 
        {
88
 
                MyGUI::UString value = mEdit->getOnlyText();
89
 
                if (!_validate)
90
 
                        value = replaceTags("ColourError") + value;
91
 
 
92
 
                size_t index = mEdit->getTextCursor();
93
 
                mEdit->setCaption(value);
94
 
                mEdit->setTextCursor(index);
95
 
        }
96
 
 
97
 
} // namespace tools