Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
Widget.hh
Go to the documentation of this file.
1#ifndef __NCPP_WIDGET_HH
2#define __NCPP_WIDGET_HH
3
4#include "Root.hh"
5#include "Plane.hh"
6
7namespace ncpp
8{
9 class NCPP_API_EXPORT Widget : public Root
10 {
11 protected:
12 explicit Widget (NotCurses *ncinst)
13 : Root (ncinst)
14 {}
15
16 void ensure_valid_plane (Plane *plane) const
17 {
18 if (plane == nullptr)
19 throw invalid_argument ("'plane' must be a valid pointer");
20 ensure_valid_plane (*plane);
21 }
22
23 void ensure_valid_plane (Plane &plane) const
24 {
25 if (!plane.is_valid ())
26 throw invalid_argument ("Invalid Plane object passed in 'plane'. Widgets must not reuse the same plane.");
27 }
28
29 void take_plane_ownership (Plane *plane) const
30 {
31 if (plane == nullptr)
32 return;
33
34 take_plane_ownership (*plane);
35 }
36
37 void take_plane_ownership (Plane &plane) const
38 {
39 plane.release_native_plane ();
40 }
41 };
42}
43#endif // __NCPP_WIDGET_HH
#define NCPP_API_EXPORT
Definition _helpers.hh:9
void release_native_plane() noexcept
Definition Plane.hh:1282
bool is_valid() const noexcept
Definition Plane.hh:1239
void ensure_valid_plane(Plane &plane) const
Definition Widget.hh:23
Widget(NotCurses *ncinst)
Definition Widget.hh:12
void take_plane_ownership(Plane *plane) const
Definition Widget.hh:29
void take_plane_ownership(Plane &plane) const
Definition Widget.hh:37
void ensure_valid_plane(Plane *plane) const
Definition Widget.hh:16