Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!bu.edu!dartvax!northstar5!kriso From: kriso@northstar5 (Kris Olander) Newsgroups: comp.windows.x Subject: Using XPolygonRegion for getting pointer locations Summary: Unclear on concept/usage of XPolygonRegion. Keywords: XPolygonRegion Message-ID: <23220@dartvax.Dartmouth.EDU> Date: 18 Jul 90 00:42:57 GMT Sender: news@dartvax.Dartmouth.EDU Distribution: comp Lines: 61 I'm creating a map. I'm using XFillPolygon to display the countries, and then I use XPolygonRegion to distinguish a the location of each country. I'm under the assumption that I don't have to specify an offset using XOffsetRegion if I want the drawable origin (the window that contains all the countries) to be the regions origin. After I've created all the countries and attached a 'Region' to each country, I have been trapping Button1 'down' events as a means of selecting a country. I then go through the list of countries passing each country's Region pointer into XPointInRegion to see which region the pointer is trying to access. The problem: none of my country's Regions ever match. The Nut Shell books give a whapping two pages describing Regions. Can anyone clue me in? Is this approach bogus? I'd rather not dive into the clipping algorithms for many sided polygons if X11 will do it for me. Here's some of the code: } /* end Switch */ for (i=0; incoords; i++) { xy_array[i].x = (geo->coords[i]->x - bX ) / mX; xy_array[i].y = (geo->coords[i]->y -bY ) / mY; } geo->locator = XPolygonRegion(xy_array, geo->ncoords,EvenOddRule); fprintf (stdout, "locator : %x \n", geo->locator); ------- and -------- DisplayRegion(window, button_event) Window window; XButtonEvent *button_event; { GeoRegion *geo_check; int i, x, y; x = button_event->x; y = button_event->y; fprintf (stdout, "x, y: %d, %d\n", x, y); for (geo_check = First_region; geo_check != NULL; geo_check = geo_check->next_region) { if(XPointInRegion(geo_check->locator,x, y)) break; fprintf (stdout, "region,locator: %s,%x\n", geo_check->name, geo_check->locator); } if(geo_check) fprintf (stdout, "Region: %s\n", geo_check->name); else fprintf (stdout, "FAILED FINDING LOCATION OF POINTER\n"); } ----------------------- Sorry this is so long :( ------------------- -Kris Olander # Kris Olander ---- ---- arpa: Kris.Olander@Dartmouth.Edu # # ---------------------------------------------------------- # # System Eng. Project NORTHSTAR # # Thayer School of Eng., Dartmouth College #