1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998,2000 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 * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en *
33 ****************************************************************************/
35 // $Id: cursslk.h,v 1.8 2002/07/06 15:47:52 juergen 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((char*)0),format(Left),num(-1) {
58 virtual ~Soft_Label_Key() {
63 // Set the text of the Label
64 void operator=(char *text);
66 // Set the Justification of the Label
67 inline void operator=(Justification just) {
71 // Retrieve the text of the label
72 inline char* operator()(void) const {
83 PC_Style_With_Index = 3
87 static long NCURSES_IMPEXP count; // Number of Key Sets
88 static Label_Layout NCURSES_IMPEXP format; // Layout of the Key Sets
89 static int NCURSES_IMPEXP num_labels; // Number Of Labels in Key Sets
90 bool NCURSES_IMPEXP b_attrInit; // Are attributes initialized
92 Soft_Label_Key *slk_array; // The array of SLK's
97 // Activate or Deactivate Label# i, Label counting starts with 1!
98 void activate_label(int i, bool bf=TRUE);
100 // Activate of Deactivate all Labels
101 void activate_labels(bool bf);
104 inline void Error (const char* msg) const THROWS(NCursesException) {
105 THROW(new NCursesException (msg));
108 // Remove SLK's from screen
110 if (ERR==::slk_clear())
116 if (ERR==::slk_restore())
117 Error("slk_restore");
122 // Construct a Key Set, use the most comfortable layout as default.
123 // You must create a Soft_Label_Key_Set before you create any object of
124 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
125 // ::initscr() is called).
126 Soft_Label_Key_Set(Label_Layout fmt);
128 // This constructor assumes, that you already constructed a Key Set
129 // with a layout by the constructor above. This layout will be reused.
130 NCURSES_IMPEXP Soft_Label_Key_Set();
132 virtual ~Soft_Label_Key_Set();
134 // Get Label# i. Label counting starts with 1!
135 NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
137 // Retrieve number of Labels
138 inline int labels() const { return num_labels; }
140 // Refresh the SLK portion of the screen
141 inline void refresh() {
142 if (ERR==::slk_refresh())
143 Error("slk_refresh");
146 // Mark the SLK portion of the screen for refresh, defer actual refresh
147 // until next update call.
148 inline void noutrefresh() {
149 if (ERR==::slk_noutrefresh())
150 Error("slk_noutrefresh");
153 // Mark the whole SLK portion of the screen as modified
154 inline void touch() {
155 if (ERR==::slk_touch())
160 inline void show(int i) {
161 activate_label(i,FALSE);
162 activate_label(i,TRUE);
166 inline void hide(int i) {
167 activate_label(i,FALSE);
172 activate_labels(FALSE);
173 activate_labels(TRUE);
178 activate_labels(FALSE);
181 inline void attron(attr_t attrs) {
182 if (ERR==::slk_attron(attrs))
186 inline void attroff(attr_t attrs) {
187 if (ERR==::slk_attroff(attrs))
188 Error("slk_attroff");
191 inline void attrset(attr_t attrs) {
192 if (ERR==::slk_attrset(attrs))
193 Error("slk_attrset");
196 inline void color(short color_pair_number) {
197 if (ERR==::slk_color(color_pair_number))
201 inline attr_t attr() const {
206 #endif // NCURSES_CURSSLK_H_incl