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

« back to all changes in this revision

Viewing changes to Tools/EditorFramework/TextFieldControl.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 "TextFieldControl.h"
 
9
 
 
10
namespace tools
 
11
{
 
12
 
 
13
        TextFieldControl::TextFieldControl() :
 
14
                mText(nullptr),
 
15
                mOk(nullptr),
 
16
                mCancel(nullptr)
 
17
        {
 
18
        }
 
19
 
 
20
        TextFieldControl::~TextFieldControl()
 
21
        {
 
22
                mMainWidget->eventRootKeyChangeFocus -= MyGUI::newDelegate(this, &TextFieldControl::notifyRootKeyChangeFocus);
 
23
 
 
24
                mOk->eventMouseButtonClick -= MyGUI::newDelegate(this, &TextFieldControl::notifyOk);
 
25
                mCancel->eventMouseButtonClick -= MyGUI::newDelegate(this, &TextFieldControl::notifyCancel);
 
26
                mText->eventEditSelectAccept -= MyGUI::newDelegate(this, &TextFieldControl::notifyTextAccept);
 
27
 
 
28
                MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
 
29
                if (window != nullptr)
 
30
                        window->eventWindowButtonPressed -= MyGUI::newDelegate(this, &TextFieldControl::notifyWindowButtonPressed);
 
31
        }
 
32
 
 
33
        void TextFieldControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
34
        {
 
35
                Control::OnInitialise(_parent, _place, "TextField.layout");
 
36
 
 
37
                setDialogRoot(mMainWidget);
 
38
 
 
39
                assignWidget(mText, "Text");
 
40
                assignWidget(mOk, "Ok", false);
 
41
                assignWidget(mCancel, "Cancel", false);
 
42
 
 
43
                mOk->eventMouseButtonClick += MyGUI::newDelegate(this, &TextFieldControl::notifyOk);
 
44
                mCancel->eventMouseButtonClick += MyGUI::newDelegate(this, &TextFieldControl::notifyCancel);
 
45
                mText->eventEditSelectAccept += MyGUI::newDelegate(this, &TextFieldControl::notifyTextAccept);
 
46
                
 
47
                mMainWidget->eventRootKeyChangeFocus += MyGUI::newDelegate(this, &TextFieldControl::notifyRootKeyChangeFocus);
 
48
 
 
49
                MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
 
50
                if (window != nullptr)
 
51
                        window->eventWindowButtonPressed += MyGUI::newDelegate(this, &TextFieldControl::notifyWindowButtonPressed);
 
52
 
 
53
                mMainWidget->setVisible(false);
 
54
        }
 
55
 
 
56
        void TextFieldControl::notifyOk(MyGUI::Widget* _sender)
 
57
        {
 
58
                eventEndDialog(this, true);
 
59
        }
 
60
 
 
61
        void TextFieldControl::notifyCancel(MyGUI::Widget* _sender)
 
62
        {
 
63
                eventEndDialog(this, false);
 
64
        }
 
65
 
 
66
        void TextFieldControl::setCaption(const MyGUI::UString& _value)
 
67
        {
 
68
                MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
 
69
                if (window != nullptr)
 
70
                        window->setCaption(_value);
 
71
        }
 
72
 
 
73
        void TextFieldControl::setTextField(const MyGUI::UString& _value)
 
74
        {
 
75
                mText->setCaption(_value);
 
76
        }
 
77
 
 
78
        MyGUI::UString TextFieldControl::getTextField()
 
79
        {
 
80
                return mText->getOnlyText();
 
81
        }
 
82
 
 
83
        void TextFieldControl::notifyWindowButtonPressed(MyGUI::Window* _sender, const std::string& _buttonName)
 
84
        {
 
85
                if (_buttonName == "close")
 
86
                        eventEndDialog(this, false);
 
87
        }
 
88
 
 
89
        void TextFieldControl::setUserData(MyGUI::Any _data)
 
90
        {
 
91
                mMainWidget->setUserData(_data);
 
92
        }
 
93
 
 
94
        void TextFieldControl::notifyTextAccept(MyGUI::EditBox* _sender)
 
95
        {
 
96
                eventEndDialog(this, true);
 
97
        }
 
98
 
 
99
        void TextFieldControl::onDoModal()
 
100
        {
 
101
                mText->setTextSelection(0, mText->getTextLength());
 
102
                MyGUI::InputManager::getInstance().setKeyFocusWidget(mText);
 
103
        }
 
104
 
 
105
        void TextFieldControl::onEndModal()
 
106
        {
 
107
        }
 
108
 
 
109
        void TextFieldControl::notifyRootKeyChangeFocus(MyGUI::Widget* _sender, bool _focus)
 
110
        {
 
111
                if (!_focus && mMainWidget->getVisible())
 
112
                        eventEndDialog(this, false);
 
113
        }
 
114
 
 
115
        void TextFieldControl::setCoord(const MyGUI::IntCoord& _value)
 
116
        {
 
117
                mMainWidget->setCoord(_value);
 
118
        }
 
119
}