本文整理汇总了C++中PageView::translateEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ PageView::translateEvent方法的具体用法?C++ PageView::translateEvent怎么用?C++ PageView::translateEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageView
的用法示例。
在下文中一共展示了PageView::translateEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_xournal_motion_notify_event
gboolean gtk_xournal_motion_notify_event(GtkWidget * widget, GdkEventMotion * event) {
#ifdef INPUT_DEBUG
bool is_core = (event->device == gdk_device_get_core_pointer());
INPUTDBG("MotionNotify (%s) (x,y)=(%.2f,%.2f), modifier %x", is_core ? "core" : "xinput", event->x, event->y, event->state);
#endif
XInputUtils::fixXInputCoords((GdkEvent*) event, widget);
GtkXournal * xournal = GTK_XOURNAL(widget);
ToolHandler * h = xournal->view->getControl()->getToolHandler();
if (h->getToolType() == TOOL_HAND) {
if (xournal->inScrolling) {
gtk_xournal_scroll_mouse_event(xournal, event);
return true;
}
return false;
} else if (xournal->selection) {
EditSelection * selection = xournal->selection;
PageView * view = selection->getView();
GdkEventMotion ev = *event;
view->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
if (xournal->selection->isMoving()) {
selection->mouseMove(ev.x, ev.y);
} else {
CursorSelectionType selType = selection->getSelectionTypeForPos(ev.x, ev.y, xournal->view->getZoom());
xournal->view->getCursor()->setMouseSelectionType(selType);
}
return true;
}
PageView * pv = gtk_xournal_get_page_view_for_pos_cached(xournal, event->x, event->y);
xournal->view->getCursor()->setInsidePage(pv != NULL);
if (pv) {
// allow events only to a single page!
if (xournal->currentInputPage == NULL || pv == xournal->currentInputPage) {
pv->translateEvent((GdkEvent*) event, xournal->x, xournal->y);
return pv->onMotionNotifyEvent(widget, event);;
}
}
return false;
}
示例2: gtk_xournal_button_press_event
gboolean gtk_xournal_button_press_event(GtkWidget* widget,
GdkEventButton* event)
{
/**
* true: Core event, false: XInput event
*/
gboolean isCore = (event->device == gdk_device_get_core_pointer());
INPUTDBG("ButtonPress (%s) (x,y)=(%.2f,%.2f), button %d, modifier %x, isCore %i",
gdk_device_get_name(event->device), event->x, event->y,
event->button, event->state, isCore);
GtkXournal* xournal = GTK_XOURNAL(widget);
Settings* settings = xournal->view->getControl()->getSettings();
if(isCore && settings->isXinputEnabled() && settings->isIgnoreCoreEvents())
{
INPUTDBG2("gtk_xournal_button_press_event return false (ignore core)");
return false;
}
XInputUtils::fixXInputCoords((GdkEvent*) event, widget);
if (event->type != GDK_BUTTON_PRESS)
{
INPUTDBG2("gtk_xournal_button_press_event return false (event->type != GDK_BUTTON_PRESS)");
return false; // this event is not handled here
}
if (event->button > 3) // scroll wheel events
{
XInputUtils::handleScrollEvent(event, widget);
INPUTDBG2("gtk_xournal_button_press_event return true handled scroll event");
return true;
}
gtk_widget_grab_focus(widget);
// none button release event was sent, send one now
if (xournal->currentInputPage)
{
INPUTDBG2("gtk_xournal_button_press_event (xournal->currentInputPage != NULL)");
GdkEventButton ev = *event;
xournal->currentInputPage->translateEvent((GdkEvent*) &ev, xournal->x,
xournal->y);
xournal->currentInputPage->onButtonReleaseEvent(widget, &ev);
}
ToolHandler* h = xournal->view->getControl()->getToolHandler();
// Change the tool depending on the key or device
if(change_tool(settings, event, xournal))
return true;
// hand tool don't change the selection, so you can scroll e.g.
// with your touchscreen without remove the selection
if (h->getToolType() == TOOL_HAND)
{
Cursor* cursor = xournal->view->getCursor();
cursor->setMouseDown(true);
xournal->lastMousePositionX = 0;
xournal->lastMousePositionY = 0;
xournal->inScrolling = true;
gtk_widget_get_pointer(widget, &xournal->lastMousePositionX,
&xournal->lastMousePositionY);
INPUTDBG2("gtk_xournal_button_press_event (h->getToolType() == TOOL_HAND) return true");
return true;
}
else if (xournal->selection)
{
EditSelection* selection = xournal->selection;
PageView* view = selection->getView();
GdkEventButton ev = *event;
view->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
CursorSelectionType selType = selection->getSelectionTypeForPos(ev.x, ev.y,
xournal->view->getZoom());
if (selType)
{
if(selType == CURSOR_SELECTION_MOVE && event->button == 3)
{
selection->copySelection();
}
xournal->view->getCursor()->setMouseDown(true);
xournal->selection->mouseDown(selType, ev.x, ev.y);
INPUTDBG2("gtk_xournal_button_press_event (selection) return true");
return true;
}
else
{
xournal->view->clearSelection();
if(change_tool(settings, event, xournal))
return true;
}
}
//.........这里部分代码省略.........
示例3: gtk_xournal_button_press_event
gboolean gtk_xournal_button_press_event(GtkWidget * widget, GdkEventButton * event) {
/**
* true: Core event, false: XInput event
*/
gboolean isCore = (event->device == gdk_device_get_core_pointer());
INPUTDBG("ButtonPress (%s) (x,y)=(%.2f,%.2f), button %d, modifier %x, isCore %i", gdk_device_get_name(event->device), event->x, event->y,
event->button, event->state, isCore);
GtkXournal * xournal = GTK_XOURNAL(widget);
Settings * settings = xournal->view->getControl()->getSettings();
if(isCore && settings->isXinputEnabled() && settings->isIgnoreCoreEvents()) {
INPUTDBG2("gtk_xournal_button_press_event return false (ignore core)");
return false;
}
XInputUtils::fixXInputCoords((GdkEvent*) event, widget);
if (event->type != GDK_BUTTON_PRESS) {
INPUTDBG2("gtk_xournal_button_press_event return false (event->type != GDK_BUTTON_PRESS)");
return false; // this event is not handled here
}
if (event->button > 3) { // scroll wheel events
XInputUtils::handleScrollEvent(event, widget);
INPUTDBG2("gtk_xournal_button_press_event return true handled scroll event");
return true;
}
gtk_widget_grab_focus(widget);
ToolHandler * h = xournal->view->getControl()->getToolHandler();
// none button release event was sent, send one now
if (xournal->currentInputPage) {
INPUTDBG2("gtk_xournal_button_press_event (xournal->currentInputPage != NULL)");
GdkEventButton ev = *event;
xournal->currentInputPage->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
xournal->currentInputPage->onButtonReleaseEvent(widget, &ev);
}
// Change the tool depending on the key or device
ButtonConfig * cfg = NULL;
ButtonConfig * cfgTouch = settings->getTouchButtonConfig();
if (event->button == 2) { // Middle Button
cfg = settings->getMiddleButtonConfig();
} else if (event->button == 3) { // Right Button
cfg = settings->getRightButtonConfig();
} else if (event->device->source == GDK_SOURCE_ERASER) {
cfg = settings->getEraserButtonConfig();
} else if (cfgTouch->device == event->device->name) {
cfg = cfgTouch;
// If an action is defined we do it, even if it's a drawing action...
if (cfg->getDisableDrawing() && cfg->getAction() == TOOL_NONE) {
ToolType tool = h->getToolType();
if (tool == TOOL_PEN || tool == TOOL_ERASER || tool == TOOL_HILIGHTER) {
printf("ignore touchscreen for drawing!\n");
return true;
}
}
}
if (cfg && cfg->getAction() != TOOL_NONE) {
h->copyCurrentConfig();
cfg->acceptActions(h);
}
// hand tool don't change the selection, so you can scroll e.g.
// with your touchscreen without remove the selection
if (h->getToolType() == TOOL_HAND) {
Cursor * cursor = xournal->view->getCursor();
cursor->setMouseDown(true);
xournal->lastMousePositionX = 0;
xournal->lastMousePositionY = 0;
xournal->inScrolling = true;
gtk_widget_get_pointer(widget, &xournal->lastMousePositionX, &xournal->lastMousePositionY);
INPUTDBG2("gtk_xournal_button_press_event (h->getToolType() == TOOL_HAND) return true");
return true;
} else if (xournal->selection) {
EditSelection * selection = xournal->selection;
PageView * view = selection->getView();
GdkEventButton ev = *event;
view->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
CursorSelectionType selType = selection->getSelectionTypeForPos(ev.x, ev.y, xournal->view->getZoom());
if (selType) {
xournal->view->getCursor()->setMouseDown(true);
xournal->selection->mouseDown(selType, ev.x, ev.y);
INPUTDBG2("gtk_xournal_button_press_event (selection) return true");
return true;
} else {
xournal->view->clearSelection();
}
}
PageView * pv = gtk_xournal_get_page_view_for_pos_cached(xournal, event->x, event->y);
//.........这里部分代码省略.........