X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-variable.c;h=0b0c24915081d916a84174a0a9626b0b21d6174c;hb=8acca2de53c1852f38726f70fc6516b34732a79f;hp=3fa71ea30b5330fe194df1e6fd8e4745f286b527;hpb=87b6d42a2d540b92baf0db8fe28657eda747b3b0;p=pspp diff --git a/src/ui/gui/psppire-variable.c b/src/ui/gui/psppire-variable.c index 3fa71ea30b..0b0c249150 100644 --- a/src/ui/gui/psppire-variable.c +++ b/src/ui/gui/psppire-variable.c @@ -1,6 +1,6 @@ /* PSPPIRE --- A Graphical User Interface for PSPP - Copyright (C) 2004 Free Software Foundation + Copyright (C) 2004, 2006 Free Software Foundation Written by John Darrington This program is free software; you can redistribute it and/or modify @@ -24,6 +24,9 @@ #include #include #include +#include + +#include #include "psppire-variable.h" #include "psppire-dict.h" @@ -115,8 +118,21 @@ psppire_variable_set_width(struct PsppireVariable *pv, gint width) fmt.w = width; if ( pv->v->type == ALPHA ) + { + gint old_var_cnt , new_var_cnt ; + + if ( pv->v->width == 0 ) + old_var_cnt = 1; + else + old_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING); + + new_var_cnt = DIV_RND_UP(width, MAX_SHORT_STRING); pv->v->width = width; + psppire_dict_resize_variable(pv->dict, pv, + old_var_cnt, new_var_cnt); + } + return psppire_variable_set_format(pv, &fmt); } @@ -124,15 +140,30 @@ psppire_variable_set_width(struct PsppireVariable *pv, gint width) gboolean psppire_variable_set_type(struct PsppireVariable *pv, int type) { + gint old_var_cnt , new_var_cnt ; + g_return_val_if_fail(pv, FALSE); g_return_val_if_fail(pv->dict, FALSE); g_return_val_if_fail(pv->v, FALSE); pv->v->type = type; + if ( pv->v->width == 0 ) + old_var_cnt = 1; + else + old_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING); + if ( type == NUMERIC ) pv->v->width = 0; + if ( pv->v->width == 0 ) + new_var_cnt = 1; + else + new_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING); + + psppire_dict_resize_variable(pv->dict, pv, + old_var_cnt, new_var_cnt); + psppire_dict_var_changed(pv->dict, pv->v->index); return TRUE; } @@ -145,17 +176,17 @@ psppire_variable_set_format(struct PsppireVariable *pv, struct fmt_spec *fmt) g_return_val_if_fail(pv->dict, FALSE); g_return_val_if_fail(pv->v, FALSE); - if ( check_output_specifier(fmt, false) - && - check_specifier_type(fmt, pv->v->type, false) - && - check_specifier_width(fmt, pv->v->width, false) - ) + msg_disable (); + if ( fmt_check_output(fmt) + && fmt_check_type_compat (fmt, pv->v->type) + && fmt_check_width_compat (fmt, pv->v->width)) { + msg_enable (); pv->v->write = pv->v->print = *fmt; psppire_dict_var_changed(pv->dict, pv->v->index); return TRUE; } + msg_enable (); return FALSE; }