annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/cursslk.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // * this is for making emacs happy: -*-Mode: C++;-*-
jpayne@69 2 // vile:cppmode
jpayne@69 3 /****************************************************************************
jpayne@69 4 * Copyright 2019-2020,2021 Thomas E. Dickey *
jpayne@69 5 * Copyright 1998-2003,2005 Free Software Foundation, Inc. *
jpayne@69 6 * *
jpayne@69 7 * Permission is hereby granted, free of charge, to any person obtaining a *
jpayne@69 8 * copy of this software and associated documentation files (the *
jpayne@69 9 * "Software"), to deal in the Software without restriction, including *
jpayne@69 10 * without limitation the rights to use, copy, modify, merge, publish, *
jpayne@69 11 * distribute, distribute with modifications, sublicense, and/or sell *
jpayne@69 12 * copies of the Software, and to permit persons to whom the Software is *
jpayne@69 13 * furnished to do so, subject to the following conditions: *
jpayne@69 14 * *
jpayne@69 15 * The above copyright notice and this permission notice shall be included *
jpayne@69 16 * in all copies or substantial portions of the Software. *
jpayne@69 17 * *
jpayne@69 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
jpayne@69 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
jpayne@69 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
jpayne@69 21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
jpayne@69 22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
jpayne@69 23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
jpayne@69 24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
jpayne@69 25 * *
jpayne@69 26 * Except as contained in this notice, the name(s) of the above copyright *
jpayne@69 27 * holders shall not be used in advertising or otherwise to promote the *
jpayne@69 28 * sale, use or other dealings in this Software without prior written *
jpayne@69 29 * authorization. *
jpayne@69 30 ****************************************************************************/
jpayne@69 31
jpayne@69 32 /****************************************************************************
jpayne@69 33 * Author: Juergen Pfeifer, 1997 *
jpayne@69 34 ****************************************************************************/
jpayne@69 35
jpayne@69 36 // $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $
jpayne@69 37
jpayne@69 38 #ifndef NCURSES_CURSSLK_H_incl
jpayne@69 39 #define NCURSES_CURSSLK_H_incl
jpayne@69 40
jpayne@69 41 #include <ncursesw/cursesw.h>
jpayne@69 42
jpayne@69 43 class NCURSES_CXX_IMPEXP Soft_Label_Key_Set {
jpayne@69 44 public:
jpayne@69 45 // This inner class represents the attributes of a Soft Label Key (SLK)
jpayne@69 46 class NCURSES_CXX_IMPEXP Soft_Label_Key {
jpayne@69 47 friend class Soft_Label_Key_Set;
jpayne@69 48 public:
jpayne@69 49 typedef enum { Left=0, Center=1, Right=2 } Justification;
jpayne@69 50
jpayne@69 51 private:
jpayne@69 52 char *label; // The Text of the Label
jpayne@69 53 Justification format; // The Justification
jpayne@69 54 int num; // The number of the Label
jpayne@69 55
jpayne@69 56 Soft_Label_Key() : label(NULL), format(Left), num(-1) {
jpayne@69 57 }
jpayne@69 58
jpayne@69 59 virtual ~Soft_Label_Key() {
jpayne@69 60 delete[] label;
jpayne@69 61 };
jpayne@69 62
jpayne@69 63 public:
jpayne@69 64 // Set the text of the Label
jpayne@69 65 Soft_Label_Key& operator=(char *text);
jpayne@69 66
jpayne@69 67 // Set the Justification of the Label
jpayne@69 68 Soft_Label_Key& operator=(Justification just) {
jpayne@69 69 format = just;
jpayne@69 70 return *this;
jpayne@69 71 }
jpayne@69 72
jpayne@69 73 // Retrieve the text of the label
jpayne@69 74 inline char* operator()(void) const {
jpayne@69 75 return label;
jpayne@69 76 }
jpayne@69 77
jpayne@69 78 Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
jpayne@69 79 {
jpayne@69 80 if (this != &rhs) {
jpayne@69 81 *this = rhs;
jpayne@69 82 }
jpayne@69 83 return *this;
jpayne@69 84 }
jpayne@69 85
jpayne@69 86 Soft_Label_Key(const Soft_Label_Key& rhs)
jpayne@69 87 : label(NULL),
jpayne@69 88 format(rhs.format),
jpayne@69 89 num(rhs.num)
jpayne@69 90 {
jpayne@69 91 *this = rhs.label;
jpayne@69 92 }
jpayne@69 93 };
jpayne@69 94
jpayne@69 95 public:
jpayne@69 96 typedef enum {
jpayne@69 97 None = -1,
jpayne@69 98 Three_Two_Three = 0,
jpayne@69 99 Four_Four = 1,
jpayne@69 100 PC_Style = 2,
jpayne@69 101 PC_Style_With_Index = 3
jpayne@69 102 } Label_Layout;
jpayne@69 103
jpayne@69 104 private:
jpayne@69 105 static long count; // Number of Key Sets
jpayne@69 106 static Label_Layout format; // Layout of the Key Sets
jpayne@69 107 static int num_labels; // Number Of Labels in Key Sets
jpayne@69 108 bool b_attrInit; // Are attributes initialized
jpayne@69 109
jpayne@69 110 Soft_Label_Key *slk_array; // The array of SLK's
jpayne@69 111
jpayne@69 112 // Init the Key Set
jpayne@69 113 void init();
jpayne@69 114
jpayne@69 115 // Activate or Deactivate Label# i, Label counting starts with 1!
jpayne@69 116 void activate_label(int i, bool bf=TRUE);
jpayne@69 117
jpayne@69 118 // Activate of Deactivate all Labels
jpayne@69 119 void activate_labels(bool bf);
jpayne@69 120
jpayne@69 121 protected:
jpayne@69 122 inline void Error (const char* msg) const THROWS(NCursesException) {
jpayne@69 123 THROW(new NCursesException (msg));
jpayne@69 124 }
jpayne@69 125
jpayne@69 126 // Remove SLK's from screen
jpayne@69 127 void clear() {
jpayne@69 128 if (ERR==::slk_clear())
jpayne@69 129 Error("slk_clear");
jpayne@69 130 }
jpayne@69 131
jpayne@69 132 // Restore them
jpayne@69 133 void restore() {
jpayne@69 134 if (ERR==::slk_restore())
jpayne@69 135 Error("slk_restore");
jpayne@69 136 }
jpayne@69 137
jpayne@69 138 public:
jpayne@69 139
jpayne@69 140 // Construct a Key Set, use the most comfortable layout as default.
jpayne@69 141 // You must create a Soft_Label_Key_Set before you create any object of
jpayne@69 142 // the NCursesWindow, NCursesPanel or derived classes. (Actually before
jpayne@69 143 // ::initscr() is called).
jpayne@69 144 explicit Soft_Label_Key_Set(Label_Layout fmt);
jpayne@69 145
jpayne@69 146 // This constructor assumes, that you already constructed a Key Set
jpayne@69 147 // with a layout by the constructor above. This layout will be reused.
jpayne@69 148 Soft_Label_Key_Set();
jpayne@69 149
jpayne@69 150 Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
jpayne@69 151 {
jpayne@69 152 if (this != &rhs) {
jpayne@69 153 *this = rhs;
jpayne@69 154 init(); // allocate a new slk_array[]
jpayne@69 155 }
jpayne@69 156 return *this;
jpayne@69 157 }
jpayne@69 158
jpayne@69 159 Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
jpayne@69 160 : b_attrInit(rhs.b_attrInit),
jpayne@69 161 slk_array(NULL)
jpayne@69 162 {
jpayne@69 163 init(); // allocate a new slk_array[]
jpayne@69 164 }
jpayne@69 165
jpayne@69 166 virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
jpayne@69 167
jpayne@69 168 // Get Label# i. Label counting starts with 1!
jpayne@69 169 Soft_Label_Key& operator[](int i);
jpayne@69 170
jpayne@69 171 // Retrieve number of Labels
jpayne@69 172 int labels() const;
jpayne@69 173
jpayne@69 174 // Refresh the SLK portion of the screen
jpayne@69 175 inline void refresh() {
jpayne@69 176 if (ERR==::slk_refresh())
jpayne@69 177 Error("slk_refresh");
jpayne@69 178 }
jpayne@69 179
jpayne@69 180 // Mark the SLK portion of the screen for refresh, defer actual refresh
jpayne@69 181 // until next update call.
jpayne@69 182 inline void noutrefresh() {
jpayne@69 183 if (ERR==::slk_noutrefresh())
jpayne@69 184 Error("slk_noutrefresh");
jpayne@69 185 }
jpayne@69 186
jpayne@69 187 // Mark the whole SLK portion of the screen as modified
jpayne@69 188 inline void touch() {
jpayne@69 189 if (ERR==::slk_touch())
jpayne@69 190 Error("slk_touch");
jpayne@69 191 }
jpayne@69 192
jpayne@69 193 // Activate Label# i
jpayne@69 194 inline void show(int i) {
jpayne@69 195 activate_label(i,FALSE);
jpayne@69 196 activate_label(i,TRUE);
jpayne@69 197 }
jpayne@69 198
jpayne@69 199 // Hide Label# i
jpayne@69 200 inline void hide(int i) {
jpayne@69 201 activate_label(i,FALSE);
jpayne@69 202 }
jpayne@69 203
jpayne@69 204 // Show all Labels
jpayne@69 205 inline void show() {
jpayne@69 206 activate_labels(FALSE);
jpayne@69 207 activate_labels(TRUE);
jpayne@69 208 }
jpayne@69 209
jpayne@69 210 // Hide all Labels
jpayne@69 211 inline void hide() {
jpayne@69 212 activate_labels(FALSE);
jpayne@69 213 }
jpayne@69 214
jpayne@69 215 inline void attron(attr_t attrs) {
jpayne@69 216 if (ERR==::slk_attron(attrs))
jpayne@69 217 Error("slk_attron");
jpayne@69 218 }
jpayne@69 219
jpayne@69 220 inline void attroff(attr_t attrs) {
jpayne@69 221 if (ERR==::slk_attroff(attrs))
jpayne@69 222 Error("slk_attroff");
jpayne@69 223 }
jpayne@69 224
jpayne@69 225 inline void attrset(attr_t attrs) {
jpayne@69 226 if (ERR==::slk_attrset(attrs))
jpayne@69 227 Error("slk_attrset");
jpayne@69 228 }
jpayne@69 229
jpayne@69 230 inline void color(short color_pair_number) {
jpayne@69 231 if (ERR==::slk_color(color_pair_number))
jpayne@69 232 Error("slk_color");
jpayne@69 233 }
jpayne@69 234
jpayne@69 235 inline attr_t attr() const {
jpayne@69 236 return ::slk_attr();
jpayne@69 237 }
jpayne@69 238 };
jpayne@69 239
jpayne@69 240 #endif /* NCURSES_CURSSLK_H_incl */