libkipr  1.0.0
button.hpp
Go to the documentation of this file.
1 #ifndef _KIPR_BUTTON_BUTTON_HPP_
2 #define _KIPR_BUTTON_BUTTON_HPP_
3 
4 #include "kipr/sensor/sensor.hpp"
5 #include "button_ids.hpp"
6 #include "kipr/export/export.h"
7 
8 namespace kipr
9 {
10  namespace button
11  {
13  {
14  public:
15  virtual ~AbstractButton();
16  virtual void setPressed(bool pressed) = 0;
17 
18  inline bool isPressed() const { return value(); };
19 
20  inline bool isNotPressed() const { return !isPressed(); }
21 
22  inline bool isClicked() const
23  {
24  const bool ret = isPressed();
25  waitUntilReleased();
26  return ret;
27  }
28 
29  virtual void waitUntilReleased() const;
30 
31  virtual void waitUntilPressed() const;
32 
33  virtual void waitUntilClicked() const;
34  };
35 
36 
38  {
39  public:
41 
42  virtual void setText(const char * text) = 0;
43 
44  virtual const char * text() const = 0;
45 
46  virtual bool isTextDirty() const = 0;
47 
48  virtual void resetText() = 0;
49  };
50 
52  {
53  public:
54  IdButton(const Id & id, const char * defaultText);
56 
57  virtual void setText(const char * text);
58  virtual const char * text() const;
59  virtual bool isTextDirty() const;
60  virtual void setPressed(bool pressed);
61  virtual bool value() const;
62  virtual void resetText();
63  private:
64  Id m_id;
65  char * m_defaultText;
66  };
67 
69  {
70  public:
71  static void show();
72 
73  static void hide();
74 
75  static void setShown(bool shown);
76 
77  static bool isShown();
78  };
79 
80  extern EXPORT_SYM IdButton A;
81  extern EXPORT_SYM IdButton B;
82  extern EXPORT_SYM IdButton C;
83 
84  extern EXPORT_SYM IdButton X;
85  extern EXPORT_SYM IdButton Y;
86  extern EXPORT_SYM IdButton Z;
87 
88  extern EXPORT_SYM IdButton Left;
89  extern EXPORT_SYM IdButton Right;
90 
91  extern EXPORT_SYM IdButton * const all[8];
92  }
93 }
94 
95 #endif
Definition: button.hpp:13
virtual void waitUntilPressed() const
bool isPressed() const
Definition: button.hpp:18
virtual void waitUntilClicked() const
bool isClicked() const
Definition: button.hpp:22
virtual void waitUntilReleased() const
virtual void setPressed(bool pressed)=0
bool isNotPressed() const
Definition: button.hpp:20
Definition: button.hpp:38
virtual void setText(const char *text)=0
virtual bool isTextDirty() const =0
virtual const char * text() const =0
Definition: button.hpp:69
static void setShown(bool shown)
Definition: button.hpp:52
virtual void resetText()
virtual bool value() const
virtual const char * text() const
virtual bool isTextDirty() const
virtual void setPressed(bool pressed)
virtual void setText(const char *text)
IdButton(const Id &id, const char *defaultText)
Definition: sensor.hpp:23
#define EXPORT_SYM
Definition: export.h:7
EXPORT_SYM IdButton X
EXPORT_SYM IdButton *const all[8]
EXPORT_SYM IdButton A
EXPORT_SYM IdButton C
Id
Definition: button_ids.hpp:9
EXPORT_SYM IdButton B
EXPORT_SYM IdButton Left
EXPORT_SYM IdButton Z
EXPORT_SYM IdButton Y
EXPORT_SYM IdButton Right
Definition: accel.hpp:7