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 __TNGSLIDR_H 20 #define __TNGSLIDR_H 21 22 /* 23 * $Source: n:/project/lib/src/ui/RCS/tngslidr.h $ 24 * $Revision: 1.9 $ 25 * $Author: dc $ 26 * $Date: 1993/10/11 20:27:42 $ 27 * 28 * $Log: tngslidr.h $ 29 * Revision 1.9 1993/10/11 20:27:42 dc 30 * Angle is fun, fun fun fun 31 * 32 * Revision 1.8 1993/06/29 10:28:14 xemu 33 * sliding sliders 34 * 35 * Revision 1.7 1993/06/10 13:34:36 xemu 36 * stuff 37 * 38 * Revision 1.6 1993/05/10 17:42:33 xemu 39 * changed type of parameter to tng_slider_set 40 * 41 * Revision 1.5 1993/04/29 19:04:37 xemu 42 * removed resource.h include 43 * 44 * Revision 1.4 1993/04/28 14:40:27 mahk 45 * Preparing for second exodus 46 * 47 * Revision 1.3 1993/04/27 16:38:29 xemu 48 * general improvement 49 * 50 * Revision 1.2 1993/04/22 15:04:47 xemu 51 * more macros 52 * 53 * Revision 1.1 1993/04/21 11:31:13 xemu 54 * Initial revision 55 * 56 * 57 */ 58 59 // Includes 60 #include "lg.h" // every file should have this 61 #include "tng.h" 62 63 // Typedefs 64 typedef struct { 65 TNG *tng_data; 66 LGPoint size; 67 int alignment; 68 int min, max; 69 int value, increm; 70 uchar dragging; 71 Ref left_id, right_id, up_id, down_id; 72 Ref slider_id; 73 } TNG_slider; 74 75 #define TNG_SL_HORIZONTAL 0 76 #define TNG_SL_VERTICAL 1 77 78 #define TNG_SL_INCREMENTER 0x0001 79 #define TNG_SL_DECREMENTER 0x0002 80 #define TNG_SL_SLIDER 0x0004 81 #define TNG_SL_ALLPARTS TNG_ALLPARTS 82 83 #define TNG_SL_LEFT_KEY 0x1c 84 #define TNG_SL_RIGHT_KEY 0x1d 85 #define TNG_SL_UP_KEY 0x1e 86 #define TNG_SL_DOWN_KEY 0x1f 87 88 // Prototypes 89 90 // Initializes the TNG slider 91 errtype tng_slider_init(void *ui_data, TNG *ptng, TNGStyle *sty, int alignment, int min, int max, int value, int increm, LGPoint size); 92 93 // Initializes the TNG slider 94 errtype tng_slider_full_init(void *ui_data, TNG *ptng, TNGStyle *sty, int alignment, int min, int max, int value, int increm, LGPoint size, 95 Ref left_id, Ref right_id, Ref up_id, Ref down_id, Ref slider_id); 96 97 // Deallocate all memory used by the TNG slider 98 errtype tng_slider_destroy(TNG *ptng); 99 100 // Draw the specified parts (may be all) of the TNG slider at screen coordinates loc 101 // assumes all appropriate setup has already been done! 102 errtype tng_slider_2d_draw(TNG *ptng, ushort partmask, LGPoint loc); 103 104 // Fill in ppt with the size of the TNG slider 105 errtype tng_slider_size(TNG *ptng, LGPoint *ppt); 106 107 // Returns the current "value" of the TNG slider 108 int tng_slider_getvalue(TNG *ptng); 109 110 // React appropriately for receiving the specified cooked key 111 uchar tng_slider_keycooked(TNG *ptng, ushort key); 112 113 // React appropriately for receiving the specified mouse button event 114 uchar tng_slider_mousebutt(TNG *ptng, uchar type, LGPoint loc); 115 116 // React to a click at the given location 117 uchar tng_slider_apply_click(TNG *ptng, LGPoint loc); 118 119 // Handle incoming signals 120 uchar tng_slider_signal(TNG *ptng, ushort signal); 121 122 uchar tng_slider_increm(TNG_slider *ptng); 123 uchar tng_slider_decrem(TNG_slider *ptng); 124 errtype tng_slider_set(TNG_slider *ptng, int perc); 125 126 // Macros 127 #define TNG_SL(ptng) ((TNG_slider *)ptng->type_data) 128 #define TNG_SL_VALFRAC(psltng) ((float)(psltng->value - psltng->min)) / ((float)(psltng->max - psltng->min)) 129 130 #endif // __TNGSLIDR_H 131 132