notcurses/include/ncpp/Menu.hh
Marek Habersack 2fabe85e6a [C++] API sync
Been a while, apologies :)

Added:
  * Direct: fg_palindex (`ncdirect_fg_palindex`)
  * Direct: bg_palindex (`ncdirect_bg_palindex`)
  * Direct: get_palette_size (`ncdirect_palette_size`)
  * Direct: putstr (`ncdirect_putstr`)
  * Direct: hline_interp (`ncdirect_hline_interp`)
  * Direct: vline_interp (`ncdirect_vline_interp`)
  * Direct: box (`ncdirect_box`)
  * Direct: rounded_box (`ncdirect_rounded_box`)
  * Direct: double_box (`ncdirect_double_box`)
  * Direct: canopen_images (`ncdirect_canopen_images`)
  * Direct: canutf8 (`ncdirect_canutf8`)
  * Menu: get_mouse_selected (`ncmenu_mouse_selected`)
  * NotCurses: version_components (`notcurses_version_components`)
  * NotCurses: str_blitter (`notcurses_str_blitter`)
  * NotCurses: str_scalemode (`notcurses_str_scalemode`)
  * NotCurses: lex_margins (`notcurses_lex_margins`)
  * NotCurses: lex_blitter (`notcurses_lex_blitter`)
  * NotCurses: lex_scalemode (`notcurses_lex_scalemode`)
  * NotCurses: render_to_file (`notcurses_render_to_file`)
  * Plane: putstr_stainable (`ncplane_putstr_stainable`)
  * Plane: printf_stainable (`ncplane_printf_stainable`)
  * Plane: vprintf_stainable (`ncplane_vprintf_stainable`)
  * Reel: offer_input (`ncreel_offer_input`)

Changed:
  * Direct: set_fg_alpha uses `unsigned alpha`
  * Direct: set_bg_alpha uses `unsigned alpha`
  * Plane: set_fg_alpha uses `unsigned alpha`
  * Plane: set_bg_alpha uses `unsigned alpha`
  * Root: made `error_guard` and `error_guard_cond` static
2020-08-01 00:27:20 -04:00

85 lines
1.7 KiB
C++

#ifndef __NCPP_MENU_HH
#define __NCPP_MENU_HH
#include <notcurses/notcurses.h>
#include "Root.hh"
namespace ncpp
{
class NotCurses;
class Plane;
class NCPP_API_EXPORT Menu : public Root
{
public:
static ncmenu_options default_options;
public:
explicit Menu (const ncmenu_options *opts = nullptr, NotCurses *ncinst = nullptr)
: Root (ncinst)
{
menu = ncmenu_create (notcurses_stdplane (get_notcurses ()), opts == nullptr ? &default_options : opts);
if (menu == nullptr)
throw init_error ("Notcurses failed to create a new menu");
}
~Menu ()
{
if (!is_notcurses_stopped ())
ncmenu_destroy (menu);
}
bool unroll (int sectionidx) const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_unroll (menu, sectionidx), -1);
}
bool rollup () const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_rollup (menu), -1);
}
bool nextsection () const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_nextsection (menu), -1);
}
bool prevsection () const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_prevsection (menu), -1);
}
bool nextitem () const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_nextitem (menu), -1);
}
bool previtem () const NOEXCEPT_MAYBE
{
return error_guard (ncmenu_previtem (menu), -1);
}
const char* get_selected (ncinput *ni = nullptr) const noexcept
{
return ncmenu_selected (menu, ni);
}
const char* get_mouse_selected (const struct ncinput* click, struct ncinput* ni) const noexcept
{
return ncmenu_mouse_selected (menu, click, ni);
}
bool offer_input (const struct ncinput* ni) const noexcept
{
return ncmenu_offer_input (menu, ni);
}
Plane* get_plane () const noexcept;
private:
ncmenu *menu;
};
}
#endif