Пример #1
0
void gfxPrint(int x, int y, const char* str, int style, int pipePos, int pipe2Pos, int halign)
{
	const int charSize = 16;
	const int pipeSize = 12;

	sf::Text text(str, *gFont, charSize);
	sf::FloatRect r = text.getLocalBounds();
	sf::Vector2f pos = sf::Vector2f(x - (r.left+r.width)/2.0f, y - text.getCharacterSize()/2.0f);
	pos = sf::Vector2f((int)pos.x, (int)pos.y);
	text.setPosition(pos - sf::Vector2f(r.width/2.0f*halign,0));
	text.setColor(textColor);

	if(pipePos != -1)
	{
		float p1 = text.findCharacterPos(pipePos).x;
		float p2 = text.findCharacterPos(pipe2Pos).x;
		gfxDrawRectangle(p1, pos.y-pipeSize/2, p2-p1, pipeSize*2, GFX_STYLE_ELEM_HOVER, false);
	}

	sf::Vector2f p = text.getPosition();
	text.setPosition((int)p.x, (int)p.y);
	gWindow->draw(text);

	if(pipePos >= 0 && pipePos == pipe2Pos)
	{
		std::string curr = str;
		curr = curr.substr(0, pipePos);
		sf::Text currText(curr+".", *gFont, charSize);
		sf::Text _Text("|", *gFont, charSize);
		sf::Text dotText(".", *gFont, charSize);

		_Text.setColor(sf::Color(0, 0, 255));
		float xDiff = currText.getLocalBounds().width - dotText.getLocalBounds().width;
		_Text.setPosition(sf::Vector2f(pos.x + xDiff, pos.y));
		//gWindow->draw(_Text);
		gfxDrawRectangle(pos.x + xDiff-2, pos.y-pipeSize/2, 2, pipeSize*2, GFX_STYLE_ELEM_PRESSED);
	} 
}
void ImageTextEditor::storeText()
{
    if ( currKey().length() > 0 ) {
	image.setText(currKey(),currLang(),currText());
    }
}