Пример #1
0
void LogMessageWindow::initialize(void)
{
	try
	{
		// always initialize after gkDebugScreen!

		Ogre::OverlayManager& mgr = Ogre::OverlayManager::getSingleton();
		m_over  = mgr.create("<gkBuiltin/LogMessageWindow>");
		m_textarea   = mgr.createOverlayElement("TextArea", "<gkBuiltin/LogMessageWindow/Textarea>");
		m_cont  = (Ogre::OverlayContainer*)mgr.createOverlayElement("Panel", "<gkBuiltin/LogMessageWindow/Containter>");


		m_cont->setMetricsMode(Ogre::GMM_PIXELS);
		m_cont->setVerticalAlignment(Ogre::GVA_TOP);
		m_cont->setHorizontalAlignment(Ogre::GHA_LEFT);
		//m_cont->setLeft(-16 * PROP_SIZE);
		//m_cont->setTop(10);
		//m_cont->setWidth(1.0f);
		//m_cont->setHeight(0.25f);
		//m_cont->s>setDimensions(1.0,0.25);
		

		m_textarea->setMetricsMode(Ogre::GMM_PIXELS);
		m_textarea->setVerticalAlignment(Ogre::GVA_TOP);
		m_textarea->setHorizontalAlignment(Ogre::GHA_LEFT);
		//m_val->setMetricsMode(Ogre::GMM_PIXELS);
		//m_val->setVerticalAlignment(Ogre::GVA_TOP);
		//m_val->setHorizontalAlignment(Ogre::GHA_LEFT);
		//m_val->setLeft(8 * PROP_SIZE);

		m_font = Ogre::FontManager::getSingleton().create("WQYFont", MY_GROUP_NAME); 
		m_font ->setSource(FONT_TTF_WQY);
		m_font ->setType(Ogre::FT_TRUETYPE);
		m_font ->setTrueTypeSize( 20 ); 
		m_font ->setTrueTypeResolution( 96 );
		m_font ->addCodePointRange(Ogre::Font::CodePointRange(33,255)); 
		m_font ->addCodePointRange(Ogre::Font::CodePointRange(19968,40869));
		m_font ->load();

		Ogre::TextAreaOverlayElement* textArea;

		textArea = static_cast<Ogre::TextAreaOverlayElement*>(m_textarea);
		//textArea->setFontName("<gkBuiltin/Font>");
		textArea->setFontName("WQYFont");
		textArea->setCharHeight(PROP_SIZE);
		textArea->setSpaceWidth(PROP_SIZE);
		textArea->setColour(Ogre::ColourValue::Green);

		//textArea = static_cast<Ogre::TextAreaOverlayElement*>(m_val);
		//textArea->setFontName("<gkBuiltin/Font>");
		//textArea->setCharHeight(PROP_SIZE);
		//textArea->setColour(Ogre::ColourValue::White);
		m_over->setZOrder(498);
		m_cont->addChild(m_textarea);
		m_over->add2D(m_cont);
	}
	catch (Ogre::Exception& e)
	{
		gkPrintf("%s\n", e.getDescription().c_str());
		return;
	}

	m_isInit = true;

}
//void setSpaceWidth( Real width );
void textareaoverlayelement_set_space_width(TextAreaOverlayElementHandle handle, coiReal width)
{
    Ogre::TextAreaOverlayElement* toe = static_cast<Ogre::TextAreaOverlayElement*>(handle);
    toe->setSpaceWidth(width);
}