Beispiel #1
0
void
navit_vehicle_add(struct navit *this_, struct vehicle *v, struct color *c, int update, int follow)
{
	this_->vehicle=v;
	this_->update_curr=this_->update=update;
	this_->follow_curr=this_->follow=follow;
	this_->cursor=cursor_new(this_->gra, v, c, this_->trans);
	cursor_register_offscreen_callback(this_->cursor, navit_cursor_offscreen, this_);
	cursor_register_update_callback(this_->cursor, navit_cursor_update, this_);
}
Beispiel #2
0
struct navit_vehicle *
navit_add_vehicle(struct navit *this_, struct vehicle *v, const char *name, struct color *c, int update, int follow)
{
	struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
	nv->vehicle=v;
	nv->name=g_strdup(name);
	nv->update_curr=nv->update=update;
	nv->follow_curr=nv->follow=follow;
	nv->cursor=cursor_new(this_->gra, v, c, this_->trans);
	nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_);
	cursor_add_callback(nv->cursor, nv->update_cb);

	this_->vehicles=g_list_append(this_->vehicles, nv);
	return nv;
}
Beispiel #3
0
/* This is the 'high level' hotspot function that will usually be called
 * by the widget code.
 *
 * It rebuilds the hotspot graph from the current divtree if necessary, finds
 * the hotspot closest to the mouse pointer, traverses the hotspot graph in
 * the indicated direction, and finds the new mouse pointer position.
 *
 * The direction is a HOTSPOT_* constant
 */
void hotspot_traverse(short direction) {
  struct hotspot *p;
  int x,y;
  struct divtree *dt;

  /* rebuild the graph */
  if (!hotspotlist) {
    hotspot_build(dts->top->head,NULL);
    if (popup_toolbar_passthrough())
      hotspot_build(dts->root->head,appmgr_nontoolbar_area());
    hotspot_graph();
  }

  /* Create the hotspotnav cursor if it doesn't exist */
  if (!dts->top->hotspot_cursor)
    if (iserror(cursor_new(&dts->top->hotspot_cursor,NULL,-1)))
      return;

  /* Find the current node 
   */
  cursor_getposition(dts->top->hotspot_cursor,&x,&y,&dt);
  p = hotspot_closest(x,y);

  if (!p)
    return;

  /* If the closest node isn't really that close, just warp to
   * that closest node. Otherwise, traverse. 
   *
   * NOTE: We used to test whether the hotspot cursor was within
   * the same divnode as the hotspot, but now that the hotspot cursor
   * is separate from all driver-controlled cursors we can do an
   * exact match.
   */
  if (x==p->x && y==p->y) {
    /* traverse */
    p = p->graph[direction];
    if (!p)
      return;
  }

  /* Make sure the divnode is scrolled in and focused now */
  if (p->div)
    request_focus(p->div->owner);

  /* Warp the hotspot cursor to the new hotspot location */
  cursor_move(dts->top->hotspot_cursor,p->x,p->y,dt);
}
Beispiel #4
0
CTEST(cursor, empty)
{
	int ret;
	struct options *opts;
	struct status *status;
	struct cache *cache;
	struct tree *tree;

	/* create */
	opts = options_new();
	status = status_new();
	cache = dbcache_new(opts);
	tree = tree_new(DBPATH0, opts, status, cache, 1);


	/* cursor */
	struct cursor *cur;

	cur = cursor_new(tree);

	/* first */
	tree_cursor_first(cur);
	ret = tree_cursor_valid(cur);
	ASSERT_EQUAL(0, ret);

	/* last */
	tree_cursor_last(cur);
	ret = tree_cursor_valid(cur);
	ASSERT_EQUAL(0, ret);

	/* next */
	tree_cursor_next(cur);
	ret = tree_cursor_valid(cur);
	ASSERT_EQUAL(0, ret);

	cursor_free(cur);

	/* free */
	dbcache_free(cache);
	tree_free(tree);
	options_free(opts);
	status_free(status);
	xcheck_all_free();
}
Beispiel #5
0
int main(int argc, char **argv)
{
#if 0
        CORBA_Environment ev;
        CORBA_ORB orb;
	Map map_client = CORBA_OBJECT_NIL;
#endif
	char *gps;

	setenv("LC_NUMERIC","C",1);
	setlocale(LC_ALL,"");
	setlocale(LC_NUMERIC,"C");
	gtk_set_locale();
	setlocale(LC_NUMERIC,"C");
	debug_init();
	gtk_init(&argc, &argv);
	gdk_rgb_init();

// 	i18n basic support

	bindtextdomain( "navit", "./locale" );
	textdomain( "navit" );

	map_data_default=load_maps(NULL);
	plugin_load();
	co=gui_gtk_window(1300000,7000000,32);
	
	co->route=route_new();
	route_mapdata_set(co->route, co->map_data); 
	gps=getenv("GPSDATA");
	if (gps) {
		co->vehicle=vehicle_new(gps);
		if (co->vehicle) {
			co->cursor=cursor_new(co,co->vehicle);
			sdl_gui_new(co->vehicle);
		}
	} else {
		g_warning(gettext("Environment-Variable GPSDATA not set - No gps tracking. Set it to file:filename or gpsd://host[:port]"));
	}
	co->speech=speech_new();
	if (! co->speech) 
		g_warning(gettext("Can't connect to speechd, no speech output available"));
	speech_handle=co->speech;
	if (co->vehicle)
		co->compass=compass_new(co);
	if (co->vehicle)
		co->track=track_new(co->map_data);


#if 0
        CORBA_exception_init(&ev);
        orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);

        map_srv_start_poa(orb, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
        map_client = map_srv_start_object(&ev, map);
        retval = CORBA_ORB_object_to_string(orb, map_client, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
	ior=fopen("map.ior","w");
	if (ior) {
  		fprintf(ior, "%s\n", retval);
		fclose(ior);
	}
        CORBA_free(retval);
#endif

	initSDL();
	gtk_main();
	return 0;
}
Beispiel #6
0
g_error sdlinput_init(void) {
  g_error e;

  if (get_param_int("input-sdlinput","pgcursor",1)) {
    e = cursor_new(&sdlinput_cursor,NULL,-1);
    errorcheck;
  }

  sdlinput_foldbuttons = get_param_int("input-sdlinput","foldbuttons",0);
  sdlinput_upmove = get_param_int("input-sdlinput","upmove",1);
  sdlinput_nomouse = get_param_int("input-sdlinput","nomouse",0);
  sdlinput_nokeyboard = get_param_int("input-sdlinput","nokeyboard",0);
  sdlinput_scroll_distance = get_param_int("input-sdlinput","scroll_distance",20);
  SDL_ShowCursor(get_param_int("input-sdlinput","sdlcursor",0));

#ifdef CONFIG_SDLSKIN
  /* Load keyboard map */
  if (sdlinput_map)
    g_free(sdlinput_map);
  sdlinput_mapsize = 0;

  {
    const char *fname = get_param_str("input-sdlinput","map",NULL);
    FILE *f;
    char linebuf[80];
    int i;
    g_error e;
    char *p;
    int mapscale_n,mapscale_d;
     
    sscanf(get_param_str("input-sdlinput","mapscale","1 1"), "%d %d",
	   &mapscale_n, &mapscale_d);
     
    if (fname && (f = fopen(fname,"r"))) {

      /* Count the number of rectangles */
      i = 0;
      while (fgets(linebuf,79,f))
	if (!strncmp(linebuf,"<AREA",5))
	  i++;

      /* Allocate map */
      sdlinput_mapsize = i;
      e = g_malloc((void**)&sdlinput_map,i * sizeof(struct sdlinput_rect));
      errorcheck;
      
      /* Really stupid parser thingy */
      rewind(f);
      i = 0;
      while (fgets(linebuf,79,f) && i<sdlinput_mapsize)
	if (!strncmp(linebuf,"<AREA",5)) {
	  p = strstr(linebuf,"COORDS=")+8;
	  sdlinput_map[i].x1 = atoi(p) * mapscale_n / mapscale_d;
	  p = strchr(p,',')+1;
	  sdlinput_map[i].y1 = atoi(p) * mapscale_n / mapscale_d;
	  p = strchr(p,',')+1;
	  sdlinput_map[i].x2 = atoi(p) * mapscale_n / mapscale_d;
	  p = strchr(p,',')+1;
	  sdlinput_map[i].y2 = atoi(p) * mapscale_n / mapscale_d;
	  p = strstr(p,"HREF=")+6;
	  sdlinput_map[i].key = atoi(p);
	  i++;
	}
    }
  }
#endif

  SDL_EnableUNICODE(1);
  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
  return success;
}
Beispiel #7
0
void infilter_pntr_normalize_handler(struct infilter *self, u32 trigger, union trigparam *param) {
  int x,y, oldbtn, newbtn;
  static struct cursor *cursor_global_invisible;

  /* If we have pointer events with no cursor, assign them our invisible global
   * cursor so that it can collect context information that we'll need for dispatch.
   */
  if (!param->mouse.cursor) {
    if (!cursor_global_invisible) {
      if (iserror(cursor_new(&cursor_global_invisible,NULL,-1)))
	return;
      cursor_global_invisible->sprite->visible = 0;
    }
    param->mouse.cursor = cursor_global_invisible;
  }

  if (trigger != PG_TRIGGER_SCROLLWHEEL) {
    
    /* Get physical cursor position for use later */
    cursor_getposition(param->mouse.cursor, &x, &y,NULL);
    if (!param->mouse.is_logical) {
      /* Normal rotation handling */
      VID(coord_physicalize)(&x,&y);
    }
    
    /* Convert relative motion to absolute motion.
     * We have to be careful about which coordinate system the input is in.
     */
    if (trigger==PG_TRIGGER_PNTR_RELATIVE) {
      trigger = PG_TRIGGER_PNTR_STATUS;
      param->mouse.x += x;
      param->mouse.y += y;
      if (param->mouse.is_logical)
	VID(coord_physicalize)(&x,&y);
      param->mouse.is_logical = 0;
    }
    
    /* Convert absolute motion to individual events
     */
    if (trigger==PG_TRIGGER_PNTR_STATUS) {
      /* Save the old/new button state too, since it may be modified by other
       * input filters when we do infilter_send. Remember that this is all working
       * with the same trigparam structure, and just repassing it after changing
       * the type :)
       */
      newbtn = param->mouse.btn;
      oldbtn = param->mouse.cursor->prev_buttons;
      
      if (newbtn & ~oldbtn)
	trigger = PG_TRIGGER_DOWN;
      else if (oldbtn & ~newbtn)
	trigger = PG_TRIGGER_UP;
      else
	trigger = PG_TRIGGER_MOVE;
    }
    
    /* If we're moving the cursor and this isn't a MOVE event, generate one
     */
    if ((param->mouse.x != x || param->mouse.y != y) && trigger!=PG_TRIGGER_MOVE) {
      union trigparam moveparam = *param;
      moveparam.mouse.btn = param->mouse.cursor->prev_buttons;
      infilter_send(self,PG_TRIGGER_MOVE,&moveparam);
    }
  }    

  /* Detect changes in buttons, and store that along with the event
   */
  param->mouse.chbtn = param->mouse.btn ^ param->mouse.cursor->prev_buttons;
  param->mouse.cursor->prev_buttons = param->mouse.btn;

  /* Resend it (we might have changed the trigger type) */
  infilter_send(self,trigger,param);
}