1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2012 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef PSPPIRE_VALUE_ENTRY_H
18 #define PSPPIRE_VALUE_ENTRY_H 1
21 #include "data/format.h"
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.
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. */
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))
50 typedef struct _PsppireValueEntry PsppireValueEntry;
51 typedef struct _PsppireValueEntryClass PsppireValueEntryClass;
53 struct _PsppireValueEntry
57 gboolean show_value_label;
59 struct val_labs *val_labs;
60 struct fmt_spec format;
63 const union value *cur_value;
66 struct _PsppireValueEntryClass
68 GtkComboBoxClass parent_class;
71 GType psppire_value_entry_get_type (void);
72 GtkWidget *psppire_value_entry_new (void);
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 *);
78 void psppire_value_entry_set_variable (PsppireValueEntry *,
79 const struct variable *);
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 *);
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 *);
91 void psppire_value_entry_set_encoding (PsppireValueEntry *, const gchar *);
92 const gchar *psppire_value_entry_get_encoding (const PsppireValueEntry *);
94 void psppire_value_entry_set_width (PsppireValueEntry *, int width);
95 int psppire_value_entry_get_width (const PsppireValueEntry *);
97 void psppire_value_entry_set_value (PsppireValueEntry *,
100 gboolean psppire_value_entry_get_value (PsppireValueEntry *,
106 #endif /* PSPPIRE_VALUE_ENTRY_H */