1 /****************************************************************************** 2 * 3 * NSSDC/CDF Header file for `widgets'. 4 * 5 * Version 1.3a, 30-Mar-97, Hughes STX. 6 * 7 * Modification history: 8 * 9 * V1.0 26-Nov-93, J Love Original version. 10 * V1.0a 4-Feb-94, J Love DEC Alpha/OpenVMS port. 11 * V1.0b 6-Apr-94, J Love Solaris using GNU C compiler. 12 * V1.1 13-Dec-94, J Love CDF V2.5. 13 * V1.1a 23-Jan-95, J Love Primary/alternate "current" item movement keys 14 * for ItemWindow. 15 * V1.1b 7-Mar-95, J Love Added FieldWindow. 16 * V1.2 30-Mar-95, J Love POSIX. 17 * V1.2a 6-Sep-95, J Love CDFexport-related changes. 18 * V1.3 18-Jul-96, J Love CDF V2.6. 19 * V1.3a 30-Mar-97, J Love Allow FieldWindow fields to grow larger than 20 * their on-screen width. 21 * 22 ******************************************************************************/ 23 24 #if !defined(WIDGETSh_INCLUDEd__) 25 #define WIDGETSh_INCLUDEd__ 26 27 /****************************************************************************** 28 * Include files. 29 ******************************************************************************/ 30 31 #include "windoz.h" 32 33 /****************************************************************************** 34 * Constants. 35 ******************************************************************************/ 36 37 #define MAX_INFO_WINDOW_eLINES 3 38 #define INFOtextMAX (MAX_INFO_WINDOW_eLINES*(SCREEN_WIDTH-2+1)) 39 40 /****************************************************************************** 41 * ItemWindow operations. 42 * 43 * ItemWindow (NEWiw, &IWstruct, ItemNumber); 44 * ItemWindow (UPDATEiw, &IWstruct, ItemNumber); 45 * ItemWindow (READiw, &IWstruct); 46 * ItemWindow (DELETEiw, &IWstruct); 47 * ItemWindow (UNDISPLAYiw, &IWstruct); 48 * ItemWindow (REDISPLAYiw, &IWstruct); 49 * ItemWindow (BEEPiw, &IWstruct); 50 * 51 * where, 52 * 53 * <op>iw......................the operation to perform. 54 * IWstruct....................a pointer to an `ItemWindowStruct' structure. 55 * ItemNumber(int).............the initial current item number. 56 * 57 ******************************************************************************/ 58 59 #define NEWiw 1 /* Create new menu. */ 60 #define UPDATEiw 2 /* Update sections. */ 61 #define READiw 3 /* Read keystrokes until `exit' key entered. */ 62 #define DELETEiw 4 /* Delete menu. */ 63 #define UNDISPLAYiw 5 /* Erase menu (it still exists though). */ 64 #define REDISPLAYiw 6 /* Redisplay menu. */ 65 #define BEEPiw 7 /* Beep. */ 66 67 /****************************************************************************** 68 * ItemWindow structure. 69 ******************************************************************************/ 70 71 struct ItemWindowStruct { 72 /*************************************************************************** 73 * These must be initialized before calling `ItemWindow' the first time. 74 ***************************************************************************/ 75 int ULrow; 76 int ULcol; 77 int nColsTotal; /* Includes left and right borders. */ 78 char *label; 79 int NhLines; 80 char **hLines; 81 int NiLines; 82 char **iLines; 83 int nItems; 84 int *iLineNs; 85 int *iCols; 86 int *iLens; 87 int NiRows; 88 int NtLines; 89 char **tLines; 90 int *exitChars; /* The characters which cause an exit from 91 the prompt window. Terminated by NUL. */ 92 int refreshChar; /* Causes entire screen to be refreshed. */ 93 Logical iPct; /* TRUE if a percentage indicator should be 94 displayed in the item section. */ 95 int NSkey; /* Next-screen key. */ 96 int PSkey; /* Prev-screen key. */ 97 /*************************************************************************** 98 * These are initialized/calculated/returned by `ItemWindow'. 99 ***************************************************************************/ 100 int itemN; /* Current item number. */ 101 int key; /* Key entered causing exit from menu. */ 102 /*************************************************************************** 103 * These are for internal use by `ItemWindow'. 104 ***************************************************************************/ 105 int nRowsTotal; /* Total number of rows (including top and 106 bottom border rows). */ 107 int nColS; /* Doesn't include left and right borders. */ 108 int *iUpTo; 109 int *iDownTo; 110 int *iLeftTo; 111 int *iRightTo; 112 int hRowT, iRowT, tRowT; /* Top row for section. */ 113 int hRowB, iRowB, tRowB; /* Bottom row for section. For the item 114 section, it is the last row actually 115 used. */ 116 Logical iScroll; /* TRUE if item section needs to be scrolled 117 (more lines than rows). */ 118 int iRowN; /* Row number in item section containing 119 current item. */ 120 int iPctRowN; /* Row number of item section percentage 121 indicator. */ 122 int iPctColN; /* Column number of item section percentage 123 indicator. */ 124 WINDOWid wid; /* Window identifier. */ 125 }; 126 127 /****************************************************************************** 128 * ItemWindow "current" item primary/alternate movement keys. 129 ******************************************************************************/ 130 131 #define IW_DOWN KB_DOWNARROW 132 #define IW_UP KB_UPARROW 133 #define IW_LEFT KB_LEFTARROW 134 #define IW_RIGHT KB_RIGHTARROW 135 136 #define IW_DOWNx KB_d 137 #define IW_UPx KB_u 138 #define IW_LEFTx KB_l 139 #define IW_RIGHTx KB_r 140 141 /****************************************************************************** 142 * PromptWindow operations. 143 * 144 * PromptWindow (NEWpw, &PWstruct, CursorAtThisChar, InsertMode); 145 * PromptWindow (RESETpw, &PWstruct, CursorAtThisChar, InsertMode); 146 * PromptWindow (READpw, &PWstruct); 147 * PromptWindow (UNDISPLAYpw, &PWstruct); 148 * PromptWindow (REDISPLAYpw, &PWstruct); 149 * PromptWindow (DELETEpw, &PWstruct); 150 * PromptWindow (BEEPpw, &PWstruct); 151 * 152 * where, 153 * <op>pw...................the operation to perform. 154 * PWstruct.................a pointer to a `PromptWindowStruct' structure. 155 * CursorAtThisChar(int)....character position at which to start the cursor. 156 * InsertMode(Logical)......initial insert mode. TRUE means insert, FALSE 157 * means overstrike. `TOGGLEchar' toggles this 158 * mode after it is initially set. 159 * 160 ******************************************************************************/ 161 162 #define NEWpw 1 /* Create new window. */ 163 #define RESETpw 2 /* Reset window. */ 164 #define READpw 3 /* Read keystrokes until `exit' key entered. */ 165 #define DELETEpw 4 /* Delete window. */ 166 #define BEEPpw 5 /* Beep. */ 167 #define UNDISPLAYpw 6 /* Erase window (it still exists though). */ 168 #define REDISPLAYpw 7 /* Redisplay window. */ 169 170 /****************************************************************************** 171 * PromptWindow structure. 172 ******************************************************************************/ 173 174 struct PromptWindowStruct { 175 /*************************************************************************** 176 * These must be initialized before calling `PromptWindow' the first time. 177 ***************************************************************************/ 178 char *label; 179 int ULrow; 180 int ULcol; 181 int nColsTotal; /* Includes left and right borders. */ 182 int NhLines; 183 char **hLines; 184 int maxChars; 185 char *value; 186 int NtLines; 187 char **tLines; 188 int *exitChars; /* The characters which cause an exit from 189 the prompt window. Terminated by NUL. */ 190 int refreshChar; /* Causes entire screen to be refreshed. */ 191 int SOLchar; /* Moves cursor to start-of-line. */ 192 int EOLchar; /* Moves cursor to end-of-line. */ 193 int TOGGLEchar; /* Toggles between insert mode and overstrike 194 mode. */ 195 /*************************************************************************** 196 * These are initialized/calculated/returned by `PromptWindow'. 197 ***************************************************************************/ 198 int key; /* Key entered causing exit from menu. */ 199 /*************************************************************************** 200 * These are for internal use by `PromptWindow'. 201 ***************************************************************************/ 202 Logical insertMode; /* If TRUE, insert mode. If FALSE, overstrike 203 mode. */ 204 int nRowsTotal; /* Total number of rows (including top and 205 bottom border rows). */ 206 int nColS; /* Doesn't include left and right borders. */ 207 int curCol; /* Current column cursor is on (numbered from 208 zero (0). */ 209 int curChar; /* Current character cursor is on (numbered 210 from zero (0). */ 211 int curLen; /* Current length of value. */ 212 int NvCols; /* Number of columns in value section. */ 213 int vRow; /* Row number value is on. */ 214 int vLcol; /* Left-most column of value. */ 215 int vRcol; /* Right-most column of value. */ 216 int mLcol; /* Column left `more' indicator is in. */ 217 int mRcol; /* Column right `more' indicator is in. */ 218 int hRowT, tRowT; /* Top row for section. */ 219 int hRowB, tRowB; /* Bottom row for section. */ 220 WINDOWid wid; /* Window id. */ 221 }; 222 223 /****************************************************************************** 224 * EditWindow operations. 225 * 226 * EditWindow (NEWew, &EWstruct, InsertMode); 227 * EditWindow (UPDATEew, &EWstruct, InsertMode); 228 * EditWindow (READew, &EWstruct); 229 * EditWindow (DELETEew, &EWstruct); 230 * EditWindow (BEEPew, &EWstruct); 231 * 232 * where, 233 * <op>ew...................the operation to perform. 234 * EWstruct.................a pointer to a `EditWindowStruct' structure. 235 * InsertMode(Logical)......initial insert mode. TRUE means insert, FALSE 236 * means overstrike. Ctrl-A toggles this mode after 237 * it is initially set. 238 * 239 ******************************************************************************/ 240 241 #define NEWew 1 /* Create edit window. */ 242 #define UPDATEew 2 /* Update edit window. */ 243 #define READew 3 /* Read keystrokes until `exit' key entered. */ 244 #define DELETEew 4 /* Delete window. */ 245 #define BEEPew 5 /* Beep. */ 246 247 /****************************************************************************** 248 * EditWindow structure. 249 ******************************************************************************/ 250 251 struct EditWindowStruct { 252 /*************************************************************************** 253 * These must be initialized before calling `EditWindow' the first time. 254 ***************************************************************************/ 255 char *label; /* Label for top of window (on border). */ 256 int ULrow; /* Row on the screen at which top line of 257 window should be placed. */ 258 int ULcol; /* Column on the screen at which the left-most 259 column of the window should be placed. */ 260 int nColsTotal; /* Number of columns that window should have 261 (this includes the left and right border 262 columns). */ 263 int NhLines; /* Number of header lines. */ 264 char **hLines; /* Header lines. */ 265 char *eText; /* Text to be edited. */ 266 int NeRows; /* Number of rows in the edit section. This 267 can be less than the number of lines. */ 268 int NtLines; /* Number of trailer lines. */ 269 char **tLines; /* Trailer lines. */ 270 Logical ePct; /* TRUE if a percentage indicator should be 271 displayed in the edit section. */ 272 Logical readOnly; /* TRUE if the edit section may not be 273 modified. */ 274 int *exitChars; /* The characters which cause an exit from 275 the edit window. Terminated by NUL. */ 276 int REFRESHkey; /* Causes entire screen to be refreshed. */ 277 int SOLkey; /* Moves cursor to start-of-line. */ 278 int EOLkey; /* Moves cursor to end-of-line. */ 279 int SOTkey; /* Moves cursor to start-of-text. */ 280 int EOTkey; /* Moves cursor to end-of-text. */ 281 int NSkey; /* Moves cursor to next-screen. */ 282 int PSkey; /* Moves cursor to prev-screen. */ 283 int DLkey; /* Delete line that cursor is on. */ 284 int NWkey; /* Moves cursor to end of current/next word. */ 285 int TOGGLEkey; /* Toggles between insert mode and overstrike 286 mode. */ 287 /*************************************************************************** 288 * These are initialized/calculated/returned by `EditWindow'. 289 ***************************************************************************/ 290 int key; /* Key entered causing exit from menu. */ 291 /*************************************************************************** 292 * These are for internal use by `EditWindow'. 293 ***************************************************************************/ 294 int nRowsTotal; /* Total number of rows (including top and 295 bottom border rows). */ 296 int nColS; /* Doesn't include left and right borders. */ 297 int hRowT, eRowT, tRowT; /* Top row for section. */ 298 int hRowB, eRowB, tRowB; /* Bottom row for section. */ 299 int nChars; /* Number of characters currently in `text'. */ 300 int xChars; /* Maximum number of characters that `text' 301 can currently contain. */ 302 int cursorRow; /* Row containing cursor. */ 303 int cursorCol; /* Column containing cursor. */ 304 int firstChar; /* Character in text at the upper-left 305 position of the EditSection. */ 306 int cursorChar; /* Character in text on which the cursor is 307 sitting. */ 308 Logical insertMode; /* If TRUE, insert mode. If FALSE, overstrike 309 mode. */ 310 int ePctRowN; /* Row number of edit section percentage 311 indicator. */ 312 int ePctColN; /* Column number of edit section percentage 313 indicator. */ 314 WINDOWid wid; /* Window id. */ 315 }; 316 317 /****************************************************************************** 318 * FieldWindow operations. 319 * 320 * FieldWindow (NEWfw, &FWstruct, fieldNumber, insertMode); 321 * FieldWindow (UPDATEfw, &FWstruct, fieldNumber, insertMode); 322 * FieldWindow (READfw, &FWstruct); 323 * FieldWindow (DELETEfw, &FWstruct); 324 * FieldWindow (UNDISPLAYfw, &FWstruct); 325 * FieldWindow (REDISPLAYfw, &FWstruct); 326 * FieldWindow (BEEPfw, &FWstruct); 327 * 328 * where, 329 * 330 * <op>fw..................is the operation to perform. 331 * FWstruct................is a pointer to an `FieldWindowStruct' structure. 332 * fieldNumber(int)........is the initial current field number. 333 * insertMode(Logical).....is the initial insert mode. TRUE means insert, 334 * FALSE means overstrike. This mode is toggled by 335 * TOGGLEkey. 336 * 337 ******************************************************************************/ 338 339 #define NEWfw 1 /* Create new menu. */ 340 #define UPDATEfw 2 /* Update sections. */ 341 #define READfw 3 /* Read keystrokes until `exit' key entered. */ 342 #define DELETEfw 4 /* Delete menu. */ 343 #define UNDISPLAYfw 5 /* Erase menu (it still exists though). */ 344 #define REDISPLAYfw 6 /* Redisplay menu. */ 345 #define BEEPfw 7 /* Beep. */ 346 347 /****************************************************************************** 348 * FieldWindow structure. 349 ******************************************************************************/ 350 351 struct FieldWindowStruct { 352 /*************************************************************************** 353 * These must be initialized before calling `FieldWindow' the first time. 354 ***************************************************************************/ 355 int ULrow; /* Upper-left row number. */ 356 int ULcol; /* Upper-left column number. */ 357 int nColsTotal; /* Includes left and right borders. */ 358 char *label; /* Label for window. */ 359 int NhLines; /* Number of header lines (zero or more). */ 360 char **hLines; /* Header lines. */ 361 int NfLines; /* Number of field lines (one or more). */ 362 char **fLines; /* Field lines. */ 363 char **fields; /* Fields. */ 364 int nFields; /* Number of fields (one or more). */ 365 int *fLineNs; /* Line number for each field. */ 366 int *fCols; /* Starting column number for each field. */ 367 int *fLens; /* Length (width) of each field. */ 368 int *fMaxs; /* Maximum length of a field. This can be 369 greater than the on-screen width. */ 370 int NfRows; /* Number of rows in fields section. */ 371 int NtLines; /* Number of trailer lines (zero or more). */ 372 char **tLines; /* Trailer lines. */ 373 int *exitChars; /* The characters which cause an exit from 374 the prompt window. Terminated by NUL. */ 375 int refreshChar; /* Causes entire screen to be refreshed. */ 376 Logical fPct; /* TRUE if a percentage indicator should be 377 displayed in the fields section. */ 378 int NSkey; /* Next-screen key. */ 379 int PSkey; /* Prev-screen key. */ 380 int toggleKey; /* Toggles between insert and overstrike. */ 381 /*************************************************************************** 382 * These are initialized/calculated/returned by `FieldWindow'. 383 ***************************************************************************/ 384 int fieldN; /* Current field number. */ 385 int key; /* Key entered causing exit from menu. */ 386 /*************************************************************************** 387 * These are for internal use by `FieldWindow'. 388 ***************************************************************************/ 389 int charN; /* Cursor position within current field. */ 390 int leftCharN; /* Character within current field that is at 391 the left (first) on-screen position. */ 392 int nRowsTotal; /* Total number of rows (including top and 393 bottom border rows). */ 394 int nColS; /* Doesn't include left and right borders. */ 395 int *fUpTo; /* Field number above. */ 396 int *fDownTo; /* Field number below. */ 397 int *fLeftTo; /* Field number to the left. */ 398 int *fRightTo; /* Field number to the right. */ 399 int hRowT, fRowT, tRowT; /* Top row for header, fields, and trailer 400 sections. */ 401 int hRowB, fRowB, tRowB; /* Bottom row for each section. For the fields 402 section, it is the last row actually used.*/ 403 Logical fScroll; /* TRUE if fields section needs to be scrolled 404 (more lines than rows). */ 405 int fRowN; /* Row number in fields section containing 406 current field. */ 407 int fPctRowN; /* Row number of fields section percentage 408 indicator. */ 409 int fPctColN; /* Column number of fields section percentage 410 indicator. */ 411 Logical insert; /* If TRUE, insert. If FALSE, overstrike. */ 412 WINDOWid wid; /* Window identifier. */ 413 }; 414 415 /****************************************************************************** 416 * FieldWindow "current" field primary/alternate movement keys. 417 ******************************************************************************/ 418 419 #define FW_DOWN_FIELD KB_DOWNARROW 420 #define FW_UP_FIELD KB_UPARROW 421 #define FW_LEFT_FIELD NUL 422 #define FW_RIGHT_FIELD KB_TAB 423 #define FW_LEFT_CHAR KB_LEFTARROW 424 #define FW_RIGHT_CHAR KB_RIGHTARROW 425 426 #define FW_DOWN_FIELDx NUL 427 #define FW_UP_FIELDx NUL 428 #define FW_LEFT_FIELDx NUL 429 #define FW_RIGHT_FIELDx NUL 430 #define FW_LEFT_CHARx NUL 431 #define FW_RIGHT_CHARx NUL 432 433 /****************************************************************************** 434 * Function prototypes. 435 ******************************************************************************/ 436 437 int ItemWindow VARPROTOARGs((int, ...)); 438 int PromptWindow VARPROTOARGs((int, ...)); 439 int EditWindow VARPROTOARGs((int, ...)); 440 int FieldWindow VARPROTOARGs((int, ...)); 441 void AllocIW PROTOARGs(( 442 struct ItemWindowStruct *IW, int nItems, int NiLines, int iLineNchars, 443 void (*fatalFnc) PROTOARGs((char *msg)) 444 )); 445 void FreeIW PROTOARGs(( 446 struct ItemWindowStruct *IW, void (*fatalFnc) PROTOARGs((char *msg)) 447 )); 448 void AllocFW PROTOARGs(( 449 struct FieldWindowStruct *FW, int nFields, int NfLines, int fLineNchars, 450 void (*fatalFnc) PROTOARGs((char *msg)) 451 )); 452 void FreeFW PROTOARGs(( 453 struct FieldWindowStruct *FW, void (*fatalFnc) PROTOARGs((char *msg)) 454 )); 455 Logical OnlineHelpWindow PROTOARGs((char *ilhFile, int helpId)); 456 Logical LoadOnlineHelp PROTOARGs(( 457 char *ilhFile, int helpId, char *header, char **eText 458 )); 459 void InfoWindow PROTOARGs(( 460 char *line1, char *line2, char *line3, Logical center, Logical beep, int wait 461 )); 462 463 /*****************************************************************************/ 464 465 #endif 466