1 /* PSPPIRE - a graphical user interface for PSPP. 2 Copyright (C) 2012 Free Software Foundation, Inc. 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (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 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef PSPPIRE_VALUE_ENTRY_H 18 #define PSPPIRE_VALUE_ENTRY_H 1 19 20 #include <gtk/gtk.h> 21 #include "data/format.h" 22 23 /* PsppireValueEntry is a subclass of GtkComboBox that is specialized for 24 displaying and entering "union value"s. Its main advantage over a plain 25 GtkEntry is that, when value labels are supplied, it (optionally) displays 26 the value label instead of the value. It also allows the user to choose a 27 new value by label from the drop-down list. 28 29 The easiest way to use a PsppireValueEntry is to hand it a particular 30 variable whose values are to be displayed, using 31 psppire_value_entry_set_variable(). If you do that, you don't need any of 32 the other functions to set value labels, format, encoding, width, etc., 33 because all of those are determined from the variable. The other functions 34 are useful if no variable is available. */ 35 36 G_BEGIN_DECLS 37 38 union value; 39 struct fmt_spec; 40 struct val_labs; 41 struct variable; 42 43 #define PSPPIRE_TYPE_VALUE_ENTRY (psppire_value_entry_get_type()) 44 #define PSPPIRE_VALUE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),PSPPIRE_TYPE_VALUE_ENTRY,PsppireValueEntry)) 45 #define PSPPIRE_VALUE_ENTRY_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class),PSPPIRE_TYPE_VALUE_ENTRY,PsppireValueEntryClass)) 46 #define PSPPIRE_IS_VALUE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),PSPPIRE_TYPE_VALUE_ENTRY)) 47 #define PSPPIRE_IS_VALUE_ENTRY_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class),PSPPIRE_TYPE_VALUE_ENTRY)) 48 #define PSPPIRE_VALUE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),PSPPIRE_TYPE_VALUE_ENTRY,PsppireValueEntryClass)) 49 50 typedef struct _PsppireValueEntry PsppireValueEntry; 51 typedef struct _PsppireValueEntryClass PsppireValueEntryClass; 52 53 struct _PsppireValueEntry 54 { 55 GtkComboBox parent; 56 57 gboolean show_value_label; 58 59 struct val_labs *val_labs; 60 struct fmt_spec format; 61 gchar *encoding; 62 63 const union value *cur_value; 64 }; 65 66 struct _PsppireValueEntryClass 67 { 68 GtkComboBoxClass parent_class; 69 }; 70 71 GType psppire_value_entry_get_type (void); 72 GtkWidget *psppire_value_entry_new (void); 73 74 void psppire_value_entry_set_show_value_label (PsppireValueEntry *, 75 gboolean show_value_label); 76 gboolean psppire_value_entry_get_show_value_label (const PsppireValueEntry *); 77 78 void psppire_value_entry_set_variable (PsppireValueEntry *, 79 const struct variable *); 80 81 void psppire_value_entry_set_value_labels (PsppireValueEntry *, 82 const struct val_labs *); 83 const struct val_labs * 84 psppire_value_entry_get_value_labels (const PsppireValueEntry *); 85 86 void psppire_value_entry_set_format (PsppireValueEntry *, 87 const struct fmt_spec *); 88 const struct fmt_spec * 89 psppire_value_entry_get_format (const PsppireValueEntry *); 90 91 void psppire_value_entry_set_encoding (PsppireValueEntry *, const gchar *); 92 const gchar *psppire_value_entry_get_encoding (const PsppireValueEntry *); 93 94 void psppire_value_entry_set_width (PsppireValueEntry *, int width); 95 int psppire_value_entry_get_width (const PsppireValueEntry *); 96 97 void psppire_value_entry_set_value (PsppireValueEntry *, 98 const union value *, 99 int width); 100 gboolean psppire_value_entry_get_value (PsppireValueEntry *, 101 union value *, 102 int width); 103 104 G_END_DECLS 105 106 #endif /* PSPPIRE_VALUE_ENTRY_H */ 107