1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // Copyright(C) 2006 Simon Howard 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 // 02111-1307, USA. 20 // 21 22 #ifndef TXT_SPINCONTROL_H 23 #define TXT_SPINCONTROL_H 24 25 /** 26 * @file txt_spinctrl.h 27 * 28 * Spin control widget. 29 */ 30 31 /** 32 * Spin control widget. 33 * 34 * A spin control widget works as an input box that can be used to 35 * set numeric values, but also has buttons that allow its value 36 * to be increased or decreased. 37 */ 38 39 typedef struct txt_spincontrol_s txt_spincontrol_t; 40 41 typedef enum 42 { 43 TXT_SPINCONTROL_INT, 44 TXT_SPINCONTROL_FLOAT, 45 } txt_spincontrol_type_t; 46 47 #include "txt_widget.h" 48 49 struct txt_spincontrol_s 50 { 51 txt_widget_t widget; 52 txt_spincontrol_type_t type; 53 union { float f; int i; } min, max, *value, step; 54 int editing; 55 char *buffer; 56 }; 57 58 /** 59 * Create a new spin control widget tracking an integer value. 60 * 61 * @param value Pointer to the variable containing the value 62 * displayed in the widget. 63 * @param min Minimum value that may be set. 64 * @param max Maximum value that may be set. 65 * @return Pointer to the new spin control widget. 66 */ 67 68 txt_spincontrol_t *TXT_NewSpinControl(int *value, int min, int max); 69 70 /** 71 * Create a new spin control widget tracking a float value. 72 * 73 * @param value Pointer to the variable containing the value 74 * displayed in the widget. 75 * @param min Minimum value that may be set. 76 * @param max Maximum value that may be set. 77 * @return Pointer to the new spin control widget. 78 */ 79 80 txt_spincontrol_t *TXT_NewFloatSpinControl(float *value, float min, float max); 81 82 #endif /* #ifndef TXT_SPINCONTROL_H */ 83 84 85