コード例 #1
0
void CTextBox::showAll(SDL_Surface * to)
{
	CIntObject::showAll(to);

	const IFont * f = graphics->fonts[font];
	int dy = f->getLineHeight(); //line height
	int base_y = pos.y;

	if (alignment == CENTER)
		base_y += std::max((pos.h - maxH)/2,0);

	int howManyLinesToPrint = slider ? slider->capacity : lines.size();
	int firstLineToPrint = slider ? slider->value : 0;

	for (int i = 0; i < howManyLinesToPrint; i++)
	{
		const std::string &line = lines[i + firstLineToPrint];
		if(!line.size()) continue;

		int width = pos.w + (slider ? (slider->pos.w) : 0);
		int x = pos.x + int(alignment) * width / 2;

		blitLine(to, Point(x, base_y + i * dy), line);
	}

}
コード例 #2
0
void CBoundedLabel::showAll(SDL_Surface * to)
{
	CIntObject::showAll(to);

	const IFont * f = graphics->fonts[font];
	int lineHeight =  f->getLineHeight();
	int lineCapacity = pos.h / lineHeight;

	int dy = f->getLineHeight(); //line height
	int base_y = pos.y;
	if(alignment == CENTER)
		base_y += std::max((pos.h - maxH)/2,0);

	for (int i = 0; i < lineCapacity; i++)
	{
		const std::string &line = lines[i];
		if ( !(lines.size() && line.size())) //empty message or empty line
			continue;

		int x = pos.x;
		if(alignment == CENTER)
		{
			x += pos.w - f->getStringWidth(line.c_str()) / 2;
		}

		blitLine(to, Point(x, base_y + i * dy), line);
	}
}
コード例 #3
0
void CLabel::showAll(SDL_Surface * to)
{
	CIntObject::showAll(to);

	std::string toPrint = visibleText();
	if(!toPrint.length())
		return;

	//blitLine(to, pos.topLeft()/2 + pos.bottomRight()/2, toPrint);
    blitLine(to, pos.topLeft() + textOffset, toPrint);

}
コード例 #4
0
ファイル: compositor.hpp プロジェクト: darkenk/wayland-test
 void copyShmBufferToDisplay(wl_shm_buffer* b, int posY = 0, int posX = 0) {
     uint8_t* data = reinterpret_cast<uint8_t*>(wl_shm_buffer_get_data(b));
     int32_t w = wl_shm_buffer_get_width(b);
     int32_t h = wl_shm_buffer_get_height(b);
     int32_t lineSize = mDisplayWidth - posX;
     lineSize = w < lineSize ? w * BYTES_PER_PIXEL : lineSize * BYTES_PER_PIXEL;
     int32_t nrOfLines = (posY + h) < mDisplayHeight ? (posY + h) : mDisplayHeight;
     int32_t offsetSrc = 0;
     if (posX < 0) {
         offsetSrc -= posX * BYTES_PER_PIXEL;
         lineSize -= offsetSrc;
         posX = 0;
     }
     int32_t offsetDst = (posY * mDisplayWidth + posX) * BYTES_PER_PIXEL;
     for (int32_t y = posY; y < nrOfLines; y++) {
         blitLine(mDisplayBuffer.get() + offsetDst, data + offsetSrc, lineSize);
         offsetDst += mDisplayWidth * BYTES_PER_PIXEL;
         offsetSrc += w * BYTES_PER_PIXEL;
     }
 }