コード例 #1
0
ファイル: SimpleUI.cpp プロジェクト: JohnCrash/iRobot
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;
}
コード例 #2
0
ファイル: SimpleUI.cpp プロジェクト: JohnCrash/iRobot
/*向界面中加入数据相
*/
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);
	}
}
コード例 #3
0
ファイル: PropertyGridManager.cpp プロジェクト: onze/Steel
/////////////////// <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);
    }
コード例 #4
0
ファイル: Console.cpp プロジェクト: Anomalous-Software/mygui
	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;
	}
コード例 #5
0
ファイル: PropertyGridManager.cpp プロジェクト: onze/Steel
    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);
    }
コード例 #6
0
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);
}
コード例 #7
0
  //--------------------------------------------------------------------------
  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();
    } 
  }
コード例 #8
0
ファイル: ColourPanel.cpp プロジェクト: fake-human/HiveGame
	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);
	}
コード例 #9
0
ファイル: formatting.cpp プロジェクト: JordanMilne/openmw
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()));
    }
}
コード例 #10
0
ファイル: MYGUIManager.cpp プロジェクト: qqdiguo/MuseOpenIG
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;
}
コード例 #11
0
ファイル: formatting.cpp プロジェクト: jhooks1/openmw
    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()));
        }
    }