Public Member Functions |
Static Public Member Functions |
Protected Member Functions |
List of all members
canvascv::MsgBox Class Reference
#include <msgbox.h>
Inheritance diagram for canvascv::MsgBox:
Public Member Functions | |
int | getUserSelection (bool blocking=false) |
getUserSelection More... | |
std::string | getTextAt (int index) const |
getTextAt More... | |
size_t | size () const |
return nunmber of buttons | |
virtual const char * | getType () const |
getType is always implemented by derived to return the same static pointer per widget. More... | |
Public Member Functions inherited from canvascv::CompoundWidget | |
virtual void | setOutlineColor (const cv::Scalar &value) |
delegate to internal Widget parts added by derived classes | |
virtual void | setFillColor (const cv::Scalar &value) |
delegate to internal Widget parts added by derived classes | |
virtual void | setSelectColor (const cv::Scalar &value) |
delegate to internal Widget parts added by derived classes | |
virtual void | setThickness (int value) |
delegate to internal Widget parts added by derived classes | |
virtual void | setLineType (int value) |
delegate to internal Widget parts added by derived classes | |
virtual void | setVisible (bool value) |
delegate to internal Widget parts added by derived classes | |
virtual const std::string & | getStatusMsg () const |
delegate to active widget or to our derived class if none active | |
virtual void | translate (const cv::Point &translation) |
delegate to internal Widget parts added by derived classes | |
void | doForAll (CBWidget cb, int recurseLevel, bool doOnSelf) |
doForAll More... | |
virtual const cv::Rect & | getRect () |
Actual size the widget is occupying due to Layout manager. | |
Public Member Functions inherited from canvascv::Widget | |
Widget (const cv::Point &pos=cv::Point(0, 0)) | |
constructor | |
virtual | ~Widget () |
virtual destructor | |
void | notifyOnChange (CBWidgetState cb) |
used to register for notifications on a widget More... | |
cv::Scalar | getOutlineColor () const |
get the outline color | |
cv::Scalar | getFillColor () const |
get the bg color | |
bool | getVisible () const |
is the widget visible | |
int | getThickness () const |
get line thickness to use when drawing | |
int | getLineType () const |
get the line type (LINE_4, LINE_8, LINE_AA) | |
uchar | getAlpha () const |
get the alpha value used for the widge background [0,255] => [transparent,opaque] | |
void | setAlpha (uchar value) |
set the alpha value used for the widge background [0,255] => [transparent,opaque] | |
Anchor | getLayoutAnchor () const |
getLayoutAnchor returns the anchor for using in the Layout we're in More... | |
void | setLayoutAnchor (const Anchor &value) |
setLayoutAnchor sets the anchor for using in the Layout we're in More... | |
Anchor | getFlowAnchor () const |
getFlowAnchor get internal widget alignment and direction of growth More... | |
void | setFlowAnchor (const Anchor &value) |
setFlowAnchor set internal widget alignment and direction of growth More... | |
int | getId () |
Widgets have a unique id per instance. | |
void | setStatusMsg (const std::string &value) |
setStatusMsg More... | |
const cv::Point & | getLocation () const |
get widget position in Canvas | |
virtual void | setLocation (const cv::Point &value) |
set widget position in Canvas | |
bool | getStretchX () const |
get if the Layout we're in should stretch us in the X direction | |
void | setStretchX (bool value) |
set if the Layout we're in should stretch us in the X direction (and calls setStretchXToParent(false)) | |
bool | getStretchY () const |
get if the Layout we're in should stretch us in the Y direction | |
void | setStretchY (bool value) |
set if the Layout we're in should stretch us in the Y direction (and calls setStretchYToParent(false)) | |
cv::Scalar | getSelectColor () const |
get the color to use when a widget is selected | |
std::shared_ptr< Widget > | rmvFromLayout () |
get rid of the widget | |
bool | getIsSelectable () const |
get if the widget should appear as selected when the mouse is over it | |
void | setIsSelectable (bool value) |
set if the widget should appear as selected when the mouse is over it | |
int | getForcedWidth () const |
get the forced width for this widget | |
void | setForcedWidth (int value) |
set the forced width for this widget (and calls setStretchX/setStretchXToParent(false)) | |
int | getForcedHeight () const |
get the forced height for this widget | |
void | setForcedHeight (int value) |
set the forced height for this widget (and calls setStretchY/setStretchYToParent(false)) | |
void | update () |
removes 'dirty' state and invokes the derived 'recalc/recalcCompound' | |
bool | isRemoved () const |
returns true if the widget has no layout and false if it does | |
bool | getStretchXToParent () const |
get if this widget streches to parent layout width | |
void | setStretchXToParent (bool value) |
set if this widget streches to parent layout width (and calls setStretchX(false)) | |
bool | getStretchYToParent () const |
get if this widget streches to parent layout height | |
void | setStretchYToParent (bool value) |
set if this widget streches to parent layout height (and calls setStretchY(false)) | |
Static Public Member Functions | |
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 More... | |
static int | createModal (const std::string &title, const std::string &msg, std::vector< std::string > buttonNames={"Ok"}, Widget::CBUserSelection cbUserSelection=Widget::CBUserSelection()) |
createModal More... | |
Protected Member Functions | |
virtual void | recalcCompound () |
recalcCompound More... | |
Protected Member Functions inherited from canvascv::CompoundWidget | |
virtual void | recalc () final |
delegate to internal Widget parts added by derived classes | |
virtual void | addWidget (const std::shared_ptr< Widget > &widget) |
adds the widget to this Layout after removing it from it's previous layout | |
virtual std::shared_ptr< Widget > | rmvWidget (const std::shared_ptr< Widget > &widget) |
rmvWidget More... | |
virtual void | renderOn (cv::Mat &dst) |
render the widget to dst More... | |
virtual void | drawFG (cv::Mat &dst) |
dst is the roi of the widget size and not the full image | |
virtual bool | isAtPos (const cv::Point &pos) |
isAtPos More... | |
virtual const cv::Rect & | getMinimalRect () |
Minimal size the widget coould have occupy. | |
Protected Member Functions inherited from canvascv::Widget | |
void | setStateChangesBG () |
widgets like buttons change bg on mouse events | |
void | allocateBG (const cv::Size &size) |
invokes Theme::allocateBG() | |
void | flatWidget () |
delegate to Theme | |
void | raisedWidget () |
delegate to Theme | |
void | sunkenWidget () |
delegate to Theme | |
void | selectedWidget () |
delegate to Theme | |
void | callDrawFG (bool preAllocateMat=true) |
helper method which delgates to drawFG for derived | |
bool | setDirty () |
setDirty More... | |
Additional Inherited Members | |
Public Types inherited from canvascv::Widget | |
typedef std::function< void(Widget *)> | CBWidget |
signature of a callback which only gets the widget | |
typedef std::function< void(Widget *, State)> | CBWidgetState |
signature of a callback which gets the State | |
typedef std::function< void(Widget *, int)> | CBUserSelection |
signature of a callback which gets a user selection | |
Detailed Description
Use a message box with any number of buttons on an OpenCV window
Member Function Documentation
|
static |
The MsgBox is not modal - does not block input to other widgets. For a modal MsgBox inside a Canvas use create() and getUserSelection(true).
- Parameters
-
canvas must be a Canvas reference for a MsgBox msg what to display in the MsgBox buttonNames automatically create buttons with names of buttonNames cbUserSelection a callback to invoke with index of pressed button pos location in the Canvas (the default is the center of the Canvas)
- Returns
- a smart pointer copy of the object kept in the Layout Or you could use the callback version (see the example)Canvas c(winName, image.size());auto msgBox = MsgBox::create(c,"This is a MsgBox example\n""with 2 lines", {"Ok", // 0"Cancel", // 1"Somthing else" // 2});while(...){if (msgBox && msgBox->getUserSelection() != -1){cout << "MsgBox was pressed with key index " << msgBox->getUserSelection() << endl;msgBox.reset();}c.redrawOn(...);imshow(...);key = c.waitKeyEx(...); // GUI and callbacks happen here}
- See also
- getUserSelection
- Examples:
- example_msgbox.cpp.
|
static |
opens a modal (blocking) MsgBox in it's own window and immediatly waits for a user selection. For a modal MsgBox inside a Canvas use create() and getUserSelection(true).
- Parameters
-
title is the title of the new window msg what to display in the MsgBox buttonNames automatically create buttons with names of buttonNames cbUserSelection a callback to invoke with index of pressed button
- Returns
- return result of getUserSelection()
- See also
- getUserSelection(true)
std::string canvascv::MsgBox::getTextAt | ( | int | index | ) | const |
return the text at index index
- Parameters
-
index is the index you want the text for
- Returns
- return the text at index index or empty string if invalid index
|
virtual |
- Returns
- const char * pointer to string with widget type name
Implements canvascv::Widget.
int canvascv::MsgBox::getUserSelection | ( | bool | blocking = false | ) |
get what the user pressed
- Parameters
-
blocking if true, block waiting on the MsgBox until a button is pressed
- Returns
- returns pressed button index or -1 if not pressed
|
protectedvirtual |
Your BG size recalculation/allocation and FG drawing is done here. It is done semi automatically. Is you invoke setters in this method on your internal widgets, then make sure to update them and/or their layout
Implements canvascv::CompoundWidget.
The documentation for this class was generated from the following file:
- CanvasCV-doxygen/src/canvascv/widgets/msgbox.h
Generated by 1.8.11