Mercurial > otakunoraifu
annotate window/event.h @ 71:1fd20d231376
Fix objScale with 2D zoom; implement objWidth and objHeight.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 01 Apr 2011 23:49:12 +0200 |
parents | 4416cfac86ae |
children |
rev | line source |
---|---|
31 | 1 /* |
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
0 | 28 #ifndef __EVENT__ |
29 #define __EVENT__ | |
30 | |
52 | 31 #include "rect.h" |
32 #include "SDL.h" | |
0 | 33 |
34 namespace Event { | |
35 | |
52 | 36 class Video; |
37 class Time; | |
38 class Container; | |
0 | 39 |
52 | 40 /* |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
41 ** マウスの press, ドラッグ、in/out を検出できる |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
42 ** focus がある時の left/right/space(==press) のキーを判別できる |
52 | 43 */ |
44 struct Video { | |
45 public: | |
46 virtual void Press(void) {} | |
47 virtual void Release(void) {} | |
48 virtual void Drag(int x_from, int y_from, int x_to, int y_to) {} | |
49 virtual void Motion(int x, int y) {} | |
50 virtual void In(void) {} | |
51 virtual void Out(void) {} | |
52 virtual void KeyLeft(void) {} | |
53 virtual void KeyRight(void) {} | |
0 | 54 |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
55 int point_in(int x, int y); /* z or -1 を返す。大きいほど高いところにある */ |
0 | 56 |
52 | 57 Video(Container& container); |
58 Video(Container& container, const Rect& init_rect); | |
59 Video(Container& container, const Rect& init_rect, int z); | |
60 void SetRegion(const Rect& new_rect); | |
61 void SetZ(int new_z); | |
62 void activate(void); | |
63 void deactivate(void); | |
64 virtual ~Video(); | |
0 | 65 |
52 | 66 Rect Region(void) const { return region;} |
67 private: | |
68 Rect region; | |
69 int z; | |
70 Container& parent; | |
71 bool activated; | |
72 friend bool operator <(const Video& position1, const Video& position2); | |
73 }; | |
0 | 74 |
52 | 75 struct Time { |
76 public: | |
77 enum { NEVER_WAKE = 0xffffffffUL, FRAME_UPDATE = 0xfffffffeUL}; | |
78 virtual void Elapsed(unsigned int current_time) {wakeup_time = NEVER_WAKE; }; /* next: never elapsed */ | |
79 void SetWakeup(unsigned int new_wakeup_time) { wakeup_time = new_wakeup_time; } | |
80 unsigned Wakeup(void) const { return wakeup_time; } | |
0 | 81 |
52 | 82 Time(Container& container); |
83 ~Time(); | |
84 private: | |
85 unsigned int wakeup_time; | |
86 Container& parent; | |
87 }; | |
0 | 88 |
52 | 89 struct Container { |
0 | 90 #define MOUSE_LEFT 0 |
91 #define MOUSE_MIDDLE 1 | |
92 #define MOUSE_RIGHT 2 | |
93 #define MOUSE_UP 3 | |
94 #define MOUSE_DOWN 4 | |
95 #define KEY_SHIFT 10 | |
96 #define BUTTON_MAX 32 | |
52 | 97 public: |
98 int button_pressed; | |
99 int button_presscount[BUTTON_MAX]; | |
100 int current_time; | |
0 | 101 |
52 | 102 void MousePos(int& x, int& y); |
103 bool Exec(unsigned int current_time); | |
0 | 104 |
52 | 105 void Add(Video* item); |
106 void Delete(Video* item); | |
0 | 107 |
52 | 108 void Add(Time* item); |
109 void Delete(Time* item); | |
0 | 110 |
52 | 111 typedef bool (*motionfunc)(int x, int y, void* pointer); |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
112 void RegisterGlobalMotionFunc(motionfunc, void* pointer); // マウスの移動のたびに呼び出される関数を登録する |
52 | 113 void DeleteGlobalMotionFunc(motionfunc, void* pointer); |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
114 void RegisterGlobalPressFunc(motionfunc, void* pointer); // マウスのクリックのたびに呼び出される関数を登録する |
52 | 115 void DeleteGlobalPressFunc(motionfunc, void* pointer); |
0 | 116 |
52 | 117 Container(void); |
118 ~Container(void); | |
119 bool pressed(int mask); | |
120 bool presscount(int mask); | |
121 private: | |
122 class ContainerImplVideo* pimpl_video; | |
123 class ContainerImplTime* pimpl_time; | |
124 }; | |
0 | 125 |
52 | 126 } /* end of namespace Event */ |
0 | 127 |
128 | |
129 #endif |