CanvasCV: CanvasCV-doxygen/src/canvascv/widgets/button.h Source File
CanvasCV  1.0.0
button.h
1 #ifndef BUTTON_H
2 #define BUTTON_H
3 
4 #include <opencv2/opencv.hpp>
5 #include <list>
6 #include "canvascv/colors.h"
7 #include "text.h"
8 
9 namespace canvascv
10 {
11 
17 class Button : public Text
18 {
19 public:
20 
31  static std::shared_ptr<Button> create(Layout &layout,
32  const cv::Point &pos,
33  const std::string &buttonText,
34  const std::string &statusMsg="",
35  CBWidget cbVal = CBWidget());
36 
38  static std::shared_ptr<Button> create(Layout &layout,
39  const std::string &buttonText,
40  const std::string &statusMsg="",
41  CBWidget cbVal = CBWidget());
42 
44  void setFlatButton();
45 
47  void onPress(CBWidget value);
48 
49  virtual const char *getType() const;
50 
51  static const char *type;
52 
53 protected:
54 
55  friend class WidgetFactory;
56  template <class T> friend class WidgetFactoryT;
57  Button(const cv::Point &pos);
58 
59  /* TODO - write/read widgets to file for a designer app
60  virtual void writeInternals(cv::FileStorage &fs) const
61  {
62  }
63  // TODO
64  virtual void readInternals(const cv::FileNode &node)
65  {
66  }
67  */
68 
69 
70 private:
71  virtual void mousePressed();
72  virtual void mouseReleased();
73  virtual void mouseEnter();
74  virtual void mouseLeave();
75 
76  CBWidget cb;
77 };
78 
79 }
80 #endif // BUTTON_H
The WidgetFactory class.
Definition: widgetfactory.h:24
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per widget.
void onPress(CBWidget value)
Call a user CB when pressed.
static std::shared_ptr< Button > create(Layout &layout, const cv::Point &pos, const std::string &buttonText, const std::string &statusMsg="", CBWidget cbVal=CBWidget())
create a button widget
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
The Layout class.
Definition: layout.h:17
The Text class.
Definition: text.h:17
void setFlatButton()
The button will always have a FLAT relief.
The WidgetFactoryT class.
Definition: widgetfactory.h:58
The Button class.
Definition: button.h:17
std::function< void(Widget *)> CBWidget
signature of a callback which only gets the widget
Definition: widget.h:42