00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_EVENT_PATTERN
00011 #define QWT_EVENT_PATTERN 1
00012
00013 #include <qnamespace.h>
00014 #include "qwt_array.h"
00015
00016 class QMouseEvent;
00017 class QKeyEvent;
00018
00028 class QWT_EXPORT QwtEventPattern
00029 {
00030 public:
00079 enum MousePatternCode
00080 {
00081 MouseSelect1,
00082 MouseSelect2,
00083 MouseSelect3,
00084 MouseSelect4,
00085 MouseSelect5,
00086 MouseSelect6,
00087
00088 MousePatternCount
00089 };
00090
00118 enum KeyPatternCode
00119 {
00120 KeySelect1,
00121 KeySelect2,
00122 KeyAbort,
00123
00124 KeyLeft,
00125 KeyRight,
00126 KeyUp,
00127 KeyDown,
00128
00129 KeyRedo,
00130 KeyUndo,
00131 KeyHome,
00132
00133 KeyPatternCount
00134 };
00135
00136 class MousePattern
00137 {
00138 public:
00139 MousePattern(int btn = Qt::NoButton, int st = Qt::NoButton)
00140 {
00141 button = btn;
00142 state = st;
00143 }
00144
00145 int button;
00146 int state;
00147 };
00148
00149 class KeyPattern
00150 {
00151 public:
00152 KeyPattern(int k = 0, int st = Qt::NoButton)
00153 {
00154 key = k;
00155 state = st;
00156 }
00157
00158 int key;
00159 int state;
00160 };
00161
00162 QwtEventPattern();
00163 virtual ~QwtEventPattern();
00164
00165 void initMousePattern(int numButtons);
00166 void initKeyPattern();
00167
00168 void setMousePattern(uint pattern, int button, int state = Qt::NoButton);
00169 void setKeyPattern(uint pattern, int key, int state = Qt::NoButton);
00170
00171 void setMousePattern(const QwtArray<MousePattern> &);
00172 void setKeyPattern(const QwtArray<KeyPattern> &);
00173
00174 const QwtArray<MousePattern> &mousePattern() const;
00175 const QwtArray<KeyPattern> &keyPattern() const;
00176
00177 QwtArray<MousePattern> &mousePattern();
00178 QwtArray<KeyPattern> &keyPattern();
00179
00180 bool mouseMatch(uint pattern, const QMouseEvent *) const;
00181 bool keyMatch(uint pattern, const QKeyEvent *) const;
00182
00183 protected:
00184 virtual bool mouseMatch(const MousePattern &, const QMouseEvent *) const;
00185 virtual bool keyMatch(const KeyPattern &, const QKeyEvent *) const;
00186
00187 private:
00188
00189 #if defined(_MSC_VER)
00190 #pragma warning(push)
00191 #pragma warning(disable: 4251)
00192 #endif
00193 QwtArray<MousePattern> d_mousePattern;
00194 QwtArray<KeyPattern> d_keyPattern;
00195 #if defined(_MSC_VER)
00196 #pragma warning(pop)
00197 #endif
00198 };
00199
00200 inline bool operator==(QwtEventPattern::MousePattern b1,
00201 QwtEventPattern::MousePattern b2)
00202 {
00203 return b1.button == b2.button && b1.state == b2.state;
00204 }
00205
00206 inline bool operator==(QwtEventPattern::KeyPattern b1,
00207 QwtEventPattern::KeyPattern b2)
00208 {
00209 return b1.key == b2.key && b1.state == b2.state;
00210 }
00211
00212 #if defined(QWT_TEMPLATEDLL)
00213
00214 template class QWT_EXPORT QwtArray<QwtEventPattern::MousePattern>;
00215 template class QWT_EXPORT QwtArray<QwtEventPattern::KeyPattern>;
00216
00217 #endif
00218
00219 #endif