Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
[elinks.git] / src / util / box.h
blobdcb572745e9c3f326e989d23d9a536a6ba88fd19
1 #ifndef EL__UTIL_BOX_H
2 #define EL__UTIL_BOX_H
4 struct box {
5 int x;
6 int y;
7 int width;
8 int height;
9 };
11 static inline int
12 is_in_box(struct box *box, int x, int y)
14 return (x >= box->x && y >= box->y
15 && x < box->x + box->width
16 && y < box->y + box->height);
19 static inline int
20 row_is_in_box(struct box *box, int y)
22 return (y >= box->y && y < box->y + box->height);
25 static inline int
26 col_is_in_box(struct box *box, int x)
28 return (x >= box->x && x < box->x + box->width);
31 /* Mainly intended for use with double-width characters. */
32 static inline int
33 colspan_is_in_box(struct box *box, int x, int span)
35 return (x >= box->x && x + span <= box->x + box->width);
39 static inline void
40 set_box(struct box *box, int x, int y, int width, int height)
42 box->x = x;
43 box->y = y;
44 box->width = width;
45 box->height = height;
48 static inline void
49 copy_box(struct box *dst, struct box *src)
51 copy_struct(dst, src);
54 #define dbg_show_box(box) DBG("x=%i y=%i width=%i height=%i", (box)->x, (box)->y, (box)->width, (box)->height)
55 #define dbg_show_xy(x_, y_) DBG("x=%i y=%i", x_, y_)
58 #endif