]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/geom.h
fix the PangoLanguage thing to get from locale
[mikachu/openbox.git] / openbox / geom.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    geom.h for the Openbox window manager
4    Copyright (c) 2003        Ben Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __geom_h
20 #define __geom_h
21
22 typedef struct _Point {
23     int x;
24     int y;
25 } Point;
26
27 #define POINT_SET(pt, nx, ny) (pt).x = (nx), (pt).y = (ny)
28
29 typedef struct _Size {
30     int width;
31     int height;
32 } Size;
33
34 #define SIZE_SET(sz, w, h) (sz).width = (w), (sz).height = (h)
35
36 typedef struct _Rect {
37     int x;
38     int y;
39     int width;
40     int height;
41 } Rect;
42
43 #define RECT_LEFT(r) ((r).x)
44 #define RECT_TOP(r) ((r).y)
45 #define RECT_RIGHT(r) ((r).x + (r).width - 1)
46 #define RECT_BOTTOM(r) ((r).y + (r).height - 1)
47
48 #define RECT_SET_POINT(r, nx, ny) \
49     (r).x = (nx), (r).y = (ny)
50 #define RECT_SET_SIZE(r, w, h) \
51     (r).width = (w), (r).height = (h)
52 #define RECT_SET(r, nx, ny, w, h) \
53     (r).x = (nx), (r).y = (ny), (r).width = (w), (r).height = (h)
54
55 #define RECT_EQUAL(r1, r2) ((r1).x == (r2).x && (r1).y == (r2).y && \
56                             (r1).width == (r2).width && \
57                             (r1).height == (r2).height)
58
59 #define RECT_CONTAINS(r, px, py) \
60     ((px) >= (r).x && (px) < (r).x + (r).width && \
61      (py) >= (r).y && (py) < (r).y + (r).height)
62 #define RECT_CONTAINS_RECT(r, o) \
63     ((o).x >= (r).x && (o).x + (o).width <= (r).x + (r).width && \
64      (o).y >= (r).y && (o).y + (o).height <= (r).y + (r).height)
65
66 /* Returns true if Rect r and o intersect */
67 #define RECT_INTERSECTS_RECT(r, o) \
68     ((o).x < (r).x + (r).width && (o).x + (o).width > (r).x && \
69      (o).y < (r).y + (r).height && (o).y + (o).height > (r).y)
70
71 /* Sets Rect r to be the intersection of Rect a and b. */
72 #define RECT_SET_INTERSECTION(r, a, b) \
73     ((r).x = MAX((a).x, (b).x), \
74      (r).y = MAX((a).y, (b).y), \
75      (r).width = MIN((a).x + (a).width - 1, \
76                      (b).x + (b).width - 1) - (r).x + 1, \
77      (r).height = MIN((a).y + (a).height - 1, \
78                       (b).y + (b).height - 1) - (r).y + 1)
79
80 typedef struct _Strut {
81     int left;
82     int top;
83     int right;
84     int bottom;
85 } Strut;
86
87 typedef struct _StrutPartial {
88     int left;
89     int top;
90     int right;
91     int bottom;
92
93     int left_start,   left_end;
94     int top_start,    top_end;
95     int right_start,  right_end;
96     int bottom_start, bottom_end;
97 } StrutPartial;
98
99 #define STRUT_SET(s, l, t, r, b) \
100     (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b)
101
102 #define STRUT_PARTIAL_SET(s, l, t, r, b, ls, le, ts, te, rs, re, bs, be) \
103     (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b), \
104     (s).left_start = (ls), (s).left_end = (le), \
105     (s).top_start = (ts), (s).top_end = (te), \
106     (s).right_start = (rs), (s).right_end = (re), \
107     (s).bottom_start = (bs), (s).bottom_end = (be)
108
109 #define STRUT_ADD(s1, s2) \
110     (s1).left = MAX((s1).left, (s2).left), \
111     (s1).right = MAX((s1).right, (s2).right), \
112     (s1).top = MAX((s1).top, (s2).top), \
113     (s1).bottom = MAX((s1).bottom, (s2).bottom)
114
115 #define STRUT_EQUAL(s1, s2) \
116     ((s1).left == (s2).left && \
117      (s1).top == (s2).top && \
118      (s1).right == (s2).right && \
119      (s1).bottom == (s2).bottom)
120
121 #define PARTIAL_STRUT_EQUAL(s1, s2) \
122     ((s1).left == (s2).left && \
123      (s1).top == (s2).top && \
124      (s1).right == (s2).right && \
125      (s1).bottom == (s2).bottom && \
126      (s1).left_start == (s2).left_start && \
127      (s1).left_end == (s2).left_end && \
128      (s1).top_start == (s2).top_start && \
129      (s1).top_end == (s2).top_end && \
130      (s1).right_start == (s2).right_start && \
131      (s1).right_end == (s2).right_end && \
132      (s1).bottom_start == (s2).bottom_start && \
133      (s1).bottom_end == (s2).bottom_end)
134
135 #endif