Ejemplo n.º 1
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);
	}
}
Ejemplo n.º 2
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;
	}
Ejemplo n.º 3
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();
    } 
  }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
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);
	}
Ejemplo n.º 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);
}
Ejemplo n.º 7
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()));
    }
}
Ejemplo n.º 8
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()));
        }
    }