-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIUtility.h
70 lines (51 loc) · 1.38 KB
/
GUIUtility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef GUIUTILITY_H
#define GUIUTILITY_H
#include <string>
#include "stdint.h"
namespace GUI {
// a simple class for error exceptions - msg points to a C-string error message
struct Error {
Error(std::string in_msg) : msg(in_msg) { }
std::string msg;
};
// an exception class for handling Errors not caused by the User. Probably should not output these in a release.
struct GUIProgramming_Error {
GUIProgramming_Error(std::string in_msg) : msg(in_msg) { }
std::string msg;
};
//template <typename In, typename Out, typename Pred>
//Out copy_if(In first, In last, Out res, Pred p) {
//
// while (first != last) {
// if (p(*first)) {
// *res++ = *first;
// }
// ++first;
// }
// return res;
//}
//
//inline double square (double x){
// return x*x;
//}
class Coord;
struct DispPoint {
DispPoint() : x(0), y(0) { }
DispPoint(int x_, int y_) : x(x_), y(y_) { }
bool operator== (DispPoint b) {
return (x == b.x && y == b.y);
}
DispPoint operator+ (DispPoint b) {
return DispPoint (x + b.x, y + b.y);
}
DispPoint operator- (DispPoint b) {
return DispPoint (x - b.x, y - b.y);
}
DispPoint(const Coord& coord);
int x,y;
};
void initSDL(unsigned int flags);
// initializes the SDL with the given flags. Returns -1 if fails and prints error. 0 otherwise.
// also sets SDL to close at exit.
} // namespace GUI
#endif /* GUIUTILITY_H */