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

« back to all changes in this revision

Viewing changes to Tools/SkinEditor/PropertyInt2Control.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 "PropertyInt2Control.h"
8
 
#include "Localise.h"
9
 
 
10
 
namespace tools
11
 
{
12
 
 
13
 
        PropertyInt2Control::PropertyInt2Control(MyGUI::Widget* _parent) :
14
 
                wraps::BaseLayout("PropertyEditControl.layout", _parent),
15
 
                mEdit(nullptr)
16
 
        {
17
 
                assignWidget(mEdit, "Edit");
18
 
 
19
 
                mEdit->eventEditTextChange += MyGUI::newDelegate(this, &PropertyInt2Control::notifyEditTextChange);
20
 
        }
21
 
 
22
 
        PropertyInt2Control::~PropertyInt2Control()
23
 
        {
24
 
                mEdit->eventEditTextChange -= MyGUI::newDelegate(this, &PropertyInt2Control::notifyEditTextChange);
25
 
        }
26
 
 
27
 
        void PropertyInt2Control::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 PropertyInt2Control::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 PropertyInt2Control::isValidate()
59
 
        {
60
 
                MyGUI::UString value = mEdit->getOnlyText();
61
 
 
62
 
                int value1 = 0;
63
 
                int value2 = 0;
64
 
                if (!MyGUI::utility::parseComplex(value, value1, value2))
65
 
                        return false;
66
 
 
67
 
                return true;
68
 
        }
69
 
 
70
 
        MyGUI::UString PropertyInt2Control::getClearValue()
71
 
        {
72
 
                MyGUI::UString value = mEdit->getOnlyText();
73
 
 
74
 
                int value1 = 0;
75
 
                int value2 = 0;
76
 
                if (MyGUI::utility::parseComplex(value, value1, value2))
77
 
                        return MyGUI::utility::toString(value1, " ", value2);
78
 
 
79
 
                return "";
80
 
        }
81
 
 
82
 
        void PropertyInt2Control::setColour(bool _validate)
83
 
        {
84
 
                MyGUI::UString value = mEdit->getOnlyText();
85
 
                if (!_validate)
86
 
                        value = replaceTags("ColourError") + value;
87
 
 
88
 
                size_t index = mEdit->getTextCursor();
89
 
                mEdit->setCaption(value);
90
 
                mEdit->setTextCursor(index);
91
 
        }
92
 
 
93
 
} // namespace tools