]> git.lyx.org Git - lyx.git/blob - src/box.h
fix to checkInsetHit() from John
[lyx.git] / src / box.h
1 /**
2  * \file box.h
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #ifndef BOX_H
10 #define BOX_H
11
12 #include <config.h>
13  
14 #include "debug.h" 
15  
16 /**
17  * A simple class representing rectangular regions.
18  * It is expected that the box be constructed in
19  * normalised form, that is to say : x1,y1 is top-left,
20  * x2,y2 is bottom-right.
21  */
22 struct Box {
23         unsigned int x1;
24         unsigned int x2;
25         unsigned int y1;
26         unsigned int y2;
27
28         Box(unsigned int x1_, unsigned int x2_,
29                 unsigned int y1_, unsigned int y2_) :
30                 x1(x1_), x2(x2_), y1(y1_), y2(y2_) {}
31
32         /**
33          * Returns true if the given co-ordinates are within
34          * the box. Check is exclusive (point on a border
35          * returns false).
36          */
37         bool contained(unsigned int x, unsigned int y) {
38                 return (x1 < x && x2 > x &&
39                         y1 < y && y2 > y);
40         }
41 };
42  
43 #endif // BOX_H