1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1997 *
32 ****************************************************************************/
34 // $Id: cursslk.h,v 1.13 2005/05/28 21:58:18 tom Exp $
36 #ifndef NCURSES_CURSSLK_H_incl
37 #define NCURSES_CURSSLK_H_incl
41 class NCURSES_IMPEXP Soft_Label_Key_Set {
43 // This inner class represents the attributes of a Soft Label Key (SLK)
44 class NCURSES_IMPEXP Soft_Label_Key {
45 friend class Soft_Label_Key_Set;
47 typedef enum { Left=0, Center=1, Right=2 } Justification;
50 char *label; // The Text of the Label
51 Justification format; // The Justification
52 int num; // The number of the Label
54 Soft_Label_Key() : label(NULL), format(Left), num(-1) {
57 virtual ~Soft_Label_Key() {
62 // Set the text of the Label
63 Soft_Label_Key& operator=(char *text);
65 // Set the Justification of the Label
66 Soft_Label_Key& operator=(Justification just) {
71 // Retrieve the text of the label
72 inline char* operator()(void) const {
76 Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
84 Soft_Label_Key(const Soft_Label_Key& rhs)
99 PC_Style_With_Index = 3
103 static long NCURSES_IMPEXP count; // Number of Key Sets
104 static Label_Layout NCURSES_IMPEXP format; // Layout of the Key Sets
105 static int NCURSES_IMPEXP num_labels; // Number Of Labels in Key Sets
106 bool NCURSES_IMPEXP b_attrInit; // Are attributes initialized
108 Soft_Label_Key *slk_array; // The array of SLK's
113 // Activate or Deactivate Label# i, Label counting starts with 1!
114 void activate_label(int i, bool bf=TRUE);
116 // Activate of Deactivate all Labels
117 void activate_labels(bool bf);
120 inline void Error (const char* msg) const THROWS(NCursesException) {
121 THROW(new NCursesException (msg));
124 // Remove SLK's from screen
126 if (ERR==::slk_clear())
132 if (ERR==::slk_restore())
133 Error("slk_restore");
138 // Construct a Key Set, use the most comfortable layout as default.
139 // You must create a Soft_Label_Key_Set before you create any object of
140 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
141 // ::initscr() is called).
142 Soft_Label_Key_Set(Label_Layout fmt);
144 // This constructor assumes, that you already constructed a Key Set
145 // with a layout by the constructor above. This layout will be reused.
146 NCURSES_IMPEXP Soft_Label_Key_Set();
148 Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
152 init(); // allocate a new slk_array[]
157 Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
158 : b_attrInit(rhs.b_attrInit),
161 init(); // allocate a new slk_array[]
164 virtual ~Soft_Label_Key_Set();
166 // Get Label# i. Label counting starts with 1!
167 NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
169 // Retrieve number of Labels
170 inline int labels() const { return num_labels; }
172 // Refresh the SLK portion of the screen
173 inline void refresh() {
174 if (ERR==::slk_refresh())
175 Error("slk_refresh");
178 // Mark the SLK portion of the screen for refresh, defer actual refresh
179 // until next update call.
180 inline void noutrefresh() {
181 if (ERR==::slk_noutrefresh())
182 Error("slk_noutrefresh");
185 // Mark the whole SLK portion of the screen as modified
186 inline void touch() {
187 if (ERR==::slk_touch())
192 inline void show(int i) {
193 activate_label(i,FALSE);
194 activate_label(i,TRUE);
198 inline void hide(int i) {
199 activate_label(i,FALSE);
204 activate_labels(FALSE);
205 activate_labels(TRUE);
210 activate_labels(FALSE);
213 inline void attron(attr_t attrs) {
214 if (ERR==::slk_attron(attrs))
218 inline void attroff(attr_t attrs) {
219 if (ERR==::slk_attroff(attrs))
220 Error("slk_attroff");
223 inline void attrset(attr_t attrs) {
224 if (ERR==::slk_attrset(attrs))
225 Error("slk_attrset");
228 inline void color(short color_pair_number) {
229 if (ERR==::slk_color(color_pair_number))
233 inline attr_t attr() const {
238 #endif /* NCURSES_CURSSLK_H_incl */