X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=c%2B%2B%2Fcursslk.h;h=091695eef27a9489e37afc3798b9b1ec9b82a403;hp=f2e2570151c3da58a9faff4b306fb0599f0230a7;hb=7d3e03f12f3e179f5780f733fa5b78d981080d48;hpb=661078ddbde3ce0f3b06e95642fbb9b5fef7dca1;ds=sidebyside diff --git a/c++/cursslk.h b/c++/cursslk.h index f2e25701..091695ee 100644 --- a/c++/cursslk.h +++ b/c++/cursslk.h @@ -1,6 +1,6 @@ // * this is for making emacs happy: -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -28,20 +28,20 @@ ****************************************************************************/ /**************************************************************************** - * Author: Juergen Pfeifer 1997 * + * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ -// $Id: cursslk.h,v 1.2 1998/02/11 12:13:41 tom Exp $ +// $Id: cursslk.h,v 1.13 2005/05/28 21:58:18 tom Exp $ -#ifndef _CURSSLK_H -#define _CURSSLK_H +#ifndef NCURSES_CURSSLK_H_incl +#define NCURSES_CURSSLK_H_incl #include -class Soft_Label_Key_Set { +class NCURSES_IMPEXP Soft_Label_Key_Set { public: // This inner class represents the attributes of a Soft Label Key (SLK) - class Soft_Label_Key { + class NCURSES_IMPEXP Soft_Label_Key { friend class Soft_Label_Key_Set; public: typedef enum { Left=0, Center=1, Right=2 } Justification; @@ -51,28 +51,45 @@ public: Justification format; // The Justification int num; // The number of the Label - Soft_Label_Key() : label((char*)0),format(Left),num(-1) { + Soft_Label_Key() : label(NULL), format(Left), num(-1) { } - + virtual ~Soft_Label_Key() { delete[] label; }; public: // Set the text of the Label - void operator=(char *text); - + Soft_Label_Key& operator=(char *text); + // Set the Justification of the Label - inline void operator=(Justification just) { + Soft_Label_Key& operator=(Justification just) { format = just; + return *this; } - + // Retrieve the text of the label inline char* operator()(void) const { - return label; + 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, @@ -83,11 +100,11 @@ public: } Label_Layout; private: - static long count; // Number of Key Sets - static Label_Layout format; // Layout of the Key Sets - static int num_labels; // Number Of Labels in Key Sets - bool b_attrInit; // Are attributes initialized - + static long NCURSES_IMPEXP count; // Number of Key Sets + static Label_Layout NCURSES_IMPEXP format; // Layout of the Key Sets + static int NCURSES_IMPEXP num_labels; // Number Of Labels in Key Sets + bool NCURSES_IMPEXP b_attrInit; // Are attributes initialized + Soft_Label_Key *slk_array; // The array of SLK's // Init the Key Set @@ -105,13 +122,13 @@ protected: } // Remove SLK's from screen - void clear() { + void clear() { if (ERR==::slk_clear()) Error("slk_clear"); - } + } // Restore them - void restore() { + void restore() { if (ERR==::slk_restore()) Error("slk_restore"); } @@ -126,31 +143,47 @@ public: // This constructor assumes, that you already constructed a Key Set // with a layout by the constructor above. This layout will be reused. - Soft_Label_Key_Set(); + NCURSES_IMPEXP Soft_Label_Key_Set(); + + Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs) + { + if (this != &rhs) { + *this = rhs; + init(); // allocate a new slk_array[] + } + return *this; + } + + Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs) + : b_attrInit(rhs.b_attrInit), + slk_array(NULL) + { + init(); // allocate a new slk_array[] + } virtual ~Soft_Label_Key_Set(); // Get Label# i. Label counting starts with 1! - Soft_Label_Key& operator[](int i); + NCURSES_IMPEXP Soft_Label_Key& operator[](int i); // Retrieve number of Labels - inline int labels() const { return num_labels; } + inline int labels() const { return num_labels; } // Refresh the SLK portion of the screen - inline void refresh() { + inline void refresh() { if (ERR==::slk_refresh()) Error("slk_refresh"); } // Mark the SLK portion of the screen for refresh, defer actual refresh // until next update call. - inline void noutrefresh() { + inline void noutrefresh() { if (ERR==::slk_noutrefresh()) Error("slk_noutrefresh"); } // Mark the whole SLK portion of the screen as modified - inline void touch() { + inline void touch() { if (ERR==::slk_touch()) Error("slk_touch"); } @@ -192,9 +225,14 @@ public: 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 // _CURSSLK_H +#endif /* NCURSES_CURSSLK_H_incl */