33 |
static GdkColor colour_enabled; |
static GdkColor colour_enabled; |
34 |
static GdkColor colour_disabled; |
static GdkColor colour_disabled; |
35 |
|
|
36 |
extern PSPP_Dict *pspp_dictionary ; |
static PSPP_Dict *pspp_dictionary ; |
37 |
|
|
38 |
|
|
39 |
/* Enable/Disable columns in the data sheet |
/* Enable/Disable columns in the data sheet |
65 |
} |
} |
66 |
|
|
67 |
|
|
68 |
|
/* Return the width that an 'M' character would occupy when typeset at |
69 |
|
row, col */ |
70 |
|
guint |
71 |
|
M_width(GtkSheet *sheet, gint row, gint col) |
72 |
|
{ |
73 |
|
GtkSheetCellAttr attributes; |
74 |
|
|
75 |
|
gtk_sheet_get_attributes(sheet, row, col, &attributes); |
76 |
|
|
77 |
|
PangoRectangle rect; |
78 |
|
PangoLayout *layout; |
79 |
|
|
80 |
|
layout = gtk_widget_create_pango_layout (GTK_WIDGET(sheet), "M"); |
81 |
|
pango_layout_set_font_description (layout, |
82 |
|
attributes.font_desc); |
83 |
|
|
84 |
|
pango_layout_get_extents (layout, NULL, &rect); |
85 |
|
|
86 |
|
g_object_unref(G_OBJECT(layout)); |
87 |
|
return PANGO_PIXELS(rect.width); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
/* Return the number of pixels corresponding to a column of |
92 |
|
WIDTH characters */ |
93 |
|
static guint |
94 |
|
columnWidthToPixels(GtkSheet *sheet, gint column, guint width) |
95 |
|
{ |
96 |
|
return (M_width(sheet, 1, column) * width); |
97 |
|
|
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
/* Update COLUMN of the data sheet */ |
/* Update COLUMN of the data sheet */ |
103 |
static gint |
static gint |
109 |
|
|
110 |
struct variable *var = pspp_dict_get_var(dict, column); |
struct variable *var = pspp_dict_get_var(dict, column); |
111 |
|
|
112 |
gtk_sheet_set_column_width (sheet, column, 12 * var->display_width ); |
gtk_sheet_set_column_width (sheet, column, |
113 |
|
columnWidthToPixels(sheet, column, |
114 |
|
var->display_width)); |
115 |
|
|
116 |
|
|
117 |
gtk_sheet_column_button_add_label (sheet, column, var->name); |
gtk_sheet_column_button_add_label (sheet, column, var->name); |
118 |
|
|
119 |
psppire_data_sheet_col_set_enable(sheet, column, column, TRUE); |
psppire_data_sheet_col_set_enable(sheet, column, column, TRUE); |
136 |
{ |
{ |
137 |
struct variable *var = pspp_dict_get_var(dict, col); |
struct variable *var = pspp_dict_get_var(dict, col); |
138 |
|
|
139 |
gtk_sheet_set_column_width (sheet, col, 12 * var->display_width ); |
gtk_sheet_set_column_width (sheet, col, |
140 |
|
columnWidthToPixels(sheet, col, |
141 |
|
var->display_width)); |
142 |
|
|
143 |
gtk_sheet_column_button_add_label (sheet, col, var->name); |
gtk_sheet_column_button_add_label (sheet, col, var->name); |
144 |
psppire_data_sheet_col_set_enable(sheet, col, col, TRUE); |
psppire_data_sheet_col_set_enable(sheet, col, col, TRUE); |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
/* Clear the entire sheet */ |
187 |
|
void |
188 |
|
psppire_data_sheet_clear(GtkSheet *sheet) |
189 |
|
{ |
190 |
|
/* get rid of all the cells */ |
191 |
|
gtk_sheet_range_clear (sheet, NULL); |
192 |
|
|
193 |
|
repopulate_columns(sheet, pspp_dictionary, 0, |
194 |
|
gtk_sheet_get_columns_count(sheet) - 1); |
195 |
|
|
196 |
|
|
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
/* Associate a dictionary with the data sheet */ |
202 |
|
void |
203 |
|
psppire_data_sheet_set_dictionary(GtkWidget *sheet, PSPP_Dict *d) |
204 |
|
{ |
205 |
|
pspp_dictionary = d; |
206 |
|
|
207 |
|
g_signal_connect(pspp_dictionary, "variable_changed", |
208 |
|
G_CALLBACK(update_variable), sheet); |
209 |
|
|
210 |
|
g_signal_connect(pspp_dictionary, "variable_deleted", |
211 |
|
G_CALLBACK(remove_variable), sheet); |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
GtkWidget* |
GtkWidget* |
228 |
|
|
229 |
sheet = gtk_sheet_new(rows, columns, "data sheet"); |
sheet = gtk_sheet_new(rows, columns, "data sheet"); |
230 |
|
|
|
g_signal_connect(pspp_dictionary, "variable_changed", |
|
|
G_CALLBACK(update_variable), sheet); |
|
|
|
|
|
g_signal_connect(pspp_dictionary, "variable_deleted", |
|
|
G_CALLBACK(remove_variable), sheet); |
|
|
|
|
|
|
|
231 |
g_assert(gdk_color_parse("dark slate gray",&colour_disabled)); |
g_assert(gdk_color_parse("dark slate gray",&colour_disabled)); |
232 |
g_assert(gdk_color_parse("white",&colour_enabled)); |
g_assert(gdk_color_parse("white",&colour_enabled)); |
233 |
|
|