/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2006, 2008 Free Software Foundation
+ Copyright (C) 2006, 2008, 2009 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <data/data-out.h>
#include <data/variable.h>
-#include <gtksheet/psppire-sheetmodel.h>
+#include <ui/gui/sheet/psppire-sheetmodel.h>
#include <ui/gui/psppire-marshal.h>
#include <pango/pango-context.h>
static gchar * get_row_button_label (const PsppireSheetModel *model, gint row);
static gboolean get_row_sensitivity (const PsppireSheetModel *model, gint row);
+static gboolean get_row_overstrike (const PsppireSheetModel *model, gint row);
static void
iface->get_row_title = get_row_button_label;
iface->get_row_sensitivity = get_row_sensitivity;
+ iface->get_row_overstrike = get_row_overstrike;
}
#endif
}
-
-
static void
variable_changed_callback (GObject *obj, gint var_num, gpointer data)
{
+#if AXIS_TRANSITION
PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
-#if AXIS_TRANSITION
psppire_sheet_column_columns_changed (PSPPIRE_SHEET_COLUMN (store),
var_num, 1);
-
psppire_sheet_model_range_changed (PSPPIRE_SHEET_MODEL (store),
-1, var_num,
-1, var_num);
{
gboolean result;
gint val_cnt, v;
- struct ccase cc;
+ struct ccase *cc;
g_return_val_if_fail (ds, FALSE);
val_cnt = datasheet_get_column_cnt (ds->datasheet) ;
g_return_val_if_fail (posn <= psppire_data_store_get_case_count (ds), FALSE);
- case_create (&cc, val_cnt);
+ cc = case_create (val_cnt);
- memset ( case_data_rw_idx (&cc, 0), 0, val_cnt * MAX_SHORT_STRING);
+ memset ( case_data_rw_idx (cc, 0), 0, val_cnt * MAX_SHORT_STRING);
for (v = 0 ; v < psppire_dict_get_var_cnt (ds->dict) ; ++v)
{
if ( var_is_alpha (pv))
continue;
- case_data_rw (&cc, pv)->f = SYSMIS;
+ case_data_rw (cc, pv)->f = SYSMIS;
}
- result = psppire_data_store_insert_case (ds, &cc, posn);
+ result = psppire_data_store_insert_case (ds, cc, posn);
- case_destroy (&cc);
+ case_unref (cc);
return result;
}
psppire_data_store_set_string (PsppireDataStore *store,
const gchar *text, glong row, glong col)
{
+ gchar *s;
glong n_cases;
const struct variable *pv = psppire_dict_get_variable (store->dict, col);
if ( NULL == pv)
if (row == n_cases)
psppire_data_store_insert_new_case (store, row);
+ s = utf8_to_pspp_locale (text, -1, NULL);
+
psppire_data_store_data_in (store, row,
- var_get_case_index (pv), ss_cstr (text),
+ var_get_case_index (pv), ss_cstr (s),
var_get_write_format (pv));
+ free (s);
psppire_sheet_model_range_changed (PSPPIRE_SHEET_MODEL (store), row, col, row, col);
\f
-/* Fills C with the CASENUMth case.
- Returns true on success, false otherwise.
+/* Returns the CASENUMth case, or a null pointer on failure.
*/
-gboolean
+struct ccase *
psppire_data_store_get_case (const PsppireDataStore *ds,
- casenumber casenum,
- struct ccase *c)
+ casenumber casenum)
{
g_return_val_if_fail (ds, FALSE);
g_return_val_if_fail (ds->datasheet, FALSE);
- return datasheet_get_row (ds->datasheet, casenum, c);
+ return datasheet_get_row (ds->datasheet, casenum);
}
struct ccase *cc,
casenumber posn)
{
- struct ccase tmp;
bool result ;
g_return_val_if_fail (ds, FALSE);
g_return_val_if_fail (ds->datasheet, FALSE);
- case_clone (&tmp, cc);
- result = datasheet_insert_rows (ds->datasheet, posn, &tmp, 1);
+ case_ref (cc);
+ result = datasheet_insert_rows (ds->datasheet, posn, &cc, 1);
if ( result )
{
return TRUE;
}
+
+static gboolean
+get_row_overstrike (const PsppireSheetModel *model, gint row)
+{
+ union value val;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
+
+ const struct dictionary *dict = ds->dict->dict;
+
+ const struct variable *filter = dict_get_filter (dict);
+
+ if ( row < 0 || row >= datasheet_get_row_cnt (ds->datasheet))
+ return FALSE;
+
+ if ( ! filter)
+ return FALSE;
+
+ g_assert (var_is_numeric (filter));
+
+ if ( ! datasheet_get_value (ds->datasheet, row,
+ var_get_case_index (filter),
+ &val, 0) )
+ return FALSE;
+
+
+ return (val.f == 0.0);
+}