예제 #1
0
PageView::~PageView()
{
	XOJ_CHECK_TYPE(PageView);

	this->xournal->getControl()->getScheduler()->removePage(this);
	delete this->inputHandler;
	this->inputHandler = NULL;
	delete this->eraser;
	this->eraser = NULL;
	endText();
	deleteViewBuffer();

	g_mutex_free(this->repaintRectMutex);
	for (GList* l = this->rerenderRects; l != NULL; l = l->next)
	{
		Rectangle* rect = (Rectangle*) l->data;
		delete rect;
	}
	g_list_free(this->rerenderRects);
	this->rerenderRects = NULL;

	g_mutex_free(this->drawingMutex);
	this->drawingMutex = NULL;

	if(this->search)
	{
		delete this->search;
	}
	this->search = NULL;

	XOJ_RELEASE_TYPE(PageView);
}
예제 #2
0
bool PageView::onKeyPressEvent(GdkEventKey* event)
{
	XOJ_CHECK_TYPE(PageView);

	// Esc leaves text edition
	if (event->keyval == GDK_Escape)
	{
		if (this->textEditor)
		{
			endText();
			return true;
		}
		else if (xournal->getSelection())
		{
			xournal->clearSelection();
			return true;
		}
		else
		{
			return false;
		}
	}

	if (this->textEditor && this->textEditor->onKeyPressEvent(event))
	{
		return true;
	}

	return false;
}
예제 #3
0
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());
		}
	}
}
예제 #4
0
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());
		}
	}
}
예제 #5
0
QVariant TextLineBase::getProperty(P_ID id) const
      {
      switch (id) {
            case P_ID::BEGIN_TEXT:
                  return beginText();
            case P_ID::BEGIN_TEXT_ALIGN:
                  return int(beginTextAlign());
            case P_ID::CONTINUE_TEXT_ALIGN:
                  return int(continueTextAlign());
            case P_ID::END_TEXT_ALIGN:
                  return int(endTextAlign());
            case P_ID::BEGIN_TEXT_PLACE:
                  return int(_beginTextPlace);
            case P_ID::BEGIN_HOOK_TYPE:
                  return int(_beginHookType);
            case P_ID::BEGIN_HOOK_HEIGHT:
                  return _beginHookHeight;
            case P_ID::BEGIN_FONT_FACE:
                  return _beginFontFamily;
            case P_ID::BEGIN_FONT_SIZE:
                  return _beginFontSize;
            case P_ID::BEGIN_FONT_BOLD:
                  return _beginFontBold;
            case P_ID::BEGIN_FONT_ITALIC:
                  return _beginFontItalic;
            case P_ID::BEGIN_FONT_UNDERLINE:
                  return _beginFontUnderline;
            case P_ID::BEGIN_TEXT_OFFSET:
                  return _beginTextOffset;
            case P_ID::CONTINUE_TEXT:
                  return continueText();
            case P_ID::CONTINUE_TEXT_PLACE:
                  return int(_continueTextPlace);
            case P_ID::CONTINUE_FONT_FACE:
                  return _continueFontFamily;
            case P_ID::CONTINUE_FONT_SIZE:
                  return _continueFontSize;
            case P_ID::CONTINUE_FONT_BOLD:
                  return _continueFontBold;
            case P_ID::CONTINUE_FONT_ITALIC:
                  return _continueFontItalic;
            case P_ID::CONTINUE_FONT_UNDERLINE:
                  return _continueFontUnderline;
            case P_ID::CONTINUE_TEXT_OFFSET:
                  return _continueTextOffset;
            case P_ID::END_TEXT:
                  return endText();
            case P_ID::END_TEXT_PLACE:
                  return int(_endTextPlace);
            case P_ID::END_HOOK_TYPE:
                  return int(_endHookType);
            case P_ID::END_HOOK_HEIGHT:
                  return _endHookHeight;
            case P_ID::END_FONT_FACE:
                  return _endFontFamily;
            case P_ID::END_FONT_SIZE:
                  return _endFontSize;
            case P_ID::END_FONT_BOLD:
                  return _endFontBold;
            case P_ID::END_FONT_ITALIC:
                  return _endFontItalic;
            case P_ID::END_FONT_UNDERLINE:
                  return _endFontUnderline;
            case P_ID::END_TEXT_OFFSET:
                  return _endTextOffset;
            case P_ID::LINE_VISIBLE:
                  return lineVisible();
            default:
                  return SLine::getProperty(id);
            }
      }