static PyObject* python_action_button_pressed(PyObject* self, PyObject* args) {
	int arg_canvas_x;
	int arg_canvas_y;
	int arg_qtype;
	if(PyArg_ParseTuple(args, "iii", &arg_canvas_x, &arg_canvas_y, &arg_qtype) == 0) return NULL;



	action_button_pressed(arg_canvas_x, arg_canvas_y, arg_qtype);
	return Py_BuildValue("i", 0);
}
Exemple #2
0
/**************************************************************************
...
**************************************************************************/
void mapctrl_btn_mapcanvas(XEvent *event)
{
  XButtonEvent *ev=&event->xbutton;
  struct tile *ptile = canvas_pos_to_tile(ev->x, ev->y);

  if (!can_client_change_view()) {
    return;
  }

  if (ev->button == Button1 && (ev->state & ControlMask)) {
    action_button_pressed(ev->x, ev->y, SELECT_SEA);
  } else if (ev->button == Button1) {
    action_button_pressed(ev->x, ev->y, SELECT_POPUP);
  } else if (ev->button == Button2 && ptile) {
    popit(ev->x, ev->y, ptile);
  } else if (ev->button == Button3 && (ev->state & ControlMask)) {
    action_button_pressed(ev->x, ev->y, SELECT_LAND);
  } else if (ev->button == Button3) {
    recenter_button_pressed(ev->x, ev->y);
  }
}
Exemple #3
0
JNIEXPORT jboolean JNICALL Java_net_hackcasual_freeciv_NativeHarness_touchEvent
  (JNIEnv *je, jobject o, jint x, jint y, jint type) {

	struct timeval tvs, tve;
    int nif = 0;
    static int oldx = -1;
    static int oldy = -1;

    lastTouchX = x;
    lastTouchY = y;

    int deltax;
    int deltay;
	static bool cancelUp;

	struct tile *plasttile;

	switch (type) {
	case 0: {
		cancelUp = FALSE;
		oldx = x;
		oldy = y;
		plasttile = canvas_pos_to_tile(x,y);

		break;
	}
	case 1: {
		if (!cancelUp && abs(x - oldx) < 10 && abs(y - oldy) < 10) {
			can_slide = FALSE;
			LOGI("ABP Lock");
			civ_lock();
			action_button_pressed(x,y,SELECT_POPUP);
			can_slide = TRUE;
			flush_dirty();
			struct tile *ptile = canvas_pos_to_tile(x,y);
			civ_unlock();
			return (ptile && ptile->units)?unit_list_size(ptile->units):0;
		} else if (!cancelUp) {
			LOGI("Recenter Lock");
			civ_lock();
			can_slide = FALSE;
			recenter_button_pressed(x, y);
			can_slide = TRUE;
			flush_dirty();
			civ_unlock();
		}
		break;
	}
	case 2: {
		/*hover_state = HOVER_GOTO;
		control_mouse_cursor(canvas_pos_to_tile(x,y));
		update_line(x,y);
		break;*/
		if (cancelUp || abs(x - oldx) > 10 || abs(y - oldy) > 10) {
			cancelUp = TRUE;
			LOGI("Slide Lock");
			civ_lock();
			can_slide = FALSE;
			deltax = oldx - x;
			deltay = oldy - y;
			set_mapview_origin(mapview.gui_x0 + deltax, mapview.gui_y0 + deltay);
			flush_dirty();
			civ_unlock();
			oldx = x;
			oldy = y;
			can_slide = TRUE;
		}
		break;
	}
	case 3: {
		cancelUp = TRUE;
		break;
	}
	}

	return 0;
}
Exemple #4
0
/**************************************************************************
 Handle all mouse button press on canvas.
 Future feature: User-configurable mouse clicks.
**************************************************************************/
gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
{
  struct city *pcity = NULL;
  struct tile *ptile = NULL;

  if (editor_is_active()) {
    return handle_edit_mouse_button_press(ev);
  }

  if (!can_client_change_view()) {
    return TRUE;
  }

  gtk_widget_grab_focus(map_canvas);
  ptile = canvas_pos_to_tile(ev->x, ev->y);
  pcity = ptile ? tile_city(ptile) : NULL;

  switch (ev->button) {

  case 1: /* LEFT mouse button */

    /* <SHIFT> + <CONTROL> + LMB : Adjust workers. */
    if ((ev->state & GDK_SHIFT_MASK) && (ev->state & GDK_CONTROL_MASK)) {
      adjust_workers_button_pressed(ev->x, ev->y);
    }
    /* <CONTROL> + LMB : Quickselect a sea unit. */
    else if (ev->state & GDK_CONTROL_MASK) {
      action_button_pressed(ev->x, ev->y, SELECT_SEA);
    }
    /* <SHIFT> + LMB: Append focus unit. */
    else if (ptile && (ev->state & GDK_SHIFT_MASK)) {
      action_button_pressed(ev->x, ev->y, SELECT_APPEND);
    }
    /* <ALT> + LMB: popit (same as middle-click) */
    /* FIXME: we need a general mechanism for letting freeciv work with
     * 1- or 2-button mice. */
    else if (ptile && (ev->state & GDK_MOD1_MASK)) {
      popit(ev, ptile);
    }
    /* LMB in Area Selection mode. */
    else if(tiles_hilited_cities) {
      if (ptile) {
        toggle_tile_hilite(ptile);
      }
    }
    /* Plain LMB click. */
    else {
      action_button_pressed(ev->x, ev->y, SELECT_POPUP);
    }
    break;

  case 2: /* MIDDLE mouse button */

    /* <CONTROL> + MMB: Wake up sentries. */
    if (ev->state & GDK_CONTROL_MASK) {
      wakeup_button_pressed(ev->x, ev->y);
    }
    /* Plain Middle click. */
    else if (ptile) {
      popit(ev, ptile);
    }
    break;

  case 3: /* RIGHT mouse button */

    /* <CONTROL> + <ALT> + RMB : insert city or tile chat link. */
    /* <CONTROL> + <ALT> + <SHIFT> + RMB : insert unit chat link. */
    if (ptile && (ev->state & GDK_MOD1_MASK)
        && (ev->state & GDK_CONTROL_MASK)) {
      inputline_make_chat_link(ptile, (ev->state & GDK_SHIFT_MASK) != 0);
    }
    /* <SHIFT> + <ALT> + RMB : Show/hide workers. */
    else if ((ev->state & GDK_SHIFT_MASK) && (ev->state & GDK_MOD1_MASK)) {
      key_city_overlay(ev->x, ev->y);
    }
    /* <SHIFT + CONTROL> + RMB: Paste Production. */
    else if ((ev->state & GDK_SHIFT_MASK) && (ev->state & GDK_CONTROL_MASK)
             && pcity != NULL) {
      clipboard_paste_production(pcity);
      cancel_tile_hiliting();
    }
    /* <SHIFT> + RMB on city/unit: Copy Production. */
    /* If nothing to copy, fall through to rectangle selection. */
    else if (ev->state & GDK_SHIFT_MASK
             && clipboard_copy_production(ptile)) {
      /* Already done the copy */
    }
    /* <CONTROL> + RMB : Quickselect a land unit. */
    else if (ev->state & GDK_CONTROL_MASK) {
      action_button_pressed(ev->x, ev->y, SELECT_LAND);
    }
    /* Plain RMB click. Area selection. */
    else {
      /*  A foolproof user will depress button on canvas,
       *  release it on another widget, and return to canvas
       *  to find rectangle still active.
       */
      if (rectangle_active) {
        release_right_button(ev->x, ev->y,
                             (ev->state & GDK_SHIFT_MASK) != 0);
        return TRUE;
      }
      if (hover_state == HOVER_NONE) {
        anchor_selection_rectangle(ev->x, ev->y);
        rbutton_down = TRUE; /* causes rectangle updates */
      }
    }
    break;

  default:
    break;
  }


  return TRUE;
}