Пример #1
0
	void DemoKeeper::createScene()
	{
		//MyGUI::LayoutManager::getInstance().loadLayout("Wallpaper.layout");

		//const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout");
		//root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("Demonstration of using different widgets and styles (something like Ogre Demo_Gui).");

		mMainPanel = new MainPanel();
		mMainPanel->eventAction = MyGUI::newDelegate(this, &DemoKeeper::notifyEventAction);
		mMainPanel->addObject("FrameWindow");
		mMainPanel->addObject("Horizontal Scrollbar");
		mMainPanel->addObject("Vertical Scrollbar");
		mMainPanel->addObject("TextBox");
		mMainPanel->addObject("ImageBox");
		mMainPanel->addObject("Render to Texture");

		mEditorWindow = new EditorWindow();
		
		MyGUI::FontManager& fontmanager = MyGUI::FontManager::getInstance();

		MyGUI::IFont* font = fontmanager.getByName(fontmanager.getDefaultFont());
#ifdef MYGUI_COCOS2D_PLATFORM
		CCScene* scene = HelloWorld::scene();
		cocos2d::CCDirector::sharedDirector()->runWithScene(scene);

		MyGUI::Cocos2dTexture* texture = (MyGUI::Cocos2dTexture*)font->getTextureFont();

		CCSprite* fontTexture = CCSprite::createWithTexture(texture->getCocos2dTexture());
		scene->addChild(fontTexture);
		fontTexture->setPosition(CCPoint(scene->getContentSize().width / 2, scene->getContentSize().height / 2));
#endif
	}
Пример #2
0
MyGUI::IntSize CalcTextWidth( MyGUI::UString text,string font ){
	MyGUI::FontManager* pfm = MyGUI::FontManager::getInstancePtr();
	MyGUI::IFont* pf = pfm->getByName(font);
	MyGUI::IntSize size;
	size.height = pf->getDefaultHeight();
	if( pf ){
		for( MyGUI::UString::iterator i=text.begin();i!=text.end();++i ){
			MyGUI::GlyphInfo* pg = pf->getGlyphInfo(*i);
			if( pg ){
				size.width += (int)pg->width;
			}
		}
	}
	return size;
}
Пример #3
0
	void FontPanel::notifyMouseButtonClick(MyGUI::Widget* _widget)
	{
		// шрифто?нету
		if (mComboFont->getOnlyText().empty()) return;
		if (mEditSaveFileName->getOnlyText().empty() && _widget == mButtonSave) return;

		MyGUI::xml::Document document;
		document.createDeclaration();
		MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
		generateFontTTFXml(root);

		if (_widget == mButtonSave)
		{
			if (!document.save(mEditSaveFileName->getOnlyText() + ".xml"))
			{
				/*MyGUI::Message* message =*/ MyGUI::Message::createMessageBox("Message", "error", document.getLastError(), MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconError);
			}
			else
			{
				/*MyGUI::Message* message =*/ MyGUI::Message::createMessageBox("Message", "success", mEditSaveFileName->getOnlyText() + ".xml", MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconInfo);
			}

			MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(mFontName);
			MyGUI::ITexture* texture = font->getTextureFont();
			texture->saveToFile(mEditSaveFileName->getOnlyText() + ".png");
		}
		else if (_widget == mButtonGenerate)
		{
			MyGUI::ResourceManager& manager = MyGUI::ResourceManager::getInstance();
			if (manager.isExist(mFontName))
			{
				manager.removeByName(mFontName);
			}

			MyGUI::ResourceManager::getInstance().loadFromXmlNode(root, "", MyGUI::Version());
			MyGUI::IResource* resource = manager.getByName(mFontName, false);
			MYGUI_ASSERT(resource != nullptr, "Could not find font '" << mFontName << "'");
			MyGUI::IFont* font = resource->castType<MyGUI::IFont>();

			// выво?реальног?размер?шрифта
			mFontHeight = font->getDefaultHeight();
			mTextPix->setCaption(MyGUI::utility::toString("Height of a font is ", mFontHeight, " pixels"));

			mFontView->setFontName(mFontName);
			mTextureView->setFontName(mFontName);
		}
	}
Пример #4
0
	void FontPanel::notifyMouseButtonClick(MyGUI::Widget* _widget)
	{
		// шрифтов нету
		if (mComboFont->getOnlyText().empty())
			return;
		if (mEditSaveFileName->getOnlyText().empty() && _widget == mButtonSave)
			return;

		if (_widget == mButtonSave)
		{
			std::string textureName = mEditSaveFileName->getOnlyText() + ".png";
			saveTexture(mFontName, textureName);

			std::string fontName = MyGUI::utility::toString(mEditSaveFileName->getOnlyText(), ".ttf.", mFontHeight);
			std::string fileName = mEditSaveFileName->getOnlyText() + ".ttf.xml";
			saveFontTTFXml(fontName, fileName);

			fontName = MyGUI::utility::toString(mEditSaveFileName->getOnlyText(), ".manual.", mFontHeight);
			fileName = mEditSaveFileName->getOnlyText() + ".manual.xml";
			saveFontManualXml(fontName, textureName, fileName);
		}
		else if (_widget == mButtonGenerate)
		{
			MyGUI::ResourceManager& manager = MyGUI::ResourceManager::getInstance();
			if (manager.isExist(mFontName))
			{
				manager.removeByName(mFontName);
			}

			MyGUI::xml::Document document;
			document.createDeclaration();
			MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
			generateFontTTFXml(root, mFontName);

			MyGUI::ResourceManager::getInstance().loadFromXmlNode(root, "", MyGUI::Version());
			MyGUI::IResource* resource = manager.getByName(mFontName, false);
			MYGUI_ASSERT(resource != nullptr, "Could not find font '" << mFontName << "'");
			MyGUI::IFont* font = resource->castType<MyGUI::IFont>();

			// вывод реального размера шрифта
			mFontHeight = font->getDefaultHeight();
			mTextPix->setCaption(MyGUI::utility::toString("Height of a font is ", mFontHeight, " pixels"));

			mFontView->setFontName(mFontName);
			mTextureView->setFontName(mFontName);
		}
	}
Пример #5
0
        void operator () (Section const & section, Line const & line, Run const & run) const
        {
            MyGUI::IFont* Font = run.mStyle->mFont;

            ActiveTextFormats::iterator j = this_->mActiveTextFormats.find (Font);

            if (j == this_->mActiveTextFormats.end ())
            {
                TextFormat * textFormat = new TextFormat (Font, this_);

                textFormat->mTexture = Font->getTextureFont ();

                j = this_->mActiveTextFormats.insert (std::make_pair (Font, textFormat)).first;
            }

            j->second->mCountVertex += run.mPrintableChars * 6;
        }
Пример #6
0
	void PropertyFieldFont::onFillValues()
	{
		WidgetStyle::VectorString values;

		const std::string DEFAULT_STRING = "[DEFAULT]";
		values.push_back(replaceTags("ColourDefault") + DEFAULT_STRING);
		values.push_back("Default");

		MyGUI::ResourceManager::EnumeratorPtr resource = MyGUI::ResourceManager::getInstance().getEnumerator();
		while (resource.next())
		{
			MyGUI::IFont* resourceFont = resource.current().second->castType<MyGUI::IFont>(false);
			if (resourceFont != nullptr)
				values.push_back(resourceFont->getResourceName());
		}

		for (WidgetStyle::VectorString::iterator iter = values.begin(); iter != values.end(); ++iter)
			mField->addItem(*iter);
		mField->beginToItemFirst();
	}
Пример #7
0
	void FontPanel::saveTexture(const std::string& _fontName, const std::string& _fileName)
	{
		MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(_fontName);
		MyGUI::ITexture* texture = font->getTextureFont();
		texture->saveToFile(_fileName);
	}
Пример #8
0
		//--------------------------------------------------------------------------------
		void	Chat::_Log(const MyGUI::UString& str, const MyGUI::UString& color)
		{
			while(mList->getItemCount() > 200)
				mList->removeItemAt(0);

			std::wstring tmp;

			std::vector<std::wstring> lines;
			lines.clear();

			MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(MyGUI::FontManager::getInstance().getDefaultFont());

			int ctr = 0;

			for(size_t i = 0; i < str.size(); i++)
			{
				if(ctr + font->getGlyphInfo((int)str[i])->width > mList->getWidth() - 35)
				{
					ctr = 0;

					if(str[i] != L' ')
						tmp.push_back(L'-');
					else
						while(str[i] == L' ' && i < str.size()){i++;}

						lines.push_back(tmp);
						tmp.clear();
				}

				tmp.push_back(str[i]);

				ctr += font->getGlyphInfo((int)str[i])->width;

				if (i >= str.size() - 1)
				{
					ctr = 0;
					lines.push_back(tmp);
					tmp.clear();
				}
			}

			for (unsigned int i = 0 ; i < lines.size() ; i++)
			{
				if (i == 0)
				{
					std::wstring toAdd;
					toAdd += lines[i].substr(0, lines[i].find(L":") + 1);
					toAdd += color;
					toAdd += lines[i].substr(lines[i].find(L":") + 1, lines[i].size());

					mList->addItem(toAdd);
				}
				else
				{
					std::wstring toAdd = color;
					toAdd += lines[i];
					mList->addItem(toAdd);
				}
			}

			mList->beginToItemLast();
		}