notcurses/include/ncpp/Direct.hh
Marek Habersack fc264677f5 Sync C++ wrapper with the latest API changes
New classes:

 * Direct (`ncdirect_*`)
 * Menu (`ncmenu_*`)
 * Selector (`ncselector_*`)

Updates:

 * Plane: added copy constructors (mapped to `ncplane_dup`)
 * Plane: added `perimeter` (`ncplane_perimeter`)
 * Plane: added `polyfill` (`ncplane_polyfill`)
 * Plane: added `blit_bgrx` (`ncblit_bgrx`)
 * Plane: added `blit_rgba` (`ncblit_rgba`)
2020-02-16 06:01:02 -05:00

92 lines
1.8 KiB
C++

#ifndef __NCPP_DIRECT_HH
#define __NCPP_DIRECT_HH
#include <cstdio>
#include <notcurses.h>
#include "Root.hh"
#include "Cell.hh"
namespace ncpp
{
class NCPP_API_EXPORT Direct : public Root
{
public:
explicit Direct (const char *termtype, FILE *fp = nullptr)
{
direct = notcurses_directmode (termtype, fp == nullptr ? stdout : fp);
if (direct == nullptr)
throw new init_error ("notcurses failed to initialize direct mode");
}
~Direct ()
{
ncdirect_stop (direct);
}
bool clear () const noexcept
{
return ncdirect_clear (direct) >= 0;
}
bool set_fg_default () const noexcept
{
return ncdirect_fg_default (direct) >= 0;
}
bool set_fg (unsigned rgb) const noexcept
{
return ncdirect_fg (direct, rgb) >= 0;
}
bool set_fg (unsigned r, unsigned g, unsigned b) const noexcept
{
return ncdirect_fg_rgb8 (direct, r, g, b) >= 0;
}
bool set_bg_default () const noexcept
{
return ncdirect_bg_default (direct) >= 0;
}
bool set_bg (unsigned rgb) const noexcept
{
return ncdirect_bg (direct, rgb) >= 0;
}
bool set_bg (unsigned r, unsigned g, unsigned b) const noexcept
{
return ncdirect_bg_rgb8 (direct, r, g, b) >= 0;
}
int get_dim_x () const noexcept
{
return ncdirect_dim_x (direct);
}
int get_dim_y () const noexcept
{
return ncdirect_dim_y (direct);
}
void styles_set (CellStyle stylebits) const noexcept
{
ncdirect_styles_set (direct, static_cast<unsigned>(stylebits));
}
void styles_on (CellStyle stylebits) const noexcept
{
ncdirect_styles_on (direct, static_cast<unsigned>(stylebits));
}
void styles_off (CellStyle stylebits) const noexcept
{
ncdirect_styles_off (direct, static_cast<unsigned>(stylebits));
}
private:
ncdirect *direct;
};
}
#endif