1 /* 2 3 Copyright (C) 2015-2018 Night Dive Studios, LLC. 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 */ 19 #ifndef __TNGQBOX_H 20 #define __TNGQBOX_H 21 22 /* 23 * $Source: n:/project/lib/src/ui/RCS/tngqbox.h $ 24 * $Revision: 1.13 $ 25 * $Author: xemu $ 26 * $Date: 1994/03/10 04:31:20 $ 27 * 28 * $Log: tngqbox.h $ 29 * Revision 1.13 1994/03/10 04:31:20 xemu 30 * uint slots 31 * 32 * Revision 1.12 1993/12/31 18:01:38 xemu 33 * rename slots 34 * 35 * Revision 1.11 1993/10/11 20:27:41 dc 36 * Angle is fun, fun fun fun 37 * 38 * Revision 1.10 1993/09/16 14:58:06 mahk 39 * Added QB_FIX_SLOT 40 * 41 * Revision 1.9 1993/08/11 11:11:06 xemu 42 * stringset display option 43 * 44 * Revision 1.8 1993/06/24 10:26:47 xemu 45 * QB_ADDCLOSE 46 * 47 * Revision 1.7 1993/06/23 18:56:11 xemu 48 * byte, hex, octal, binary 49 * 50 * Revision 1.6 1993/06/16 02:22:38 xemu 51 * new options 52 * 53 * Revision 1.5 1993/06/10 13:34:49 xemu 54 * added QB_GRABFOCUS 55 * 56 * Revision 1.4 1993/04/30 11:40:00 xemu 57 * slider_size to aux_size 58 * 59 * Revision 1.3 1993/04/29 19:02:51 xemu 60 * support options 61 * 62 * Revision 1.2 1993/04/28 14:40:26 mahk 63 * Preparing for second exodus 64 * 65 * Revision 1.1 1993/04/27 16:37:18 xemu 66 * Initial revision 67 * 68 * Revision 1.1 1993/04/22 15:09:55 xemu 69 * Initial revision 70 * 71 * 72 */ 73 74 // Includes 75 #include "lg.h" // every file should have this 76 #include "tng.h" 77 78 // Typedefs 79 typedef struct _QuickboxSlot { 80 char *label; // Text Label 81 ulong options; // Options mask 82 int vartype; // Type of the slot 83 void *var; // Pointer to actual variable 84 intptr_t p1, p2; // parameters 85 struct _QuickboxSlot *next; // next slot in the box 86 TNG *aux_tng; // An auxilliary gadget, if relevant 87 LGPoint aux_size; 88 TNG *tng; 89 } QuickboxSlot; 90 91 typedef struct { 92 TNG *tng_data; 93 LGPoint size, slot_size, spacing, border; 94 Ref left_id, right_id; 95 int aux_size, internal_margin; 96 ushort options; 97 QuickboxSlot *slots; 98 QuickboxSlot *current_slot; 99 } TNG_quickbox; 100 101 // SlotTypes 102 #define QB_INT_SLOT 0 // var is an int * 103 #define QB_SHORT_SLOT 1 // var is a short * 104 #define QB_BYTE_SLOT 2 // var is a ubyte * 105 #define QB_TEXT_SLOT 3 // var is a char * 106 #define QB_BOOL_SLOT 4 // var is a bool, and should be displayed as TRUE/FALSE 107 #define QB_PUSHBUTTON_SLOT 5 // var is a GadgetCallback to be called when the button using the label as text is pressed 108 // requires parameters to be set. P1 is the user_data for the callback. If P2 is null, 109 // then the label will be the text of the button. If P2 is not null, it is taken as a 110 // pointer to a resource to display in the button, and the label will appear off to the 111 // right, like for other slot types 112 #define QB_FIX_SLOT 6 // fixpoint number 113 #define QB_UINT_SLOT 7 // var is an uint * 114 115 // Overall Options 116 // Align up all the data fields nicely 117 #define QB_ALIGNMENT 0x01 118 119 // Have the quickbox set the slot width to the minimum setting 120 // large enough to encompass the data for every slot. 121 #define QB_AUTOSIZE 0x02 122 123 // Has the quickbox grab keyboard focus upon creation, 124 // releasing it upon exit. 125 #define QB_GRABFOCUS 0x04 126 127 // Add a "close" button at the bottom of the quickbox which 128 // will close it down. If you want your own code to get run 129 // when quickbox closed, don't use this option! 130 #define QB_ADDCLOSE 0x08 131 132 // ******************** 133 // *** SLOT OPTIONS *** 134 // ******************** 135 136 // no options for this slot, plain vanilla 137 #define QB_NO_OPTION 0x0000 138 139 // the var can be toggled up and down with clickable arrows. 140 // SUPPORTED TYPES: INT_SLOT, SHORT_SLOT, BYTE_SLOT, BOOL_SLOT 141 #define QB_ARROWS 0x0001UL 142 143 // the var has an associated slider which can be used to set it's value. Requires parameters 144 // which are the max and min values of the variable. If variables not provided, default to 0 and 100 145 // for minimum and maximum. 146 // SUPPORTED TYPES: INT_SLOT, SHORT_SLOT, BYTE_SLOT 147 #define QB_SLIDER 0x0002UL 148 149 // the var is for output purposes only and should not be allowed to be changed. 150 // SUPPORTED TYPES: ALL 151 #define QB_RD_ONLY 0x0004UL 152 153 // limit the upper and lower limit of the start to p1 min and p2 max. 154 // SUPPORTED TYPES: INT_SLOT, SHORT_SLOT, BYTE_SLOT 155 #define QB_BOUNDED 0x0008UL 156 157 // like QB_BOUNDED, but when max exceeded, cycles around to min 158 #define QB_CYCLE 0x0010UL 159 160 // These all constrain the slot to that type of number 161 // SUPPORTED TYPES: INT_SLOT, SHORT_SLOT, BYTE_SLOT, only if standard display options chosen 162 #define QB_HEX 0x0020UL 163 #define QB_OCTAL 0x0040UL 164 #define QB_BINARY 0x0080UL 165 166 // Display the value of the slot as one a set of string values 167 // SUPPORTED TYPES: INT_SLOT, SHORT_SLOT, BYTE_SLOT 168 // automatically inherits QB_CYCLE from 0 to the number of provided values 169 #define QB_STRINGSET 0x0100UL 170 171 // ***************** 172 // ** KEY DEFINES ** 173 // ***************** 174 175 #define QB_RETURN_KEY 0xd 176 #define QB_UP_KEY 0x48 177 #define QB_DOWN_KEY 0x50 178 #define QB_LEFT_KEY 0x4b 179 #define QB_RIGHT_KEY 0x4d 180 181 #define TNG_QB_SELECTION_SPACING 0 182 #define TNG_QB_DEFAULT_SLIDER_SIZE 60 183 184 // Prototypes 185 186 // Initializes the TNG 187 errtype tng_quickbox_init(void *ui_data, TNG *ptng, TNGStyle *sty, ushort options, LGPoint slot_size, LGPoint spacing, LGPoint border, 188 Ref left_id, Ref right_id); 189 190 // Add a line to a quickbox. slot_type describes the type of slot, var is a pointer to the variable to be 191 // displaying, and slot_options describes any additional modifiers to the qbox. Note that some bizarre-o 192 // combinations of options and types might not be implemented. 193 errtype tng_quickbox_add(char *label, int slot_type, void *var, ulong slot_options); 194 195 // Just like gad_qbox_add but allows two parameters to be set for the slot. Certain slot options require 196 // this form of accessing. 197 errtype tng_quickbox_add_parm(char *label, int slot_type, void *var, ulong slot_options, intptr_t parm1, intptr_t parm2); 198 199 // Deallocate all memory used by the TNG 200 errtype tng_quickbox_destroy(TNG *ptng); 201 202 // This represents that the quickbox is done being created and is ready for display, input, etc. 203 errtype tng_quickbox_end(); 204 205 // Draw the specified parts (may be all) of the TNG at screen coordinates loc 206 // assumes all appropriate setup has already been done! 207 errtype tng_quickbox_2d_draw(TNG *ptng, ushort partmask, LGPoint loc); 208 209 // Fill in ppt with the size of the TNG 210 errtype tng_quickbox_size(TNG *ptng, LGPoint *ppt); 211 212 // Returns the current "value" of the TNG 213 int tng_quickbox_getvalue(TNG *ptng); 214 215 // React appropriately for receiving the specified cooked key 216 uchar tng_quickbox_keycooked(TNG *ptng, ushort key); 217 218 // React appropriately for receiving the specified mouse button event 219 uchar tng_quickbox_mousebutt(TNG *ptng, uchar type, LGPoint loc); 220 221 // Handle incoming signals 222 uchar tng_quickbox_signal(TNG *ptng, ushort signal); 223 224 // Rename a slot 225 errtype tng_quickbox_rename_slot(TNG *qb, int slot_num, char *new_name); 226 227 // Macros 228 #define TNG_QB(ptng) ((TNG_quickbox *)(ptng->type_data)) 229 #define QB_CURRENT(ptng) TNG_QB(ptng)->current_slot 230 #define QB_SLOTS(ptng) TNG_QB(ptng)->slots 231 232 #endif // __TNGQBOX_H 233 234