Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_event_pattern.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_EVENT_PATTERN
    00011 #define QWT_EVENT_PATTERN 1
    00012
    00013 #include "qwt_array.h"
    00014
    00015 class QMouseEvent;
    00016 class QKeyEvent;
    00017
    00027 class QWT_EXPORT QwtEventPattern
    00028 {
    00029 public:
    00078     enum MousePatternCode
    00079     {
    00080         MouseSelect1,
    00081         MouseSelect2,
    00082         MouseSelect3,
    00083         MouseSelect4,
    00084         MouseSelect5,
    00085         MouseSelect6,
    00086
    00087         MousePatternCount
    00088     };
    00089
    00117     enum KeyPatternCode
    00118     {
    00119         KeySelect1,
    00120         KeySelect2,
    00121         KeyAbort,
    00122
    00123         KeyLeft,
    00124         KeyRight,
    00125         KeyUp,
    00126         KeyDown,
    00127
    00128         KeyRedo,
    00129         KeyUndo,
    00130         KeyHome,
    00131
    00132         KeyPatternCount
    00133     };
    00134
    00135     class MousePattern
    00136     {
    00137     public:
    00138         MousePattern(int btn = Qt::NoButton, int st = Qt::NoButton)
    00139         {
    00140             button = btn;
    00141             state = st;
    00142         }
    00143
    00144         int button;
    00145         int state;
    00146     };
    00147
    00148     class KeyPattern
    00149     {
    00150     public:
    00151         KeyPattern(int k = 0, int st = Qt::NoButton)
    00152         {
    00153             key = k;
    00154             state = st;
    00155         }
    00156
    00157         int key;
    00158         int state;
    00159     };
    00160
    00161     QwtEventPattern();
    00162     virtual ~QwtEventPattern();
    00163
    00164     void initMousePattern(int numButtons);
    00165     void initKeyPattern();
    00166
    00167     void setMousePattern(uint pattern, int button, int state = Qt::NoButton);
    00168     void setKeyPattern(uint pattern, int key, int state = Qt::NoButton);
    00169
    00170     void setMousePattern(const QwtArray<MousePattern> &);
    00171     void setKeyPattern(const QwtArray<KeyPattern> &);
    00172
    00173     const QwtArray<MousePattern> &mousePattern() const;
    00174     const QwtArray<KeyPattern> &keyPattern() const;
    00175
    00176     QwtArray<MousePattern> &mousePattern();
    00177     QwtArray<KeyPattern> &keyPattern();
    00178
    00179     bool mouseMatch(uint pattern, const QMouseEvent *) const;
    00180     bool keyMatch(uint pattern, const QKeyEvent *) const;
    00181
    00182 protected:
    00183     virtual bool mouseMatch(const MousePattern &, const QMouseEvent *) const;
    00184     virtual bool keyMatch(const KeyPattern &, const QKeyEvent *) const;
    00185
    00186 private:
    00187
    00188 #if defined(_MSC_VER)
    00189 #pragma warning(push)
    00190 #pragma warning(disable: 4251)
    00191 #endif
    00192     QwtArray<MousePattern> d_mousePattern;
    00193     QwtArray<KeyPattern> d_keyPattern;
    00194 #if defined(_MSC_VER)
    00195 #pragma warning(pop)
    00196 #endif
    00197 };
    00198
    00199 #if defined(QWT_TEMPLATEDLL)
    00200 // MOC_SKIP_BEGIN
    00201 template class QWT_EXPORT QwtArray<QwtEventPattern::MousePattern>;
    00202 template class QWT_EXPORT QwtArray<QwtEventPattern::KeyPattern>;
    00203 // MOC_SKIP_END
    00204 #endif
    00205
    00206 #endif