1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright 2019,2020 Thomas E. Dickey *
4 * Copyright 1998-2003,2005 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************/
31 /****************************************************************************
32 * Author: Juergen Pfeifer, 1997 *
33 ****************************************************************************/
35 // $Id: cursslk.h,v 1.16 2020/02/29 15:46:00 anonymous.maarten Exp $
37 #ifndef NCURSES_CURSSLK_H_incl
38 #define NCURSES_CURSSLK_H_incl
42 class NCURSES_IMPEXP Soft_Label_Key_Set {
44 // This inner class represents the attributes of a Soft Label Key (SLK)
45 class NCURSES_IMPEXP Soft_Label_Key {
46 friend class Soft_Label_Key_Set;
48 typedef enum { Left=0, Center=1, Right=2 } Justification;
51 char *label; // The Text of the Label
52 Justification format; // The Justification
53 int num; // The number of the Label
55 Soft_Label_Key() : label(NULL), format(Left), num(-1) {
58 virtual ~Soft_Label_Key() {
63 // Set the text of the Label
64 Soft_Label_Key& operator=(char *text);
66 // Set the Justification of the Label
67 Soft_Label_Key& operator=(Justification just) {
72 // Retrieve the text of the label
73 inline char* operator()(void) const {
77 Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
85 Soft_Label_Key(const Soft_Label_Key& rhs)
100 PC_Style_With_Index = 3
104 static long count; // Number of Key Sets
105 static Label_Layout format; // Layout of the Key Sets
106 static int num_labels; // Number Of Labels in Key Sets
107 bool b_attrInit; // Are attributes initialized
109 Soft_Label_Key *slk_array; // The array of SLK's
114 // Activate or Deactivate Label# i, Label counting starts with 1!
115 void activate_label(int i, bool bf=TRUE);
117 // Activate of Deactivate all Labels
118 void activate_labels(bool bf);
121 inline void Error (const char* msg) const THROWS(NCursesException) {
122 THROW(new NCursesException (msg));
125 // Remove SLK's from screen
127 if (ERR==::slk_clear())
133 if (ERR==::slk_restore())
134 Error("slk_restore");
139 // Construct a Key Set, use the most comfortable layout as default.
140 // You must create a Soft_Label_Key_Set before you create any object of
141 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
142 // ::initscr() is called).
143 Soft_Label_Key_Set(Label_Layout fmt);
145 // This constructor assumes, that you already constructed a Key Set
146 // with a layout by the constructor above. This layout will be reused.
147 Soft_Label_Key_Set();
149 Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
153 init(); // allocate a new slk_array[]
158 Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
159 : b_attrInit(rhs.b_attrInit),
162 init(); // allocate a new slk_array[]
165 virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
167 // Get Label# i. Label counting starts with 1!
168 Soft_Label_Key& operator[](int i);
170 // Retrieve number of Labels
171 inline int labels() const { return num_labels; }
173 // Refresh the SLK portion of the screen
174 inline void refresh() {
175 if (ERR==::slk_refresh())
176 Error("slk_refresh");
179 // Mark the SLK portion of the screen for refresh, defer actual refresh
180 // until next update call.
181 inline void noutrefresh() {
182 if (ERR==::slk_noutrefresh())
183 Error("slk_noutrefresh");
186 // Mark the whole SLK portion of the screen as modified
187 inline void touch() {
188 if (ERR==::slk_touch())
193 inline void show(int i) {
194 activate_label(i,FALSE);
195 activate_label(i,TRUE);
199 inline void hide(int i) {
200 activate_label(i,FALSE);
205 activate_labels(FALSE);
206 activate_labels(TRUE);
211 activate_labels(FALSE);
214 inline void attron(attr_t attrs) {
215 if (ERR==::slk_attron(attrs))
219 inline void attroff(attr_t attrs) {
220 if (ERR==::slk_attroff(attrs))
221 Error("slk_attroff");
224 inline void attrset(attr_t attrs) {
225 if (ERR==::slk_attrset(attrs))
226 Error("slk_attrset");
229 inline void color(short color_pair_number) {
230 if (ERR==::slk_color(color_pair_number))
234 inline attr_t attr() const {
239 #endif /* NCURSES_CURSSLK_H_incl */