annotate window/event.h @ 1:b753afeb3f34

Does build under debian testing
author thib
date Fri, 01 Aug 2008 16:34:21 +0000
parents 223b71206888
children 5ae5533b3a9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 #ifndef __EVENT__
223b71206888 Initial import
thib
parents:
diff changeset
2 #define __EVENT__
223b71206888 Initial import
thib
parents:
diff changeset
3
223b71206888 Initial import
thib
parents:
diff changeset
4 #include"rect.h"
223b71206888 Initial import
thib
parents:
diff changeset
5 #include"SDL.h"
223b71206888 Initial import
thib
parents:
diff changeset
6
223b71206888 Initial import
thib
parents:
diff changeset
7 namespace Event {
223b71206888 Initial import
thib
parents:
diff changeset
8
223b71206888 Initial import
thib
parents:
diff changeset
9 class Video;
223b71206888 Initial import
thib
parents:
diff changeset
10 class Time;
223b71206888 Initial import
thib
parents:
diff changeset
11 class Container;
223b71206888 Initial import
thib
parents:
diff changeset
12
223b71206888 Initial import
thib
parents:
diff changeset
13 /*
223b71206888 Initial import
thib
parents:
diff changeset
14 ** マウスの press, ドラッグ、in/out を検出できる
223b71206888 Initial import
thib
parents:
diff changeset
15 ** focus がある時の left/right/space(==press) のキーを判別できる
223b71206888 Initial import
thib
parents:
diff changeset
16 */
223b71206888 Initial import
thib
parents:
diff changeset
17 struct Video {
223b71206888 Initial import
thib
parents:
diff changeset
18 virtual void Press(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
19 virtual void Release(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
20 virtual void Drag(int x_from, int y_from, int x_to, int y_to) {}
223b71206888 Initial import
thib
parents:
diff changeset
21 virtual void Motion(int x, int y) {}
223b71206888 Initial import
thib
parents:
diff changeset
22 virtual void In(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
23 virtual void Out(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
24 virtual void KeyLeft(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
25 virtual void KeyRight(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
26
223b71206888 Initial import
thib
parents:
diff changeset
27 int point_in(int x, int y); /* z or -1 を返す。大きいほど高いところにある */
223b71206888 Initial import
thib
parents:
diff changeset
28
223b71206888 Initial import
thib
parents:
diff changeset
29 Video(Container& container);
223b71206888 Initial import
thib
parents:
diff changeset
30 Video(Container& container, const Rect& init_rect);
223b71206888 Initial import
thib
parents:
diff changeset
31 Video(Container& container, const Rect& init_rect, int z);
223b71206888 Initial import
thib
parents:
diff changeset
32 void SetRegion(const Rect& new_rect);
223b71206888 Initial import
thib
parents:
diff changeset
33 void SetZ(int new_z);
223b71206888 Initial import
thib
parents:
diff changeset
34 void activate(void);
223b71206888 Initial import
thib
parents:
diff changeset
35 void deactivate(void);
223b71206888 Initial import
thib
parents:
diff changeset
36 virtual ~Video();
223b71206888 Initial import
thib
parents:
diff changeset
37
223b71206888 Initial import
thib
parents:
diff changeset
38 Rect Region(void) const { return region;}
223b71206888 Initial import
thib
parents:
diff changeset
39 private:
223b71206888 Initial import
thib
parents:
diff changeset
40 Rect region;
223b71206888 Initial import
thib
parents:
diff changeset
41 int z;
223b71206888 Initial import
thib
parents:
diff changeset
42 Container& parent;
223b71206888 Initial import
thib
parents:
diff changeset
43 bool activated;
223b71206888 Initial import
thib
parents:
diff changeset
44 friend bool operator <(const Video& position1, const Video& position2);
223b71206888 Initial import
thib
parents:
diff changeset
45 };
223b71206888 Initial import
thib
parents:
diff changeset
46
223b71206888 Initial import
thib
parents:
diff changeset
47 struct Time {
223b71206888 Initial import
thib
parents:
diff changeset
48 enum { NEVER_WAKE = 0xffffffff, FRAME_UPDATE = 0xfffffffe};
223b71206888 Initial import
thib
parents:
diff changeset
49 virtual void Elapsed(unsigned int current_time) {wakeup_time = NEVER_WAKE; }; /* next: never elapsed */
223b71206888 Initial import
thib
parents:
diff changeset
50 void SetWakeup(unsigned int new_wakeup_time) { wakeup_time = new_wakeup_time; }
223b71206888 Initial import
thib
parents:
diff changeset
51 unsigned Wakeup(void) const { return wakeup_time; }
223b71206888 Initial import
thib
parents:
diff changeset
52
223b71206888 Initial import
thib
parents:
diff changeset
53 Time(Container& container);
223b71206888 Initial import
thib
parents:
diff changeset
54 ~Time();
223b71206888 Initial import
thib
parents:
diff changeset
55 private:
223b71206888 Initial import
thib
parents:
diff changeset
56 unsigned int wakeup_time;
223b71206888 Initial import
thib
parents:
diff changeset
57 Container& parent;
223b71206888 Initial import
thib
parents:
diff changeset
58 };
223b71206888 Initial import
thib
parents:
diff changeset
59
223b71206888 Initial import
thib
parents:
diff changeset
60 struct Container {
223b71206888 Initial import
thib
parents:
diff changeset
61 #define MOUSE_LEFT 0
223b71206888 Initial import
thib
parents:
diff changeset
62 #define MOUSE_MIDDLE 1
223b71206888 Initial import
thib
parents:
diff changeset
63 #define MOUSE_RIGHT 2
223b71206888 Initial import
thib
parents:
diff changeset
64 #define MOUSE_UP 3
223b71206888 Initial import
thib
parents:
diff changeset
65 #define MOUSE_DOWN 4
223b71206888 Initial import
thib
parents:
diff changeset
66 #define KEY_SHIFT 10
223b71206888 Initial import
thib
parents:
diff changeset
67 #define BUTTON_MAX 32
223b71206888 Initial import
thib
parents:
diff changeset
68 int button_pressed;
223b71206888 Initial import
thib
parents:
diff changeset
69 int button_presscount[BUTTON_MAX];
223b71206888 Initial import
thib
parents:
diff changeset
70 int current_time;
223b71206888 Initial import
thib
parents:
diff changeset
71
223b71206888 Initial import
thib
parents:
diff changeset
72 void MousePos(int& x, int& y);
223b71206888 Initial import
thib
parents:
diff changeset
73 bool Exec(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
74
223b71206888 Initial import
thib
parents:
diff changeset
75 void Add(Video* item);
223b71206888 Initial import
thib
parents:
diff changeset
76 void Delete(Video* item);
223b71206888 Initial import
thib
parents:
diff changeset
77
223b71206888 Initial import
thib
parents:
diff changeset
78 void Add(Time* item);
223b71206888 Initial import
thib
parents:
diff changeset
79 void Delete(Time* item);
223b71206888 Initial import
thib
parents:
diff changeset
80
223b71206888 Initial import
thib
parents:
diff changeset
81 typedef bool (*motionfunc)(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
82 void RegisterGlobalMotionFunc(motionfunc, void* pointer); // マウスの移動のたびに呼び出される関数を登録する
223b71206888 Initial import
thib
parents:
diff changeset
83 void DeleteGlobalMotionFunc(motionfunc, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
84 void RegisterGlobalPressFunc(motionfunc, void* pointer); // マウスのクリックのたびに呼び出される関数を登録する
223b71206888 Initial import
thib
parents:
diff changeset
85 void DeleteGlobalPressFunc(motionfunc, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
86
223b71206888 Initial import
thib
parents:
diff changeset
87 Container(void);
223b71206888 Initial import
thib
parents:
diff changeset
88 ~Container(void);
223b71206888 Initial import
thib
parents:
diff changeset
89 bool pressed(int mask);
223b71206888 Initial import
thib
parents:
diff changeset
90 bool presscount(int mask);
223b71206888 Initial import
thib
parents:
diff changeset
91 private:
223b71206888 Initial import
thib
parents:
diff changeset
92 class ContainerImplVideo* pimpl_video;
223b71206888 Initial import
thib
parents:
diff changeset
93 class ContainerImplTime* pimpl_time;
223b71206888 Initial import
thib
parents:
diff changeset
94 };
223b71206888 Initial import
thib
parents:
diff changeset
95
223b71206888 Initial import
thib
parents:
diff changeset
96 }; /* end of namespace Event */
223b71206888 Initial import
thib
parents:
diff changeset
97
223b71206888 Initial import
thib
parents:
diff changeset
98
223b71206888 Initial import
thib
parents:
diff changeset
99 #endif