comparison engine/core/eventchannel/eventchannel.i @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children e84dccee1bb7
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
4 * This file is part of FIFE. *
5 * *
6 * FIFE 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 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 %module fife
23 %{
24 #include "eventchannel/base/ec_event.h"
25 #include "eventchannel/base/ec_inputevent.h"
26 #include "eventchannel/command/ec_command.h"
27 #include "eventchannel/command/ec_commandids.h"
28 #include "eventchannel/command/ec_icommandlistener.h"
29 #include "eventchannel/key/ec_key.h"
30 #include "eventchannel/key/ec_keyevent.h"
31 #include "eventchannel/key/ec_ikeylistener.h"
32 #include "eventchannel/source/ec_eventsourcetypes.h"
33 #include "eventchannel/source/ec_ieventsource.h"
34 #include "eventchannel/mouse/ec_mouseevent.h"
35 #include "eventchannel/mouse/ec_imouselistener.h"
36 #include "eventchannel/widget/ec_widgetevent.h"
37 #include "eventchannel/widget/ec_iwidgetlistener.h"
38 #include "eventchannel/eventmanager.h"
39 %}
40
41 %include "eventchannel/key/ec_key.h"
42 %include "eventchannel/source/ec_eventsourcetypes.h"
43 %include "eventchannel/command/ec_commandids.h"
44
45 namespace FIFE {
46 %feature("director") IEventSource;
47 class IEventSource {
48 public:
49 virtual EventSourceType getEventSourceType() = 0;
50 virtual ~IEventSource();
51 };
52
53 class Event {
54 public:
55 virtual void consume();
56 virtual bool isConsumed() const;
57 virtual IEventSource* getSource();
58 virtual gcn::Widget* getSourceWidget();
59 virtual int getTimeStamp() const;
60 virtual std::string getDebugString() const;
61 virtual const std::string& getName() const;
62 virtual ~IEvent() {}
63 private:
64 Event();
65 };
66
67 class InputEvent: public Event {
68 public:
69 virtual bool isAltPressed() const;
70 virtual bool isControlPressed() const;
71 virtual bool isMetaPressed() const;
72 virtual bool isShiftPressed() const;
73 virtual ~IInputEvent() {}
74 private:
75 InputEvent();
76 };
77
78 class Command: public Event {
79 public:
80 Command();
81 virtual ~Command();
82
83 CommandType getCommandType();
84 void setCommandType(CommandType type);
85
86 int getCode();
87 void setCode(int code);
88
89 virtual void setSource(IEventSource* source);
90 virtual void setSourceWidget(gcn::Widget* widget);
91 virtual void setTimeStamp(int timestamp);
92 };
93
94 %feature("director") ICommandListener;
95 class ICommandListener {
96 public:
97 virtual void onCommand(Command& command) = 0;
98 virtual ~ICommandListener() {}
99 };
100
101 class KeyEvent: public InputEvent {
102 public:
103 enum KeyEventType {
104 UNKNOWN = -1,
105 PRESSED = 0,
106 RELEASED
107 };
108 virtual KeyEventType getType() const;
109 virtual bool isNumericPad() const;
110 virtual const Key& getKey() const;
111 virtual ~KeyEvent();
112 private:
113 KeyEvent();
114 };
115
116 %feature("director") IKeyListener;
117 class IKeyListener {
118 public:
119 virtual void keyPressed(KeyEvent& evt) = 0;
120 virtual void keyReleased(KeyEvent& evt) = 0;
121 virtual ~IKeyListener();
122 };
123
124 class MouseEvent: public InputEvent {
125 public:
126 enum MouseEventType {
127 UNKNOWN_EVENT = -1,
128 MOVED = 0,
129 PRESSED,
130 RELEASED,
131 WHEEL_MOVED_DOWN,
132 WHEEL_MOVED_UP,
133 CLICKED,
134 ENTERED,
135 EXITED,
136 DRAGGED
137 };
138
139 enum MouseButtonType {
140 EMPTY = 0,
141 LEFT = 1,
142 RIGHT = 2,
143 MIDDLE = 4,
144 UNKNOWN_BUTTON = 8
145 };
146 virtual int getX() const;
147 virtual int getY() const;
148 virtual MouseEventType getType() const;
149 virtual MouseButtonType getButton() const;
150 virtual ~IMouseEvent();
151 private:
152 MouseEvent();
153 };
154
155 %feature("director") IMouseListener;
156 class IMouseListener {
157 public:
158 virtual void mouseEntered(MouseEvent& evt) = 0;
159 virtual void mouseExited(MouseEvent& evt) = 0;
160 virtual void mousePressed(MouseEvent& evt) = 0;
161 virtual void mouseReleased(MouseEvent& evt) = 0;
162 virtual void mouseClicked(MouseEvent& evt) = 0;
163 virtual void mouseWheelMovedUp(MouseEvent& evt) = 0;
164 virtual void mouseWheelMovedDown(MouseEvent& evt) = 0;
165 virtual void mouseMoved(MouseEvent& evt) = 0;
166 virtual void mouseDragged(MouseEvent& evt) = 0;
167 virtual ~IMouseListener();
168 };
169
170 class WidgetEvent: public Event {
171 public:
172 virtual const std::string& getId();
173 virtual ~WidgetEvent();
174 private:
175 WidgetEvent();
176 };
177
178 %feature("director") IWidgetListener;
179 class IWidgetListener {
180 public:
181 virtual void onWidgetAction(WidgetEvent& evt) = 0;
182 virtual ~IWidgetListener();
183 };
184
185 class EventManager {
186 public:
187 EventManager();
188 virtual ~EventManager();
189 void addCommandListener(ICommandListener* listener);
190 void removeCommandListener(ICommandListener* listener);
191 void addKeyListener(IKeyListener* listener);
192 void removeKeyListener(IKeyListener* listener);
193 void addMouseListener(IMouseListener* listener);
194 void removeMouseListener(IMouseListener* listener);
195 void addWidgetListener(IWidgetListener* listener);
196 void removeWidgetListener(IWidgetListener* listener);
197 EventSourceType getEventSourceType();
198 void dispatchCommand(Command& command);
199 void setNonConsumableKeys(const std::vector<int>& keys);
200 std::vector<int> getNonConsumableKeys();
201 };
202 };