1 // * this is for making emacs happy: -*-Mode: C++;-*-
3 /****************************************************************************
4 * Copyright 2019-2020,2021 Thomas E. Dickey *
5 * Copyright 1998-2003,2005 Free Software Foundation, Inc. *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
30 ****************************************************************************/
32 /****************************************************************************
33 * Author: Juergen Pfeifer, 1997 *
34 ****************************************************************************/
36 // $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $
38 #ifndef NCURSES_CURSSLK_H_incl
39 #define NCURSES_CURSSLK_H_incl
43 class NCURSES_CXX_IMPEXP Soft_Label_Key_Set {
45 // This inner class represents the attributes of a Soft Label Key (SLK)
46 class NCURSES_CXX_IMPEXP Soft_Label_Key {
47 friend class Soft_Label_Key_Set;
49 typedef enum { Left=0, Center=1, Right=2 } Justification;
52 char *label; // The Text of the Label
53 Justification format; // The Justification
54 int num; // The number of the Label
56 Soft_Label_Key() : label(NULL), format(Left), num(-1) {
59 virtual ~Soft_Label_Key() {
64 // Set the text of the Label
65 Soft_Label_Key& operator=(char *text);
67 // Set the Justification of the Label
68 Soft_Label_Key& operator=(Justification just) {
73 // Retrieve the text of the label
74 inline char* operator()(void) const {
78 Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
86 Soft_Label_Key(const Soft_Label_Key& rhs)
101 PC_Style_With_Index = 3
105 static long count; // Number of Key Sets
106 static Label_Layout format; // Layout of the Key Sets
107 static int num_labels; // Number Of Labels in Key Sets
108 bool b_attrInit; // Are attributes initialized
110 Soft_Label_Key *slk_array; // The array of SLK's
115 // Activate or Deactivate Label# i, Label counting starts with 1!
116 void activate_label(int i, bool bf=TRUE);
118 // Activate of Deactivate all Labels
119 void activate_labels(bool bf);
122 inline void Error (const char* msg) const THROWS(NCursesException) {
123 THROW(new NCursesException (msg));
126 // Remove SLK's from screen
128 if (ERR==::slk_clear())
134 if (ERR==::slk_restore())
135 Error("slk_restore");
140 // Construct a Key Set, use the most comfortable layout as default.
141 // You must create a Soft_Label_Key_Set before you create any object of
142 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
143 // ::initscr() is called).
144 explicit Soft_Label_Key_Set(Label_Layout fmt);
146 // This constructor assumes, that you already constructed a Key Set
147 // with a layout by the constructor above. This layout will be reused.
148 Soft_Label_Key_Set();
150 Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
154 init(); // allocate a new slk_array[]
159 Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
160 : b_attrInit(rhs.b_attrInit),
163 init(); // allocate a new slk_array[]
166 virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
168 // Get Label# i. Label counting starts with 1!
169 Soft_Label_Key& operator[](int i);
171 // Retrieve number of Labels
174 // Refresh the SLK portion of the screen
175 inline void refresh() {
176 if (ERR==::slk_refresh())
177 Error("slk_refresh");
180 // Mark the SLK portion of the screen for refresh, defer actual refresh
181 // until next update call.
182 inline void noutrefresh() {
183 if (ERR==::slk_noutrefresh())
184 Error("slk_noutrefresh");
187 // Mark the whole SLK portion of the screen as modified
188 inline void touch() {
189 if (ERR==::slk_touch())
194 inline void show(int i) {
195 activate_label(i,FALSE);
196 activate_label(i,TRUE);
200 inline void hide(int i) {
201 activate_label(i,FALSE);
206 activate_labels(FALSE);
207 activate_labels(TRUE);
212 activate_labels(FALSE);
215 inline void attron(attr_t attrs) {
216 if (ERR==::slk_attron(attrs))
220 inline void attroff(attr_t attrs) {
221 if (ERR==::slk_attroff(attrs))
222 Error("slk_attroff");
225 inline void attrset(attr_t attrs) {
226 if (ERR==::slk_attrset(attrs))
227 Error("slk_attrset");
230 inline void color(short color_pair_number) {
231 if (ERR==::slk_color(color_pair_number))
235 inline attr_t attr() const {
240 #endif /* NCURSES_CURSSLK_H_incl */