00001 #ifndef KDE__EVENT_H
00002 #define KDE__EVENT_H
00003
00004 #include <faith/point.h>
00005 #include <faith/rect.h>
00006 #include <faith/string.h>
00007 #include <faith/global.h>
00008 #include <faith/core.h>
00009
00010 namespace Faith
00011 {
00012
00017 class FAITH_CORE_EXPORT Event
00018 {
00019 public:
00020 enum EventType
00021 {
00022 EventTimer,
00023 EventMouseButtonPress,
00024 EventMouseButtonRelease,
00025 EventMouseMove,
00026 EventPaint,
00027 EventKeyPress,
00028 EventKeyRelease,
00029 EventFocusIn,
00030 EventFocusOut,
00031 EventEnter,
00032 EventLeave,
00033 EventClose,
00034 EventResize,
00035 EventMove,
00036 EventShow,
00037 EventHide,
00038
00039 EventCreate,
00040 EventDelete,
00041 EventLayout,
00042
00043 EventUser = 4096,
00044
00045 eventType_BC = 0xffffffff
00046 };
00047 private:
00048 Event::EventType mType;
00049
00050 public:
00051 Event(EventType type)
00052 : mType(type)
00053 { }
00054
00055 virtual ~Event() { }
00060 inline EventType type() const{ return mType; }
00061 };
00062
00069 class MouseEvent : public Event
00070 {
00071 Point mAt;
00072 int mButton;
00073 int mState;
00074
00075 public:
00079 MouseEvent(EventType t, const Point &at, int button, int state)
00080 : Event(t), mAt(at), mButton(button), mState(state)
00081 {
00082 }
00083
00087 inline Point pos() const { return mAt; }
00091 inline int button() const { return mButton; }
00095 inline int state() const { return mState; }
00096
00097 };
00098
00104 class KeyPressEvent : public Event
00105 {
00106 int mState;
00107 String mText;
00108 Key mKey;
00109
00110 public:
00111 KeyPressEvent(EventType t, int state, Key key, const String &text)
00112 : Event(t), mState(state), mText(text), mKey(key)
00113 {
00114 }
00115
00120 inline String text() const { return mText; }
00124 inline int state() const { return mState; }
00125
00126 Key key() const { return mKey; }
00127
00128 };
00129
00135 class FocusEvent : public Event
00136 {
00137 public:
00141 FocusEvent(EventType t)
00142 : Event(t)
00143 {
00144 }
00145 };
00146
00150 class CloseEvent : public Event
00151 {
00152 public:
00156 CloseEvent()
00157 : Event(Event::EventClose)
00158 {
00159 }
00160 };
00161
00165 class ResizeEvent : public Event
00166 {
00167 Faith::Size mSize;
00168 public:
00172 ResizeEvent(const Faith::Size &size)
00173 : Event(Event::EventResize), mSize(size)
00174 {
00175 }
00176
00180 Faith::Size size() const { return mSize; }
00181 };
00182
00186 class MoveEvent : public Event
00187 {
00188 Faith::Point mPoint;
00189 public:
00193 MoveEvent(const Faith::Point &pt)
00194 : Event(Event::EventMove), mPoint(pt)
00195 {
00196 }
00197
00201 Faith::Point pos() const { return mPoint; }
00202 };
00203
00208 class PaintEvent : public Event
00209 {
00210 Rect mRect;
00211 int mButton;
00212 public:
00216 PaintEvent(const Rect &rect)
00217 : Event(Event::EventPaint), mRect(rect)
00218 {
00219 }
00220
00224 inline Rect rect() const { return mRect; }
00225 };
00226
00233 class TimerEvent : public Event
00234 {
00235 int mId;
00236 public:
00241 TimerEvent(int id)
00242 : Event(Event::EventTimer), mId(id)
00243 {
00244 }
00245
00249 inline int timerId() const { return mId; }
00250 };
00251
00252
00253 }
00254 #endif