当前位置: 首页>>代码示例>>C++>>正文


C++ ToolHandler::getColor方法代码示例

本文整理汇总了C++中ToolHandler::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolHandler::getColor方法的具体用法?C++ ToolHandler::getColor怎么用?C++ ToolHandler::getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ToolHandler的用法示例。


在下文中一共展示了ToolHandler::getColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startText

void PageView::startText(double x, double y) {
	XOJ_CHECK_TYPE(PageView);

	this->xournal->endTextAllPages(this);

	if (this->textEditor == NULL) {
		// Is there already a textfield?
		ListIterator<Element *> eit = this->page.getSelectedLayer()->elementIterator();

		Text * text = NULL;

		while (eit.hasNext()) {
			Element * e = eit.next();

			if (e->getType() == ELEMENT_TEXT) {
				GdkRectangle matchRect = { x - 10, y - 10, 20, 20 };
				if (e->intersectsArea(&matchRect)) {
					text = (Text *) e;
					break;
				}
			}
		}

		bool ownText = false;
		if (text == NULL) {
			ToolHandler * h = xournal->getControl()->getToolHandler();
			ownText = true;
			text = new Text();
			text->setX(x);
			text->setY(y);
			text->setColor(h->getColor());
			text->setFont(settings->getFont());
		}

		this->textEditor = new TextEditor(this, xournal->getWidget(), text, ownText);
		if (!ownText) {
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}

		rerenderPage();
	} else {
		Text * text = this->textEditor->getText();
		GdkRectangle matchRect = { x - 10, y - 10, 20, 20 };
		if (!text->intersectsArea(&matchRect)) {
			endText();
		} else {
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}
	}
}
开发者ID:whacked,项目名称:xournalpp,代码行数:50,代码来源:PageView.cpp

示例2: startStroke

void InputHandler::startStroke(GdkEventButton * event, StrokeTool tool, double x, double y) {
	XOJ_CHECK_TYPE(InputHandler);

	ToolHandler * h = xournal->getControl()->getToolHandler();

	if(event->device == NULL) {
		g_warning("startStroke: event->device == null");
	}

	if (tmpStroke == NULL) {
		currentInputDevice = event->device;
		tmpStroke = new Stroke();
		tmpStroke->setWidth(h->getThickness());
		tmpStroke->setColor(h->getColor());
		tmpStroke->setToolType(tool);
		tmpStroke->addPoint(Point(x, y));
	}
}
开发者ID:wbrenna,项目名称:xournalpp,代码行数:18,代码来源:InputHandler.cpp

示例3: startText

void PageView::startText(double x, double y)
{
	XOJ_CHECK_TYPE(PageView);

	this->xournal->endTextAllPages(this);

	if (this->textEditor == NULL)
	{
		// Is there already a textfield?
		ListIterator<Element*> eit = this->page->getSelectedLayer()->elementIterator();

		Text* text = NULL;

		while (eit.hasNext())
		{
			Element* e = eit.next();

			if (e->getType() == ELEMENT_TEXT)
			{
				GdkRectangle matchRect = { gint(x - 10), gint(y - 10), 20, 20 };
				if (e->intersectsArea(&matchRect))
				{
					text = (Text*) e;
					break;
				}
			}
		}

		bool ownText = false;
		if (text == NULL)
		{
			ToolHandler* h = xournal->getControl()->getToolHandler();
			ownText = true;
			text = new Text();
			text->setX(x);
			text->setY(y);
			text->setColor(h->getColor());
			text->setFont(settings->getFont());
		}
		else
		{

			//We can try to add an undo action here. The initial text shows up in this
			//textEditor element.
			this->oldtext = text;
			//text = new Text(*oldtext);
			//need to clone the old text so that references still work properly.
			//cloning breaks things a little. do it manually
			text = new Text();
			text->setX(oldtext->getX());
			text->setY(oldtext->getY());
			text->setColor(oldtext->getColor());
			text->setFont(oldtext->getFont());
			text->setText(oldtext->getText());

			Layer* layer = this->page->getSelectedLayer();
			layer->removeElement(this->oldtext, false);
			layer->addElement(text);
			//perform the old swap onto the new text drawn.
		}

		this->textEditor = new TextEditor(this, xournal->getWidget(), text, ownText);
		if (!ownText)
		{
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}

		this->rerenderPage();
	}
	else
	{
		Text* text = this->textEditor->getText();
		GdkRectangle matchRect = {gint(x - 10), gint(y - 10), 20, 20 };
		if (!text->intersectsArea(&matchRect))
		{
			endText();
		}
		else
		{
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}
	}
}
开发者ID:gitter-badger,项目名称:xournalpp,代码行数:83,代码来源:PageView.cpp

示例4: getPenCursor

GdkCursor* Cursor::getPenCursor()
{
	XOJ_CHECK_TYPE(Cursor);

	ToolHandler* handler = control->getToolHandler();

	bool big = control->getSettings()->isShowBigCursor();

	int height = 3;
	int width = 3;
	if (big)
	{
		height = 22;
		width = 15;
	}

	cairo_surface_t* crCursor = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
	                                                       width, height);
	cairo_t* cr = cairo_create(crCursor);

	Util::cairo_set_source_rgbi(cr, handler->getColor());

	if (big)
	{
		cairo_set_source_rgb(cr, 1, 1, 1);
		cairo_set_line_width(cr, 1.2);
		cairo_move_to(cr, 1.5, 1.5);
		cairo_line_to(cr, 2, 19);
		cairo_line_to(cr, 5.5, 15.5);
		cairo_line_to(cr, 8.5, 20.5);
		cairo_line_to(cr, 10.5, 19);
		cairo_line_to(cr, 8.5, 14);
		cairo_line_to(cr, 13, 14);
		cairo_close_path(cr);
		cairo_fill_preserve(cr);

		cairo_set_source_rgb(cr, 0, 0, 0);
		cairo_stroke(cr);

		Util::cairo_set_source_rgbi(cr, handler->getColor());
		cairo_rectangle(cr, 0, 0, 3, 3);
		cairo_fill(cr);
	}
	else
	{
		cairo_rectangle(cr, 0, 0, 3, 3);
		cairo_fill(cr);
	}

	cairo_destroy(cr);

	GdkPixbuf* pixbuf = xoj_pixbuf_get_from_surface(crCursor, 0, 0, width, height);

	//	cairo_surface_write_to_png(crCursor, "/home/andreas/xoj-cursor-orig.png");
	//	gdk_pixbuf_save(pixbuf, "/home/andreas/xoj-cursor.png", "png", NULL, NULL);

	cairo_surface_destroy(crCursor);

	GdkCursor* cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(
	                                                   control->getWindow()->getXournal()->getWidget()), pixbuf, 1, 1);

	gdk_pixbuf_unref(pixbuf);

	return cursor;
}
开发者ID:gitter-badger,项目名称:xournalpp,代码行数:65,代码来源:Cursor.cpp


注:本文中的ToolHandler::getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。