CanvasCV: CanvasCV-doxygen/src/canvascv/widgets/radiobuttons.h Source File
CanvasCV  1.0.0
radiobuttons.h
1 #ifndef RADIOBUTTONS_H
2 #define RADIOBUTTONS_H
3 
4 #include <future>
5 #include "compoundwidget.h"
6 #include "vframe.h"
7 
8 namespace canvascv
9 {
10 
11 class MatWidget;
12 
19 {
20 public:
21 
50  static std::shared_ptr<RadioButtons> create(Layout &layoutVal,
51  std::vector<std::string> buttonNames,
52  int defaultSelection = -1,
54  const cv::Point &pos = cv::Point(0,0));
55 
62  void setSelection(int value);
63 
65  int getSelection() const;
66 
74  std::string getTextAt(int index) const;
75 
77  size_t size() const;
78 
80  void setUserCB(Widget::CBUserSelection cbUserSelection);
81 
82  virtual const char *getType() const;
83 
84  static const char *type;
85 
86 protected:
87  friend class WidgetFactory;
88  template <class T> friend class WidgetFactoryT;
89 
90  RadioButtons(const cv::Point &pos);
91 
92  void addRadioButton(const std::string &txt);
93 
94  virtual void recalcCompound();
95 
96 private:
97 
98  cv::Mat getRadioNotSelected();
99  cv::Mat getRadioSelected();
100 
101  std::shared_ptr<VFrame> frame;
102  std::vector<MatWidget*> drawings;
103  cv::Mat radioNotSelected;
104  cv::Mat radioSelected;
105  int selection;
107 };
108 
109 }
110 
115 #endif // RADIOBUTTONS_H
The WidgetFactory class.
Definition: widgetfactory.h:24
static std::shared_ptr< RadioButtons > create(Layout &layoutVal, std::vector< std::string > buttonNames, int defaultSelection=-1, Widget::CBUserSelection cbUserSelection=Widget::CBUserSelection(), const cv::Point &pos=cv::Point(0, 0))
create a radio buttons widget
The RadioButtons class.
Definition: radiobuttons.h:18
int getSelection() const
get the current selected option
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per widget.
The CompoundWidget class.
Definition: compoundwidget.h:18
std::function< void(Widget *, int)> CBUserSelection
signature of a callback which gets a user selection
Definition: widget.h:48
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
The Layout class.
Definition: layout.h:17
void setUserCB(Widget::CBUserSelection cbUserSelection)
cbUserSelection will be invoked per user selection
std::string getTextAt(int index) const
getTextAt
virtual void recalcCompound()
recalcCompound
size_t size() const
return nunmber of check boxes in group
The WidgetFactoryT class.
Definition: widgetfactory.h:58
void setSelection(int value)
setSelection