You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
notcurses/include/ncpp/Tablet.hh

64 lines
1.1 KiB
C++

5 years ago
#ifndef __NCPP_TABLET_HH
#define __NCPP_TABLET_HH
#include <map>
#include <mutex>
#include <notcurses/notcurses.h>
5 years ago
#include "Root.hh"
namespace ncpp
{
class Plane;
class NotCurses;
5 years ago
class NCPP_API_EXPORT NcTablet : public Root
5 years ago
{
protected:
explicit NcTablet (nctablet *t, NotCurses *ncinst)
: Root (ncinst),
_tablet (t)
5 years ago
{
if (t == nullptr)
throw invalid_argument ("'t' must be a valid pointer");
5 years ago
};
public:
template<typename T>
T* get_userptr () const noexcept
{
return static_cast<T*>(nctablet_userptr (_tablet));
5 years ago
}
operator nctablet* () const noexcept
5 years ago
{
return _tablet;
}
operator nctablet const* () const noexcept
5 years ago
{
return _tablet;
}
Plane* get_plane () const noexcept;
static NcTablet* map_tablet (nctablet *t, NotCurses *ncinst = nullptr) noexcept;
5 years ago
protected:
static void unmap_tablet (NcTablet *p) noexcept;
5 years ago
nctablet* get_tablet () const noexcept
5 years ago
{
return _tablet;
}
private:
nctablet *_tablet = nullptr;
static std::map<nctablet*,NcTablet*> *tablet_map;
5 years ago
static std::mutex tablet_map_mutex;
friend class NcReel;
5 years ago
};
}
#endif