Retry only for https protocol
[elinks.git] / src / util / box.h
blobb155dd2bda6a2e3cedb9c55994b16ba2988b19ff
1 #ifndef EL__UTIL_BOX_H
2 #define EL__UTIL_BOX_H
4 /** A rectangular part of a drawing surface, such as the screen. */
5 struct box {
6 int x;
7 int y;
8 int width;
9 int height;
12 /** @relates box */
13 static inline int
14 is_in_box(struct box *box, int x, int y)
16 return (x >= box->x && y >= box->y
17 && x < box->x + box->width
18 && y < box->y + box->height);
21 /** @relates box */
22 static inline int
23 row_is_in_box(struct box *box, int y)
25 return (y >= box->y && y < box->y + box->height);
28 /** @relates box */
29 static inline int
30 col_is_in_box(struct box *box, int x)
32 return (x >= box->x && x < box->x + box->width);
35 /** Check whether a span of columns is in @a box.
36 * Mainly intended for use with double-width characters.
37 * @relates box */
38 static inline int
39 colspan_is_in_box(struct box *box, int x, int span)
41 return (x >= box->x && x + span <= box->x + box->width);
45 /** @relates box */
46 static inline void
47 set_box(struct box *box, int x, int y, int width, int height)
49 box->x = int_max(0, x);
50 box->y = int_max(0, y);
51 box->width = int_max(0, width);
52 box->height = int_max(0, height);
55 /** @relates box */
56 static inline void
57 copy_box(struct box *dst, struct box *src)
59 copy_struct(dst, src);
62 #define dbg_show_box(box) DBG("x=%i y=%i width=%i height=%i", (box)->x, (box)->y, (box)->width, (box)->height)
63 #define dbg_show_xy(x_, y_) DBG("x=%i y=%i", x_, y_)
66 #endif