123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- #ifndef NCURSES_CURSSLK_H_incl
- #define NCURSES_CURSSLK_H_incl
- #include <cursesw.h>
- class NCURSES_IMPEXP Soft_Label_Key_Set {
- public:
-
- class NCURSES_IMPEXP Soft_Label_Key {
- friend class Soft_Label_Key_Set;
- public:
- typedef enum { Left=0, Center=1, Right=2 } Justification;
- private:
- char *label;
- Justification format;
- int num;
- Soft_Label_Key() : label(NULL), format(Left), num(-1) {
- }
- virtual ~Soft_Label_Key() {
- delete[] label;
- };
- public:
-
- Soft_Label_Key& operator=(char *text);
-
- Soft_Label_Key& operator=(Justification just) {
- format = just;
- return *this;
- }
-
- inline char* operator()(void) const {
- return label;
- }
- Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
- {
- if (this != &rhs) {
- *this = rhs;
- }
- return *this;
- }
- Soft_Label_Key(const Soft_Label_Key& rhs)
- : label(NULL),
- format(rhs.format),
- num(rhs.num)
- {
- *this = rhs.label;
- }
- };
- public:
- typedef enum {
- None = -1,
- Three_Two_Three = 0,
- Four_Four = 1,
- PC_Style = 2,
- PC_Style_With_Index = 3
- } Label_Layout;
- private:
- static long NCURSES_IMPEXP count;
- static Label_Layout NCURSES_IMPEXP format;
- static int NCURSES_IMPEXP num_labels;
- bool NCURSES_IMPEXP b_attrInit;
- Soft_Label_Key *slk_array;
-
- void init();
-
- void activate_label(int i, bool bf=TRUE);
-
- void activate_labels(bool bf);
- protected:
- inline void Error (const char* msg) const THROWS(NCursesException) {
- THROW(new NCursesException (msg));
- }
-
- void clear() {
- if (ERR==::slk_clear())
- Error("slk_clear");
- }
-
- void restore() {
- if (ERR==::slk_restore())
- Error("slk_restore");
- }
- public:
-
-
-
-
- Soft_Label_Key_Set(Label_Layout fmt);
-
-
- NCURSES_IMPEXP Soft_Label_Key_Set();
- Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
- {
- if (this != &rhs) {
- *this = rhs;
- init();
- }
- return *this;
- }
- Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
- : b_attrInit(rhs.b_attrInit),
- slk_array(NULL)
- {
- init();
- }
- virtual ~Soft_Label_Key_Set();
-
- NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
-
- inline int labels() const { return num_labels; }
-
- inline void refresh() {
- if (ERR==::slk_refresh())
- Error("slk_refresh");
- }
-
-
- inline void noutrefresh() {
- if (ERR==::slk_noutrefresh())
- Error("slk_noutrefresh");
- }
-
- inline void touch() {
- if (ERR==::slk_touch())
- Error("slk_touch");
- }
-
- inline void show(int i) {
- activate_label(i,FALSE);
- activate_label(i,TRUE);
- }
-
- inline void hide(int i) {
- activate_label(i,FALSE);
- }
-
- inline void show() {
- activate_labels(FALSE);
- activate_labels(TRUE);
- }
-
- inline void hide() {
- activate_labels(FALSE);
- }
- inline void attron(attr_t attrs) {
- if (ERR==::slk_attron(attrs))
- Error("slk_attron");
- }
- inline void attroff(attr_t attrs) {
- if (ERR==::slk_attroff(attrs))
- Error("slk_attroff");
- }
- inline void attrset(attr_t attrs) {
- if (ERR==::slk_attrset(attrs))
- Error("slk_attrset");
- }
- inline void color(short color_pair_number) {
- if (ERR==::slk_color(color_pair_number))
- Error("slk_color");
- }
- inline attr_t attr() const {
- return ::slk_attr();
- }
- };
- #endif
|