1 /*! 2 @file 3 @author Albert Semenov 4 @date 08/2010 5 */ 6 7 #include "Precompiled.h" 8 #include "PropertyStringControl.h" 9 #include "Localise.h" 10 11 namespace tools 12 { 13 PropertyStringControl()14 PropertyStringControl::PropertyStringControl() : 15 mName(nullptr), 16 mEdit(nullptr) 17 { 18 } 19 ~PropertyStringControl()20 PropertyStringControl::~PropertyStringControl() 21 { 22 mEdit->eventEditTextChange -= MyGUI::newDelegate(this, &PropertyStringControl::notifyEditTextChange); 23 } 24 OnInitialise(Control * _parent,MyGUI::Widget * _place,const std::string & _layoutName)25 void PropertyStringControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName) 26 { 27 PropertyControl::OnInitialise(_parent, _place, "PropertyEditControl.layout"); 28 29 assignWidget(mName, "Name", false); 30 assignWidget(mEdit, "Edit"); 31 32 mEdit->eventEditTextChange += MyGUI::newDelegate(this, &PropertyStringControl::notifyEditTextChange); 33 } 34 updateCaption()35 void PropertyStringControl::updateCaption() 36 { 37 PropertyPtr proper = getProperty(); 38 if (proper != nullptr) 39 mName->setCaption(proper->getType()->getName()); 40 } 41 updateProperty()42 void PropertyStringControl::updateProperty() 43 { 44 PropertyPtr proper = getProperty(); 45 if (proper != nullptr) 46 { 47 mEdit->setEnabled(!proper->getType()->getReadOnly()); 48 if (mEdit->getOnlyText() != proper->getValue()) 49 mEdit->setCaption(proper->getValue()); 50 } 51 else 52 { 53 mEdit->setCaption(""); 54 mEdit->setEnabled(false); 55 } 56 } 57 notifyEditTextChange(MyGUI::EditBox * _sender)58 void PropertyStringControl::notifyEditTextChange(MyGUI::EditBox* _sender) 59 { 60 PropertyPtr proper = getProperty(); 61 if (proper != nullptr) 62 executeAction(getClearValue()); 63 } 64 getClearValue()65 MyGUI::UString PropertyStringControl::getClearValue() 66 { 67 MyGUI::UString value = mEdit->getOnlyText(); 68 return value; 69 } 70 71 } 72