コード例 #1
0
ファイル: diffsrfc.cpp プロジェクト: YemSalat/jetcat
void Componentality::Graphics::operator-=(ISurface& dst, ISurface& src)
{
	for (size_t i = 0; i < ____min(dst.getWidth(), src.getWidth()); i++)
		for (size_t j = 0; j < ____min(dst.getHeight(), src.getHeight()); j++)
		{
			ColorRGB dst_color = dst.peek(i, j);
			ColorRGB src_color = src.peek(i, j);
			dst_color.red -= src_color.red;
			dst_color.green -= src_color.green;
			dst_color.blue -= src_color.blue;
			dst.plot(i, j, dst_color);
		}
}
コード例 #2
0
ファイル: caption.cpp プロジェクト: YemSalat/jetcat
Margins Caption::draw(ISurface& surface)
{
	Point topleft(0, 0), rightbottom(surface.getWidth(), mHeight);
	ViewPort vp(surface, topleft, rightbottom);
	Drawer drawer(vp);
	Point _topleft(0, 0), _rightbottom(vp.getWidth() - 1, vp.getHeight() - 1);
	drawer.filled_rectangle(_topleft, _rightbottom, mColor);
	Drawer linedrawer(surface);
	topleft.y = mHeight;
	linedrawer.line(topleft, rightbottom, mLineColor);

	{
		ITextOutput* text_output = provideTextOutput(vp);
		text_output->setFont(mFont);
		text_output->setColor(mFontColor);
		text_output->setMargins(mMargins);
		System::Alignments align = System::getSystemProperties().getAlignments(System::SYSALIGN_CAPTION_TEXT);
		text_output->setHAlignment(align.first);
		text_output->setVAlignment(align.second);
		text_output->print(mTitle);
		delete text_output;
	}

	Margins results;
	results.mBottom = results.mLeft = results.mRight = 0;
	results.mTop = mHeight + 1;

	IElement::draw(vp);

	return results;
}
コード例 #3
0
ファイル: editbox.cpp プロジェクト: YemSalat/jetcat
Margins EditBox::draw(ISurface& master)
{
	if (isHidden())
		return Margins();
	CST::Common::scoped_lock lock(mLock);
	Margins margins = getMargins();
	if (!mFrameColor.isUndefined())
	{
		Drawer drawer(master);
		drawer.rectangle(Point(0, 0), Point(master.getWidth() - 1, master.getHeight() - 1), mFrameColor);
		margins += Margins(1, 1, 1, 1);
	}
	if (!mBackgroundColor.isUndefined())
	{
		Drawer drawer(master);
		drawer.filled_rectangle(Point(1, 1), Point(master.getWidth() - 2, master.getHeight() - 2), mBackgroundColor);
	}
	ViewPort basic_surface(master, margins.getTopLeft(master), margins.getRightBottom(master));
	if (mCursor)
	{
		if (mCursorColor.isUndefined())
		{
			Color color = getColor();
			Componentality::Graphics::Color cursor_color(255 - color.operator Componentality::Graphics::ColorRGB().red,
				255 - color.operator Componentality::Graphics::ColorRGB().green,
				255 - color.operator Componentality::Graphics::ColorRGB().blue);
			mCursor->setColor(cursor_color);
		}
		else
			mCursor->setColor(mCursorColor);
		std::pair<Point, std::pair<size_t, size_t> > cursor_defs = positionCursor(basic_surface);
		mCursor->setLocation(cursor_defs.first + margins.getTopLeft(master));
		mCursor->setSize(cursor_defs.second.first, cursor_defs.second.second);
		mCursor->reset();
	}
	Font* font = System::getSystemProperties().getFontSet().find(this->getFont());
	MovingPort surface(basic_surface, -(int) mScrolling, 0);
	if (font)
	{
		std::list<int> text = getText();
		font->setForeground(mColor);
		font->print(surface, Point(1, 0), text);
	}
	IElement::draw(surface);
	return margins;
}
コード例 #4
0
ファイル: frame.cpp プロジェクト: YemSalat/jetcat
Margins Frame::draw(ISurface& surface)
{
	Point topleft(mWidth / 2, mWidth / 2), bottomright(surface.getWidth() - mWidth / 2 - 1, surface.getHeight() - mWidth / 2 - 1);
	AdvancedSurface asurface(surface);
	SquareBrush brush(mWidth);
	asurface.setBrush(&brush);
	Drawer drawer(asurface);
	drawer.rectangle(topleft, bottomright, mColor);
	Margins result;
	result.mBottom = result.mLeft = result.mRight = result.mTop = mWidth;

	ViewPort port = getDrawArea(surface, result);
	IElement::draw(port);
	return result;
}
コード例 #5
0
ファイル: editbox.cpp プロジェクト: YemSalat/jetcat
std::pair<Point, std::pair<size_t, size_t> > EditBox::positionCursor(ISurface& surface)
{
	CST::Common::scoped_lock lock(mLock);
	std::pair<Point, std::pair<size_t, size_t> > result(Point(0, 0), std::pair<size_t, size_t>(0, 0));
	NullSurface null_surface((size_t)-1, (size_t)-1);
	Font* font = System::getSystemProperties().getFontSet().find(this->getFont());
	if (!font)
		return result;
	Measurer measurer(this->mPosition);
	std::list<int> string = getText();
	font->print(null_surface, Point(0, 0), string, &measurer);
	if (System::getSystemProperties().getCursorType() == System::SYSCURSOR_HORIZONTAL)
	{
		result.first.x = mPosition < string.size() ? measurer.mBegin : measurer.mTotal;
		result.second.first = (measurer.mBegin != (size_t)-1) && (measurer.mEnd != (size_t)-1) ? measurer.mEnd - measurer.mBegin : font->getHeight() / 2;
		result.first.y = font->getBaseline() + System::getSystemProperties().getCursorIndent();
		result.second.second = mCursor->getSize().second;
	}
	else if (System::getSystemProperties().getCursorType() == System::SYSCURSOR_VERTICAL)
	{
		result.first.x = mPosition < string.size() ? measurer.mBegin : measurer.mTotal;
		result.second.first = mCursor->getSize().first;
		result.first.y = 0;
		result.second.second = font->getHeight() - result.first.y;
	}
	while (result.first.x + mSpace >= mScrolling + (int) surface.getWidth())
	{
		mScrolling += mSpace;
	}
	while (result.first.x < mScrolling)
	{
		mScrolling -= ____min(mSpace, mScrolling);
	}
	result.first.x -= mScrolling;
	return result;
}