}
}
+/* Returns a string representing the format TYPE for use in a GUI dialog. */
+const char *
+fmt_gui_name (enum fmt_type type)
+{
+ switch (type)
+ {
+ case FMT_F:
+ return _("Numeric");
+
+ case FMT_COMMA:
+ return _("Comma");
+
+ case FMT_DOT:
+ return _("Dot");
+
+ case FMT_E:
+ return _("Scientific");
+
+ case FMT_DATE:
+ case FMT_EDATE:
+ case FMT_SDATE:
+ case FMT_ADATE:
+ case FMT_JDATE:
+ case FMT_QYR:
+ case FMT_MOYR:
+ case FMT_WKYR:
+ case FMT_DATETIME:
+ case FMT_TIME:
+ case FMT_DTIME:
+ case FMT_WKDAY:
+ case FMT_MONTH:
+ return _("Date");
+
+ case FMT_DOLLAR:
+ return _("Dollar");
+
+ case FMT_CCA:
+ case FMT_CCB:
+ case FMT_CCC:
+ case FMT_CCD:
+ case FMT_CCE:
+ return _("Custom");
+
+ case FMT_A:
+ return _("String");
+
+ default:
+ return fmt_name (type);
+ }
+}
\f
/* Returns true if TYPE is a valid format type,
false otherwise. */
bool fmt_from_io (int io, enum fmt_type *);
const char *fmt_date_template (enum fmt_type) PURE_FUNCTION;
+const char *fmt_gui_name (enum fmt_type);
\f
/* Format settings.
return m == MEASURE_NOMINAL || m == MEASURE_ORDINAL || m == MEASURE_SCALE;
}
+/* Returns a string version of measurement level M, for display to a user. */
+const char *
+measure_to_string (enum measure m)
+{
+ switch (m)
+ {
+ case MEASURE_NOMINAL:
+ return _("Nominal");
+
+ case MEASURE_ORDINAL:
+ return _("Ordinal");
+
+ case MEASURE_SCALE:
+ return _("Scale");
+
+ default:
+ return "Invalid";
+ }
+}
+
/* Returns V's measurement level. */
enum measure
var_get_measure (const struct variable *v)
return a == ALIGN_LEFT || a == ALIGN_RIGHT || a == ALIGN_CENTRE;
}
+/* Returns a string version of alignment A, for display to a user. */
+const char *
+alignment_to_string (enum alignment a)
+{
+ switch (a)
+ {
+ case ALIGN_LEFT:
+ return _("Left");
+
+ case ALIGN_RIGHT:
+ return _("Right");
+
+ case ALIGN_CENTRE:
+ return _("Center");
+
+ default:
+ return "Invalid";
+ }
+}
+
/* Returns V's display alignment, which applies only to GUIs. */
enum alignment
var_get_alignment (const struct variable *v)
};
bool measure_is_valid (enum measure);
+const char *measure_to_string (enum measure);
+
enum measure var_get_measure (const struct variable *);
void var_set_measure (struct variable *, enum measure);
{
ALIGN_LEFT = 0,
ALIGN_RIGHT = 1,
- ALIGN_CENTRE = 2,
- n_ALIGN
+ ALIGN_CENTRE = 2
};
bool alignment_is_valid (enum alignment);
+const char *alignment_to_string (enum alignment);
+
enum alignment var_get_alignment (const struct variable *);
void var_set_alignment (struct variable *, enum alignment);
const struct variable *pv, gint c, GError **err)
{
PsppireDict *dict = vs->dictionary;
- static const gchar *const type_label[] =
- {
- N_("Numeric"),
- N_("Comma"),
- N_("Dot"),
- N_("Scientific"),
- N_("Date"),
- N_("Dollar"),
- N_("Custom"),
- N_("String")
- };
-
- enum {VT_NUMERIC, VT_COMMA, VT_DOT, VT_SCIENTIFIC, VT_DATE, VT_DOLLAR,
- VT_CUSTOM, VT_STRING};
const struct fmt_spec *format = var_get_print_format (pv);
return xstrdup (var_get_name (pv));
break;
case PSPPIRE_VAR_STORE_COL_TYPE:
- {
- switch ( format->type )
- {
- case FMT_F:
- return xstrdup (gettext (type_label[VT_NUMERIC]));
- break;
- case FMT_COMMA:
- return xstrdup (gettext (type_label[VT_COMMA]));
- break;
- case FMT_DOT:
- return xstrdup (gettext (type_label[VT_DOT]));
- break;
- case FMT_E:
- return xstrdup (gettext (type_label[VT_SCIENTIFIC]));
- break;
- case FMT_DATE:
- case FMT_EDATE:
- case FMT_SDATE:
- case FMT_ADATE:
- case FMT_JDATE:
- case FMT_QYR:
- case FMT_MOYR:
- case FMT_WKYR:
- case FMT_DATETIME:
- case FMT_TIME:
- case FMT_DTIME:
- case FMT_WKDAY:
- case FMT_MONTH:
- return xstrdup (gettext (type_label[VT_DATE]));
- break;
- case FMT_DOLLAR:
- return xstrdup (gettext (type_label[VT_DOLLAR]));
- break;
- case FMT_CCA:
- case FMT_CCB:
- case FMT_CCC:
- case FMT_CCD:
- case FMT_CCE:
- return xstrdup (gettext (type_label[VT_CUSTOM]));
- break;
- case FMT_A:
- return xstrdup (gettext (type_label[VT_STRING]));
- break;
- default:
- {
- char str[FMT_STRING_LEN_MAX + 1];
- g_warning ("Unknown format: `%s'\n",
- fmt_to_string (format, str));
- }
- break;
- }
- }
+ return xstrdup (fmt_gui_name (format->type));
break;
case PSPPIRE_VAR_STORE_COL_WIDTH:
{
const gint align = var_get_alignment (pv);
g_assert (align < n_ALIGNMENTS);
- return xstrdup (gettext (alignments[align]));
+ return xstrdup (alignment_to_string (align));
}
break;
case PSPPIRE_VAR_STORE_COL_MEASURE:
{
- return xstrdup (measure_to_string (pv, err));
+ return xstrdup (measure_to_string (var_get_measure (pv)));
}
break;
}
static const gchar none[] = N_("None");
-const gchar *
-measure_to_string (const struct variable *var, GError **err)
-{
- const gint measure = var_get_measure (var);
-
- g_assert (measure < n_MEASURES);
- return gettext (measures[measure]);
-}
-
-
gchar *
missing_values_to_string (const PsppireDict *dict, const struct variable *pv, GError **err)
{
extern const gchar *const measures[n_MEASURES + 1];
gchar *missing_values_to_string (const PsppireDict *dict, const struct variable *pv, GError **err);
-const gchar *measure_to_string (const struct variable *var, GError **err);
#endif
g_free (text);
g_string_append_printf (gstring, _("Measurement Level: %s\n"),
- measure_to_string (var, NULL));
+ measure_to_string (var_get_measure (var)));
/* Value Labels */