bool PageView::onMotionNotifyEvent(GtkWidget * widget, GdkEventMotion * event) { XOJ_CHECK_TYPE(PageView); double zoom = xournal->getZoom(); double x = event->x / zoom; double y = event->y / zoom; ToolHandler * h = xournal->getControl()->getToolHandler(); if (this->inputHandler->onMotionNotifyEvent(event)) { //input handler used this event } else if (this->selection) { this->selection->currentPos(x, y); } else if (this->verticalSpace) { this->verticalSpace->currentPos(x, y); } else if (this->textEditor) { Cursor * cursor = getXournal()->getCursor(); cursor->setInvisible(false); Text * text = this->textEditor->getText(); this->textEditor->mouseMoved(x - text->getX(), y - text->getY()); } else if (h->getToolType() == TOOL_ERASER && h->getEraserType() != ERASER_TYPE_WHITEOUT && this->inEraser) { this->eraser->erase(x, y); } return false; }
bool PageView::onButtonPressEvent(GtkWidget * widget, GdkEventButton * event) { XOJ_CHECK_TYPE(PageView); if ((event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) != 0) { return false; // not handled here } if (!this->selected) { xournal->getControl()->firePageSelected(this->page); } ToolHandler * h = xournal->getControl()->getToolHandler(); double x = event->x; double y = event->y; if ((x < 0 || y < 0) && !extendedWarningDisplayd && settings->isXinputEnabled()) { GtkWidget * dialog = gtk_message_dialog_new((GtkWindow *) *xournal->getControl()->getWindow(), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, _("There was a wrong input event, input is not working.\nDo you want to disable \"Extended Input\"?")); gtk_dialog_add_button(GTK_DIALOG(dialog), "Disable \"Extended Input\"", 1); gtk_dialog_add_button(GTK_DIALOG(dialog), "Cancel", 2); this->extendedWarningDisplayd = true; gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(this->xournal->getControl()->getWindow()->getWindow())); if (gtk_dialog_run(GTK_DIALOG(dialog)) == 1) { settings->setXinputEnabled(false); xournal->updateXEvents(); } gtk_widget_destroy(dialog); return true; } double zoom = xournal->getZoom(); x /= zoom; y /= zoom; Cursor * cursor = xournal->getCursor(); cursor->setMouseDown(true); if (h->getToolType() == TOOL_PEN) { this->inputHandler->startStroke(event, STROKE_TOOL_PEN, x, y); } else if (h->getToolType() == TOOL_HILIGHTER) { this->inputHandler->startStroke(event, STROKE_TOOL_HIGHLIGHTER, x, y); } else if (h->getToolType() == TOOL_ERASER) { if (h->getEraserType() == ERASER_TYPE_WHITEOUT) { this->inputHandler->startStroke(event, STROKE_TOOL_ERASER, x, y); this->inputHandler->getTmpStroke()->setColor(0xffffff); // White } else { this->eraser->erase(x, y); this->inEraser = true; } } else if (h->getToolType() == TOOL_VERTICAL_SPACE) { this->verticalSpace = new VerticalToolHandler(this, this->page, y, zoom); } else if (h->getToolType() == TOOL_SELECT_RECT || h->getToolType() == TOOL_SELECT_REGION || h->getToolType() == TOOL_SELECT_OBJECT) { if (h->getToolType() == TOOL_SELECT_RECT) { if (this->selection) { delete this->selection; this->selection = NULL; repaintPage(); } this->selection = new RectSelection(x, y, this); } else if (h->getToolType() == TOOL_SELECT_REGION) { if (this->selection) { delete this->selection; this->selection = NULL; repaintPage(); } this->selection = new RegionSelect(x, y, this); } else if (h->getToolType() == TOOL_SELECT_OBJECT) { selectObjectAt(x, y); } } else if (h->getToolType() == TOOL_TEXT) { startText(x, y); } else if (h->getToolType() == TOOL_IMAGE) { ImageHandler imgHandler(xournal->getControl(), this); imgHandler.insertImage(x, y); } return true; }