2005-11-18 17:54:58 +02:00
|
|
|
/*
|
2006-01-20 16:20:24 +02:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 17:54:58 +02:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
2006-06-12 13:20:30 +02:00
|
|
|
#include "wm.h"
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-04-23 20:00:47 +02:00
|
|
|
BlitzAlign
|
2006-06-12 13:20:30 +02:00
|
|
|
quadofcoord(XRectangle *rect, int x, int y)
|
2006-04-12 10:44:07 +02:00
|
|
|
{
|
2006-06-01 19:56:42 -04:00
|
|
|
BlitzAlign ret = 0;
|
|
|
|
x -= rect->x;
|
|
|
|
y -= rect->y;
|
|
|
|
|
|
|
|
if(x >= rect->width * .5)
|
2006-06-02 13:40:59 -04:00
|
|
|
ret |= EAST;
|
|
|
|
if(x <= rect->width * .5)
|
2006-06-01 19:56:42 -04:00
|
|
|
ret |= WEST;
|
|
|
|
if(y <= rect->height * .5)
|
|
|
|
ret |= NORTH;
|
|
|
|
if(y >= rect->height * .5)
|
|
|
|
ret |= SOUTH;
|
|
|
|
|
|
|
|
return ret;
|
2006-04-12 10:44:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-12 13:20:30 +02:00
|
|
|
Bool
|
|
|
|
ispointinrect(int x, int y, XRectangle * r)
|
2005-11-18 17:54:58 +02:00
|
|
|
{
|
2006-05-26 14:16:19 +02:00
|
|
|
return (x >= r->x) && (x <= r->x + r->width)
|
|
|
|
&& (y >= r->y) && (y <= r->y + r->height);
|
2005-11-18 17:54:58 +02:00
|
|
|
}
|
|
|
|
|
2006-05-26 14:16:19 +02:00
|
|
|
/* Syntax: <x> <y> <width> <height> */
|
2006-06-12 13:20:30 +02:00
|
|
|
int
|
|
|
|
strtorect(XRectangle *r, const char *val)
|
2006-05-26 14:16:19 +02:00
|
|
|
{
|
|
|
|
XRectangle new;
|
2005-11-18 17:54:58 +02:00
|
|
|
if (!val)
|
2006-01-04 17:23:09 +02:00
|
|
|
return -1;
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-05-26 14:16:19 +02:00
|
|
|
if(sscanf(val, "%hd %hd %hu %hu", &new.x, &new.y, &new.width, &new.height) != 4)
|
|
|
|
return -1;
|
2005-12-21 15:48:01 +02:00
|
|
|
|
2006-05-26 14:16:19 +02:00
|
|
|
*r = new;
|
2006-01-04 17:23:09 +02:00
|
|
|
return 0;
|
2005-11-18 17:54:58 +02:00
|
|
|
}
|