2020-03-14 23:35:54 +00:00
|
|
|
#ifndef __NCPP_MULTI_SELECTOR_HH
|
|
|
|
#define __NCPP_MULTI_SELECTOR_HH
|
|
|
|
|
|
|
|
#include <notcurses/notcurses.h>
|
|
|
|
|
|
|
|
#include "Root.hh"
|
|
|
|
#include "NCAlign.hh"
|
2020-05-07 19:06:07 +00:00
|
|
|
#include "NotCurses.hh"
|
2020-03-14 23:35:54 +00:00
|
|
|
|
|
|
|
namespace ncpp
|
|
|
|
{
|
|
|
|
class Plane;
|
|
|
|
|
|
|
|
class NCPP_API_EXPORT MultiSelector : public Root
|
|
|
|
{
|
|
|
|
public:
|
2020-05-09 00:58:00 +00:00
|
|
|
static ncmultiselector_options default_options;
|
2020-03-14 23:35:54 +00:00
|
|
|
|
|
|
|
public:
|
2020-05-09 00:58:00 +00:00
|
|
|
explicit MultiSelector (NotCurses *nc, int y, int x, const ncmultiselector_options *opts = nullptr)
|
2020-05-07 19:06:07 +00:00
|
|
|
: MultiSelector (reinterpret_cast<notcurses*>(nc), y, x, opts)
|
2020-03-14 23:35:54 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 00:58:00 +00:00
|
|
|
explicit MultiSelector (NotCurses const* nc, int y, int x, const ncmultiselector_options *opts = nullptr)
|
2020-05-07 19:06:07 +00:00
|
|
|
: MultiSelector (const_cast<NotCurses*>(nc), y, x, opts)
|
2020-03-14 23:35:54 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 00:58:00 +00:00
|
|
|
explicit MultiSelector (NotCurses &nc, int y, int x, const ncmultiselector_options *opts = nullptr)
|
2020-05-07 19:06:07 +00:00
|
|
|
: MultiSelector (reinterpret_cast<notcurses*>(&nc), y, x, opts)
|
2020-03-14 23:35:54 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 00:58:00 +00:00
|
|
|
explicit MultiSelector (NotCurses const& nc, int y, int x, const ncmultiselector_options *opts = nullptr)
|
2020-05-07 19:06:07 +00:00
|
|
|
: MultiSelector (const_cast<NotCurses*>(&nc), y, x, opts)
|
2020-03-14 23:35:54 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 00:58:00 +00:00
|
|
|
explicit MultiSelector (notcurses *nc, int y, int x, const ncmultiselector_options *opts = nullptr)
|
2020-03-14 23:35:54 +00:00
|
|
|
{
|
2020-05-07 19:06:07 +00:00
|
|
|
multiselector = ncmultiselector_create (nc, y, x, opts == nullptr ? &default_options : opts);
|
2020-03-14 23:35:54 +00:00
|
|
|
if (multiselector == nullptr)
|
2020-05-09 00:58:00 +00:00
|
|
|
throw init_error ("notcurses failed to create a new ncmultiselector");
|
2020-03-14 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~MultiSelector ()
|
|
|
|
{
|
|
|
|
if (!is_notcurses_stopped ())
|
|
|
|
ncmultiselector_destroy (multiselector, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool offer_input (const struct ncinput *nc) const noexcept
|
|
|
|
{
|
|
|
|
return ncmultiselector_offer_input (multiselector, nc);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int get_selected (bool *selected, unsigned count) const NOEXCEPT_MAYBE
|
2020-03-14 23:35:54 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncmultiselector_selected (multiselector, selected, count), -1);
|
2020-03-14 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Plane* get_plane () const noexcept;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ncmultiselector *multiselector;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|