CanvasCV: CanvasCV-doxygen/src/canvascv/widgets/msgbox.h Source File
CanvasCV  1.0.0
msgbox.h
1 #ifndef MSGBOX_H
2 #define MSGBOX_H
3 
4 #include <future>
5 #include "compoundwidget.h"
6 #include "vframe.h"
7 #include "horizontallayout.h"
8 
9 namespace canvascv
10 {
11 
12 class Canvas;
13 
19 class MsgBox : public CompoundWidget
20 {
21 public:
22 
59  static std::shared_ptr<MsgBox> create(Canvas &canvas,
60  const std::string &msg,
61  std::vector<std::string> buttonNames = {"Ok"},
63  const cv::Point &pos = cv::Point(-1,-1));
64 
77  static int createModal(const std::string &title,
78  const std::string &msg,
79  std::vector<std::string> buttonNames = {"Ok"},
81 
89  int getUserSelection(bool blocking = false);
90 
98  std::string getTextAt(int index) const;
99 
101  size_t size() const;
102 
103  virtual const char *getType() const;
104 
105  static const char *type;
106 
107 protected:
108  friend class WidgetFactory;
109  template <class T> friend class WidgetFactoryT;
110 
111  MsgBox(const cv::Point &pos);
112 
113  void setMsg(const std::string &msg);
114 
115  virtual void recalcCompound();
116 
117 private:
118  int userSelection;
119  VFrame *frame;
120  HorizontalLayout *buttons;
121 };
122 
123 }
124 
129 #endif // MSGBOX_H
The WidgetFactory class.
Definition: widgetfactory.h:24
The MsgBox class.
Definition: msgbox.h:19
The VFrame class.
Definition: vframe.h:16
The CompoundWidget class.
Definition: compoundwidget.h:18
static int createModal(const std::string &title, const std::string &msg, std::vector< std::string > buttonNames={"Ok"}, Widget::CBUserSelection cbUserSelection=Widget::CBUserSelection())
createModal
static std::shared_ptr< MsgBox > create(Canvas &canvas, const std::string &msg, std::vector< std::string > buttonNames={"Ok"}, Widget::CBUserSelection cbUserSelection=Widget::CBUserSelection(), const cv::Point &pos=cv::Point(-1,-1))
create a message box widget which is closed automatically
std::function< void(Widget *, int)> CBUserSelection
signature of a callback which gets a user selection
Definition: widget.h:48
virtual void recalcCompound()
recalcCompound
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
The HorizontalLayout class.
Definition: horizontallayout.h:37
int getUserSelection(bool blocking=false)
getUserSelection
The WidgetFactoryT class.
Definition: widgetfactory.h:58
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per widget.
size_t size() const
return nunmber of buttons
The Canvas class is the entry point into CanvasCV.
Definition: canvas.h:33
std::string getTextAt(int index) const
getTextAt