Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
Palette Class Reference

#include <Palette.hh>

Inheritance diagram for Palette:
Collaboration diagram for Palette:

Public Member Functions

 Palette (NotCurses *ncinst=nullptr)
 
 ~Palette ()
 
 operator ncpalette * () noexcept
 
 operator ncpalette const * () const noexcept
 
bool set (int idx, int r, int g, int b) const NOEXCEPT_MAYBE
 
bool set (int idx, unsigned rgb) const NOEXCEPT_MAYBE
 
bool get (int idx, unsigned *r, unsigned *g, unsigned *b) const
 
bool get (int idx, unsigned &r, unsigned &g, unsigned &b) const NOEXCEPT_MAYBE
 
- Public Member Functions inherited from Root
notcursesget_notcurses () const
 
NotCursesget_notcurses_cpp () const
 

Additional Inherited Members

- Protected Member Functions inherited from Root
 Root (NotCurses *ncinst)
 
bool is_notcurses_stopped () const noexcept
 
- Static Protected Member Functions inherited from Root
template<typename TRet = bool, typename TValue = int>
static TRet error_guard (TValue ret, TValue error_value)
 
template<typename TRet = bool, typename TValue = int>
static TRet error_guard_cond (TValue ret, bool error_value)
 
- Static Protected Attributes inherited from Root
static constexpr char ncpp_invalid_state_message [] = "notcurses++ is in an invalid state (already stopped?)"
 

Detailed Description

Definition at line 11 of file Palette.hh.

Constructor & Destructor Documentation

◆ Palette()

Palette ( NotCurses ncinst = nullptr)
inline

Definition at line 14 of file Palette.hh.

15 : Root (ncinst)
16 {
17 palette = ncpalette_new (get_notcurses ());
18 if (palette == nullptr)
19 throw init_error ("Notcurses failed to create a new palette");
20 }
notcurses * get_notcurses() const
Root(NotCurses *ncinst)
Definition Root.hh:34
static TRet error_guard(TValue ret, TValue error_value)
Definition Root.hh:39
ncpalette * ncpalette_new(notcurses *nc)
Definition notcurses.c:2563
Here is the call graph for this function:

◆ ~Palette()

~Palette ( )
inline

Definition at line 22 of file Palette.hh.

23 {
24 ncpalette_free (palette);
25 }
void ncpalette_free(ncpalette *p)
Definition notcurses.c:2586
Here is the call graph for this function:

Member Function Documentation

◆ get() [1/2]

bool get ( int  idx,
unsigned r,
unsigned g,
unsigned b 
) const
inline

Definition at line 59 of file Palette.hh.

60 {
61 return error_guard (ncpalette_get_rgb8 (palette, idx, &r, &g, &b), -1);
62 }
uint32_t idx
Definition egcpool.h:298
int r
Definition fbuf.h:226

◆ get() [2/2]

bool get ( int  idx,
unsigned r,
unsigned g,
unsigned b 
) const
inline

Definition at line 47 of file Palette.hh.

48 {
49 if (r == nullptr)
50 throw invalid_argument ("'r' must be a valid pointer");
51 if (g == nullptr)
52 throw invalid_argument ("'g' must be a valid pointer");
53 if (b == nullptr)
54 throw invalid_argument ("'b' must be a valid pointer");
55
56 return get (idx, *r, *g, *b);
57 }
bool get(int idx, unsigned *r, unsigned *g, unsigned *b) const
Definition Palette.hh:47

◆ operator ncpalette *()

operator ncpalette * ( )
inlinenoexcept

Definition at line 27 of file Palette.hh.

28 {
29 return palette;
30 }

◆ operator ncpalette const *()

operator ncpalette const * ( ) const
inlinenoexcept

Definition at line 32 of file Palette.hh.

33 {
34 return palette;
35 }

◆ set() [1/2]

bool set ( int  idx,
int  r,
int  g,
int  b 
) const
inline

Definition at line 37 of file Palette.hh.

38 {
39 return error_guard (ncpalette_set_rgb8 (palette, idx, r, g, b), -1);
40 }

◆ set() [2/2]

bool set ( int  idx,
unsigned  rgb 
) const
inline

Definition at line 42 of file Palette.hh.

43 {
44 return error_guard (ncpalette_set (palette, idx, rgb), -1);
45 }

The documentation for this class was generated from the following file: