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

« back to all changes in this revision

Viewing changes to Tools/SkinEditor/SettingsGeneralControl.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           09/2010
5
 
*/
6
 
#include "Precompiled.h"
7
 
#include "SettingsGeneralControl.h"
8
 
#include "SettingsManager.h"
9
 
 
10
 
namespace tools
11
 
{
12
 
        SettingsGeneralControl::SettingsGeneralControl(MyGUI::Widget* _parent) :
13
 
                wraps::BaseLayout("SettingsGeneralControl.layout", _parent),
14
 
                mGridStep(0),
15
 
                mGridEdit(nullptr),
16
 
                mSaveLastTexture(nullptr),
17
 
                mInterfaceLanguage(nullptr)
18
 
        {
19
 
                assignWidget(mGridEdit, "gridEdit");
20
 
                assignWidget(mSaveLastTexture, "SaveLastTexture");
21
 
                assignWidget(mInterfaceLanguage, "InterfaceLanguage");
22
 
 
23
 
                mGridEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStepAccept);
24
 
                mGridEdit->eventKeyLostFocus += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStep);
25
 
                mSaveLastTexture->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyMouseButtonClick);
26
 
        }
27
 
 
28
 
        SettingsGeneralControl::~SettingsGeneralControl()
29
 
        {
30
 
                mSaveLastTexture->eventMouseButtonClick -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyMouseButtonClick);
31
 
                mGridEdit->eventEditSelectAccept -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStepAccept);
32
 
                mGridEdit->eventKeyLostFocus -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStep);
33
 
        }
34
 
 
35
 
        void SettingsGeneralControl::loadSettings()
36
 
        {
37
 
                mGridStep = SettingsManager::getInstance().getSector("Settings")->getPropertyValue<int>("Grid");
38
 
                mGridEdit->setCaption(MyGUI::utility::toString(mGridStep));
39
 
                mSaveLastTexture->setStateSelected(SettingsManager::getInstance().getSector("Settings")->getPropertyValue<bool>("SaveLastTexture"));
40
 
                setLanguageValue(SettingsManager::getInstance().getSector("Settings")->getPropertyValue("InterfaceLanguage"));
41
 
        }
42
 
 
43
 
        void SettingsGeneralControl::saveSettings()
44
 
        {
45
 
                SettingsManager::getInstance().getSector("Settings")->setPropertyValue("Grid", mGridStep);
46
 
                SettingsManager::getInstance().getSector("Settings")->setPropertyValue("SaveLastTexture", mSaveLastTexture->getStateSelected());
47
 
                SettingsManager::getInstance().getSector("Settings")->setPropertyValue("InterfaceLanguage", getLanguageValue());
48
 
        }
49
 
 
50
 
        void SettingsGeneralControl::notifyNewGridStep(MyGUI::Widget* _sender, MyGUI::Widget* _new)
51
 
        {
52
 
                mGridStep = MyGUI::utility::parseInt(mGridEdit->getOnlyText());
53
 
                mGridStep = std::max(1, mGridStep);
54
 
                mGridEdit->setCaption(MyGUI::utility::toString(mGridStep));
55
 
        }
56
 
 
57
 
        void SettingsGeneralControl::notifyNewGridStepAccept(MyGUI::EditBox* _sender)
58
 
        {
59
 
                notifyNewGridStep(_sender);
60
 
        }
61
 
 
62
 
        void SettingsGeneralControl::notifyMouseButtonClick(MyGUI::Widget* _sender)
63
 
        {
64
 
                MyGUI::Button* button = _sender->castType<MyGUI::Button>(false);
65
 
                if (button != nullptr)
66
 
                        button->setStateSelected(!button->getStateSelected());
67
 
        }
68
 
 
69
 
        void SettingsGeneralControl::setLanguageValue(const std::string& _value)
70
 
        {
71
 
                for (size_t index = 0; index < mInterfaceLanguage->getItemCount(); index ++)
72
 
                {
73
 
                        if (mInterfaceLanguage->getItemNameAt(index) == _value)
74
 
                        {
75
 
                                mInterfaceLanguage->setIndexSelected(index);
76
 
                                return;
77
 
                        }
78
 
                }
79
 
                for (size_t index = 0; index < mInterfaceLanguage->getItemCount(); index ++)
80
 
                {
81
 
                        if (mInterfaceLanguage->getItemNameAt(index) == "Auto")
82
 
                        {
83
 
                                mInterfaceLanguage->setIndexSelected(index);
84
 
                                return;
85
 
                        }
86
 
                }
87
 
        }
88
 
 
89
 
        std::string SettingsGeneralControl::getLanguageValue()
90
 
        {
91
 
                if (mInterfaceLanguage->getIndexSelected() == MyGUI::ITEM_NONE)
92
 
                        return "Auto";
93
 
                return mInterfaceLanguage->getItemNameAt(mInterfaceLanguage->getIndexSelected());
94
 
        }
95
 
 
96
 
} // namespace tools
 
1
/*!
 
2
        @file
 
3
        @author         Albert Semenov
 
4
        @date           09/2010
 
5
*/
 
6
 
 
7
#include "Precompiled.h"
 
8
#include "SettingsGeneralControl.h"
 
9
#include "SettingsManager.h"
 
10
#include "FactoryManager.h"
 
11
 
 
12
namespace tools
 
13
{
 
14
 
 
15
        FACTORY_ITEM_ATTRIBUTE(SettingsGeneralControl)
 
16
 
 
17
        SettingsGeneralControl::SettingsGeneralControl() :
 
18
                mGridStep(0),
 
19
                mGridEdit(nullptr),
 
20
                mSaveLastTexture(nullptr),
 
21
                mInterfaceLanguage(nullptr)
 
22
        {
 
23
        }
 
24
 
 
25
        SettingsGeneralControl::~SettingsGeneralControl()
 
26
        {
 
27
                mSaveLastTexture->eventMouseButtonClick -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyMouseButtonClick);
 
28
                mGridEdit->eventEditSelectAccept -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStepAccept);
 
29
                mGridEdit->eventKeyLostFocus -= MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStep);
 
30
        }
 
31
 
 
32
        void SettingsGeneralControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
33
        {
 
34
                Control::OnInitialise(_parent, _place, _layoutName);
 
35
 
 
36
                assignWidget(mGridEdit, "gridEdit");
 
37
                assignWidget(mSaveLastTexture, "SaveLastTexture");
 
38
                assignWidget(mInterfaceLanguage, "InterfaceLanguage");
 
39
 
 
40
                mGridEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStepAccept);
 
41
                mGridEdit->eventKeyLostFocus += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyNewGridStep);
 
42
                mSaveLastTexture->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsGeneralControl::notifyMouseButtonClick);
 
43
        }
 
44
 
 
45
        void SettingsGeneralControl::loadSettings()
 
46
        {
 
47
                mGridStep = SettingsManager::getInstance().getValue<int>("Settings/GridStep");
 
48
                mGridEdit->setCaption(MyGUI::utility::toString(mGridStep));
 
49
                mSaveLastTexture->setStateSelected(SettingsManager::getInstance().getValue<bool>("Settings/SaveLastTexture"));
 
50
                setLanguageValue(SettingsManager::getInstance().getValue("Settings/InterfaceLanguage"));
 
51
        }
 
52
 
 
53
        void SettingsGeneralControl::saveSettings()
 
54
        {
 
55
                SettingsManager::getInstance().setValue("Settings/GridStep", mGridStep);
 
56
                SettingsManager::getInstance().setValue("Settings/SaveLastTexture", mSaveLastTexture->getStateSelected());
 
57
                SettingsManager::getInstance().setValue("Settings/InterfaceLanguage", getLanguageValue());
 
58
        }
 
59
 
 
60
        void SettingsGeneralControl::notifyNewGridStep(MyGUI::Widget* _sender, MyGUI::Widget* _new)
 
61
        {
 
62
                mGridStep = MyGUI::utility::parseInt(mGridEdit->getOnlyText());
 
63
                mGridStep = (std::max)(1, mGridStep);
 
64
                mGridEdit->setCaption(MyGUI::utility::toString(mGridStep));
 
65
        }
 
66
 
 
67
        void SettingsGeneralControl::notifyNewGridStepAccept(MyGUI::EditBox* _sender)
 
68
        {
 
69
                notifyNewGridStep(_sender);
 
70
        }
 
71
 
 
72
        void SettingsGeneralControl::notifyMouseButtonClick(MyGUI::Widget* _sender)
 
73
        {
 
74
                MyGUI::Button* button = _sender->castType<MyGUI::Button>(false);
 
75
                if (button != nullptr)
 
76
                        button->setStateSelected(!button->getStateSelected());
 
77
        }
 
78
 
 
79
        void SettingsGeneralControl::setLanguageValue(const std::string& _value)
 
80
        {
 
81
                for (size_t index = 0; index < mInterfaceLanguage->getItemCount(); index ++)
 
82
                {
 
83
                        if (mInterfaceLanguage->getItemNameAt(index) == _value)
 
84
                        {
 
85
                                mInterfaceLanguage->setIndexSelected(index);
 
86
                                return;
 
87
                        }
 
88
                }
 
89
                for (size_t index = 0; index < mInterfaceLanguage->getItemCount(); index ++)
 
90
                {
 
91
                        if (mInterfaceLanguage->getItemNameAt(index) == "Auto")
 
92
                        {
 
93
                                mInterfaceLanguage->setIndexSelected(index);
 
94
                                return;
 
95
                        }
 
96
                }
 
97
        }
 
98
 
 
99
        std::string SettingsGeneralControl::getLanguageValue()
 
100
        {
 
101
                if (mInterfaceLanguage->getIndexSelected() == MyGUI::ITEM_NONE)
 
102
                        return "Auto";
 
103
                return mInterfaceLanguage->getItemNameAt(mInterfaceLanguage->getIndexSelected());
 
104
        }
 
105
 
 
106
        void SettingsGeneralControl::OnCommand(const std::string& _command)
 
107
        {
 
108
                Control::OnCommand(_command);
 
109
 
 
110
                if (_command == "Command_LoadSettings")
 
111
                        loadSettings();
 
112
                else if (_command == "Command_SaveSettings")
 
113
                        saveSettings();
 
114
        }
 
115
 
 
116
}