notcurses/include/ncpp/Pile.hh

58 lines
1.0 KiB
C++
Raw Normal View History

#ifndef __NCPP_PILE_HH
#define __NCPP_PILE_HH
#include <exception>
#include <notcurses/notcurses.h>
#include "NotCurses.hh"
#include "Plane.hh"
namespace ncpp
{
class NCPP_API_EXPORT Pile : public Plane
{
public:
Pile (ncplane_options const* nopts, NotCurses* ncinst = nullptr)
: Plane (ncinst)
{
if (nopts == nullptr) {
throw invalid_argument ("'nopts' must be a valid pointer");
}
notcurses *n;
if (ncinst == nullptr) {
n = NotCurses::get_instance ();
} else {
n = *ncinst;
}
ncplane *pile = ncpile_create (n, nopts);
if (pile == nullptr) {
throw init_error ("Notcurses failed to create a new pile");
}
set_plane (pile);
}
bool render () const NOEXCEPT_MAYBE
{
return error_guard (ncpile_render (to_ncplane ()), -1);
}
bool rasterize () const NOEXCEPT_MAYBE
{
return error_guard (ncpile_rasterize (to_ncplane ()), -1);
}
bool show () const NOEXCEPT_MAYBE
{
if (!render ()) {
return false;
}
return rasterize ();
}
};
}
#endif