ASPiK SDK
cbuttonstate.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __cbuttonstate__
6 #define __cbuttonstate__
7 
8 #include "vstguibase.h"
9 
10 namespace VSTGUI {
11 
12 //----------------------------
13 // @brief Button Types (+modifiers)
14 //----------------------------
15 enum CButton
16 {
17  kLButton = 1 << 1,
18  kMButton = 1 << 2,
19  kRButton = 1 << 3,
20  kShift = 1 << 4,
21  kControl = 1 << 5,
22  kAlt = 1 << 6,
23  kApple = 1 << 7,
24  kButton4 = 1 << 8,
25  kButton5 = 1 << 9,
26  kDoubleClick = 1 << 10,
27  kMouseWheelInverted = 1 << 11
28 };
29 
30 //-----------------------------------------------------------------------------
31 // CButtonState Declaration
33 //-----------------------------------------------------------------------------
35 {
36 public:
37  CButtonState (int32_t state = 0) : state (state) {}
38  CButtonState (const CButtonState& bs) : state (bs.state) {}
39 
40  int32_t getButtonState () const { return state & (kLButton | kRButton | kMButton | kButton4 | kButton5); }
41  int32_t getModifierState () const { return state & (kShift | kAlt | kControl | kApple); }
42 
44  bool isLeftButton () const { return getButtonState () == kLButton; }
46  bool isRightButton () const { return getButtonState () == kRButton; }
47 
48  bool isDoubleClick () const { return hasBit<int32_t> (state, kDoubleClick); }
49 
50  int32_t operator() () const { return state; }
51  CButtonState& operator= (int32_t s) { state = s; return *this; }
52  CButtonState& operator&= (int32_t s) { state &= s; return *this; }
53  CButtonState& operator|= (int32_t s) { state |= s; return *this; }
54 
55  int32_t operator& (const CButtonState& s) const { return state & s.state; }
56  int32_t operator| (const CButtonState& s) const { return state | s.state; }
57  int32_t operator~ () const { return ~state; }
58 
59  bool operator== (const CButtonState& s) const { return state == s.state; }
60  bool operator!= (const CButtonState& s) const { return state != s.state; }
61 protected:
62  int32_t state;
63 };
64 
65 }
66 
67 #endif // __cbuttonstate__
Definition: customcontrols.cpp:8
bool isLeftButton() const
Definition: cbuttonstate.h:44
bool isRightButton() const
Definition: cbuttonstate.h:46
Button and Modifier state.
Definition: cbuttonstate.h:34