1 // 2 // Copyright(C) 2005-2014 Simon Howard 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 2 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 15 #ifndef TXT_CHECKBOX_H 16 #define TXT_CHECKBOX_H 17 18 /** 19 * @file txt_checkbox.h 20 * 21 * Checkbox widget. 22 */ 23 24 /** 25 * Checkbox widget. 26 * 27 * A checkbox is used to control boolean values that may be either on 28 * or off. The widget has a label that is displayed to the right of 29 * the checkbox indicator. The widget tracks an integer variable; 30 * if the variable is non-zero, the checkbox is checked, while if it 31 * is zero, the checkbox is unchecked. It is also possible to 32 * create "inverted" checkboxes where this logic is reversed. 33 * 34 * When a checkbox is changed, it emits the "changed" signal. 35 */ 36 37 typedef struct txt_checkbox_s txt_checkbox_t; 38 39 #include "txt_widget.h" 40 41 struct txt_checkbox_s 42 { 43 txt_widget_t widget; 44 char *label; 45 int *variable; 46 int inverted; 47 }; 48 49 /** 50 * Create a new checkbox. 51 * 52 * @param label The label for the new checkbox (UTF-8 format). 53 * @param variable Pointer to the variable containing this checkbox's 54 * value. 55 * @return Pointer to the new checkbox. 56 */ 57 58 txt_checkbox_t *TXT_NewCheckBox(const char *label, int *variable); 59 60 /** 61 * Create a new inverted checkbox. 62 * 63 * An inverted checkbox displays the opposite of a normal checkbox; 64 * where it would be checked, it appears unchecked, and vice-versa. 65 * 66 * @param label The label for the new checkbox (UTF-8 format). 67 * @param variable Pointer to the variable containing this checkbox's 68 * value. 69 * @return Pointer to the new checkbox. 70 */ 71 72 txt_checkbox_t *TXT_NewInvertedCheckBox(const char *label, int *variable); 73 74 #endif /* #ifndef TXT_CHECKBOX_H */ 75 76 77