windowobserver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(INCLUDED_WINDOWOBSERVER_H)
00023 #define INCLUDED_WINDOWOBSERVER_H
00024
00025 template<typename Enumeration> class BitFieldValue;
00026 struct ModifierEnumeration;
00027 typedef BitFieldValue<ModifierEnumeration> ModifierFlags;
00028
00029 template<typename Enumeration> class EnumeratedValue;
00030 struct ButtonEnumeration;
00031 typedef EnumeratedValue<ButtonEnumeration> ButtonIdentifier;
00032
00033 #include <algorithm>
00034 #include "math/Vector2.h"
00035 #include "generic/bitfield.h"
00036
00037 struct ModifierEnumeration {
00038 enum Value {
00039 SHIFT = 0,
00040 CONTROL = 1,
00041 ALT = 2
00042 };
00043 };
00044
00045 typedef BitFieldValue<ModifierEnumeration> ModifierFlags;
00046
00047 const ModifierFlags c_modifierNone;
00048 const ModifierFlags c_modifierShift(ModifierEnumeration::SHIFT);
00049 const ModifierFlags c_modifierControl(ModifierEnumeration::CONTROL);
00050 const ModifierFlags c_modifierAlt(ModifierEnumeration::ALT);
00051
00052 #include "generic/enumeration.h"
00053
00054 struct ButtonEnumeration {
00055 enum Value {
00056 INVALID = 0,
00057 LEFT = 1,
00058 MIDDLE = 3,
00059 RIGHT = 2
00060 };
00061 };
00062
00063 typedef EnumeratedValue<ButtonEnumeration> ButtonIdentifier;
00064
00065 const ButtonIdentifier c_buttonInvalid(ButtonEnumeration::INVALID);
00066 const ButtonIdentifier c_buttonLeft(ButtonEnumeration::LEFT);
00067 const ButtonIdentifier c_buttonMiddle(ButtonEnumeration::MIDDLE);
00068 const ButtonIdentifier c_buttonRight(ButtonEnumeration::RIGHT);
00069
00070
00071 template<typename Element>
00072 class BasicVector2;
00073 typedef BasicVector2<float> Vector2;
00074 typedef Vector2 WindowVector;
00075
00076 class WindowObserver {
00077 public:
00078 virtual ~WindowObserver() {}
00079 virtual void onSizeChanged(int width, int height) = 0;
00080 virtual void onMouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers) = 0;
00081 virtual void onMouseUp(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers) = 0;
00082 virtual void onMouseMotion(const WindowVector& position, ModifierFlags modifiers) = 0;
00083 virtual void onModifierDown(ModifierFlags modifier) = 0;
00084 virtual void onModifierUp(ModifierFlags modifier) = 0;
00085 };
00086
00087 #endif