1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998 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 <juergen.pfeifer@gmx.net> 1997 *
32 ****************************************************************************/
34 // $Id: cursslk.h,v 1.5 1999/05/16 17:30:08 juergen Exp $
41 class Soft_Label_Key_Set {
43 // This inner class represents the attributes of a Soft Label Key (SLK)
44 class 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((char*)0),format(Left),num(-1) {
57 virtual ~Soft_Label_Key() {
62 // Set the text of the Label
63 void operator=(char *text);
65 // Set the Justification of the Label
66 inline void operator=(Justification just) {
70 // Retrieve the text of the label
71 inline char* operator()(void) const {
82 PC_Style_With_Index = 3
86 static long count; // Number of Key Sets
87 static Label_Layout format; // Layout of the Key Sets
88 static int num_labels; // Number Of Labels in Key Sets
89 bool b_attrInit; // Are attributes initialized
91 Soft_Label_Key *slk_array; // The array of SLK's
96 // Activate or Deactivate Label# i, Label counting starts with 1!
97 void activate_label(int i, bool bf=TRUE);
99 // Activate of Deactivate all Labels
100 void activate_labels(bool bf);
103 inline void Error (const char* msg) const THROWS(NCursesException) {
104 THROW(new NCursesException (msg));
107 // Remove SLK's from screen
109 if (ERR==::slk_clear())
115 if (ERR==::slk_restore())
116 Error("slk_restore");
121 // Construct a Key Set, use the most comfortable layout as default.
122 // You must create a Soft_Label_Key_Set before you create any object of
123 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
124 // ::initscr() is called).
125 Soft_Label_Key_Set(Label_Layout fmt);
127 // This constructor assumes, that you already constructed a Key Set
128 // with a layout by the constructor above. This layout will be reused.
129 Soft_Label_Key_Set();
131 virtual ~Soft_Label_Key_Set();
133 // Get Label# i. Label counting starts with 1!
134 Soft_Label_Key& operator[](int i);
136 // Retrieve number of Labels
137 inline int labels() const { return num_labels; }
139 // Refresh the SLK portion of the screen
140 inline void refresh() {
141 if (ERR==::slk_refresh())
142 Error("slk_refresh");
145 // Mark the SLK portion of the screen for refresh, defer actual refresh
146 // until next update call.
147 inline void noutrefresh() {
148 if (ERR==::slk_noutrefresh())
149 Error("slk_noutrefresh");
152 // Mark the whole SLK portion of the screen as modified
153 inline void touch() {
154 if (ERR==::slk_touch())
159 inline void show(int i) {
160 activate_label(i,FALSE);
161 activate_label(i,TRUE);
165 inline void hide(int i) {
166 activate_label(i,FALSE);
171 activate_labels(FALSE);
172 activate_labels(TRUE);
177 activate_labels(FALSE);
180 inline void attron(attr_t attrs) {
181 if (ERR==::slk_attron(attrs))
185 inline void attroff(attr_t attrs) {
186 if (ERR==::slk_attroff(attrs))
187 Error("slk_attroff");
190 inline void attrset(attr_t attrs) {
191 if (ERR==::slk_attrset(attrs))
192 Error("slk_attrset");
195 inline void color(short color_pair_number) {
196 if (ERR==::slk_color(color_pair_number))
200 inline attr_t attr() const {