Esempio n. 1
0
SimpleData SimpleDataUI::get( string name ){
	assert( mParent );
	SimpleData sd;

	for( size_t i = 0;i<mParent->getChildCount();++i ){
		MyGUI::Widget* pw = mParent->getChildAt(i); 
		SimpleData* psd = pw->getUserData<SimpleData>(false);
		if( psd && psd->name==name ){
			MyGUI::UString us;
			MyGUI::EditBox* pe = pw->castType<MyGUI::EditBox>(false);
			if( pe ){
				us = pe->getCaption();
				if( psd->type==SimpleData::STRING )
					psd->str = us;
				else if( psd->type==SimpleData::REAL ){
					try{
						psd->real = boost::lexical_cast<Ogre::Real>( us );
					}catch( boost::bad_lexical_cast& e ){
						MYGUI_LOG(Warning,e.what());
					}
				}
			}
			return *psd;
		}
	}
	return sd;
}
Esempio n. 2
0
/*向界面中加入数据相
*/
void SimpleDataUI::add( const MyGUI::UString& caption,SimpleData sd ){

	MyGUI::TextBox* pt = mParent->createWidget<MyGUI::TextBox>(
		"TextBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
	
	pt->setTextAlign( MyGUI::Align::Right );
	pt->setCaption( caption );
	pt->setUserData( MyGUI::Any(string("@")) ); //打一个标记为删除做准备

	if( sd.type==SimpleData::BOOL ){
		MyGUI::Button* pe = mParent->createWidget<MyGUI::Button>(
		"CheckBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		pe->setStateSelected(sd.b);
		sd.change = mep;
		pe->setUserData(MyGUI::Any(sd));
		pe->eventMouseButtonClick += newDelegate(_simpleDataCheckChange);
	}else if( sd.sv.empty() ){//编辑
		MyGUI::EditBox* pe = mParent->createWidget<MyGUI::EditBox>(
		"EditBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		if( sd.type== SimpleData::STRING )
			pe->setCaption( sd.str );
		else if( sd.type== SimpleData::REAL)
		{
			pe->setCaption( (boost::format("%.2f")%sd.real).str() );
		}

		sd.change = mep;
		pe->setUserData(MyGUI::Any(sd));
		//数据改变
		pe->eventEditTextChange += newDelegate(_simpleDataEditTextChange);
	}else{//有可选数据
		MyGUI::ComboBox* pc = mParent->createWidget<MyGUI::ComboBox>(
		"ComboBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		if( sd.type== SimpleData::STRING )
			pc->setCaption( sd.str );
		else if( sd.type== SimpleData::REAL )
			pc->setCaption( boost::lexical_cast<string>(sd.real) );
		for( vector<MyGUI::UString>::const_iterator i = sd.sv.begin();
			i!=sd.sv.end();++i){
			pc->addItem(*i);
			if( *i == sd.str ){
				if( sd.type== SimpleData::STRING )
					pc->setEditStatic(true);
				pc->setIndexSelected(i-sd.sv.begin());
			}
		}

		sd.change = mep;
		pc->setUserData(MyGUI::Any(sd));
		//数据改变
		pc->eventComboChangePosition += newDelegate(_simpleDataChange);
	}
}
Esempio n. 3
0
/////////////////// <STRING CONTROL>
    void PropertyGridManager::buildStringControl(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        int left = insertPropertyIdLabel(control, property);

        MyGUI::IntCoord coord(left + WIDGET_SPACING, 0, control->getRight() - left - 2 * WIDGET_SPACING, control->getHeight());
        MyGUI::EditBox *editBox = (MyGUI::EditBox *)control->createWidget<MyGUI::EditBox>("EditBox", coord, MyGUI::Align::Left | MyGUI::Align::VCenter, "EditBox");
        editBox->setEditReadOnly(property->isReadOnly());

        editBox->setUserData(property);
        editBox->eventEditSelectAccept += MyGUI::newDelegate(this, &PropertyGridManager::onMyGUIEditSelectAccept);
    }
Esempio n. 4
0
	void Console::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
	{
		MyGUI::EditBox* edit = _sender->castType<MyGUI::EditBox>();
		size_t len = edit->getCaption().length();
		if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocomleted))
		{
			edit->deleteTextSelection();
			len = edit->getCaption().length();
			edit->eraseText(len - 1);
		}

		MyGUI::UString command = edit->getCaption();
		if (command.length() == 0)
			return;

		for (MapDelegate::iterator iter = mDelegates.begin(); iter != mDelegates.end(); ++iter)
		{
			if (iter->first.find(command) == 0)
			{
				if (command == iter->first) break;
				edit->setCaption(iter->first);
				edit->setTextSelection(command.length(), iter->first.length());
				mAutocomleted = true;
				return;
			}
		}
		mAutocomleted = false;
	}
Esempio n. 5
0
    void PropertyGridManager::updateStringControlValue(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        MyGUI::EditBox *editBox = (MyGUI::EditBox *)control->findWidget("EditBox");

        if(nullptr == editBox)
        {
            Debug::error(STEEL_METH_INTRO, "could not find editBox in String propertyControl. Control: ", control, " property: ", *property, ". Aborting.").endl();
            return;
        }

        Ogre::String value = StringUtils::BLANK;
        property->read(value);
        editBox->setCaption(value);
    }
void RigEditorBeamsPanel::SetBeamTypeFieldMixedValueMode(MyGUI::Widget* label_widget, MyGUI::Widget* combobox_widget, const char* beam_type, bool is_mixed)
{
	// Process input
	MyGUI::TextBox* label = nullptr;
	if (label_widget != nullptr) 
	{ 
		label = label_widget->castType<MyGUI::TextBox>(false); 
	}
	MyGUI::EditBox* combobox = combobox_widget->castType<MyGUI::EditBox>(false);
	assert(combobox != nullptr);

	// Update GUI
	if (label != nullptr)
	{
		label->setTextColour( (is_mixed) ? m_text_color_mixvalues : m_text_color_default);
	}
	combobox->setCaption( (is_mixed) ? "" : beam_type);
}
  //--------------------------------------------------------------------------
  void EnvironmentDialog::notifyEditTextChange(MyGUI::EditBox* _sender)
  {
    if (_sender == mStartFog)
    {
      mStart = MyGUI::utility::parseFloat(mStartFog->getCaption());
      SetFog();
    }
    else
    if (_sender == mEndFog)
    {
      mEnd = MyGUI::utility::parseFloat(mEndFog->getCaption());
      SetFog();
    }
    else
    {
      MyGUI::EditBox* edit = static_cast<MyGUI::EditBox*>(_sender);
      size_t cursor = edit->getTextCursor();
      size_t num = MyGUI::utility::parseSizeT(edit->getCaption());
      if (num > 255) num = 255;
      edit->setCaption(MyGUI::utility::toString(num));
      if (cursor < edit->getTextLength()) edit->setTextCursor(cursor);

      mFogColour = ColourValue(
        MyGUI::utility::parseFloat(mEditRed->getCaption()) / 255.0f,
        MyGUI::utility::parseFloat(mEditGreen->getCaption()) / 255.0f,
        MyGUI::utility::parseFloat(mEditBlue->getCaption()) / 255.0f);

      SetFog();
    } 
  }
Esempio n. 8
0
	void ColourPanel::notifyEditTextChange(MyGUI::EditBox* _sender)
	{
		MyGUI::EditBox* edit = static_cast<MyGUI::EditBox*>(_sender);
		size_t cursor = edit->getTextCursor();
		size_t num = MyGUI::utility::parseSizeT(edit->getOnlyText());
		if (num > 255) num = 255;
		edit->setCaption(MyGUI::utility::toString(num));
		if (cursor < edit->getTextLength()) edit->setTextCursor(cursor);

		MyGUI::Colour colour(
			MyGUI::utility::parseFloat(mEditRed->getOnlyText()) / 255.0f,
			MyGUI::utility::parseFloat(mEditGreen->getOnlyText()) / 255.0f,
			MyGUI::utility::parseFloat(mEditBlue->getOnlyText()) / 255.0f);

		updateFromColour(colour);
	}
Esempio n. 9
0
void BookTextParser::parseSubText(std::string text)
{
    if (text[0] == '<')
    {
        if (text.find('>') == std::string::npos)
            throw std::runtime_error("BookTextParser Error: Tag is not terminated");

        if (text.size() > 4 && text.substr(0, 4) == "<IMG")
            parseImage(text.substr(0, text.find('>')));
        else if (text.size() > 5 && text.substr(0, 5) == "<FONT")
            parseFont(text.substr(0, text.find('>')));
        else if (text.size() > 4 && text.substr(0, 4) == "<DIV")
            parseDiv(text.substr(0, text.find('>')));

        text.erase(0, text.find('>')+1);
    }

    bool tagFound = false;
    std::string realText; // real text, without tags
    unsigned int i=0;
    for (; i<text.size(); ++i)
    {
        char c = text[i];
        if (c == '<')
        {
            if (text[i+1] == '/') // ignore closing tags
            {
                while (c != '>')
                {
                    if (i >= text.size())
                        throw std::runtime_error("BookTextParser Error: Tag is not terminated");
                    ++i;
                    c = text[i];
                }
                continue;
            }
            else
            {
                tagFound = true;
                break;
            }
        }
        else
            realText += c;
    }

    MyGUI::EditBox* box = mParent->createWidget<MyGUI::EditBox>("NormalText",
        MyGUI::IntCoord(0, mHeight, mWidth, 24), MyGUI::Align::Left | MyGUI::Align::Top,
        mParent->getName() + boost::lexical_cast<std::string>(mParent->getChildCount()));
    box->setProperty("Static", "true");
    box->setProperty("MultiLine", "true");
    box->setProperty("WordWrap", "true");
    box->setProperty("NeedMouse", "false");
    box->setMaxTextLength(realText.size());
    box->setTextAlign(mTextStyle.mTextAlign);
    box->setTextColour(mTextStyle.mColour);
    box->setFontName(mTextStyle.mFont);
    box->setCaption(realText);
    box->setSize(box->getSize().width, box->getTextSize().height);
    mHeight += box->getTextSize().height;

    if (tagFound)
    {
        parseSubText(text.substr(i, text.size()));
    }
}
Esempio n. 10
0
void MYGUIManager::setIntersectionPoint(const osg::Vec3d& point, bool update)
{
	_intersectionPoint = point;

	if (!update)
	{
		_intersectionPointUpdated = true;
		return;
	}

	if (_root && _intersectionPointUpdated)
	{
		try
		{
			MyGUI::ListBox* list = MyGUI::Gui::getInstance().findWidget<MyGUI::ListBox>("CommandListBox");
			MyGUI::EditBox* edit = MyGUI::Gui::getInstance().findWidget<MyGUI::EditBox>("Arguments");

			if (edit && list)
			{
				if (list->getIndexSelected() == MyGUI::ITEM_NONE) return;

				Base::Commands::CommandPtr command = *list->getItemDataAt<Base::Commands::CommandPtr>(
					list->getItemIndexSelected(), false
					);
				if (command.valid())
				{
					const std::string format = command->getArgumentsFormat();
					const std::string cmd = edit->getOnlyText();

					Base::StringUtils::Tokens cmdTokens = Base::StringUtils::instance()->tokenize(cmd);
					Base::StringUtils::Tokens formatTokens = Base::StringUtils::instance()->tokenize(format, ":");

					std::ostringstream oss;
					for (size_t i = 0; i < cmdTokens.size(); ++i)
					{
						if (i < formatTokens.size())
						{
							std::string token = formatTokens.at(i);
							if (token.at(0) == 'P')
							{
								oss << std::setprecision(10) << " " << _intersectionPoint.x() << " " << _intersectionPoint.y() << " " << _intersectionPoint.z();
								i += 2;
								continue;
							}
							if (token.at(0) == 'F')
							{
								oss << " \"" << cmdTokens.at(i) << "\"";
								continue;
							}
						}
						oss << " " << cmdTokens.at(i);
					}
					if (cmdTokens.size() < formatTokens.size() && formatTokens.at(cmdTokens.size()).at(0) == 'P')
					{
						oss << std::setprecision(10) << " " << _intersectionPoint.x() << " " << _intersectionPoint.y() << " " << _intersectionPoint.z();
					}
					edit->setOnlyText(oss.str().c_str());

				}
			}
		}
		catch (const std::exception& e)
		{
			osg::notify(osg::NOTICE) << "UI: exception: " << e.what() << std::endl;
		}
	}

	_intersectionPointUpdated = false;
}
Esempio n. 11
0
    void BookTextParser::parseSubText(std::string text)
    {
        if (text[0] == '<')
        {
            const size_t tagStart = 1;
            const size_t tagEnd = text.find('>', tagStart);
            if (tagEnd == std::string::npos)
                throw std::runtime_error("BookTextParser Error: Tag is not terminated");
            const std::string tag = text.substr(tagStart, tagEnd - tagStart);

            if (boost::algorithm::starts_with(tag, "IMG"))
                parseImage(tag);
            if (boost::algorithm::starts_with(tag, "FONT"))
                parseFont(tag);
            if (boost::algorithm::starts_with(tag, "DIV"))
                parseDiv(tag);

            text.erase(0, tagEnd + 1);
        }

        size_t tagStart = std::string::npos;
        std::string realText; // real text, without tags
        for (size_t i = 0; i<text.size(); ++i)
        {
            char c = text[i];
            if (c == '<')
            {
                if ((i + 1 < text.size()) && text[i+1] == '/') // ignore closing tags
                {
                    while (c != '>')
                    {
                        if (i >= text.size())
                            throw std::runtime_error("BookTextParser Error: Tag is not terminated");
                        ++i;
                        c = text[i];
                    }
                    continue;
                }
                else
                {
                    tagStart = i;
                    break;
                }
            }
            else
                realText += c;
        }

        MyGUI::EditBox* box = mParent->createWidget<MyGUI::EditBox>("NormalText",
            MyGUI::IntCoord(0, mHeight, mWidth, 24), MyGUI::Align::Left | MyGUI::Align::Top,
            mParent->getName() + boost::lexical_cast<std::string>(mParent->getChildCount()));
        box->setProperty("Static", "true");
        box->setProperty("MultiLine", "true");
        box->setProperty("WordWrap", "true");
        box->setProperty("NeedMouse", "false");
        box->setMaxTextLength(realText.size());
        box->setTextAlign(mTextStyle.mTextAlign);
        box->setTextColour(mTextStyle.mColour);
        box->setFontName(mTextStyle.mFont);
        box->setCaption(realText);
        box->setSize(box->getSize().width, box->getTextSize().height);
        mHeight += box->getTextSize().height;

        if (tagStart != std::string::npos)
        {
            parseSubText(text.substr(tagStart, text.size()));
        }
    }